Skip to content

Commit

Permalink
Gel / Fermeture : indiquer dans la modale de confirmation les créneau…
Browse files Browse the repository at this point in the history
…x à venir du membre (#640)

* Before closing account, display period_position & upcoming_shifts counts

* Before pausing account, display period_position & upcoming_shifts counts

* Pluralize créneaux depending on list length
  • Loading branch information
raphodn authored Nov 23, 2022
1 parent 55d8a6a commit 545d4b5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/Resources/views/Profile/show_content.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
{% if display_swipe_cards_settings %}
<li>
<div class="collapsible-header">
<i class="material-icons">credit_card</i>Badge{% if beneficiary.swipeCards | length > 1%}s{% endif %}
<i class="material-icons">credit_card</i>Badge{% if beneficiary.swipeCards | length > 1 %}s{% endif %}
</div>
<div class="collapsible-body">
{% include "member/_partial/swipe_card.html.twig" with { member: member, showBadgeImage: true } %}
Expand Down
14 changes: 13 additions & 1 deletion app/Resources/views/member/show.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,14 @@
<h5>
<i class="material-icons left small">pause_circle_filled</i>Gel immédiat du compte
</h5>
<p>Attention, le gel immédiat sera effectif dés aujourd'hui, interdisant l'accès au magasin</p>
<p>Attention, le gel immédiat sera effectif dés aujourd'hui, interdisant l'accès au magasin.</p>
<p>De plus, à la fin du cycle, les heures effectuées ne seront pas décomptées.</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 %} à 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>
Expand Down Expand Up @@ -292,6 +298,12 @@
<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 %} à 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>
Expand Down
1 change: 1 addition & 0 deletions src/AppBundle/Controller/MembershipController.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ public function showAction(Membership $member)
'delete_form' => $deleteForm->createView(),
'time_log_form' => $timeLogForm->createView(),
'period_positions' => $period_positions,
'in_progress_and_upcoming_shifts' => $member->getInProgressAndUpcomingShifts(),
));
}

Expand Down
16 changes: 15 additions & 1 deletion src/AppBundle/Entity/Membership.php
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,8 @@ public function getCycleShiftsDuration($cycleOffset = 0, $excludeDismissed = fal

/**
* Get all shifts for all beneficiaries
* @param bool $excludeDismissed
* @return ArrayCollection|\Doctrine\Common\Collections\Collection
*/
public function getAllShifts($excludeDismissed = false)
{
Expand All @@ -504,6 +506,19 @@ public function getAllShifts($excludeDismissed = false)
}
}

/**
* Get all in progress & upcoming shifts for all beneficiaries
* @param bool $excludeDismissed
* @return ArrayCollection|\Doctrine\Common\Collections\Collection
*/
public function getInProgressAndUpcomingShifts($excludeDismissed = false)
{
$now = new DateTime('now');
return $this->getAllShifts($excludeDismissed)->filter(function($shift) use ($now) {
return $shift->getStart() > $now;
});
}

/**
* Get all reserved shifts for all beneficiaries
*/
Expand All @@ -518,7 +533,6 @@ public function getReservedShifts()
return $shifts;
}


/**
* Get shifts of a specific cycle
* @param $cycleOffset int to chose a cycle (0 for current cycle, 1 for next, -1 for previous)
Expand Down

0 comments on commit 545d4b5

Please sign in to comment.