mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-24 17:03:27 +03:00
Refactor the calendar page appointment removal so that it also uses a request parameter called "cancellation_reason", just like the public booking page does.
This commit is contained in:
parent
64edc3e450
commit
8e37e54bdb
5 changed files with 16 additions and 22 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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']
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 () {
|
|||
|
||||
$('<textarea/>', {
|
||||
'class': 'form-control w-100',
|
||||
'id': 'delete-reason',
|
||||
'id': 'cancellation-reason',
|
||||
'rows': '3'
|
||||
}).appendTo('#message-box');
|
||||
}).appendTo('#message-modal .modal-body');
|
||||
} else {
|
||||
// Do not display confirmation prompt.
|
||||
|
||||
|
|
Loading…
Reference in a new issue