From 7bfe16b6be73c8b909d7dd332848a0b7c6cf46ca Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Fri, 17 Mar 2023 07:53:16 +0100 Subject: [PATCH] Check on trashed items when fetching appointment information --- application/controllers/Calendar.php | 24 +++++++++---------- .../api/v1/Appointments_api_v1.php | 18 +++++++------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/application/controllers/Calendar.php b/application/controllers/Calendar.php index cee3c718..f130a462 100644 --- a/application/controllers/Calendar.php +++ b/application/controllers/Calendar.php @@ -267,9 +267,9 @@ class Calendar extends EA_Controller { } $appointment = $this->appointments_model->find($appointment['id']); - $provider = $this->providers_model->find($appointment['id_users_provider']); - $customer = $this->customers_model->find($appointment['id_users_customer']); - $service = $this->services_model->find($appointment['id_services']); + $provider = $this->providers_model->find($appointment['id_users_provider'], TRUE); + $customer = $this->customers_model->find($appointment['id_users_customer'], TRUE); + $service = $this->services_model->find($appointment['id_services'], TRUE); $settings = [ 'company_name' => setting('company_name'), @@ -320,9 +320,9 @@ class Calendar extends EA_Controller { // Store appointment data for later use in this method. $appointment = $this->appointments_model->find($appointment_id); - $provider = $this->providers_model->find($appointment['id_users_provider']); - $customer = $this->customers_model->find($appointment['id_users_customer']); - $service = $this->services_model->find($appointment['id_services']); + $provider = $this->providers_model->find($appointment['id_users_provider'], TRUE); + $customer = $this->customers_model->find($appointment['id_users_customer'], TRUE); + $service = $this->services_model->find($appointment['id_services'], TRUE); $settings = [ 'company_name' => setting('company_name'), @@ -518,9 +518,9 @@ class Calendar extends EA_Controller { foreach ($response['appointments'] as &$appointment) { - $appointment['provider'] = $this->providers_model->find($appointment['id_users_provider']); - $appointment['service'] = $this->services_model->find($appointment['id_services']); - $appointment['customer'] = $this->customers_model->find($appointment['id_users_customer']); + $appointment['provider'] = $this->providers_model->find($appointment['id_users_provider'], TRUE); + $appointment['service'] = $this->services_model->find($appointment['id_services'], TRUE); + $appointment['customer'] = $this->customers_model->find($appointment['id_users_customer'], TRUE); } unset($appointment); @@ -646,9 +646,9 @@ class Calendar extends EA_Controller { foreach ($response['appointments'] as &$appointment) { - $appointment['provider'] = $this->providers_model->find($appointment['id_users_provider']); - $appointment['service'] = $this->services_model->find($appointment['id_services']); - $appointment['customer'] = $this->customers_model->find($appointment['id_users_customer']); + $appointment['provider'] = $this->providers_model->find($appointment['id_users_provider'], TRUE); + $appointment['service'] = $this->services_model->find($appointment['id_services'], TRUE); + $appointment['customer'] = $this->customers_model->find($appointment['id_users_customer'], TRUE); } // Get unavailability periods (only for provider). diff --git a/application/controllers/api/v1/Appointments_api_v1.php b/application/controllers/api/v1/Appointments_api_v1.php index 1490fbe7..e167ddad 100644 --- a/application/controllers/api/v1/Appointments_api_v1.php +++ b/application/controllers/api/v1/Appointments_api_v1.php @@ -282,11 +282,11 @@ class Appointments_api_v1 extends EA_Controller { $deleted_appointment = $occurrences[0]; - $service = $this->services_model->find($deleted_appointment['id_services']); + $service = $this->services_model->find($deleted_appointment['id_services'], TRUE); - $provider = $this->providers_model->find($deleted_appointment['id_users_provider']); + $provider = $this->providers_model->find($deleted_appointment['id_users_provider'], TRUE); - $customer = $this->customers_model->find($deleted_appointment['id_users_customer']); + $customer = $this->customers_model->find($deleted_appointment['id_users_customer'], TRUE); $settings = [ 'company_name' => setting('company_name'), @@ -320,11 +320,11 @@ class Appointments_api_v1 extends EA_Controller { { $manage_mode = $action === 'update'; - $service = $this->services_model->find($appointment['id_services']); + $service = $this->services_model->find($appointment['id_services'], TRUE); - $provider = $this->providers_model->find($appointment['id_users_provider']); + $provider = $this->providers_model->find($appointment['id_users_provider'], TRUE); - $customer = $this->customers_model->find($appointment['id_users_customer']); + $customer = $this->customers_model->find($appointment['id_users_customer'], TRUE); $settings = [ 'company_name' => setting('company_name'), @@ -376,9 +376,9 @@ class Appointments_api_v1 extends EA_Controller { if ($aggregates) { - $appointment['service'] = $this->services_model->find($appointment['id_services'] ?? $appointment['serviceId'] ?? NULL); - $appointment['provider'] = $this->providers_model->find($appointment['id_users_provider'] ?? $appointment['providerId'] ?? NULL); - $appointment['customer'] = $this->customers_model->find($appointment['id_users_customer'] ?? $appointment['customerId']) ?? NULL; + $appointment['service'] = $this->services_model->find($appointment['id_services'] ?? $appointment['serviceId'] ?? NULL, TRUE); + $appointment['provider'] = $this->providers_model->find($appointment['id_users_provider'] ?? $appointment['providerId'] ?? NULL, TRUE); + $appointment['customer'] = $this->customers_model->find($appointment['id_users_customer'] ?? $appointment['customerId'] ?? NULL, TRUE); $this->services_model->api_encode($appointment['service']); $this->providers_model->api_encode($appointment['provider']); $this->customers_model->api_encode($appointment['customer']);