add quick+dirty public dashboard
This commit is contained in:
parent
afb77d22ba
commit
74f3677f19
|
@ -0,0 +1,70 @@
|
||||||
|
<?php
|
||||||
|
use Engelsystem\Database\Db;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads all data for the public dashboard
|
||||||
|
*/
|
||||||
|
function public_dashboard_controller()
|
||||||
|
{
|
||||||
|
$stats = [];
|
||||||
|
|
||||||
|
$now = time();
|
||||||
|
$in3hours = $now + 3 * 60 * 60;
|
||||||
|
$result = Db::selectOne("
|
||||||
|
SELECT SUM(
|
||||||
|
(SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`)
|
||||||
|
- (SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0)
|
||||||
|
) as `count`
|
||||||
|
FROM `Shifts`
|
||||||
|
WHERE ((`end` > ? AND `end` < ?) OR (`start` > ? AND `start` < ?))", [
|
||||||
|
$now,
|
||||||
|
$in3hours,
|
||||||
|
$now,
|
||||||
|
$in3hours
|
||||||
|
]);
|
||||||
|
$stats['needed-3-hours'] = $result['count'];
|
||||||
|
|
||||||
|
$night_start = parse_date('Y-m-d H:i', date('Y-m-d', time() + 12 * 60 * 60) . ' 02:00');
|
||||||
|
$night_end = $night_start + 6 * 60 * 60;
|
||||||
|
$result = Db::selectOne("
|
||||||
|
SELECT SUM(
|
||||||
|
(SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`)
|
||||||
|
- (SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0)
|
||||||
|
) as `count`
|
||||||
|
FROM `Shifts`
|
||||||
|
WHERE ((`end` > ? AND `end` < ?) OR (`start` > ? AND `start` < ?))", [
|
||||||
|
$night_start,
|
||||||
|
$night_end,
|
||||||
|
$night_start,
|
||||||
|
$night_end
|
||||||
|
]);
|
||||||
|
$stats['needed-night'] = $result['count'];
|
||||||
|
|
||||||
|
$result = Db::selectOne("
|
||||||
|
SELECT SUM(
|
||||||
|
(SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0)
|
||||||
|
) as `count`
|
||||||
|
FROM `Shifts`
|
||||||
|
WHERE (`end` >= ? AND `start` <= ?)", [
|
||||||
|
time(),
|
||||||
|
time()
|
||||||
|
]);
|
||||||
|
$stats['angels-working'] = $result['count'];
|
||||||
|
|
||||||
|
$result = Db::selectOne("
|
||||||
|
SELECT ROUND(SUM(
|
||||||
|
(SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0)
|
||||||
|
* (`Shifts`.`end` - `Shifts`.`start`)/3600
|
||||||
|
)) as `count`
|
||||||
|
FROM `Shifts`
|
||||||
|
WHERE `end` >= ?", [
|
||||||
|
time()
|
||||||
|
]);
|
||||||
|
$stats['hours-to-work'] = $result['count'];
|
||||||
|
|
||||||
|
return [
|
||||||
|
'Engelsystem Public Dashboard',
|
||||||
|
public_dashboard_view($stats)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
?>
|
|
@ -30,6 +30,7 @@ $includeFiles = [
|
||||||
|
|
||||||
__DIR__ . '/../includes/view/AngelTypes_view.php',
|
__DIR__ . '/../includes/view/AngelTypes_view.php',
|
||||||
__DIR__ . '/../includes/view/EventConfig_view.php',
|
__DIR__ . '/../includes/view/EventConfig_view.php',
|
||||||
|
__DIR__ . '/../includes/view/PublicDashboard_view.php',
|
||||||
__DIR__ . '/../includes/view/Questions_view.php',
|
__DIR__ . '/../includes/view/Questions_view.php',
|
||||||
__DIR__ . '/../includes/view/Rooms_view.php',
|
__DIR__ . '/../includes/view/Rooms_view.php',
|
||||||
__DIR__ . '/../includes/view/ShiftCalendarLane.php',
|
__DIR__ . '/../includes/view/ShiftCalendarLane.php',
|
||||||
|
@ -46,6 +47,7 @@ $includeFiles = [
|
||||||
|
|
||||||
__DIR__ . '/../includes/controller/angeltypes_controller.php',
|
__DIR__ . '/../includes/controller/angeltypes_controller.php',
|
||||||
__DIR__ . '/../includes/controller/event_config_controller.php',
|
__DIR__ . '/../includes/controller/event_config_controller.php',
|
||||||
|
__DIR__ . '/../includes/controller/public_dashboard_controller.php',
|
||||||
__DIR__ . '/../includes/controller/rooms_controller.php',
|
__DIR__ . '/../includes/controller/rooms_controller.php',
|
||||||
__DIR__ . '/../includes/controller/shift_entries_controller.php',
|
__DIR__ . '/../includes/controller/shift_entries_controller.php',
|
||||||
__DIR__ . '/../includes/controller/shifts_controller.php',
|
__DIR__ . '/../includes/controller/shifts_controller.php',
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Public dashboard (formerly known as angel news hub)
|
||||||
|
*/
|
||||||
|
function public_dashboard_view($stats)
|
||||||
|
{
|
||||||
|
return page([
|
||||||
|
div('first', [
|
||||||
|
div('col-xs-3 text-center', [
|
||||||
|
_('Angels needed in the next 3 hrs'),
|
||||||
|
heading($stats['needed-3-hours'], 1)
|
||||||
|
]),
|
||||||
|
div('col-xs-3 text-center', [
|
||||||
|
_('Angels needed for nightshifts'),
|
||||||
|
heading($stats['needed-night'], 1)
|
||||||
|
]),
|
||||||
|
div('col-xs-3 text-center', [
|
||||||
|
_('Angels currently working'),
|
||||||
|
heading($stats['angels-working'], 1)
|
||||||
|
]),
|
||||||
|
div('col-xs-3 text-center', [
|
||||||
|
_('Hours to be worked'),
|
||||||
|
heading($stats['hours-to-work'], 1)
|
||||||
|
]),
|
||||||
|
'<script>$(function(){setTimeout(function(){window.location.reload();}, 60000)})</script>'
|
||||||
|
])
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -12,6 +12,7 @@ $free_pages = [
|
||||||
'credits',
|
'credits',
|
||||||
'ical',
|
'ical',
|
||||||
'login',
|
'login',
|
||||||
|
'public_dashboard',
|
||||||
'rooms',
|
'rooms',
|
||||||
'shifts',
|
'shifts',
|
||||||
'shifts_json_export',
|
'shifts_json_export',
|
||||||
|
@ -77,6 +78,9 @@ if (
|
||||||
$title = user_password_recovery_title();
|
$title = user_password_recovery_title();
|
||||||
$content = user_password_recovery_controller();
|
$content = user_password_recovery_controller();
|
||||||
break;
|
break;
|
||||||
|
case 'public_dashboard':
|
||||||
|
list($title, $content) = public_dashboard_controller();
|
||||||
|
break;
|
||||||
case 'angeltypes':
|
case 'angeltypes':
|
||||||
list($title, $content) = angeltypes_controller();
|
list($title, $content) = angeltypes_controller();
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue