Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Déplacer la notion de volant du beneficiary vers le membership #918

Merged
merged 4 commits into from
Aug 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions app/DoctrineMigrations/Version20230729100654.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare(strict_types=1);

namespace Application\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20230729100654 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}

public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('ALTER TABLE membership ADD flying TINYINT(1) DEFAULT \'0\' NOT NULL');
$this->addSql('UPDATE membership LEFT OUTER JOIN beneficiary ON beneficiary.id = membership.main_beneficiary_id SET membership.flying=beneficiary.flying WHERE beneficiary.flying = 1');
$this->addSql('ALTER TABLE beneficiary DROP flying');
}

public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('ALTER TABLE beneficiary ADD flying TINYINT(1) DEFAULT \'0\' NOT NULL');
$this->addSql('ALTER TABLE membership DROP flying');
}
}
10 changes: 0 additions & 10 deletions app/Resources/views/beneficiary/_partial/info.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,6 @@
{% endif %})
{% endif %}
</div>
{% if use_fly_and_fixed %}
<div class="col s12">
<i class="material-icons tiny">accessibility</i>
{% if beneficiary.flying %}
<div class="chip green-text">Equipe volante</div>
{% else %}
<div class="chip green-text">Equipe fixe</div>
{% endif %}
</div>
{% endif %}
{% if beneficiary.formations | length %}
<div class="col s12">
<i class="material-icons tiny">assignment_ind</i>
Expand Down
186 changes: 102 additions & 84 deletions app/Resources/views/member/show.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,61 @@
{% endblock %}

{% block content %}
<h4>
{% if member.withdrawn %}<del>{% endif %}
Membre #{{ member.memberNumber }}{% if member.withdrawn %}</del>{% endif %}
{% if member.mainBeneficiary and not member.mainBeneficiary.user.isEnabled %}
<i class="material-icons" title="Compte pas encore activé">{{ user_account_not_enabled_material_icon }}</i>
{% endif %}
{% if member.isCurrentlyExemptedFromShifts() %}
<i class="material-icons" title="Compte exempté">{{member_exempted_material_icon }}</i>
{% endif %}
{% if member.frozen %}
<i class="material-icons" title="Compte gelé">{{ member_frozen_material_icon }}</i>
{% endif %}
{% if member.withdrawn %}
<i class="material-icons" title="Compte fermé">{{ member_withdrawn_material_icon }}</i>
{% elseif not member | uptodate %}
<i class="material-icons" title="Compte en attente d'adhésion">{{ member_registration_missing_material_icon }}</i>
{% endif %}
</h4>
<div class="row valign-wrapper" style="flex-wrap: wrap;">
<div class="col s12 m5">
<h4>
{% if member.withdrawn %}<del>{% endif %}
Membre #{{ member.memberNumber }}{% if member.withdrawn %}</del>{% endif %}
{% if member.mainBeneficiary and not member.mainBeneficiary.user.isEnabled %}
<i class="material-icons" title="Compte pas encore activé">{{ user_account_not_enabled_material_icon }}</i>
{% endif %}
{% if member.isCurrentlyExemptedFromShifts() %}
<i class="material-icons" title="Compte exempté">{{member_exempted_material_icon }}</i>
{% endif %}
{% if member.frozen %}
<i class="material-icons" title="Compte gelé">{{ member_frozen_material_icon }}</i>
{% endif %}
{% if member.withdrawn %}
<i class="material-icons" title="Compte fermé">{{ member_withdrawn_material_icon }}</i>
{% elseif not member | uptodate %}
<i class="material-icons" title="Compte en attente d'adhésion">{{ member_registration_missing_material_icon }}</i>
{% endif %}
</h4>
</div>
<div class="col s12 m7 right-align">
<!-- Fermer le compte -->
{% if is_granted("ROLE_USER_MANAGER") and ((member.withdrawn and is_granted("open",member)) or (not member.withdrawn and is_granted("close",member))) %}
<a href="#withdrawn-member-confirmation-modal" class="modal-trigger waves-effect waves-light btn btn-small {% if not member.withdrawn %}red{% else %}teal{% endif %}">
{% if not member.withdrawn %}
<i class="material-icons left">close</i>Fermer <span class="hide-on-med-and-down">le compte</span>
{% else %}
<i class="material-icons left">check</i>Ré-ouvrir <span class="hide-on-med-and-down">le compte</span>
{% endif %}
</a>
{% endif %}
<!-- Passer fixe ou volant -->
{% if use_fly_and_fixed and not member.withdrawn and is_granted("ROLE_USER_MANAGER") and is_granted("flying",member) %}
<a href="#flying-member-confirmation-modal" class="modal-trigger waves-effect waves-light btn btn-small teal">
{% if not member.flying %}
<i class="material-icons left">cached</i><span class="hide-on-med-and-down">Passer en</span> volant
{% else %}
<i class="material-icons left">cached</i><span class="hide-on-med-and-down">Passer en</span> fixe
{% endif %}
</a>
{% endif %}
</div>
<div class="col s12">
{% if member.withdrawn and member.withdrawnDate %}
Compte fermé le <i>{{ member.withdrawnDate | date_fr }}</i>
{% if member.withdrawnBy %}
par {% include "admin/member/_partial/member_or_user_link.html.twig" with { user: member.withdrawnBy, target_blank: true } %}.
{% endif %}
{% elseif use_fly_and_fixed and not member.withdrawn %}
Compte {% if member.flying %}volant{% else %}fixe{% endif %}
{% endif %}
</div>
</div>


