Completed the working plan exceptions feature.

This commit is contained in:
Alex Tselegidis 2020-10-20 16:03:48 +03:00
parent f917529dc2
commit 0e6fdebe0f
51 changed files with 1691 additions and 1315 deletions

View File

@ -156,7 +156,7 @@ class Appointments extends CI_Controller {
{
$hours = floor($book_advance_timeout / 60);
$minutes = ($book_advance_timeout % 60);
$view = [
'message_title' => $this->lang->line('appointment_locked'),
'message_text' => strtr($this->lang->line('appointment_locked_message'), [
@ -577,8 +577,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 custom availability periods.
$custom_availability_periods = json_decode($this->providers_model->get_setting('custom_availability_periods', $provider_id), TRUE);
// Get the provider's working plan exceptions.
$working_plan_exceptions = json_decode($this->providers_model->get_setting('working_plan_exceptions', $provider_id), TRUE);
$provider_appointments = $this->appointments_model->get_batch([
'id_users_provider' => $provider_id,
@ -602,12 +602,9 @@ class Appointments extends CI_Controller {
$selected_date_working_plan = $working_plan[strtolower(date('l', strtotime($selected_date)))];
// Search if the $selected_date is an custom availability period added outside the normal working plan.
if ($selected_date_working_plan == NULL)
if (isset($working_plan_exceptions[$selected_date]))
{
if (isset($custom_availability_periods[strtolower(date('Y-m-d', strtotime($selected_date)))]))
{
$selected_date_working_plan = $custom_availability_periods[strtolower(date('Y-m-d', strtotime($selected_date)))];
}
$selected_date_working_plan = $working_plan_exceptions[$selected_date];
}
$periods = [];

View File

@ -97,6 +97,7 @@ class Backend extends CI_Controller {
$user = $this->user_model->get_user($user_id);
$view['base_url'] = $this->config->item('base_url');
$view['page_title'] = lang('calendar');
$view['user_display_name'] = $this->user_model->get_user_display_name($this->session->userdata('user_id'));
$view['active_menu'] = PRIV_APPOINTMENTS;
$view['date_format'] = $this->settings_model->get_setting('date_format');
@ -228,6 +229,7 @@ class Backend extends CI_Controller {
$this->load->library('timezones');
$view['base_url'] = $this->config->item('base_url');
$view['page_title'] = lang('customers');
$view['user_display_name'] = $this->user_model->get_user_display_name($this->session->userdata('user_id'));
$view['active_menu'] = PRIV_CUSTOMERS;
$view['company_name'] = $this->settings_model->get_setting('company_name');
@ -281,6 +283,7 @@ class Backend extends CI_Controller {
$this->load->library('timezones');
$view['base_url'] = $this->config->item('base_url');
$view['page_title'] = lang('services');
$view['user_display_name'] = $this->user_model->get_user_display_name($this->session->userdata('user_id'));
$view['active_menu'] = PRIV_SERVICES;
$view['company_name'] = $this->settings_model->get_setting('company_name');
@ -321,6 +324,7 @@ class Backend extends CI_Controller {
$this->load->library('timezones');
$view['base_url'] = $this->config->item('base_url');
$view['page_title'] = lang('users');
$view['user_display_name'] = $this->user_model->get_user_display_name($this->session->userdata('user_id'));
$view['active_menu'] = PRIV_USERS;
$view['company_name'] = $this->settings_model->get_setting('company_name');
@ -333,7 +337,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['custom_availability_periods'] = '{}';
$view['working_plan_exceptions'] = '{}';
$this->set_user_data($view);
$this->load->view('backend/header', $view);
@ -365,6 +369,7 @@ class Backend extends CI_Controller {
$user_id = $this->session->userdata('user_id');
$view['base_url'] = $this->config->item('base_url');
$view['page_title'] = lang('settings');
$view['user_display_name'] = $this->user_model->get_user_display_name($user_id);
$view['active_menu'] = PRIV_SYSTEM_SETTINGS;
$view['company_name'] = $this->settings_model->get_setting('company_name');

View File

@ -930,26 +930,27 @@ class Backend_api extends CI_Controller {
}
/**
* Insert of update custom availability periods to database.
* Insert of update working plan exceptions to database.
*/
public function ajax_save_custom_availability_period()
public function ajax_save_working_plan_exception()
{
try
{
// Check privileges
$custom_availability_period = json_decode($this->input->post('custom_availability_period'), TRUE);
$required_privileges = $this->privileges[PRIV_USERS]['edit'];
$required_privileges = ( ! isset($custom_availability_period['id']))
? $this->privileges[PRIV_APPOINTMENTS]['add']
: $this->privileges[PRIV_APPOINTMENTS]['edit'];
if ($required_privileges == FALSE)
{
throw new Exception('You do not have the required privileges for this task.');
}
$date = $this->input->post('date');
$working_plan_exception = $this->input->post('working_plan_exception');
$provider_id = $this->input->post('provider_id');
$this->load->model('providers_model');
$success = $this->providers_model->set_custom_availability_period($custom_availability_period, $custom_availability_period['id_users_provider']);
$success = $this->providers_model->save_working_plan_exception($date, $working_plan_exception, $provider_id);
if ($success)
{
@ -957,7 +958,7 @@ class Backend_api extends CI_Controller {
}
else
{
$response = ['warnings' => 'Error on saving custom availability period.'];
$response = ['warnings' => 'Error on saving working plan exception.'];
}
}
catch (Exception $exception)
@ -976,25 +977,26 @@ class Backend_api extends CI_Controller {
}
/**
* Delete an custom availability periods time period to database.
* Delete an working plan exceptions time period to database.
*/
public function ajax_delete_custom_availability_period()
public function ajax_delete_working_plan_exception()
{
try
{
if ($this->privileges[PRIV_APPOINTMENTS]['delete'] == FALSE)
// Check privileges
$required_privileges = $this->privileges[PRIV_USERS]['edit'];
if ($required_privileges == FALSE)
{
throw new Exception('You do not have the required privileges for this task.');
}
// Check privileges
$custom_availability_period = $this->input->post('custom_availability_period');
$date = $this->input->post('date');
$provider_id = $this->input->post('provider_id');
$this->load->model('providers_model');
// Delete unavailable
$success = $this->providers_model->delete_custom_availability_period($custom_availability_period, $provider_id);
$success = $this->providers_model->delete_working_plan_exception($date, $provider_id);
if ($success)
{
@ -1002,7 +1004,7 @@ class Backend_api extends CI_Controller {
}
else
{
$response = ['warnings' => 'Error on deleting custom availability period.'];
$response = ['warnings' => 'Error on deleting working plan exception.'];
}
}
catch (Exception $exception)

View File

@ -151,6 +151,9 @@ class Availabilities extends API_V1_Controller {
// Get the provider's working plan and reserved appointments.
$working_plan = json_decode($this->providers_model->get_setting('working_plan', $provider_id), TRUE);
// Get the provider's working plan exceptions.
$working_plan_exceptions = json_decode($this->providers_model->get_setting('working_plan_exceptions', $provider_id), TRUE);
$where_clause = [
'id_users_provider' => $provider_id
];
@ -170,10 +173,15 @@ class Availabilities extends API_V1_Controller {
}
}
// Find the empty spaces on the plan. The first split between the plan is due to
// a break (if exist). After that every reserved appointment is considered to be
// a taken space in the plan.
// Find the empty spaces on the plan. The first split between the plan is due to a break (if exist). After that
// 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)))];
if (isset($working_plan_exceptions[$selected_date]))
{
$selected_date_working_plan = $working_plan_exceptions[$selected_date];
}
$available_periods_with_breaks = [];
if (isset($selected_date_working_plan['breaks']))
@ -219,8 +227,8 @@ class Availabilities extends API_V1_Controller {
$open_start = $s;
$open_end = $break_start;
$available_periods_with_breaks[] = [
'start' => $open_start->format("H:i"),
'end' => $open_end->format("H:i")
'start' => $open_start->format('H:i'),
'end' => $open_end->format('H:i')
];
$changed = TRUE;
}
@ -230,8 +238,8 @@ class Availabilities extends API_V1_Controller {
$open_start = $break_end;
$open_end = $e;
$available_periods_with_breaks[] = [
'start' => $open_start->format("H:i"),
'end' => $open_end->format("H:i")
'start' => $open_start->format('H:i'),
'end' => $open_end->format('H:i')
];
$changed = TRUE;
}

View File

@ -298,13 +298,14 @@ $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['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a custom availability period day, outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New Custom Availability Period';
$lang['custom_availability_period_saved'] = 'Custom availability period saved successfully.';
$lang['add_custom_availability_periods_during_each_day'] = 'Add custom availability periods, outside the working plan.';
$lang['add_custom_availability_period'] = 'Add Custom Availability Period';
$lang['working_plan_exception'] = 'Working Plan Exception';
$lang['working_plan_exceptions'] = 'Working Plan Exceptions';
$lang['working_plan_exceptions_hint'] = 'Add a working plan exception day, outside the working plan.';
$lang['new_working_plan_exception_title'] = 'New Working Plan Exception';
$lang['working_plan_exception_saved'] = 'Working plan exception saved successfully.';
$lang['working_plan_exception_deleted'] = 'Working plan exception deleted successfully.';
$lang['add_working_plan_exceptions_during_each_day'] = 'Add working plan exceptions, outside the working plan.';
$lang['add_working_plan_exception'] = 'Add Working Plan Exception';
$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,14 @@ $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['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a custom availability period day, outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New Custom Availability Period';
$lang['custom_availability_period_saved'] = 'Custom availability period saved successfully.';
$lang['add_custom_availability_periods_during_each_day'] = 'Add custom availability periods, outside the working plan.';
$lang['add_custom_availability_period'] = 'Add Custom Availability Period';
$lang['working_plan_exception'] = 'Working Plan Exception';
$lang['working_plan_exceptions'] = 'Working Plan Exceptions';
$lang['working_plan_exceptions_hint'] = 'Add a working plan exception day, outside the working plan.';
$lang['new_working_plan_exception_title'] = 'New Working Plan Exception';
$lang['working_plan_exception_saved'] = 'Working plan exception saved successfully.';
$lang['working_plan_exception_deleted'] = 'Working plan exception deleted successfully.';
$lang['add_working_plan_exceptions_during_each_day'] = 'Add working plan exceptions, outside the working plan.';
$lang['add_working_plan_exception'] = 'Add Working Plan Exception';
$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,14 @@ $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['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a custom availability period day, outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New Custom Availability Period';
$lang['custom_availability_period_saved'] = 'Custom availability period saved successfully.';
$lang['add_custom_availability_periods_during_each_day'] = 'Add custom availability periods, outside the working plan.';
$lang['add_custom_availability_period'] = 'Add Custom Availability Period';
$lang['working_plan_exception'] = 'Working Plan Exception';
$lang['working_plan_exceptions'] = 'Working Plan Exceptions';
$lang['working_plan_exceptions_hint'] = 'Add a working plan exception day, outside the working plan.';
$lang['new_working_plan_exception_title'] = 'New Working Plan Exception';
$lang['working_plan_exception_saved'] = 'Working plan exception saved successfully.';
$lang['working_plan_exception_deleted'] = 'Working plan exception deleted successfully.';
$lang['add_working_plan_exceptions_during_each_day'] = 'Add working plan exceptions, outside the working plan.';
$lang['add_working_plan_exception'] = 'Add Working Plan Exception';
$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,14 @@ $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['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a custom availability period day, outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New Custom Availability Period';
$lang['custom_availability_period_saved'] = 'Custom availability period saved successfully.';
$lang['add_custom_availability_periods_during_each_day'] = 'Add custom availability periods, outside the working plan.';
$lang['add_custom_availability_period'] = 'Add Custom Availability Period';
$lang['working_plan_exception'] = 'Working Plan Exception';
$lang['working_plan_exceptions'] = 'Working Plan Exceptions';
$lang['working_plan_exceptions_hint'] = 'Add a working plan exception day, outside the working plan.';
$lang['new_working_plan_exception_title'] = 'New Working Plan Exception';
$lang['working_plan_exception_saved'] = 'Working plan exception saved successfully.';
$lang['working_plan_exception_deleted'] = 'Working plan exception deleted successfully.';
$lang['add_working_plan_exceptions_during_each_day'] = 'Add working plan exceptions, outside the working plan.';
$lang['add_working_plan_exception'] = 'Add Working Plan Exception';
$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,14 @@ $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['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a custom availability period day, outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New Custom Availability Period';
$lang['custom_availability_period_saved'] = 'Custom availability period saved successfully.';
$lang['add_custom_availability_periods_during_each_day'] = 'Add custom availability periods, outside the working plan.';
$lang['add_custom_availability_period'] = 'Add Custom Availability Period';
$lang['working_plan_exception'] = 'Working Plan Exception';
$lang['working_plan_exceptions'] = 'Working Plan Exceptions';
$lang['working_plan_exceptions_hint'] = 'Add a working plan exception day, outside the working plan.';
$lang['new_working_plan_exception_title'] = 'New Working Plan Exception';
$lang['working_plan_exception_saved'] = 'Working plan exception saved successfully.';
$lang['working_plan_exception_deleted'] = 'Working plan exception deleted successfully.';
$lang['add_working_plan_exceptions_during_each_day'] = 'Add working plan exceptions, outside the working plan.';
$lang['add_working_plan_exception'] = 'Add Working Plan Exception';
$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,14 @@ $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['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a custom availability period day, outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New Custom Availability Period';
$lang['custom_availability_period_saved'] = 'Custom availability period saved successfully.';
$lang['add_custom_availability_periods_during_each_day'] = 'Add custom availability periods, outside the working plan.';
$lang['add_custom_availability_period'] = 'Add Custom Availability Period';
$lang['working_plan_exception'] = 'Working Plan Exception';
$lang['working_plan_exceptions'] = 'Working Plan Exceptions';
$lang['working_plan_exceptions_hint'] = 'Add a working plan exception day, outside the working plan.';
$lang['new_working_plan_exception_title'] = 'New Working Plan Exception';
$lang['working_plan_exception_saved'] = 'Working plan exception saved successfully.';
$lang['working_plan_exception_deleted'] = 'Working plan exception deleted successfully.';
$lang['add_working_plan_exceptions_during_each_day'] = 'Add working plan exceptions, outside the working plan.';
$lang['add_working_plan_exception'] = 'Add Working Plan Exception';
$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,14 @@ $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['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a custom availability period day, outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New Custom Availability Period';
$lang['custom_availability_period_saved'] = 'Custom availability period saved successfully.';
$lang['add_custom_availability_periods_during_each_day'] = 'Add custom availability periods, outside the working plan.';
$lang['add_custom_availability_period'] = 'Add Custom Availability Period';
$lang['working_plan_exception'] = 'Working Plan Exception';
$lang['working_plan_exceptions'] = 'Working Plan Exceptions';
$lang['working_plan_exceptions_hint'] = 'Add a working plan exception day, outside the working plan.';
$lang['new_working_plan_exception_title'] = 'New Working Plan Exception';
$lang['working_plan_exception_saved'] = 'Working plan exception saved successfully.';
$lang['working_plan_exception_deleted'] = 'Working plan exception deleted successfully.';
$lang['add_working_plan_exceptions_during_each_day'] = 'Add working plan exceptions, outside the working plan.';
$lang['add_working_plan_exception'] = 'Add Working Plan Exception';
$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

@ -304,13 +304,14 @@ $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['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a custom availability period day, outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New Custom Availability Period';
$lang['custom_availability_period_saved'] = 'Custom availability period saved successfully.';
$lang['add_custom_availability_periods_during_each_day'] = 'Add custom availability periods, outside the working plan.';
$lang['add_custom_availability_period'] = 'Add Custom Availability Period';
$lang['working_plan_exception'] = 'Working Plan Exception';
$lang['working_plan_exceptions'] = 'Working Plan Exceptions';
$lang['working_plan_exceptions_hint'] = 'Add a working plan exception day, outside the working plan.';
$lang['new_working_plan_exception_title'] = 'New Working Plan Exception';
$lang['working_plan_exception_saved'] = 'Working plan exception saved successfully.';
$lang['working_plan_exception_deleted'] = 'Working plan exception deleted successfully.';
$lang['add_working_plan_exceptions_during_each_day'] = 'Add working plan exceptions, outside the working plan.';
$lang['add_working_plan_exception'] = 'Add Working Plan Exception';
$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,14 @@ $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['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a custom availability period day, outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New Custom Availability Period';
$lang['custom_availability_period_saved'] = 'Custom availability period saved successfully.';
$lang['add_custom_availability_periods_during_each_day'] = 'Add custom availability periods, outside the working plan.';
$lang['add_custom_availability_period'] = 'Add Custom Availability Period';
$lang['working_plan_exception'] = 'Working Plan Exception';
$lang['working_plan_exceptions'] = 'Working Plan Exceptions';
$lang['working_plan_exceptions_hint'] = 'Add a working plan exception day, outside the working plan.';
$lang['new_working_plan_exception_title'] = 'New Working Plan Exception';
$lang['working_plan_exception_saved'] = 'Working plan exception saved successfully.';
$lang['working_plan_exception_deleted'] = 'Working plan exception deleted successfully.';
$lang['add_working_plan_exceptions_during_each_day'] = 'Add working plan exceptions, outside the working plan.';
$lang['add_working_plan_exception'] = 'Add Working Plan Exception';
$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

@ -302,13 +302,14 @@ $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['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a custom availability period day, outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New Custom Availability Period';
$lang['custom_availability_period_saved'] = 'Custom availability period saved successfully.';
$lang['add_custom_availability_periods_during_each_day'] = 'Add custom availability periods, outside the working plan.';
$lang['add_custom_availability_period'] = 'Add Custom Availability Period';
$lang['working_plan_exception'] = 'Working Plan Exception';
$lang['working_plan_exceptions'] = 'Working Plan Exceptions';
$lang['working_plan_exceptions_hint'] = 'Add a working plan exception day, outside the working plan.';
$lang['new_working_plan_exception_title'] = 'New Working Plan Exception';
$lang['working_plan_exception_saved'] = 'Working plan exception saved successfully.';
$lang['working_plan_exception_deleted'] = 'Working plan exception deleted successfully.';
$lang['add_working_plan_exceptions_during_each_day'] = 'Add working plan exceptions, outside the working plan.';
$lang['add_working_plan_exception'] = 'Add Working Plan Exception';
$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

@ -301,13 +301,14 @@ $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['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a custom availability period day, outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New Custom Availability Period';
$lang['custom_availability_period_saved'] = 'Custom availability period saved successfully.';
$lang['add_custom_availability_periods_during_each_day'] = 'Add custom availability periods, outside the working plan.';
$lang['add_custom_availability_period'] = 'Add Custom Availability Period';
$lang['working_plan_exception'] = 'Working Plan Exception';
$lang['working_plan_exceptions'] = 'Working Plan Exceptions';
$lang['working_plan_exceptions_hint'] = 'Add a working plan exception day, outside the working plan.';
$lang['new_working_plan_exception_title'] = 'New Working Plan Exception';
$lang['working_plan_exception_saved'] = 'Working plan exception saved successfully.';
$lang['working_plan_exception_deleted'] = 'Working plan exception deleted successfully.';
$lang['add_working_plan_exceptions_during_each_day'] = 'Add working plan exceptions, outside the working plan.';
$lang['add_working_plan_exception'] = 'Add Working Plan Exception';
$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,14 @@ $lang['delete_personal_information_hint'] = 'Κατάργηση όλων των
$lang['delete_personal_information'] = 'Διαγραφή Προσωπικών Πληροφοριών';
$lang['delete_personal_information_prompt'] = 'Είστε σίγουρος ότι θέλετε να διαγράψετε τις προσωπικές σας πληροφορίες; Αυτή η ενέργεια δεν μπορεί να αναιρεθεί.';
$lang['location'] = 'Τοποθεσία';
$lang['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a custom availability period day, outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New Custom Availability Period';
$lang['custom_availability_period_saved'] = 'Custom availability period saved successfully.';
$lang['add_custom_availability_periods_during_each_day'] = 'Add custom availability periods, outside the working plan.';
$lang['add_custom_availability_period'] = 'Add Custom Availability Period';
$lang['working_plan_exception'] = 'Working Plan Exception';
$lang['working_plan_exceptions'] = 'Working Plan Exceptions';
$lang['working_plan_exceptions_hint'] = 'Add a working plan exception day, outside the working plan.';
$lang['new_working_plan_exception_title'] = 'New Working Plan Exception';
$lang['working_plan_exception_saved'] = 'Working plan exception saved successfully.';
$lang['working_plan_exception_deleted'] = 'Working plan exception deleted successfully.';
$lang['add_working_plan_exceptions_during_each_day'] = 'Add working plan exceptions, outside the working plan.';
$lang['add_working_plan_exception'] = 'Add Working Plan Exception';
$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,14 @@ $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['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a custom availability period day, outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New Custom Availability Period';
$lang['custom_availability_period_saved'] = 'Custom availability period saved successfully.';
$lang['add_custom_availability_periods_during_each_day'] = 'Add custom availability periods, outside the working plan.';
$lang['add_custom_availability_period'] = 'Add Custom Availability Period';
$lang['working_plan_exception'] = 'Working Plan Exception';
$lang['working_plan_exceptions'] = 'Working Plan Exceptions';
$lang['working_plan_exceptions_hint'] = 'Add a working plan exception day, outside the working plan.';
$lang['new_working_plan_exception_title'] = 'New Working Plan Exception';
$lang['working_plan_exception_saved'] = 'Working plan exception saved successfully.';
$lang['working_plan_exception_deleted'] = 'Working plan exception deleted successfully.';
$lang['add_working_plan_exceptions_during_each_day'] = 'Add working plan exceptions, outside the working plan.';
$lang['add_working_plan_exception'] = 'Add Working Plan Exception';
$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,14 @@ $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['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a custom availability period day, outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New Custom Availability Period';
$lang['custom_availability_period_saved'] = 'Custom availability period saved successfully.';
$lang['add_custom_availability_periods_during_each_day'] = 'Add custom availability periods, outside the working plan.';
$lang['add_custom_availability_period'] = 'Add Custom Availability Period';
$lang['working_plan_exception'] = 'Working Plan Exception';
$lang['working_plan_exceptions'] = 'Working Plan Exceptions';
$lang['working_plan_exceptions_hint'] = 'Add a working plan exception day, outside the working plan.';
$lang['new_working_plan_exception_title'] = 'New Working Plan Exception';
$lang['working_plan_exception_saved'] = 'Working plan exception saved successfully.';
$lang['working_plan_exception_deleted'] = 'Working plan exception deleted successfully.';
$lang['add_working_plan_exceptions_during_each_day'] = 'Add working plan exceptions, outside the working plan.';
$lang['add_working_plan_exception'] = 'Add Working Plan Exception';
$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,25 +298,25 @@ $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['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'] = 'Richiedi il numero di telefono';
$lang['require_phone_number_hint'] = 'Quando è abilitato, i clienti e gli utenti dovranno inserire il numero di telefono del cliente al momento della prenotazione di un appuntamento';
$lang['check_spam_folder'] = 'Se l\'e-mail non arriva entro pochi minuti per favore controlla la cartella spam.';
$lang['api_token_hint'] = 'Impostare un token segreto per abilitare l\'autenticazione basata su token dell\'API Easy!Appointments.';
$lang['timezone'] = 'Fuso orario';
$lang['overwrite_existing_working_plans'] = 'Questo sovrascriverà i piani di lavoro del fornitore esistente, siete sicuri di voler continuare?';
$lang['working_plans_got_updated'] = 'Tutti i piani di lavoro sono stati aggiornati.';
$lang['apply_to_all_providers'] = 'Applicare a tutti i fornitori';
$lang['display_any_provider'] = 'Visualizzare qualsiasi opzione del fornitore';
$lang['display_any_provider_hint'] = 'La pagina di prenotazione otterrà un\'opzione aggiuntiva che permette ai clienti di prenotare senza specificare un fornitore.';
$lang['load_more'] = 'Carica di più';
$lang['list'] = 'Elenco';
$lang['working_plan_exception'] = 'Giorno extra';
$lang['working_plan_exceptions'] = 'Giorni Extra';
$lang['working_plan_exceptions_hint'] = 'Aggiungi una giornata lavorativa al di fuori del piano di lavoro.';
$lang['new_working_plan_exception_title'] = 'Nuova giornata lavorativa';
$lang['working_plan_exception_saved'] = 'Giornata lavorativa salvata con successo.';
$lang['add_working_plan_exceptions_during_each_day'] = 'Aggiungi giornate lavorative al di fuori del piano di lavoro.';
$lang['add_working_plan_exception'] = '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.';
$lang['api_token_hint'] = 'Set a secret token in order to enable the token based authentication of the Easy!Appointments API.';
$lang['timezone'] = 'Timezone';
$lang['overwrite_existing_working_plans'] = 'This will overwrite the existing provider working plans, are you sure that you want to continue?';
$lang['working_plans_got_updated'] = 'All the working plans got updated.';
$lang['apply_to_all_providers'] = 'Apply To All Providers';
$lang['display_any_provider'] = 'Display Any Provider Option';
$lang['display_any_provider_hint'] = 'The booking page will get an additional option that allows customers to book without specifying a provider.';
$lang['load_more'] = 'Load More';
$lang['list'] = 'List';
$lang['default'] = 'Default';
$lang['table'] = 'Tabella';
$lang['date'] = 'Date';

View File

@ -298,13 +298,14 @@ $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['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a custom availability period day, outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New Custom Availability Period';
$lang['custom_availability_period_saved'] = 'Custom availability period saved successfully.';
$lang['add_custom_availability_periods_during_each_day'] = 'Add custom availability periods, outside the working plan.';
$lang['add_custom_availability_period'] = 'Add Custom Availability Period';
$lang['working_plan_exception'] = 'Working Plan Exception';
$lang['working_plan_exceptions'] = 'Working Plan Exceptions';
$lang['working_plan_exceptions_hint'] = 'Add a working plan exception day, outside the working plan.';
$lang['new_working_plan_exception_title'] = 'New Working Plan Exception';
$lang['working_plan_exception_saved'] = 'Working plan exception saved successfully.';
$lang['working_plan_exception_deleted'] = 'Working plan exception deleted successfully.';
$lang['add_working_plan_exceptions_during_each_day'] = 'Add working plan exceptions, outside the working plan.';
$lang['add_working_plan_exception'] = 'Add Working Plan Exception';
$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,14 @@ $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['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a custom availability period day, outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New Custom Availability Period';
$lang['custom_availability_period_saved'] = 'Custom availability period saved successfully.';
$lang['add_custom_availability_periods_during_each_day'] = 'Add custom availability periods, outside the working plan.';
$lang['add_custom_availability_period'] = 'Add Custom Availability Period';
$lang['working_plan_exception'] = 'Working Plan Exception';
$lang['working_plan_exceptions'] = 'Working Plan Exceptions';
$lang['working_plan_exceptions_hint'] = 'Add a working plan exception day, outside the working plan.';
$lang['new_working_plan_exception_title'] = 'New Working Plan Exception';
$lang['working_plan_exception_saved'] = 'Working plan exception saved successfully.';
$lang['working_plan_exception_deleted'] = 'Working plan exception deleted successfully.';
$lang['add_working_plan_exceptions_during_each_day'] = 'Add working plan exceptions, outside the working plan.';
$lang['add_working_plan_exception'] = 'Add Working Plan Exception';
$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,14 @@ $lang['delete_personal_information_hint'] = 'सिस्टमवरून स
$lang['delete_personal_information'] = 'वैयक्तिक माहिती हटवा';
$lang['delete_personal_information_prompt'] = 'आपली खात्री आहे की आपण आपली वैयक्तिक माहिती हटवू इच्छिता? ही क्रिया पूर्ववत करणे शक्य नाही.';
$lang['location'] = 'Location';
$lang['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a custom availability period day, outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New Custom Availability Period';
$lang['custom_availability_period_saved'] = 'Custom availability period saved successfully.';
$lang['add_custom_availability_periods_during_each_day'] = 'Add custom availability periods, outside the working plan.';
$lang['add_custom_availability_period'] = 'Add Custom Availability Period';
$lang['working_plan_exception'] = 'Working Plan Exception';
$lang['working_plan_exceptions'] = 'Working Plan Exceptions';
$lang['working_plan_exceptions_hint'] = 'Add a working plan exception day, outside the working plan.';
$lang['new_working_plan_exception_title'] = 'New Working Plan Exception';
$lang['working_plan_exception_saved'] = 'Working plan exception saved successfully.';
$lang['working_plan_exception_deleted'] = 'Working plan exception deleted successfully.';
$lang['add_working_plan_exceptions_during_each_day'] = 'Add working plan exceptions, outside the working plan.';
$lang['add_working_plan_exception'] = 'Add Working Plan Exception';
$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,14 @@ $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['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a custom availability period day, outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New Custom Availability Period';
$lang['custom_availability_period_saved'] = 'Custom availability period saved successfully.';
$lang['add_custom_availability_periods_during_each_day'] = 'Add custom availability periods, outside the working plan.';
$lang['add_custom_availability_period'] = 'Add Custom Availability Period';
$lang['working_plan_exception'] = 'Working Plan Exception';
$lang['working_plan_exceptions'] = 'Working Plan Exceptions';
$lang['working_plan_exceptions_hint'] = 'Add a working plan exception day, outside the working plan.';
$lang['new_working_plan_exception_title'] = 'New Working Plan Exception';
$lang['working_plan_exception_saved'] = 'Working plan exception saved successfully.';
$lang['working_plan_exception_deleted'] = 'Working plan exception deleted successfully.';
$lang['add_working_plan_exceptions_during_each_day'] = 'Add working plan exceptions, outside the working plan.';
$lang['add_working_plan_exception'] = 'Add Working Plan Exception';
$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,14 @@ $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['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a custom availability period day, outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New Custom Availability Period';
$lang['custom_availability_period_saved'] = 'Custom availability period saved successfully.';
$lang['add_custom_availability_periods_during_each_day'] = 'Add custom availability periods, outside the working plan.';
$lang['add_custom_availability_period'] = 'Add Custom Availability Period';
$lang['working_plan_exception'] = 'Working Plan Exception';
$lang['working_plan_exceptions'] = 'Working Plan Exceptions';
$lang['working_plan_exceptions_hint'] = 'Add a working plan exception day, outside the working plan.';
$lang['new_working_plan_exception_title'] = 'New Working Plan Exception';
$lang['working_plan_exception_saved'] = 'Working plan exception saved successfully.';
$lang['working_plan_exception_deleted'] = 'Working plan exception deleted successfully.';
$lang['add_working_plan_exceptions_during_each_day'] = 'Add working plan exceptions, outside the working plan.';
$lang['add_working_plan_exception'] = 'Add Working Plan Exception';
$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,14 @@ $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['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a custom availability period day, outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New Custom Availability Period';
$lang['custom_availability_period_saved'] = 'Custom availability period saved successfully.';
$lang['add_custom_availability_periods_during_each_day'] = 'Add custom availability periods, outside the working plan.';
$lang['add_custom_availability_period'] = 'Add Custom Availability Period';
$lang['working_plan_exception'] = 'Working Plan Exception';
$lang['working_plan_exceptions'] = 'Working Plan Exceptions';
$lang['working_plan_exceptions_hint'] = 'Add a working plan exception day, outside the working plan.';
$lang['new_working_plan_exception_title'] = 'New Working Plan Exception';
$lang['working_plan_exception_saved'] = 'Working plan exception saved successfully.';
$lang['working_plan_exception_deleted'] = 'Working plan exception deleted successfully.';
$lang['add_working_plan_exceptions_during_each_day'] = 'Add working plan exceptions, outside the working plan.';
$lang['add_working_plan_exception'] = 'Add Working Plan Exception';
$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,14 @@ $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['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a custom availability period day, outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New Custom Availability Period';
$lang['custom_availability_period_saved'] = 'Custom availability period saved successfully.';
$lang['add_custom_availability_periods_during_each_day'] = 'Add custom availability periods, outside the working plan.';
$lang['add_custom_availability_period'] = 'Add Custom Availability Period';
$lang['working_plan_exception'] = 'Working Plan Exception';
$lang['working_plan_exceptions'] = 'Working Plan Exceptions';
$lang['working_plan_exceptions_hint'] = 'Add a working plan exception day, outside the working plan.';
$lang['new_working_plan_exception_title'] = 'New Working Plan Exception';
$lang['working_plan_exception_saved'] = 'Working plan exception saved successfully.';
$lang['working_plan_exception_deleted'] = 'Working plan exception deleted successfully.';
$lang['add_working_plan_exceptions_during_each_day'] = 'Add working plan exceptions, outside the working plan.';
$lang['add_working_plan_exception'] = 'Add Working Plan Exception';
$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,14 @@ $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['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a custom availability period day, outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New Custom Availability Period';
$lang['custom_availability_period_saved'] = 'Custom availability period saved successfully.';
$lang['add_custom_availability_periods_during_each_day'] = 'Add custom availability periods, outside the working plan.';
$lang['add_custom_availability_period'] = 'Add Custom Availability Period';
$lang['working_plan_exception'] = 'Working Plan Exception';
$lang['working_plan_exceptions'] = 'Working Plan Exceptions';
$lang['working_plan_exceptions_hint'] = 'Add a working plan exception day, outside the working plan.';
$lang['new_working_plan_exception_title'] = 'New Working Plan Exception';
$lang['working_plan_exception_saved'] = 'Working plan exception saved successfully.';
$lang['working_plan_exception_deleted'] = 'Working plan exception deleted successfully.';
$lang['add_working_plan_exceptions_during_each_day'] = 'Add working plan exceptions, outside the working plan.';
$lang['add_working_plan_exception'] = 'Add Working Plan Exception';
$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,14 @@ $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['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a custom availability period day, outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New Custom Availability Period';
$lang['custom_availability_period_saved'] = 'Custom availability period saved successfully.';
$lang['add_custom_availability_periods_during_each_day'] = 'Add custom availability periods, outside the working plan.';
$lang['add_custom_availability_period'] = 'Add Custom Availability Period';
$lang['working_plan_exception'] = 'Working Plan Exception';
$lang['working_plan_exceptions'] = 'Working Plan Exceptions';
$lang['working_plan_exceptions_hint'] = 'Add a working plan exception day, outside the working plan.';
$lang['new_working_plan_exception_title'] = 'New Working Plan Exception';
$lang['working_plan_exception_saved'] = 'Working plan exception saved successfully.';
$lang['working_plan_exception_deleted'] = 'Working plan exception deleted successfully.';
$lang['add_working_plan_exceptions_during_each_day'] = 'Add working plan exceptions, outside the working plan.';
$lang['add_working_plan_exception'] = 'Add Working Plan Exception';
$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,14 @@ $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['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a custom availability period day, outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New Custom Availability Period';
$lang['custom_availability_period_saved'] = 'Custom availability period saved successfully.';
$lang['add_custom_availability_periods_during_each_day'] = 'Add custom availability periods, outside the working plan.';
$lang['add_custom_availability_period'] = 'Add Custom Availability Period';
$lang['working_plan_exception'] = 'Working Plan Exception';
$lang['working_plan_exceptions'] = 'Working Plan Exceptions';
$lang['working_plan_exceptions_hint'] = 'Add a working plan exception day, outside the working plan.';
$lang['new_working_plan_exception_title'] = 'New Working Plan Exception';
$lang['working_plan_exception_saved'] = 'Working plan exception saved successfully.';
$lang['working_plan_exception_deleted'] = 'Working plan exception deleted successfully.';
$lang['add_working_plan_exceptions_during_each_day'] = 'Add working plan exceptions, outside the working plan.';
$lang['add_working_plan_exception'] = 'Add Working Plan Exception';
$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['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['working_plan_exception'] = 'Extra arbetsdag';
$lang['working_plan_exceptions'] = 'Extra arbetsdagar';
$lang['working_plan_exceptions_hint'] = 'Lägg till en arbetsdag utanför schemat.';
$lang['new_working_plan_exception_title'] = 'Ny arbetsdag';
$lang['working_plan_exception_saved'] = 'Den nya arbetsdagen är sparad.';
$lang['add_working_plan_exceptions_during_each_day'] = 'Lägg till arbetsdagar utanför schemat.';
$lang['add_working_plan_exception'] = '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,14 @@ $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['custom_availability_period'] = 'Custom availability period';
$lang['custom_availability_periods'] = 'Custom availability periods';
$lang['custom_availability_periods_hint'] = 'Add a custom availability period day, outside the working plan.';
$lang['new_custom_availability_period_title'] = 'New Custom Availability Period';
$lang['custom_availability_period_saved'] = 'Custom availability period saved successfully.';
$lang['add_custom_availability_periods_during_each_day'] = 'Add custom availability periods, outside the working plan.';
$lang['add_custom_availability_period'] = 'Add Custom Availability Period';
$lang['working_plan_exception'] = 'Working Plan Exception';
$lang['working_plan_exceptions'] = 'Working Plan Exceptions';
$lang['working_plan_exceptions_hint'] = 'Add a working plan exception day, outside the working plan.';
$lang['new_working_plan_exception_title'] = 'New Working Plan Exception';
$lang['working_plan_exception_saved'] = 'Working plan exception saved successfully.';
$lang['working_plan_exception_deleted'] = 'Working plan exception deleted successfully.';
$lang['add_working_plan_exceptions_during_each_day'] = 'Add working plan exceptions, outside the working plan.';
$lang['add_working_plan_exception'] = 'Add Working Plan Exception';
$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_custom_availability_periods_to_user_settings
* Class Migration_Add_working_plan_exceptions_to_user_settings
*
* @property CI_DB_query_builder $db
* @property CI_DB_forge dbforge
*/
class Migration_Add_custom_availability_periods_to_user_settings extends CI_Migration {
class Migration_Add_working_plan_exceptions_to_user_settings extends CI_Migration {
/**
* Upgrade method.
*/
public function up()
{
if ( ! $this->db->field_exists('custom_availability_periods', 'user_settings'))
if ( ! $this->db->field_exists('working_plan_exceptions', 'user_settings'))
{
$fields = [
'custom_availability_periods' => [
'working_plan_exceptions' => [
'type' => 'TEXT',
'null' => TRUE,
'after' => 'working_plan'
@ -42,9 +42,9 @@ class Migration_Add_custom_availability_periods_to_user_settings extends CI_Migr
*/
public function down()
{
if ( ! $this->db->field_exists('custom_availability_periods', 'user_settings'))
if ( ! $this->db->field_exists('working_plan_exceptions', 'user_settings'))
{
$this->dbforge->drop_column('user_settings', 'custom_availability_periods');
$this->dbforge->drop_column('user_settings', 'working_plan_exceptions');
}
}
}

View File

@ -314,22 +314,22 @@ class Providers_Model extends CI_Model {
}
// Check if the setting record exists in db.
if ($this->db->get_where('user_settings', ['id_users' => $provider_id])
->num_rows() == 0)
if ($this->db->get_where('user_settings', ['id_users' => $provider_id])->num_rows() === 0)
{
$this->db->insert('user_settings', ['id_users' => $provider_id]);
}
foreach ($settings as $name => $value)
{
// Sort in descending order the custom availability periods
if ($name == 'custom_availability_periods')
// Sort in descending order the working plan exceptions in a reverse order (makes it easier to edit them
// later on).
if ($name === 'working_plan_exceptions')
{
$value = json_decode($value, TRUE);
// Sort the array and put in reverse order
krsort($value);
$value = json_encode($value);
}
$this->set_setting($name, $value, $provider_id);
}
}
@ -473,7 +473,6 @@ class Providers_Model extends CI_Model {
// Get provider data.
$provider = $this->db->get_where('users', ['id' => $provider_id])->row_array();
// Include provider services.
$services = $this->db->get_where('services_providers',
['id_users' => $provider_id])->result_array();
@ -484,8 +483,7 @@ class Providers_Model extends CI_Model {
}
// Include provider settings.
$provider['settings'] = $this->db->get_where('user_settings',
['id_users' => $provider_id])->row_array();
$provider['settings'] = $this->db->get_where('user_settings', ['id_users' => $provider_id])->row_array();
unset($provider['settings']['id_users']);
// Return provider data array.
@ -633,51 +631,6 @@ class Providers_Model extends CI_Model {
return $providers;
}
/**
* Save the provider custom availability period.
*
* @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 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_custom_availability_period($custom_availability_period, $provider_id)
{
// Validate period
$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.');
}
// Validate provider record
$where_clause = [
'id' => $provider_id,
'id_roles' => $this->db->get_where('roles', ['slug' => DB_SLUG_PROVIDER])->row()->id
];
if ($this->db->get_where('users', $where_clause)->num_rows() == 0)
{
throw new Exception('Provider id was not found in database.');
}
// Add record to database.
$custom_availability_periods = json_decode($this->get_setting('custom_availability_periods', $provider_id), TRUE);
$custom_availability_periods[$dateStart] = [
'start' => $start,
'end' => $end,
'breaks' => []
];
return $this->set_setting('custom_availability_periods', json_encode($custom_availability_periods), $provider_id);
}
/**
* Get a providers setting from the database.
*
@ -689,37 +642,89 @@ class Providers_Model extends CI_Model {
public function get_setting($setting_name, $provider_id)
{
$provider_settings = $this->db->get_where('user_settings', ['id_users' => $provider_id])->row_array();
return $provider_settings[$setting_name];
}
/**
* Delete a provider custom availability period.
* Save the provider working plan exception.
*
* @param string $custom_availability_period Contains the date to be deleted from the custom availability periods.
* @param string $date The working plan exception date (in YYYY-MM-DD format).
* @param array $working_plan_exception Contains the working plan exception information ("start", "end" and "breaks"
* properties).
* @param int $provider_id The selected provider record id.
*
* @return bool Return if the new custom availability periods is correctly deleted from DB.
* @return bool Return if the new working plan exceptions 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 delete_custom_availability_period($custom_availability_period, $provider_id)
public function save_working_plan_exception($date, $working_plan_exception, $provider_id)
{
// Validate provider record
$where_clause = [
// Validate the working plan exception data.
$start = date('H:i', strtotime($working_plan_exception['start']));
$end = date('H:i', strtotime($working_plan_exception['end']));
if ($start > $end)
{
throw new Exception('Working plan exception "start" must be prior to "end".');
}
// Make sure the provider record exists.
$conditions = [
'id' => $provider_id,
'id_roles' => $this->db->get_where('roles', ['slug' => DB_SLUG_PROVIDER])->row()->id
];
if ($this->db->get_where('users', $where_clause)->num_rows() == 0)
if ($this->db->get_where('users', $conditions)->num_rows() === 0)
{
throw new Exception('Provider id was not found in database.');
throw new Exception('Provider record was not found in database: ' . $provider_id);
}
// Add record to database.
$custom_availability_periods = json_decode($this->get_setting('custom_availability_periods', $provider_id), TRUE);
$working_plan_exceptions = json_decode($this->get_setting('working_plan_exceptions', $provider_id), TRUE);
unset($custom_availability_periods[$custom_availability_period]);
if (!isset($working_plan_exception['breaks']))
{
$working_plan_exception['breaks'] = [];
}
return $this->set_setting('custom_availability_periods', json_encode($custom_availability_periods), $provider_id);
$working_plan_exceptions[$date] = $working_plan_exception;
return $this->set_setting(
'working_plan_exceptions',
json_encode($working_plan_exceptions),
$provider_id
);
}
/**
* Delete a provider working plan exception.
*
* @param string $date The working plan exception date (in YYYY-MM-DD format).
* @param int $provider_id The selected provider record id.
*
* @return bool Return if the new working plan exceptions is correctly deleted from DB.
*
* @throws Exception If $provider_id argument is invalid.
*/
public function delete_working_plan_exception($date, $provider_id)
{
$provider = $this->get_row($provider_id);
$working_plan_exceptions = json_decode($provider['settings']['working_plan_exceptions'], TRUE);
if ( ! isset($working_plan_exceptions[$date]))
{
return TRUE; // The selected date does not exist in provider's settings.
}
unset($working_plan_exceptions[$date]);
return $this->set_setting(
'working_plan_exceptions',
json_encode(empty($working_plan_exceptions) ? new stdClass() : $working_plan_exceptions),
$provider_id
);
}
}

View File

@ -1,15 +1,15 @@
<link rel="stylesheet" type="text/css" href="<?= asset_url('/assets/ext/jquery-fullcalendar/fullcalendar.min.css') ?>">
<script src="<?= asset_url('assets/ext/moment/moment.min.js') ?>"></script>
<script src="<?= asset_url('assets/ext/jquery-fullcalendar/fullcalendar.min.js') ?>"></script>
<script src="<?= asset_url('assets/ext/jquery-jeditable/jquery.jeditable.min.js') ?>"></script>
<script src="<?= asset_url('assets/ext/jquery-ui/jquery-ui-timepicker-addon.min.js') ?>"></script>
<script src="<?= asset_url('assets/js/working_plan_exceptions_modal.js') ?>"></script>
<script src="<?= asset_url('assets/js/backend_calendar.js') ?>"></script>
<script src="<?= asset_url('assets/js/backend_calendar_default_view.js') ?>"></script>
<script src="<?= asset_url('assets/js/backend_calendar_table_view.js') ?>"></script>
<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_custom_availability_periods_modal.js') ?>"></script>
<script src="<?= asset_url('assets/js/backend_calendar_api.js') ?>"></script>
<script>
var GlobalVariables = {
@ -82,9 +82,9 @@
<i class="far fa-plus-square mr-2"></i>
<?= lang('unavailable') ?>
</a>
<a class="dropdown-item" href="#" id="insert-custom-availability-period">
<a class="dropdown-item" href="#" id="insert-working-plan-exception">
<i class="far fa-plus-square mr-2"></i>
<?= lang('custom_availability_period') ?>
<?= lang('working_plan_exception') ?>
</a>
</div>
</div>
@ -271,12 +271,12 @@
<fieldset>
<legend>
<?= lang('customer_details_title') ?>
<button id="new-customer" class="btn btn-secondary btn-sm" type="button"
<button id="new-customer" class="btn btn-outline-secondary btn-sm" type="button"
title="<?= lang('clear_fields_add_existing_customer_hint') ?>">
<i class="far fa-plus-square mr-2"></i>
<?= lang('new') ?>
</button>
<button id="select-customer" class="btn btn-secondary btn-sm" type="button"
<button id="select-customer" class="btn btn-outline-secondary btn-sm" type="button"
title="<?= lang('pick_existing_customer_hint') ?>">
<i class="far fa-hand-pointer mr-2"></i>
<span>
@ -456,90 +456,6 @@
</div>
</div>
<!-- MANAGE CUSTOM AVAILABILITY PERIODS MODAL -->
<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_custom_availability_period_title') ?></h3>
<button class="close" data-dismiss="modal">&times;</button>
</div>
<div class="modal-body">
<div class="modal-message alert d-none"></div>
<form>
<fieldset>
<input id="custom-availability-period-id" type="hidden">
<div class="form-group">
<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="custom-availability-period-date" class="control-label">
<?= lang('date') ?>
<span class="text-danger">*</span>
</label>
<input id="custom-availability-period-date" class="form-control">
</div>
<div class="form-group">
<label for="custom-availability-period-start" class="control-label">
<?= lang('start') ?>
<span class="text-danger">*</span>
</label>
<input id="custom-availability-period-start" class="form-control">
</div>
<div class="form-group">
<label for="custom-availability-period-end" class="control-label">
<?= lang('end') ?>
<span class="text-danger">*</span>
</label>
<input id="custom-availability-period-end" class="form-control">
</div>
<div class="form-group">
<label class="control-label">
<?= lang('timezone') ?>
</label>
<ul>
<li>
<?= lang('provider') ?>:
<span class="provider-timezone">
-
</span>
</li>
<li>
<?= lang('current_user') ?>:
<span>
<?= $timezones[$timezone] ?>
</span>
</li>
</ul>
</div>
</fieldset>
</form>
</div>
<div class="modal-footer">
<button class="btn btn-outline-secondary" data-dismiss="modal">
<i class="fas fa-ban mr-2"></i>
<?= lang('cancel') ?>
</button>
<button id="save-custom-availability-period" class="btn btn-primary">
<i class="far fa-check-square mr-2"></i>
<?= lang('save') ?>
</button>
</div>
</div>
</div>
</div>
<!-- SELECT GOOGLE CALENDAR MODAL -->
<div id="select-google-calendar" class="modal fade">
@ -570,3 +486,8 @@
</div>
</div>
</div>
<!-- WORKING PLAN EXCEPTIONS MODAL -->
<?php require __DIR__ . '/working_plan_exceptions_modal.php' ?>

View File

@ -27,7 +27,8 @@
<script src="<?= asset_url('assets/ext/bootstrap/js/bootstrap.bundle.min.js') ?>"></script>
<script src="<?= asset_url('assets/ext/jquery-ui/jquery-ui.min.js') ?>"></script>
<script src="<?= asset_url('assets/ext/jquery-qtip/jquery.qtip.min.js') ?>"></script>
<script src="<?= asset_url('assets/ext/datejs/date.min.js') ?>"></script>
<script src="<?= asset_url('assets/ext/moment/moment.min.js') ?>"></script>
<script src="<?= asset_url('assets/ext/datejs/date.min.js') ?>"></script>
<script src="<?= asset_url('assets/ext/trumbowyg/trumbowyg.min.js') ?>"></script>
<script src="<?= asset_url('assets/ext/select2/select2.min.js') ?>"></script>
<script src="<?= asset_url('assets/ext/fontawesome/js/all.min.js') ?>"></script>

View File

@ -3,6 +3,7 @@
<script src="<?= asset_url('assets/js/backend_users_secretaries.js') ?>"></script>
<script src="<?= asset_url('assets/js/backend_users.js') ?>"></script>
<script src="<?= asset_url('assets/js/working_plan.js') ?>"></script>
<script src="<?= asset_url('assets/js/working_plan_exceptions_modal.js') ?>"></script>
<script src="<?= asset_url('assets/ext/jquery-ui/jquery-ui-timepicker-addon.min.js') ?>"></script>
<script src="<?= asset_url('assets/ext/jquery-jeditable/jquery.jeditable.min.js') ?>"></script>
<script>
@ -18,7 +19,7 @@
services: <?= json_encode($services) ?>,
timezones: <?= json_encode($timezones) ?>,
workingPlan: <?= json_encode(json_decode($working_plan)) ?>,
customavailabilityperiods: <?= json_encode(json_decode($custom_availability_periods)) ?>,
workingPlanExceptions: <?= json_encode(json_decode($working_plan_exceptions)) ?>,
user: {
id: <?= $user_id ?>,
email: <?= json_encode($user_email) ?>,
@ -328,22 +329,22 @@
<br>
<h3><?= lang('custom_availability_periods') ?></h3>
<h3><?= lang('working_plan_exceptions') ?></h3>
<p>
<?= lang('add_custom_availability_periods_during_each_day') ?>
<?= lang('add_working_plan_exceptions_during_each_day') ?>
</p>
<div>
<button type="button" class="add-custom-availability-periods btn btn-primary mr-2">
<button type="button" class="add-working-plan-exception btn btn-primary mr-2">
<i class="far fa-plus-square"></i>
<?= lang('add_custom_availability_period') ?>
<?= lang('add_working_plan_exception') ?>
</button>
</div>
<br>
<table class="custom-availability-periods table table-striped">
<table class="working-plan-exceptions table table-striped">
<thead>
<tr>
<th><?= lang('day') ?></th>
@ -354,6 +355,8 @@
</thead>
<tbody><!-- Dynamic Content --></tbody>
</table>
<?php require __DIR__ . '/working_plan_exceptions_modal.php' ?>
</div>
</div>
</div>

View File

@ -0,0 +1,58 @@
<div class="modal" id="working-plan-exceptions-modal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><?= lang('working_plan_exception') ?></h5>
<button type="button" class="close" data-dismiss="modal">
<span>&times;</span>
</button>
</div>
<div class="modal-body">
<div class="form-group">
<label for="working-plan-exceptions-date"><?= lang('date') ?></label>
<input class="form-control" id="working-plan-exceptions-date">
</div>
<div class="form-group">
<label for="working-plan-exceptions-start"><?= lang('start') ?></label>
<input class="form-control" id="working-plan-exceptions-start">
</div>
<div class="form-group">
<label for="working-plan-exceptions-end"><?= lang('end') ?></label>
<input class="form-control" id="working-plan-exceptions-end">
</div>
<h3><?= lang('breaks') ?></h3>
<p>
<?= lang('add_breaks_during_each_day') ?>
</p>
<div>
<button type="button" class="btn btn-primary working-plan-exceptions-add-break">
<i class="far fa-plus-square mr-2"></i>
<?= lang('add_break') ?>
</button>
</div>
<br>
<table class="table table-striped" id="working-plan-exceptions-breaks">
<thead>
<tr>
<th><?= lang('start') ?></th>
<th><?= lang('end') ?></th>
<th><?= lang('actions') ?></th>
</tr>
</thead>
<tbody><!-- Dynamic Content --></tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal"><?= lang('cancel') ?></button>
<button type="button" class="btn btn-primary" id="working-plan-exceptions-save"><?= lang('save') ?></button>
</div>
</div>
</div>
</div>

View File

@ -725,7 +725,7 @@ body .form-horizontal .controls {
padding: 4px 7px;
}
#users-page #providers .custom-availability-periods .btn {
#users-page #providers .working-plan-exceptions .btn {
margin-right: 5px;
padding: 4px 7px;
}
@ -735,7 +735,7 @@ body .form-horizontal .controls {
height: 36px;
}
.custom-availability-periods .custom-availability-period select {
.working-plan-exceptions .working-plan-exception select {
height: 36px;
}
}

View File

@ -64,6 +64,43 @@ window.BackendCalendar = window.BackendCalendar || {};
.addClass('btn-success');
}
});
$('#insert-working-plan-exception').on('click', function () {
var providerId = $('#select-filter-item').val();
var provider = GlobalVariables.availableProviders.find(function (availableProvider) {
return Number(availableProvider.id) === Number(providerId);
});
if (!provider) {
throw new Error('Provider could not be found: ' + providerId);
}
WorkingPlanExceptionsModal
.add()
.done(function (date, workingPlanException) {
var successCallback = function () {
Backend.displayNotification(EALang.working_plan_exception_saved);
var workingPlanExceptions = jQuery.parseJSON(provider.settings.working_plan_exceptions) || {};
workingPlanExceptions[date] = workingPlanException;
for (var index in GlobalVariables.availableProviders) {
var availableProvider = GlobalVariables.availableProviders[index];
if (Number(availableProvider.id) === Number(providerId)) {
availableProvider.settings.working_plan_exceptions = JSON.stringify(workingPlanExceptions);
break;
}
}
$('#select-filter-item').trigger('change'); // Update the calendar.
};
BackendCalendarApi.saveWorkingPlanException(date, workingPlanException, providerId, successCallback, null);
});
});
}
/**
@ -78,7 +115,6 @@ window.BackendCalendar = window.BackendCalendar || {};
BackendCalendarGoogleSync.initialize();
BackendCalendarAppointmentsModal.initialize();
BackendCalendarUnavailabilitiesModal.initialize();
BackendCalendarCustomAvailabilityPeriodsModal.initialize();
// Load and initialize the calendar view.
if (view === 'table') {

View File

@ -91,18 +91,23 @@ window.BackendCalendarApi = window.BackendCalendarApi || {};
};
/**
* Save custom availability period of work to database.
* Save working plan exception of work to database.
*
* @param {Object} customAvailabilityPeriods Contains the custom availability periods data.
* @param {Date} date Contains the working plan exceptions data.
* @param {Object} workingPlanException Contains the working plan exceptions data.
* @param {Number} providerId Contains the working plan exceptions data.
* @param {Function} successCallback The ajax success callback function.
* @param {Function} errorCallback The ajax failure callback function.
*/
exports.saveCustomAvailabilityPeriod = function (customAvailabilityPeriods, successCallback, errorCallback) {
var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_custom_availability_period';
exports.saveWorkingPlanException = function (date, workingPlanException, providerId,
successCallback, errorCallback) {
var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_working_plan_exception';
var data = {
csrfToken: GlobalVariables.csrfToken,
custom_availability_period: JSON.stringify(customAvailabilityPeriods)
date: date,
working_plan_exception: workingPlanException,
provider_id: providerId
};
$.post(url, data)
@ -120,4 +125,27 @@ window.BackendCalendarApi = window.BackendCalendarApi || {};
});
}
exports.deleteWorkingPlanException = function (date, providerId, successCallback, errorCallback) {
var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_working_plan_exception';
var data = {
csrfToken: GlobalVariables.csrfToken,
date: date,
provider_id: providerId
};
$.post(url, data)
.done(function (response) {
if (successCallback) {
successCallback(response);
}
})
.fail(function (jqXHR, textStatus, errorThrown) {
GeneralFunctions.ajaxFailureHandler(jqXHR, textStatus, errorThrown);
if (errorCallback) {
errorCallback();
}
});
}
})(window.BackendCalendarApi);

View File

@ -1,224 +0,0 @@
/* ----------------------------------------------------------------------------
* Easy!Appointments - Open Source Web Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) 2013 - 2017, Alex Tselegidis
* @license http://opensource.org/licenses/GPL-3.0 - GPLv3
* @link http://easyappointments.org
* @since v1.2.0
* ---------------------------------------------------------------------------- */
/**
* Backend Calendar Custom availability periods Modal
*
* This module implements the custom availability periods modal functionality.
*
* @module BackendCalendarCustomAvailabilityPeriodsModal
*/
window.BackendCalendarCustomAvailabilityPeriodsModal = window.BackendCalendarCustomAvailabilityPeriodsModal || {};
(function (exports) {
'use strict';
function bindEventHandlers() {
/**
* Event: Manage Dialog Save Button "Click"
*
* Stores the custom availability period changes or inserts a new record.
*/
$('#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('#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.
$dialog.find('.modal-message')
.text(EALang.start_date_before_end_error)
.addClass('alert-danger')
.removeClass('hidden');
$dialog.find('#custom-availability-period-start, #custom-availability-period-end').closest('.form-group').addClass('has-error');
return;
}
// 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: $('#custom-availability-period-provider').val() // curr provider
};
//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.custom_availability_period_saved);
// Close the modal dialog and refresh the calendar appointments.
$dialog.find('.alert').addClass('hidden');
$dialog.modal('hide');
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 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.custom_availability_periods = JSON.stringify(customAvailabilityPeriods);
GlobalVariables.availableProviders[providerIdx] = provider;
$('#select-filter-item').trigger('change');
};
var errorCallback = function (jqXHR, textStatus, errorThrown) {
$dialog.find('.modal-message').text(EALang.service_communication_error);
$dialog.find('.modal-message').addClass('alert-danger').removeClass('hidden');
};
BackendCalendarApi.saveCustomavailabilityperiod(customAvailabilityPeriod, successCallback, errorCallback);
});
/**
* Event: Manage Dialog Cancel Button "Click"
*
* Closes the dialog without saving any changes to the database.
*/
$('#manage-custom-availability-periods #cancel-custom-availability-period').on('click', function () {
$('#manage-custom-availability-periods').modal('hide');
});
/**
* 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.
*/
$('#insert-custom-availability-period').on('click', function () {
BackendCalendarCustomAvailabilityPeriodsModal.resetCustomavailabilityperiodDialog();
var $dialog = $('#manage-custom-availability-periods');
// Set the default datetime values.
var start = new Date();
start.addDays(1);
start.set({'hour': 8});
start.set({'minute': 30});
if ($('.calendar-view').length === 0) {
$dialog.find('#custom-availability-period-provider')
.val($('#select-filter-item').val())
.closest('.form-group')
.hide();
}
$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 custom availability period dialog form.
*
* 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.resetCustomavailabilityperiodDialog = function () {
var $dialog = $('#manage-custom-availability-periods');
$dialog.find('#custom-availability-period-id').val('');
// Set the default datetime values.
var start = new Date();
start.addDays(1);
start.set({'hour': 8});
start.set({'minute': 30});
var end = GlobalVariables.timeFormat === 'regular' ? '8:00 PM' : '19:00'
var dateFormat;
switch (GlobalVariables.dateFormat) {
case 'DMY':
dateFormat = 'dd/mm/yy';
break;
case 'MDY':
dateFormat = 'mm/dd/yy';
break;
case 'YMD':
dateFormat = 'yy/mm/dd';
break;
}
$dialog.find('#custom-availability-period-start').datetimepicker({
dateFormat: dateFormat,
timeFormat: GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : GlobalVariables.timeFormat,
// Translation
dayNames: [EALang.sunday, EALang.monday, EALang.tuesday, EALang.wednesday,
EALang.thursday, EALang.friday, EALang.saturday],
dayNamesShort: [EALang.sunday.substr(0, 3), EALang.monday.substr(0, 3),
EALang.tuesday.substr(0, 3), EALang.wednesday.substr(0, 3),
EALang.thursday.substr(0, 3), EALang.friday.substr(0, 3),
EALang.saturday.substr(0, 3)],
dayNamesMin: [EALang.sunday.substr(0, 2), EALang.monday.substr(0, 2),
EALang.tuesday.substr(0, 2), EALang.wednesday.substr(0, 2),
EALang.thursday.substr(0, 2), EALang.friday.substr(0, 2),
EALang.saturday.substr(0, 2)],
monthNames: [EALang.january, EALang.february, EALang.march, EALang.april,
EALang.may, EALang.june, EALang.july, EALang.august, EALang.september,
EALang.october, EALang.november, EALang.december],
prevText: EALang.previous,
nextText: EALang.next,
currentText: EALang.now,
closeText: EALang.close,
timeOnlyTitle: EALang.select_time,
timeText: EALang.time,
hourText: EALang.hour,
minuteText: EALang.minutes,
firstDay: 0
});
$dialog.find('#custom-availability-period-start').val(GeneralFunctions.formatDate(start, GlobalVariables.dateFormat, true));
$dialog.find('#custom-availability-period-start').draggable();
$dialog.find('#custom-availability-period-end').timepicker({
timeFormat: GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : GlobalVariables.timeFormat,
currentText: EALang.now,
closeText: EALang.close,
timeOnlyTitle: EALang.select_time,
timeText: EALang.time,
hourText: EALang.hour,
minuteText: EALang.minutes
});
$dialog.find('#custom-availability-period-end').val(end);
// Clear the custom availability period notes field.
$dialog.find('#custom-availability-period-notes').val('');
};
exports.initialize = function () {
var customAvailabilityPeriodProvider = $('#custom-availability-period-provider');
for (var index in GlobalVariables.availableProviders) {
var provider = GlobalVariables.availableProviders[index];
customAvailabilityPeriodProvider.append(new Option(provider.first_name + ' ' + provider.last_name, provider.id));
}
bindEventHandlers();
};
})(window.BackendCalendarCustomAvailabilityPeriodsModal);

View File

@ -40,12 +40,14 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
* When the user clicks the reload button an the calendar items need to be refreshed.
*/
$('#reload-appointments').on('click', function () {
var calendarView = $('#calendar').fullCalendar('getView');
refreshCalendarAppointments(
$('#calendar'),
$('#select-filter-item').val(),
$('#select-filter-item').find('option:selected').attr('type'),
$('#calendar').fullCalendar('getView').start,
$('#calendar').fullCalendar('getView').end);
calendarView.start,
calendarView.end);
});
/**
@ -69,7 +71,36 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
var startDatetime;
var endDatetime;
if (lastFocusedEventData.data.is_unavailable === '0') {
if (lastFocusedEventData.data.workingPlanException) {
var date = lastFocusedEventData.data.date;
var workingPlanException = lastFocusedEventData.data.workingPlanException;
var provider = lastFocusedEventData.data.provider;
WorkingPlanExceptionsModal
.edit(date, workingPlanException)
.done(function (date, workingPlanException) {
var successCallback = function () {
Backend.displayNotification(EALang.working_plan_exception_saved);
var workingPlanExceptions = jQuery.parseJSON(provider.settings.working_plan_exceptions) || {};
workingPlanExceptions[date] = workingPlanException;
for (var index in GlobalVariables.availableProviders) {
var availableProvider = GlobalVariables.availableProviders[index];
if (Number(availableProvider.id) === Number(provider.id)) {
availableProvider.settings.working_plan_exceptions = JSON.stringify(workingPlanExceptions);
break;
}
}
$('#select-filter-item').trigger('change'); // Update the calendar.
};
BackendCalendarApi.saveWorkingPlanException(date, workingPlanException, provider.id, successCallback, null);
});
} else if (lastFocusedEventData.data.is_unavailable === '0') {
var appointment = lastFocusedEventData.data;
$dialog = $('#manage-appointment');
@ -100,6 +131,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
$dialog.find('#appointment-location').val(appointment.location);
$dialog.find('#appointment-notes').val(appointment.notes);
$dialog.find('#customer-notes').val(customer.notes);
$dialog.modal('show');
} else {
var unavailable = lastFocusedEventData.data;
@ -119,10 +151,8 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
$dialog.find('#unavailable-provider').val(unavailable.id_users_provider);
$dialog.find('#unavailable-end').datetimepicker('setDate', endDatetime);
$dialog.find('#unavailable-notes').val(unavailable.notes);
$dialog.modal('show');
}
// :: DISPLAY EDIT DIALOG
$dialog.modal('show');
});
/**
@ -137,31 +167,39 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
var url;
var data;
// 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_custom_availability_period';
if (lastFocusedEventData.data.workingPlanException) {
var providerId = $('#select-filter-item').val();
data = {
csrfToken: GlobalVariables.csrfToken,
custom_availability_period: lastFocusedEventData.start.format('YYYY-MM-DD'),
provider_id: lastFocusedEventData.data.id
var provider = GlobalVariables.availableProviders.find(function (availableProvider) {
return Number(availableProvider.id) === Number(providerId);
});
if (!provider) {
throw new Error('Provider could not be found: ' + providerId);
}
var successCallback = function () {
Backend.displayNotification(EALang.working_plan_exception_deleted);
var workingPlanExceptions = jQuery.parseJSON(provider.settings.working_plan_exceptions) || {};
delete workingPlanExceptions[date];
for (var index in GlobalVariables.availableProviders) {
var availableProvider = GlobalVariables.availableProviders[index];
if (Number(availableProvider.id) === Number(providerId)) {
availableProvider.settings.working_plan_exceptions = JSON.stringify(workingPlanExceptions);
break;
}
}
$('#select-filter-item').trigger('change'); // Update the calendar.
};
$.post(url, data)
.done(function () {
$('#message-box').dialog('close');
var date = lastFocusedEventData.start.format('YYYY-MM-DD');
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');
})
.fail(GeneralFunctions.ajaxFailureHandler);
}
else if (lastFocusedEventData.data.is_unavailable === '0') {
BackendCalendarApi.deleteWorkingPlanException(date, providerId, successCallback);
} else if (lastFocusedEventData.data.is_unavailable === '0') {
var buttons = [
{
text: EALang.cancel,
@ -231,16 +269,20 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
// If current value is service, then the sync buttons must be disabled.
if ($('#select-filter-item option:selected').attr('type') === FILTER_TYPE_SERVICE) {
$('#google-sync, #enable-sync, #insert-appointment, #insert-dropdown').prop('disabled', true);
$('#calendar').fullCalendar('option', 'selectable', false);
$('#calendar').fullCalendar('option', 'editable', false);
$('#calendar').fullCalendar('option', {
selectable: false,
editable: false,
});
} else {
$('#google-sync, #enable-sync, #insert-appointment, #insert-dropdown').prop('disabled', false);
$('#calendar').fullCalendar('option', 'selectable', true);
$('#calendar').fullCalendar('option', 'editable', true);
$('#calendar').fullCalendar('option', {
selectable: true,
editable: true,
});
var providerId = $('#select-filter-item').val();
var provider = GlobalVariables.availableProviders.find(function(availableProvider) {
var provider = GlobalVariables.availableProviders.find(function (availableProvider) {
return Number(availableProvider.id) === Number(providerId);
});
@ -250,11 +292,11 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
// If the user has already the sync enabled then apply the proper style changes.
if ($('#select-filter-item option:selected').attr('google-sync') === 'true') {
$('#enable-sync').removeClass('btn-light').addClass('btn-secondary enabled');
// $('#enable-sync').removeClass('btn-light').addClass('btn-secondary enabled');
$('#enable-sync span').text(EALang.disable_sync);
$('#google-sync').prop('disabled', false);
} else {
$('#enable-sync').removeClass('btn-secondary enabled').addClass('btn-light');
// $('#enable-sync').removeClass('btn-secondary enabled').addClass('btn-light');
$('#enable-sync span').text(EALang.enable_sync);
$('#google-sync').prop('disabled', true);
}
@ -282,7 +324,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
* @param {Event} event
*/
function getEventNotes(event) {
if (!event.data || !event.data.notes) {
if (!event.data || !event.data.notes) {
return '-';
}
@ -362,7 +404,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
]
}),
$('<button/>', {
'class': 'delete-popover btn btn-danger ' + displayDelete,
'class': 'delete-popover btn btn-outline-secondary ' + displayDelete,
'html': [
$('<i/>', {
'class': 'far fa-trash-alt mr-2'
@ -387,7 +429,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
})
]
});
} else if ($(this).hasClass('fc-custom-availability-period') || $parent.hasClass('fc-custom-availability-period') || $altParent.hasClass('fc-custom-availability-period')) {
} else if ($(this).hasClass('fc-working-plan-exception') || $parent.hasClass('fc-working-plan-exception') || $altParent.hasClass('fc-working-plan-exception')) {
displayDelete = (($parent.hasClass('fc-custom') || $altParent.hasClass('fc-custom'))
&& GlobalVariables.user.privileges.appointments.delete === true)
? 'mr-2' : 'd-none'; // Same value at the time.
@ -399,7 +441,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
'text': EALang.provider
}),
$('<span/>', {
'text': event.data ? event.data.first_name + ' ' + event.data.last_name : '-'
'text': event.data ? event.data.provider.first_name + ' ' + event.data.provider.last_name : '-'
}),
$('<br/>'),
@ -435,10 +477,6 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
$('<div/>', {
'class': 'd-flex justify-content-between',
'html': [
$('<button/>', {
'class': 'delete-popover btn btn-danger ' + displayDelete,
'text': EALang.delete
}),
$('<button/>', {
'class': 'close-popover btn btn-outline-secondary',
'html': [
@ -449,7 +487,29 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
'text': EALang.close
})
]
})
}),
$('<button/>', {
'class': 'delete-popover btn btn-outline-secondary ' + displayDelete,
'html': [
$('<i/>', {
'class': 'fas fa-trash-alt mr-2'
}),
$('<span/>', {
'text': EALang.delete
})
]
}),
$('<button/>', {
'class': 'edit-popover btn btn-primary ' + displayEdit,
'html': [
$('<i/>', {
'class': 'fas fa-edit mr-2'
}),
$('<span/>', {
'text': EALang.edit
})
]
}),
]
})
]
@ -566,7 +626,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
]
}),
$('<button/>', {
'class': 'delete-popover btn btn-danger ' + displayDelete,
'class': 'delete-popover btn btn-outline-secondary ' + displayDelete,
'html': [
$('<i/>', {
'class': 'far fa-trash-alt mr-2'
@ -981,13 +1041,14 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
return $.post(url, data)
.done(function (response) {
// Add appointments to calendar.
var calendarEvents = [];
var $calendar = $('#calendar');
$calendar.fullCalendar('removeEvents');
// Add appointments to calendar.
var appointmentEvents = [];
response.appointments.forEach(function (appointment) {
var event = {
var appointmentEvent = {
id: appointment.id,
title: appointment.service.name + ' - '
+ appointment.customer.first_name + ' '
@ -998,317 +1059,314 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
data: appointment // Store appointment data for later use.
};
calendarEvents.push(event);
appointmentEvents.push(appointmentEvent);
});
$calendar.fullCalendar('removeEvents');
$calendar.fullCalendar('addEventSource', calendarEvents);
$calendar.fullCalendar('addEventSource', appointmentEvents);
// :: ADD PROVIDER'S UNAVAILABLE TIME PERIODS
var calendarView = $calendar.fullCalendar('getView').name;
// Add custom unavailable periods (they are always displayed on the calendar, even if the provider won't
// work on that day).
var unavailableEvents = [];
response.unavailables.forEach(function (unavailable) {
var notes = unavailable.notes ? ' - ' + unavailable.notes : '';
if (filterType === FILTER_TYPE_PROVIDER && calendarView !== 'month') {
GlobalVariables.availableProviders.forEach(function (provider) {
if (Number(provider.id) === Number(recordId)) {
var workingPlan = jQuery.parseJSON(provider.settings.working_plan);
var customAvailabilityPeriods = jQuery.parseJSON(provider.settings.custom_availability_periods);
var unavailablePeriod;
if (unavailable.notes.length > 30) {
notes = unavailable.notes.substring(0, 30) + '...'
}
// 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);
var sortedWorkingPlan = GeneralFunctions.sortWeekDictionary(workingPlan, firstWeekdayNumber);
var unavailableEvent = {
title: EALang.unavailable + notes,
start: moment(unavailable.start_datetime),
end: moment(unavailable.end_datetime),
allDay: false,
color: '#879DB4',
editable: true,
className: 'fc-unavailable fc-custom',
data: unavailable
};
switch (calendarView) {
case 'agendaDay':
var selectedDayName = GeneralFunctions
.getWeekdayName(parseInt($calendar.fullCalendar('getView').start.format('d')));
unavailableEvents.push(unavailableEvent);
});
// Add custom unavailable periods.
response.unavailables.forEach(function (unavailable) {
var notes = unavailable.notes ? ' - ' + unavailable.notes : '';
$calendar.fullCalendar('addEventSource', unavailableEvents);
if (unavailable.notes.length > 30) {
notes = unavailable.notes.substring(0, 30) + '...'
}
var calendarView = $('#calendar').fullCalendar('getView');
var unavailablePeriod = {
title: EALang.unavailable + notes,
start: moment(unavailable.start_datetime),
end: moment(unavailable.end_datetime),
allDay: false,
color: '#879DB4',
editable: true,
className: 'fc-unavailable fc-custom',
data: unavailable
};
$calendar.fullCalendar('renderEvent', unavailablePeriod, false);
});
// Non-working day.
if (sortedWorkingPlan[selectedDayName] === null) {
// Custom availability period.
var selectedDay = $calendar.fullCalendar('getView').intervalStart.clone();
selectedDay.locale('en');
if (customAvailabilityPeriods && selectedDay.format() in customAvailabilityPeriods) {
sortedWorkingPlan[selectedDay.format('dddd').toLowerCase()] = customAvailabilityPeriods[selectedDay.format('YYYY-MM-DD')];
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 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-custom-availability-period fc-custom',
data: provider
};
$calendar.fullCalendar('renderEvent', customAvailabilityPeriod, false);
} else {
unavailablePeriod = {
title: EALang.not_working,
start: $calendar.fullCalendar('getView').intervalStart.clone(),
end: $calendar.fullCalendar('getView').intervalEnd.clone(),
allDay: false,
color: '#BEBEBE',
editable: false,
className: 'fc-unavailable'
};
$calendar.fullCalendar('renderEvent', unavailablePeriod, false);
return; // Go to next loop.
}
}
// Add unavailable period before work starts.
var calendarDateStart = moment($calendar.fullCalendar('getView').start.format('YYYY-MM-DD') + ' 00:00:00');
var startHour = sortedWorkingPlan[selectedDayName].start.split(':');
var workDateStart = calendarDateStart.clone();
workDateStart.hour(parseInt(startHour[0]));
workDateStart.minute(parseInt(startHour[1]));
if (calendarDateStart < workDateStart) {
var unavailablePeriodBeforeWorkStarts = {
title: EALang.not_working,
start: calendarDateStart,
end: workDateStart,
allDay: false,
color: '#BEBEBE',
editable: false,
className: 'fc-unavailable'
};
$calendar.fullCalendar('renderEvent', unavailablePeriodBeforeWorkStarts, false);
}
// Add unavailable period after work ends.
var calendarDateEnd = moment($calendar.fullCalendar('getView').end.format('YYYY-MM-DD') + ' 00:00:00');
var endHour = sortedWorkingPlan[selectedDayName].end.split(':');
var workDateEnd = calendarDateStart.clone();
workDateEnd.hour(parseInt(endHour[0]));
workDateEnd.minute(parseInt(endHour[1]));
if (calendarDateEnd > workDateEnd) {
var unavailablePeriodAfterWorkEnds = {
title: EALang.not_working,
start: workDateEnd,
end: calendarDateEnd,
allDay: false,
color: '#BEBEBE',
editable: false,
className: 'fc-unavailable'
};
$calendar.fullCalendar('renderEvent', unavailablePeriodAfterWorkEnds, false);
}
// Add unavailable periods for breaks.
var breakStart;
var breakEnd;
sortedWorkingPlan[selectedDayName].breaks.forEach(function (currentBreak) {
var breakStartString = currentBreak.start.split(':');
breakStart = calendarDateStart.clone();
breakStart.hour(parseInt(breakStartString[0]));
breakStart.minute(parseInt(breakStartString[1]));
var breakEndString = currentBreak.end.split(':');
breakEnd = calendarDateStart.clone();
breakEnd.hour(parseInt(breakEndString[0]));
breakEnd.minute(parseInt(breakEndString[1]));
var unavailablePeriod = {
title: EALang.break,
start: breakStart,
end: breakEnd,
allDay: false,
color: '#BEBEBE',
editable: false,
className: 'fc-unavailable fc-break'
};
$calendar.fullCalendar('renderEvent', unavailablePeriod, false);
});
break;
case 'agendaWeek':
var currentDateStart = $calendar.fullCalendar('getView').start.clone();
var currentDateEnd = currentDateStart.clone().add(1, 'days');
// Add custom unavailable periods (they are always displayed on the calendar, even if
// the provider won't work on that day).
response.unavailables.forEach(function (unavailable) {
var notes = unavailable.notes ? ' - ' + unavailable.notes : '';
if (unavailable.notes.length > 30) {
notes = unavailable.notes.substring(0, 30) + '...'
}
unavailablePeriod = {
title: EALang.unavailable + notes,
start: moment(unavailable.start_datetime),
end: moment(unavailable.end_datetime),
allDay: false,
color: '#879DB4',
editable: true,
className: 'fc-unavailable fc-custom',
data: unavailable
};
$calendar.fullCalendar('renderEvent', unavailablePeriod, false);
});
$.each(sortedWorkingPlan, function (index, workingDay) {
if (workingDay === null) {
// 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 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 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-custom-availability-period fc-custom',
data: provider
};
$calendar.fullCalendar('renderEvent', customAvailabilityPeriod, false);
} else {
// Add a full day unavailable event.
unavailablePeriod = {
title: EALang.not_working,
start: moment(currentDateStart.format('YYYY-MM-DD')),
end: moment(currentDateEnd.format('YYYY-MM-DD')),
allDay: false,
color: '#BEBEBE',
editable: false,
className: 'fc-unavailable'
};
$calendar.fullCalendar('renderEvent', unavailablePeriod, true);
currentDateStart.add(1, 'days');
currentDateEnd.add(1, 'days');
return; // Go to the next loop.
}
}
var start;
var end;
// Add unavailable period before work starts.
var workingDayStartString = workingDay.start.split(':');
start = currentDateStart.clone();
start.hour(parseInt(workingDayStartString[0]));
start.minute(parseInt(workingDayStartString[1]));
if (currentDateStart < start) {
unavailablePeriod = {
title: EALang.not_working,
start: moment(currentDateStart.format('YYYY-MM-DD') + ' 00:00:00'),
end: moment(currentDateStart.format('YYYY-MM-DD') + ' ' + workingDay.start + ':00'),
allDay: false,
color: '#BEBEBE',
editable: false,
className: 'fc-unavailable'
};
$calendar.fullCalendar('renderEvent', unavailablePeriod, true);
}
// Add unavailable period after work ends.
var workingDayEndString = workingDay.end.split(':');
end = currentDateStart.clone();
end.hour(parseInt(workingDayEndString[0]));
end.minute(parseInt(workingDayEndString[1]));
if (currentDateEnd > end) {
unavailablePeriod = {
title: EALang.not_working,
start: moment(currentDateStart.format('YYYY-MM-DD') + ' ' + workingDay.end + ':00'),
end: moment(currentDateEnd.format('YYYY-MM-DD') + ' 00:00:00'),
allDay: false,
color: '#BEBEBE',
editable: false,
className: 'fc-unavailable'
};
$calendar.fullCalendar('renderEvent', unavailablePeriod, false);
}
// Add unavailable periods during day breaks.
var breakStart;
var breakEnd;
workingDay.breaks.forEach(function (currentBreak) {
var breakStartString = currentBreak.start.split(':');
breakStart = currentDateStart.clone();
breakStart.hour(parseInt(breakStartString[0]));
breakStart.minute(parseInt(breakStartString[1]));
var breakEndString = currentBreak.end.split(':');
breakEnd = currentDateStart.clone();
breakEnd.hour(parseInt(breakEndString[0]));
breakEnd.minute(parseInt(breakEndString[1]));
var unavailablePeriod = {
title: EALang.break,
start: moment(currentDateStart.format('YYYY-MM-DD') + ' ' + currentBreak.start),
end: moment(currentDateStart.format('YYYY-MM-DD') + ' ' + currentBreak.end),
allDay: false,
color: '#BEBEBE',
editable: false,
className: 'fc-unavailable fc-break'
};
$calendar.fullCalendar('renderEvent', unavailablePeriod, false);
});
currentDateStart.add(1, 'days');
currentDateEnd.add(1, 'days');
});
break;
}
}
if (filterType === FILTER_TYPE_PROVIDER && calendarView.name !== 'month') {
var provider = GlobalVariables.availableProviders.find(function (availableProvider) {
return Number(availableProvider.id) === Number(recordId);
});
if (!provider) {
throw new Error('Provider was not found.');
}
var workingPlan = jQuery.parseJSON(provider.settings.working_plan);
var workingPlanExceptions = jQuery.parseJSON(provider.settings.working_plan_exceptions);
var unavailableEvent;
var viewStart;
var viewEnd;
var breakStart;
var breakEnd;
var workingPlanExceptionStart;
var workingPlanExceptionEnd;
var weekdayNumber;
var weekdayName;
var weekdayDate;
var workingPlanExceptionEvent;
var startHour;
var endHour;
var workDateStart;
var workDateEnd;
// 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);
var sortedWorkingPlan = GeneralFunctions.sortWeekDictionary(workingPlan, firstWeekdayNumber);
switch (calendarView.name) {
case 'agendaDay':
weekdayNumber = parseInt(calendarView.start.format('d'));
weekdayName = GeneralFunctions.getWeekdayName(weekdayNumber);
weekdayDate = calendarView.start.clone().format('YYYY-MM-DD');
// Add working plan exception.
if (workingPlanExceptions && workingPlanExceptions[weekdayDate]) {
sortedWorkingPlan[weekdayName] = workingPlanExceptions[weekdayDate];
workingPlanExceptionStart = weekdayDate + ' ' + sortedWorkingPlan[weekdayName].start;
workingPlanExceptionEnd = weekdayDate + ' ' + sortedWorkingPlan[weekdayName].end;
workingPlanExceptionEvent = {
title: EALang.working_plan_exception,
start: moment(workingPlanExceptionStart, 'YYYY-MM-DD HH:mm', true),
end: moment(workingPlanExceptionEnd, 'YYYY-MM-DD HH:mm', true).add(1, 'day'),
allDay: true,
color: '#879DB4',
editable: false,
className: 'fc-working-plan-exception fc-custom',
data: {
date: weekdayDate,
workingPlanException: workingPlanExceptions[weekdayDate],
provider: provider
}
};
$calendar.fullCalendar('renderEvent', workingPlanExceptionEvent, false);
}
// Non-working day.
if (sortedWorkingPlan[weekdayName] === null) {
// Working plan exception.
unavailableEvent = {
title: EALang.not_working,
start: calendarView.intervalStart.clone(),
end: calendarView.intervalEnd.clone(),
allDay: false,
color: '#BEBEBE',
editable: false,
className: 'fc-unavailable'
};
$calendar.fullCalendar('renderEvent', unavailableEvent, false);
return; // Go to next loop.
}
// Add unavailable period before work starts.
viewStart = moment(calendarView.start.format('YYYY-MM-DD') + ' 00:00:00');
startHour = sortedWorkingPlan[weekdayName].start.split(':');
workDateStart = viewStart.clone();
workDateStart.hour(parseInt(startHour[0]));
workDateStart.minute(parseInt(startHour[1]));
if (viewStart < workDateStart) {
var unavailablePeriodBeforeWorkStarts = {
title: EALang.not_working,
start: viewStart,
end: workDateStart,
allDay: false,
color: '#BEBEBE',
editable: false,
className: 'fc-unavailable'
};
$calendar.fullCalendar('renderEvent', unavailablePeriodBeforeWorkStarts, false);
}
// Add unavailable period after work ends.
viewEnd = moment(calendarView.end.format('YYYY-MM-DD') + ' 00:00:00');
endHour = sortedWorkingPlan[weekdayName].end.split(':');
workDateEnd = viewStart.clone();
workDateEnd.hour(parseInt(endHour[0]));
workDateEnd.minute(parseInt(endHour[1]));
if (viewEnd > workDateEnd) {
var unavailablePeriodAfterWorkEnds = {
title: EALang.not_working,
start: workDateEnd,
end: viewEnd,
allDay: false,
color: '#BEBEBE',
editable: false,
className: 'fc-unavailable'
};
$calendar.fullCalendar('renderEvent', unavailablePeriodAfterWorkEnds, false);
}
// Add unavailable periods for breaks.
sortedWorkingPlan[weekdayName].breaks.forEach(function (breakPeriod) {
var breakStartString = breakPeriod.start.split(':');
breakStart = viewStart.clone();
breakStart.hour(parseInt(breakStartString[0]));
breakStart.minute(parseInt(breakStartString[1]));
var breakEndString = breakPeriod.end.split(':');
breakEnd = viewStart.clone();
breakEnd.hour(parseInt(breakEndString[0]));
breakEnd.minute(parseInt(breakEndString[1]));
var unavailablePeriod = {
title: EALang.break,
start: breakStart,
end: breakEnd,
allDay: false,
color: '#BEBEBE',
editable: false,
className: 'fc-unavailable fc-break'
};
$calendar.fullCalendar('renderEvent', unavailablePeriod, false);
});
break;
case 'agendaWeek':
var calendarDate = calendarView.start.clone();
while (calendarDate < calendarView.end) {
weekdayName = calendarDate.format('dddd').toLowerCase();
weekdayDate = calendarDate.format('YYYY-MM-DD');
// Add working plan exception event.
if (workingPlanExceptions && workingPlanExceptions[weekdayDate]) {
sortedWorkingPlan[weekdayName] = workingPlanExceptions[weekdayDate];
workingPlanExceptionStart = weekdayDate + ' ' + sortedWorkingPlan[weekdayName].start;
workingPlanExceptionEnd = weekdayDate + ' ' + sortedWorkingPlan[weekdayName].end;
workingPlanExceptionEvent = {
title: EALang.working_plan_exception,
start: moment(workingPlanExceptionStart, 'YYYY-MM-DD HH:mm', true),
end: moment(workingPlanExceptionEnd, 'YYYY-MM-DD HH:mm', true).add(1, 'day'),
allDay: true,
color: '#879DB4',
editable: false,
className: 'fc-working-plan-exception fc-custom',
data: {
date: weekdayDate,
workingPlanException: workingPlanExceptions[weekdayDate],
provider: provider
}
};
$calendar.fullCalendar('renderEvent', workingPlanExceptionEvent, false);
}
// Non-working day.
if (sortedWorkingPlan[weekdayName] === null) {
// Add a full day unavailable event.
unavailableEvent = {
title: EALang.not_working,
start: calendarDate.clone(),
end: calendarDate.clone().add(1, 'day'),
allDay: false,
color: '#BEBEBE',
editable: false,
className: 'fc-unavailable'
};
$calendar.fullCalendar('renderEvent', unavailableEvent, true);
calendarDate.add(1, 'day');
continue; // Go to the next loop.
}
// Add unavailable period before work starts.
startHour = sortedWorkingPlan[weekdayName].start.split(':');
workDateStart = calendarDate.clone();
workDateStart.hour(parseInt(startHour[0]));
workDateStart.minute(parseInt(startHour[1]));
if (calendarDate < workDateStart) {
unavailableEvent = {
title: EALang.not_working,
start: calendarDate.clone(),
end: moment(calendarDate.format('YYYY-MM-DD') + ' ' + sortedWorkingPlan[weekdayName].start + ':00'),
allDay: false,
color: '#BEBEBE',
editable: false,
className: 'fc-unavailable'
};
$calendar.fullCalendar('renderEvent', unavailableEvent, true);
}
// Add unavailable period after work ends.
endHour = sortedWorkingPlan[weekdayName].end.split(':');
workDateEnd = calendarDate.clone();
workDateEnd.hour(parseInt(endHour[0]));
workDateEnd.minute(parseInt(endHour[1]));
if (calendarView.end > workDateEnd) {
unavailableEvent = {
title: EALang.not_working,
start: moment(calendarDate.format('YYYY-MM-DD') + ' ' + sortedWorkingPlan[weekdayName].end + ':00'),
end: calendarDate.clone().add(1, 'day'),
allDay: false,
color: '#BEBEBE',
editable: false,
className: 'fc-unavailable'
};
$calendar.fullCalendar('renderEvent', unavailableEvent, false);
}
// Add unavailable periods during day breaks.
sortedWorkingPlan[weekdayName].breaks.forEach(function (breakPeriod) {
var breakStartString = breakPeriod.start.split(':');
breakStart = calendarDate.clone();
breakStart.hour(parseInt(breakStartString[0]));
breakStart.minute(parseInt(breakStartString[1]));
var breakEndString = breakPeriod.end.split(':');
breakEnd = calendarDate.clone();
breakEnd.hour(parseInt(breakEndString[0]));
breakEnd.minute(parseInt(breakEndString[1]));
var unavailableEvent = {
title: EALang.break,
start: moment(calendarDate.format('YYYY-MM-DD') + ' ' + breakPeriod.start),
end: moment(calendarDate.format('YYYY-MM-DD') + ' ' + breakPeriod.end),
allDay: false,
color: '#BEBEBE',
editable: false,
className: 'fc-unavailable fc-break'
};
$calendar.fullCalendar('renderEvent', unavailableEvent, false);
});
calendarDate.add(1, 'day');
}
break;
}
}
})
.fail(GeneralFunctions.ajaxFailureHandler)
.always(function() {
.always(function () {
$('#loading').css('visibility', '')
});
}
@ -1334,7 +1392,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
// Time formats
var timeFormat = '';
var slotTimeFormat= '';
var slotTimeFormat = '';
switch (GlobalVariables.timeFormat) {
case 'military':
@ -1501,8 +1559,8 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
if (GlobalVariables.user.role_slug === Backend.DB_SLUG_SECRETARY) {
// Remove the providers that are not connected to the secretary.
$('#select-filter-item option[type="provider"]').each(function (index, option) {
var provider = GlobalVariables.secretaryProviders.find(function(secretaryProviderId) {
return Number($(option).val()) === Number(secretaryProviderId);
var provider = GlobalVariables.secretaryProviders.find(function (secretaryProviderId) {
return Number($(option).val()) === Number(secretaryProviderId);
});
if (!provider) {
@ -1589,12 +1647,14 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
var $selectFilterItem = $('#select-filter-item');
setInterval(function () {
var calendarView = $calendar.fullCalendar('getView');
refreshCalendarAppointments(
$calendar,
$selectFilterItem.val(),
$selectFilterItem.find('option:selected').attr('type'),
$calendar.fullCalendar('getView').start,
$calendar.fullCalendar('getView').end);
calendarView.start,
calendarView.end);
}, 30000);
};

View File

@ -213,14 +213,14 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
var url;
var data;
// If id_role parameter exists the popover is an custom availability period.
// If id_role parameter exists the popover is an working plan exception.
if (lastFocusedEventData.data.hasOwnProperty('id_roles')) {
// Do not display confirmation prompt.
url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_custom_availability_period';
url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_working_plan_exception';
data = {
csrfToken: GlobalVariables.csrfToken,
custom_availability_period: lastFocusedEventData.start.format('YYYY-MM-DD'),
working_plan_exception: lastFocusedEventData.start.format('YYYY-MM-DD'),
provider_id: lastFocusedEventData.data.id
};
@ -228,9 +228,9 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
.done(function () {
$('#message-box').dialog('close');
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);
var workingPlanExceptions = jQuery.parseJSON(lastFocusedEventData.data.settings.working_plan_exceptions);
delete workingPlanExceptions[lastFocusedEventData.start.format('YYYY-MM-DD')];
lastFocusedEventData.data.settings.working_plan_exceptions = JSON.stringify(workingPlanExceptions);
// Refresh calendar event items.
$('#select-filter-item').trigger('change');
@ -1084,7 +1084,7 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
]
}),
$('<button/>', {
'class': 'delete-popover btn btn-danger ' + displayDelete,
'class': 'delete-popover btn btn-outline-secondary ' + displayDelete,
'html': [
$('<i/>', {
'class': 'far fa-trash-alt mr-2'
@ -1109,7 +1109,7 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
})
]
});
} else if ($(this).hasClass('fc-custom-availability-period') || $parent.hasClass('fc-custom-availability-period') || $altParent.hasClass('fc-custom-availability-period')) {
} else if ($(this).hasClass('fc-working-plan-exception') || $parent.hasClass('fc-working-plan-exception') || $altParent.hasClass('fc-working-plan-exception')) {
displayEdit = (($parent.hasClass('fc-custom') || $altParent.hasClass('fc-custom'))
&& GlobalVariables.user.privileges.appointments.edit === true)
? 'mr-2' : 'd-none'; // Same value at the time.
@ -1169,7 +1169,7 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
]
}),
$('<button/>', {
'class': 'delete-popover btn btn-danger ' + displayDelete,
'class': 'delete-popover btn btn-outline-secondary ' + displayDelete,
'html': [
$('<i/>', {
'class': 'far fa-trash-alt mr-2'
@ -1295,7 +1295,7 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
]
}),
$('<button/>', {
'class': 'delete-popover btn btn-danger ' + displayDelete,
'class': 'delete-popover btn btn-outline-secondary ' + displayDelete,
'html': [
$('<i/>', {
'class': 'far fa-trash-alt mr-2'

View File

@ -0,0 +1,230 @@
/* ----------------------------------------------------------------------------
* Easy!Appointments - Open Source Web Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) 2013 - 2020, Alex Tselegidis
* @license http://opensource.org/licenses/GPL-3.0 - GPLv3
* @link http://easyappointments.org
* @since v1.2.0
* ---------------------------------------------------------------------------- */
/**
* Backend Calendar Working plan exceptions Modal
*
* This module implements the working plan exceptions modal functionality.
*
* @module BackendCalendarWorkingPlanExceptionsModal
*/
window.BackendCalendarWorkingPlanExceptionsModal = window.BackendCalendarWorkingPlanExceptionsModal || {};
(function (exports) {
'use strict';
function bindEventHandlers() {
/**
* Event: Manage Modal Save Button "Click"
*
* Stores the working plan exception changes or inserts a new record.
*/
$('#manage-working-plan-exceptions #save-working-plan-exception').on('click', function () {
$('#manage-working-plan-exceptions .modal-message').addClass('hidden');
$('#manage-working-plan-exceptions').find('.has-error').removeClass('has-error');
var date = $('#working-plan-exception-date').datetimepicker('getDate');
if (!date) {
$('#working-plan-exception-date').closest('.form-group').addClass('has-error');
return;
}
var start = $('#working-plan-exception-start').datetimepicker('getDate');
if (!start) {
$('#working-plan-exception-start').closest('.form-group').addClass('has-error');
return;
}
var end = Date.parse($('#working-plan-exception-end').datetimepicker('getDate'));
if (!end) {
$('#working-plan-exception-end').closest('.form-group').addClass('has-error');
return;
}
if (start > end) {
// Start time is after end time - display message to user.
$('#manage-working-plan-exceptions .modal-message')
.text(EALang.start_date_before_end_error)
.addClass('alert-danger')
.removeClass('hidden');
$('#working-plan-exception-start').addClass('has-error');
$('#working-plan-exception-end').addClass('has-error');
return;
}
var workingPlanException = {
start: start.toString('HH:mm'),
end: end.toString('HH:mm'),
breaks: []
};
var successCallback = function () {
// Display success message to the user.
Backend.displayNotification(EALang.working_plan_exception_saved);
// Close the modal modal and update the local provider.
$('#manage-working-plan-exceptions .modal-message').addClass('hidden');
$('#manage-working-plan-exceptions').modal('hide');
var providerId = $('#working-plan-exception-provider').val();
var provider = GlobalVariables.availableProviders.find(function(availableProvider) {
return Number(availableProvider.id) === Number(providerId);
});
if (!provider) {
throw new Error('Provider could not be found: ' + providerId);
}
var selectedDate = date.toString('yyyy-MM-dd');
var workingPlanExceptions = jQuery.parseJSON(provider.settings.working_plan_exceptions);
workingPlanExceptions[selectedDate] = {
start: start.toString('HH:mm'),
end: end.toString('HH:mm'),
breaks: [],
};
provider.settings.working_plan_exceptions = JSON.stringify(workingPlanExceptions);
$('#select-filter-item').trigger('change'); // Update the calendar.
};
BackendCalendarApi.saveWorkingPlanException(date, workingPlanException, provider.id, successCallback, null);
});
/**
* Event: Insert Custom Working Time Period Button "Click"
*
* When the user clicks this button a popup modal appears and the use can set a time period where he cannot
* accept any appointments.
*/
$('#insert-working-plan-exception').on('click', function () {
BackendCalendarWorkingPlanExceptionsModal.resetWorkingPlanExceptionModal();
if ($('.calendar-view').length === 0) {
$('#manage-working-plan-exceptions').find('#working-plan-exception-provider')
.val($('#select-filter-item').val())
.closest('.form-group')
.hide();
}
$('#working-plan-exception-date').val(GeneralFunctions.formatDate(new Date(), GlobalVariables.dateFormat, false));
$('#working-plan-exception-start').val(GlobalVariables.timeFormat === 'regular' ? '8:00 AM' : '08:00');
$('#working-plan-exception-end').val(GlobalVariables.timeFormat === 'regular' ? '8:00 PM' : '20:00');
$('#manage-working-plan-exceptions').find('.modal-header h3').text(EALang.new_working_plan_exception_title);
$('#manage-working-plan-exceptions').modal('show');
});
}
/**
* Reset working plan exception modal form.
*
* Reset the "#manage-working-plan-exceptions" modal. Use this method to bring the modal to the initial state
* before it becomes visible to the user.
*/
exports.resetWorkingPlanExceptionModal = function () {
$('#manage-working-plan-exceptions').find('#working-plan-exception-id').val('');
// Set the default datetime values.
var date = new Date();
var start = GlobalVariables.timeFormat === 'regular' ? '8:00 AM' : '08:00'
var end = GlobalVariables.timeFormat === 'regular' ? '8:00 PM' : '20:00'
var dateFormat;
switch (GlobalVariables.dateFormat) {
case 'DMY':
dateFormat = 'dd/mm/yy';
break;
case 'MDY':
dateFormat = 'mm/dd/yy';
break;
case 'YMD':
dateFormat = 'yy/mm/dd';
break;
}
$('#working-plan-exception-date').datepicker({
dateFormat: dateFormat,
// Translation
dayNames: [EALang.sunday, EALang.monday, EALang.tuesday, EALang.wednesday,
EALang.thursday, EALang.friday, EALang.saturday],
dayNamesShort: [EALang.sunday.substr(0, 3), EALang.monday.substr(0, 3),
EALang.tuesday.substr(0, 3), EALang.wednesday.substr(0, 3),
EALang.thursday.substr(0, 3), EALang.friday.substr(0, 3),
EALang.saturday.substr(0, 3)],
dayNamesMin: [EALang.sunday.substr(0, 2), EALang.monday.substr(0, 2),
EALang.tuesday.substr(0, 2), EALang.wednesday.substr(0, 2),
EALang.thursday.substr(0, 2), EALang.friday.substr(0, 2),
EALang.saturday.substr(0, 2)],
monthNames: [EALang.january, EALang.february, EALang.march, EALang.april,
EALang.may, EALang.june, EALang.july, EALang.august, EALang.september,
EALang.october, EALang.november, EALang.december],
prevText: EALang.previous,
nextText: EALang.next,
currentText: EALang.now,
closeText: EALang.close,
timeOnlyTitle: EALang.select_time,
timeText: EALang.time,
hourText: EALang.hour,
minuteText: EALang.minutes,
firstDay: 0
});
$('#working-plan-exception-date').val(GeneralFunctions.formatDate(date, GlobalVariables.dateFormat, false));
$('#working-plan-exception-start').timepicker({
timeFormat: GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : GlobalVariables.timeFormat,
// Translation
prevText: EALang.previous,
nextText: EALang.next,
currentText: EALang.now,
closeText: EALang.close,
timeOnlyTitle: EALang.select_time,
timeText: EALang.time,
hourText: EALang.hour,
minuteText: EALang.minutes,
firstDay: 0
});
$('#working-plan-exception-start').val(start);
$('#working-plan-exception-end').timepicker({
timeFormat: GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : GlobalVariables.timeFormat,
// Translation
prevText: EALang.previous,
nextText: EALang.next,
currentText: EALang.now,
closeText: EALang.close,
timeOnlyTitle: EALang.select_time,
timeText: EALang.time,
hourText: EALang.hour,
minuteText: EALang.minutes,
firstDay: 0
});
$('#working-plan-exception-end').val(end);
};
exports.initialize = function () {
GlobalVariables.availableProviders.forEach(function (availableProvider) {
$('#working-plan-exception-provider').append(new Option(availableProvider.first_name + ' ' + availableProvider.last_name, availableProvider.id));
});
bindEventHandlers();
};
})(window.BackendCalendarWorkingPlanExceptionsModal);

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-custom-availability-periods, .edit-custom-availability-period, .delete-custom-availability-period, #reset-working-plan').prop('disabled', false);
$('#providers').find('.add-break, .edit-break, .delete-break, .add-working-plan-exception, .edit-working-plan-exception, .delete-working-plan-exception, #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-custom-availability-periods, .edit-custom-availability-period, .delete-custom-availability-period, #reset-working-plan').prop('disabled', false);
$('#providers').find('.add-break, .edit-break, .delete-break, .add-working-plan-exception, .edit-working-plan-exception, .delete-working-plan-exception, #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()),
custom_availability_periods: JSON.stringify(BackendUsers.wp.getCustomAvailabilityPeriods()),
working_plan_exceptions: JSON.stringify(BackendUsers.wp.getWorkingPlanExceptions()),
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();
$('.custom-availability-periods tbody').empty();
$('.working-plan-exceptions 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-custom-availability-periods, #reset-working-plan').prop('disabled', true);
$('#providers .add-break, .add-working-plan-exception, #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);
$('.custom-availability-periods').find('.edit-custom-availability-period, .delete-custom-availability-period').prop('disabled', true);
$('.working-plan-exceptions').find('.edit-working-plan-exception, .delete-working-plan-exception').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 .custom-availability-periods tbody').empty();
$('#providers .working-plan-exceptions 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 .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-exceptions tbody').empty();
var workingPlanExceptions = $.parseJSON(provider.settings.working_plan_exceptions);
BackendUsers.wp.setupWorkingPlanExceptions(workingPlanExceptions);
$('.working-plan-exceptions').find('.edit-working-plan-exception, .delete-working-plan-exception').prop('disabled', true);
$('#providers .working-plan input:checkbox').prop('disabled', true);
Backend.placeFooterToBottom();
};
@ -525,7 +525,7 @@
*
* @param {Object} $selector The cells to be initialized.
*/
ProvidersHelper.prototype.editableBreakDay = function ($selector) {
ProvidersHelper.prototype.editableDayCell = function ($selector) {
var weekDays = {};
weekDays[EALang.monday] = 'Monday';
weekDays[EALang.tuesday] = 'Tuesday';
@ -564,7 +564,7 @@
*
* @param {jQuery} $selector The cells to be initialized.
*/
ProvidersHelper.prototype.editableBreakTime = function ($selector) {
ProvidersHelper.prototype.editableTimeCell = function ($selector) {
$selector.editable(function (value, settings) {
// Do not return the value because the user needs to press the "Save" button.
return value;

View File

@ -99,12 +99,11 @@ window.FrontendBook = window.FrontendBook || {};
}
});
var fDay = GlobalVariables.firstWeekday;
var fDaynum = GeneralFunctions.getWeekDayId(fDay);
var weekDayId = GeneralFunctions.getWeekDayId(GlobalVariables.firstWeekday);
$('#select-date').datepicker({
dateFormat: 'dd-mm-yy',
firstDay: fDaynum,
firstDay: weekDayId,
minDate: 0,
defaultDate: Date.today(),

View File

@ -347,7 +347,7 @@ window.GeneralFunctions = window.GeneralFunctions || {};
/**
* Format a given date according to the date format setting.
*
* @param {Date} date The date to be formatted.
* @param {String} date The date to be formatted.
* @param {String} dateFormatSetting The setting provided by PHP must be one of the "DMY", "MDY" or "YMD".
* @param {Boolean} addHours (optional) Whether to add hours to the result.

View File

@ -183,97 +183,23 @@
}.bind(this));
// Make break cells editable.
this.editableBreakDay($('.breaks .break-day'));
this.editableBreakTime($('.breaks').find('.break-start, .break-end'));
this.editableDayCell($('.breaks .break-day'));
this.editableTimeCell($('.breaks').find('.break-start, .break-end'));
};
/**
* Setup the dom elements of a given Custom availability period.
* Setup the dom elements of a given working plan exception.
*
* @param {Object} customAvailabilityPeriods Contains the custom availability period.
* @param {Object} workingPlanExceptions Contains the working plan exception.
*/
WorkingPlan.prototype.setupcustomAvailabilityPeriods = function (customAvailabilityPeriods) {
$.each(customAvailabilityPeriods, function (index, customAvailabilityPeriod) {
if (customAvailabilityPeriod) {
$('#' + index).prop('checked', true);
$('#' + 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());
WorkingPlan.prototype.setupWorkingPlanExceptions = function (workingPlanExceptions) {
for (var date in workingPlanExceptions) {
var workingPlanException = workingPlanExceptions[date];
var day = GeneralFunctions.formatDate(Date.parse(index), GlobalVariables.dateFormat, false);
var timeFormat = GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm';
$('<tr/>', {
'html': [
$('<td/>', {
'class': 'custom-availability-period editable',
'text': day
}),
$('<td/>', {
'class': 'custom-availability-period-start editable',
'text': Date.parse(customAvailabilityPeriod.start).toString(timeFormat).toUpperCase()
}),
$('<td/>', {
'class': 'custom-availability-period-end editable',
'text': Date.parse(customAvailabilityPeriod.end).toString(timeFormat).toUpperCase()
}),
$('<td/>', {
'html': [
$('<button/>', {
'type': 'button',
'class': 'btn btn-outline-secondary btn-sm edit-custom-availability-period',
'title': EALang.edit,
'html': [
$('<span/>', {
'class': 'far fa-edit'
})
]
}),
$('<button/>', {
'type': 'button',
'class': 'btn btn-outline-secondary btn-sm delete-custom-availability-period',
'title': EALang.delete,
'html': [
$('<span/>', {
'class': 'far fa-trash-alt'
})
]
}),
$('<button/>', {
'type': 'button',
'class': 'btn btn-outline-secondary btn-sm save-custom-availability-period d-none',
'title': EALang.save,
'html': [
$('<span/>', {
'class': 'far fa-check-circle'
})
]
}),
$('<button/>', {
'type': 'button',
'class': 'btn btn-outline-secondary btn-sm cancel-custom-availability-period d-none',
'title': EALang.cancel,
'html': [
$('<span/>', {
'class': 'fas fa-ban'
})
]
})
]
})
]
})
.appendTo('.custom-availability-periods tbody');
} else {
$('#' + index).prop('checked', false);
$('#' + index + '-start').prop('disabled', true);
$('#' + index + '-end').prop('disabled', true);
}
}.bind(this));
// Make break cells editable.
this.editableBreakTime($('.custom-availability-periods .custom-availability-period'));
this.editableBreakTime($('.custom-availability-periods').find('.custom-availability-period-start, .custom-availability-period-end'));
this
.renderWorkingPlanExceptionRow(date, workingPlanException)
.appendTo('.working-plan-exceptions tbody');
}
};
/**
@ -283,7 +209,7 @@
*
* @param {Object} $selector The jquery selector ready for use.
*/
WorkingPlan.prototype.editableBreakDay = function ($selector) {
WorkingPlan.prototype.editableDayCell = function ($selector) {
var weekDays = {};
weekDays[EALang.sunday] = EALang.sunday; //'Sunday';
weekDays[EALang.monday] = EALang.monday; //'Monday';
@ -323,7 +249,7 @@
*
* @param {Object} $selector The jquery selector ready for use.
*/
WorkingPlan.prototype.editableBreakTime = function ($selector) {
WorkingPlan.prototype.editableTimeCell = function ($selector) {
$selector.editable(function (value, settings) {
// Do not return the value because the user needs to press the "Save" button.
return value;
@ -339,7 +265,7 @@
.outerHTML,
cancel: $('<button/>', {
'type': 'button',
'class': 'd-none cancek-editable',
'class': 'd-none cancel-editable',
'text': EALang.cancel
})
.get(0)
@ -358,6 +284,63 @@
});
};
/**
* Enable editable break time.
*
* This method makes editable the break time cells.
*
* @param {String} date In "Y-m-d" format.
* @param {Object} workingPlanException Contains exception information.
*/
WorkingPlan.prototype.renderWorkingPlanExceptionRow = function (date, workingPlanException) {
var timeFormat = GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm';
return $('<tr/>', {
'data': {
'date': date,
'workingPlanException': workingPlanException
},
'html': [
$('<td/>', {
'class': 'working-plan-exception-date',
'text': GeneralFunctions.formatDate(date, GlobalVariables.dateFormat, false)
}),
$('<td/>', {
'class': 'working-plan-exception--start',
'text': Date.parse(workingPlanException.start).toString(timeFormat)
}),
$('<td/>', {
'class': 'working-plan-exception--end',
'text': Date.parse(workingPlanException.end).toString(timeFormat)
}),
$('<td/>', {
'html': [
$('<button/>', {
'type': 'button',
'class': 'btn btn-outline-secondary btn-sm edit-working-plan-exception',
'title': EALang.edit,
'html': [
$('<span/>', {
'class': 'far fa-edit'
})
]
}),
$('<button/>', {
'type': 'button',
'class': 'btn btn-outline-secondary btn-sm delete-working-plan-exception',
'title': EALang.delete,
'html': [
$('<span/>', {
'class': 'far fa-trash-alt'
})
]
}),
]
})
]
});
};
/**
* Binds the event handlers for the working plan dom elements.
*/
@ -367,7 +350,7 @@
*
* Enable or disable the time selection for each day.
*/
$('.working-plan tbody').on("click", "input:checkbox", function () {
$('.working-plan tbody').on('click', 'input:checkbox', function () {
var id = $(this).attr('id');
if ($(this).prop('checked') === true) {
@ -396,11 +379,11 @@
}),
$('<td/>', {
'class': 'break-start editable',
'text': '9:00 AM'
'text': Date.parse('12:00:00').toString(timeFormat)
}),
$('<td/>', {
'class': 'break-end editable',
'text': '10:00 AM'
'text': Date.parse('14:00:00').toString(timeFormat)
}),
$('<td/>', {
'html': [
@ -451,8 +434,8 @@
.appendTo('.breaks tbody');
// Bind editable and event handlers.
this.editableBreakDay($newBreak.find('.break-day'));
this.editableBreakTime($newBreak.find('.break-start, .break-end'));
this.editableDayCell($newBreak.find('.break-day'));
this.editableTimeCell($newBreak.find('.break-start, .break-end'));
$newBreak.find('.edit-break').trigger('click');
$('.add-break').prop('disabled', true);
}.bind(this));
@ -508,7 +491,7 @@
*
* Bring the ".breaks" table back to its initial state.
*
* @param {jQuery.Event} e
* @param {jQuery.Event} event
*/
$(document).on('click', '.cancel-break', function (event) {
var element = event.target;
@ -554,212 +537,62 @@
}.bind(this));
/**
* Event: Add custom availability period Button "Click"
* Event: Add Working Plan Exception Button "Click"
*
* 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.
* A new row is added on the table and the user can enter the new working plan exception.
*/
$('.add-custom-availability-periods').on('click', function () {
var today = GeneralFunctions.formatDate(new Date(), GlobalVariables.dateFormat, false);
$(document).on('click', '.add-working-plan-exception', function () {
WorkingPlanExceptionsModal
.add()
.done(function (date, workingPlanException) {
var $tr = null;
var $newcustomAvailabilityPeriod = $('<tr/>', {
'html': [
$('<td/>', {
'class': 'custom-availability-period editable',
'text': today
}),
$('<td/>', {
'class': 'custom-availability-period-start editable',
'text': '9:00 AM'
}),
$('<td/>', {
'class': 'custom-availability-period-end editable',
'text': '10:00 AM'
}),
$('<td/>', {
'html': [
$('<button/>', {
'type': 'button',
'class': 'btn btn-outline-secondary btn-sm edit-custom-availability-period',
'title': EALang.edit,
'html': [
$('<span/>', {
'class': 'far fa-edit'
})
]
}),
$('<button/>', {
'type': 'button',
'class': 'btn btn-outline-secondary btn-sm delete-custom-availability-period',
'title': EALang.delete,
'html': [
$('<span/>', {
'class': 'far fa-trash-alt'
})
]
}),
$('<button/>', {
'type': 'button',
'class': 'btn btn-outline-secondary btn-sm save-custom-availability-period d-none',
'title': EALang.save,
'html': [
$('<span/>', {
'class': 'far fa-check-circle'
})
]
}),
$('<button/>', {
'type': 'button',
'class': 'btn btn-outline-secondary btn-sm cancel-custom-availability-period d-none',
'title': EALang.cancel,
'html': [
$('<span/>', {
'class': 'fas fa-ban'
})
]
})
]
}),
]
})
.appendTo('.custom-availability-periods tbody');
$('.working-plan-exceptions tbody tr').each(function(index, tr) {
if (date === $(tr).data('date')) {
$tr = $(tr);
return false;
}
});
// Bind editable and event handlers.
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);
var $newTr = this.renderWorkingPlanExceptionRow(date, workingPlanException);
if ($tr) {
$tr.replaceWith($newTr);
} else {
$newTr.appendTo('.working-plan-exceptions tbody');
}
}.bind(this));
}.bind(this));
/**
* Event: Edit custom availability period Button "Click"
* Event: Edit working plan exception Button "Click"
*
* Enables the row editing for the "custom availability period" table rows.
* Enables the row editing for the "working plan exception" table rows.
*
* @param {jQuery.Event} event
*/
$(document).on('click', '.edit-custom-availability-period', function () {
// Reset previous editable table cells.
var $previousEdits = $(this).closest('table').find('.editable');
$(document).on('click', '.edit-working-plan-exception', function (event) {
var $tr = $(event.target).closest('tr');
var date = $tr.data('date');
var workingPlanException = $tr.data('workingPlanException');
$previousEdits.each(function (index, editable) {
if (editable.reset) {
editable.reset();
}
});
WorkingPlanExceptionsModal
.edit(date, workingPlanException)
.done(function (date, workingPlanException) {
$tr.replaceWith(
this.renderWorkingPlanExceptionRow(date, workingPlanException)
);
}.bind(this));
}.bind(this));
// Make all cells in current row editable.
$(this).parent().parent().children().trigger('edit');
$(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,
timeOnlyTitle: EALang.select_time,
timeText: EALang.time,
hourText: EALang.hour,
minuteText: EALang.minutes
});
var dateFormat;
switch (GlobalVariables.dateFormat) {
case 'DMY':
dateFormat = 'dd/mm/yy';
break;
case 'MDY':
dateFormat = 'mm/dd/yy';
break;
case 'YMD':
dateFormat = 'yy/mm/dd';
break;
}
$(this).parent().parent().find('.custom-availability-period input').datetimepicker({
dateFormat: dateFormat,
// Translation
dayNames: [EALang.sunday, EALang.monday, EALang.tuesday, EALang.wednesday,
EALang.thursday, EALang.friday, EALang.saturday],
dayNamesShort: [EALang.sunday.substr(0, 3), EALang.monday.substr(0, 3),
EALang.tuesday.substr(0, 3), EALang.wednesday.substr(0, 3),
EALang.thursday.substr(0, 3), EALang.friday.substr(0, 3),
EALang.saturday.substr(0, 3)],
dayNamesMin: [EALang.sunday.substr(0, 2), EALang.monday.substr(0, 2),
EALang.tuesday.substr(0, 2), EALang.wednesday.substr(0, 2),
EALang.thursday.substr(0, 2), EALang.friday.substr(0, 2),
EALang.saturday.substr(0, 2)],
monthNames: [EALang.january, EALang.february, EALang.march, EALang.april,
EALang.may, EALang.june, EALang.july, EALang.august, EALang.september,
EALang.october, EALang.november, EALang.december],
prevText: EALang.previous,
nextText: EALang.next,
currentText: EALang.now,
closeText: EALang.close,
firstDay: 1,
showTimepicker: false
});
// Show save - cancel buttons.
var $tr = $(this).closest('tr');
$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-custom-availability-periods').prop('disabled', true);
/**
* Event: Delete working plan exception Button "Click"
*
* Removes the current line from the "working plan exceptions" table.
*/
$(document).on('click', '.delete-working-plan-exception', function () {
$(this).closest('tr').remove();
});
/**
* Event: Delete custom availability period Button "Click"
*
* Removes the current line from the "custom availability periods" table.
*/
$(document).on('click', '.delete-custom-availability-period', function () {
$(this).parent().parent().remove();
});
/**
* Event: Cancel custom availability period Button "Click"
*
* Bring the ".custom-availability-period" table back to its initial state.
*
* @param {jQuery.Event} e
*/
$(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-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 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-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('.custom-availability-period-start input').val());
var end = Date.parse($modifiedRow.find('.custom-availability-period-end input').val());
if (start > end) {
$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-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));
};
/**
@ -769,6 +602,7 @@
*/
WorkingPlan.prototype.get = function () {
var workingPlan = {};
$('.working-plan input:checkbox').each(function (index, checkbox) {
var id = $(checkbox).attr('id');
if ($(checkbox).prop('checked') === true) {
@ -806,27 +640,20 @@
};
/**
* Get the custom availability periods settings.
* Get the working plan exceptions settings.
*
* @return {Object} Returns the custom availability periods settings object.
* @return {Object} Returns the working plan exceptions settings object.
*/
WorkingPlan.prototype.getCustomAvailabilityPeriods = function () {
var customAvailabilityPeriods = {};
$('.custom-availability-periods tbody tr').each(function (index, tr) {
WorkingPlan.prototype.getWorkingPlanExceptions = function () {
var workingPlanExceptions = {};
var day = GeneralFunctions.ISO8601DateString($(tr).find('.custom-availability-period').text(), GlobalVariables.dateFormat);
$('.working-plan-exceptions tbody tr').each(function (index, tr) {
var $tr = $(tr);
var date = $tr.data('date');
workingPlanExceptions[date] = $tr.data('workingPlanException');
});
var start = $(tr).find('.custom-availability-period-start').text();
var end = $(tr).find('.custom-availability-period-end').text();
customAvailabilityPeriods[day] = {
start: Date.parse(start).toString('HH:mm'),
end: Date.parse(end).toString('HH:mm'),
breaks: []
};
}.bind(this));
return customAvailabilityPeriods;
return workingPlanExceptions;
};
/**

View File

@ -0,0 +1,377 @@
$(function () {
'use strict';
var $modal = $('#working-plan-exceptions-modal');
var $date = $('#working-plan-exceptions-date');
var $start = $('#working-plan-exceptions-start');
var $end = $('#working-plan-exceptions-end');
var $breaks = $('#working-plan-exceptions-breaks');
var $save = $('#working-plan-exceptions-save');
var deferred = null;
var enableSubmit = false;
var enableCancel = false;
function resetModal() {
$date.val('');
$start.val('');
$end.val('');
$breaks.find('tbody').empty();
}
function validate() {
$modal.find('.is-invalid').removeClass('is-invalid');
var date = $date.datepicker('getDate');
if (!date) {
$date.addClass('is-invalid');
}
var start = $start.timepicker('getDate');
if (!start) {
$start.addClass('is-invalid');
}
var end = $end.timepicker('getDate');
if (!end) {
$end.addClass('is-invalid');
}
return !$modal.find('.is-invalid').length;
}
function onModalHidden() {
resetModal();
}
function getBreaks() {
var breaks = [];
$breaks.find('tbody tr').each(function (index, tr) {
var $tr = $(tr);
if ($tr.find('input:text').length) {
return true;
}
var start = $tr.find('.working-plan-exceptions-break-start').text();
var end = $tr.find('.working-plan-exceptions-break-end').text();
breaks.push({
start: Date.parse(start).toString('HH:mm'),
end: Date.parse(end).toString('HH:mm')
});
});
// Sort breaks increasingly by hour within day
breaks.sort(function (break1, break2) {
// We can do a direct string comparison since we have time based on 24 hours clock.
return (break1.start).localeCompare(break2.start);
});
return breaks;
}
function onSaveClick() {
if (!deferred) {
return;
}
if (!validate()) {
return;
}
var date = $date.datepicker('getDate').toString('yyyy-MM-dd');
var workingPlanException = {
start: $start.datetimepicker('getDate').toString('HH:mm'),
end: $end.datetimepicker('getDate').toString('HH:mm'),
breaks: getBreaks()
};
deferred.resolve(date, workingPlanException);
$modal.modal('hide');
resetModal();
}
function editableTimeCell($target) {
$target.editable(function (value) {
// Do not return the value because the user needs to press the "Save" button.
return value;
}, {
event: 'edit',
height: '30px',
submit: $('<button/>', {
'type': 'button',
'class': 'd-none submit-editable',
'text': EALang.save
})
.get(0)
.outerHTML,
cancel: $('<button/>', {
'type': 'button',
'class': 'd-none cancel-editable',
'text': EALang.cancel
})
.get(0)
.outerHTML,
onblur: 'ignore',
onreset: function () {
if (!enableCancel) {
return false; // disable ESC button
}
},
onsubmit: function () {
if (!enableSubmit) {
return false; // disable Enter button
}
}
});
}
function add() {
deferred = jQuery.Deferred();
$date.datepicker('setDate', new Date());
$start.timepicker('setDate', moment('08:00', 'HH:mm').toDate());
$end.timepicker('setDate', moment('20:00', 'HH:mm').toDate());
$modal.modal('show');
return deferred.promise();
}
function edit(date, workingPlanException) {
deferred = jQuery.Deferred();
$date.datepicker('setDate', moment(date, 'YYYY-MM-DD').toDate());
$start.timepicker('setDate', moment(workingPlanException.start, 'HH:mm').toDate());
$end.timepicker('setDate', moment(workingPlanException.end, 'HH:mm').toDate());
workingPlanException.breaks.forEach(function (workingPlanExceptionBreak) {
renderBreakRow(workingPlanExceptionBreak)
.appendTo($breaks.find('tbody'));
});
editableTimeCell($breaks.find('tbody .working-plan-exceptions-break-start, tbody .working-plan-exceptions-break-end'));
$modal.modal('show');
return deferred.promise();
}
function renderBreakRow(breakPeriod) {
var timeFormat = GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm';
return $('<tr/>', {
'html': [
$('<td/>', {
'class': 'working-plan-exceptions-break-start editable',
'text': Date.parse(breakPeriod.start).toString(timeFormat)
}),
$('<td/>', {
'class': 'working-plan-exceptions-break-end editable',
'text': Date.parse(breakPeriod.end).toString(timeFormat)
}),
$('<td/>', {
'html': [
$('<button/>', {
'type': 'button',
'class': 'btn btn-outline-secondary btn-sm mr-2 working-plan-exceptions-edit-break',
'title': EALang.edit,
'html': [
$('<span/>', {
'class': 'far fa-edit'
})
]
}),
$('<button/>', {
'type': 'button',
'class': 'btn btn-outline-secondary btn-sm working-plan-exceptions-delete-break',
'title': EALang.delete,
'html': [
$('<span/>', {
'class': 'far fa-trash-alt'
})
]
}),
$('<button/>', {
'type': 'button',
'class': 'btn btn-outline-secondary btn-sm mr-2 working-plan-exceptions-save-break d-none',
'title': EALang.save,
'html': [
$('<span/>', {
'class': 'far fa-check-circle'
})
]
}),
$('<button/>', {
'type': 'button',
'class': 'btn btn-outline-secondary btn-sm working-plan-exceptions-cancel-break d-none',
'title': EALang.cancel,
'html': [
$('<span/>', {
'class': 'fas fa-ban'
})
]
})
]
})
]
});
}
function onAddBreakClick() {
var $newBreak = renderBreakRow({
start: '12:00',
end: '14:00'
})
.appendTo('#working-plan-exceptions-breaks tbody');
// Bind editable and event handlers.
editableTimeCell($newBreak.find('.working-plan-exceptions-break-start, .working-plan-exceptions-break-end'));
$newBreak.find('.working-plan-exceptions-edit-break').trigger('click');
$('.working-plan-exceptions-add-break').prop('disabled', true);
}
function onEditBreakClick() {
// Reset previous editable table cells.
var $previousEdits = $(this).closest('table').find('.editable');
$previousEdits.each(function (index, editable) {
if (editable.reset) {
editable.reset();
}
});
// Make all cells in current row editable.
var $tr = $(this).closest('tr');
$tr.children().trigger('edit');
initializeTimepicker($tr.find('.working-plan-exceptions-break-start input, .working-plan-exceptions-break-end input'));
$(this).closest('tr').find('.working-plan-exceptions-break-start').focus();
// Show save - cancel buttons.
var $tr = $(this).closest('tr');
$tr.find('.working-plan-exceptions-edit-break, .working-plan-exceptions-delete-break').addClass('d-none');
$tr.find('.working-plan-exceptions-save-break, .working-plan-exceptions-cancel-break').removeClass('d-none');
$tr.find('select,input:text').addClass('form-control input-sm')
$('.working-plan-exceptions-add-break').prop('disabled', true);
}
function onDeleteBreakClick() {
$(this).closest('tr').remove();
}
function onSaveBreakClick() {
// Break's start time must always be prior to break's end.
var $tr = $(this).closest('tr');
var start = Date.parse($tr.find('.working-plan-exceptions-break-start input').val());
var end = Date.parse($tr.find('.working-plan-exceptions-break-end input').val());
if (start > end) {
$tr.find('.working-plan-exceptions-break-end input')
.val(start.addHours(1).toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm'));
}
enableSubmit = true;
$tr.find('.editable .submit-editable').trigger('click');
enableSubmit = false;
$tr.find('.working-plan-exceptions-save-break, .working-plan-exceptions-cancel-break').addClass('d-none');
$tr.closest('table').find('.working-plan-exceptions-edit-break, .working-plan-exceptions-delete-break').removeClass('d-none');
$('.working-plan-exceptions-add-break').prop('disabled', false);
}
function onCancelBreakClick() {
var $tr = $(this).closest('tr');
enableCancel = true;
$tr.find('.cancel-editable').trigger('click');
enableCancel = false;
$breaks.find('.working-plan-exceptions-edit-break, .working-plan-exceptions-delete-break').removeClass('d-none');
$tr.find('.working-plan-exceptions-save-break, .working-plan-exceptions-cancel-break').addClass('d-none');
$('.working-plan-exceptions-add-break').prop('disabled', false);
}
function initializeDatepicker($target) {
var dateFormat;
switch (GlobalVariables.dateFormat) {
case 'DMY':
dateFormat = 'dd/mm/yy';
break;
case 'MDY':
dateFormat = 'mm/dd/yy';
break;
case 'YMD':
dateFormat = 'yy/mm/dd';
break;
default:
throw new Error('Invalid date format setting provided: ' + GlobalVariables.dateFormat);
}
$target.datepicker({
dateFormat: dateFormat,
firstDay: GeneralFunctions.getWeekDayId(GlobalVariables.firstWeekday),
minDate: 0,
defaultDate: Date.today(),
dayNames: [
EALang.sunday, EALang.monday, EALang.tuesday, EALang.wednesday,
EALang.thursday, EALang.friday, EALang.saturday],
dayNamesShort: [EALang.sunday.substr(0, 3), EALang.monday.substr(0, 3),
EALang.tuesday.substr(0, 3), EALang.wednesday.substr(0, 3),
EALang.thursday.substr(0, 3), EALang.friday.substr(0, 3),
EALang.saturday.substr(0, 3)],
dayNamesMin: [EALang.sunday.substr(0, 2), EALang.monday.substr(0, 2),
EALang.tuesday.substr(0, 2), EALang.wednesday.substr(0, 2),
EALang.thursday.substr(0, 2), EALang.friday.substr(0, 2),
EALang.saturday.substr(0, 2)],
monthNames: [EALang.january, EALang.february, EALang.march, EALang.april,
EALang.may, EALang.june, EALang.july, EALang.august, EALang.september,
EALang.october, EALang.november, EALang.december],
prevText: EALang.previous,
nextText: EALang.next,
currentText: EALang.now,
closeText: EALang.close,
});
}
function initializeTimepicker($target) {
$target.timepicker({
timeFormat: GlobalVariables.timeFormat === 'regular' ? 'h:mm TT' : 'HH:mm',
currentText: EALang.now,
closeText: EALang.close,
timeOnlyTitle: EALang.select_time,
timeText: EALang.time,
hourText: EALang.hour,
minuteText: EALang.minutes
});
}
initializeDatepicker($date);
initializeTimepicker($start);
initializeTimepicker($end);
$modal
.on('hidden.bs.modal', onModalHidden)
.on('click', '.working-plan-exceptions-add-break', onAddBreakClick)
.on('click', '.working-plan-exceptions-edit-break', onEditBreakClick)
.on('click', '.working-plan-exceptions-delete-break', onDeleteBreakClick)
.on('click', '.working-plan-exceptions-save-break', onSaveBreakClick)
.on('click', '.working-plan-exceptions-cancel-break', onCancelBreakClick);
$save.on('click', onSaveClick);
window.WorkingPlanExceptionsModal = {
add: add,
edit: edit,
};
});

View File

@ -335,6 +335,18 @@ You can also try the GET requests with your browser by navigating to the respect
},
"saturday":null,
"sunday":null
},
"workingPlanExceptions": {
"2020-01-01": {
"start": "08:00",
"end": "20:00",
"breaks":[
{
"start": "12:00",
"end": "14:00"
}
]
}
}
}
}

View File

@ -59,6 +59,7 @@ class Providers implements ParsersInterface {
'syncFutureDays' => $response['settings']['sync_future_days'] !== NULL ? (int)$response['settings']['sync_future_days'] : NULL,
'syncPastDays' => $response['settings']['sync_past_days'] !== NULL ? (int)$response['settings']['sync_past_days'] : NULL,
'workingPlan' => json_decode($response['settings']['working_plan'], TRUE),
'workingPlanExceptions' => json_decode($response['settings']['working_plan_exceptions'], TRUE),
];
}
@ -193,6 +194,11 @@ class Providers implements ParsersInterface {
{
$decodedRequest['settings']['working_plan'] = json_encode($request['settings']['workingPlan']);
}
if ( ! empty($request['settings']['workingPlanExceptions']))
{
$decodedRequest['settings']['working_plan_exceptions'] = json_encode($request['settings']['workingPlanExceptions']);
}
}
$request = $decodedRequest;