summaryrefslogtreecommitdiff
path: root/includes/view/Shifts_view.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/view/Shifts_view.php')
-rw-r--r--includes/view/Shifts_view.php29
1 files changed, 25 insertions, 4 deletions
diff --git a/includes/view/Shifts_view.php b/includes/view/Shifts_view.php
index 594cb33c..00c18572 100644
--- a/includes/view/Shifts_view.php
+++ b/includes/view/Shifts_view.php
@@ -1,6 +1,23 @@
<?php
-function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source, $user_shift_admin, $admin_rooms, $admin_shifttypes) {
+function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null, $user_shifts = null) {
+ global $user;
+
+ if ($user_angeltype == null) {
+ $user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
+ if ($user_angeltype === false)
+ engelsystem_error('Unable to load user angeltype.');
+ }
+
+ if (Shift_signup_allowed($shift, $angeltype, $user_angeltype, $user_shifts))
+ return button(page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $angeltype['id'], _('Sign up'));
+ elseif ($user_angeltype == null)
+ return button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], sprintf('Become %s', $angeltype['name']));
+ else
+ return '';
+}
+
+function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source, $user_shift_admin, $admin_rooms, $admin_shifttypes, $user_shifts, $signed_up) {
$parsedown = new Parsedown();
$angeltypes = [];
@@ -15,7 +32,9 @@ function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source,
if ($needed_angeltype['taken'] >= $needed_angeltype['count'])
$class = 'progress-bar-success';
$needed_angels .= '<div class="list-group-item">';
- $needed_angels .= '<div class="pull-right">' . button(page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $needed_angeltype['TID'], _('Sign up')) . '</div>';
+
+ $needed_angels .= '<div class="pull-right">' . Shift_signup_button_render($shift, $angeltypes[$needed_angeltype['TID']]) . '</div>';
+
$needed_angels .= '<h3>' . AngelType_name_render($angeltypes[$needed_angeltype['TID']]) . '</h3>';
$needed_angels .= progress_bar(0, $needed_angeltype['count'], $needed_angeltype['taken'], $class, $needed_angeltype['taken'] . ' / ' . $needed_angeltype['count']);
@@ -42,6 +61,8 @@ function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source,
return page_with_title($shift['name'] . ' <small class="moment-countdown" data-timestamp="' . $shift['start'] . '">%c</small>', [
msg(),
+ Shift_collides($shift, $user_shifts) ? info(_('This shift collides with one of your shifts.'), true) : '',
+ $signed_up ? info(_('You are signed up for this shift.'), true) : '',
($shift_admin || $admin_shifttypes || $admin_rooms) ? buttons([
$shift_admin ? button(shift_edit_link($shift), glyph('pencil') . _('edit')) : '',
$shift_admin ? button(shift_delete_link($shift), glyph('trash') . _('delete')) : '',
@@ -55,7 +76,7 @@ function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source,
]),
div('col-sm-3 col-xs-6', [
'<h4>' . _('Start') . '</h4>',
- '<p class="lead">',
+ '<p class="lead' . (time() >= $shift['start'] ? ' text-success' : '') . '">',
glyph('calendar') . date('y-m-d', $shift['start']),
'<br />',
glyph('time') . date('H:i', $shift['start']),
@@ -63,7 +84,7 @@ function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source,
]),
div('col-sm-3 col-xs-6', [
'<h4>' . _('End') . '</h4>',
- '<p class="lead">',
+ '<p class="lead' . (time() >= $shift['end'] ? ' text-success' : '') . '">',
glyph('calendar') . date('y-m-d', $shift['end']),
'<br />',
glyph('time') . date('H:i', $shift['end']),