fixes #635: set end of the last created shift to the official end inestead of first shift change on next day
This commit is contained in:
parent
e4c2bd104b
commit
76a7ceb27b
|
@ -213,23 +213,25 @@ function admin_shifts()
|
||||||
$shift_start = $shift_end;
|
$shift_start = $shift_end;
|
||||||
} while ($shift_end < $end);
|
} while ($shift_end < $end);
|
||||||
} elseif ($mode == 'variable') {
|
} elseif ($mode == 'variable') {
|
||||||
|
// Fehlende Minutenangaben ergänzen
|
||||||
array_walk($change_hours, function (&$value) {
|
array_walk($change_hours, function (&$value) {
|
||||||
if (!preg_match('/^\d{1,2}:\d{2}$/', $value)) {
|
if (!preg_match('/^\d{1,2}:\d{2}$/', $value)) {
|
||||||
$value .= ':00';
|
$value .= ':00';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Chronologisch absteigend sortieren
|
||||||
usort($change_hours, function ($a, $b) {
|
usort($change_hours, function ($a, $b) {
|
||||||
return str_replace(':', '', $a) > str_replace(':', '', $b) ? -1 : 1;
|
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');
|
$day = parse_date('Y-m-d H:i', date('Y-m-d', $start) . ' 00:00');
|
||||||
|
|
||||||
$change_index = 0;
|
$change_index = 0;
|
||||||
// Ersten/nächsten passenden Schichtwechsel suchen
|
// Ersten/nächsten passenden Schichtwechsel suchen
|
||||||
foreach ($change_hours as $i => $change_time) {
|
foreach ($change_hours as $i => $change_time) {
|
||||||
$change_time = explode(':', $change_time);
|
list($change_hour, $change_minute) = explode(':', $change_time);
|
||||||
$change_hour = $change_time[0];
|
|
||||||
$change_minute = $change_time[1];
|
|
||||||
|
|
||||||
$shift_end = $day + $change_hour * 60 * 60 + $change_minute * 60;
|
$shift_end = $day + $change_hour * 60 * 60 + $change_minute * 60;
|
||||||
if ($start < $shift_end) {
|
if ($start < $shift_end) {
|
||||||
|
@ -247,10 +249,7 @@ function admin_shifts()
|
||||||
do {
|
do {
|
||||||
$day = parse_date('Y-m-d H:i', date('Y-m-d', $shift_start) . ' 00:00');
|
$day = parse_date('Y-m-d H:i', date('Y-m-d', $shift_start) . ' 00:00');
|
||||||
|
|
||||||
$change_time = $change_hours[$change_index];
|
list($change_hour, $change_minute) = explode(':', $change_hours[$change_index]);
|
||||||
$change_time = explode(':', $change_time);
|
|
||||||
$change_hour = $change_time[0];
|
|
||||||
$change_minute = $change_time[1];
|
|
||||||
|
|
||||||
$shift_end = $day + $change_hour * 60 * 60 + $change_minute * 60;
|
$shift_end = $day + $change_hour * 60 * 60 + $change_minute * 60;
|
||||||
|
|
||||||
|
@ -259,6 +258,9 @@ function admin_shifts()
|
||||||
}
|
}
|
||||||
if ($shift_start >= $shift_end) {
|
if ($shift_start >= $shift_end) {
|
||||||
$shift_end += 24 * 60 * 60;
|
$shift_end += 24 * 60 * 60;
|
||||||
|
if ($shift_end > $end) {
|
||||||
|
$shift_end = $end;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$shifts[] = [
|
$shifts[] = [
|
||||||
|
|
Loading…
Reference in New Issue