summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authormsquare <msquare@notrademark.de>2019-08-15 21:14:54 +0200
committermsquare <msquare@notrademark.de>2019-08-15 21:14:54 +0200
commit76a7ceb27b91569924df39f0ed134b87a63d4607 (patch)
tree2f14888fcc4da63ab1c1420d86bbe3df12899526 /includes
parente4c2bd104b7f335c006784036747ba69620dda02 (diff)
fixes #635: set end of the last created shift to the official end inestead of first shift change on next day
Diffstat (limited to 'includes')
-rw-r--r--includes/pages/admin_shifts.php16
1 files changed, 9 insertions, 7 deletions
diff --git a/includes/pages/admin_shifts.php b/includes/pages/admin_shifts.php
index 8ff2f226..511dc5ca 100644
--- a/includes/pages/admin_shifts.php
+++ b/includes/pages/admin_shifts.php
@@ -213,23 +213,25 @@ function admin_shifts()
$shift_start = $shift_end;
} while ($shift_end < $end);
} elseif ($mode == 'variable') {
+ // Fehlende Minutenangaben ergänzen
array_walk($change_hours, function (&$value) {
if (!preg_match('/^\d{1,2}:\d{2}$/', $value)) {
$value .= ':00';
}
});
+ // Chronologisch absteigend sortieren
usort($change_hours, function ($a, $b) {
return str_replace(':', '', $a) > str_replace(':', '', $b) ? -1 : 1;
});
+ // Start-Tag
$day = parse_date('Y-m-d H:i', date('Y-m-d', $start) . ' 00:00');
+
$change_index = 0;
// Ersten/nächsten passenden Schichtwechsel suchen
foreach ($change_hours as $i => $change_time) {
- $change_time = explode(':', $change_time);
- $change_hour = $change_time[0];
- $change_minute = $change_time[1];
+ list($change_hour, $change_minute) = explode(':', $change_time);
$shift_end = $day + $change_hour * 60 * 60 + $change_minute * 60;
if ($start < $shift_end) {
@@ -247,10 +249,7 @@ function admin_shifts()
do {
$day = parse_date('Y-m-d H:i', date('Y-m-d', $shift_start) . ' 00:00');
- $change_time = $change_hours[$change_index];
- $change_time = explode(':', $change_time);
- $change_hour = $change_time[0];
- $change_minute = $change_time[1];
+ list($change_hour, $change_minute) = explode(':', $change_hours[$change_index]);
$shift_end = $day + $change_hour * 60 * 60 + $change_minute * 60;
@@ -259,6 +258,9 @@ function admin_shifts()
}
if ($shift_start >= $shift_end) {
$shift_end += 24 * 60 * 60;
+ if ($shift_end > $end) {
+ $shift_end = $end;
+ }
}
$shifts[] = [