Skip to content

Commit

Permalink
Fix the booking settings require-notes setting application, as it sho…
Browse files Browse the repository at this point in the history
…uld check on the appointment notes and not the customer ones
  • Loading branch information
alextselegidis committed Jun 30, 2023
1 parent 80d9177 commit 66dfd36
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 4 additions & 0 deletions application/models/Appointments_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,16 @@ public function validate(array $appointment)
}

// 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));
Expand Down
2 changes: 0 additions & 2 deletions application/models/Customers_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ public function validate(array $customer)
$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)
Expand All @@ -111,7 +110,6 @@ public function validate(array $customer)
|| (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));
Expand Down

0 comments on commit 66dfd36

Please sign in to comment.