Improvements and fixes on the custom availability feature

This commit is contained in:
Alex Tselegidis 2020-09-23 12:24:42 +03:00
parent 1aa8132e4d
commit 30eb95461a
43 changed files with 489 additions and 498 deletions

View file

@ -519,8 +519,8 @@ 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);
// Get the provider's custom availability periods.
$custom_availability_periods = json_decode($this->providers_model->get_setting('custom_availability_periods', $provider_id), TRUE);
$provider_appointments = $this->appointments_model->get_batch([
'id_users_provider' => $provider_id,
@ -543,12 +543,12 @@ 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
// Search if the $selected_date is an custom availability period 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)))]))
if (isset($custom_availability_periods[strtolower(date('Y-m-d', strtotime($selected_date)))]))
{
$selected_date_working_plan = $extra_working_plan[strtolower(date('Y-m-d', strtotime($selected_date)))];
$selected_date_working_plan = $custom_availability_periods[strtolower(date('Y-m-d', strtotime($selected_date)))];
}
}
@ -757,7 +757,7 @@ class Appointments extends CI_Controller {
/**
* Get multiple attendants hours.
*
* This method will add the extra appointment hours whenever a service accepts multiple attendants.
* This method will add the additional appointment hours whenever a service accepts multiple attendants.
*
* @param string $selected_date The selected appointment date.
* @param array $service Selected service data.

View file

@ -333,7 +333,7 @@ class Backend extends CI_Controller {
$view['services'] = $this->services_model->get_batch();
$view['working_plan'] = $this->settings_model->get_setting('company_working_plan');
$view['timezones'] = $this->timezones->to_array();
$view['extra_working_plan'] = '{}';
$view['custom_availability_periods'] = '{}';
$this->set_user_data($view);
$this->load->view('backend/header', $view);

View file

@ -857,16 +857,16 @@ class Backend_api extends CI_Controller {
}
/**
* Insert of update extra working plan time period to database.
* Insert of update custom availability periods to database.
*/
public function ajax_save_extra_period()
public function ajax_save_custom_availability_period()
{
try
{
// Check privileges
$extra_period = json_decode($this->input->post('extra_period'), TRUE);
$custom_availability_period = json_decode($this->input->post('custom_availability_period'), TRUE);
$required_privileges = ( ! isset($extra_period['id']))
$required_privileges = ( ! isset($custom_availability_period['id']))
? $this->privileges[PRIV_APPOINTMENTS]['add']
: $this->privileges[PRIV_APPOINTMENTS]['edit'];
if ($required_privileges == FALSE)
@ -876,7 +876,7 @@ class Backend_api extends CI_Controller {
$this->load->model('providers_model');
$success = $this->providers_model->set_extra_working_day($extra_period, $extra_period['id_users_provider']);
$success = $this->providers_model->set_custom_availability_period($custom_availability_period, $custom_availability_period['id_users_provider']);
if ($success)
{
@ -884,7 +884,7 @@ class Backend_api extends CI_Controller {
}
else
{
$response = ['warnings' => 'Error on saving extra period.'];
$response = ['warnings' => 'Error on saving custom availability period.'];
}
}
catch (Exception $exception)
@ -903,9 +903,9 @@ class Backend_api extends CI_Controller {
}
/**
* Delete an extra working plan time period to database.
* Delete an custom availability periods time period to database.
*/
public function ajax_delete_extra_period()
public function ajax_delete_custom_availability_period()
{
try
{
@ -915,13 +915,13 @@ class Backend_api extends CI_Controller {
}
// Check privileges
$extra_period = $this->input->post('extra_period');
$custom_availability_period = $this->input->post('custom_availability_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);
$success = $this->providers_model->delete_custom_availability_period($custom_availability_period, $provider_id);
if ($success)
{
@ -929,7 +929,7 @@ class Backend_api extends CI_Controller {
}
else
{
$response = ['warnings' => 'Error on deleting extra period.'];
$response = ['warnings' => 'Error on deleting custom availability period.'];
}
}
catch (Exception $exception)

View file

@ -369,13 +369,13 @@ class Availabilities extends API_V1_Controller {
/**
* Get multiple attendants hours.
*
* This method will add the extra appointment hours whenever a service accepts multiple attendants.
* This method will add the additional appointment hours whenever a service accepts multiple attendants.
*
* @param string $selected_date The selected appointment date.
* @param array $service Selected service data.
* @param array $provider Selected provider data.
*
* @return array Retunrs the available hours array.
* @return array Returns the available hours array.
*/
protected function _getMultipleAttendantsHours(
$selected_date,

View file

@ -298,13 +298,13 @@ $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';
$lang['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a working day outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New working day';
$lang['custom_availability_period_saved'] = 'New working day saved successfully!';
$lang['add_custom_availability_periods_during_each_day'] = 'Add working days outside the working plan.';
$lang['add_custom_availability_period'] = 'Add a working day';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
$lang['check_spam_folder'] = 'Please check your spam folder if the email does not arrive within a few minutes.';

View file

@ -298,13 +298,13 @@ $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';
$lang['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a working day outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New working day';
$lang['custom_availability_period_saved'] = 'New working day saved successfully!';
$lang['add_custom_availability_periods_during_each_day'] = 'Add working days outside the working plan.';
$lang['add_custom_availability_period'] = 'Add a working day';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
$lang['check_spam_folder'] = 'Please check your spam folder if the email does not arrive within a few minutes.';

View file

@ -298,13 +298,13 @@ $lang['delete_personal_information_hint'] = 'Elimineu les vostres dades del sist
$lang['delete_personal_information'] = 'Eliminació de dades personals';
$lang['delete_personal_information_prompt'] = 'Esteu segur que voleu eliminar la vostra informació personal? Aquesta acció no es pot desfer.';
$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';
$lang['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a working day outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New working day';
$lang['custom_availability_period_saved'] = 'New working day saved successfully!';
$lang['add_custom_availability_periods_during_each_day'] = 'Add working days outside the working plan.';
$lang['add_custom_availability_period'] = 'Add a working day';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
$lang['check_spam_folder'] = 'Please check your spam folder if the email does not arrive within a few minutes.';

View file

@ -298,13 +298,13 @@ $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';
$lang['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a working day outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New working day';
$lang['custom_availability_period_saved'] = 'New working day saved successfully!';
$lang['add_custom_availability_periods_during_each_day'] = 'Add working days outside the working plan.';
$lang['add_custom_availability_period'] = 'Add a working day';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
$lang['check_spam_folder'] = 'Please check your spam folder if the email does not arrive within a few minutes.';

View file

@ -298,13 +298,13 @@ $lang['delete_personal_information_hint'] = 'Odstranit ze systému všechny osob
$lang['delete_personal_information'] = 'Odstranit osobní údaje';
$lang['delete_personal_information_prompt'] = 'Jste si jisti, že chcete odstranit vaše osobní údaje? Tuto akci nelze vzít zpět.';
$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';
$lang['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a working day outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New working day';
$lang['custom_availability_period_saved'] = 'New working day saved successfully!';
$lang['add_custom_availability_periods_during_each_day'] = 'Add working days outside the working plan.';
$lang['add_custom_availability_period'] = 'Add a working day';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
$lang['check_spam_folder'] = 'Please check your spam folder if the email does not arrive within a few minutes.';

View file

@ -298,13 +298,13 @@ $lang['delete_personal_information_hint'] = 'Slet alle dine personlige oplysning
$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';
$lang['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a working day outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New working day';
$lang['custom_availability_period_saved'] = 'New working day saved successfully!';
$lang['add_custom_availability_periods_during_each_day'] = 'Add working days outside the working plan.';
$lang['add_custom_availability_period'] = 'Add a working day';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
$lang['check_spam_folder'] = 'Please check your spam folder if the email does not arrive within a few minutes.';

View file

@ -298,13 +298,13 @@ $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';
$lang['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a working day outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New working day';
$lang['custom_availability_period_saved'] = 'New working day saved successfully!';
$lang['add_custom_availability_periods_during_each_day'] = 'Add working days outside the working plan.';
$lang['add_custom_availability_period'] = 'Add a working day';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
$lang['check_spam_folder'] = 'Please check your spam folder if the email does not arrive within a few minutes.';

View file

@ -300,13 +300,13 @@ $lang['delete_personal_information_hint'] = 'Remove all your appointments and pe
$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';
$lang['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a working day outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New working day';
$lang['custom_availability_period_saved'] = 'New working day saved successfully!';
$lang['add_custom_availability_periods_during_each_day'] = 'Add working days outside the working plan.';
$lang['add_custom_availability_period'] = 'Add a working day';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
$lang['check_spam_folder'] = 'Please check your spam folder if the email does not arrive within a few minutes.';

View file

@ -298,13 +298,13 @@ $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';
$lang['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a working day outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New working day';
$lang['custom_availability_period_saved'] = 'New working day saved successfully!';
$lang['add_custom_availability_periods_during_each_day'] = 'Add working days outside the working plan.';
$lang['add_custom_availability_period'] = 'Add a working day';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
$lang['check_spam_folder'] = 'Please check your spam folder if the email does not arrive within a few minutes.';

View file

@ -298,13 +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['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';
$lang['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a working day outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New working day';
$lang['custom_availability_period_saved'] = 'New working day saved successfully!';
$lang['add_custom_availability_periods_during_each_day'] = 'Add working days outside the working plan.';
$lang['add_custom_availability_period'] = 'Add a working day';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
$lang['check_spam_folder'] = 'Please check your spam folder if the email does not arrive within a few minutes.';

View file

@ -298,13 +298,13 @@ $lang['delete_personal_information_hint'] = 'Entfernen Sie alle Ihre Termine und
$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'] = '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';
$lang['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a working day outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New working day';
$lang['custom_availability_period_saved'] = 'New working day saved successfully!';
$lang['add_custom_availability_periods_during_each_day'] = 'Add working days outside the working plan.';
$lang['add_custom_availability_period'] = 'Add a working day';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
$lang['check_spam_folder'] = 'Please check your spam folder if the email does not arrive within a few minutes.';

View file

@ -298,13 +298,13 @@ $lang['delete_personal_information_hint'] = 'Κατάργηση όλων των
$lang['delete_personal_information'] = 'Διαγραφή Προσωπικών Πληροφοριών';
$lang['delete_personal_information_prompt'] = 'Είστε σίγουρος ότι θέλετε να διαγράψετε τις προσωπικές σας πληροφορίες; Αυτή η ενέργεια δεν μπορεί να αναιρεθεί.';
$lang['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';
$lang['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a working day outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New working day';
$lang['custom_availability_period_saved'] = 'New working day saved successfully!';
$lang['add_custom_availability_periods_during_each_day'] = 'Add working days outside the working plan.';
$lang['add_custom_availability_period'] = 'Add a working day';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
$lang['check_spam_folder'] = 'Please check your spam folder if the email does not arrive within a few minutes.';

View file

@ -298,13 +298,13 @@ $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';
$lang['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a working day outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New working day';
$lang['custom_availability_period_saved'] = 'New working day saved successfully!';
$lang['add_custom_availability_periods_during_each_day'] = 'Add working days outside the working plan.';
$lang['add_custom_availability_period'] = 'Add a working day';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
$lang['check_spam_folder'] = 'Please check your spam folder if the email does not arrive within a few minutes.';

View file

@ -298,13 +298,13 @@ $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';
$lang['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a working day outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New working day';
$lang['custom_availability_period_saved'] = 'New working day saved successfully!';
$lang['add_custom_availability_periods_during_each_day'] = 'Add working days outside the working plan.';
$lang['add_custom_availability_period'] = 'Add a working day';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
$lang['check_spam_folder'] = 'Please check your spam folder if the email does not arrive within a few minutes.';

View file

@ -298,13 +298,13 @@ $lang['delete_personal_information_hint'] = 'Cancella tutti i dati personali dal
$lang['delete_personal_information'] = 'Cancella dati personali';
$lang['delete_personal_information_prompt'] = 'Sicuro di voler cancellare i tuoi dati personali? Questa operazione è irreversibile.';
$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';
$lang['custom_availability_period'] = 'Giorno extra';
$lang['custom_availability_periods'] = 'Giorni Extra';
$lang['custom_availability_periods_hint'] = 'Aggiungi una giornata lavorativa al di fuori del piano di lavoro.';
$lang['new_custom_availability_period_title'] = 'Nuova giornata lavorativa';
$lang['custom_availability_period_saved'] = 'Giornata lavorativa salvata con successo!';
$lang['add_custom_availability_periods_during_each_day'] = 'Aggiungi giornate lavorative al di fuori del piano di lavoro.';
$lang['add_custom_availability_period'] = 'Aggiungi giornata lavorativa';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
$lang['check_spam_folder'] = 'Please check your spam folder if the email does not arrive within a few minutes.';

View file

@ -298,13 +298,13 @@ $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';
$lang['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a working day outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New working day';
$lang['custom_availability_period_saved'] = 'New working day saved successfully!';
$lang['add_custom_availability_periods_during_each_day'] = 'Add working days outside the working plan.';
$lang['add_custom_availability_period'] = 'Add a working day';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
$lang['check_spam_folder'] = 'Please check your spam folder if the email does not arrive within a few minutes.';

View file

@ -298,13 +298,13 @@ $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';
$lang['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a working day outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New working day';
$lang['custom_availability_period_saved'] = 'New working day saved successfully!';
$lang['add_custom_availability_periods_during_each_day'] = 'Add working days outside the working plan.';
$lang['add_custom_availability_period'] = 'Add a working day';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
$lang['check_spam_folder'] = 'Please check your spam folder if the email does not arrive within a few minutes.';

View file

@ -298,13 +298,13 @@ $lang['delete_personal_information_hint'] = 'सिस्टमवरून स
$lang['delete_personal_information'] = 'वैयक्तिक माहिती हटवा';
$lang['delete_personal_information_prompt'] = 'आपली खात्री आहे की आपण आपली वैयक्तिक माहिती हटवू इच्छिता? ही क्रिया पूर्ववत करणे शक्य नाही.';
$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';
$lang['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a working day outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New working day';
$lang['custom_availability_period_saved'] = 'New working day saved successfully!';
$lang['add_custom_availability_periods_during_each_day'] = 'Add working days outside the working plan.';
$lang['add_custom_availability_period'] = 'Add a working day';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
$lang['check_spam_folder'] = 'Please check your spam folder if the email does not arrive within a few minutes.';

View file

@ -298,13 +298,13 @@ $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';
$lang['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a working day outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New working day';
$lang['custom_availability_period_saved'] = 'New working day saved successfully!';
$lang['add_custom_availability_periods_during_each_day'] = 'Add working days outside the working plan.';
$lang['add_custom_availability_period'] = 'Add a working day';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
$lang['check_spam_folder'] = 'Please check your spam folder if the email does not arrive within a few minutes.';

View file

@ -298,13 +298,13 @@ $lang['delete_personal_information_hint'] = 'Deletar toda informação pessoal d
$lang['delete_personal_information'] = 'Deletar Informação Pessoal';
$lang['delete_personal_information_prompt'] = 'Tem certeza que deja deletar suas informações pessoais? Essa ação não pode ser desfeita.';
$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';
$lang['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a working day outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New working day';
$lang['custom_availability_period_saved'] = 'New working day saved successfully!';
$lang['add_custom_availability_periods_during_each_day'] = 'Add working days outside the working plan.';
$lang['add_custom_availability_period'] = 'Add a working day';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
$lang['check_spam_folder'] = 'Please check your spam folder if the email does not arrive within a few minutes.';

View file

@ -298,13 +298,13 @@ $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';
$lang['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a working day outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New working day';
$lang['custom_availability_period_saved'] = 'New working day saved successfully!';
$lang['add_custom_availability_periods_during_each_day'] = 'Add working days outside the working plan.';
$lang['add_custom_availability_period'] = 'Add a working day';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
$lang['check_spam_folder'] = 'Please check your spam folder if the email does not arrive within a few minutes.';

View file

@ -298,13 +298,13 @@ $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';
$lang['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a working day outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New working day';
$lang['custom_availability_period_saved'] = 'New working day saved successfully!';
$lang['add_custom_availability_periods_during_each_day'] = 'Add working days outside the working plan.';
$lang['add_custom_availability_period'] = 'Add a working day';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
$lang['check_spam_folder'] = 'Please check your spam folder if the email does not arrive within a few minutes.';

View file

@ -298,13 +298,13 @@ $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';
$lang['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a working day outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New working day';
$lang['custom_availability_period_saved'] = 'New working day saved successfully!';
$lang['add_custom_availability_periods_during_each_day'] = 'Add working days outside the working plan.';
$lang['add_custom_availability_period'] = 'Add a working day';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
$lang['check_spam_folder'] = 'Please check your spam folder if the email does not arrive within a few minutes.';

View file

@ -298,13 +298,13 @@ $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';
$lang['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a working day outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New working day';
$lang['custom_availability_period_saved'] = 'New working day saved successfully!';
$lang['add_custom_availability_periods_during_each_day'] = 'Add working days outside the working plan.';
$lang['add_custom_availability_period'] = 'Add a working day';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
$lang['check_spam_folder'] = 'Please check your spam folder if the email does not arrive within a few minutes.';

View file

@ -298,13 +298,13 @@ $lang['delete_personal_information_hint'] = 'Borrar toda la información persona
$lang['delete_personal_information'] = 'Borrar información personal';
$lang['delete_personal_information_prompt'] = '¿Estás seguro que quieres borrar tu información personal? Esta acción no se puede deshacer.';
$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';
$lang['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a working day outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New working day';
$lang['custom_availability_period_saved'] = 'New working day saved successfully!';
$lang['add_custom_availability_periods_during_each_day'] = 'Add working days outside the working plan.';
$lang['add_custom_availability_period'] = 'Add a working day';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
$lang['check_spam_folder'] = 'Please check your spam folder if the email does not arrive within a few minutes.';

View file

@ -298,13 +298,13 @@ $lang['delete_personal_information_hint'] = 'Ta bort all dina personliga uppgift
$lang['delete_personal_information'] = 'Ta bort Personlig Information';
$lang['delete_personal_information_prompt'] = 'Är du säker på att du vill ta bort all information om dig från systemet? Det går inte att återställa informationen om du ångrar dig.';
$lang['location'] = 'Plats';
$lang['extra_period'] = 'Extra arbetsdag';
$lang['extra_periods'] = 'Extra arbetsdagar';
$lang['extra_periods_hint'] = 'Lägg till en arbetsdag utanför schemat.';
$lang['new_extra_period_title'] = 'Ny arbetsdag';
$lang['extra_period_saved'] = 'Den nya arbetsdagen är sparad.';
$lang['add_extra_periods_during_each_day'] = 'Lägg till arbetsdagar utanför schemat.';
$lang['add_extra_period'] = 'Lägg till en arbetsdag.';
$lang['custom_availability_period'] = 'Extra arbetsdag';
$lang['custom_availability_periods'] = 'Extra arbetsdagar';
$lang['custom_availability_periods_hint'] = 'Lägg till en arbetsdag utanför schemat.';
$lang['new_custom_availability_period_title'] = 'Ny arbetsdag';
$lang['custom_availability_period_saved'] = 'Den nya arbetsdagen är sparad.';
$lang['add_custom_availability_periods_during_each_day'] = 'Lägg till arbetsdagar utanför schemat.';
$lang['add_custom_availability_period'] = 'Lägg till en arbetsdag.';
$lang['require_phone_number'] = 'Kräv telefonnummer.';
$lang['require_phone_number_hint'] = 'När denna är aktiv måste kunderna ange ett telefonnummer för att kunna göra en bokning.';
$lang['check_spam_folder'] = 'Om eposten inte kommit fram inom några minuter; kolla skräpposten.';

View file

@ -298,13 +298,13 @@ $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';
$lang['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a working day outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New working day';
$lang['custom_availability_period_saved'] = 'New working day saved successfully!';
$lang['add_custom_availability_periods_during_each_day'] = 'Add working days outside the working plan.';
$lang['add_custom_availability_period'] = 'Add a working day';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
$lang['check_spam_folder'] = 'Please check your spam folder if the email does not arrive within a few minutes.';

View file

@ -12,21 +12,21 @@
* ---------------------------------------------------------------------------- */
/**
* Class Migration_Add_extra_working_plan_to_user_settings
* Class Migration_Add_custom_availability_periods_to_user_settings
*
* @property CI_DB_query_builder db
* @property CI_DB_forge dbforge
*/
class Migration_Add_extra_working_plan_to_user_settings extends CI_Migration {
class Migration_Add_custom_availability_periods_to_user_settings extends CI_Migration {
/**
* Upgrade method.
*/
public function up()
{
if ( ! $this->db->field_exists('extra_working_plan', 'user_settings'))
if ( ! $this->db->field_exists('custom_availability_periods', 'user_settings'))
{
$fields = [
'extra_working_plan' => [
'custom_availability_periods' => [
'type' => 'TEXT',
'null' => TRUE,
'after' => 'working_plan'
@ -42,9 +42,9 @@ class Migration_Add_extra_working_plan_to_user_settings extends CI_Migration {
*/
public function down()
{
if ( ! $this->db->field_exists('extra_working_plan', 'user_settings'))
if ( ! $this->db->field_exists('custom_availability_periods', 'user_settings'))
{
$this->dbforge->drop_column('user_settings', 'extra_working_plan');
$this->dbforge->drop_column('user_settings', 'custom_availability_periods');
}
}
}

View file

@ -322,8 +322,8 @@ 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')
// Sort in descending order the custom availability periods
if ($name == 'custom_availability_periods')
{
$value = json_decode($value, TRUE);
// Sort the array and put in reverse order
@ -634,22 +634,22 @@ class Providers_Model extends CI_Model {
}
/**
* Save the provider extra working plan days.
* Save the provider custom availability period.
*
* @param array $extra_period Contains the date and the hours of the extra working plan day.
* @param array $custom_availability_period Contains the date and the hours of the Custom availability period.
* @param int $provider_id The selected provider record id.
*
* @return bool Return if the new extra working plan is correctly saved to DB.
* @return bool Return if the new custom availability periods 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)
public function set_custom_availability_period($custom_availability_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']));
$dateStart = date('Y-m-d', strtotime($custom_availability_period['start_datetime']));
$start = date('H:i', strtotime($custom_availability_period['start_datetime']));
$end = date('H:i', strtotime($custom_availability_period['end_datetime']));
if ($start > $end)
{
throw new Exception('Unavailable period start must be prior to end.');
@ -667,17 +667,15 @@ class Providers_Model extends CI_Model {
}
// Add record to database.
$extra_working_plan = json_decode($this->get_setting('extra_working_plan', $provider_id), TRUE);
$custom_availability_periods = json_decode($this->get_setting('custom_availability_periods', $provider_id), TRUE);
$extra_working_plan[$dateStart] = [
$custom_availability_periods[$dateStart] = [
'start' => $start,
'end' => $end,
'breaks' => []
];
$success = $this->set_setting('extra_working_plan', json_encode($extra_working_plan), $provider_id);
return $success;
return $this->set_setting('custom_availability_periods', json_encode($custom_availability_periods), $provider_id);
}
/**
@ -695,16 +693,16 @@ class Providers_Model extends CI_Model {
}
/**
* Delete a provider extra working plan day.
* Delete a provider custom availability period.
*
* @param string $extra_period Contains the date to be deleted from the extra working plan.
* @param string $custom_availability_period Contains the date to be deleted from the custom availability periods.
* @param int $provider_id The selected provider record id.
*
* @return bool Return if the new extra working plan is correctly deleted from DB.
* @return bool Return if the new custom availability periods is correctly deleted from DB.
*
* @throws Exception If $provider_id argument is invalid.
*/
public function delete_extra_working_day($extra_period, $provider_id)
public function delete_custom_availability_period($custom_availability_period, $provider_id)
{
// Validate provider record
$where_clause = [
@ -718,12 +716,10 @@ class Providers_Model extends CI_Model {
}
// Add record to database.
$extra_working_plan = json_decode($this->get_setting('extra_working_plan', $provider_id), TRUE);
$custom_availability_periods = json_decode($this->get_setting('custom_availability_periods', $provider_id), TRUE);
unset($extra_working_plan[$extra_period]);
unset($custom_availability_periods[$custom_availability_period]);
$success = $this->set_setting('extra_working_plan', json_encode($extra_working_plan), $provider_id);
return $success;
return $this->set_setting('custom_availability_periods', json_encode($custom_availability_periods), $provider_id);
}
}

View file

@ -9,7 +9,7 @@
<script src="<?= asset_url('assets/js/backend_calendar_google_sync.js') ?>"></script>
<script src="<?= asset_url('assets/js/backend_calendar_appointments_modal.js') ?>"></script>
<script src="<?= asset_url('assets/js/backend_calendar_unavailabilities_modal.js') ?>"></script>
<script src="<?= asset_url('assets/js/backend_calendar_extra_periods_modal.js') ?>"></script>
<script src="<?= asset_url('assets/js/backend_calendar_custom_availability_periods_modal.js') ?>"></script>
<script src="<?= asset_url('assets/js/backend_calendar_api.js') ?>"></script>
<script>
var GlobalVariables = {
@ -83,9 +83,9 @@
<i class="far fa-plus-square mr-2"></i>
<?= lang('unavailable') ?>
</a>
<a class="dropdown-item" href="#" id="insert-extra-period">
<a class="dropdown-item" href="#" id="insert-custom-availability-period">
<i class="far fa-plus-square mr-2"></i>
<?= lang('extra_period') ?>
<?= lang('custom_availability_period') ?>
</a>
</div>
</div>
@ -117,7 +117,7 @@
<!-- MANAGE APPOINTMENT MODAL -->
<div id="manage-appointment" class="modal fade" data-keyboard="true" tabindex="-1">
<div id="manage-appointment" class="modal fade" tabindex="-1">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
@ -355,7 +355,7 @@
<!-- MANAGE UNAVAILABLE MODAL -->
<div id="manage-unavailable" class="modal fade">
<div id="manage-unavailable" class="modal fade" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
@ -424,13 +424,13 @@
</div>
</div>
<!-- MANAGE EXTRA PERIOD MODAL -->
<!-- MANAGE CUSTOM AVAILABILITY PERIODS MODAL -->
<div id="manage-extra" class="modal fade">
<div id="manage-custom-availability-periods" class="modal fade" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title"><?= lang('new_extra_period_title') ?></h3>
<h3 class="modal-title"><?= lang('new_custom_availability_period_title') ?></h3>
<button class="close" data-dismiss="modal">&times;</button>
</div>
<div class="modal-body">
@ -438,21 +438,21 @@
<form>
<fieldset>
<input id="extra-id" type="hidden">
<input id="custom-availability-period-id" type="hidden">
<div class="form-group">
<label for="extra-provider" class="control-label"><?= lang('provider') ?></label>
<select id="extra-provider" class="form-control"></select>
<label for="custom-availability-period-provider" class="control-label"><?= lang('provider') ?></label>
<select id="custom-availability-period-provider" class="form-control"></select>
</div>
<div class="form-group">
<label for="extra-start" class="control-label"><?= lang('start') ?></label>
<input id="extra-start" class="form-control">
<label for="custom-availability-period-start" class="control-label"><?= lang('start') ?></label>
<input id="custom-availability-period-start" class="form-control">
</div>
<div class="form-group">
<label for="extra-end" class="control-label"><?= lang('end') ?></label>
<input id="extra-end" class="form-control">
<label for="custom-availability-period-end" class="control-label"><?= lang('end') ?></label>
<input id="custom-availability-period-end" class="form-control">
</div>
<div class="form-group">
@ -477,11 +477,11 @@
</form>
</div>
<div class="modal-footer">
<button id="cancel-extra" class="btn btn-light" data-dismiss="modal">
<button id="cancel-custom-availability-period" class="btn btn-light" data-dismiss="modal">
<i class="fas fa-ban"></i>
<?= lang('cancel') ?>
</button>
<button id="save-extra" class="btn btn-primary">
<button id="save-custom-availability-period" class="btn btn-primary">
<i class="far fa-check-square mr-2"></i>
<?= lang('save') ?>
</button>

View file

@ -18,7 +18,7 @@
services: <?= json_encode($services) ?>,
timezones: <?= json_encode($timezones) ?>,
workingPlan: <?= json_encode(json_decode($working_plan)) ?>,
extraWorkingPlan: <?= json_encode(json_decode($extra_working_plan)) ?>,
customavailabilityperiods: <?= json_encode(json_decode($custom_availability_periods)) ?>,
user: {
id: <?= $user_id ?>,
email: <?= json_encode($user_email) ?>,
@ -290,22 +290,22 @@
<br>
<h3><?= lang('extra_periods') ?></h3>
<h3><?= lang('custom_availability_periods') ?></h3>
<span class="help-block">
<?= lang('add_extra_periods_during_each_day') ?>
<?= lang('add_custom_availability_periods_during_each_day') ?>
</span>
<div>
<button type="button" class="add-extra-periods btn btn-primary mr-2">
<button type="button" class="add-custom-availability-periods btn btn-primary mr-2">
<i class="far fa-plus-square"></i>
<?= lang('add_extra_period') ?>
<?= lang('add_custom_availability_period') ?>
</button>
</div>
<br>
<table class="extra-periods table table-striped">
<table class="custom-availability-periods table table-striped">
<thead>
<tr>
<th><?= lang('day') ?></th>

View file

@ -148,8 +148,7 @@ body .modal .modal-title {
body .modal-header {
padding: 12px 15px;
background: #39c678;
border-bottom: 4px solid #c0f1d6;
background: #429a82;
}
body .modal-header h3 {
@ -726,7 +725,7 @@ body .form-horizontal .controls {
padding: 4px 7px;
}
#users-page #providers .extra-periods .btn {
#users-page #providers .custom-availability-periods .btn {
margin-right: 5px;
padding: 4px 7px;
}
@ -736,7 +735,7 @@ body .form-horizontal .controls {
height: 36px;
}
.extra-periods .extra-day select {
.custom-availability-periods .custom-availability-period select {
height: 36px;
}
}

View file

@ -78,7 +78,7 @@ window.BackendCalendar = window.BackendCalendar || {};
BackendCalendarGoogleSync.initialize();
BackendCalendarAppointmentsModal.initialize();
BackendCalendarUnavailabilitiesModal.initialize();
BackendCalendarExtraPeriodsModal.initialize();
BackendCalendarCustomAvailabilityPeriodsModal.initialize();
// Load and initialize the calendar view.
if (view === 'table') {

View file

@ -91,18 +91,18 @@ window.BackendCalendarApi = window.BackendCalendarApi || {};
};
/**
* Save extra period of work to database.
* Save custom availability period of work to database.
*
* @param {Object} extra_periods Contains the extra period data.
* @param {Object} customAvailabilityPeriods Contains the custom availability periods data.
* @param {Function} successCallback The ajax success callback function.
* @param {Function} errorCallback The ajax failure callback function.
*/
exports.saveExtraPeriod = function (extra_periods, successCallback, errorCallback) {
var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_extra_period';
exports.saveCustomavailabilityperiod = function (customAvailabilityPeriods, successCallback, errorCallback) {
var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_custom_availability_period';
var data = {
csrfToken: GlobalVariables.csrfToken,
extra_period: JSON.stringify(extra_periods)
custom_availability_period: JSON.stringify(customAvailabilityPeriods)
};
$.post(url, data)

View file

@ -10,13 +10,13 @@
* ---------------------------------------------------------------------------- */
/**
* Backend Calendar Extra Periods Modal
* Backend Calendar Custom availability periods Modal
*
* This module implements the extra periods modal functionality.
* This module implements the custom availability periods modal functionality.
*
* @module BackendCalendarExtraPeriodsModal
* @module BackendCalendarCustomAvailabilityPeriodsModal
*/
window.BackendCalendarExtraPeriodsModal = window.BackendCalendarExtraPeriodsModal || {};
window.BackendCalendarCustomAvailabilityPeriodsModal = window.BackendCalendarCustomAvailabilityPeriodsModal || {};
(function (exports) {
@ -24,15 +24,15 @@ window.BackendCalendarExtraPeriodsModal = window.BackendCalendarExtraPeriodsModa
function bindEventHandlers() {
/**
* Event: Manage extra Dialog Save Button "Click"
* Event: Manage Dialog Save Button "Click"
*
* Stores the extra period changes or inserts a new record.
* Stores the custom availability period changes or inserts a new record.
*/
$('#manage-extra #save-extra').on('click', function () {
var $dialog = $('#manage-extra');
$('#manage-custom-availability-periods #save-custom-availability-period').on('click', function () {
var $dialog = $('#manage-custom-availability-periods');
$dialog.find('.has-error').removeClass('has-error');
var start = $dialog.find('#extra-start').datetimepicker('getDate');
var end = Date.parse($dialog.find('#extra-end').datetimepicker('getDate'));
var start = $dialog.find('#custom-availability-period-start').datetimepicker('getDate');
var end = Date.parse($dialog.find('#custom-availability-period-end').datetimepicker('getDate'));
if (start.toString('HH:mm') > end.toString('HH:mm')) {
// Start time is after end time - display message to user.
@ -41,43 +41,43 @@ window.BackendCalendarExtraPeriodsModal = window.BackendCalendarExtraPeriodsModa
.addClass('alert-danger')
.removeClass('hidden');
$dialog.find('#extra-start, #extra-end').closest('.form-group').addClass('has-error');
$dialog.find('#custom-availability-period-start, #custom-availability-period-end').closest('.form-group').addClass('has-error');
return;
}
// extra period records go to the appointments table.
var extra = {
// Custom availability period period records go to the appointments table.
var customAvailabilityPeriod = {
start_datetime: start.toString('yyyy-MM-dd HH:mm'),
end_datetime: start.toString('yyyy-MM-dd') + ' ' + end.toString('HH:mm'),
id_users_provider: $('#extra-provider').val() // curr provider
id_users_provider: $('#custom-availability-period-provider').val() // curr provider
};
//if ($dialog.find('#extra-id').val() !== '') {
// // Set the id value, only if we are editing an appointment.
// extra.id = $dialog.find('#extra-id').val();
//if ($dialog.find('#custom-availability-period-id').val() !== '') {
// // Set the id value, only if we are editing a custom availability period.
// customAvailabilityPeriod.id = $dialog.find('#custom-availability-period-id').val();
//}
var successCallback = function (response) {
// Display success message to the user.
Backend.displayNotification(EALang.extra_period_saved);
Backend.displayNotification(EALang.custom_availability_period_saved);
// Close the modal dialog and refresh the calendar appointments.
$dialog.find('.alert').addClass('hidden');
$dialog.modal('hide');
var providerId = $('#extra-provider').val();
var providerId = $('#custom-availability-period-provider').val();
var provider = GlobalVariables.availableProviders.filter(function (p) {
return p.id === providerId;
})[0];
var providerIdx = GlobalVariables.availableProviders.indexOf(provider);
var extraWorkingPlan = jQuery.parseJSON(provider.settings.extra_working_plan);
extraWorkingPlan[start.toString('yyyy-MM-dd')] = {
var customAvailabilityPeriods = jQuery.parseJSON(provider.settings.custom_availability_periods);
customAvailabilityPeriods[start.toString('yyyy-MM-dd')] = {
start: start.toString('HH:mm'),
end: end.toString('HH:mm'),
breaks: []
};
provider.settings.extra_working_plan = JSON.stringify(extraWorkingPlan);
provider.settings.custom_availability_periods = JSON.stringify(customAvailabilityPeriods);
GlobalVariables.availableProviders[providerIdx] = provider;
$('#select-filter-item').trigger('change');
@ -88,27 +88,27 @@ window.BackendCalendarExtraPeriodsModal = window.BackendCalendarExtraPeriodsModa
$dialog.find('.modal-message').addClass('alert-danger').removeClass('hidden');
};
BackendCalendarApi.saveExtraPeriod(extra, successCallback, errorCallback);
BackendCalendarApi.saveCustomavailabilityperiod(customAvailabilityPeriod, successCallback, errorCallback);
});
/**
* Event: Manage extra Dialog Cancel Button "Click"
* Event: Manage Dialog Cancel Button "Click"
*
* Closes the dialog without saveing any changes to the database.
* Closes the dialog without saving any changes to the database.
*/
$('#manage-extra #cancel-extra').on('click', function () {
$('#manage-extra').modal('hide');
$('#manage-custom-availability-periods #cancel-custom-availability-period').on('click', function () {
$('#manage-custom-availability-periods').modal('hide');
});
/**
* Event : Insert extra Time Period Button "Click"
* Event: Insert Custom Working Time Period Button "Click"
*
* When the user clicks this button a popup dialog appears and the use can set a time period where
* he cannot accept any appointments.
* When the user clicks this button a popup dialog appears and the use can set a time period where he cannot
* accept any appointments.
*/
$('#insert-extra-period').on('click', function () {
BackendCalendarExtraPeriodsModal.resetExtraDialog();
var $dialog = $('#manage-extra');
$('#insert-custom-availability-period').on('click', function () {
BackendCalendarCustomAvailabilityPeriodsModal.resetCustomavailabilityperiodDialog();
var $dialog = $('#manage-custom-availability-periods');
// Set the default datetime values.
var start = new Date();
@ -117,29 +117,29 @@ window.BackendCalendarExtraPeriodsModal = window.BackendCalendarExtraPeriodsModa
start.set({'minute': 30});
if ($('.calendar-view').length === 0) {
$dialog.find('#extra-provider')
$dialog.find('#custom-availability-period-provider')
.val($('#select-filter-item').val())
.closest('.form-group')
.hide();
}
$dialog.find('#extra-start').val(GeneralFunctions.formatDate(start, GlobalVariables.dateFormat, true));
$dialog.find('#extra-end').val(GlobalVariables.timeFormat === 'regular' ? '8:00 PM' : '19:00');
$dialog.find('.modal-header h3').text(EALang.new_extra_period_title);
$dialog.find('#custom-availability-period-start').val(GeneralFunctions.formatDate(start, GlobalVariables.dateFormat, true));
$dialog.find('#custom-availability-period-end').val(GlobalVariables.timeFormat === 'regular' ? '8:00 PM' : '19:00');
$dialog.find('.modal-header h3').text(EALang.new_custom_availability_period_title);
$dialog.modal('show');
});
}
/**
* Reset extra dialog form.
* Reset custom availability period dialog form.
*
* Reset the "#manage-extra" dialog. Use this method to bring the dialog to the initial state
* Reset the "#manage-custom-availability-periods" dialog. Use this method to bring the dialog to the initial state
* before it becomes visible to the user.
*/
exports.resetExtraDialog = function () {
var $dialog = $('#manage-extra');
exports.resetCustomavailabilityperiodDialog = function () {
var $dialog = $('#manage-custom-availability-periods');
$dialog.find('#extra-id').val('');
$dialog.find('#custom-availability-period-id').val('');
// Set the default datetime values.
var start = new Date();
@ -163,7 +163,7 @@ window.BackendCalendarExtraPeriodsModal = window.BackendCalendarExtraPeriodsModa
}
$dialog.find('#extra-start').datetimepicker({
$dialog.find('#custom-availability-period-start').datetimepicker({
dateFormat: dateFormat,
timeFormat: GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : GlobalVariables.timeFormat,
@ -191,10 +191,10 @@ window.BackendCalendarExtraPeriodsModal = window.BackendCalendarExtraPeriodsModa
minuteText: EALang.minutes,
firstDay: 0
});
$dialog.find('#extra-start').val(GeneralFunctions.formatDate(start, GlobalVariables.dateFormat, true));
$dialog.find('#extra-start').draggable();
$dialog.find('#custom-availability-period-start').val(GeneralFunctions.formatDate(start, GlobalVariables.dateFormat, true));
$dialog.find('#custom-availability-period-start').draggable();
$dialog.find('#extra-end').timepicker({
$dialog.find('#custom-availability-period-end').timepicker({
timeFormat: GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : GlobalVariables.timeFormat,
currentText: EALang.now,
closeText: EALang.close,
@ -203,22 +203,22 @@ window.BackendCalendarExtraPeriodsModal = window.BackendCalendarExtraPeriodsModa
hourText: EALang.hour,
minuteText: EALang.minutes
});
$dialog.find('#extra-end').val(end);
$dialog.find('#custom-availability-period-end').val(end);
// Clear the extra notes field.
$dialog.find('#extra-notes').val('');
// Clear the custom availability period notes field.
$dialog.find('#custom-availability-period-notes').val('');
};
exports.initialize = function () {
var extraProvider = $('#extra-provider');
var customAvailabilityPeriodProvider = $('#custom-availability-period-provider');
for (var index in GlobalVariables.availableProviders) {
var provider = GlobalVariables.availableProviders[index];
extraProvider.append(new Option(provider.first_name + ' ' + provider.last_name, provider.id));
customAvailabilityPeriodProvider.append(new Option(provider.first_name + ' ' + provider.last_name, provider.id));
}
bindEventHandlers();
};
})(window.BackendCalendarExtraPeriodsModal);
})(window.BackendCalendarCustomAvailabilityPeriodsModal);

View file

@ -66,6 +66,8 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
$(this).parents('.popover').popover('dispose');
var $dialog;
var startDatetime;
var endDatetime;
if (lastFocusedEventData.data.is_unavailable === '0') {
var appointment = lastFocusedEventData.data;
@ -80,10 +82,10 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
$dialog.find('#select-provider').val(appointment.id_users_provider);
// Set the start and end datetime of the appointment.
var startDatetime = Date.parseExact(appointment.start_datetime, 'yyyy-MM-dd HH:mm:ss');
startDatetime = Date.parseExact(appointment.start_datetime, 'yyyy-MM-dd HH:mm:ss');
$dialog.find('#start-datetime').datetimepicker('setDate', startDatetime);
var endDatetime = Date.parseExact(appointment.end_datetime, 'yyyy-MM-dd HH:mm:ss');
endDatetime = Date.parseExact(appointment.end_datetime, 'yyyy-MM-dd HH:mm:ss');
$dialog.find('#end-datetime').datetimepicker('setDate', endDatetime);
var customer = appointment.customer;
@ -103,9 +105,9 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
// Replace string date values with actual date objects.
unavailable.start_datetime = lastFocusedEventData.start.format('YYYY-MM-DD HH:mm:ss');
var startDatetime = Date.parseExact(unavailable.start_datetime, 'yyyy-MM-dd HH:mm:ss');
startDatetime = Date.parseExact(unavailable.start_datetime, 'yyyy-MM-dd HH:mm:ss');
unavailable.end_datetime = lastFocusedEventData.end.format('YYYY-MM-DD HH:mm:ss');
var endDatetime = Date.parseExact(unavailable.end_datetime, 'yyyy-MM-dd HH:mm:ss');
endDatetime = Date.parseExact(unavailable.end_datetime, 'yyyy-MM-dd HH:mm:ss');
$dialog = $('#manage-unavailable');
BackendCalendarUnavailabilitiesModal.resetUnavailableDialog();
@ -135,14 +137,14 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
var url;
var data;
// If id_role parameter exists the popover is an extra working day.
// If id_role parameter exists the popover is an custom availability period.
if (lastFocusedEventData.data.hasOwnProperty('id_roles')) {
// Do not display confirmation prompt.
url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_extra_period';
url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_custom_availability_period';
data = {
csrfToken: GlobalVariables.csrfToken,
extra_period: lastFocusedEventData.start.format('YYYY-MM-DD'),
custom_availability_period: lastFocusedEventData.start.format('YYYY-MM-DD'),
provider_id: lastFocusedEventData.data.id
};
@ -150,9 +152,9 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
.done(function () {
$('#message-box').dialog('close');
var extraWorkingPlan = jQuery.parseJSON(lastFocusedEventData.data.settings.extra_working_plan);
delete extraWorkingPlan[lastFocusedEventData.start.format('YYYY-MM-DD')];
lastFocusedEventData.data.settings.extra_working_plan = JSON.stringify(extraWorkingPlan);
var customAvailabilityPeriods = jQuery.parseJSON(lastFocusedEventData.data.settings.custom_availability_periods);
delete customAvailabilityPeriods[lastFocusedEventData.start.format('YYYY-MM-DD')];
lastFocusedEventData.data.settings.custom_availability_periods = JSON.stringify(customAvailabilityPeriods);
// Refresh calendar event items.
$('#select-filter-item').trigger('change');
@ -295,7 +297,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
* When the user clicks on an appointment object on the calendar, then a data preview popover is display
* above the calendar item.
*/
function calendarEventClick(event, jsEvent, view) {
function calendarEventClick(event, jsEvent) {
$('.popover').popover('dispose'); // Close all open popovers.
var $html;
@ -385,7 +387,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
})
]
});
} else if ($(this).hasClass('fc-extra') || $parent.hasClass('fc-extra') || $altParent.hasClass('fc-extra')) {
} else if ($(this).hasClass('fc-custom-availability-period') || $parent.hasClass('fc-custom-availability-period') || $altParent.hasClass('fc-custom-availability-period')) {
displayDelete = (($parent.hasClass('fc-custom') || $altParent.hasClass('fc-custom'))
&& GlobalVariables.user.privileges.appointments.delete === true)
? 'mr-2' : 'd-none'; // Same value at the time.
@ -618,7 +620,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
*
* @see updateAppointmentData()
*/
function calendarEventResize(event, delta, revertFunc, jsEvent, ui, view) {
function calendarEventResize(event, delta, revertFunc) {
if (GlobalVariables.user.privileges.appointments.edit === false) {
revertFunc();
Backend.displayNotification(EALang.no_privileges_edit_appointments);
@ -626,6 +628,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
}
var $calendar = $('#calendar');
var successCallback;
if ($('#notification').is(':visible')) {
$('#notification').hide('bind');
@ -646,7 +649,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
delete appointment.service;
// Success callback
var successCallback = function (response) {
successCallback = function () {
// Display success notification to user.
var undoFunction = function () {
appointment.end_datetime = event.data.end_datetime = Date.parseExact(
@ -695,7 +698,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
event.data.end_datetime = unavailable.end_datetime;
// Define success callback function.
var successCallback = function (response) {
successCallback = function () {
// Display success notification to user.
var undoFunction = function () {
unavailable.end_datetime = event.data.end_datetime = Date.parseExact(
@ -731,7 +734,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
$calendar.fullCalendar('updateEvent', event);
};
BackendCalendarApi.saveUnavailable(unavailable, successCallback);
BackendCalendarApi.saveUnavailable(unavailable, successCallback, null);
}
}
@ -743,7 +746,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
*
* @see getCalendarHeight()
*/
function calendarWindowResize(view) {
function calendarWindowResize() {
$('#calendar').fullCalendar('option', 'height', getCalendarHeight());
}
@ -752,8 +755,10 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
*
* When the user clicks on a day square on the calendar, then he will automatically be transferred to that
* day view calendar.
*
* @param {Date} date
*/
function calendarDayClick(date, jsEvent, view) {
function calendarDayClick(date) {
if (!date.hasTime()) {
$('#calendar').fullCalendar('changeView', 'agendaDay');
$('#calendar').fullCalendar('gotoDate', date);
@ -765,8 +770,12 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
*
* This event handler is triggered whenever the user drags and drops an event into a different position
* on the calendar. We need to update the database with this change. This is done via an ajax call.
*
* @param {object} event
* @param {object} delta
* @param {function} revertFunc
*/
function calendarEventDrop(event, delta, revertFunc, jsEvent, ui, view) {
function calendarEventDrop(event, delta, revertFunc) {
if (GlobalVariables.user.privileges.appointments.edit === false) {
revertFunc();
Backend.displayNotification(EALang.no_privileges_edit_appointments);
@ -777,6 +786,8 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
$('#notification').hide('bind');
}
var successCallback;
if (event.data.is_unavailable === '0') {
// Prepare appointment data.
var appointment = GeneralFunctions.clone(event.data);
@ -800,7 +811,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
event.data.end_datetime = appointment.end_datetime;
// Define success callback function.
var successCallback = function (response) {
successCallback = function () {
// Define the undo function, if the user needs to reset the last change.
var undoFunction = function () {
appointment.start_datetime = Date.parseExact(
@ -852,7 +863,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
id_users_provider: event.data.id_users_provider
};
var successCallback = function (response) {
successCallback = function () {
var undoFunction = function () {
unavailable.start_datetime = Date.parseExact(
unavailable.start_datetime, 'yyyy-MM-dd HH:mm:ss')
@ -993,31 +1004,20 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
$calendar.fullCalendar('removeEvents');
$calendar.fullCalendar('addEventSource', calendarEvents);
var weekDays = [
'sunday',
'monday',
'tuesday',
'wednesday',
'thursday',
'friday',
'saturday'
];
// :: ADD PROVIDER'S UNAVAILABLE TIME PERIODS
var calendarView = $calendar.fullCalendar('getView').name;
if (filterType === FILTER_TYPE_PROVIDER && calendarView !== 'month') {
GlobalVariables.availableProviders.forEach(function (provider, index) {
GlobalVariables.availableProviders.forEach(function (provider) {
if (Number(provider.id) === Number(recordId)) {
var workingPlan = {};
var workingPlanBulk = jQuery.parseJSON(provider.settings.working_plan);
var extraWorkingPlan = jQuery.parseJSON(provider.settings.extra_working_plan);
var workingPlan = jQuery.parseJSON(provider.settings.working_plan);
var customAvailabilityPeriods = jQuery.parseJSON(provider.settings.custom_availability_periods);
var unavailablePeriod;
// Sort the working plan starting with the first day as set in General settings to correctly
// align breaks in the calendar display.
var firstWeekdayNumber = GeneralFunctions.getWeekDayId(GlobalVariables.firstWeekday);
workingPlan = GeneralFunctions.sortWeekDictionary(workingPlanBulk, firstWeekdayNumber);
var sortedWorkingPlan = GeneralFunctions.sortWeekDictionary(workingPlan, firstWeekdayNumber);
switch (calendarView) {
case 'agendaDay':
@ -1025,7 +1025,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
.getWeekdayName(parseInt($calendar.fullCalendar('getView').start.format('d')));
// Add custom unavailable periods.
response.unavailables.forEach(function (unavailable, index) {
response.unavailables.forEach(function (unavailable) {
var notes = unavailable.notes ? ' - ' + unavailable.notes : '';
if (unavailable.notes.length > 30) {
@ -1047,28 +1047,28 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
});
// Non-working day.
if (workingPlan[selectedDayName] === null) {
// Extra working plan day.
if (sortedWorkingPlan[selectedDayName] === null) {
// Custom availability period.
var selectedDay = $calendar.fullCalendar('getView').intervalStart.clone();
selectedDay.locale('en');
if (extraWorkingPlan && selectedDay.format() in extraWorkingPlan) {
workingPlan[selectedDay.format('dddd').toLowerCase()] = extraWorkingPlan[selectedDay.format('YYYY-MM-DD')];
if (customAvailabilityPeriods && selectedDay.format() in customAvailabilityPeriods) {
sortedWorkingPlan[selectedDay.format('dddd').toLowerCase()] = customAvailabilityPeriods[selectedDay.format('YYYY-MM-DD')];
var start_extra = selectedDay.format('YYYY-MM-DD') + ' ' + extraWorkingPlan[selectedDay.format('YYYY-MM-DD')].start;
var end_extra = selectedDay.format('YYYY-MM-DD') + ' ' + extraWorkingPlan[selectedDay.format('YYYY-MM-DD')].end;
var customAvailabilityPeriodStart = selectedDay.format('YYYY-MM-DD') + ' ' + customAvailabilityPeriods[selectedDay.format('YYYY-MM-DD')].start;
var customAvailabilityPeriodEnd = selectedDay.format('YYYY-MM-DD') + ' ' + customAvailabilityPeriods[selectedDay.format('YYYY-MM-DD')].end;
var extraPeriod = {
title: EALang.extra_period,
start: moment(start_extra, 'YYYY-MM-DD HH:mm', true),
end: moment(end_extra, 'YYYY-MM-DD HH:mm', true).add(1, 'day'),
var customAvailabilityPeriod = {
title: EALang.custom_availability_period,
start: moment(customAvailabilityPeriodStart, 'YYYY-MM-DD HH:mm', true),
end: moment(customAvailabilityPeriodEnd, 'YYYY-MM-DD HH:mm', true).add(1, 'day'),
allDay: true,
color: '#879DB4',
editable: false,
className: 'fc-extra fc-custom',
className: 'fc-custom-availability-period fc-custom',
data: provider
};
$calendar.fullCalendar('renderEvent', extraPeriod, false);
$calendar.fullCalendar('renderEvent', customAvailabilityPeriod, false);
} else {
unavailablePeriod = {
title: EALang.not_working,
@ -1088,7 +1088,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
// Add unavailable period before work starts.
var calendarDateStart = moment($calendar.fullCalendar('getView').start.format('YYYY-MM-DD') + ' 00:00:00');
var startHour = workingPlan[selectedDayName].start.split(':');
var startHour = sortedWorkingPlan[selectedDayName].start.split(':');
var workDateStart = calendarDateStart.clone();
workDateStart.hour(parseInt(startHour[0]));
workDateStart.minute(parseInt(startHour[1]));
@ -1108,7 +1108,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
// Add unavailable period after work ends.
var calendarDateEnd = moment($calendar.fullCalendar('getView').end.format('YYYY-MM-DD') + ' 00:00:00');
var endHour = workingPlan[selectedDayName].end.split(':');
var endHour = sortedWorkingPlan[selectedDayName].end.split(':');
var workDateEnd = calendarDateStart.clone();
workDateEnd.hour(parseInt(endHour[0]));
@ -1132,7 +1132,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
var breakStart;
var breakEnd;
workingPlan[selectedDayName].breaks.forEach(function (currentBreak) {
sortedWorkingPlan[selectedDayName].breaks.forEach(function (currentBreak) {
var breakStartString = currentBreak.start.split(':');
breakStart = calendarDateStart.clone();
breakStart.hour(parseInt(breakStartString[0]));
@ -1185,27 +1185,27 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
$calendar.fullCalendar('renderEvent', unavailablePeriod, false);
});
$.each(workingPlan, function (index, workingDay) {
$.each(sortedWorkingPlan, function (index, workingDay) {
if (workingDay === null) {
// Check if the day is an extra working day added to the working plan
if (extraWorkingPlan && currentDateStart.format('YYYY-MM-DD') in extraWorkingPlan) {
workingDay = extraWorkingPlan[currentDateStart.format('YYYY-MM-DD')]
// Check if the day is an custom availability period added to the working plan
if (customAvailabilityPeriods && currentDateStart.format('YYYY-MM-DD') in customAvailabilityPeriods) {
workingDay = customAvailabilityPeriods[currentDateStart.format('YYYY-MM-DD')]
var extraPeriodStart = currentDateStart.format('YYYY-MM-DD') + ' ' + extraWorkingPlan[currentDateStart.format('YYYY-MM-DD')].start;
var extraPeriodEnd = currentDateStart.format('YYYY-MM-DD') + ' ' + extraWorkingPlan[currentDateStart.format('YYYY-MM-DD')].end;
var customAvailabilityPeriodStart = currentDateStart.format('YYYY-MM-DD') + ' ' + customAvailabilityPeriods[currentDateStart.format('YYYY-MM-DD')].start;
var customAvailabilityPeriodEnd = currentDateStart.format('YYYY-MM-DD') + ' ' + customAvailabilityPeriods[currentDateStart.format('YYYY-MM-DD')].end;
var extraPeriod = {
title: EALang.extra_period,
start: moment(extraPeriodStart, 'YYYY-MM-DD HH:mm', true),
end: moment(extraPeriodEnd, 'YYYY-MM-DD HH:mm', true).add(1, 'day'),
var customAvailabilityPeriod = {
title: EALang.custom_woring_period,
start: moment(customAvailabilityPeriodStart, 'YYYY-MM-DD HH:mm', true),
end: moment(customAvailabilityPeriodEnd, 'YYYY-MM-DD HH:mm', true).add(1, 'day'),
allDay: true,
color: '#879DB4',
editable: false,
className: 'fc-extra fc-custom',
className: 'fc-custom-availability-period fc-custom',
data: provider
};
$calendar.fullCalendar('renderEvent', extraPeriod, false);
$calendar.fullCalendar('renderEvent', customAvailabilityPeriod, false);
} else {
// Add a full day unavailable event.
unavailablePeriod = {
@ -1273,7 +1273,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
var breakStart;
var breakEnd;
workingDay.breaks.forEach(function (currentBreak, index) {
workingDay.breaks.forEach(function (currentBreak) {
var breakStartString = currentBreak.start.split(':');
breakStart = currentDateStart.clone();
breakStart.hour(parseInt(breakStartString[0]));
@ -1375,7 +1375,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
// Selectable
selectable: true,
selectHelper: true,
select: function (start, end, jsEvent, view) {
select: function (start, end) {
if (!start.hasTime() || !end.hasTime()) {
return;
}

View file

@ -71,7 +71,7 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
var endDate = endDateMoment.toDate();
getCalendarEvents(startDate, endDate)
.done(function (response) {
.done(function () {
var currentDate = startDate;
while (currentDate <= endDate) {
@ -89,22 +89,22 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
var $providerColumn = $(providerColumn);
var provider = $providerColumn.data('provider');
// $providerColumn.find('.calendar-wrapper').fullCalendar('removeEvents');
$providerColumn.find('.calendar-wrapper').fullCalendar('removeEvents');
// createNonWorkingHours($providerColumn.find('.calendar-wrapper'), JSON.parse($providerColumn.data('provider').settings.working_plan));
createNonWorkingHours($providerColumn.find('.calendar-wrapper'), JSON.parse($providerColumn.data('provider').settings.working_plan));
// Add the appointments to the column.
// createAppointments($providerColumn, response.appointments);
createAppointments($providerColumn, response.appointments);
// Add the unavailabilities to the column.
// createUnavailabilities($providerColumn, response.unavailabilities);
createUnavailabilities($providerColumn, response.unavailabilities);
// Add the provider breaks to the column.
var workingPlan = JSON.parse(provider.settings.working_plan);
var day = date.toString('dddd').toLowerCase();
if (workingPlan[day]) {
var breaks = workingPlan[day].breaks;
// createBreaks($providerColumn, breaks);
createBreaks($providerColumn, breaks);
}
});
});
@ -213,24 +213,24 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
var url;
var data;
// If id_role parameter exists the popover is an extra working day.
// If id_role parameter exists the popover is an custom availability period.
if (lastFocusedEventData.data.hasOwnProperty('id_roles')) {
// Do not display confirmation prompt.
url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_extra_period';
url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_custom_availability_period';
data = {
csrfToken: GlobalVariables.csrfToken,
extra_period: lastFocusedEventData.start.format('YYYY-MM-DD'),
custom_availability_period: lastFocusedEventData.start.format('YYYY-MM-DD'),
provider_id: lastFocusedEventData.data.id
};
$.post(url, data)
.done(function (response) {
.done(function () {
$('#message-box').dialog('close');
var extraWorkingPlan = jQuery.parseJSON(lastFocusedEventData.data.settings.extra_working_plan);
delete extraWorkingPlan[lastFocusedEventData.start.format('YYYY-MM-DD')];
lastFocusedEventData.data.settings.extra_working_plan = JSON.stringify(extraWorkingPlan);
var customAvailabilityPeriods = jQuery.parseJSON(lastFocusedEventData.data.settings.custom_availability_periods);
delete customAvailabilityPeriods[lastFocusedEventData.start.format('YYYY-MM-DD')];
lastFocusedEventData.data.settings.custom_availability_periods = JSON.stringify(customAvailabilityPeriods);
// Refresh calendar event items.
$('#select-filter-item').trigger('change');
@ -329,7 +329,7 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
$('<input/>', {
'type': 'text',
'class': 'form-control d-inline-block select-date mr-2',
'value': GeneralFunctions.formatDate(new Date(), GlobalVariables.dateFormat)
'value': GeneralFunctions.formatDate(new Date(), GlobalVariables.dateFormat, false)
})
.appendTo($calendarHeader);
@ -359,7 +359,7 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
break;
default:
throw new Error('Invalid date format setting provided!', GlobalVariables.dateFormat);
throw new Error('Invalid date format setting provided: ' + GlobalVariables.dateFormat);
}
$calendarHeader.find('.select-date').datepicker({
@ -677,7 +677,7 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
// Selectable
selectable: true,
selectHelper: true,
select: function (start, end, jsEvent, view) {
select: function (start, end, jsEvent) {
if (!start.hasTime() || !end.hasTime()) {
return;
}
@ -850,7 +850,7 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
var breakStart;
var breakEnd;
workingPlan[selDayName].breaks.forEach(function (currentBreak, index) {
workingPlan[selDayName].breaks.forEach(function (currentBreak) {
breakStart = moment(start.toDate().toString('yyyy-MM-dd') + ' ' + currentBreak.start);
breakEnd = moment(start.toDate().toString('yyyy-MM-dd') + ' ' + currentBreak.end);
@ -1109,19 +1109,15 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
})
]
});
} else if ($(this).hasClass('fc-extra') || $parent.hasClass('fc-extra') || $altParent.hasClass('fc-extra')) {
} else if ($(this).hasClass('fc-custom-availability-period') || $parent.hasClass('fc-custom-availability-period') || $altParent.hasClass('fc-custom-availability-period')) {
displayEdit = (($parent.hasClass('fc-custom') || $altParent.hasClass('fc-custom'))
&& GlobalVariables.user.privileges.appointments.edit === true)
? 'mr-2' : 'd-none'; // Same value at the time.
displayDelete = (($parent.hasClass('fc-custom') || $altParent.hasClass('fc-custom'))
&& GlobalVariables.user.privileges.appointments.delete === true)
? 'mr-2' : 'd-none'; // Same value at the time.
var provider = '';
if (event.data) { // Only custom unavailable periods have notes.
provider = '<strong>' + EALang.provider + '</strong> ' + event.data.first_name + ' ' + event.data.last_name;
}
var extraPeriod = jQuery.parseJSON(event.data.settings.extra_working_plan)[event.start.format()];
$html = $('<div/>', {
'html': [
$('<strong/>', {
@ -1353,7 +1349,7 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
*
* @see updateAppointmentData()
*/
function onEventResize(event, delta, revertFunc, jsEvent, ui, view) {
function onEventResize(event, delta, revertFunc) {
if (GlobalVariables.user.privileges.appointments.edit === false) {
revertFunc();
Backend.displayNotification(EALang.no_privileges_edit_appointments);

View file

@ -86,7 +86,7 @@
$('#providers .save-cancel-group').show();
$('#providers .record-details').find('input, select, textarea').prop('disabled', false);
$('#provider-password, #provider-password-confirm').addClass('required');
$('#providers').find('.add-break, .edit-break, .delete-break, .add-extra-periods, .edit-extra, .delete-extra, #reset-working-plan').prop('disabled', false);
$('#providers').find('.add-break, .edit-break, .delete-break, .add-custom-availability-periods, .edit-custom-availability-period, .delete-custom-availability-period, #reset-working-plan').prop('disabled', false);
$('#provider-services input:checkbox').prop('disabled', false);
// Apply default working plan
@ -105,7 +105,7 @@
$('#providers .record-details').find('input, select, textarea').prop('disabled', false);
$('#provider-password, #provider-password-confirm').removeClass('required');
$('#provider-services input:checkbox').prop('disabled', false);
$('#providers').find('.add-break, .edit-break, .delete-break, .add-extra-periods, .edit-extra, .delete-extra, #reset-working-plan').prop('disabled', false);
$('#providers').find('.add-break, .edit-break, .delete-break, .add-custom-availability-periods, .edit-custom-availability-period, .delete-custom-availability-period, #reset-working-plan').prop('disabled', false);
$('#providers input:checkbox').prop('disabled', false);
BackendUsers.wp.timepickers(false);
});
@ -154,7 +154,7 @@
settings: {
username: $('#provider-username').val(),
working_plan: JSON.stringify(BackendUsers.wp.get()),
extra_working_plan: JSON.stringify(BackendUsers.wp.getExtraWP()),
custom_availability_periods: JSON.stringify(BackendUsers.wp.getCustomavailabilityperiods()),
notifications: $('#provider-notifications').prop('checked'),
calendar_view: $('#provider-calendar-view').val()
}
@ -210,7 +210,7 @@
*/
$('#providers').on('click', '#reset-working-plan', function () {
$('.breaks tbody').empty();
$('.extra-periods tbody').empty();
$('.custom-availability-periods tbody').empty();
$('.work-start, .work-end').val('');
BackendUsers.wp.setup(GlobalVariables.workingPlan);
BackendUsers.wp.timepickers(false);
@ -333,12 +333,12 @@
$('#providers .record-details').find('input, select, textarea')
.val('')
.prop('disabled', true);
$('#providers .add-break, .add-extra-periods, #reset-working-plan').prop('disabled', true);
$('#providers .add-break, .add-custom-availability-periods, #reset-working-plan').prop('disabled', true);
BackendUsers.wp.timepickers(true);
$('#providers .working-plan input:text').timepicker('destroy');
$('#providers .working-plan input:checkbox').prop('disabled', true);
$('.breaks').find('.edit-break, .delete-break').prop('disabled', true);
$('.extra-periods').find('.edit-extra, .delete-extra').prop('disabled', true);
$('.custom-availability-periods').find('.edit-custom-availability-period, .delete-custom-availability-period').prop('disabled', true);
$('#providers .record-details .has-error').removeClass('has-error');
$('#providers .record-details .form-message').hide();
@ -350,7 +350,7 @@
$('#provider-services a').remove();
$('#providers .working-plan tbody').empty();
$('#providers .breaks tbody').empty();
$('#providers .extra-periods tbody').empty();
$('#providers .custom-availability-periods tbody').empty();
};
/**
@ -426,10 +426,10 @@
BackendUsers.wp.setup(workingPlan);
$('.working-plan').find('input').prop('disabled', true);
$('.breaks').find('.edit-break, .delete-break').prop('disabled', true);
$('#providers .extra-periods tbody').empty();
var extraWorkingPlan = $.parseJSON(provider.settings.extra_working_plan);
BackendUsers.wp.setupExtraPeriods(extraWorkingPlan);
$('.extra-periods').find('.edit-extra, .delete-extra').prop('disabled', true);
$('#providers .custom-availability-periods tbody').empty();
var customAvailabilityPeriods = $.parseJSON(provider.settings.custom_availability_periods);
BackendUsers.wp.setupcustomAvailabilityPeriods(customAvailabilityPeriods);
$('.custom-availability-periods').find('.edit-custom-availability-period, .delete-custom-availability-period').prop('disabled', true);
$('#providers .working-plan input:checkbox').prop('disabled', true);
Backend.placeFooterToBottom();
};

View file

@ -188,16 +188,16 @@
};
/**
* Setup the dom elements of a given extra working plan day.
* Setup the dom elements of a given Custom availability period.
*
* @param {Object} extraWorkingPlan Contains the extra working day.
* @param {Object} customAvailabilityPeriods Contains the custom availability period.
*/
WorkingPlan.prototype.setupExtraPeriods = function (extraWorkingPlan) {
$.each(extraWorkingPlan, function (index, extraWorkingDay) {
if (extraWorkingDay) {
WorkingPlan.prototype.setupcustomAvailabilityPeriods = function (customAvailabilityPeriods) {
$.each(customAvailabilityPeriods, function (index, customAvailabilityPeriod) {
if (customAvailabilityPeriod) {
$('#' + index).prop('checked', true);
$('#' + index + '-start').val(Date.parse(extraWorkingDay.start).toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm').toUpperCase());
$('#' + index + '-end').val(Date.parse(extraWorkingDay.end).toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm').toUpperCase());
$('#' + index + '-start').val(Date.parse(customAvailabilityPeriod.start).toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm').toUpperCase());
$('#' + index + '-end').val(Date.parse(customAvailabilityPeriod.end).toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm').toUpperCase());
var day = GeneralFunctions.formatDate(Date.parse(index), GlobalVariables.dateFormat, false);
@ -206,22 +206,22 @@
$('<tr/>', {
'html': [
$('<td/>', {
'class': 'extra-day editable',
'class': 'custom-availability-period editable',
'text': day
}),
$('<td/>', {
'class': 'extra-start editable',
'text': Date.parse(extraWorkingDay.start).toString(timeFormat).toUpperCase()
'class': 'custom-availability-period-start editable',
'text': Date.parse(customAvailabilityPeriod.start).toString(timeFormat).toUpperCase()
}),
$('<td/>', {
'class': 'extra-end editable',
'text': Date.parse(extraWorkingDay.end).toString(timeFormat).toUpperCase()
'class': 'custom-availability-period-end editable',
'text': Date.parse(customAvailabilityPeriod.end).toString(timeFormat).toUpperCase()
}),
$('<td/>', {
'html': [
$('<button/>', {
'type': 'button',
'class': 'btn btn-light btn-sm edit-extra',
'class': 'btn btn-light btn-sm edit-custom-availability-period',
'title': EALang.edit,
'html': [
$('<span/>', {
@ -231,7 +231,7 @@
}),
$('<button/>', {
'type': 'button',
'class': 'btn btn-light btn-sm delete-extra',
'class': 'btn btn-light btn-sm delete-custom-availability-period',
'title': EALang.delete,
'html': [
$('<span/>', {
@ -241,7 +241,7 @@
}),
$('<button/>', {
'type': 'button',
'class': 'btn btn-light btn-sm save-extra d-none',
'class': 'btn btn-light btn-sm save-custom-availability-period d-none',
'title': EALang.save,
'html': [
$('<span/>', {
@ -251,7 +251,7 @@
}),
$('<button/>', {
'type': 'button',
'class': 'btn btn-light btn-sm cancel-extra d-none',
'class': 'btn btn-light btn-sm cancel-custom-availability-period d-none',
'title': EALang.cancel,
'html': [
$('<span/>', {
@ -263,7 +263,7 @@
})
]
})
.appendTo('.extra-periods tbody');
.appendTo('.custom-availability-periods tbody');
} else {
$('#' + index).prop('checked', false);
$('#' + index + '-start').prop('disabled', true);
@ -272,8 +272,8 @@
}.bind(this));
// Make break cells editable.
this.editableBreakTime($('.extra-periods .extra-day'));
this.editableBreakTime($('.extra-periods').find('.extra-start, .extra-end'));
this.editableBreakTime($('.custom-availability-periods .custom-availability-period'));
this.editableBreakTime($('.custom-availability-periods').find('.custom-availability-period-start, .custom-availability-period-end'));
};
/**
@ -554,33 +554,33 @@
}.bind(this));
/**
* Event: Add Extra Period Button "Click"
* Event: Add custom availability period Button "Click"
*
* A new row is added on the table and the user can enter the new extra day
* data. After that he can either press the save or cancel button.
* A new row is added on the table and the user can enter the new custom availability period. After that he can
* either press the save or cancel button.
*/
$('.add-extra-periods').on('click', function () {
$('.add-custom-availability-periods').on('click', function () {
var today = GeneralFunctions.formatDate(new Date(), GlobalVariables.dateFormat, false);
var $newExtraPeriod = $('<tr/>', {
var $newcustomAvailabilityPeriod = $('<tr/>', {
'html': [
$('<td/>', {
'class': 'extra-day editable',
'class': 'custom-availability-period editable',
'text': today
}),
$('<td/>', {
'class': 'extra-start editable',
'class': 'custom-availability-period-start editable',
'text': '9:00 AM'
}),
$('<td/>', {
'class': 'extra-end editable',
'class': 'custom-availability-period-end editable',
'text': '10:00 AM'
}),
$('<td/>', {
'html': [
$('<button/>', {
'type': 'button',
'class': 'btn btn-light btn-sm edit-extra',
'class': 'btn btn-light btn-sm edit-custom-availability-period',
'title': EALang.edit,
'html': [
$('<span/>', {
@ -590,7 +590,7 @@
}),
$('<button/>', {
'type': 'button',
'class': 'btn btn-light btn-sm delete-extra',
'class': 'btn btn-light btn-sm delete-custom-availability-period',
'title': EALang.delete,
'html': [
$('<span/>', {
@ -600,7 +600,7 @@
}),
$('<button/>', {
'type': 'button',
'class': 'btn btn-light btn-sm save-extra d-none',
'class': 'btn btn-light btn-sm save-custom-availability-period d-none',
'title': EALang.save,
'html': [
$('<span/>', {
@ -610,7 +610,7 @@
}),
$('<button/>', {
'type': 'button',
'class': 'btn btn-light btn-sm cancel-extra d-none',
'class': 'btn btn-light btn-sm cancel-custom-availability-period d-none',
'title': EALang.cancel,
'html': [
$('<span/>', {
@ -622,21 +622,21 @@
}),
]
})
.appendTo('.extra-periods tbody');
.appendTo('.custom-availability-periods tbody');
// Bind editable and event handlers.
this.editableBreakTime($newExtraPeriod.find('.extra-day'));
this.editableBreakTime($newExtraPeriod.find('.extra-start, .extra-end'));
$newExtraPeriod.find('.edit-extra').trigger('click');
$('.add-extra-periods').prop('disabled', true);
this.editableBreakTime($newcustomAvailabilityPeriod.find('.custom-availability-period'));
this.editableBreakTime($newcustomAvailabilityPeriod.find('.custom-availability-period-start, .custom-availability-period-end'));
$newcustomAvailabilityPeriod.find('.edit-custom-availability-period').trigger('click');
$('.add-custom-availability-periods').prop('disabled', true);
}.bind(this));
/**
* Event: Edit Extra Period Button "Click"
* Event: Edit custom availability period Button "Click"
*
* Enables the row editing for the "Extra Period" table rows.
* Enables the row editing for the "custom availability period" table rows.
*/
$(document).on('click', '.edit-extra', function () {
$(document).on('click', '.edit-custom-availability-period', function () {
// Reset previous editable table cells.
var $previousEdits = $(this).closest('table').find('.editable');
@ -648,7 +648,7 @@
// Make all cells in current row editable.
$(this).parent().parent().children().trigger('edit');
$(this).parent().parent().find('.extra-start input, .extra-end input').timepicker({
$(this).parent().parent().find('.custom-availability-period-start input, .custom-availability-period-end input').timepicker({
timeFormat: GlobalVariables.timeFormat === 'regular' ? 'h:mm TT' : 'HH:mm',
currentText: EALang.now,
closeText: EALang.close,
@ -672,7 +672,7 @@
break;
}
$(this).parent().parent().find('.extra-day input').datetimepicker({
$(this).parent().parent().find('.custom-availability-period input').datetimepicker({
dateFormat: dateFormat,
// Translation
@ -699,66 +699,66 @@
// Show save - cancel buttons.
var $tr = $(this).closest('tr');
$tr.find('.edit-extra, .delete-extra').addClass('d-none');
$tr.find('.save-extra, .cancel-extra').removeClass('d-none');
$tr.find('.edit-custom-availability-period, .delete-custom-availability-period').addClass('d-none');
$tr.find('.save-custom-availability-period, .cancel-custom-availability-period').removeClass('d-none');
$tr.find('select,input:text').addClass('form-control input-sm')
$('.add-extra-periods').prop('disabled', true);
$('.add-custom-availability-periods').prop('disabled', true);
});
/**
* Event: Delete Extra Period Button "Click"
* Event: Delete custom availability period Button "Click"
*
* Removes the current line from the "Extra Periods" table.
* Removes the current line from the "custom availability periods" table.
*/
$(document).on('click', '.delete-extra', function () {
$(document).on('click', '.delete-custom-availability-period', function () {
$(this).parent().parent().remove();
});
/**
* Event: Cancel Extra Period Button "Click"
* Event: Cancel custom availability period Button "Click"
*
* Bring the ".extra-period" table back to its initial state.
* Bring the ".custom-availability-period" table back to its initial state.
*
* @param {jQuery.Event} e
*/
$(document).on('click', '.cancel-extra', function (event) {
$(document).on('click', '.cancel-custom-availability-period', function (event) {
var element = event.target;
var $modifiedRow = $(element).closest('tr');
this.enableCancel = true;
$modifiedRow.find('.cancel-editable').trigger('click');
this.enableCancel = false;
$(element).closest('table').find('.edit-extra, .delete-extra').removeClass('d-none');
$modifiedRow.find('.save-extra, .cancel-extra').addClass('d-none');
$('.add-extra-periods').prop('disabled', false);
$(element).closest('table').find('.edit-custom-availability-period, .delete-custom-availability-period').removeClass('d-none');
$modifiedRow.find('.save-custom-availability-period, .cancel-custom-availability-period').addClass('d-none');
$('.add-custom-availability-periods').prop('disabled', false);
}.bind(this));
/**
* Event: Save Extra Period Button "Click"
* Event: Save custom availability period Button "Click"
*
* Save the editable values and restore the table to its initial state.
*
* @param {jQuery.Event} e
*/
$(document).on('click', '.save-extra', function (event) {
$(document).on('click', '.save-custom-availability-period', function (event) {
// Break's start time must always be prior to break's end.
var element = event.target;
var $modifiedRow = $(element).closest('tr');
var start = Date.parse($modifiedRow.find('.extra-start input').val());
var end = Date.parse($modifiedRow.find('.extra-end input').val());
var start = Date.parse($modifiedRow.find('.custom-availability-period-start input').val());
var end = Date.parse($modifiedRow.find('.custom-availability-period-end input').val());
if (start > end) {
$modifiedRow.find('.extra-end input').val(start.addHours(1).toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm').toUpperCase());
$modifiedRow.find('.custom-availability-period-end input').val(start.addHours(1).toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm').toUpperCase());
}
this.enableSubmit = true;
$modifiedRow.find('.editable .submit-editable').trigger('click');
this.enableSubmit = false;
$modifiedRow.find('.save-extra, .cancel-extra').addClass('d-none');
$(element).closest('table').find('.edit-extra, .delete-extra').removeClass('d-none');
$('.add-extra-periods').prop('disabled', false);
$modifiedRow.find('.save-custom-availability-period, .cancel-custom-availability-period').addClass('d-none');
$(element).closest('table').find('.edit-custom-availability-period, .delete-custom-availability-period').removeClass('d-none');
$('.add-custom-availability-periods').prop('disabled', false);
}.bind(this));
};
@ -806,27 +806,27 @@
};
/**
* Get the extra working plan settings.
* Get the custom availability periods settings.
*
* @return {Object} Returns the extra working plan settings object.
* @return {Object} Returns the custom availability periods settings object.
*/
WorkingPlan.prototype.getExtraWP = function () {
var extraWorkingPlan = {};
$('.extra-periods tbody tr').each(function (index, tr) {
WorkingPlan.prototype.getCustomavailabilityperiods = function () {
var customAvailabilityPeriods = {};
$('.custom-availability-periods tbody tr').each(function (index, tr) {
var day = GeneralFunctions.ISO8601DateString($(tr).find('.extra-day').text(), GlobalVariables.dateFormat);
var day = GeneralFunctions.ISO8601DateString($(tr).find('.custom-availability-period').text(), GlobalVariables.dateFormat);
var start = $(tr).find('.extra-start').text();
var end = $(tr).find('.extra-end').text();
var start = $(tr).find('.custom-availability-period-start').text();
var end = $(tr).find('.custom-availability-period-end').text();
extraWorkingPlan[day] = {
customAvailabilityPeriods[day] = {
start: Date.parse(start).toString('HH:mm'),
end: Date.parse(end).toString('HH:mm'),
breaks: []
};
}.bind(this));
return extraWorkingPlan;
return customAvailabilityPeriods;
};
/**