Added new button for applying the global working plan to all providers (#551).

This commit is contained in:
Alex Tselegidis 2020-03-29 19:25:23 +02:00
parent 20b8557cd9
commit 513b0101eb
28 changed files with 158 additions and 0 deletions

View file

@ -1739,4 +1739,38 @@ class Backend_api extends CI_Controller {
->set_output(json_encode(['exceptions' => [exceptionToJavaScript($exc)]]));
}
}
/**
* Apply global working plan to all providers.
*/
public function ajax_apply_global_working_plan()
{
try
{
if ($this->privileges[PRIV_SYSTEM_SETTINGS]['edit'] == FALSE)
{
throw new Exception('You do not have the required privileges for this task.');
}
$working_plan = $this->input->post('working_plan');
$this->load->model('providers_model');
$providers = $this->providers_model->get_batch();
foreach ($providers as $provider)
{
$this->providers_model->set_setting('working_plan', $working_plan, $provider['id']);
}
$this->output
->set_content_type('application/json')
->set_output(json_encode(AJAX_SUCCESS));
} catch (Exception $exc)
{
$this->output
->set_content_type('application/json')
->set_output(json_encode(['exceptions' => [exceptionToJavaScript($exc)]]));
}
}
}

View file

@ -310,3 +310,6 @@ $lang['require_phone_number_hint'] = 'When enabled, customers and users will nee
$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';

View file

@ -310,3 +310,6 @@ $lang['require_phone_number_hint'] = 'When enabled, customers and users will nee
$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';

View file

@ -310,3 +310,6 @@ $lang['require_phone_number_hint'] = 'When enabled, customers and users will nee
$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';

View file

@ -310,3 +310,6 @@ $lang['require_phone_number_hint'] = 'When enabled, customers and users will nee
$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';

View file

@ -310,3 +310,6 @@ $lang['require_phone_number_hint'] = 'When enabled, customers and users will nee
$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';

View file

@ -310,3 +310,6 @@ $lang['require_phone_number_hint'] = 'When enabled, customers and users will nee
$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';

View file

@ -310,3 +310,6 @@ $lang['require_phone_number_hint'] = 'When enabled, customers and users will nee
$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';

View file

@ -310,3 +310,6 @@ $lang['require_phone_number_hint'] = 'When enabled, customers and users will nee
$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';

View file

@ -310,3 +310,6 @@ $lang['require_phone_number_hint'] = 'When enabled, customers and users will nee
$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';

View file

@ -310,3 +310,6 @@ $lang['require_phone_number_hint'] = 'When enabled, customers and users will nee
$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';

View file

@ -310,3 +310,6 @@ $lang['require_phone_number_hint'] = 'When enabled, customers and users will nee
$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';

View file

@ -310,3 +310,6 @@ $lang['require_phone_number_hint'] = 'When enabled, customers and users will nee
$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';

View file

@ -310,3 +310,6 @@ $lang['require_phone_number_hint'] = 'When enabled, customers and users will nee
$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';

View file

@ -310,3 +310,6 @@ $lang['require_phone_number_hint'] = 'When enabled, customers and users will nee
$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';

View file

@ -310,3 +310,6 @@ $lang['require_phone_number_hint'] = 'When enabled, customers and users will nee
$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';

View file

@ -310,3 +310,6 @@ $lang['require_phone_number_hint'] = 'When enabled, customers and users will nee
$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';

View file

@ -310,3 +310,6 @@ $lang['require_phone_number_hint'] = 'When enabled, customers and users will nee
$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';

View file

@ -310,3 +310,6 @@ $lang['require_phone_number_hint'] = 'When enabled, customers and users will nee
$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';

View file

@ -310,3 +310,6 @@ $lang['require_phone_number_hint'] = 'When enabled, customers and users will nee
$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';

View file

@ -310,3 +310,6 @@ $lang['require_phone_number_hint'] = 'When enabled, customers and users will nee
$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';

View file

@ -310,5 +310,11 @@ $lang['require_phone_number_hint'] = 'When enabled, customers and users will nee
$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['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';

View file

@ -310,3 +310,6 @@ $lang['require_phone_number_hint'] = 'When enabled, customers and users will nee
$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';

View file

@ -310,3 +310,6 @@ $lang['require_phone_number_hint'] = 'When enabled, customers and users will nee
$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';

View file

@ -310,3 +310,6 @@ $lang['require_phone_number_hint'] = 'When enabled, customers and users will nee
$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';

View file

@ -310,3 +310,6 @@ $lang['require_phone_number_hint'] = 'When enabled, customers and users will nee
$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';

View file

@ -244,6 +244,13 @@
<tbody><!-- Dynamic Content --></tbody>
</table>
<div class="text-right">
<button class="btn btn-default" id="apply-global-working-plan" type="button">
<span class="glyphicon glyphicon-ok"></span>
<?= lang('apply_to_all_providers') ?>
</button>
</div>
<br>
<h4><?= lang('book_advance_timeout') ?></h4>

View file

@ -236,6 +236,45 @@ window.BackendSettings = window.BackendSettings || {};
}
}, 'json').fail(GeneralFunctions.ajaxFailureHandler);
});
/**
* Event: Apply Global Working Plan
*/
$('#apply-global-working-plan').on('click', function() {
var buttons = [
{
text: 'OK',
click: function() {
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_apply_global_working_plan';
var postData = {
csrfToken: GlobalVariables.csrfToken,
working_plan: JSON.stringify(exports.wp.get()),
};
$.post(postUrl, postData, function (response) {
if (!GeneralFunctions.handleAjaxExceptions(response)) {
return;
}
Backend.displayNotification(EALang.working_plans_got_updated);
}, 'json')
.fail(GeneralFunctions.ajaxFailureHandler)
.always(function() {
$('#message_box').dialog('close');
});
}
},
{
text: EALang.cancel,
click: function() {
$('#message_box').dialog('close');
}
}
];
GeneralFunctions.displayMessageBox(EALang.working_plan, EALang.overwrite_existing_working_plans, buttons);
});
}
})(window.BackendSettings);