diff --git a/application/controllers/Booking_cancellation.php b/application/controllers/Booking_cancellation.php index 62e51dbc..2b993fc0 100755 --- a/application/controllers/Booking_cancellation.php +++ b/application/controllers/Booking_cancellation.php @@ -95,7 +95,7 @@ class Booking_cancellation extends EA_Controller { $this->synchronization->sync_appointment_deleted($appointment, $provider); - $this->notifications->notify_appointment_deleted($appointment, $service, $provider, $customer, $settings); + $this->notifications->notify_appointment_deleted($appointment, $service, $provider, $customer, $settings, $cancellation_reason); $this->webhooks_client->trigger(WEBHOOK_APPOINTMENT_DELETE, $appointment); diff --git a/application/controllers/Calendar.php b/application/controllers/Calendar.php index 694631c2..4e31d31d 100644 --- a/application/controllers/Calendar.php +++ b/application/controllers/Calendar.php @@ -233,7 +233,7 @@ class Calendar extends EA_Controller { } // If the appointment does not contain the customer record id, then it means that is going to be - // inserted. + // inserted. if ( ! isset($appointment['id_users_customer'])) { $appointment['id_users_customer'] = $customer['id'] ?? $customer_data['id']; @@ -312,6 +312,7 @@ class Calendar extends EA_Controller { } $appointment_id = request('appointment_id'); + $cancellation_reason = request('cancellation_reason'); if (empty($appointment_id)) { @@ -335,7 +336,7 @@ class Calendar extends EA_Controller { // Delete appointment record from the database. $this->appointments_model->delete($appointment_id); - $this->notifications->notify_appointment_deleted($appointment, $service, $provider, $customer, $settings); + $this->notifications->notify_appointment_deleted($appointment, $service, $provider, $customer, $settings, $cancellation_reason); $this->synchronization->sync_appointment_deleted($appointment, $provider); diff --git a/application/libraries/Notifications.php b/application/libraries/Notifications.php index eb89be6c..9ccf4eec 100644 --- a/application/libraries/Notifications.php +++ b/application/libraries/Notifications.php @@ -201,17 +201,10 @@ class Notifications { * @param array $customer Customer data. * @param array $settings Required settings. */ - public function notify_appointment_deleted(array $appointment, array $service, array $provider, array $customer, array $settings): void + public function notify_appointment_deleted(array $appointment, array $service, array $provider, array $customer, array $settings, string $cancellation_reason = ''): void { try { - $delete_reason = (string)request('delete_reason'); - - if (empty($delete_reason)) - { - $delete_reason = (string)request('cancellation_reason'); - } - // Notify provider. $send_provider = filter_var( $this->CI->providers_model->get_setting($provider['id'], 'notifications'), @@ -227,7 +220,7 @@ class Notifications { $customer, $settings, $provider['email'], - $delete_reason, + $cancellation_reason, $provider['timezone'] ); } @@ -247,7 +240,7 @@ class Notifications { $customer, $settings, $customer['email'], - $delete_reason, + $cancellation_reason, $customer['timezone'] ); } @@ -269,7 +262,7 @@ class Notifications { $customer, $settings, $admin['email'], - $delete_reason, + $cancellation_reason, $admin['timezone'] ); } @@ -296,7 +289,7 @@ class Notifications { $customer, $settings, $secretary['email'], - $delete_reason, + $cancellation_reason, $secretary['timezone'] ); } diff --git a/assets/js/http/calendar_http_client.js b/assets/js/http/calendar_http_client.js index aacec8da..1375ea9f 100755 --- a/assets/js/http/calendar_http_client.js +++ b/assets/js/http/calendar_http_client.js @@ -59,17 +59,17 @@ App.Http.Calendar = (function () { * Remove an appointment. * * @param {Number} appointmentId - * @param {String} deleteReason + * @param {String} cancellationReason * * @return {*|jQuery.jqXHR} */ - function deleteAppointment(appointmentId, deleteReason) { + function deleteAppointment(appointmentId, cancellationReason) { const url = App.Utils.Url.siteUrl('calendar/delete_appointment'); const data = { csrf_token: vars('csrf_token'), appointment_id: appointmentId, - delete_reason: deleteReason + cancellation_reason: cancellationReason }; return $.post(url, data); diff --git a/assets/js/utils/calendar_default_view.js b/assets/js/utils/calendar_default_view.js index ee39dbd3..cd28ca89 100755 --- a/assets/js/utils/calendar_default_view.js +++ b/assets/js/utils/calendar_default_view.js @@ -243,9 +243,9 @@ App.Utils.CalendarDefaultView = (function () { click: (event, messageModal) => { const appointmentId = lastFocusedEventData.extendedProps.data.id; - const deleteReason = $('#delete-reason').val(); + const cancellationReason = $('#cancellation-reason').val(); - App.Http.Calendar.deleteAppointment(appointmentId, deleteReason).done(() => { + App.Http.Calendar.deleteAppointment(appointmentId, cancellationReason).done(() => { messageModal.dispose(); // Refresh calendar event items. @@ -263,9 +263,9 @@ App.Utils.CalendarDefaultView = (function () { $('