Correction in the Appointments check datetime availability method

This commit is contained in:
Alex Tselegidis 2020-11-12 14:46:51 +02:00
parent 423edc80c8
commit 0c20363b8b
2 changed files with 6 additions and 14 deletions

View file

@ -578,23 +578,15 @@ class Appointments extends CI_Controller {
$provider = $this->providers_model->get_row($appointment['id_users_provider']); $provider = $this->providers_model->get_row($appointment['id_users_provider']);
$available_periods = $this->availability->get_available_periods($date, $provider, $exclude_appointment_id); $available_hours = $this->availability->get_available_hours($date, $service, $provider, $exclude_appointment_id);
$is_still_available = FALSE; $is_still_available = FALSE;
foreach ($available_periods as $available_period) $appointment_hour = date('H:i', strtotime($appointment['start_datetime']));
foreach ($available_hours as $available_hour)
{ {
$appointment_start = new DateTime($appointment['start_datetime']); if ($appointment_hour === $available_hour)
$appointment_start = $appointment_start->format('H:i');
$appointment_end = new DateTime($appointment['start_datetime']);
$appointment_end->add(new DateInterval('PT' . $service['duration'] . 'M'));
$appointment_end = $appointment_end->format('H:i');
$available_period_start = date('H:i', strtotime($available_period['start']));
$available_period_end = date('H:i', strtotime($available_period['end']));
if ($available_period_start <= $appointment_start && $available_period_end >= $appointment_end)
{ {
$is_still_available = TRUE; $is_still_available = TRUE;
break; break;

View file

@ -79,7 +79,7 @@ class Availability {
* *
* @throws Exception * @throws Exception
*/ */
public function get_available_periods( protected function get_available_periods(
$date, $date,
$provider, $provider,
$exclude_appointment_id = NULL $exclude_appointment_id = NULL