From 142871f852c717319608de43d954180f17e5ed66 Mon Sep 17 00:00:00 2001 From: MichiK Date: Sun, 3 Dec 2017 04:05:02 +0100 Subject: Add a config option for maximum signup in advance We now have `signup_advance_hours` in the configuration that only allows signup for shifts so many hours in the future. A notice is displayed in the shift view for shifts in the far future, together with an info notice on when signup for that shift will be possible. In addition, we now have a new shift state `NOT_YET` for this purpose so we do not have to abuse `SHIFT_ENDED` anymore for `signup_requires_arrival` as well. --- includes/view/ShiftCalendarShiftRenderer.php | 5 +++++ includes/view/Shifts_view.php | 7 +++++++ 2 files changed, 12 insertions(+) (limited to 'includes/view') diff --git a/includes/view/ShiftCalendarShiftRenderer.php b/includes/view/ShiftCalendarShiftRenderer.php index 3f427ea0..ac206ad0 100644 --- a/includes/view/ShiftCalendarShiftRenderer.php +++ b/includes/view/ShiftCalendarShiftRenderer.php @@ -74,6 +74,7 @@ class ShiftCalendarShiftRenderer return 'primary'; case ShiftSignupState::NOT_ARRIVED: + case ShiftSignupState::NOT_YET: case ShiftSignupState::SHIFT_ENDED: return 'default'; @@ -203,6 +204,10 @@ class ShiftCalendarShiftRenderer $entry_list[] = $inner_text . ' (' . __('please arrive for signup') . ')'; break; + case ShiftSignupState::NOT_YET: + $entry_list[] = $inner_text . '(' . _('not yet') . ')'; + break; + case ShiftSignupState::ANGELTYPE: if ($angeltype['restricted'] == 1) { // User has to be confirmed on the angeltype first diff --git a/includes/view/Shifts_view.php b/includes/view/Shifts_view.php index 2e7bfa4b..01dc1561 100644 --- a/includes/view/Shifts_view.php +++ b/includes/view/Shifts_view.php @@ -129,6 +129,13 @@ function Shift_view($shift, $shifttype, $room, $angeltypes_source, ShiftSignupSt $content[] = info(__('You are signed up for this shift.'), true); } + if (config('signup_advance_hours') && $shift['start'] > time() + config('signup_advance_hours') * 3600) { + $content[] = info(sprintf( + _('This shift is in the far future and becomes available for signup at %s.'), + date(_('Y-m-d') . ' H:i', $shift['start'] - config('signup_advance_hours') * 3600) + ), true); + } + $buttons = []; if ($shift_admin || $admin_shifttypes || $admin_rooms) { $buttons = [ -- cgit v1.2.3-54-g00ecf