2017-12-11 22:26:36 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Public dashboard (formerly known as angel news hub)
|
2017-12-25 23:12:52 +01:00
|
|
|
*
|
|
|
|
* @param array $stats
|
|
|
|
* @param array[] $free_shifts
|
|
|
|
* @return string
|
2017-12-11 22:26:36 +01:00
|
|
|
*/
|
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) {
|
2017-12-26 10:47:39 +01:00
|
|
|
$shift_panels = [
|
|
|
|
'<div class="row">'
|
|
|
|
];
|
2017-12-26 10:51:23 +01:00
|
|
|
foreach ($free_shifts as $i => $shift) {
|
2017-12-25 23:12:52 +01:00
|
|
|
$shift_panels[] = public_dashboard_shift_render($shift);
|
2018-10-17 01:30:10 +02:00
|
|
|
if ($i % 4 == 3) {
|
2017-12-26 10:47:39 +01:00
|
|
|
$shift_panels[] = '</div><div class="row">';
|
|
|
|
}
|
2017-12-12 22:09:01 +01:00
|
|
|
}
|
2017-12-26 10:47:39 +01:00
|
|
|
$shift_panels[] = '</div>';
|
2017-12-13 17:50:52 +01:00
|
|
|
$needed_angels = div('first', [
|
2017-12-13 12:37:05 +01:00
|
|
|
div('col-md-12', [
|
2018-08-29 21:55:32 +02:00
|
|
|
heading(__('Needed angels:'), 1)
|
2017-12-12 22:09:01 +01:00
|
|
|
]),
|
2017-12-26 10:51:23 +01:00
|
|
|
div('container-fluid', [
|
|
|
|
join($shift_panels)
|
|
|
|
])
|
2017-12-12 22:09:01 +01:00
|
|
|
]);
|
2017-12-12 21:57:57 +01:00
|
|
|
}
|
2017-12-25 23:12:52 +01:00
|
|
|
|
2020-10-27 17:13:46 +01:00
|
|
|
$isFiltered = request()->get('filtered');
|
2017-12-11 22:26:36 +01:00
|
|
|
return page([
|
2017-12-13 16:51:38 +01:00
|
|
|
div('public-dashboard', [
|
2017-12-13 17:50:52 +01:00
|
|
|
div('first', [
|
2018-08-29 21:55:32 +02:00
|
|
|
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-13 16:51:38 +01:00
|
|
|
'<script>
|
|
|
|
$(function() {
|
|
|
|
setInterval(function() {
|
2020-10-27 17:13:46 +01:00
|
|
|
$(\'#public-dashboard\').load(window.location.href + \' #public-dashboard\');
|
2017-12-13 16:51:38 +01:00
|
|
|
}, 60000);
|
|
|
|
})
|
|
|
|
</script>'
|
|
|
|
], 'statistics'),
|
2017-12-14 20:09:51 +01:00
|
|
|
$needed_angels
|
|
|
|
], 'public-dashboard'),
|
2020-10-27 17:13:46 +01:00
|
|
|
div('first col-md-12 text-center', [buttons([
|
|
|
|
button_js(
|
|
|
|
'
|
|
|
|
$(\'#navbar-collapse-1,.navbar-nav,.navbar-toggle,#footer,#fullscreen-button\').remove();
|
|
|
|
$(\'.navbar-brand\').append(\' ' . __('Public Dashboard') . '\');
|
|
|
|
',
|
|
|
|
glyph('fullscreen') . __('Fullscreen')
|
|
|
|
),
|
|
|
|
auth()->user() ? button(
|
|
|
|
public_dashboard_link($isFiltered ? [] : ['filtered' => 1]),
|
|
|
|
glyph('filter') . ($isFiltered ? __('All') : __('Filtered'))
|
|
|
|
) : ''
|
|
|
|
])], 'fullscreen-button'),
|
2017-12-13 17:50:52 +01:00
|
|
|
]);
|
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
|
2017-12-25 23:12:52 +01:00
|
|
|
*
|
|
|
|
* @param array $shift
|
|
|
|
* @return string
|
2017-12-12 21:57:57 +01:00
|
|
|
*/
|
2017-12-25 23:12:52 +01:00
|
|
|
function public_dashboard_shift_render($shift)
|
2017-12-12 21:57:57 +01:00
|
|
|
{
|
2017-12-23 11:59:13 +01:00
|
|
|
$panel_body = glyph('time') . $shift['start'] . ' - ' . $shift['end'];
|
2017-12-30 12:07:10 +01:00
|
|
|
$panel_body .= ' (' . $shift['duration'] . ' h)';
|
2017-12-25 23:12:52 +01:00
|
|
|
|
2017-12-23 11:59:13 +01:00
|
|
|
$panel_body .= '<br>' . glyph('tasks') . $shift['shifttype_name'];
|
2017-12-25 23:12:52 +01:00
|
|
|
if (!empty($shift['title'])) {
|
2017-12-12 21:57:57 +01:00
|
|
|
$panel_body .= ' (' . $shift['title'] . ')';
|
|
|
|
}
|
2017-12-25 23:12:52 +01:00
|
|
|
|
2017-12-23 11:59:13 +01:00
|
|
|
$panel_body .= '<br>' . glyph('map-marker') . $shift['room_name'];
|
2017-12-25 23:12:52 +01:00
|
|
|
|
2017-12-23 11:59:13 +01:00
|
|
|
foreach ($shift['needed_angels'] as $needed_angels) {
|
2017-12-25 23:12:52 +01:00
|
|
|
$panel_body .= '<br>' . glyph('user')
|
|
|
|
. '<span class="text-' . $shift['style'] . '">'
|
|
|
|
. $needed_angels['need'] . ' × ' . $needed_angels['angeltype_name']
|
|
|
|
. '</span>';
|
2017-12-12 21:57:57 +01:00
|
|
|
}
|
2017-12-25 23:12:52 +01:00
|
|
|
|
2017-12-13 12:37:05 +01:00
|
|
|
return div('col-md-3', [
|
2017-12-23 11:59:13 +01:00
|
|
|
div('dashboard-panel panel panel-' . $shift['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
|
|
|
])
|
|
|
|
]);
|
|
|
|
}
|