<!-- Détails sur le(s) bénéficiaire(s) -->
{% if member.beneficiaries | length %}
Expand Down Expand Up @@ -314,72 +351,6 @@
</li>
{% endif %}

<!-- Fermer le compte -->
{% if is_granted("ROLE_USER_MANAGER") and is_granted("close",member) %}
<li id="close">
<div class="collapsible-header {% if frontend_cookie and frontend_cookie.user_show is defined and frontend_cookie.user_show.close_open is defined and frontend_cookie.user_show.close_open %}active{% endif %}">
<i class="material-icons">close</i>{% if member.withdrawn %}Ré-ouvrir le compte{% else %}Fermer le compte{% endif %}
</div>
<div class="collapsible-body white">
{% if not member.withdrawn %}
<a href="#close-member-confirmation-modal" class="modal-trigger waves-effect waves-light btn red">
<i class="material-icons left">close</i>Fermer le compte
</a>
{{ form_start(close_form) }}
<div id="close-member-confirmation-modal" class="modal">
<div class="modal-content">
<h5>
<i class="material-icons left small">remove_circle_outline</i>Fermeture du compte membre
</h5>
<p>Attention, vous êtes sur le point de fermer le compte du membre.</p>
<ul>
{% if use_fly_and_fixed %}
<li>Ce membre a {{ period_positions | length }} créneau{% if period_positions | length > 1 %}x{% endif %} fixe.</li>
{% endif %}
<li>Ce membre a {{ in_progress_and_upcoming_shifts | length }} créneau{% if in_progress_and_upcoming_shifts | length > 1 %}x{% endif %} réservé à venir.</li>
</ul>
</div>
<div class="modal-footer">
<a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat green-text">Retour à la raison</a>
<button type="submit" class="btn waves-effect waves-light orange">
<i class="material-icons left">check</i>Je sais ce que je fais !
</button>
</div>
</div>
{{ form_end(close_form) }}
{% else %}
{% if member.withdrawnDate %}
<p>
Compte fermé le <i>{{ member.withdrawnDate | date_fr }}</i>
{% if member.withdrawnBy %}
par {% include "admin/member/_partial/member_or_user_link.html.twig" with { user: member.withdrawnBy, target_blank: true } %}.
{% endif %}
</p>
{% endif %}
<a href="#open-member-confirmation-modal" class="modal-trigger waves-effect waves-light btn teal">
<i class="material-icons left">check</i>Ré-ouvrir le compte
</a>
{{ form_start(open_form) }}
<div id="open-member-confirmation-modal" class="modal">
<div class="modal-content">
<h5>
<i class="material-icons left small">info_outline</i>Ré-ouverture du compte membre
</h5>
<p>Attention, vous êtes sur le point de ré-ouvrir le compte du membre.</p>
</div>
<div class="modal-footer">
<a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat green-text">Retour à la raison</a>
<button type="submit" class="btn waves-effect waves-light orange">
<i class="material-icons left">check</i>Je sais ce que je fais !
</button>
</div>
</div>
{{ form_end(open_form) }}
{% endif %}
</div>
</li>
{% endif %}

