Reimplementation of 2840bb619 (signup requires arrival), closes #330

This commit is contained in:
Igor Scheller 2017-08-31 12:25:06 +02:00
parent 2bd127c011
commit 0a20883aa8
7 changed files with 52 additions and 24 deletions

View File

@ -44,6 +44,9 @@ return [
// Number of News shown on one site
'display_news' => 6,
// Only arrived angels can sign up for shifts
'signup_requires_arrival' => false,
// Anzahl Stunden bis zum Austragen eigener Schichten
'last_unsubscribe' => 3,

View File

@ -57,16 +57,17 @@ function success($msg, $immediately = false)
* @param string $class
* @param string $msg
* @param bool $immediately
* @return string|null
* @return string
*/
function alert($class, $msg, $immediately = false)
{
$session = session();
if ($immediately) {
if ($msg == '') {
if (empty($msg)) {
return '';
}
if ($immediately) {
return '<div class="alert alert-' . $class . '">' . $msg . '</div>';
}
@ -74,5 +75,5 @@ function alert($class, $msg, $immediately = false)
$message .= alert($class, $msg, true);
$session->set('msg', $message);
return null;
return '';
}

View File

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

View File

@ -206,6 +206,11 @@ function view_user_shifts()
$end_day = date('Y-m-d', $shiftsFilter->getEndTime());
$end_time = date('H:i', $shiftsFilter->getEndTime());
$assignNotice = '';
if (config('signup_requires_arrival') && !$user['Gekommen']) {
$assignNotice = info(render_user_arrived_hint(), true);
}
return page([
div('col-md-12', [
msg(),
@ -229,6 +234,7 @@ function view_user_shifts()
. ' <a href="' . page_link_to('angeltypes', ['action' => 'about']) . '">'
. _('Description of the jobs.')
. '</a>',
'assign_notice' => $assignNotice,
'shifts_table' => msg() . $shiftCalendarRenderer->render(),
'ical_text' => '<h2>' . _('iCal export') . '</h2><p>' . sprintf(
_('Export of shown shifts. <a href="%s">iCal format</a> or <a href="%s">JSON format</a> available (please keep secret, otherwise <a href="%s">reset the api key</a>).'),

View File

@ -11,8 +11,16 @@ use Engelsystem\ShiftsFilterRenderer;
*/
function Room_view($room, ShiftsFilterRenderer $shiftsFilterRenderer, ShiftCalendarRenderer $shiftCalendarRenderer)
{
global $user;
$assignNotice = '';
if (config('signup_requires_arrival') && !$user['Gekommen']) {
$assignNotice = info(render_user_arrived_hint(), true);
}
return page_with_title(glyph('map-marker') . $room['Name'], [
$shiftsFilterRenderer->render($room),
$assignNotice,
$shiftCalendarRenderer->render()
]);
}

View File

@ -19,7 +19,7 @@ $free_pages = [
'stats',
'users',
'user_driver_licenses',
'user_password_recovery'
'user_password_recovery',
];
// Gewünschte Seite/Funktion
@ -218,6 +218,7 @@ $parameters = [
if ($page == 'user_meetings') {
$parameters['meetings'] = 1;
}
echo view(__DIR__ . '/../templates/layout.html', [
'theme' => isset($user) ? $user['color'] : config('theme'),
'title' => $title,

View File

@ -4,12 +4,14 @@
var days = document.getElementById(id + '_day').getElementsByTagName(
'option');
for (var i = 0; i < days.length; i++) {
if (days[i].value == moment().format('YYYY-MM-DD'))
if (days[i].value === moment().format('YYYY-MM-DD')) {
days[i].selected = true;
}
}
}
</script>
<form class="form-inline" action="" method="get">
<form class="form-inline" action="">
<input type="hidden" name="p" value="user_shifts">
<div class="row">
<div class="col-md-6">
@ -17,7 +19,7 @@
<div class="form-group">%start_select%</div>
<div class="form-group">
<div class="input-group">
<input class="form-control" type="text" id="start_time" name="start_time" size="5"
<input class="form-control" id="start_time" name="start_time" size="5"
pattern="^\d{1,2}:\d{2}$" placeholder="HH:MM" maxlength="5" value="%start_time%">
<div class="input-group-btn">
<button class="btn btn-default" title="Now" type="button" onclick="set_to_now('start');">
@ -30,7 +32,7 @@
<div class="form-group">%end_select%</div>
<div class="form-group">
<div class="input-group">
<input class="form-control" type="text" id="end_time" name="end_time" size="5"
<input class="form-control" id="end_time" name="end_time" size="5"
pattern="^\d{1,2}:\d{2}$" placeholder="HH:MM" maxlength="5" value="%end_time%">
<div class="input-group-btn">
<button class="btn btn-default" title="Now" type="button" onclick="set_to_now('end');">
@ -46,8 +48,11 @@
</div>
<div class="row">
<div class="col-md-6">
<div>%task_notice%</div>
<input class="btn btn-primary" type="submit" style="width: 75%; margin-bottom: 20px" value="%filter%">
<div>%assign_notice%</div>
</div>
<div class="col-md-6">
<div><p>%task_notice%</p></div>
<input class="btn btn-primary" type="submit" style="width:75%; margin-bottom: 20px" value="%filter%">
</div>
</div>
</form>