diff --git a/src/application/config/migration.php b/src/application/config/migration.php old mode 100644 new mode 100755 index 5f8c03eb..988cc798 --- a/src/application/config/migration.php +++ b/src/application/config/migration.php @@ -37,7 +37,7 @@ $config['migration_table'] = 'ea_migrations'; | be upgraded / downgraded to. | */ -$config['migration_version'] = 13; // current +$config['migration_version'] = 14; // current /* diff --git a/src/application/controllers/Appointments.php b/src/application/controllers/Appointments.php index 498652be..1b5fca56 100755 --- a/src/application/controllers/Appointments.php +++ b/src/application/controllers/Appointments.php @@ -810,6 +810,9 @@ class Appointments extends CI_Controller { // Get the service, provider's working plan and provider appointments. $working_plan = json_decode($this->providers_model->get_setting('working_plan', $provider_id), TRUE); + // Get the provider's extra working plan. + $extra_working_plan = json_decode($this->providers_model->get_setting('extra_working_plan', $provider_id), TRUE); + $provider_appointments = $this->appointments_model->get_batch([ 'id_users_provider' => $provider_id, ]); @@ -831,6 +834,14 @@ class Appointments extends CI_Controller { // every reserved appointment is considered to be a taken space in the plan. $selected_date_working_plan = $working_plan[strtolower(date('l', strtotime($selected_date)))]; + // Search if the $selected_date is an extra date added outside the normal working plan + if ($selected_date_working_plan == null) { + if (isset($extra_working_plan[strtolower(date('Y-m-d', strtotime($selected_date)))])){ + $selected_date_working_plan = $extra_working_plan[strtolower(date('Y-m-d', strtotime($selected_date)))]; + } + } + + $periods = []; if (isset($selected_date_working_plan['breaks'])) diff --git a/src/application/controllers/Backend.php b/src/application/controllers/Backend.php index 71ee1319..4f226fdf 100755 --- a/src/application/controllers/Backend.php +++ b/src/application/controllers/Backend.php @@ -224,6 +224,7 @@ class Backend extends CI_Controller { $view['secretaries'] = $this->secretaries_model->get_batch(); $view['services'] = $this->services_model->get_batch(); $view['working_plan'] = $this->settings_model->get_setting('company_working_plan'); + $view['extra_working_plan'] = "{}"; $this->set_user_data($view); $this->load->view('backend/header', $view); diff --git a/src/application/controllers/Backend_api.php b/src/application/controllers/Backend_api.php index e44e24be..1ed668c4 100755 --- a/src/application/controllers/Backend_api.php +++ b/src/application/controllers/Backend_api.php @@ -798,6 +798,101 @@ class Backend_api extends CI_Controller { } } + /** + * [AJAX] Insert of update extra working plan time period to database. + * + * Required POST Parameters: + * + * - array $_POST['extra_period'] JSON encoded array that contains the unavailable period data. + */ + public function ajax_save_extra_period() + { + try + { + // Check privileges + $extra_period = json_decode($this->input->post('extra_period'), TRUE); + + $REQUIRED_PRIV = ( ! isset($extra_period['id'])) + ? $this->privileges[PRIV_APPOINTMENTS]['add'] + : $this->privileges[PRIV_APPOINTMENTS]['edit']; + if ($REQUIRED_PRIV == FALSE) + { + throw new Exception('You do not have the required privileges for this task.'); + } + + $this->load->model('providers_model'); + + $success = $this->providers_model->set_extra_working_day($extra_period, $extra_period['id_users_provider']); + + if ( ! $success) + { + $this->output + ->set_content_type('application/json') + ->set_output(json_encode(['warnings' => 'Error on saving extra period.'])); + } + else + { + $this->output + ->set_content_type('application/json') + ->set_output(json_encode(AJAX_SUCCESS)); + } + } + catch (Exception $exc) + { + $this->output + ->set_content_type('application/json') + ->set_output(json_encode(['exceptions' => [exceptionToJavaScript($exc)]])); + } + } + + /** + * [AJAX] Delete an extra working plan time period to database. + * + * Required POST Parameters: + * + * - String $_POST['extra_period'] Date to be deleted. + * - int $_POST['provider_id'] Record id to be deleted. + */ + public function ajax_delete_extra_period() + { + try + { + if ($this->privileges[PRIV_APPOINTMENTS]['delete'] == FALSE) + { + throw new Exception('You do not have the required privileges for this task.'); + } + + // Check privileges + $extra_period = $this->input->post('extra_period'); + $provider_id = $this->input->post('provider_id'); + + $this->load->model('providers_model'); + + // Delete unavailable + $success = $this->providers_model->delete_extra_working_day($extra_period, $provider_id); + + if ( ! $success) + { + $this->output + ->set_content_type('application/json') + ->set_output(json_encode(['warnings' => 'Error on deleting extra working day'])); + } + else + { + $this->output + ->set_content_type('application/json') + ->set_output(json_encode(AJAX_SUCCESS)); + } + + } // + catch (Exception $exc) // + { // + $this->output // + ->set_content_type('application/json') // + ->set_output(json_encode(['exceptions' => [exceptionToJavaScript($exc)]])); // + }// + } // + /** * [AJAX] Save (insert or update) a customer record. * diff --git a/src/application/language/arabic/translations_lang.php b/src/application/language/arabic/translations_lang.php index 641ad909..066f9acf 100755 --- a/src/application/language/arabic/translations_lang.php +++ b/src/application/language/arabic/translations_lang.php @@ -298,3 +298,10 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro $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'; +$lang['extra_period'] = ''; +$lang['extra_periods'] = ''; +$lang['extra_periods_hint'] = ''; +$lang['new_extra_period_title'] = ''; +$lang['extra_period_saved'] = ''; +$lang['add_extra_periods_during_each_day'] = ''; +$lang['add_extra_period'] = ''; diff --git a/src/application/language/bulgarian/translations_lang.php b/src/application/language/bulgarian/translations_lang.php index 38e182c3..1300275f 100755 --- a/src/application/language/bulgarian/translations_lang.php +++ b/src/application/language/bulgarian/translations_lang.php @@ -298,3 +298,10 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro $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'; +$lang['extra_period'] = ''; +$lang['extra_periods'] = ''; +$lang['extra_periods_hint'] = ''; +$lang['new_extra_period_title'] = ''; +$lang['extra_period_saved'] = ''; +$lang['add_extra_periods_during_each_day'] = ''; +$lang['add_extra_period'] = ''; diff --git a/src/application/language/chinese/translations_lang.php b/src/application/language/chinese/translations_lang.php index 7302958d..9b72d7ba 100755 --- a/src/application/language/chinese/translations_lang.php +++ b/src/application/language/chinese/translations_lang.php @@ -298,3 +298,10 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro $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'; +$lang['extra_period'] = ''; +$lang['extra_periods'] = ''; +$lang['extra_periods_hint'] = ''; +$lang['new_extra_period_title'] = ''; +$lang['extra_period_saved'] = ''; +$lang['add_extra_periods_during_each_day'] = ''; +$lang['add_extra_period'] = ''; diff --git a/src/application/language/danish/translations_lang.php b/src/application/language/danish/translations_lang.php index 0d301b9b..c589c46d 100755 --- a/src/application/language/danish/translations_lang.php +++ b/src/application/language/danish/translations_lang.php @@ -298,3 +298,10 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro $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'; +$lang['extra_period'] = ''; +$lang['extra_periods'] = ''; +$lang['extra_periods_hint'] = ''; +$lang['new_extra_period_title'] = ''; +$lang['extra_period_saved'] = ''; +$lang['add_extra_periods_during_each_day'] = ''; +$lang['add_extra_period'] = ''; diff --git a/src/application/language/dutch/translations_lang.php b/src/application/language/dutch/translations_lang.php index e9b0cdc7..9478872e 100755 --- a/src/application/language/dutch/translations_lang.php +++ b/src/application/language/dutch/translations_lang.php @@ -298,3 +298,10 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro $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'; +$lang['extra_period'] = ''; +$lang['extra_periods'] = ''; +$lang['extra_periods_hint'] = ''; +$lang['new_extra_period_title'] = ''; +$lang['extra_period_saved'] = ''; +$lang['add_extra_periods_during_each_day'] = ''; +$lang['add_extra_period'] = ''; diff --git a/src/application/language/english/translations_lang.php b/src/application/language/english/translations_lang.php index 33dc74e3..c71b1933 100755 --- a/src/application/language/english/translations_lang.php +++ b/src/application/language/english/translations_lang.php @@ -298,3 +298,10 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro $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'; +$lang['extra_period'] = 'Extra working day'; +$lang['extra_periods'] = 'Extra working days'; +$lang['extra_periods_hint'] = 'Add a working day outside the working plan.'; +$lang['new_extra_period_title'] = 'New working day'; +$lang['extra_period_saved'] = 'New working day saved successfully!'; +$lang['add_extra_periods_during_each_day'] = 'Add working days outside the working plan.'; +$lang['add_extra_period'] = 'Add a working day'; diff --git a/src/application/language/finnish/translations_lang.php b/src/application/language/finnish/translations_lang.php index 8ec16de6..61d891eb 100755 --- a/src/application/language/finnish/translations_lang.php +++ b/src/application/language/finnish/translations_lang.php @@ -298,3 +298,10 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro $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'; +$lang['extra_period'] = ''; +$lang['extra_periods'] = ''; +$lang['extra_periods_hint'] = ''; +$lang['new_extra_period_title'] = ''; +$lang['extra_period_saved'] = ''; +$lang['add_extra_periods_during_each_day'] = ''; +$lang['add_extra_period'] = ''; diff --git a/src/application/language/french/translations_lang.php b/src/application/language/french/translations_lang.php index 36f5f59c..ca61da96 100755 --- a/src/application/language/french/translations_lang.php +++ b/src/application/language/french/translations_lang.php @@ -298,3 +298,13 @@ $lang['delete_personal_information_hint'] = 'Effacer toutes vos données personn $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'; +$lang['fixed'] = 'Fixed'; +$lang['attendants_number'] = 'Attendants Number'; +$lang['reset_working_plan'] = 'Reset the working plan back to the default values.'; +$lang['extra_period'] = ''; +$lang['extra_periods'] = ''; +$lang['extra_periods_hint'] = ''; +$lang['new_extra_period_title'] = ''; +$lang['extra_period_saved'] = ''; +$lang['add_extra_periods_during_each_day'] = ''; +$lang['add_extra_period'] = ''; diff --git a/src/application/language/german/translations_lang.php b/src/application/language/german/translations_lang.php index f252cd01..c4e3b38a 100755 --- a/src/application/language/german/translations_lang.php +++ b/src/application/language/german/translations_lang.php @@ -298,3 +298,10 @@ $lang['delete_personal_information_hint'] = 'Alle persönlichen Informationen au $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'; +$lang['extra_period'] = ''; +$lang['extra_periods'] = ''; +$lang['extra_periods_hint'] = ''; +$lang['new_extra_period_title'] = ''; +$lang['extra_period_saved'] = ''; +$lang['add_extra_periods_during_each_day'] = ''; +$lang['add_extra_period'] = ''; diff --git a/src/application/language/greek/translations_lang.php b/src/application/language/greek/translations_lang.php index b2e234a7..5f98cfcd 100755 --- a/src/application/language/greek/translations_lang.php +++ b/src/application/language/greek/translations_lang.php @@ -298,3 +298,10 @@ $lang['delete_personal_information_hint'] = 'Διαγραφή όλων των π $lang['delete_personal_information'] = 'Διαγραφή Προσωπικών Πληροφοριών'; $lang['delete_personal_information_prompt'] = 'Είστε σίγουρος ότι θέλετε να διαγράψετε τις προσωπικές σας πληροφορίες; Αυτή η ενέργεια δεν μπορεί να αναιρεθεί.'; $lang['location'] = 'Τοποθεσία'; +$lang['extra_period'] = ''; +$lang['extra_periods'] = ''; +$lang['extra_periods_hint'] = ''; +$lang['new_extra_period_title'] = ''; +$lang['extra_period_saved'] = ''; +$lang['add_extra_periods_during_each_day'] = ''; +$lang['add_extra_period'] = ''; diff --git a/src/application/language/hindi/translations_lang.php b/src/application/language/hindi/translations_lang.php index abea1d55..5471bf2b 100755 --- a/src/application/language/hindi/translations_lang.php +++ b/src/application/language/hindi/translations_lang.php @@ -298,3 +298,10 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro $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'; +$lang['extra_period'] = ''; +$lang['extra_periods'] = ''; +$lang['extra_periods_hint'] = ''; +$lang['new_extra_period_title'] = ''; +$lang['extra_period_saved'] = ''; +$lang['add_extra_periods_during_each_day'] = ''; +$lang['add_extra_period'] = ''; diff --git a/src/application/language/hungarian/translations_lang.php b/src/application/language/hungarian/translations_lang.php index 4e074324..177cf794 100755 --- a/src/application/language/hungarian/translations_lang.php +++ b/src/application/language/hungarian/translations_lang.php @@ -298,3 +298,10 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro $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'; +$lang['extra_period'] = ''; +$lang['extra_periods'] = ''; +$lang['extra_periods_hint'] = ''; +$lang['new_extra_period_title'] = ''; +$lang['extra_period_saved'] = ''; +$lang['add_extra_periods_during_each_day'] = ''; +$lang['add_extra_period'] = ''; diff --git a/src/application/language/italian/translations_lang.php b/src/application/language/italian/translations_lang.php index b4625602..a3e6cd21 100755 --- a/src/application/language/italian/translations_lang.php +++ b/src/application/language/italian/translations_lang.php @@ -298,3 +298,10 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro $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'; +$lang['extra_period'] = 'Giorno extra'; +$lang['extra_periods'] = 'Giorni Extra'; +$lang['extra_periods_hint'] = 'Aggiungi una giornata lavorativa al di fuori del piano di lavoro.'; +$lang['new_extra_period_title'] = 'Nuova giornata lavorativa'; +$lang['extra_period_saved'] = 'Giornata lavorativa salvata con successo!'; +$lang['add_extra_periods_during_each_day'] = 'Aggiungi giornate lavorative al di fuori del piano di lavoro.'; +$lang['add_extra_period'] = 'Aggiungi giornata lavorativa'; diff --git a/src/application/language/japanese/translations_lang.php b/src/application/language/japanese/translations_lang.php index 9087afe6..d3cfae0a 100755 --- a/src/application/language/japanese/translations_lang.php +++ b/src/application/language/japanese/translations_lang.php @@ -298,3 +298,10 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro $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'; +$lang['extra_period'] = ''; +$lang['extra_periods'] = ''; +$lang['extra_periods_hint'] = ''; +$lang['new_extra_period_title'] = ''; +$lang['extra_period_saved'] = ''; +$lang['add_extra_periods_during_each_day'] = ''; +$lang['add_extra_period'] = ''; diff --git a/src/application/language/luxembourgish/translations_lang.php b/src/application/language/luxembourgish/translations_lang.php index 91dd0e14..ae781c5f 100755 --- a/src/application/language/luxembourgish/translations_lang.php +++ b/src/application/language/luxembourgish/translations_lang.php @@ -298,3 +298,10 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro $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'; +$lang['extra_period'] = ''; +$lang['extra_periods'] = ''; +$lang['extra_periods_hint'] = ''; +$lang['new_extra_period_title'] = ''; +$lang['extra_period_saved'] = ''; +$lang['add_extra_periods_during_each_day'] = ''; +$lang['add_extra_period'] = ''; diff --git a/src/application/language/polish/translations_lang.php b/src/application/language/polish/translations_lang.php index d04c6533..f346e25c 100755 --- a/src/application/language/polish/translations_lang.php +++ b/src/application/language/polish/translations_lang.php @@ -298,3 +298,10 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro $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'; +$lang['extra_period'] = ''; +$lang['extra_periods'] = ''; +$lang['extra_periods_hint'] = ''; +$lang['new_extra_period_title'] = ''; +$lang['extra_period_saved'] = ''; +$lang['add_extra_periods_during_each_day'] = ''; +$lang['add_extra_period'] = ''; diff --git a/src/application/language/portuguese-br/translations_lang.php b/src/application/language/portuguese-br/translations_lang.php index 7d96954e..d1b7bca4 100755 --- a/src/application/language/portuguese-br/translations_lang.php +++ b/src/application/language/portuguese-br/translations_lang.php @@ -298,3 +298,15 @@ $lang['delete_personal_information_hint'] = 'Remover toda a informação pessoal $lang['delete_personal_information'] = 'Remover informação pessoal'; $lang['delete_personal_information_prompt'] = 'Tem certeza que você quer remover usa informação pessoal? Essa ação não pode ser desfeita.'; $lang['location'] = 'Location'; +$lang['availabilities_type'] = 'Availabilities Type'; +$lang['flexible'] = 'Flexible'; +$lang['fixed'] = 'Fixed'; +$lang['attendants_number'] = 'Attendants Number'; +$lang['reset_working_plan'] = 'Reset the working plan back to the default values.'; +$lang['extra_period'] = ''; +$lang['extra_periods'] = ''; +$lang['extra_periods_hint'] = ''; +$lang['new_extra_period_title'] = ''; +$lang['extra_period_saved'] = ''; +$lang['add_extra_periods_during_each_day'] = ''; +$lang['add_extra_period'] = ''; diff --git a/src/application/language/portuguese/translations_lang.php b/src/application/language/portuguese/translations_lang.php index 6a5ee8e4..32cdf6ee 100755 --- a/src/application/language/portuguese/translations_lang.php +++ b/src/application/language/portuguese/translations_lang.php @@ -298,3 +298,10 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro $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'; +$lang['extra_period'] = ''; +$lang['extra_periods'] = ''; +$lang['extra_periods_hint'] = ''; +$lang['new_extra_period_title'] = ''; +$lang['extra_period_saved'] = ''; +$lang['add_extra_periods_during_each_day'] = ''; +$lang['add_extra_period'] = ''; diff --git a/src/application/language/romanian/translations_lang.php b/src/application/language/romanian/translations_lang.php index cb06b90c..37fdaebd 100755 --- a/src/application/language/romanian/translations_lang.php +++ b/src/application/language/romanian/translations_lang.php @@ -298,3 +298,10 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro $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'; +$lang['extra_period'] = ''; +$lang['extra_periods'] = ''; +$lang['extra_periods_hint'] = ''; +$lang['new_extra_period_title'] = ''; +$lang['extra_period_saved'] = ''; +$lang['add_extra_periods_during_each_day'] = ''; +$lang['add_extra_period'] = ''; diff --git a/src/application/language/russian/translations_lang.php b/src/application/language/russian/translations_lang.php index a1f4817a..5f1d427b 100755 --- a/src/application/language/russian/translations_lang.php +++ b/src/application/language/russian/translations_lang.php @@ -298,3 +298,10 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro $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'; +$lang['extra_period'] = ''; +$lang['extra_periods'] = ''; +$lang['extra_periods_hint'] = ''; +$lang['new_extra_period_title'] = ''; +$lang['extra_period_saved'] = ''; +$lang['add_extra_periods_during_each_day'] = ''; +$lang['add_extra_period'] = ''; diff --git a/src/application/language/slovak/translations_lang.php b/src/application/language/slovak/translations_lang.php index 2f3214ae..b7c0bd62 100755 --- a/src/application/language/slovak/translations_lang.php +++ b/src/application/language/slovak/translations_lang.php @@ -298,3 +298,10 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro $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'; +$lang['extra_period'] = ''; +$lang['extra_periods'] = ''; +$lang['extra_periods_hint'] = ''; +$lang['new_extra_period_title'] = ''; +$lang['extra_period_saved'] = ''; +$lang['add_extra_periods_during_each_day'] = ''; +$lang['add_extra_period'] = ''; diff --git a/src/application/language/spanish/translations_lang.php b/src/application/language/spanish/translations_lang.php index cffc8b93..d34ac84e 100755 --- a/src/application/language/spanish/translations_lang.php +++ b/src/application/language/spanish/translations_lang.php @@ -298,3 +298,10 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro $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'; +$lang['extra_period'] = ''; +$lang['extra_periods'] = ''; +$lang['extra_periods_hint'] = ''; +$lang['new_extra_period_title'] = ''; +$lang['extra_period_saved'] = ''; +$lang['add_extra_periods_during_each_day'] = ''; +$lang['add_extra_period'] = ''; diff --git a/src/application/language/turkish/translations_lang.php b/src/application/language/turkish/translations_lang.php index 1e77b547..59b7e1f5 100755 --- a/src/application/language/turkish/translations_lang.php +++ b/src/application/language/turkish/translations_lang.php @@ -298,3 +298,10 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro $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'; +$lang['extra_period'] = ''; +$lang['extra_periods'] = ''; +$lang['extra_periods_hint'] = ''; +$lang['new_extra_period_title'] = ''; +$lang['extra_period_saved'] = ''; +$lang['add_extra_periods_during_each_day'] = ''; +$lang['add_extra_period'] = ''; diff --git a/src/application/migrations/014_add_user_extra_working_plan.php b/src/application/migrations/014_add_user_extra_working_plan.php new file mode 100644 index 00000000..e934484c --- /dev/null +++ b/src/application/migrations/014_add_user_extra_working_plan.php @@ -0,0 +1,37 @@ + + * @copyright Copyright (c) 2013 - 2018, Alex Tselegidis + * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 + * @link http://easyappointments.org + * @since v1.2.0 + * ---------------------------------------------------------------------------- */ + +class Migration_Add_user_extra_working_plan extends CI_Migration { + public function up() + { + if (!$this->db->field_exists('extra_working_plan', 'ea_user_settings')) { + $fields = [ + 'extra_working_plan' => [ + 'type' => 'TEXT', + 'null' => TRUE, + 'default' => '', + 'after' => 'working_plan' + ] + ]; + + $this->dbforge->add_column('ea_user_settings', $fields); + } + } + + public function down() + { + if (!$this->db->field_exists('extra_working_plan', 'ea_user_settings')) { + $this->dbforge->drop_column('ea_user_settings', 'extra_working_plan'); + } + } +} diff --git a/src/application/models/Providers_model.php b/src/application/models/Providers_model.php old mode 100644 new mode 100755 index d5529829..c3c001cd --- a/src/application/models/Providers_model.php +++ b/src/application/models/Providers_model.php @@ -600,6 +600,13 @@ class Providers_Model extends CI_Model { foreach ($settings as $name => $value) { + // Sort in descending order the extra working plan days + if ($name == 'extra_working_plan') { + $value = json_decode($value, true); + // Sort the array and put in reverse order + krsort($value); + $value = json_encode($value); + } $this->set_setting($name, $value, $provider_id); } } @@ -638,6 +645,86 @@ class Providers_Model extends CI_Model { } } + /** + * Save the provider extra working plan days. + * + * @param array $extra_period Contains the date and the hours of the extra working plan day. + * @param int $provider_id The selected provider record id. + * + * @return bool Return if the new extra working plan is correctly saved to DB. + * + * @throws Exception If start time is after the end time. + * @throws Exception If $provider_id argument is invalid. + */ + public function set_extra_working_day($extra_period, $provider_id) + { + // Validate period + $dateStart = date('Y-m-d', strtotime($extra_period['start_datetime'])); + $start = date('H:i',strtotime($extra_period['start_datetime'])); + $end = date('H:i',strtotime($extra_period['end_datetime'])); + if ($start > $end) + { + throw new Exception('Unavailable period start must be prior to end.'); + } + + // Validate provider record + $where_clause = [ + 'id' => $provider_id, + 'id_roles' => $this->db->get_where('ea_roles', ['slug' => DB_SLUG_PROVIDER])->row()->id + ]; + + if ($this->db->get_where('ea_users', $where_clause)->num_rows() == 0) + { + throw new Exception('Provider id was not found in database.'); + } + + // Add record to database. + $extra_working_plan = json_decode($this->get_setting('extra_working_plan', $provider_id), true); + + $extra_working_plan[$dateStart] = [ + 'start' => $start, + 'end' => $end, + 'breaks' => [] + ]; + + $success = $this->set_setting('extra_working_plan', json_encode($extra_working_plan), $provider_id); + + return $success; + } + + /** + * Delete a provider extra working plan day. + * + * @param string $extra_period Contains the date to be deleted from the extra working plan. + * @param int $provider_id The selected provider record id. + * + * @return bool Return if the new extra working plan is correctly deleted from DB. + * + * @throws Exception If $provider_id argument is invalid. + */ + public function delete_extra_working_day($extra_period, $provider_id) + { + // Validate provider record + $where_clause = [ + 'id' => $provider_id, + 'id_roles' => $this->db->get_where('ea_roles', ['slug' => DB_SLUG_PROVIDER])->row()->id + ]; + + if ($this->db->get_where('ea_users', $where_clause)->num_rows() == 0) + { + throw new Exception('Provider id was not found in database.'); + } + + // Add record to database. + $extra_working_plan = json_decode($this->get_setting('extra_working_plan', $provider_id), true); + + unset($extra_working_plan[$extra_period]); + + $success = $this->set_setting('extra_working_plan', json_encode($extra_working_plan), $provider_id); + + return $success; + } + /** * Validate Records Username * diff --git a/src/application/views/backend/calendar.php b/src/application/views/backend/calendar.php index c02b1086..09f7a9bf 100755 --- a/src/application/views/backend/calendar.php +++ b/src/application/views/backend/calendar.php @@ -10,6 +10,7 @@ +