From 950738f2fe4235e17bde35d2788117b7f659be51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=CC=81bastien?= Date: Fri, 5 Jun 2020 18:24:05 +0200 Subject: [PATCH] Redirect clients which are tying to update an appointment during the book advance timeout to a warning page. --- application/controllers/Appointments.php | 22 +++++++++++++++++++ .../language/english/translations_lang.php | 2 ++ .../language/french/translations_lang.php | 2 ++ .../language/german/translations_lang.php | 2 ++ 4 files changed, 28 insertions(+) diff --git a/application/controllers/Appointments.php b/application/controllers/Appointments.php index 09c8b61d..2988919c 100755 --- a/application/controllers/Appointments.php +++ b/application/controllers/Appointments.php @@ -95,6 +95,7 @@ class Appointments extends CI_Controller { $available_services = $this->services_model->get_available_services(); $available_providers = $this->providers_model->get_available_providers(); $company_name = $this->settings_model->get_setting('company_name'); + $book_advance_timeout = $this->settings_model->get_setting('book_advance_timeout'); $date_format = $this->settings_model->get_setting('date_format'); $time_format = $this->settings_model->get_setting('time_format'); $first_weekday = $this->settings_model->get_setting('first_weekday'); @@ -144,6 +145,27 @@ class Appointments extends CI_Controller { return; } + // If the requested apppointment begin date is lower than book_advance_timeout. Display + // a message to the customer. + $startDate = strtotime($results[0]['start_datetime']); + $limit = strtotime('+' . $book_advance_timeout . ' minutes', strtotime('now')); + + if ($startDate < $limit) + { + $hours = floor($book_advance_timeout / 60); + $minutes = ($book_advance_timeout % 60); + + $view = [ + 'message_title' => $this->lang->line('appointment_locked'), + 'message_text' => strtr($this->lang->line('appointment_locked_message'), [ + '{$limit}' => sprintf('%02d:%02d', $hours, $minutes) + ]), + 'message_icon' => base_url('assets/img/error.png') + ]; + $this->load->view('appointments/message', $view); + return; + } + $appointment = $results[0]; $provider = $this->providers_model->get_row($appointment['id_users_provider']); $customer = $this->customers_model->get_row($appointment['id_users_customer']); diff --git a/application/language/english/translations_lang.php b/application/language/english/translations_lang.php index 21ac685c..ef31b689 100755 --- a/application/language/english/translations_lang.php +++ b/application/language/english/translations_lang.php @@ -50,6 +50,8 @@ $lang['appointment_added_to_google_calendar'] = 'Your appointment has been added $lang['view_appointment_in_google_calendar'] = 'Click here to view your appointment on Google Calendar.'; $lang['appointment_added_to_your_plan'] = 'A new appointment has been added to your plan.'; $lang['appointment_link_description'] = 'You can make changes by clicking the appointment link below.'; +$lang['appointment_locked'] = 'Modification impossible!'; +$lang['appointment_locked_message'] = 'The appointment cannot be changed less than {$limit} hours in advance.'; $lang['appointment_not_found'] = 'Appointment Not Found!'; $lang['appointment_does_not_exist_in_db'] = 'The appointment you requested does not exist in the system database anymore.'; $lang['display_calendar'] = 'Display Calendar'; diff --git a/application/language/french/translations_lang.php b/application/language/french/translations_lang.php index dc4f37dc..41b44a7d 100755 --- a/application/language/french/translations_lang.php +++ b/application/language/french/translations_lang.php @@ -50,6 +50,8 @@ $lang['appointment_added_to_google_calendar'] = 'Votre rendez-vous a été ajout $lang['view_appointment_in_google_calendar'] = 'Cliquez ici pour voir votre rendez-vous dans le calendrier Google.'; $lang['appointment_added_to_your_plan'] = 'Un nouveau rendez-vous a été ajouté à votre planning.'; $lang['appointment_link_description'] = 'Vous pouvez faires des modifications en cliquant sur le lien suivant.'; +$lang['appointment_locked'] = 'Modification impossible !'; +$lang['appointment_locked_message'] = 'Le rendez-vous ne peut pas être modifié moins de {$limit} heures avant.'; $lang['appointment_not_found'] = 'Rendez-vous introuvable !'; $lang['appointment_does_not_exist_in_db'] = 'Le rendez-vous demandé n\'existe plus dans la base de données système.'; $lang['display_calendar'] = 'Afficher le calendrier.'; diff --git a/application/language/german/translations_lang.php b/application/language/german/translations_lang.php index d8af8f51..02258bb8 100755 --- a/application/language/german/translations_lang.php +++ b/application/language/german/translations_lang.php @@ -50,6 +50,8 @@ $lang['appointment_added_to_google_calendar'] = 'Ihr Termin ist zu Ihrem Google $lang['view_appointment_in_google_calendar'] = 'Bitte klicken Sie hier, um Ihren Termin im Google Kalender zu sehen.'; $lang['appointment_added_to_your_plan'] = 'Ein neuer Termin ist zu Ihrer Planung hinzugefügt worden.'; $lang['appointment_link_description'] = 'Sie können Änderungen durch Klicken auf den Termin-Link durchführen.'; +$lang['appointment_locked'] = 'Änderungen unmöglich!'; +$lang['appointment_locked_message'] = 'Der Termin kann nicht weniger als {$limit} Stunden im Voraus geändert werden.'; $lang['appointment_not_found'] = 'Termin nicht gefunden!'; $lang['appointment_does_not_exist_in_db'] = 'Der von Ihnen angeforderte Termin existiert nicht in der Systemdatenbank.'; $lang['display_calendar'] = 'Kalender anzeigen';