From 76b8f951ae66b971e34b4b970182449f84ea1484 Mon Sep 17 00:00:00 2001 From: Arthur Bols Date: Sun, 24 Mar 2019 23:15:14 +0100 Subject: [PATCH] added dateperiod --- shiftcounter.php | 44 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/shiftcounter.php b/shiftcounter.php index 80f5e26..d572a24 100644 --- a/shiftcounter.php +++ b/shiftcounter.php @@ -37,8 +37,20 @@ $totalShifted = 0; $total = 0; $checkedLists = []; -if (isset($_GET['worklist'])) { - $checkedLists = $_GET['worklist']; +if (isset($_GET['date_period'])) { + $checkedLists = []; + $start = \DateTime::createFromFormat('d/m/Y', $_GET['date_period']['startDate']); + $end = \DateTime::createFromFormat('d/m/Y', $_GET['date_period']['endDate']); + + foreach($worklists as $key => $list) { + if ($list[1] >= $start && $list[1] <= $end) $checkedLists[] = $key; + } +} + +if (isset($_GET['worklist']) || count($checkedLists) > 0) { + + if (count($checkedLists) === 0) + $checkedLists = $_GET['worklist']; foreach ($checkedLists as $site) { $site = 'https://old.wina.be/worklists/' . $site; @@ -90,9 +102,10 @@ if ($totalShifted !== 0 & count($all_names) !== 0) - + - + + @@ -109,11 +122,22 @@ if ($totalShifted !== 0 & count($all_names) !== 0) } ?> +

or enter a period:

+
+ +
+ to +
+ + + +
+ 0) { - echo '

' . floor($totalShifted) . ' uur ' . ($totalShifted - floor($totalShifted) > 0 ? ' en ' . ($totalShifted - floor($totalShifted)) * 60 . ' minuten' : '') . ' geshift!
+ echo '

' . floor($totalShifted) . ' uur ' . ($totalShifted - floor($totalShifted) > 0 ? ' en ' . round(($totalShifted - floor($totalShifted)) * 60) . ' minuten' : '') . ' geshift!
Gemiddeld: ' . floor($avg) . ' uur en ' . round(($avg - floor($avg)) * 60) . ' minuten

'; } @@ -147,10 +171,11 @@ if ($totalShifted !== 0 & count($all_names) !== 0) - - + + - + +