From c0e7a082f3cd0565f24957becdf1881532e97d28 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Sun, 19 Jun 2022 14:38:46 +0100 Subject: [PATCH] Check both appointments and unavailabilities when generating available hours --- application/libraries/Availability.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/application/libraries/Availability.php b/application/libraries/Availability.php index ac14c3f2..7c447926 100644 --- a/application/libraries/Availability.php +++ b/application/libraries/Availability.php @@ -38,6 +38,7 @@ class Availability { $this->CI->load->model('secretaries_model'); $this->CI->load->model('secretaries_model'); $this->CI->load->model('settings_model'); + $this->CI->load->model('unavailabilities_model'); $this->CI->load->library('ics_file'); } @@ -110,7 +111,12 @@ class Availability { $where .= ' AND id != ' . $escaped_exclude_appointment_id; } - $appointments = $this->CI->appointments_model->get($where); + $appointments = array_values( + array_merge( + $this->CI->appointments_model->get($where), + $this->CI->unavailabilities_model->get($where), + ) + ); // Find the empty spaces on the plan. The first split between the plan is due to a break (if any). After that // every reserved appointment is considered to be a taken space in the plan.