link to next shift in menu
This commit is contained in:
parent
d02272afd6
commit
038bf97178
|
@ -16,7 +16,7 @@ function shift_controller() {
|
|||
global $user, $privileges;
|
||||
|
||||
if (! in_array('user_shifts', $privileges))
|
||||
redirect(page_link_to('user_shifts'));
|
||||
redirect(page_link_to('?'));
|
||||
|
||||
if (! isset($_REQUEST['shift_id']))
|
||||
redirect(page_link_to('user_shifts'));
|
||||
|
@ -58,9 +58,30 @@ function shifts_controller() {
|
|||
redirect(page_link_to('?'));
|
||||
case 'view':
|
||||
return shift_controller();
|
||||
case 'next':
|
||||
return shift_next_controller();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirects the user to his next shift.
|
||||
*/
|
||||
function shift_next_controller() {
|
||||
global $user, $privileges;
|
||||
|
||||
if (! in_array('user_shifts', $privileges))
|
||||
redirect(page_link_to('?'));
|
||||
|
||||
$upcoming_shifts = ShiftEntries_upcoming_for_user($user);
|
||||
if ($upcoming_shifts === false)
|
||||
return false;
|
||||
|
||||
if (count($upcoming_shifts) > 0)
|
||||
redirect(shift_link($upcoming_shifts[0]));
|
||||
|
||||
redirect(page_link_to('user_shifts'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Export all shifts using api-key.
|
||||
*/
|
||||
|
|
|
@ -19,7 +19,7 @@ function header_toolbar() {
|
|||
$toolbar_items = array();
|
||||
|
||||
if (isset($user))
|
||||
$toolbar_items[] = toolbar_item_link(page_link_to('users') . '&action=view', 'time', User_shift_state_render($user));
|
||||
$toolbar_items[] = toolbar_item_link(page_link_to('shifts') . '&action=next', 'time', User_shift_state_render($user));
|
||||
|
||||
if (! isset($user) && in_array('register', $privileges))
|
||||
$toolbar_items[] = toolbar_item_link(page_link_to('register'), 'plus', register_title(), $p == 'register');
|
||||
|
|
|
@ -1,8 +1,18 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* AngelTypes
|
||||
*/
|
||||
|
||||
/**
|
||||
* Renders the angeltypes name as link.
|
||||
*
|
||||
* @param AngelType $angeltype
|
||||
*/
|
||||
function AngelType_name_render($angeltype) {
|
||||
return '<a href="' . page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'] . '">' . ($angeltype['restricted'] ? glyph('lock') : '') . $angeltype['name'] . '</a>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Render angeltype membership state
|
||||
*
|
||||
|
|
|
@ -16,7 +16,7 @@ function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source,
|
|||
$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 .= '<h3>' . $angeltypes[$needed_angeltype['TID']]['name'] . '</h3>';
|
||||
$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']);
|
||||
|
||||
$angels = [];
|
||||
|
@ -47,7 +47,7 @@ function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source,
|
|||
button(shift_delete_link($shift), glyph('trash') . _('delete'))
|
||||
]) : '',
|
||||
div('row', [
|
||||
div('col-sm-3', [
|
||||
div('col-sm-3 col-xs-6', [
|
||||
'<h4>' . _('Start') . '</h4>',
|
||||
'<p class="lead">',
|
||||
date('y-m-d', $shift['start']),
|
||||
|
@ -55,7 +55,7 @@ function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source,
|
|||
date('H:i', $shift['start']),
|
||||
'</p>'
|
||||
]),
|
||||
div('col-sm-3', [
|
||||
div('col-sm-3 col-xs-6', [
|
||||
'<h4>' . _('End') . '</h4>',
|
||||
'<p class="lead">',
|
||||
date('y-m-d', $shift['end']),
|
||||
|
@ -63,11 +63,11 @@ function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source,
|
|||
date('H:i', $shift['end']),
|
||||
'</p>'
|
||||
]),
|
||||
div('col-sm-3', [
|
||||
div('col-sm-3 col-xs-6', [
|
||||
'<h4>' . _('Location') . '</h4>',
|
||||
'<p class="lead">' . $room['Name'] . '</p>'
|
||||
]),
|
||||
div('col-sm-3', [
|
||||
div('col-sm-3 col-xs-6', [
|
||||
'<h4>' . _('More info') . '</h4>',
|
||||
$shift['URL'] != '' ? '<a href="' . $shift['URL'] . '">' . $shift['URL'] . '</a>' : ''
|
||||
])
|
||||
|
|
Loading…
Reference in New Issue