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;
|
global $user, $privileges;
|
||||||
|
|
||||||
if (! in_array('user_shifts', $privileges))
|
if (! in_array('user_shifts', $privileges))
|
||||||
redirect(page_link_to('user_shifts'));
|
redirect(page_link_to('?'));
|
||||||
|
|
||||||
if (! isset($_REQUEST['shift_id']))
|
if (! isset($_REQUEST['shift_id']))
|
||||||
redirect(page_link_to('user_shifts'));
|
redirect(page_link_to('user_shifts'));
|
||||||
|
@ -58,9 +58,30 @@ function shifts_controller() {
|
||||||
redirect(page_link_to('?'));
|
redirect(page_link_to('?'));
|
||||||
case 'view':
|
case 'view':
|
||||||
return shift_controller();
|
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.
|
* Export all shifts using api-key.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -19,7 +19,7 @@ function header_toolbar() {
|
||||||
$toolbar_items = array();
|
$toolbar_items = array();
|
||||||
|
|
||||||
if (isset($user))
|
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))
|
if (! isset($user) && in_array('register', $privileges))
|
||||||
$toolbar_items[] = toolbar_item_link(page_link_to('register'), 'plus', register_title(), $p == 'register');
|
$toolbar_items[] = toolbar_item_link(page_link_to('register'), 'plus', register_title(), $p == 'register');
|
||||||
|
|
|
@ -1,8 +1,18 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AngelTypes
|
* 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
|
* Render angeltype membership state
|
||||||
*
|
*
|
||||||
|
|
|
@ -16,7 +16,7 @@ function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source,
|
||||||
$class = 'progress-bar-success';
|
$class = 'progress-bar-success';
|
||||||
$needed_angels .= '<div class="list-group-item">';
|
$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">' . 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']);
|
$needed_angels .= progress_bar(0, $needed_angeltype['count'], $needed_angeltype['taken'], $class, $needed_angeltype['taken'] . ' / ' . $needed_angeltype['count']);
|
||||||
|
|
||||||
$angels = [];
|
$angels = [];
|
||||||
|
@ -47,7 +47,7 @@ function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source,
|
||||||
button(shift_delete_link($shift), glyph('trash') . _('delete'))
|
button(shift_delete_link($shift), glyph('trash') . _('delete'))
|
||||||
]) : '',
|
]) : '',
|
||||||
div('row', [
|
div('row', [
|
||||||
div('col-sm-3', [
|
div('col-sm-3 col-xs-6', [
|
||||||
'<h4>' . _('Start') . '</h4>',
|
'<h4>' . _('Start') . '</h4>',
|
||||||
'<p class="lead">',
|
'<p class="lead">',
|
||||||
date('y-m-d', $shift['start']),
|
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']),
|
date('H:i', $shift['start']),
|
||||||
'</p>'
|
'</p>'
|
||||||
]),
|
]),
|
||||||
div('col-sm-3', [
|
div('col-sm-3 col-xs-6', [
|
||||||
'<h4>' . _('End') . '</h4>',
|
'<h4>' . _('End') . '</h4>',
|
||||||
'<p class="lead">',
|
'<p class="lead">',
|
||||||
date('y-m-d', $shift['end']),
|
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']),
|
date('H:i', $shift['end']),
|
||||||
'</p>'
|
'</p>'
|
||||||
]),
|
]),
|
||||||
div('col-sm-3', [
|
div('col-sm-3 col-xs-6', [
|
||||||
'<h4>' . _('Location') . '</h4>',
|
'<h4>' . _('Location') . '</h4>',
|
||||||
'<p class="lead">' . $room['Name'] . '</p>'
|
'<p class="lead">' . $room['Name'] . '</p>'
|
||||||
]),
|
]),
|
||||||
div('col-sm-3', [
|
div('col-sm-3 col-xs-6', [
|
||||||
'<h4>' . _('More info') . '</h4>',
|
'<h4>' . _('More info') . '</h4>',
|
||||||
$shift['URL'] != '' ? '<a href="' . $shift['URL'] . '">' . $shift['URL'] . '</a>' : ''
|
$shift['URL'] != '' ? '<a href="' . $shift['URL'] . '">' . $shift['URL'] . '</a>' : ''
|
||||||
])
|
])
|
||||||
|
|
Loading…
Reference in New Issue