diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php index ff2c9dd2..5c6041c1 100644 --- a/includes/model/Shifts_model.php +++ b/includes/model/Shifts_model.php @@ -554,7 +554,7 @@ function Shift_signout_allowed(Shift $shift, AngelType $angeltype, $signout_user return true; } - if ($signout_user_id == $user->id && $shift->start->timestamp > time() + config('last_unsubscribe') * 3600) { + if ($signout_user_id == $user->id && $shift->start->subHours(config('last_unsubscribe')) > Carbon::now()) { return true; } diff --git a/includes/sys_template.php b/includes/sys_template.php index 362824ad..aab1e530 100644 --- a/includes/sys_template.php +++ b/includes/sys_template.php @@ -352,7 +352,7 @@ function render_table($columns, $rows, $data = true) * @param string $id * @return string */ -function button($href, $label, $class = '', $id = '', $title = '') +function button($href, $label, $class = '', $id = '', $title = '', $disabled = false) { if (!Str::contains(str_replace(['btn-sm', 'btn-xl'], '', $class), 'btn-')) { $class = 'btn-secondary' . ($class ? ' ' . $class : ''); @@ -361,7 +361,7 @@ function button($href, $label, $class = '', $id = '', $title = '') $idAttribute = $id ? 'id="' . $id . '"' : ''; return '' . $label . ''; + . '" class="btn ' . $class . ($disabled ? ' disabled' : '') . '" title="' . $title . '">' . $label . ''; } /** @@ -387,9 +387,9 @@ function button_checkbox_selection($name, $label, $value) * * @return string */ -function button_icon($href, $icon, $class = '', $title = '') +function button_icon($href, $icon, $class = '', $title = '', $disabled = false) { - return button($href, icon($icon), $class, '', $title); + return button($href, icon($icon), $class, '', $title, $disabled); } /** diff --git a/includes/view/Shifts_view.php b/includes/view/Shifts_view.php index 0e7deba7..a49ed005 100644 --- a/includes/view/Shifts_view.php +++ b/includes/view/Shifts_view.php @@ -1,5 +1,6 @@ getState() === ShiftSignupStatus::SIGNED_UP) { - $content[] = info(__('You are signed up for this shift.'), true); + $content[] = info(__('You are signed up for this shift.') + . (($shift->start->subHours(config('last_unsubscribe')) < Carbon::now() && $shift->end > Carbon::now()) + ? ' ' . __('shift.sign_out.hint', [config('last_unsubscribe')]) + : ''), true); } if (config('signup_advance_hours') && $shift->start->timestamp > time() + config('signup_advance_hours') * 3600) { @@ -325,7 +329,13 @@ function Shift_view_render_shift_entry(ShiftEntry $shift_entry, $user_shift_admi } $angeltype = $shift_entry->angelType; $disabled = Shift_signout_allowed($shift, $angeltype, $shift_entry->user_id) ? '' : ' btn-disabled'; - $entry .= button_icon(shift_entry_delete_link($shift_entry), 'trash', 'btn-sm btn-danger' . $disabled, __('form.delete')); + $entry .= button_icon( + shift_entry_delete_link($shift_entry), + 'trash', + 'btn-sm btn-danger' . $disabled, + __('form.delete'), + !Shift_signout_allowed($shift, $angeltype, $shift_entry->user_id) + ); $entry .= ''; } return $entry; diff --git a/resources/assets/themes/base.scss b/resources/assets/themes/base.scss index c9018032..f0abc88c 100644 --- a/resources/assets/themes/base.scss +++ b/resources/assets/themes/base.scss @@ -102,6 +102,10 @@ a .icon-icon_angel { background-color: $link-color; } +a .disabled { + pointer-events: none; +} + .navbar .icon-icon_angel { background-color: $nav-link-disabled-color; } diff --git a/resources/lang/de_DE/default.po b/resources/lang/de_DE/default.po index 652edbc1..d3c9b65e 100644 --- a/resources/lang/de_DE/default.po +++ b/resources/lang/de_DE/default.po @@ -2095,3 +2095,7 @@ msgstr "Es wurde noch kein Schichttyp erstellt. Ohne können keine Schichten ers msgid "admin_shifts.no_angeltypes" msgstr "Es wurde noch kein Engeltyp erstellt. Ohne können keine Schichten erstellt werden." + +msgid "shift.sign_out.hint" +msgstr "Du kannst dich bis %s Stunden vor dem Start der Schicht austragen. " +"Wenn du nicht zu deiner Schicht kommen kannst, lass dich vom Himmel austragen." diff --git a/resources/lang/en_US/default.po b/resources/lang/en_US/default.po index 30dd04e2..e45e758a 100644 --- a/resources/lang/en_US/default.po +++ b/resources/lang/en_US/default.po @@ -974,3 +974,7 @@ msgstr "No shift type has been created yet. Shifts can't be created without one. msgid "admin_shifts.no_angeltypes" msgstr "No angeltype has been created yet. Shifts can't be created without one." + +msgid "shift.sign_out.hint" +msgstr "You can self sign out up to %s hours before the start of the shift. " +"If you can't attend your shift, ask heaven to sign you out."