From 1027bbc8f7930fc07380eab114cf10628670af82 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Sun, 31 Jan 2016 13:01:37 +0100 Subject: [PATCH 1/9] Fixes #116: the book timeout would not be taken into account in the available appointment hours calculation. --- src/application/controllers/appointments.php | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/application/controllers/appointments.php b/src/application/controllers/appointments.php index aee276f1..b976f29b 100755 --- a/src/application/controllers/appointments.php +++ b/src/application/controllers/appointments.php @@ -104,10 +104,10 @@ class Appointments extends CI_Controller { } else { // The customer is going to book a new appointment so there is no // need for the manage functionality to be initialized. - $manage_mode = FALSE; - $appointment = array(); - $provider = array(); - $customer = array(); + $manage_mode = FALSE; + $appointment = array(); + $provider = array(); + $customer = array(); } // Load the book appointment view. @@ -310,7 +310,7 @@ class Appointments extends CI_Controller { $_POST['selected_date'], $exclude_appointments); $available_hours = $this->calculate_available_hours($empty_periods, $_POST['selected_date'], - $_POST['service_duration'], (bool)$_POST['manage_mode']); + $_POST['service_duration'], filter_var($_POST['manage_mode'], FILTER_VALIDATE_BOOLEAN)); echo json_encode($available_hours); @@ -756,11 +756,7 @@ class Appointments extends CI_Controller { // booking that is set in the backoffice the system. Normally we might want the customer to book // an appointment that is at least half or one hour from now. The setting is stored in minutes. if (date('m/d/Y', strtotime($selected_date)) === date('m/d/Y')) { - if ($manage_mode) { - $book_advance_timeout = 0; - } else { - $book_advance_timeout = $this->settings_model->get_setting('book_advance_timeout'); - } + $book_advance_timeout = $this->settings_model->get_setting('book_advance_timeout'); foreach($available_hours as $index => $value) { $available_hour = strtotime($value); From bdccb642aa495da6e03c7a6ae167c679150a863f Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Sat, 6 Feb 2016 01:05:11 +0100 Subject: [PATCH 2/9] Fixes #118 - Added filter_var method for boolean values normalization. --- src/application/controllers/appointments.php | 32 +++++++++++--------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/application/controllers/appointments.php b/src/application/controllers/appointments.php index b976f29b..717c941a 100755 --- a/src/application/controllers/appointments.php +++ b/src/application/controllers/appointments.php @@ -174,7 +174,8 @@ class Appointments extends CI_Controller { // :: SYNC APPOINTMENT REMOVAL WITH GOOGLE CALENDAR if ($appointment['id_google_calendar'] != NULL) { try { - $google_sync = $this->providers_model->get_setting('google_sync',$appointment['id_users_provider']); + $google_sync = filter_var($this->providers_model + ->get_setting('google_sync',$appointment['id_users_provider']), FILTER_VALIDATE_BOOLEAN); if ($google_sync == TRUE) { $google_token = json_decode($this->providers_model @@ -192,8 +193,8 @@ class Appointments extends CI_Controller { try { $this->load->library('Notifications'); - $send_provider = $this->providers_model - ->get_setting('notifications', $provider['id']); + $send_provider = filter_var($this->providers_model + ->get_setting('notifications', $provider['id']), FILTER_VALIDATE_BOOLEAN); if ($send_provider == TRUE) { $this->notifications->send_delete_appointment($appointment, $provider, @@ -201,9 +202,10 @@ class Appointments extends CI_Controller { $_POST['cancel_reason']); } - $send_customer = $this->settings_model->get_setting('customer_notifications'); + $send_customer = filter_var($this->settings_model->get_setting('customer_notifications'), + FILTER_VALIDATE_BOOLEAN); - if ((bool)$send_customer === TRUE) { + if ($send_customer === TRUE) { $this->notifications->send_delete_appointment($appointment, $provider, $service, $customer, $company_settings, $customer['email'], $_POST['cancel_reason']); @@ -329,6 +331,7 @@ class Appointments extends CI_Controller { public function ajax_register_appointment() { try { $post_data = $_POST['post_data']; // alias + $post_data['manage_mode'] = filter_var($post_data['manage_mode'], FILTER_VALIDATE_BOOLEAN); $this->load->model('appointments_model'); $this->load->model('providers_model'); @@ -377,8 +380,8 @@ class Appointments extends CI_Controller { // The provider must have previously granted access to his google calendar account // in order to sync the appointment. try { - $google_sync = $this->providers_model->get_setting('google_sync', - $appointment['id_users_provider']); + $google_sync = filter_var($this->providers_model->get_setting('google_sync', + $appointment['id_users_provider']), FILTER_VALIDATE_BOOLEAN); if ($google_sync == TRUE) { $google_token = json_decode($this->providers_model @@ -411,10 +414,7 @@ class Appointments extends CI_Controller { try { $this->load->library('Notifications'); - $send_provider = $this->providers_model - ->get_setting('notifications', $provider['id']); - - if (!$post_data['manage_mode']) { + if ($post_data['manage_mode'] == FALSE) { $customer_title = $this->lang->line('appointment_booked'); $customer_message = $this->lang->line('thank_you_for_appointment'); $customer_link = $this->config->item('base_url') . '/index.php/appointments/index/' @@ -436,14 +436,18 @@ class Appointments extends CI_Controller { . $appointment['hash']; } - $send_customer = $this->settings_model->get_setting('customer_notifications'); + $send_customer = filter_var($this->settings_model->get_setting('customer_notifications'), + FILTER_VALIDATE_BOOLEAN); - if ((bool)$send_customer === TRUE) { + if ($send_customer == TRUE) { $this->notifications->send_appointment_details($appointment, $provider, $service, $customer,$company_settings, $customer_title, $customer_message, $customer_link, $customer['email']); } + $send_provider = filter_var($this->providers_model ->get_setting('notifications', $provider['id']), + FILTER_VALIDATE_BOOLEAN); + if ($send_provider == TRUE) { $this->notifications->send_appointment_details($appointment, $provider, $service, $customer, $company_settings, $provider_title, @@ -539,7 +543,7 @@ class Appointments extends CI_Controller { $this->load->model('providers_model'); // Get the provider's working plan and reserved appointments. - $working_plan = json_decode($this->providers_model->get_setting('working_plan', $provider_id), true); + $working_plan = json_decode($this->providers_model->get_setting('working_plan', $provider_id), TRUE); $where_clause = array( 'id_users_provider' => $provider_id From e45900bfe3bdb2428e469ac992c2da94f413ab3f Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Sun, 7 Feb 2016 12:05:37 +0100 Subject: [PATCH 3/9] Updated changelog for v1.1.1 release. --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f532805..78b0692a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ This file contains the code changes that were introduced into each release (starting from v1.1.0) so that is easy for developers to maintain and readjust their custom modifications on the main project codebase. +### Version 1.1.1 +- Issue #116: Book advance timeout not taken into account for proposed appointments. +- Issue #118: Google Calendar and notification mail problem bug. + ### Version 1.1.0 - Issue #4: Raising more useful exceptions and enable error logging by default. - Issue #6: Business Logic created is not getting assigned to service provider. From 42ff47a7536ac25e1e3d92ad617d41b65a629d60 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Sun, 7 Feb 2016 15:15:17 +0100 Subject: [PATCH 4/9] Added issue #120 to change log. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 78b0692a..3e50ecc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ their custom modifications on the main project codebase. ### Version 1.1.1 - Issue #116: Book advance timeout not taken into account for proposed appointments. - Issue #118: Google Calendar and notification mail problem bug. +- Issue #120: Invalid appointment date set after editing an existing appointment. ### Version 1.1.0 - Issue #4: Raising more useful exceptions and enable error logging by default. From a669a83cce3ce10d5300800f6c1b6a6659e311a9 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Sun, 7 Feb 2016 15:29:54 +0100 Subject: [PATCH 5/9] Increased the E\!A version in the config file for v1.1.1 --- src/application/config/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/application/config/config.php b/src/application/config/config.php index 10d9c160..25b3fa44 100644 --- a/src/application/config/config.php +++ b/src/application/config/config.php @@ -9,7 +9,7 @@ | the global "config" variable. | */ -$config['ea_version'] = '1.1.0'; // This must be changed manually. +$config['ea_version'] = '1.1.1'; // This must be changed manually. $config['ea_release_title'] = ''; // Leave empty for no title or add BETA, TEST etc ... $config['ea_google_sync_feature'] = Config::GOOGLE_SYNC_FEATURE; From 3bed331a1fb3d9e326e1799f828cd3a8bd115451 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Sun, 7 Feb 2016 15:52:27 +0100 Subject: [PATCH 6/9] Fixes #120 - Invalid appointment date set after editing an existing appointment. --- src/assets/js/backend_calendar.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/assets/js/backend_calendar.js b/src/assets/js/backend_calendar.js index 20e529b9..d6d11db4 100644 --- a/src/assets/js/backend_calendar.js +++ b/src/assets/js/backend_calendar.js @@ -382,11 +382,13 @@ var BackendCalendar = { // Set the start and end datetime of the appointment. var startDatetime = Date.parseExact(appointment['start_datetime'], 'yyyy-MM-dd HH:mm:ss'); - $dialog.find('#start-datetime').val(GeneralFunctions.formatDate(startDatetime, GlobalVariables.dateFormat, true)); + // $dialog.find('#start-datetime').val(GeneralFunctions.formatDate(startDatetime, GlobalVariables.dateFormat, true)); + $dialog.find('#start-datetime').datetimepicker('setDate', startDatetime); var endDatetime = Date.parseExact(appointment['end_datetime'], 'yyyy-MM-dd HH:mm:ss'); - $dialog.find('#end-datetime').val(GeneralFunctions.formatDate(endDatetime, GlobalVariables.dateFormat, true)); + // $dialog.find('#end-datetime').val(GeneralFunctions.formatDate(endDatetime, GlobalVariables.dateFormat, true)); + $dialog.find('#end-datetime').datetimepicker('setDate', endDatetime); var customer = appointment['customer']; $dialog.find('#customer-id').val(appointment['id_users_customer']); @@ -411,9 +413,9 @@ var BackendCalendar = { // :: APPLY UNAVAILABLE DATA TO DIALOG $dialog.find('.modal-header h3').text('Edit Unavailable Period'); + $dialog.find('#unavailable-start').datetimepicker('setDate', unavailable.start_datetime); $dialog.find('#unavailable-id').val(unavailable.id); - $dialog.find('#unavailable-start').val(unavailable.start_datetime.toString('dd/MM/yyyy HH:mm')); - $dialog.find('#unavailable-end').val(unavailable.end_datetime.toString('dd/MM/yyyy HH:mm')); + $dialog.find('#unavailable-end').datetimepicker('setDate', unavailable.end_datetime); $dialog.find('#unavailable-notes').val(unavailable.notes); } @@ -1952,7 +1954,6 @@ var BackendCalendar = { minuteText: EALang['minutes'], firstDay: 1 }); - // $dialog.find('#start-datetime').val(formattedStartDatetime); $dialog.find('#start-datetime').datepicker('setDate', startDatetime); $dialog.find('#end-datetime').datetimepicker({ @@ -1982,7 +1983,6 @@ var BackendCalendar = { minuteText: EALang['minutes'], firstDay: 1 }); - // $dialog.find('#end-datetime').val(formattedEndDatetime); $dialog.find('#end-datetime').datepicker('setDate', endDatetime); }, From 8f52705ebe495a631eac3b89c587b1f71c4054cc Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Sun, 7 Feb 2016 15:54:23 +0100 Subject: [PATCH 7/9] Added the 'Beta' label to v1.1.1 release. --- src/application/config/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/application/config/config.php b/src/application/config/config.php index 25b3fa44..bbb870cb 100644 --- a/src/application/config/config.php +++ b/src/application/config/config.php @@ -10,7 +10,7 @@ | */ $config['ea_version'] = '1.1.1'; // This must be changed manually. -$config['ea_release_title'] = ''; // Leave empty for no title or add BETA, TEST etc ... +$config['ea_release_title'] = 'Beta'; // Leave empty for no title or add BETA, TEST etc ... $config['ea_google_sync_feature'] = Config::GOOGLE_SYNC_FEATURE; /* From 77d7d02ea22e1a47e8c741d83540fc12e4cf7a56 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Sun, 14 Feb 2016 14:05:50 +0100 Subject: [PATCH 8/9] Removed the 'Beta' label of v1.1.1. --- src/application/config/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/application/config/config.php b/src/application/config/config.php index bbb870cb..25b3fa44 100644 --- a/src/application/config/config.php +++ b/src/application/config/config.php @@ -10,7 +10,7 @@ | */ $config['ea_version'] = '1.1.1'; // This must be changed manually. -$config['ea_release_title'] = 'Beta'; // Leave empty for no title or add BETA, TEST etc ... +$config['ea_release_title'] = ''; // Leave empty for no title or add BETA, TEST etc ... $config['ea_google_sync_feature'] = Config::GOOGLE_SYNC_FEATURE; /* From d3e86800b5b5196dda210e115a96ad48addbd0f2 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Sun, 14 Feb 2016 14:08:51 +0100 Subject: [PATCH 9/9] Corrected the class that needed to be removed from the sync-button after the user disables the syncing. --- src/assets/js/backend_calendar.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/assets/js/backend_calendar.js b/src/assets/js/backend_calendar.js index d6d11db4..a042c97d 100644 --- a/src/assets/js/backend_calendar.js +++ b/src/assets/js/backend_calendar.js @@ -291,7 +291,7 @@ var BackendCalendar = { $('#enable-sync span:eq(1)').text(EALang['disable_sync']); $('#google-sync').prop('disabled', false); } else { - $('#enable-sync').removeClass('btn-success enabled'); + $('#enable-sync').removeClass('btn-danger enabled'); $('#enable-sync span:eq(1)').text(EALang['enable_sync']); $('#google-sync').prop('disabled', true); } @@ -776,7 +776,7 @@ var BackendCalendar = { BackendCalendar.disableProviderSync(provider['id']); - $('#enable-sync').removeClass('btn-success enabled'); + $('#enable-sync').removeClass('btn-danger enabled'); $('#enable-sync span:eq(1)').text(EALang['enable_sync']); $('#google-sync').prop('disabled', true); $('#select-filter-item option:selected').attr('google-sync', 'false');