From ff94df53d69234ae2625462a76926e131ade05b7 Mon Sep 17 00:00:00 2001 From: msquare Date: Tue, 12 Dec 2017 21:57:57 +0100 Subject: finish basic public dashboard --- .../controller/public_dashboard_controller.php | 66 +++------------------- 1 file changed, 9 insertions(+), 57 deletions(-) (limited to 'includes/controller/public_dashboard_controller.php') diff --git a/includes/controller/public_dashboard_controller.php b/includes/controller/public_dashboard_controller.php index dc81ba2c..bf909bed 100644 --- a/includes/controller/public_dashboard_controller.php +++ b/includes/controller/public_dashboard_controller.php @@ -1,70 +1,22 @@ ? 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']; + $stats = [ + 'needed-3-hours' => stats_angels_needed_three_hours(), + 'needed-night' => stats_angels_needed_for_nightshifts(), + 'angels-working' => stats_currently_working(), + 'hours-to-work' => stats_hours_to_work() + ]; - $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']; + $free_shifts = Shifts_free(time(), time() + 12 * 60 * 60); return [ - 'Engelsystem Public Dashboard', - public_dashboard_view($stats) + _('Engelsystem Public Dashboard'), + public_dashboard_view($stats, $free_shifts) ]; } ?> \ No newline at end of file -- cgit v1.2.3-70-g09d2