introduce new shift signup state for not arrived angels

This commit is contained in:
msquare 2017-12-20 23:05:46 +01:00
parent 7a3bdda483
commit 2c04e35bed
4 changed files with 17 additions and 3 deletions

View File

@ -191,6 +191,8 @@ function shift_entry_error_message(ShiftSignupState $shift_signup_state) {
error(_('This shift is already occupied.')); error(_('This shift is already occupied.'));
} elseif ($shift_signup_state->getState() == ShiftSignupState::SHIFT_ENDED) { } elseif ($shift_signup_state->getState() == ShiftSignupState::SHIFT_ENDED) {
error(_('This shift ended already.')); error(_('This shift ended already.'));
} elseif ($shift_signup_state->getState() == ShiftSignupState::NOT_ARRIVED) {
error(_('You are not marked as arrived.'));
} elseif ($shift_signup_state->getState() == ShiftSignupState::SIGNED_UP) { } elseif ($shift_signup_state->getState() == ShiftSignupState::SIGNED_UP) {
error(_('You are signed up for this shift.')); error(_('You are signed up for this shift.'));
} }

View File

@ -42,7 +42,12 @@ class ShiftSignupState
* User is already signed up * User is already signed up
*/ */
const SIGNED_UP = 'SIGNED_UP'; const SIGNED_UP = 'SIGNED_UP';
/**
* User has to be arrived
*/
const NOT_ARRIVED = 'NOT_ARRIVED';
/** @var string */ /** @var string */
private $state; private $state;
@ -83,6 +88,7 @@ class ShiftSignupState
private function valueForState($state) private function valueForState($state)
{ {
switch ($state) { switch ($state) {
case ShiftSignupState::NOT_ARRIVED:
case ShiftSignupState::SHIFT_ENDED: case ShiftSignupState::SHIFT_ENDED:
return 100; return 100;

View File

@ -312,7 +312,7 @@ function Shift_signup_allowed_angel(
$free_entries = Shift_free_entries($needed_angeltype, $shift_entries); $free_entries = Shift_free_entries($needed_angeltype, $shift_entries);
if (config('signup_requires_arrival') && !$user['Gekommen']) { if (config('signup_requires_arrival') && !$user['Gekommen']) {
return new ShiftSignupState(ShiftSignupState::SHIFT_ENDED, $free_entries); return new ShiftSignupState(ShiftSignupState::NOT_ARRIVED, $free_entries);
} }
if ($user_shifts == null) { if ($user_shifts == null) {

View File

@ -67,6 +67,7 @@ class ShiftCalendarShiftRenderer
case ShiftSignupState::SIGNED_UP: case ShiftSignupState::SIGNED_UP:
return 'primary'; return 'primary';
case ShiftSignupState::NOT_ARRIVED:
case ShiftSignupState::SHIFT_ENDED: case ShiftSignupState::SHIFT_ENDED:
return 'default'; return 'default';
@ -180,11 +181,16 @@ class ShiftCalendarShiftRenderer
_('Sign up'), 'btn-xs btn-primary' _('Sign up'), 'btn-xs btn-primary'
); );
break; break;
case ShiftSignupState::SHIFT_ENDED: case ShiftSignupState::SHIFT_ENDED:
// No link and add a text hint, when the shift ended // No link and add a text hint, when the shift ended
$entry_list[] = $inner_text . ' (' . _('ended') . ')'; $entry_list[] = $inner_text . ' (' . _('ended') . ')';
break; break;
case ShiftSignupState::NOT_ARRIVED:
// No link and add a text hint, when the shift ended
$entry_list[] = $inner_text . ' (' . _('not arrived') . ')';
break;
case ShiftSignupState::ANGELTYPE: case ShiftSignupState::ANGELTYPE:
if ($angeltype['restricted'] == 1) { if ($angeltype['restricted'] == 1) {