From 2a134e6c0b8e7c5bbeade38d29052194bd9dfa46 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Mon, 17 Sep 2018 12:33:15 +0200 Subject: Config: Removed nightshifts query --- includes/model/Stats.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'includes/model/Stats.php') diff --git a/includes/model/Stats.php b/includes/model/Stats.php index 20376ac6..c8342d82 100644 --- a/includes/model/Stats.php +++ b/includes/model/Stats.php @@ -128,17 +128,21 @@ function stats_angels_needed_three_hours() } /** - * Returns the number of needed angels for nightshifts (between 2 and 8) + * Returns the number of needed angels for nightshifts (see config) * * @return int|string */ function stats_angels_needed_for_nightshifts() { + $nightShiftsConfig = config('night_shifts'); + $nightStartTime = $nightShiftsConfig['start']; + $nightEndTime = $nightShiftsConfig['end']; + $night_start = parse_date( 'Y-m-d H:i', - date('Y-m-d', time() + 12 * 60 * 60) . ' 02:00' + date('Y-m-d', time() + 12 * 60 * 60) . ' ' . $nightStartTime . ':00' ); - $night_end = $night_start + 6 * 60 * 60; + $night_end = $night_start + ($nightEndTime - $nightStartTime) * 60 * 60; $result = Db::selectOne(" SELECT SUM(`count`) AS `count` FROM ( SELECT -- cgit v1.2.3-70-g09d2