From f7ffb25f059eb73598549123d32b16cfe7543294 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Thu, 24 Feb 2022 15:38:51 +0100 Subject: [PATCH] Replace Google Client JS with the Google Calendar Template link in the book success page (#1216) --- application/controllers/Appointments.php | 30 ++++- .../views/appointments/book_success.php | 14 +-- assets/js/frontend_book_success.js | 111 +----------------- 3 files changed, 33 insertions(+), 122 deletions(-) diff --git a/application/controllers/Appointments.php b/application/controllers/Appointments.php index 3ce6675b..ce91ad8e 100755 --- a/application/controllers/Appointments.php +++ b/application/controllers/Appointments.php @@ -150,7 +150,7 @@ class Appointments extends EA_Controller { } $appointment = $results[0]; - + $appointment = [ 'id' => $appointment['id'], 'hash' => $appointment['hash'], @@ -303,7 +303,7 @@ class Appointments extends EA_Controller { } /** - * GET an specific appointment book and redirect to the success screen. + * GET a specific appointment book and redirect to the success screen. * * @param string $appointment_hash The appointment hash identifier. * @@ -315,12 +315,18 @@ class Appointments extends EA_Controller { if (empty($appointments)) { - redirect('appointments'); // The appointment does not exist. + $vars = [ + 'message_title' => lang('appointment_not_found'), + 'message_text' => lang('appointment_does_not_exist_in_db'), + 'message_icon' => base_url('assets/img/error.png') + ]; + + $this->load->view('appointments/message', $vars); + return; } $appointment = $appointments[0]; - unset($appointment['notes']); $customer = $this->customers_model->get_row($appointment['id_users_customer']); @@ -330,6 +336,21 @@ class Appointments extends EA_Controller { $company_name = $this->settings_model->get_setting('company_name'); + $appointment_start_instance = new DateTime($appointment['start_datetime']); + + $appointment_end_instance = new DateTime($appointment['end_datetime']); + + $add_to_google_url_params = [ + 'action' => 'TEMPLATE', + 'text' => $service['name'], + 'dates' => $appointment_start_instance->format('Ymd\THis\Z') . '/' . $appointment_end_instance->format('Ymd\THis\Z'), + 'location' => $company_name, + 'details' => 'View/Change Appointment: ' . site_url('appointments/index/' . $appointment['hash']), + 'add' => $provider['email'] . ',' . $customer['email'] + ]; + + $add_to_google_url = 'https://calendar.google.com/calendar/render?' . http_build_query($add_to_google_url_params); + // Get any pending exceptions. $exceptions = $this->session->flashdata('book_success'); @@ -354,6 +375,7 @@ class Appointments extends EA_Controller { 'name' => $service['name'], ], 'company_name' => $company_name, + 'add_to_google_url' => $add_to_google_url, ]; if ($exceptions) diff --git a/application/views/appointments/book_success.php b/application/views/appointments/book_success.php index 875d2eb1..d2a3c0da 100755 --- a/application/views/appointments/book_success.php +++ b/application/views/appointments/book_success.php @@ -42,12 +42,10 @@ - - - + + + +
@@ -75,7 +73,6 @@ -