From 84afca8b26db01f64c6a5a8d6ff263ce00041b1e Mon Sep 17 00:00:00 2001 From: alext Date: Sat, 8 Jun 2019 16:43:21 +0200 Subject: [PATCH] Integrated location field in the backend section. --- src/application/controllers/Appointments.php | 28 +++++++++++++++++-- src/application/controllers/Google.php | 5 +++- .../language/arabic/translations_lang.php | 1 + .../language/bulgarian/translations_lang.php | 1 + .../language/chinese/translations_lang.php | 1 + .../language/danish/translations_lang.php | 1 + .../language/dutch/translations_lang.php | 1 + .../language/english/translations_lang.php | 1 + .../language/finnish/translations_lang.php | 1 + .../language/french/translations_lang.php | 1 + .../language/german/translations_lang.php | 1 + .../language/greek/translations_lang.php | 1 + .../language/hindi/translations_lang.php | 1 + .../language/hungarian/translations_lang.php | 1 + .../language/italian/translations_lang.php | 1 + .../language/japanese/translations_lang.php | 1 + .../luxembourgish/translations_lang.php | 1 + .../language/polish/translations_lang.php | 1 + .../portuguese-br/translations_lang.php | 1 + .../language/portuguese/translations_lang.php | 1 + .../language/romanian/translations_lang.php | 1 + .../language/russian/translations_lang.php | 1 + .../language/slovak/translations_lang.php | 1 + .../language/spanish/translations_lang.php | 1 + .../language/turkish/translations_lang.php | 1 + src/application/libraries/Google_sync.php | 6 ++-- src/application/views/backend/calendar.php | 11 ++++---- src/assets/css/backend.css | 5 ++++ .../js/backend_calendar_appointments_modal.js | 1 + .../js/backend_calendar_default_view.js | 2 ++ 30 files changed, 70 insertions(+), 11 deletions(-) diff --git a/src/application/controllers/Appointments.php b/src/application/controllers/Appointments.php index a13bdbbe..66e1cc42 100755 --- a/src/application/controllers/Appointments.php +++ b/src/application/controllers/Appointments.php @@ -479,15 +479,37 @@ class Appointments extends CI_Controller { $customer['id'] = $this->customers_model->find_record_id($customer); } + $provider = $this->providers_model->get_row($appointment['id_users_provider']); + $service = $this->services_model->get_row($appointment['id_services']); + + if (empty($appointment['location'])) { + $location = []; + + if (!empty($provider['address'])) { + $location[] = $provider['address']; + } + + if (!empty($provider['city'])) { + $location[] = $provider['city']; + } + + if (!empty($provider['state'])) { + $location[] = $provider['state']; + } + + if (!empty($provider['zip_code'])) { + $location[] = $provider['zip_code']; + } + + $appointment['location'] = implode(', ', $location); + } + $customer_id = $this->customers_model->add($customer); $appointment['id_users_customer'] = $customer_id; $appointment['is_unavailable'] = (int)$appointment['is_unavailable']; // needs to be type casted $appointment['id'] = $this->appointments_model->add($appointment); $appointment['hash'] = $this->appointments_model->get_value('hash', $appointment['id']); - $provider = $this->providers_model->get_row($appointment['id_users_provider']); - $service = $this->services_model->get_row($appointment['id_services']); - $company_settings = [ 'company_name' => $this->settings_model->get_setting('company_name'), 'company_link' => $this->settings_model->get_setting('company_link'), diff --git a/src/application/controllers/Google.php b/src/application/controllers/Google.php index 3a350443..933f9883 100644 --- a/src/application/controllers/Google.php +++ b/src/application/controllers/Google.php @@ -190,7 +190,8 @@ class Google extends CI_Controller { $event_start = strtotime($google_event->getStart()->getDateTime()); $event_end = strtotime($google_event->getEnd()->getDateTime()); - if ($appt_start != $event_start || $appt_end != $event_end) + if ($appt_start != $event_start || $appt_end != $event_end + || $appointment['notes'] !== $google_event->getDescription()) { $is_different = TRUE; } @@ -199,6 +200,7 @@ class Google extends CI_Controller { { $appointment['start_datetime'] = date('Y-m-d H:i:s', $event_start); $appointment['end_datetime'] = date('Y-m-d H:i:s', $event_end); + $appointment['notes'] = $google_event->getDescription(); $this->appointments_model->add($appointment); } @@ -226,6 +228,7 @@ class Google extends CI_Controller { 'start_datetime' => date('Y-m-d H:i:s', strtotime($event->start->getDateTime())), 'end_datetime' => date('Y-m-d H:i:s', strtotime($event->end->getDateTime())), 'is_unavailable' => TRUE, + 'location' => $event->getLocation(), 'notes' => $event->getSummary() . ' ' . $event->getDescription(), 'id_users_provider' => $provider_id, 'id_google_calendar' => $event->getId(), diff --git a/src/application/language/arabic/translations_lang.php b/src/application/language/arabic/translations_lang.php index 712363dd..641ad909 100755 --- a/src/application/language/arabic/translations_lang.php +++ b/src/application/language/arabic/translations_lang.php @@ -297,3 +297,4 @@ $lang['read_and_agree_to_privacy_policy'] = 'I have read and agree to the {$link $lang['delete_personal_information_hint'] = 'Delete all personal information from the system.'; $lang['delete_personal_information'] = 'Delete Personal Information'; $lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.'; +$lang['location'] = 'Location'; diff --git a/src/application/language/bulgarian/translations_lang.php b/src/application/language/bulgarian/translations_lang.php index 34256468..38e182c3 100755 --- a/src/application/language/bulgarian/translations_lang.php +++ b/src/application/language/bulgarian/translations_lang.php @@ -297,3 +297,4 @@ $lang['read_and_agree_to_privacy_policy'] = 'I have read and agree to the {$link $lang['delete_personal_information_hint'] = 'Delete all personal information from the system.'; $lang['delete_personal_information'] = 'Delete Personal Information'; $lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.'; +$lang['location'] = 'Location'; diff --git a/src/application/language/chinese/translations_lang.php b/src/application/language/chinese/translations_lang.php index e14c9d6b..7302958d 100755 --- a/src/application/language/chinese/translations_lang.php +++ b/src/application/language/chinese/translations_lang.php @@ -297,3 +297,4 @@ $lang['read_and_agree_to_privacy_policy'] = 'I have read and agree to the {$link $lang['delete_personal_information_hint'] = 'Delete all personal information from the system.'; $lang['delete_personal_information'] = 'Delete Personal Information'; $lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.'; +$lang['location'] = 'Location'; diff --git a/src/application/language/danish/translations_lang.php b/src/application/language/danish/translations_lang.php index 593f7a53..0d301b9b 100755 --- a/src/application/language/danish/translations_lang.php +++ b/src/application/language/danish/translations_lang.php @@ -297,3 +297,4 @@ $lang['read_and_agree_to_privacy_policy'] = 'I have read and agree to the {$link $lang['delete_personal_information_hint'] = 'Delete all personal information from the system.'; $lang['delete_personal_information'] = 'Delete Personal Information'; $lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.'; +$lang['location'] = 'Location'; diff --git a/src/application/language/dutch/translations_lang.php b/src/application/language/dutch/translations_lang.php index 20827257..e9b0cdc7 100755 --- a/src/application/language/dutch/translations_lang.php +++ b/src/application/language/dutch/translations_lang.php @@ -297,3 +297,4 @@ $lang['read_and_agree_to_privacy_policy'] = 'I have read and agree to the {$link $lang['delete_personal_information_hint'] = 'Delete all personal information from the system.'; $lang['delete_personal_information'] = 'Delete Personal Information'; $lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.'; +$lang['location'] = 'Location'; diff --git a/src/application/language/english/translations_lang.php b/src/application/language/english/translations_lang.php index 551aeb61..33dc74e3 100755 --- a/src/application/language/english/translations_lang.php +++ b/src/application/language/english/translations_lang.php @@ -297,3 +297,4 @@ $lang['read_and_agree_to_privacy_policy'] = 'I have read and agree to the {$link $lang['delete_personal_information_hint'] = 'Delete all personal information from the system.'; $lang['delete_personal_information'] = 'Delete Personal Information'; $lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.'; +$lang['location'] = 'Location'; diff --git a/src/application/language/finnish/translations_lang.php b/src/application/language/finnish/translations_lang.php index cb7d51f1..8ec16de6 100755 --- a/src/application/language/finnish/translations_lang.php +++ b/src/application/language/finnish/translations_lang.php @@ -297,3 +297,4 @@ $lang['read_and_agree_to_privacy_policy'] = 'I have read and agree to the {$link $lang['delete_personal_information_hint'] = 'Delete all personal information from the system.'; $lang['delete_personal_information'] = 'Delete Personal Information'; $lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.'; +$lang['location'] = 'Location'; diff --git a/src/application/language/french/translations_lang.php b/src/application/language/french/translations_lang.php index cb1ea145..36f5f59c 100755 --- a/src/application/language/french/translations_lang.php +++ b/src/application/language/french/translations_lang.php @@ -297,3 +297,4 @@ $lang['read_and_agree_to_privacy_policy'] = 'J\'ai lu, compris et accepte la {$l $lang['delete_personal_information_hint'] = 'Effacer toutes vos données personnelles du système.'; $lang['delete_personal_information'] = 'Effacer toutes mes données personnelles'; $lang['delete_personal_information_prompt'] = 'Etes-vous sûr(e) de vouloir effacer toutes vos données personnelles ? Cette action est irréversible.'; +$lang['location'] = 'Location'; diff --git a/src/application/language/german/translations_lang.php b/src/application/language/german/translations_lang.php index c1ff67cd..f252cd01 100755 --- a/src/application/language/german/translations_lang.php +++ b/src/application/language/german/translations_lang.php @@ -297,3 +297,4 @@ $lang['read_and_agree_to_privacy_policy'] = 'Ich habe die {$link}Datenschutzerkl $lang['delete_personal_information_hint'] = 'Alle persönlichen Informationen aus dem System löschen.'; $lang['delete_personal_information'] = 'Persönlichen Informationen löschen'; $lang['delete_personal_information_prompt'] = 'Sind Sie sicher, dass Sie Ihre persönlichen Daten löschen möchten? Diese Aktion kann nicht rückgängig gemacht werden.'; +$lang['location'] = 'Ort'; diff --git a/src/application/language/greek/translations_lang.php b/src/application/language/greek/translations_lang.php index 607726ba..b2e234a7 100755 --- a/src/application/language/greek/translations_lang.php +++ b/src/application/language/greek/translations_lang.php @@ -297,3 +297,4 @@ $lang['read_and_agree_to_privacy_policy'] = 'Διάβασα και αποδέχ $lang['delete_personal_information_hint'] = 'Διαγραφή όλων των προσωπικών πληροφοριών από το σύστημα.'; $lang['delete_personal_information'] = 'Διαγραφή Προσωπικών Πληροφοριών'; $lang['delete_personal_information_prompt'] = 'Είστε σίγουρος ότι θέλετε να διαγράψετε τις προσωπικές σας πληροφορίες; Αυτή η ενέργεια δεν μπορεί να αναιρεθεί.'; +$lang['location'] = 'Τοποθεσία'; diff --git a/src/application/language/hindi/translations_lang.php b/src/application/language/hindi/translations_lang.php index 39e912e3..abea1d55 100755 --- a/src/application/language/hindi/translations_lang.php +++ b/src/application/language/hindi/translations_lang.php @@ -297,3 +297,4 @@ $lang['read_and_agree_to_privacy_policy'] = 'I have read and agree to the {$link $lang['delete_personal_information_hint'] = 'Delete all personal information from the system.'; $lang['delete_personal_information'] = 'Delete Personal Information'; $lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.'; +$lang['location'] = 'Location'; diff --git a/src/application/language/hungarian/translations_lang.php b/src/application/language/hungarian/translations_lang.php index 1b07fb87..4e074324 100755 --- a/src/application/language/hungarian/translations_lang.php +++ b/src/application/language/hungarian/translations_lang.php @@ -297,3 +297,4 @@ $lang['read_and_agree_to_privacy_policy'] = 'I have read and agree to the {$link $lang['delete_personal_information_hint'] = 'Delete all personal information from the system.'; $lang['delete_personal_information'] = 'Delete Personal Information'; $lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.'; +$lang['location'] = 'Location'; diff --git a/src/application/language/italian/translations_lang.php b/src/application/language/italian/translations_lang.php index 8911eded..b4625602 100755 --- a/src/application/language/italian/translations_lang.php +++ b/src/application/language/italian/translations_lang.php @@ -297,3 +297,4 @@ $lang['read_and_agree_to_privacy_policy'] = 'I have read and agree to the {$link $lang['delete_personal_information_hint'] = 'Delete all personal information from the system.'; $lang['delete_personal_information'] = 'Delete Personal Information'; $lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.'; +$lang['location'] = 'Location'; diff --git a/src/application/language/japanese/translations_lang.php b/src/application/language/japanese/translations_lang.php index be8d7909..9087afe6 100755 --- a/src/application/language/japanese/translations_lang.php +++ b/src/application/language/japanese/translations_lang.php @@ -297,3 +297,4 @@ $lang['read_and_agree_to_privacy_policy'] = 'I have read and agree to the {$link $lang['delete_personal_information_hint'] = 'Delete all personal information from the system.'; $lang['delete_personal_information'] = 'Delete Personal Information'; $lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.'; +$lang['location'] = 'Location'; diff --git a/src/application/language/luxembourgish/translations_lang.php b/src/application/language/luxembourgish/translations_lang.php index d742dc4d..91dd0e14 100755 --- a/src/application/language/luxembourgish/translations_lang.php +++ b/src/application/language/luxembourgish/translations_lang.php @@ -297,3 +297,4 @@ $lang['read_and_agree_to_privacy_policy'] = 'I have read and agree to the {$link $lang['delete_personal_information_hint'] = 'Delete all personal information from the system.'; $lang['delete_personal_information'] = 'Delete Personal Information'; $lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.'; +$lang['location'] = 'Location'; diff --git a/src/application/language/polish/translations_lang.php b/src/application/language/polish/translations_lang.php index 1066dbe1..d04c6533 100755 --- a/src/application/language/polish/translations_lang.php +++ b/src/application/language/polish/translations_lang.php @@ -297,3 +297,4 @@ $lang['read_and_agree_to_privacy_policy'] = 'I have read and agree to the {$link $lang['delete_personal_information_hint'] = 'Delete all personal information from the system.'; $lang['delete_personal_information'] = 'Delete Personal Information'; $lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.'; +$lang['location'] = 'Location'; diff --git a/src/application/language/portuguese-br/translations_lang.php b/src/application/language/portuguese-br/translations_lang.php index 3ba9c118..390d25bb 100755 --- a/src/application/language/portuguese-br/translations_lang.php +++ b/src/application/language/portuguese-br/translations_lang.php @@ -297,3 +297,4 @@ $lang['read_and_agree_to_privacy_policy'] = 'I have read and agree to the {$link $lang['delete_personal_information_hint'] = 'Delete all personal information from the system.'; $lang['delete_personal_information'] = 'Delete Personal Information'; $lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.'; +$lang['location'] = 'Location'; diff --git a/src/application/language/portuguese/translations_lang.php b/src/application/language/portuguese/translations_lang.php index 15b29a0e..6a5ee8e4 100755 --- a/src/application/language/portuguese/translations_lang.php +++ b/src/application/language/portuguese/translations_lang.php @@ -297,3 +297,4 @@ $lang['read_and_agree_to_privacy_policy'] = 'I have read and agree to the {$link $lang['delete_personal_information_hint'] = 'Delete all personal information from the system.'; $lang['delete_personal_information'] = 'Delete Personal Information'; $lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.'; +$lang['location'] = 'Location'; diff --git a/src/application/language/romanian/translations_lang.php b/src/application/language/romanian/translations_lang.php index 7c9a63a3..cb06b90c 100755 --- a/src/application/language/romanian/translations_lang.php +++ b/src/application/language/romanian/translations_lang.php @@ -297,3 +297,4 @@ $lang['read_and_agree_to_privacy_policy'] = 'I have read and agree to the {$link $lang['delete_personal_information_hint'] = 'Delete all personal information from the system.'; $lang['delete_personal_information'] = 'Delete Personal Information'; $lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.'; +$lang['location'] = 'Location'; diff --git a/src/application/language/russian/translations_lang.php b/src/application/language/russian/translations_lang.php index 2076bfd5..a1f4817a 100755 --- a/src/application/language/russian/translations_lang.php +++ b/src/application/language/russian/translations_lang.php @@ -297,3 +297,4 @@ $lang['read_and_agree_to_privacy_policy'] = 'I have read and agree to the {$link $lang['delete_personal_information_hint'] = 'Delete all personal information from the system.'; $lang['delete_personal_information'] = 'Delete Personal Information'; $lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.'; +$lang['location'] = 'Location'; diff --git a/src/application/language/slovak/translations_lang.php b/src/application/language/slovak/translations_lang.php index 3881b6bb..2f3214ae 100755 --- a/src/application/language/slovak/translations_lang.php +++ b/src/application/language/slovak/translations_lang.php @@ -297,3 +297,4 @@ $lang['read_and_agree_to_privacy_policy'] = 'I have read and agree to the {$link $lang['delete_personal_information_hint'] = 'Delete all personal information from the system.'; $lang['delete_personal_information'] = 'Delete Personal Information'; $lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.'; +$lang['location'] = 'Location'; diff --git a/src/application/language/spanish/translations_lang.php b/src/application/language/spanish/translations_lang.php index e3f2ea3c..cffc8b93 100755 --- a/src/application/language/spanish/translations_lang.php +++ b/src/application/language/spanish/translations_lang.php @@ -297,3 +297,4 @@ $lang['read_and_agree_to_privacy_policy'] = 'I have read and agree to the {$link $lang['delete_personal_information_hint'] = 'Delete all personal information from the system.'; $lang['delete_personal_information'] = 'Delete Personal Information'; $lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.'; +$lang['location'] = 'Location'; diff --git a/src/application/language/turkish/translations_lang.php b/src/application/language/turkish/translations_lang.php index 35f199be..1e77b547 100755 --- a/src/application/language/turkish/translations_lang.php +++ b/src/application/language/turkish/translations_lang.php @@ -297,3 +297,4 @@ $lang['read_and_agree_to_privacy_policy'] = 'I have read and agree to the {$link $lang['delete_personal_information_hint'] = 'Delete all personal information from the system.'; $lang['delete_personal_information'] = 'Delete Personal Information'; $lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.'; +$lang['location'] = 'Location'; diff --git a/src/application/libraries/Google_sync.php b/src/application/libraries/Google_sync.php index b6f8b4fd..55209ce5 100644 --- a/src/application/libraries/Google_sync.php +++ b/src/application/libraries/Google_sync.php @@ -142,7 +142,8 @@ class Google_Sync { $event = new Google_Event(); $event->setSummary(($service != NULL) ? $service['name'] : 'Unavailable'); - $event->setLocation($company_settings['company_name']); + $event->setDescription($appointment['notes']); + $event->setLocation($appointment['location']); $start = new Google_EventDateTime(); $start->setDateTime(date3339(strtotime($appointment['start_datetime']))); @@ -199,7 +200,8 @@ class Google_Sync { $appointment['id_google_calendar']); $event->setSummary($service['name']); - $event->setLocation($company_settings['company_name']); + $event->setDescription($appointment['notes']); + $event->setLocation($appointment['location']); $start = new Google_EventDateTime(); $start->setDateTime(date3339(strtotime($appointment['start_datetime']))); diff --git a/src/application/views/backend/calendar.php b/src/application/views/backend/calendar.php index b0e0afe6..c02b1086 100755 --- a/src/application/views/backend/calendar.php +++ b/src/application/views/backend/calendar.php @@ -173,6 +173,11 @@ + +
+ + +
@@ -185,14 +190,10 @@
- - -
-
- +
diff --git a/src/assets/css/backend.css b/src/assets/css/backend.css index b88f9b16..bd8b5d8e 100644 --- a/src/assets/css/backend.css +++ b/src/assets/css/backend.css @@ -424,6 +424,11 @@ body legend { font-size: 12px; } +#appointment-notes, +#customer-notes { + height: 37px; /* Align with location field */ +} + body .form-horizontal .control-label { width: 135px; } diff --git a/src/assets/js/backend_calendar_appointments_modal.js b/src/assets/js/backend_calendar_appointments_modal.js index a1d18a4d..ed630746 100755 --- a/src/assets/js/backend_calendar_appointments_modal.js +++ b/src/assets/js/backend_calendar_appointments_modal.js @@ -57,6 +57,7 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa id_users_provider: $dialog.find('#select-provider').val(), start_datetime: startDatetime, end_datetime: endDatetime, + location: $dialog.find('#appointment-location').val(), notes: $dialog.find('#appointment-notes').val(), is_unavailable: false }; diff --git a/src/assets/js/backend_calendar_default_view.js b/src/assets/js/backend_calendar_default_view.js index 2dc4d9a3..68aa0481 100755 --- a/src/assets/js/backend_calendar_default_view.js +++ b/src/assets/js/backend_calendar_default_view.js @@ -90,6 +90,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {}; $dialog.find('#address').val(customer.address); $dialog.find('#city').val(customer.city); $dialog.find('#zip-code').val(customer.zip_code); + $dialog.find('#appointment-location').val(appointment.location); $dialog.find('#appointment-notes').val(appointment.notes); $dialog.find('#customer-notes').val(customer.notes); } else { @@ -1281,6 +1282,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {}; $dialog.find('#address').val(customer.address); $dialog.find('#city').val(customer.city); $dialog.find('#zip-code').val(customer.zip_code); + $dialog.find('#appointment-location').val(appointment.location); $dialog.find('#appointment-notes').val(appointment.notes); $dialog.find('#customer-notes').val(customer.notes);