Added filter to dashboard
This commit is contained in:
parent
6738fbeec3
commit
2745b04dc2
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Engelsystem\Models\Room;
|
use Engelsystem\Models\Room;
|
||||||
|
use Engelsystem\ShiftsFilter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads all data for the public dashboard
|
* Loads all data for the public dashboard
|
||||||
|
@ -9,17 +10,23 @@ use Engelsystem\Models\Room;
|
||||||
*/
|
*/
|
||||||
function public_dashboard_controller()
|
function public_dashboard_controller()
|
||||||
{
|
{
|
||||||
|
$filter = null;
|
||||||
|
if (request()->get('filtered') && auth()->user()) {
|
||||||
|
$filter = new ShiftsFilter();
|
||||||
|
$filter->sessionImport(session()->get('shifts-filter'));
|
||||||
|
}
|
||||||
|
|
||||||
$stats = [
|
$stats = [
|
||||||
'needed-3-hours' => stats_angels_needed_three_hours(),
|
'needed-3-hours' => stats_angels_needed_three_hours($filter),
|
||||||
'needed-night' => stats_angels_needed_for_nightshifts(),
|
'needed-night' => stats_angels_needed_for_nightshifts($filter),
|
||||||
'angels-working' => stats_currently_working(),
|
'angels-working' => stats_currently_working($filter),
|
||||||
'hours-to-work' => stats_hours_to_work()
|
'hours-to-work' => stats_hours_to_work($filter)
|
||||||
];
|
];
|
||||||
|
|
||||||
$free_shifts_source = Shifts_free(time(), time() + 12 * 60 * 60);
|
$free_shifts_source = Shifts_free(time(), time() + 12 * 60 * 60, $filter);
|
||||||
$free_shifts = [];
|
$free_shifts = [];
|
||||||
foreach ($free_shifts_source as $shift) {
|
foreach ($free_shifts_source as $shift) {
|
||||||
$free_shift = public_dashboard_controller_free_shift($shift);
|
$free_shift = public_dashboard_controller_free_shift($shift, $filter);
|
||||||
if (count($free_shift['needed_angels']) > 0) {
|
if (count($free_shift['needed_angels']) > 0) {
|
||||||
$free_shifts[] = $free_shift;
|
$free_shifts[] = $free_shift;
|
||||||
}
|
}
|
||||||
|
@ -34,10 +41,12 @@ function public_dashboard_controller()
|
||||||
/**
|
/**
|
||||||
* Gathers information for free shifts to display.
|
* Gathers information for free shifts to display.
|
||||||
*
|
*
|
||||||
* @param array $shift
|
* @param array $shift
|
||||||
|
* @param ShiftsFilter|null $filter
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function public_dashboard_controller_free_shift($shift)
|
function public_dashboard_controller_free_shift($shift, ShiftsFilter $filter = null)
|
||||||
{
|
{
|
||||||
$shifttype = ShiftType($shift['shifttype_id']);
|
$shifttype = ShiftType($shift['shifttype_id']);
|
||||||
$room = Room::find($shift['RID']);
|
$room = Room::find($shift['RID']);
|
||||||
|
@ -61,7 +70,7 @@ function public_dashboard_controller_free_shift($shift)
|
||||||
$free_shift['style'] = 'danger';
|
$free_shift['style'] = 'danger';
|
||||||
}
|
}
|
||||||
|
|
||||||
$free_shift['needed_angels'] = public_dashboard_needed_angels($shift['NeedAngels']);
|
$free_shift['needed_angels'] = public_dashboard_needed_angels($shift['NeedAngels'], $filter);
|
||||||
|
|
||||||
return $free_shift;
|
return $free_shift;
|
||||||
}
|
}
|
||||||
|
@ -69,15 +78,17 @@ function public_dashboard_controller_free_shift($shift)
|
||||||
/**
|
/**
|
||||||
* Gathers information for needed angels on dashboard
|
* Gathers information for needed angels on dashboard
|
||||||
*
|
*
|
||||||
* @param array $needed_angels
|
* @param array $needed_angels
|
||||||
|
* @param ShiftsFilter|null $filter
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function public_dashboard_needed_angels($needed_angels)
|
function public_dashboard_needed_angels($needed_angels, ShiftsFilter $filter = null)
|
||||||
{
|
{
|
||||||
$result = [];
|
$result = [];
|
||||||
foreach ($needed_angels as $needed_angel) {
|
foreach ($needed_angels as $needed_angel) {
|
||||||
$need = $needed_angel['count'] - $needed_angel['taken'];
|
$need = $needed_angel['count'] - $needed_angel['taken'];
|
||||||
if ($need > 0) {
|
if ($need > 0 && (!$filter || in_array($needed_angel['TID'], $filter->getTypes()))) {
|
||||||
$angeltype = AngelType($needed_angel['TID']);
|
$angeltype = AngelType($needed_angel['TID']);
|
||||||
if ($angeltype['show_on_dashboard']) {
|
if ($angeltype['show_on_dashboard']) {
|
||||||
$result[] = [
|
$result[] = [
|
||||||
|
@ -93,9 +104,11 @@ function public_dashboard_needed_angels($needed_angels)
|
||||||
/**
|
/**
|
||||||
* Returns url to public dashboard
|
* Returns url to public dashboard
|
||||||
*
|
*
|
||||||
|
* @param array $parameters
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function public_dashboard_link()
|
function public_dashboard_link(array $parameters = []): string
|
||||||
{
|
{
|
||||||
return page_link_to('public-dashboard');
|
return page_link_to('public-dashboard', $parameters);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,21 +34,24 @@ function Shifts_by_angeltype($angeltype)
|
||||||
/**
|
/**
|
||||||
* Returns every shift with needed angels in the given time range.
|
* Returns every shift with needed angels in the given time range.
|
||||||
*
|
*
|
||||||
* @param int $start timestamp
|
* @param int $start timestamp
|
||||||
* @param int $end timestamp
|
* @param int $end timestamp
|
||||||
|
* @param ShiftsFilter|null $filter
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function Shifts_free($start, $end)
|
function Shifts_free($start, $end, ShiftsFilter $filter = null)
|
||||||
{
|
{
|
||||||
$shifts = Db::select("
|
$shifts = Db::select('
|
||||||
SELECT * FROM (
|
SELECT * FROM (
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `Shifts`
|
FROM `Shifts`
|
||||||
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
|
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
|
||||||
WHERE (`end` > ? AND `start` < ?)
|
WHERE (`end` > ? AND `start` < ?)
|
||||||
AND (SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`)
|
AND (SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`' . ($filter ? ' AND NeededAngelTypes.angel_type_id IN (' . implode(',', $filter->getTypes()) . ')' : '') . ')
|
||||||
> (SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0)
|
> (SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0' . ($filter ? ' AND ShiftEntry.TID IN (' . implode(',', $filter->getTypes()) . ')' : '') . ')
|
||||||
AND s.shift_id IS NULL
|
AND s.shift_id IS NULL
|
||||||
|
' . ($filter ? 'AND Shifts.RID IN (' . implode(',', $filter->getRooms()) . ')' : '') . '
|
||||||
|
|
||||||
UNION
|
UNION
|
||||||
|
|
||||||
|
@ -56,12 +59,13 @@ function Shifts_free($start, $end)
|
||||||
FROM `Shifts`
|
FROM `Shifts`
|
||||||
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
|
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
|
||||||
WHERE (`end` > ? AND `start` < ?)
|
WHERE (`end` > ? AND `start` < ?)
|
||||||
AND (SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`room_id`=`Shifts`.`RID`)
|
AND (SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`room_id`=`Shifts`.`RID`' . ($filter ? ' AND NeededAngelTypes.angel_type_id IN (' . implode(',', $filter->getTypes()) . ')' : '') . ')
|
||||||
> (SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0)
|
> (SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0' . ($filter ? ' AND ShiftEntry.TID IN (' . implode(',', $filter->getTypes()) . ')' : '') . ')
|
||||||
AND NOT s.shift_id IS NULL
|
AND NOT s.shift_id IS NULL
|
||||||
|
' . ($filter ? 'AND Shifts.RID IN (' . implode(',', $filter->getRooms()) . ')' : '') . '
|
||||||
) AS `tmp`
|
) AS `tmp`
|
||||||
ORDER BY `tmp`.`start`
|
ORDER BY `tmp`.`start`
|
||||||
", [
|
', [
|
||||||
$start,
|
$start,
|
||||||
$end,
|
$end,
|
||||||
$start,
|
$start,
|
||||||
|
|
|
@ -1,78 +1,83 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Engelsystem\Database\Db;
|
use Engelsystem\Database\Db;
|
||||||
|
use Engelsystem\ShiftsFilter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of angels currently working.
|
* Returns the number of angels currently working.
|
||||||
*
|
*
|
||||||
|
* @param ShiftsFilter|null $filter
|
||||||
|
*
|
||||||
* @return int|string
|
* @return int|string
|
||||||
*/
|
*/
|
||||||
function stats_currently_working()
|
function stats_currently_working(ShiftsFilter $filter = null)
|
||||||
{
|
{
|
||||||
$result = Db::selectOne("
|
$result = Db::selectOne(
|
||||||
SELECT SUM(
|
'
|
||||||
(SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0)
|
SELECT SUM((
|
||||||
) AS `count`
|
SELECT COUNT(*)
|
||||||
|
FROM `ShiftEntry`
|
||||||
|
WHERE `ShiftEntry`.`SID`=`Shifts`.`SID`
|
||||||
|
AND `freeloaded`=0
|
||||||
|
' . ($filter ? 'AND ShiftEntry.TID IN (' . implode(',', $filter->getTypes()) . ')' : '') . '
|
||||||
|
)) AS `count`
|
||||||
FROM `Shifts`
|
FROM `Shifts`
|
||||||
WHERE (`end` >= ? AND `start` <= ?)", [
|
WHERE (`end` >= UNIX_TIMESTAMP() AND `start` <= UNIX_TIMESTAMP())
|
||||||
time(),
|
'. ($filter ? 'AND Shifts.RID IN (' . implode(',', $filter->getRooms()) . ')' : '')
|
||||||
time()
|
);
|
||||||
]);
|
|
||||||
|
|
||||||
if (empty($result['count'])) {
|
return $result['count'] ?: '-';
|
||||||
return '-';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result['count'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the number of hours still to work.
|
* Return the number of hours still to work.
|
||||||
*
|
*
|
||||||
|
* @param ShiftsFilter|null $filter
|
||||||
|
*
|
||||||
* @return int|string
|
* @return int|string
|
||||||
*/
|
*/
|
||||||
function stats_hours_to_work()
|
function stats_hours_to_work(ShiftsFilter $filter = null)
|
||||||
{
|
{
|
||||||
$result = Db::selectOne("
|
$result = Db::selectOne(
|
||||||
|
'
|
||||||
SELECT ROUND(SUM(`count`)) AS `count` FROM (
|
SELECT ROUND(SUM(`count`)) AS `count` FROM (
|
||||||
SELECT
|
SELECT
|
||||||
(SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`)
|
(SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`' . ($filter ? ' AND NeededAngelTypes.angel_type_id IN (' . implode(',', $filter->getTypes()) . ')' : '') . ')
|
||||||
* (`Shifts`.`end` - `Shifts`.`start`)/3600 AS `count`
|
* (`Shifts`.`end` - `Shifts`.`start`)/3600 AS `count`
|
||||||
FROM `Shifts`
|
FROM `Shifts`
|
||||||
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
|
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
|
||||||
WHERE `end` >= ?
|
WHERE `end` >= UNIX_TIMESTAMP()
|
||||||
AND s.shift_id IS NULL
|
AND s.shift_id IS NULL
|
||||||
|
'. ($filter ? 'AND Shifts.RID IN (' . implode(',', $filter->getRooms()) . ')' : '') . '
|
||||||
|
|
||||||
UNION ALL
|
UNION ALL
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
(SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`room_id`=`Shifts`.`RID`)
|
(SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`room_id`=`Shifts`.`RID`' . ($filter ? ' AND NeededAngelTypes.angel_type_id IN (' . implode(',', $filter->getTypes()) . ')' : '') . ')
|
||||||
* (`Shifts`.`end` - `Shifts`.`start`)/3600 AS `count`
|
* (`Shifts`.`end` - `Shifts`.`start`)/3600 AS `count`
|
||||||
FROM `Shifts`
|
FROM `Shifts`
|
||||||
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
|
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
|
||||||
WHERE `end` >= ?
|
WHERE `end` >= UNIX_TIMESTAMP()
|
||||||
AND NOT s.shift_id IS NULL
|
AND NOT s.shift_id IS NULL
|
||||||
|
'. ($filter ? 'AND Shifts.RID IN (' . implode(',', $filter->getRooms()) . ')' : '') . '
|
||||||
) AS `tmp`
|
) AS `tmp`
|
||||||
", [
|
'
|
||||||
time(),
|
);
|
||||||
time()
|
|
||||||
]);
|
return $result['count'] ?: '-';
|
||||||
if (empty($result['count'])) {
|
|
||||||
return '-';
|
|
||||||
}
|
|
||||||
return $result['count'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of needed angels in the next 3 hours
|
* Returns the number of needed angels in the next 3 hours
|
||||||
*
|
*
|
||||||
|
* @param ShiftsFilter|null $filter
|
||||||
|
*
|
||||||
* @return int|string
|
* @return int|string
|
||||||
*/
|
*/
|
||||||
function stats_angels_needed_three_hours()
|
function stats_angels_needed_three_hours(ShiftsFilter $filter = null)
|
||||||
{
|
{
|
||||||
$now = time();
|
$in3hours = time() + 3 * 60 * 60;
|
||||||
$in3hours = $now + 3 * 60 * 60;
|
$result = Db::selectOne('
|
||||||
$result = Db::selectOne("
|
|
||||||
SELECT SUM(`count`) AS `count` FROM (
|
SELECT SUM(`count`) AS `count` FROM (
|
||||||
SELECT
|
SELECT
|
||||||
GREATEST(0,
|
GREATEST(0,
|
||||||
|
@ -82,19 +87,22 @@ function stats_angels_needed_three_hours()
|
||||||
JOIN `AngelTypes` ON `AngelTypes`.`id`=`NeededAngelTypes`.`angel_type_id`
|
JOIN `AngelTypes` ON `AngelTypes`.`id`=`NeededAngelTypes`.`angel_type_id`
|
||||||
WHERE `AngelTypes`.`show_on_dashboard`=TRUE
|
WHERE `AngelTypes`.`show_on_dashboard`=TRUE
|
||||||
AND `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`
|
AND `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`
|
||||||
|
' . ($filter ? 'AND NeededAngelTypes.angel_type_id IN (' . implode(',', $filter->getTypes()) . ')' : '') . '
|
||||||
) - (
|
) - (
|
||||||
SELECT COUNT(*) FROM `ShiftEntry`
|
SELECT COUNT(*) FROM `ShiftEntry`
|
||||||
JOIN `AngelTypes` ON `AngelTypes`.`id`=`ShiftEntry`.`TID`
|
JOIN `AngelTypes` ON `AngelTypes`.`id`=`ShiftEntry`.`TID`
|
||||||
WHERE `AngelTypes`.`show_on_dashboard`=TRUE
|
WHERE `AngelTypes`.`show_on_dashboard`=TRUE
|
||||||
AND `ShiftEntry`.`SID`=`Shifts`.`SID`
|
AND `ShiftEntry`.`SID`=`Shifts`.`SID`
|
||||||
AND `freeloaded`=0
|
AND `freeloaded`=0
|
||||||
|
' . ($filter ? 'AND ShiftEntry.TID IN (' . implode(',', $filter->getTypes()) . ')' : '') . '
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
AS `count`
|
AS `count`
|
||||||
FROM `Shifts`
|
FROM `Shifts`
|
||||||
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
|
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
|
||||||
WHERE `end` > ? AND `start` < ?
|
WHERE `end` > UNIX_TIMESTAMP() AND `start` < ?
|
||||||
AND s.shift_id IS NULL
|
AND s.shift_id IS NULL
|
||||||
|
'. ($filter ? 'AND Shifts.RID IN (' . implode(',', $filter->getRooms()) . ')' : '') . '
|
||||||
|
|
||||||
UNION ALL
|
UNION ALL
|
||||||
|
|
||||||
|
@ -106,37 +114,38 @@ function stats_angels_needed_three_hours()
|
||||||
JOIN `AngelTypes` ON `AngelTypes`.`id`=`NeededAngelTypes`.`angel_type_id`
|
JOIN `AngelTypes` ON `AngelTypes`.`id`=`NeededAngelTypes`.`angel_type_id`
|
||||||
WHERE `AngelTypes`.`show_on_dashboard`=TRUE
|
WHERE `AngelTypes`.`show_on_dashboard`=TRUE
|
||||||
AND `NeededAngelTypes`.`room_id`=`Shifts`.`RID`
|
AND `NeededAngelTypes`.`room_id`=`Shifts`.`RID`
|
||||||
|
' . ($filter ? 'AND NeededAngelTypes.angel_type_id IN (' . implode(',', $filter->getTypes()) . ')' : '') . '
|
||||||
) - (
|
) - (
|
||||||
SELECT COUNT(*) FROM `ShiftEntry`
|
SELECT COUNT(*) FROM `ShiftEntry`
|
||||||
JOIN `AngelTypes` ON `AngelTypes`.`id`=`ShiftEntry`.`TID`
|
JOIN `AngelTypes` ON `AngelTypes`.`id`=`ShiftEntry`.`TID`
|
||||||
WHERE `AngelTypes`.`show_on_dashboard`=TRUE
|
WHERE `AngelTypes`.`show_on_dashboard`=TRUE
|
||||||
AND `ShiftEntry`.`SID`=`Shifts`.`SID`
|
AND `ShiftEntry`.`SID`=`Shifts`.`SID`
|
||||||
AND `freeloaded`=0
|
AND `freeloaded`=0
|
||||||
|
' . ($filter ? 'AND ShiftEntry.TID IN (' . implode(',', $filter->getTypes()) . ')' : '') . '
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
AS `count`
|
AS `count`
|
||||||
FROM `Shifts`
|
FROM `Shifts`
|
||||||
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
|
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
|
||||||
WHERE `end` > ? AND `start` < ?
|
WHERE `end` > UNIX_TIMESTAMP() AND `start` < ?
|
||||||
AND NOT s.shift_id IS NULL
|
AND NOT s.shift_id IS NULL
|
||||||
) AS `tmp`", [
|
'. ($filter ? 'AND Shifts.RID IN (' . implode(',', $filter->getRooms()) . ')' : '') . '
|
||||||
$now,
|
) AS `tmp`', [
|
||||||
$in3hours,
|
$in3hours,
|
||||||
$now,
|
|
||||||
$in3hours
|
$in3hours
|
||||||
]);
|
]);
|
||||||
if (empty($result['count'])) {
|
|
||||||
return '-';
|
return $result['count'] ?: '-';
|
||||||
}
|
|
||||||
return $result['count'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of needed angels for nightshifts (see config)
|
* Returns the number of needed angels for nightshifts (see config)
|
||||||
*
|
*
|
||||||
|
* @param ShiftsFilter|null $filter
|
||||||
|
*
|
||||||
* @return int|string
|
* @return int|string
|
||||||
*/
|
*/
|
||||||
function stats_angels_needed_for_nightshifts()
|
function stats_angels_needed_for_nightshifts(ShiftsFilter $filter = null)
|
||||||
{
|
{
|
||||||
$nightShiftsConfig = config('night_shifts');
|
$nightShiftsConfig = config('night_shifts');
|
||||||
$nightStartTime = $nightShiftsConfig['start'];
|
$nightStartTime = $nightShiftsConfig['start'];
|
||||||
|
@ -147,7 +156,7 @@ function stats_angels_needed_for_nightshifts()
|
||||||
date('Y-m-d', time() + 12 * 60 * 60) . ' ' . $nightStartTime . ':00'
|
date('Y-m-d', time() + 12 * 60 * 60) . ' ' . $nightStartTime . ':00'
|
||||||
);
|
);
|
||||||
$night_end = $night_start + ($nightEndTime - $nightStartTime) * 60 * 60;
|
$night_end = $night_start + ($nightEndTime - $nightStartTime) * 60 * 60;
|
||||||
$result = Db::selectOne("
|
$result = Db::selectOne('
|
||||||
SELECT SUM(`count`) AS `count` FROM (
|
SELECT SUM(`count`) AS `count` FROM (
|
||||||
SELECT
|
SELECT
|
||||||
GREATEST(0,
|
GREATEST(0,
|
||||||
|
@ -157,12 +166,14 @@ function stats_angels_needed_for_nightshifts()
|
||||||
JOIN `AngelTypes` ON `AngelTypes`.`id`=`NeededAngelTypes`.`angel_type_id`
|
JOIN `AngelTypes` ON `AngelTypes`.`id`=`NeededAngelTypes`.`angel_type_id`
|
||||||
WHERE `AngelTypes`.`show_on_dashboard`=TRUE
|
WHERE `AngelTypes`.`show_on_dashboard`=TRUE
|
||||||
AND `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`
|
AND `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`
|
||||||
|
' . ($filter ? 'AND NeededAngelTypes.angel_type_id IN (' . implode(',', $filter->getTypes()) . ')' : '') . '
|
||||||
) - (
|
) - (
|
||||||
SELECT COUNT(*) FROM `ShiftEntry`
|
SELECT COUNT(*) FROM `ShiftEntry`
|
||||||
JOIN `AngelTypes` ON `AngelTypes`.`id`=`ShiftEntry`.`TID`
|
JOIN `AngelTypes` ON `AngelTypes`.`id`=`ShiftEntry`.`TID`
|
||||||
WHERE `AngelTypes`.`show_on_dashboard`=TRUE
|
WHERE `AngelTypes`.`show_on_dashboard`=TRUE
|
||||||
AND `ShiftEntry`.`SID`=`Shifts`.`SID`
|
AND `ShiftEntry`.`SID`=`Shifts`.`SID`
|
||||||
AND `freeloaded`=0
|
AND `freeloaded`=0
|
||||||
|
' . ($filter ? 'AND ShiftEntry.TID IN (' . implode(',', $filter->getTypes()) . ')' : '') . '
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
AS `count`
|
AS `count`
|
||||||
|
@ -170,6 +181,7 @@ function stats_angels_needed_for_nightshifts()
|
||||||
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
|
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
|
||||||
WHERE `end` > ? AND `start` < ?
|
WHERE `end` > ? AND `start` < ?
|
||||||
AND s.shift_id IS NULL
|
AND s.shift_id IS NULL
|
||||||
|
'. ($filter ? 'AND Shifts.RID IN (' . implode(',', $filter->getRooms()) . ')' : '') . '
|
||||||
|
|
||||||
UNION ALL
|
UNION ALL
|
||||||
|
|
||||||
|
@ -181,12 +193,14 @@ function stats_angels_needed_for_nightshifts()
|
||||||
JOIN `AngelTypes` ON `AngelTypes`.`id`=`NeededAngelTypes`.`angel_type_id`
|
JOIN `AngelTypes` ON `AngelTypes`.`id`=`NeededAngelTypes`.`angel_type_id`
|
||||||
WHERE `AngelTypes`.`show_on_dashboard`=TRUE
|
WHERE `AngelTypes`.`show_on_dashboard`=TRUE
|
||||||
AND `NeededAngelTypes`.`room_id`=`Shifts`.`RID`
|
AND `NeededAngelTypes`.`room_id`=`Shifts`.`RID`
|
||||||
|
' . ($filter ? 'AND AngelTypes.id IN (' . implode(',', $filter->getTypes()) . ')' : '') . '
|
||||||
) - (
|
) - (
|
||||||
SELECT COUNT(*) FROM `ShiftEntry`
|
SELECT COUNT(*) FROM `ShiftEntry`
|
||||||
JOIN `AngelTypes` ON `AngelTypes`.`id`=`ShiftEntry`.`TID`
|
JOIN `AngelTypes` ON `AngelTypes`.`id`=`ShiftEntry`.`TID`
|
||||||
WHERE `AngelTypes`.`show_on_dashboard`=TRUE
|
WHERE `AngelTypes`.`show_on_dashboard`=TRUE
|
||||||
AND `ShiftEntry`.`SID`=`Shifts`.`SID`
|
AND `ShiftEntry`.`SID`=`Shifts`.`SID`
|
||||||
AND `freeloaded`=0
|
AND `freeloaded`=0
|
||||||
|
' . ($filter ? 'AND ShiftEntry.TID IN (' . implode(',', $filter->getTypes()) . ')' : '') . '
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
AS `count`
|
AS `count`
|
||||||
|
@ -194,14 +208,13 @@ function stats_angels_needed_for_nightshifts()
|
||||||
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
|
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
|
||||||
WHERE `end` > ? AND `start` < ?
|
WHERE `end` > ? AND `start` < ?
|
||||||
AND NOT s.shift_id IS NULL
|
AND NOT s.shift_id IS NULL
|
||||||
) AS `tmp`", [
|
'. ($filter ? 'AND Shifts.RID IN (' . implode(',', $filter->getRooms()) . ')' : '') . '
|
||||||
|
) AS `tmp`', [
|
||||||
$night_start,
|
$night_start,
|
||||||
$night_end,
|
$night_end,
|
||||||
$night_start,
|
$night_start,
|
||||||
$night_end
|
$night_end
|
||||||
]);
|
]);
|
||||||
if (empty($result['count'])) {
|
|
||||||
return '-';
|
return $result['count'] ?: '-';
|
||||||
}
|
|
||||||
return $result['count'];
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ function public_dashboard_view($stats, $free_shifts)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$isFiltered = request()->get('filtered');
|
||||||
return page([
|
return page([
|
||||||
div('public-dashboard', [
|
div('public-dashboard', [
|
||||||
div('first', [
|
div('first', [
|
||||||
|
@ -41,21 +42,26 @@ function public_dashboard_view($stats, $free_shifts)
|
||||||
'<script>
|
'<script>
|
||||||
$(function() {
|
$(function() {
|
||||||
setInterval(function() {
|
setInterval(function() {
|
||||||
$(\'#public-dashboard\').parent().load(window.location.href + \' #public-dashboard\');
|
$(\'#public-dashboard\').load(window.location.href + \' #public-dashboard\');
|
||||||
}, 60000);
|
}, 60000);
|
||||||
})
|
})
|
||||||
</script>'
|
</script>'
|
||||||
], 'statistics'),
|
], 'statistics'),
|
||||||
$needed_angels
|
$needed_angels
|
||||||
], 'public-dashboard'),
|
], 'public-dashboard'),
|
||||||
div('first col-md-12 text-center', [
|
div('first col-md-12 text-center', [buttons([
|
||||||
buttons([
|
button_js(
|
||||||
button_js('
|
'
|
||||||
$(\'#navbar-collapse-1,#footer,#fullscreen-button\').remove();
|
$(\'#navbar-collapse-1,.navbar-nav,.navbar-toggle,#footer,#fullscreen-button\').remove();
|
||||||
$(\'.navbar-brand\').append(\' ' . __('Public Dashboard') . '\');
|
$(\'.navbar-brand\').append(\' ' . __('Public Dashboard') . '\');
|
||||||
', glyph('fullscreen') . __('Fullscreen'))
|
',
|
||||||
])
|
glyph('fullscreen') . __('Fullscreen')
|
||||||
], 'fullscreen-button')
|
),
|
||||||
|
auth()->user() ? button(
|
||||||
|
public_dashboard_link($isFiltered ? [] : ['filtered' => 1]),
|
||||||
|
glyph('filter') . ($isFiltered ? __('All') : __('Filtered'))
|
||||||
|
) : ''
|
||||||
|
])], 'fullscreen-button'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2157,6 +2157,9 @@ msgstr "Noch zu schaffende Stunden"
|
||||||
msgid "Fullscreen"
|
msgid "Fullscreen"
|
||||||
msgstr "Vollbild"
|
msgstr "Vollbild"
|
||||||
|
|
||||||
|
msgid "Filtered"
|
||||||
|
msgstr "Filtern"
|
||||||
|
|
||||||
#: includes/view/Questions_view.php:28
|
#: includes/view/Questions_view.php:28
|
||||||
msgid "Open questions"
|
msgid "Open questions"
|
||||||
msgstr "Offene Fragen"
|
msgstr "Offene Fragen"
|
||||||
|
|
Loading…
Reference in New Issue