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);