2017-12-11 22:26:36 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Public dashboard (formerly known as angel news hub)
|
|
|
|
*/
|
2017-12-12 21:57:57 +01:00
|
|
|
function public_dashboard_view($stats, $free_shifts)
|
2017-12-11 22:26:36 +01:00
|
|
|
{
|
2017-12-12 22:09:01 +01:00
|
|
|
$needed_angels = '';
|
|
|
|
if (count($free_shifts) > 0) {
|
|
|
|
$shift_panels = [];
|
|
|
|
foreach ($free_shifts as $shift) {
|
|
|
|
$shift_panels[] = public_dashborad_shift_render($shift);
|
|
|
|
}
|
|
|
|
$needed_angels = div('container-fluid first', [
|
2017-12-13 12:37:05 +01:00
|
|
|
div('col-md-12', [
|
2017-12-12 22:09:01 +01:00
|
|
|
heading(_('Needed angels:'), 1)
|
|
|
|
]),
|
|
|
|
join($shift_panels)
|
|
|
|
]);
|
2017-12-12 21:57:57 +01:00
|
|
|
}
|
2017-12-11 22:26:36 +01:00
|
|
|
return page([
|
2017-12-12 21:57:57 +01:00
|
|
|
div('first container-fluid', [
|
|
|
|
stats(_('Angels needed in the next 3 hrs'), $stats['needed-3-hours']),
|
|
|
|
stats(_('Angels needed for nightshifts'), $stats['needed-night']),
|
|
|
|
stats(_('Angels currently working'), $stats['angels-working'], 'default'),
|
|
|
|
stats(_('Hours to be worked'), $stats['hours-to-work'], 'default'),
|
2017-12-11 22:26:36 +01:00
|
|
|
'<script>$(function(){setTimeout(function(){window.location.reload();}, 60000)})</script>'
|
2017-12-12 21:57:57 +01:00
|
|
|
]),
|
2017-12-12 22:09:01 +01:00
|
|
|
$needed_angels
|
2017-12-11 22:26:36 +01:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2017-12-12 21:57:57 +01:00
|
|
|
/**
|
|
|
|
* Renders a single shift panel for a dashboard shift with needed angels
|
|
|
|
*/
|
|
|
|
function public_dashborad_shift_render($shift)
|
|
|
|
{
|
|
|
|
$style = 'default';
|
|
|
|
if (time() + 3 * 60 * 60 > $shift['start']) {
|
|
|
|
$style = 'warning';
|
|
|
|
}
|
|
|
|
if (time() > $shift['start']) {
|
|
|
|
$style = 'danger';
|
|
|
|
}
|
|
|
|
|
|
|
|
$panel_body = glyph('time') . date('H:i', $shift['start']) . ' - ' . date('H:i', $shift['end']);
|
2017-12-12 22:04:12 +01:00
|
|
|
$panel_body .= ' (' . round(($shift['end'] - $shift['start']) / 3600) . ' h)';
|
2017-12-12 21:57:57 +01:00
|
|
|
|
|
|
|
$panel_body .= '<br>' . glyph('tasks') . ShiftType($shift['shifttype_id'])['name'];
|
|
|
|
if (! empty($shift['title'])) {
|
|
|
|
$panel_body .= ' (' . $shift['title'] . ')';
|
|
|
|
}
|
|
|
|
|
|
|
|
$panel_body .= '<br>' . glyph('map-marker') . Room($shift['RID'])['Name'];
|
|
|
|
|
|
|
|
foreach ($shift['NeedAngels'] as $needed_angels) {
|
|
|
|
$need = $needed_angels['count'] - $needed_angels['taken'];
|
|
|
|
if ($need > 0) {
|
2017-12-13 12:22:26 +01:00
|
|
|
$panel_body .=
|
|
|
|
'<br>' . glyph('user') .
|
|
|
|
'<span class="text-' . $style . '">' .
|
|
|
|
$need . ' × ' . AngelType($needed_angels['TID'])['name'] .
|
|
|
|
'</span>';
|
2017-12-12 21:57:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-13 12:22:26 +01:00
|
|
|
// $panel_body = '<a href="' . shift_link($shift) . '">' . $panel_body . '</a>';
|
2017-12-12 21:57:57 +01:00
|
|
|
|
2017-12-13 12:37:05 +01:00
|
|
|
return div('col-md-3', [
|
2017-12-13 12:22:26 +01:00
|
|
|
div('dashboard-panel panel panel-' . $style, [
|
2017-12-12 22:00:29 +01:00
|
|
|
div('panel-body', [
|
2017-12-13 12:22:26 +01:00
|
|
|
'<a class="panel-link" href="' . shift_link($shift) . '"></a>',
|
2017-12-13 12:37:05 +01:00
|
|
|
$panel_body
|
2017-12-12 22:00:29 +01:00
|
|
|
])
|
2017-12-12 21:57:57 +01:00
|
|
|
])
|
|
|
|
]);
|
|
|
|
}
|
2017-12-11 22:26:36 +01:00
|
|
|
?>
|