diff --git a/shiftcounter.php b/shiftcounter.php
index 4e2e333..da4e51b 100644
--- a/shiftcounter.php
+++ b/shiftcounter.php
@@ -22,45 +22,48 @@ for($i = 0; $i < 2; $i++) {
natsort($worklists);
-$checkedLists = $_GET['worklist'];
-
-$monthTrans = ['jan' => 'Jan', 'feb' => 'Feb', 'mrt' => 'Mar', 'apr' => 'Apr', 'mei' => 'May', 'jul' => 'Jul', 'aug' => 'Aug', 'sep' => 'Sep',
- 'okt' => 'Oct', 'nov' => 'Nov', 'dec' => 'Dec'];
-
$all_names = [];
$totalShifted = 0;
$total = 0;
+$checkedLists = [];
-foreach ($checkedLists as $site) {
- $site = 'https://old.wina.be/worklists/' . $site;
- $data = file_get_contents($site);
+if (isset($_GET['worklist'])) {
+ $checkedLists = $_GET['worklist'];
- preg_match_all('/
.*?<\/table>)/s', $data, $shiften);
+ $shiften = $shiften[1];
- preg_match_all('/data_shift.*?Invulling.*?
(.*?)<\/td>/s', $shift, $blockNames);
- if (count($blockNames[1]) !== 0) {
- preg_match_all('/(.*?)<\/span>/s', $blockNames[1][0], $names);
+ foreach ($shiften as $shift) {
+ preg_match_all('/data_shift.*?Start<\/td>.*?>.*?(\d.*?)<\/td>/s', $shift, $start);
+ preg_match_all('/data_shift.*?Einde<\/td>.*?>.*?(\d.*?)<\/td>/s', $shift, $einde);
+ $start = explode(' ', $start[1][0]);
+ $start[1] = $monthTrans[$start[1]];
+ $start = DateTime::createFromFormat('j M Y - G:i', implode(' ', $start));
+ $einde = explode(' ', $einde[1][0]);
+ $einde[1] = $monthTrans[$einde[1]];
+ $einde = DateTime::createFromFormat('j M Y - G:i', implode(' ', $einde));
- foreach ($names[1] as $name) {
- if (!array_key_exists($name, $all_names)) {
- $all_names[$name] = $diff;
- } else {
- $all_names[$name] += $diff;
+ $diff = ($einde->getTimestamp() - $start->getTimestamp()) / 3600;
+
+ preg_match_all('/data_shift.*?Invulling.*?(.*?)<\/td>/s', $shift, $blockNames);
+ if (count($blockNames[1]) !== 0) {
+ preg_match_all('/(.*?)<\/span>/s', $blockNames[1][0], $names);
+
+ foreach ($names[1] as $name) {
+ if (!array_key_exists($name, $all_names)) {
+ $all_names[$name] = $diff;
+ } else {
+ $all_names[$name] += $diff;
+ }
+ $totalShifted += $diff;
}
- $totalShifted += $diff;
}
}
}
@@ -73,9 +76,9 @@ $avg = $totalShifted / count($all_names);
-
-
+
Wina shift counter
+
@@ -90,7 +93,7 @@ $avg = $totalShifted / count($all_names);
Wina shift counter