<!-- Rôles -->
{% if is_granted("ROLE_ADMIN") %}
<li id="super">
Expand Down Expand Up @@ -429,6 +400,53 @@
</li>
{% endif %}
</ul>

<div id="withdrawn-member-confirmation-modal" class="modal">
<div class="modal-content">
<h5>
<i class="material-icons left small">remove_circle_outline</i>{% if member.withdrawn %}Ré-ouverture{% else %}Fermeture{% endif %} du compte membre
</h5>
<p>Attention, vous êtes sur le point de {% if member.withdrawn %}ré-ouvrir{% else %}fermer{% endif %} le compte du membre.</p>
{% if not member.withdrawn %}
<ul>
{% if use_fly_and_fixed %}
<li>Ce membre a {{ period_positions | length }} créneau{% if period_positions | length > 1 %}x{% endif %} fixe.</li>
{% endif %}
<li>Ce membre a {{ in_progress_and_upcoming_shifts | length }} créneau{% if in_progress_and_upcoming_shifts | length > 1 %}x{% endif %} réservé à venir.</li>
</ul>
{% endif %}
</div>
<div class="modal-footer">
{{ form_start(withdrawn_form) }}
<a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat green-text">Retour à la raison</a>
<button type="submit" class="btn waves-effect waves-light orange">
<i class="material-icons left">check</i>Je sais ce que je fais !
</button>
{{ form_end(withdrawn_form) }}
</div>
</div>

<div id="flying-member-confirmation-modal" class="modal">
<div class="modal-content">
<h5>
<i class="material-icons left small">remove_circle_outline</i>Passage du compte en {% if member.flying %}fixe{% else %}volant{% endif %}
</h5>
<p>Attention, vous êtes sur le point de passer le compte du membre en {% if member.flying %}fixe{% else %}volant{% endif %}.</p>
{% if not member.flying %}
<ul>
<li>Ce membre a {{ period_positions | length }} créneau{% if period_positions | length > 1 %}x{% endif %} fixe.</li>
</ul>
{% endif %}
</div>
<div class="modal-footer">
{{ form_start(flying_form) }}
<a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat green-text">Retour à la raison</a>
<button type="submit" class="btn waves-effect waves-light orange">
<i class="material-icons left">check</i>OK
</button>
{{ form_end(flying_form) }}
</div>
</div>
{% endblock %}

{% block javascripts %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
Réservé
</div>
{% else %}
{% set warning = beneficiary_service.hasWarningStatus(shifter) %}
{% set warning = membership_service.hasWarningStatus(shifter.membership) %}
<a href="{{ path('member_show', { 'member_number': shifter.membership.memberNumber }) }}" target="_blank"
class="black-text tooltipped editable-box truncate" data-position="bottom"
data-tooltip="{{ shifter | print_with_number_and_status_icon | raw }} &#013;&#010; ({{ formation }})">
Expand Down
1 change: 0 additions & 1 deletion src/AppBundle/Command/ImportUsersCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
$dispatcher->dispatch(BeneficiaryCreatedEvent::NAME, new BeneficiaryCreatedEvent($beneficiary));

$beneficiary->setEmail($email);
$beneficiary->setFlying(false);

$em->persist($beneficiary);
}
Expand Down
1 change: 0 additions & 1 deletion src/AppBundle/Controller/MailController.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ public function sendAction(Request $request, \Swift_Mailer $mailer)
$user = $em->getRepository(User::class)->findOneBy(array('email' => $nonMember));
if (is_object($user)) {
$fake_beneficiary = new Beneficiary();
$fake_beneficiary->setFlying(false);
$fake_beneficiary->setUser($user);
$fake_beneficiary->setFirstname($user->getUsername());
$fake_beneficiary->setLastname(' ');
Expand Down
Loading
Loading