2017-12-11 22:26:36 +01:00
|
|
|
<?php
|
|
|
|
|
2023-08-13 16:09:56 +02:00
|
|
|
use Engelsystem\Helpers\DayOfEvent;
|
2023-02-13 21:19:45 +01:00
|
|
|
use Engelsystem\Models\News;
|
|
|
|
use Illuminate\Support\Collection;
|
|
|
|
|
2017-12-11 22:26:36 +01:00
|
|
|
/**
|
|
|
|
* Public dashboard (formerly known as angel news hub)
|
2017-12-25 23:12:52 +01:00
|
|
|
*
|
2023-02-13 21:19:45 +01:00
|
|
|
* @param array $stats
|
|
|
|
* @param array[] $free_shifts
|
|
|
|
* @param News[]|Collection $important_news
|
2017-12-25 23:12:52 +01:00
|
|
|
* @return string
|
2017-12-11 22:26:36 +01:00
|
|
|
*/
|
2023-02-13 21:19:45 +01:00
|
|
|
function public_dashboard_view($stats, $free_shifts, $important_news)
|
2017-12-11 22:26:36 +01:00
|
|
|
{
|
2017-12-12 22:09:01 +01:00
|
|
|
$needed_angels = '';
|
2023-02-13 21:19:45 +01:00
|
|
|
$news = '';
|
|
|
|
if ($important_news->isNotEmpty()) {
|
|
|
|
$first_news = $important_news->first();
|
|
|
|
$news = div('alert alert-warning text-center', [
|
2023-12-04 23:33:07 +01:00
|
|
|
'<a href="' . url('/news/' . $first_news->id) . '">'
|
|
|
|
. '<strong>' . htmlspecialchars($first_news->title) . '</strong>'
|
|
|
|
. '</a>',
|
2023-02-13 21:19:45 +01:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2017-12-12 22:09:01 +01:00
|
|
|
if (count($free_shifts) > 0) {
|
2017-12-26 10:47:39 +01:00
|
|
|
$shift_panels = [
|
2023-02-05 18:03:00 +01:00
|
|
|
'<div class="row">',
|
2017-12-26 10:47:39 +01:00
|
|
|
];
|
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', [
|
2023-02-05 18:03:00 +01:00
|
|
|
heading(__('Needed angels:')),
|
2017-12-12 22:09:01 +01:00
|
|
|
]),
|
2017-12-26 10:51:23 +01:00
|
|
|
div('container-fluid', [
|
2023-02-05 18:03:00 +01:00
|
|
|
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
|
|
|
|
2023-08-13 16:09:56 +02:00
|
|
|
$stats = [
|
|
|
|
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'),
|
|
|
|
];
|
|
|
|
|
|
|
|
$dayOfEvent = DayOfEvent::get();
|
|
|
|
|
|
|
|
if (config('enable_show_day_of_event') && $dayOfEvent !== null) {
|
|
|
|
$stats[] = stats(__('dashboard.day'), $dayOfEvent, 'default');
|
|
|
|
}
|
|
|
|
|
2020-10-27 17:13:46 +01:00
|
|
|
$isFiltered = request()->get('filtered');
|
2020-11-24 01:18:05 +01:00
|
|
|
$filter = collect(session()->get('shifts-filter'))->only(['rooms', 'types'])->toArray();
|
2017-12-11 22:26:36 +01:00
|
|
|
return page([
|
2021-07-24 20:31:40 +02:00
|
|
|
div('wrapper', [
|
|
|
|
div('public-dashboard', [
|
2023-08-13 16:09:56 +02:00
|
|
|
div('first row', $stats, 'statistics'),
|
2023-02-13 21:19:45 +01:00
|
|
|
$news,
|
2023-02-05 18:03:00 +01:00
|
|
|
$needed_angels,
|
2021-07-24 20:31:40 +02:00
|
|
|
], 'public-dashboard'),
|
|
|
|
]),
|
2020-10-27 17:13:46 +01:00
|
|
|
div('first col-md-12 text-center', [buttons([
|
2022-11-29 21:47:26 +01:00
|
|
|
button(
|
|
|
|
'#',
|
|
|
|
icon('fullscreen') . __('Fullscreen'),
|
|
|
|
'',
|
|
|
|
'dashboard-fullscreen'
|
2020-10-27 17:13:46 +01:00
|
|
|
),
|
|
|
|
auth()->user() ? button(
|
2020-11-24 01:18:05 +01:00
|
|
|
public_dashboard_link($isFiltered ? [] : ['filtered' => 1] + $filter),
|
2021-07-22 21:22:21 +02:00
|
|
|
icon('filter') . ($isFiltered ? __('All') : __('Filtered'))
|
2023-02-05 18:03:00 +01:00
|
|
|
) : '',
|
2020-10-27 17:13:46 +01:00
|
|
|
])], '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
|
|
|
{
|
2022-12-02 23:03:23 +01:00
|
|
|
$panel_body = icon('clock-history') . $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
|
|
|
|
2023-12-04 23:33:07 +01:00
|
|
|
$panel_body .= '<br>' . icon('list-task') . htmlspecialchars($shift['shifttype_name']);
|
2017-12-25 23:12:52 +01:00
|
|
|
if (!empty($shift['title'])) {
|
2023-12-04 23:33:07 +01:00
|
|
|
$panel_body .= ' (' . htmlspecialchars($shift['title']) . ')';
|
2017-12-12 21:57:57 +01:00
|
|
|
}
|
2017-12-25 23:12:52 +01:00
|
|
|
|
2023-12-04 23:33:07 +01:00
|
|
|
$panel_body .= '<br>' . icon('pin-map-fill') . htmlspecialchars($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) {
|
2021-07-22 21:22:21 +02:00
|
|
|
$panel_body .= '<br>' . icon('person')
|
2017-12-25 23:12:52 +01:00
|
|
|
. '<span class="text-' . $shift['style'] . '">'
|
2023-12-04 23:33:07 +01:00
|
|
|
. $needed_angels['need'] . ' × ' . htmlspecialchars($needed_angels['angeltype_name'])
|
2017-12-25 23:12:52 +01:00
|
|
|
. '</span>';
|
2017-12-12 21:57:57 +01:00
|
|
|
}
|
2017-12-25 23:12:52 +01:00
|
|
|
|
2021-07-24 20:31:40 +02:00
|
|
|
$type = 'bg-dark';
|
|
|
|
if (theme_type() == 'light') {
|
|
|
|
$type = 'bg-light';
|
|
|
|
}
|
|
|
|
|
|
|
|
return div('col-md-3 mb-3', [
|
2021-07-25 21:41:57 +02:00
|
|
|
div('dashboard-card card border-' . $shift['style'] . ' ' . $type, [
|
2021-07-24 20:31:40 +02:00
|
|
|
div('card-body', [
|
2021-07-25 21:41:57 +02:00
|
|
|
'<a class="card-link" href="' . shift_link($shift) . '"></a>',
|
2023-02-05 18:03:00 +01:00
|
|
|
$panel_body,
|
|
|
|
]),
|
|
|
|
]),
|
2017-12-12 21:57:57 +01:00
|
|
|
]);
|
|
|
|
}
|