From ae1f951cf8088b69f0f83ad2779961a7768d84be Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Mon, 21 Sep 2020 14:26:15 +0300 Subject: [PATCH] Resolve the any-provider selection before processing provider information (#885). --- application/controllers/Appointments.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/application/controllers/Appointments.php b/application/controllers/Appointments.php index f1bcd0ad..779d00bf 100755 --- a/application/controllers/Appointments.php +++ b/application/controllers/Appointments.php @@ -967,6 +967,14 @@ class Appointments extends CI_Controller { $appointment = $post_data['appointment']; $customer = $post_data['customer']; + // Check appointment availability before registering it to the database. + $appointment['id_users_provider'] = $this->check_datetime_availability(); + + if ( ! $appointment['id_users_provider']) + { + throw new Exception(lang('requested_hour_is_unavailable')); + } + $provider = $this->providers_model->get_row($appointment['id_users_provider']); $service = $this->services_model->get_row($appointment['id_services']); @@ -985,12 +993,6 @@ class Appointments extends CI_Controller { return; } - // Check appointment availability before registering it to the database. - if ( ! $this->check_datetime_availability()) - { - throw new Exception(lang('requested_hour_is_unavailable')); - } - if ($this->customers_model->exists($customer)) { $customer['id'] = $this->customers_model->find_record_id($customer);