Fix timezone bug causing slots past closing time; remove lunch fallback outside window

- Add Europe/Oslo timezone to all DateTime constructors in getAvailableTimes() and
  computeLunchBreak() to prevent UTC vs local time mismatch that allowed booking
  slots 1 hour past the worker's end time on same-day bookings
- Remove fallback loop in computeLunchBreak() that pushed the lunch break outside
  the configured window; lunch break is now strictly enforced within the interval

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-07 11:52:30 +01:00
co-authored by Claude Sonnet 4.6
parent f30d8d1a07
commit 307f17faa6
8 changed files with 36 additions and 83 deletions
-35
View File
@@ -209,41 +209,6 @@ class Admin extends CI_Controller {
public function admin_worker_override() {
$this->load->helper('url');
$this->load->model('User_model');
$this->load->model('Service_model');
$data['pageTitle'] = 'Egyedi napok kezelése';
$data['workers'] = $this->Service_model->getAllWorkers();
if ($this->input->post('storeOverride')) {
$this->load->database();
$insert = [
'worker_id' => $_POST['worker_id'],
'date' => $_POST['date'],
'is_day_off' => isset($_POST['is_day_off']) ? 1 : 0,
'start_time' => $_POST['start_time'],
'end_time' => $_POST['end_time']
];
$existing = $this->db->query("SELECT * FROM worker_schedule_overrides WHERE worker_id = '{$insert['worker_id']}' AND date = '{$insert['date']}'")->row();
if ($existing) {
$this->db->where('id', $existing->id)->update('worker_schedule_overrides', $insert);
} else {
$this->db->insert('worker_schedule_overrides', $insert);
}
}
if (!empty($_GET['worker_id'])) {
$this->load->database();
$worker_id = $_GET['worker_id'];
$data['selectedWorkerId'] = $worker_id;
$data['overrides'] = $this->db->query("SELECT * FROM worker_schedule_overrides WHERE worker_id = '$worker_id' ORDER BY date ASC")->result();
}
$this->load->view('admin/worker_override', $data);
}
public function manage_worker_schedule($worker_id = null) {