Do not allow a customer to book the same hours multiple times

(#1420)
This commit is contained in:
Alex Tselegidis 2023-10-23 11:46:41 +02:00
parent e987aedf75
commit ae76ad7385
33 changed files with 47 additions and 3 deletions

View file

@ -465,6 +465,7 @@ class Booking extends EA_Controller {
$captcha_phrase = session('captcha_phrase');
// Validate the CAPTCHA string.
if ($require_captcha && strtoupper($captcha_phrase) !== strtoupper($captcha))
{
json_response([
@ -477,6 +478,17 @@ class Booking extends EA_Controller {
if ($this->customers_model->exists($customer))
{
$customer['id'] = $this->customers_model->find_record_id($customer);
$existing_appointments = $this->appointments_model->get([
'id_users_customer' => $customer['id'],
'start_datetime <=' => $appointment['start_datetime'],
'end_datetime >=' => $appointment['end_datetime']
]);
if (count($existing_appointments))
{
throw new RuntimeException(lang('customer_is_already_booked'));
}
}
if (empty($appointment['location']) && ! empty($service['location']))
@ -708,14 +720,14 @@ class Booking extends EA_Controller {
$unavailable_dates[] = $current_date->format('Y-m-d');
}
}
if (count($unavailable_dates) === $number_of_days_in_month)
{
json_response([
'is_month_unavailable' => TRUE,
]);
return;
return;
}
json_response($unavailable_dates);

View file

@ -436,4 +436,5 @@ $lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
$lang['customer_is_already_booked'] = 'This customer is already booked for the selected time, please use a different time.';
// End

View file

@ -436,4 +436,5 @@ $lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
$lang['customer_is_already_booked'] = 'This customer is already booked for the selected time, please use a different time.';
// End

View file

@ -436,4 +436,5 @@ $lang['scroll_to_increment'] = 'Desplaça per incrementar';
$lang['year'] = 'Any';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
$lang['customer_is_already_booked'] = 'This customer is already booked for the selected time, please use a different time.';
// End

View file

@ -436,4 +436,5 @@ $lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
$lang['customer_is_already_booked'] = 'This customer is already booked for the selected time, please use a different time.';
// End

View file

@ -436,4 +436,5 @@ $lang['scroll_to_increment'] = 'Skrolajte za inkrementaciju';
$lang['year'] = 'Godina';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
$lang['customer_is_already_booked'] = 'This customer is already booked for the selected time, please use a different time.';
// End

View file

@ -436,4 +436,5 @@ $lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
$lang['customer_is_already_booked'] = 'This customer is already booked for the selected time, please use a different time.';
// End

View file

@ -436,4 +436,5 @@ $lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
$lang['customer_is_already_booked'] = 'This customer is already booked for the selected time, please use a different time.';
// End

View file

@ -436,4 +436,5 @@ $lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
$lang['customer_is_already_booked'] = 'This customer is already booked for the selected time, please use a different time.';
// End

View file

@ -436,4 +436,5 @@ $lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
$lang['customer_is_already_booked'] = 'This customer is already booked for the selected time, please use a different time.';
// End

View file

@ -436,4 +436,5 @@ $lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
$lang['customer_is_already_booked'] = 'This customer is already booked for the selected time, please use a different time.';
// End

View file

@ -436,4 +436,5 @@ $lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
$lang['customer_is_already_booked'] = 'This customer is already booked for the selected time, please use a different time.';
// End

View file

@ -436,4 +436,5 @@ $lang['scroll_to_increment'] = 'Faire défiler pour incrémenter';
$lang['year'] = 'Année';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
$lang['customer_is_already_booked'] = 'This customer is already booked for the selected time, please use a different time.';
// End

View file

@ -436,4 +436,5 @@ $lang['scroll_to_increment'] = 'Scrollen Sie zu Inkrement';
$lang['year'] = 'Jahr';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
$lang['customer_is_already_booked'] = 'This customer is already booked for the selected time, please use a different time.';
// End

View file

@ -436,4 +436,5 @@ $lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
$lang['customer_is_already_booked'] = 'This customer is already booked for the selected time, please use a different time.';
// End

View file

@ -436,4 +436,5 @@ $lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
$lang['customer_is_already_booked'] = 'This customer is already booked for the selected time, please use a different time.';
// End

View file

@ -436,4 +436,5 @@ $lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
$lang['customer_is_already_booked'] = 'This customer is already booked for the selected time, please use a different time.';
// End

View file

@ -436,4 +436,5 @@ $lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
$lang['customer_is_already_booked'] = 'This customer is already booked for the selected time, please use a different time.';
// End

View file

@ -436,4 +436,5 @@ $lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
$lang['customer_is_already_booked'] = 'This customer is already booked for the selected time, please use a different time.';
// End

View file

@ -436,4 +436,5 @@ $lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
$lang['customer_is_already_booked'] = 'This customer is already booked for the selected time, please use a different time.';
// End

View file

@ -436,4 +436,5 @@ $lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
$lang['customer_is_already_booked'] = 'This customer is already booked for the selected time, please use a different time.';
// End

View file

@ -436,4 +436,5 @@ $lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
$lang['customer_is_already_booked'] = 'This customer is already booked for the selected time, please use a different time.';
// End

View file

@ -436,4 +436,5 @@ $lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
$lang['customer_is_already_booked'] = 'This customer is already booked for the selected time, please use a different time.';
// End

View file

@ -436,4 +436,5 @@ $lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
$lang['customer_is_already_booked'] = 'This customer is already booked for the selected time, please use a different time.';
// End

View file

@ -436,4 +436,5 @@ $lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
$lang['customer_is_already_booked'] = 'This customer is already booked for the selected time, please use a different time.';
// End

View file

@ -436,4 +436,5 @@ $lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
$lang['customer_is_already_booked'] = 'This customer is already booked for the selected time, please use a different time.';
// End

View file

@ -436,4 +436,5 @@ $lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
$lang['customer_is_already_booked'] = 'This customer is already booked for the selected time, please use a different time.';
// End

View file

@ -436,4 +436,5 @@ $lang['scroll_to_increment'] = 'Прокрутка для увеличения';
$lang['year'] = 'Год';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
$lang['customer_is_already_booked'] = 'This customer is already booked for the selected time, please use a different time.';
// End

View file

@ -436,4 +436,5 @@ $lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
$lang['customer_is_already_booked'] = 'This customer is already booked for the selected time, please use a different time.';
// End

View file

@ -436,4 +436,5 @@ $lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
$lang['customer_is_already_booked'] = 'This customer is already booked for the selected time, please use a different time.';
// End

View file

@ -436,4 +436,5 @@ $lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
$lang['customer_is_already_booked'] = 'This customer is already booked for the selected time, please use a different time.';
// End

View file

@ -436,4 +436,5 @@ $lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
$lang['customer_is_already_booked'] = 'This customer is already booked for the selected time, please use a different time.';
// End

View file

@ -436,4 +436,5 @@ $lang['scroll_to_increment'] = 'Scroll To Increment';
$lang['year'] = 'Year';
$lang['make_non_working_day'] = 'This provider will not be available for work on the selected day.';
$lang['no_breaks'] = 'No Breaks';
$lang['customer_is_already_booked'] = 'This customer is already booked for the selected time, please use a different time.';
// End