diff --git a/application/models/Service_model.php b/application/models/Service_model.php index 639fc1e..9672d99 100755 --- a/application/models/Service_model.php +++ b/application/models/Service_model.php @@ -622,6 +622,10 @@ class Service_model extends CI_Model { $finishTime = new DateTime($selectedDate . ' ' . $schedule->end_time, new DateTimeZone('Europe/Oslo')); } + // A műszak valódi kezdete - $dayStartTime-ot a mai napra alább felülírjuk a legkorábban + // foglalható időponttal, az ebédszünet számítása viszont a tényleges műszakkal dolgozik. + $shiftStartTime = clone $dayStartTime; + // --- ÚJ: ma foglalva csak (következő 15 perces blokk + 1 óra) UTÁN legyen időpont --- if ($selectedDate == date('Y-m-d')) { // használd a helyi (Oslo) időt, ne az esetleges UTC defaultot @@ -648,7 +652,7 @@ class Service_model extends CI_Model { // --- Lunch break setup --- // Pre-fetch all bookings for the day so we can do hypothetical checks per slot $workerRow = $this->db->query("SELECT lunch_window_start, lunch_window_end, lunch_preferred_time FROM workers WHERE worker_id = ? LIMIT 1", array($worker_id))->row(); - $shiftSeconds = $finishTime->getTimestamp() - $dayStartTime->getTimestamp(); + $shiftSeconds = $finishTime->getTimestamp() - $shiftStartTime->getTimestamp(); $lunchRequired = $workerRow && $workerRow->lunch_window_start && $workerRow->lunch_window_end && $shiftSeconds >= 6 * 3600; $allBookings = []; @@ -705,7 +709,7 @@ class Service_model extends CI_Model { ]]); $canStillBreak = $this->computeLunchBreak( $workerRow->lunch_window_start, $workerRow->lunch_window_end, - $selectedDate, $hypo, $finishTime, $dayStartTime, + $selectedDate, $hypo, $finishTime, $shiftStartTime, $workerRow->lunch_preferred_time ) !== null; if (!$canStillBreak) continue; // booking this slot would eliminate the only break opportunity