From 74f3677f19b70bbe6655f2d9d9a42792b22120de Mon Sep 17 00:00:00 2001 From: msquare Date: Mon, 11 Dec 2017 22:26:36 +0100 Subject: add quick+dirty public dashboard --- .../controller/public_dashboard_controller.php | 70 ++++++++++++++++++++++ includes/includes.php | 2 + includes/view/PublicDashboard_view.php | 31 ++++++++++ 3 files changed, 103 insertions(+) create mode 100644 includes/controller/public_dashboard_controller.php create mode 100644 includes/view/PublicDashboard_view.php (limited to 'includes') diff --git a/includes/controller/public_dashboard_controller.php b/includes/controller/public_dashboard_controller.php new file mode 100644 index 00000000..dc81ba2c --- /dev/null +++ b/includes/controller/public_dashboard_controller.php @@ -0,0 +1,70 @@ + ? 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) + ]; +} +?> \ No newline at end of file diff --git a/includes/includes.php b/includes/includes.php index a42f960f..c533cfe8 100644 --- a/includes/includes.php +++ b/includes/includes.php @@ -30,6 +30,7 @@ $includeFiles = [ __DIR__ . '/../includes/view/AngelTypes_view.php', __DIR__ . '/../includes/view/EventConfig_view.php', + __DIR__ . '/../includes/view/PublicDashboard_view.php', __DIR__ . '/../includes/view/Questions_view.php', __DIR__ . '/../includes/view/Rooms_view.php', __DIR__ . '/../includes/view/ShiftCalendarLane.php', @@ -46,6 +47,7 @@ $includeFiles = [ __DIR__ . '/../includes/controller/angeltypes_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/shift_entries_controller.php', __DIR__ . '/../includes/controller/shifts_controller.php', diff --git a/includes/view/PublicDashboard_view.php b/includes/view/PublicDashboard_view.php new file mode 100644 index 00000000..6fa40ed4 --- /dev/null +++ b/includes/view/PublicDashboard_view.php @@ -0,0 +1,31 @@ +$(function(){setTimeout(function(){window.location.reload();}, 60000)})' + ]) + ]); +} + +?> \ No newline at end of file -- cgit v1.2.3-54-g00ecf