diff --git a/application/models/Appointments_model.php b/application/models/Appointments_model.php index 4a96eb3b..1c385d56 100644 --- a/application/models/Appointments_model.php +++ b/application/models/Appointments_model.php @@ -92,12 +92,16 @@ class Appointments_model extends EA_Model { } // Make sure all required fields are provided. + + $require_notes = filter_var(setting('require_notes'), FILTER_VALIDATE_BOOLEAN); + if ( empty($appointment['start_datetime']) || empty($appointment['end_datetime']) || empty($appointment['id_services']) || empty($appointment['id_users_provider']) || empty($appointment['id_users_customer']) + || (empty($appointment['notes']) && $require_notes) ) { throw new InvalidArgumentException('Not all required fields are provided: ' . print_r($appointment, TRUE)); diff --git a/application/models/Customers_model.php b/application/models/Customers_model.php index f00e1905..994034fc 100644 --- a/application/models/Customers_model.php +++ b/application/models/Customers_model.php @@ -101,7 +101,6 @@ class Customers_model extends EA_Model { $require_address = filter_var(setting('require_address'), FILTER_VALIDATE_BOOLEAN); $require_city = filter_var(setting('require_city'), FILTER_VALIDATE_BOOLEAN); $require_zip_code = filter_var(setting('require_zip_code'), FILTER_VALIDATE_BOOLEAN); - $require_notes = filter_var(setting('require_notes'), FILTER_VALIDATE_BOOLEAN); if ( (empty($customer['first_name']) && $require_first_name) @@ -111,7 +110,6 @@ class Customers_model extends EA_Model { || (empty($customer['address']) && $require_address) || (empty($customer['city']) && $require_city) || (empty($customer['zip_code']) && $require_zip_code) - || (empty($customer['notes']) && $require_notes) ) { throw new InvalidArgumentException('Not all required fields are provided: ' . print_r($customer, TRUE));