From 94ba51bc461ec4f696eee3d1267e8f0c7134f98c Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Tue, 29 Aug 2023 23:41:27 +0200 Subject: [PATCH] Shifts creation: Fix start hours before 10:00 --- includes/pages/admin_shifts.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/includes/pages/admin_shifts.php b/includes/pages/admin_shifts.php index bbf58ad9..3f760d7b 100644 --- a/includes/pages/admin_shifts.php +++ b/includes/pages/admin_shifts.php @@ -141,9 +141,15 @@ function admin_shifts() ); // Fehlende Minutenangaben ergänzen, 24 Uhr -> 00 Uhr array_walk($change_hours, function (&$value) use ($valid) { + // Add minutes if (!preg_match('/^(\d{1,2}):\d{2}$/', $value)) { $value .= ':00'; } + // Add 0 before low hours + if (preg_match('/^\d:\d{2}$/', $value)) { + $value = '0' . $value; + } + // Fix 24:00 if ($value == '24:00') { $value = '00:00'; } @@ -248,10 +254,10 @@ function admin_shifts() // Alle Schichtwechselstunden durchgehen for ($i = 0; $i < count($change_hours); $i++) { $start_hour = $change_hours[$i]; - if ($i < count($change_hours) - 1) { + if (isset($change_hours[$i+1])) { // Normales Intervall zwischen zwei Schichtwechselstunden $end_hour = $change_hours[$i + 1]; - } elseif ($shift_over_midnight) { + } elseif ($shift_over_midnight && $day != $end_day) { // Letzte Schichtwechselstunde: Wenn eine 24h Abdeckung gewünscht ist, // hier die erste Schichtwechselstunde als Ende einsetzen $end_hour = $change_hours[0];