mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-10 10:02:33 +03:00
Replace the global App.Vars with the "vars" helper method, which is more appropriate due to the dynamic load of script vars.
This commit is contained in:
parent
ca4e58313a
commit
e93565500d
45 changed files with 323 additions and 314 deletions
|
@ -4,6 +4,16 @@
|
|||
*/
|
||||
?>
|
||||
<script <?= $attributes ?>>
|
||||
window.App.Vars = <?= json_encode(script_vars()) ?>
|
||||
window.vars = (function () {
|
||||
const vars = <?= json_encode(script_vars()) ?>;
|
||||
|
||||
return (key) => {
|
||||
if (!key) {
|
||||
return vars;
|
||||
}
|
||||
|
||||
return vars[key] || undefined;
|
||||
};
|
||||
})();
|
||||
</script>
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ window.App = (function () {
|
|||
Lang: {},
|
||||
Layouts: {},
|
||||
Pages: {},
|
||||
Utils: {},
|
||||
Vars: {}
|
||||
Utils: {}
|
||||
};
|
||||
})();
|
||||
|
|
|
@ -48,12 +48,12 @@ App.Components.AppointmentsModal = (function () {
|
|||
function updateTimezone() {
|
||||
const providerId = $selectProvider.val();
|
||||
|
||||
const provider = App.Vars.available_providers.find(function (availableProvider) {
|
||||
const provider = vars('available_providers').find(function (availableProvider) {
|
||||
return Number(availableProvider.id) === Number(providerId);
|
||||
});
|
||||
|
||||
if (provider && provider.timezone) {
|
||||
$('.provider-timezone').text(App.Vars.timezones[provider.timezone]);
|
||||
$('.provider-timezone').text(vars('timezones')[provider.timezone]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ App.Components.AppointmentsModal = (function () {
|
|||
if ($selectFilterItem.find('option:selected').attr('type') === 'provider') {
|
||||
const providerId = $('#select-filter-item').val();
|
||||
|
||||
const providers = App.Vars.available_providers.filter(
|
||||
const providers = vars('available_providers').filter(
|
||||
(provider) => Number(provider.id) === Number(providerId)
|
||||
);
|
||||
|
||||
|
@ -163,7 +163,7 @@ App.Components.AppointmentsModal = (function () {
|
|||
|
||||
const serviceId = $selectService.val();
|
||||
|
||||
const service = App.Vars.available_services.find(
|
||||
const service = vars('available_services').find(
|
||||
(availableService) => Number(availableService.id) === Number(serviceId)
|
||||
);
|
||||
|
||||
|
@ -184,14 +184,14 @@ App.Components.AppointmentsModal = (function () {
|
|||
}
|
||||
|
||||
$startDatetime.val(
|
||||
App.Utils.Date.format(startMoment.toDate(), App.Vars.date_format, App.Vars.time_format, true)
|
||||
App.Utils.Date.format(startMoment.toDate(), vars('date_format'), vars('time_format'), true)
|
||||
);
|
||||
|
||||
$endDatetime.val(
|
||||
App.Utils.Date.format(
|
||||
startMoment.add(duration, 'minutes').toDate(),
|
||||
App.Vars.date_format,
|
||||
App.Vars.time_format,
|
||||
vars('date_format'),
|
||||
vars('time_format'),
|
||||
true
|
||||
)
|
||||
);
|
||||
|
@ -213,7 +213,7 @@ App.Components.AppointmentsModal = (function () {
|
|||
$existingCustomersList.empty();
|
||||
$existingCustomersList.slideDown('slow');
|
||||
$filterExistingCustomers.fadeIn('slow').val('');
|
||||
App.Vars.customers.forEach(function (customer) {
|
||||
vars('customers').forEach(function (customer) {
|
||||
$('<div/>', {
|
||||
'data-id': customer.id,
|
||||
'text': customer.first_name + ' ' + customer.last_name
|
||||
|
@ -234,7 +234,7 @@ App.Components.AppointmentsModal = (function () {
|
|||
$appointmentsModal.on('click', '#existing-customers-list div', (event) => {
|
||||
const customerId = $(event.target).attr('data-id');
|
||||
|
||||
const customer = App.Vars.customers.find(function (customer) {
|
||||
const customer = vars('customers').find(function (customer) {
|
||||
return Number(customer.id) === Number(customerId);
|
||||
});
|
||||
|
||||
|
@ -281,13 +281,13 @@ App.Components.AppointmentsModal = (function () {
|
|||
}).appendTo($existingCustomersList);
|
||||
|
||||
// Verify if this customer is on the old customer list.
|
||||
const result = App.Vars.customers.filter((existingCustomer) => {
|
||||
const result = vars('customers').filter((existingCustomer) => {
|
||||
return Number(existingCustomer.id) === Number(customer.id);
|
||||
});
|
||||
|
||||
// Add it to the customer list.
|
||||
if (!result.length) {
|
||||
App.Vars.customers.push(customer);
|
||||
vars('customers').push(customer);
|
||||
}
|
||||
});
|
||||
})
|
||||
|
@ -295,7 +295,7 @@ App.Components.AppointmentsModal = (function () {
|
|||
// If there is any error on the request, search by the local client database.
|
||||
$existingCustomersList.empty();
|
||||
|
||||
App.Vars.customers.forEach((customer) => {
|
||||
vars('customers').forEach((customer) => {
|
||||
if (
|
||||
customer.first_name.toLowerCase().indexOf(keyword) !== -1 ||
|
||||
customer.last_name.toLowerCase().indexOf(keyword) !== -1 ||
|
||||
|
@ -331,7 +331,7 @@ App.Components.AppointmentsModal = (function () {
|
|||
$selectProvider.empty();
|
||||
|
||||
// Automatically update the service duration.
|
||||
const service = App.Vars.available_services.find((availableService) => {
|
||||
const service = vars('available_services').find((availableService) => {
|
||||
return Number(availableService.id) === Number(serviceId);
|
||||
});
|
||||
|
||||
|
@ -342,18 +342,18 @@ App.Components.AppointmentsModal = (function () {
|
|||
|
||||
// Update the providers select box.
|
||||
|
||||
App.Vars.available_providers.forEach((provider) => {
|
||||
vars('available_providers').forEach((provider) => {
|
||||
provider.services.forEach((providerServiceId) => {
|
||||
if (
|
||||
App.Vars.role_slug === App.Layouts.Backend.DB_SLUG_PROVIDER &&
|
||||
Number(provider.id) !== App.Vars.user_id
|
||||
vars('role_slug') === App.Layouts.Backend.DB_SLUG_PROVIDER &&
|
||||
Number(provider.id) !== vars('user_id')
|
||||
) {
|
||||
return; // continue
|
||||
}
|
||||
|
||||
if (
|
||||
App.Vars.role_slug === App.Layouts.Backend.DB_SLUG_SECRETARY &&
|
||||
App.Vars.secretaryProviders.indexOf(provider.id) === -1
|
||||
vars('role_slug') === App.Layouts.Backend.DB_SLUG_SECRETARY &&
|
||||
vars('secretary_providers').indexOf(provider.id) === -1
|
||||
) {
|
||||
return; // continue
|
||||
}
|
||||
|
@ -403,7 +403,7 @@ App.Components.AppointmentsModal = (function () {
|
|||
// Fill the providers list box with providers that can serve the appointment's service and then select the
|
||||
// user's provider.
|
||||
$selectProvider.empty();
|
||||
App.Vars.available_providers.forEach((provider) => {
|
||||
vars('available_providers').forEach((provider) => {
|
||||
const serviceId = $selectService.val();
|
||||
|
||||
const canProvideService =
|
||||
|
@ -426,7 +426,7 @@ App.Components.AppointmentsModal = (function () {
|
|||
// Get the selected service duration. It will be needed in order to calculate the appointment end datetime.
|
||||
const serviceId = $selectService.val();
|
||||
|
||||
const service = App.Vars.available_services.forEach((service) => Number(service.id) === Number(serviceId));
|
||||
const service = vars('available_services').forEach((service) => Number(service.id) === Number(serviceId));
|
||||
|
||||
const duration = service ? service.duration : 0;
|
||||
|
||||
|
@ -434,7 +434,7 @@ App.Components.AppointmentsModal = (function () {
|
|||
const endDatetime = moment().add(duration, 'minutes').toDate();
|
||||
let dateFormat;
|
||||
|
||||
switch (App.Vars.date_format) {
|
||||
switch (vars('date_format')) {
|
||||
case 'DMY':
|
||||
dateFormat = 'dd/mm/yy';
|
||||
break;
|
||||
|
@ -445,16 +445,16 @@ App.Components.AppointmentsModal = (function () {
|
|||
dateFormat = 'yy/mm/dd';
|
||||
break;
|
||||
default:
|
||||
throw new Error('Invalid App.Vars.date_format value.');
|
||||
throw new Error('Invalid date format value.');
|
||||
}
|
||||
|
||||
const firstWeekDay = App.Vars.first_weekday;
|
||||
const firstWeekDay = vars('first_weekday');
|
||||
|
||||
const firstWeekDayNumber = App.Utils.Date.getWeekdayId(firstWeekDay);
|
||||
|
||||
$startDatetime.datetimepicker({
|
||||
dateFormat: dateFormat,
|
||||
timeFormat: App.Vars.time_format === 'regular' ? 'h:mm tt' : 'HH:mm',
|
||||
timeFormat: vars('time_format') === 'regular' ? 'h:mm tt' : 'HH:mm',
|
||||
|
||||
// Translation
|
||||
dayNames: [
|
||||
|
@ -511,7 +511,7 @@ App.Components.AppointmentsModal = (function () {
|
|||
const serviceId = $selectService.val();
|
||||
|
||||
// Automatically update the #end-datetime DateTimePicker based on service duration.
|
||||
const service = App.Vars.available_services.find(
|
||||
const service = vars('available_services').find(
|
||||
(availableService) => Number(availableService.id) === Number(serviceId)
|
||||
);
|
||||
|
||||
|
@ -523,7 +523,7 @@ App.Components.AppointmentsModal = (function () {
|
|||
|
||||
$endDatetime.datetimepicker({
|
||||
dateFormat: dateFormat,
|
||||
timeFormat: App.Vars.time_format === 'regular' ? 'h:mm tt' : 'HH:mm',
|
||||
timeFormat: vars('time_format') === 'regular' ? 'h:mm tt' : 'HH:mm',
|
||||
|
||||
// Translation
|
||||
dayNames: [
|
||||
|
|
|
@ -129,13 +129,13 @@ App.Components.UnavailabilitiesModal = (function () {
|
|||
}
|
||||
|
||||
$unavailabilityStart.val(
|
||||
App.Utils.Date.format(startMoment.toDate(), App.Vars.date_format, App.Vars.time_format, true)
|
||||
App.Utils.Date.format(startMoment.toDate(), vars('date_format'), vars('time_format'), true)
|
||||
);
|
||||
$unavailabilityEnd.val(
|
||||
App.Utils.Date.format(
|
||||
startMoment.add(1, 'hour').toDate(),
|
||||
App.Vars.date_format,
|
||||
App.Vars.time_format,
|
||||
vars('date_format'),
|
||||
vars('time_format'),
|
||||
true
|
||||
)
|
||||
);
|
||||
|
@ -154,18 +154,18 @@ App.Components.UnavailabilitiesModal = (function () {
|
|||
$unavailabilityId.val('');
|
||||
|
||||
// Set default time values
|
||||
const start = App.Utils.Date.format(moment().toDate(), App.Vars.date_format, App.Vars.time_format, true);
|
||||
const start = App.Utils.Date.format(moment().toDate(), vars('date_format'), vars('time_format'), true);
|
||||
|
||||
const end = App.Utils.Date.format(
|
||||
moment().add(1, 'hour').toDate(),
|
||||
App.Vars.date_format,
|
||||
App.Vars.time_format,
|
||||
vars('date_format'),
|
||||
vars('time_format'),
|
||||
true
|
||||
);
|
||||
|
||||
let dateFormat;
|
||||
|
||||
switch (App.Vars.date_format) {
|
||||
switch (vars('date_format')) {
|
||||
case 'DMY':
|
||||
dateFormat = 'dd/mm/yy';
|
||||
break;
|
||||
|
@ -177,13 +177,13 @@ App.Components.UnavailabilitiesModal = (function () {
|
|||
break;
|
||||
}
|
||||
|
||||
const firstWeekday = App.Vars.first_weekday;
|
||||
const firstWeekday = vars('first_weekday');
|
||||
|
||||
const firstWeekdayId = App.Utils.Date.getWeekdayId(firstWeekday);
|
||||
|
||||
$unavailabilityStart.datetimepicker({
|
||||
dateFormat: dateFormat,
|
||||
timeFormat: App.Vars.time_format === 'regular' ? 'h:mm tt' : 'HH:mm',
|
||||
timeFormat: vars('time_format') === 'regular' ? 'h:mm tt' : 'HH:mm',
|
||||
|
||||
// Translation
|
||||
dayNames: [
|
||||
|
@ -241,7 +241,7 @@ App.Components.UnavailabilitiesModal = (function () {
|
|||
|
||||
$unavailabilityEnd.datetimepicker({
|
||||
dateFormat: dateFormat,
|
||||
timeFormat: App.Vars.time_format === 'regular' ? 'h:mm tt' : 'HH:mm',
|
||||
timeFormat: vars('time_format') === 'regular' ? 'h:mm tt' : 'HH:mm',
|
||||
|
||||
// Translation
|
||||
dayNames: [
|
||||
|
@ -305,8 +305,8 @@ App.Components.UnavailabilitiesModal = (function () {
|
|||
* Initialize the module.
|
||||
*/
|
||||
function initialize() {
|
||||
for (const index in App.Vars.available_providers) {
|
||||
const provider = App.Vars.available_providers[index];
|
||||
for (const index in vars('available_providers')) {
|
||||
const provider = vars('available_providers')[index];
|
||||
|
||||
$unavailabilityProvider.append(new Option(provider.first_name + ' ' + provider.last_name, provider.id));
|
||||
}
|
||||
|
|
|
@ -92,8 +92,8 @@ App.Components.WorkingPlanExceptionsModal = (function () {
|
|||
const end = $tr.find('.working-plan-exceptions-break-end').text();
|
||||
|
||||
breaks.push({
|
||||
start: moment(start, App.Vars.time_format === 'regular' ? 'h:mm a' : 'HH:mm').format('HH:mm'),
|
||||
end: moment(end, App.Vars.time_format === 'regular' ? 'h:mm a' : 'HH:mm').format('HH:mm')
|
||||
start: moment(start, vars('time_format') === 'regular' ? 'h:mm a' : 'HH:mm').format('HH:mm'),
|
||||
end: moment(end, vars('time_format') === 'regular' ? 'h:mm a' : 'HH:mm').format('HH:mm')
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -226,7 +226,7 @@ App.Components.WorkingPlanExceptionsModal = (function () {
|
|||
* @return {jQuery}
|
||||
*/
|
||||
function renderBreakRow(breakPeriod) {
|
||||
const timeFormat = App.Vars.time_format === 'regular' ? 'h:mm a' : 'HH:mm';
|
||||
const timeFormat = vars('time_format') === 'regular' ? 'h:mm a' : 'HH:mm';
|
||||
|
||||
return $('<tr/>', {
|
||||
'html': [
|
||||
|
@ -346,16 +346,16 @@ App.Components.WorkingPlanExceptionsModal = (function () {
|
|||
const $tr = $(this).closest('tr');
|
||||
const start = moment(
|
||||
$tr.find('.working-plan-exceptions-break-start input').val(),
|
||||
App.Vars.time_format === 'regular' ? 'h:mm a' : 'HH:mm'
|
||||
vars('time_format') === 'regular' ? 'h:mm a' : 'HH:mm'
|
||||
);
|
||||
const end = moment(
|
||||
$tr.find('.working-plan-exceptions-break-end input').val(),
|
||||
App.Vars.time_format === 'regular' ? 'h:mm a' : 'HH:mm'
|
||||
vars('time_format') === 'regular' ? 'h:mm a' : 'HH:mm'
|
||||
);
|
||||
|
||||
if (start > end) {
|
||||
$tr.find('.working-plan-exceptions-break-end input').val(
|
||||
start.add(1, 'hour').format(App.Vars.time_format === 'regular' ? 'h:mm a' : 'HH:mm')
|
||||
start.add(1, 'hour').format(vars('time_format') === 'regular' ? 'h:mm a' : 'HH:mm')
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -394,7 +394,7 @@ App.Components.WorkingPlanExceptionsModal = (function () {
|
|||
function initializeDatepicker($target) {
|
||||
let dateFormat;
|
||||
|
||||
switch (App.Vars.date_format) {
|
||||
switch (vars('date_format')) {
|
||||
case 'DMY':
|
||||
dateFormat = 'dd/mm/yy';
|
||||
break;
|
||||
|
@ -408,12 +408,12 @@ App.Components.WorkingPlanExceptionsModal = (function () {
|
|||
break;
|
||||
|
||||
default:
|
||||
throw new Error('Invalid date format setting provided: ' + App.Vars.date_format);
|
||||
throw new Error('Invalid date format setting provided: ' + vars('date_format'));
|
||||
}
|
||||
|
||||
$target.datepicker({
|
||||
dateFormat: dateFormat,
|
||||
firstDay: App.Utils.Date.getWeekdayId(App.Vars.first_weekday),
|
||||
firstDay: App.Utils.Date.getWeekdayId(vars('first_weekday')),
|
||||
minDate: 0,
|
||||
defaultDate: moment().toDate(),
|
||||
dayNames: [
|
||||
|
@ -471,7 +471,7 @@ App.Components.WorkingPlanExceptionsModal = (function () {
|
|||
*/
|
||||
function initializeTimepicker($target) {
|
||||
$target.timepicker({
|
||||
timeFormat: App.Vars.time_format === 'regular' ? 'h:mm tt' : 'HH:mm',
|
||||
timeFormat: vars('time_format') === 'regular' ? 'h:mm tt' : 'HH:mm',
|
||||
currentText: App.Lang.now,
|
||||
closeText: App.Lang.close,
|
||||
timeOnlyTitle: App.Lang.select_time,
|
||||
|
|
|
@ -26,7 +26,7 @@ App.Http.Account = (function () {
|
|||
const url = App.Utils.Url.siteUrl('account/save');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
account
|
||||
};
|
||||
|
||||
|
@ -45,7 +45,7 @@ App.Http.Account = (function () {
|
|||
const url = App.Utils.Url.siteUrl('account/validate_username');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
user_id: userId,
|
||||
username
|
||||
};
|
||||
|
@ -62,7 +62,7 @@ App.Http.Account = (function () {
|
|||
const url = App.Utils.Url.siteUrl('account/change_language');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
language
|
||||
};
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ App.Http.Admins = (function () {
|
|||
const url = App.Utils.Url.siteUrl('admins/create');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
admin: admin
|
||||
};
|
||||
|
||||
|
@ -55,7 +55,7 @@ App.Http.Admins = (function () {
|
|||
const url = App.Utils.Url.siteUrl('admins/update');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
admin: admin
|
||||
};
|
||||
|
||||
|
@ -73,7 +73,7 @@ App.Http.Admins = (function () {
|
|||
const url = App.Utils.Url.siteUrl('admins/destroy');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
admin_id: adminId
|
||||
};
|
||||
|
||||
|
@ -94,7 +94,7 @@ App.Http.Admins = (function () {
|
|||
const url = App.Utils.Url.siteUrl('admins/search');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
keyword,
|
||||
limit,
|
||||
offset,
|
||||
|
@ -115,7 +115,7 @@ App.Http.Admins = (function () {
|
|||
const url = App.Utils.Url.siteUrl('admins/find');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
admin_id: adminId
|
||||
};
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ App.Http.Appointments = (function () {
|
|||
const url = App.Utils.Url.siteUrl('appointments/create');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
appointment: appointment
|
||||
};
|
||||
|
||||
|
@ -55,7 +55,7 @@ App.Http.Appointments = (function () {
|
|||
const url = App.Utils.Url.siteUrl('appointments/update');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
appointment: appointment
|
||||
};
|
||||
|
||||
|
@ -73,7 +73,7 @@ App.Http.Appointments = (function () {
|
|||
const url = App.Utils.Url.siteUrl('appointments/destroy');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
appointment_id: appointmentId
|
||||
};
|
||||
|
||||
|
@ -94,7 +94,7 @@ App.Http.Appointments = (function () {
|
|||
const url = App.Utils.Url.siteUrl('appointments/search');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
keyword,
|
||||
limit,
|
||||
offset,
|
||||
|
@ -115,7 +115,7 @@ App.Http.Appointments = (function () {
|
|||
const url = App.Utils.Url.siteUrl('appointments/find');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
appointment_id: appointmentId
|
||||
};
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ App.Http.Booking = (function () {
|
|||
// Default value of duration (in minutes).
|
||||
let serviceDuration = 15;
|
||||
|
||||
const service = App.Vars.available_services.find(
|
||||
const service = vars('available_services').find(
|
||||
(availableService) => Number(availableService.id) === Number(serviceId)
|
||||
);
|
||||
|
||||
|
@ -52,13 +52,13 @@ App.Http.Booking = (function () {
|
|||
}
|
||||
|
||||
// If the manage mode is true then the appointment's start date should return as available too.
|
||||
const appointmentId = App.Pages.Booking.manageMode ? App.Vars.appointment_data.id : null;
|
||||
const appointmentId = App.Pages.Booking.manageMode ? vars('appointment_data').id : null;
|
||||
|
||||
// Make ajax post request and get the available hours.
|
||||
const url = App.Utils.Url.siteUrl('booking/get_available_hours');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
service_id: $selectService.val(),
|
||||
provider_id: $selectProvider.val(),
|
||||
selected_date: selectedDate,
|
||||
|
@ -74,7 +74,7 @@ App.Http.Booking = (function () {
|
|||
let providerId = $selectProvider.val();
|
||||
|
||||
if (providerId === 'any-provider') {
|
||||
for (const availableProvider of App.Vars.available_providers) {
|
||||
for (const availableProvider of vars('available_providers')) {
|
||||
if (availableProvider.services.indexOf(Number(serviceId)) !== -1) {
|
||||
providerId = availableProvider.id; // Use first available provider.
|
||||
break;
|
||||
|
@ -82,7 +82,7 @@ App.Http.Booking = (function () {
|
|||
}
|
||||
}
|
||||
|
||||
const provider = App.Vars.available_providers.find(
|
||||
const provider = vars('available_providers').find(
|
||||
(availableProvider) => Number(providerId) === Number(availableProvider.id)
|
||||
);
|
||||
|
||||
|
@ -92,7 +92,7 @@ App.Http.Booking = (function () {
|
|||
|
||||
const providerTimezone = provider.timezone;
|
||||
const selectedTimezone = $('#select-timezone').val();
|
||||
const timeFormat = App.Vars.time_format === 'regular' ? 'h:mm a' : 'HH:mm';
|
||||
const timeFormat = vars('time_format') === 'regular' ? 'h:mm a' : 'HH:mm';
|
||||
|
||||
response.forEach((availableHour) => {
|
||||
const availableHourMoment = moment
|
||||
|
@ -121,7 +121,7 @@ App.Http.Booking = (function () {
|
|||
.filter(
|
||||
(index, availableHourEl) =>
|
||||
$(availableHourEl).text() ===
|
||||
moment(App.Vars.appointment_data.start_datetime).format(timeFormat)
|
||||
moment(vars('appointment_data').start_datetime).format(timeFormat)
|
||||
)
|
||||
.addClass('selected-hour');
|
||||
} else {
|
||||
|
@ -158,7 +158,7 @@ App.Http.Booking = (function () {
|
|||
const formData = JSON.parse($('input[name="post_data"]').val());
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
post_data: formData
|
||||
};
|
||||
|
||||
|
@ -166,8 +166,8 @@ App.Http.Booking = (function () {
|
|||
data.captcha = $captchaText.val();
|
||||
}
|
||||
|
||||
if (App.Vars.manage_mode) {
|
||||
data.exclude_appointment_id = App.Vars.appointment_data.id;
|
||||
if (vars('manage_mode')) {
|
||||
data.exclude_appointment_id = vars('appointment_data').id;
|
||||
}
|
||||
|
||||
const url = App.Utils.Url.siteUrl('booking/register');
|
||||
|
@ -236,7 +236,7 @@ App.Http.Booking = (function () {
|
|||
return;
|
||||
}
|
||||
|
||||
const appointmentId = App.Pages.Booking.manageMode ? App.Vars.appointment_data.id : null;
|
||||
const appointmentId = App.Pages.Booking.manageMode ? vars('appointment_data').id : null;
|
||||
|
||||
const url = App.Utils.Url.siteUrl('booking/get_unavailable_dates');
|
||||
|
||||
|
@ -244,7 +244,7 @@ App.Http.Booking = (function () {
|
|||
provider_id: providerId,
|
||||
service_id: serviceId,
|
||||
selected_date: encodeURIComponent(selectedDateString),
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
manage_mode: App.Pages.Booking.manageMode,
|
||||
appointment_id: appointmentId
|
||||
};
|
||||
|
@ -275,7 +275,7 @@ App.Http.Booking = (function () {
|
|||
const selectedDate = selectedDateMoment.toDate();
|
||||
const numberOfDays = selectedDateMoment.daysInMonth();
|
||||
|
||||
if (setDate && !App.Vars.manage_mode) {
|
||||
if (setDate && !vars('manage_mode')) {
|
||||
for (let i = 1; i <= numberOfDays; i++) {
|
||||
const currentDate = new Date(selectedDate.getFullYear(), selectedDate.getMonth(), i);
|
||||
if (unavailableDates.indexOf(moment(currentDate).format('YYYY-MM-DD')) === -1) {
|
||||
|
@ -311,7 +311,7 @@ App.Http.Booking = (function () {
|
|||
const url = App.Utils.Url.siteUrl('consents/save_consent');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
consent: consent
|
||||
};
|
||||
|
||||
|
@ -327,12 +327,12 @@ App.Http.Booking = (function () {
|
|||
const url = App.Utils.Url.siteUrl('privacy/delete_personal_information');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
customer_token: customerToken
|
||||
};
|
||||
|
||||
$.post(url, data).done(() => {
|
||||
window.location.href = App.Vars.base_url;
|
||||
window.location.href = vars('base_url');
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ App.Http.BookingSettings = (function () {
|
|||
const url = App.Utils.Url.siteUrl('booking_settings/save');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
booking_settings: bookingSettings
|
||||
};
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ App.Http.BusinessSettings = (function () {
|
|||
const url = App.Utils.Url.siteUrl('business_settings/save');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
business_settings: businessSettings
|
||||
};
|
||||
|
||||
|
@ -44,7 +44,7 @@ App.Http.BusinessSettings = (function () {
|
|||
const url = App.Utils.Url.siteUrl('business_settings/apply_global_working_plan');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
working_plan: JSON.stringify(workingPlan)
|
||||
};
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ App.Http.Calendar = (function () {
|
|||
const url = App.Utils.Url.siteUrl('calendar/save_appointment');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
appointment_data: appointment
|
||||
};
|
||||
|
||||
|
@ -67,7 +67,7 @@ App.Http.Calendar = (function () {
|
|||
const url = App.Utils.Url.siteUrl('calendar/delete_appointment');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
appointment_id: appointmentId,
|
||||
delete_reason: deleteReason
|
||||
};
|
||||
|
@ -86,7 +86,7 @@ App.Http.Calendar = (function () {
|
|||
const url = App.Utils.Url.siteUrl('calendar/save_unavailable');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
unavailable: unavailable
|
||||
};
|
||||
|
||||
|
@ -114,7 +114,7 @@ App.Http.Calendar = (function () {
|
|||
const url = App.Utils.Url.siteUrl('calendar/delete_unavailable');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
unavailable_id: unavailableId
|
||||
};
|
||||
|
||||
|
@ -134,7 +134,7 @@ App.Http.Calendar = (function () {
|
|||
const url = App.Utils.Url.siteUrl('calendar/save_working_plan_exception');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
date: date,
|
||||
working_plan_exception: workingPlanException,
|
||||
provider_id: providerId
|
||||
|
@ -167,7 +167,7 @@ App.Http.Calendar = (function () {
|
|||
const url = App.Utils.Url.siteUrl('calendar/delete_working_plan_exception');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
date: date,
|
||||
provider_id: providerId
|
||||
};
|
||||
|
@ -199,7 +199,7 @@ App.Http.Calendar = (function () {
|
|||
const url = App.Utils.Url.siteUrl('calendar/get_calendar_appointments');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
record_id: recordId,
|
||||
start_date: moment(startDate).format('YYYY-MM-DD'),
|
||||
end_date: moment(endDate).format('YYYY-MM-DD'),
|
||||
|
@ -221,7 +221,7 @@ App.Http.Calendar = (function () {
|
|||
const url = App.Utils.Url.siteUrl('calendar/get_calendar_appointments_for_table_view');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
start_date: moment(startDate).format('YYYY-MM-DD'),
|
||||
end_date: moment(endDate).format('YYYY-MM-DD')
|
||||
};
|
||||
|
|
|
@ -37,7 +37,7 @@ App.Http.Categories = (function () {
|
|||
const url = App.Utils.Url.siteUrl('categories/create');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
category: category
|
||||
};
|
||||
|
||||
|
@ -55,7 +55,7 @@ App.Http.Categories = (function () {
|
|||
const url = App.Utils.Url.siteUrl('categories/update');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
category: category
|
||||
};
|
||||
|
||||
|
@ -73,7 +73,7 @@ App.Http.Categories = (function () {
|
|||
const url = App.Utils.Url.siteUrl('categories/destroy');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
category_id: categoryId
|
||||
};
|
||||
|
||||
|
@ -94,7 +94,7 @@ App.Http.Categories = (function () {
|
|||
const url = App.Utils.Url.siteUrl('categories/search');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
keyword,
|
||||
limit,
|
||||
offset,
|
||||
|
@ -115,7 +115,7 @@ App.Http.Categories = (function () {
|
|||
const url = App.Utils.Url.siteUrl('categories/find');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
category_id: categoryId
|
||||
};
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ App.Http.Customers = (function () {
|
|||
const url = App.Utils.Url.siteUrl('customers/create');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
customer: customer
|
||||
};
|
||||
|
||||
|
@ -55,7 +55,7 @@ App.Http.Customers = (function () {
|
|||
const url = App.Utils.Url.siteUrl('customers/update');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
customer: customer
|
||||
};
|
||||
|
||||
|
@ -73,7 +73,7 @@ App.Http.Customers = (function () {
|
|||
const url = App.Utils.Url.siteUrl('customers/destroy');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
customer_id: customerId
|
||||
};
|
||||
|
||||
|
@ -94,7 +94,7 @@ App.Http.Customers = (function () {
|
|||
const url = App.Utils.Url.siteUrl('customers/search');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
keyword,
|
||||
limit,
|
||||
offset,
|
||||
|
@ -115,7 +115,7 @@ App.Http.Customers = (function () {
|
|||
const url = App.Utils.Url.siteUrl('customers/find');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
customer_id: customerId
|
||||
};
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ App.Http.GeneralSettings = (function () {
|
|||
const url = App.Utils.Url.siteUrl('general_settings/save');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
general_settings: generalSettings
|
||||
};
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ App.Http.Google = (function () {
|
|||
const url = App.Utils.Url.siteUrl('google/select_google_calendar');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
provider_id: providerId,
|
||||
calendar_id: googleCalendarId
|
||||
};
|
||||
|
@ -46,7 +46,7 @@ App.Http.Google = (function () {
|
|||
const url = App.Utils.Url.siteUrl('google/disable_provider_sync');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
provider_id: providerId
|
||||
};
|
||||
|
||||
|
@ -64,7 +64,7 @@ App.Http.Google = (function () {
|
|||
const url = App.Utils.Url.siteUrl('google/get_google_calendars');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
provider_id: providerId
|
||||
};
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ App.Http.LegalSettings = (function () {
|
|||
const url = App.Utils.Url.siteUrl('legal_settings/save');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
legal_settings: legalSettings
|
||||
};
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ App.Http.Login = (function () {
|
|||
const url = App.Utils.Url.siteUrl('login/validate');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
username,
|
||||
password
|
||||
};
|
||||
|
|
|
@ -37,7 +37,7 @@ App.Http.Providers = (function () {
|
|||
const url = App.Utils.Url.siteUrl('providers/create');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
provider: provider
|
||||
};
|
||||
|
||||
|
@ -55,7 +55,7 @@ App.Http.Providers = (function () {
|
|||
const url = App.Utils.Url.siteUrl('providers/update');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
provider: provider
|
||||
};
|
||||
|
||||
|
@ -73,7 +73,7 @@ App.Http.Providers = (function () {
|
|||
const url = App.Utils.Url.siteUrl('providers/destroy');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
provider_id: providerId
|
||||
};
|
||||
|
||||
|
@ -94,7 +94,7 @@ App.Http.Providers = (function () {
|
|||
const url = App.Utils.Url.siteUrl('providers/search');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
keyword,
|
||||
limit,
|
||||
offset,
|
||||
|
@ -115,7 +115,7 @@ App.Http.Providers = (function () {
|
|||
const url = App.Utils.Url.siteUrl('providers/find');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
provider_id: providerId
|
||||
};
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ App.Http.Recovery = (function () {
|
|||
const url = App.Utils.Url.siteUrl('recovery/perform');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
username,
|
||||
email
|
||||
};
|
||||
|
|
|
@ -37,7 +37,7 @@ App.Http.Secretaries = (function () {
|
|||
const url = App.Utils.Url.siteUrl('secretaries/create');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
secretary: secretary
|
||||
};
|
||||
|
||||
|
@ -55,7 +55,7 @@ App.Http.Secretaries = (function () {
|
|||
const url = App.Utils.Url.siteUrl('secretaries/update');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
secretary: secretary
|
||||
};
|
||||
|
||||
|
@ -73,7 +73,7 @@ App.Http.Secretaries = (function () {
|
|||
const url = App.Utils.Url.siteUrl('secretaries/destroy');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
secretary_id: secretaryId
|
||||
};
|
||||
|
||||
|
@ -94,7 +94,7 @@ App.Http.Secretaries = (function () {
|
|||
const url = App.Utils.Url.siteUrl('secretaries/search');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
keyword,
|
||||
limit,
|
||||
offset,
|
||||
|
@ -115,7 +115,7 @@ App.Http.Secretaries = (function () {
|
|||
const url = App.Utils.Url.siteUrl('secretaries/find');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
secretary_id: secretaryId
|
||||
};
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ App.Http.Services = (function () {
|
|||
const url = App.Utils.Url.siteUrl('services/create');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
service: service
|
||||
};
|
||||
|
||||
|
@ -55,7 +55,7 @@ App.Http.Services = (function () {
|
|||
const url = App.Utils.Url.siteUrl('services/update');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
service: service
|
||||
};
|
||||
|
||||
|
@ -73,7 +73,7 @@ App.Http.Services = (function () {
|
|||
const url = App.Utils.Url.siteUrl('services/destroy');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
service_id: serviceId
|
||||
};
|
||||
|
||||
|
@ -94,7 +94,7 @@ App.Http.Services = (function () {
|
|||
const url = App.Utils.Url.siteUrl('services/search');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
keyword,
|
||||
limit,
|
||||
offset,
|
||||
|
@ -115,7 +115,7 @@ App.Http.Services = (function () {
|
|||
const url = App.Utils.Url.siteUrl('services/find');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
service_id: serviceId
|
||||
};
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ App.Http.Settings = (function () {
|
|||
const url = App.Utils.Url.siteUrl('settings/create');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
setting: setting
|
||||
};
|
||||
|
||||
|
@ -55,7 +55,7 @@ App.Http.Settings = (function () {
|
|||
const url = App.Utils.Url.siteUrl('settings/update');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
setting: setting
|
||||
};
|
||||
|
||||
|
@ -73,7 +73,7 @@ App.Http.Settings = (function () {
|
|||
const url = App.Utils.Url.siteUrl('settings/destroy');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
setting_id: settingId
|
||||
};
|
||||
|
||||
|
@ -94,7 +94,7 @@ App.Http.Settings = (function () {
|
|||
const url = App.Utils.Url.siteUrl('settings/search');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
keyword,
|
||||
limit,
|
||||
offset,
|
||||
|
@ -115,7 +115,7 @@ App.Http.Settings = (function () {
|
|||
const url = App.Utils.Url.siteUrl('settings/find');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
setting_id: settingId
|
||||
};
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ App.Http.Unavailabilities = (function () {
|
|||
const url = App.Utils.Url.siteUrl('unavailabilities/create');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
unavailability: unavailability
|
||||
};
|
||||
|
||||
|
@ -55,7 +55,7 @@ App.Http.Unavailabilities = (function () {
|
|||
const url = App.Utils.Url.siteUrl('unavailabilities/update');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
unavailability: unavailability
|
||||
};
|
||||
|
||||
|
@ -73,7 +73,7 @@ App.Http.Unavailabilities = (function () {
|
|||
const url = App.Utils.Url.siteUrl('unavailabilities/destroy');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
unavailability_id: unavailabilityId
|
||||
};
|
||||
|
||||
|
@ -94,7 +94,7 @@ App.Http.Unavailabilities = (function () {
|
|||
const url = App.Utils.Url.siteUrl('unavailabilities/search');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
keyword,
|
||||
limit,
|
||||
offset,
|
||||
|
@ -115,7 +115,7 @@ App.Http.Unavailabilities = (function () {
|
|||
const url = App.Utils.Url.siteUrl('unavailabilities/find');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
unavailability_id: unavailabilityId
|
||||
};
|
||||
|
||||
|
|
|
@ -180,7 +180,7 @@ App.Pages.Account = (function () {
|
|||
* Initialize the page.
|
||||
*/
|
||||
function initialize() {
|
||||
const account = App.Vars.account;
|
||||
const account = vars('account');
|
||||
|
||||
deserialize(account);
|
||||
|
||||
|
|
|
@ -281,9 +281,9 @@ App.Pages.Admins = (function () {
|
|||
throw new Error(App.Lang.passwords_mismatch);
|
||||
}
|
||||
|
||||
if ($password.val().length < App.Vars.min_password_length && $password.val() !== '') {
|
||||
if ($password.val().length < vars('min_password_length') && $password.val() !== '') {
|
||||
$('#admin-password, #admin-password-confirm').addClass('is-invalid');
|
||||
throw new Error(App.Lang.password_length_notice.replace('$number', BackendAdmins.MIN_PASSWORD_LENGTH));
|
||||
throw new Error(App.Lang.password_length_notice.replace('$number', vars('min_password_length')));
|
||||
}
|
||||
|
||||
// Validate user email.
|
||||
|
|
|
@ -60,7 +60,7 @@ App.Pages.Booking = (function () {
|
|||
* Initialize the module.
|
||||
*/
|
||||
function initialize() {
|
||||
if (App.Vars.display_cookie_notice) {
|
||||
if (vars('display_cookie_notice')) {
|
||||
cookieconsent.initialise({
|
||||
palette: {
|
||||
popup: {
|
||||
|
@ -89,12 +89,12 @@ App.Pages.Booking = (function () {
|
|||
);
|
||||
}
|
||||
|
||||
manageMode = App.Vars.manage_mode;
|
||||
manageMode = vars('manage_mode');
|
||||
|
||||
// Initialize page's components (tooltips, datepickers etc).
|
||||
tippy('[data-tippy-content]');
|
||||
|
||||
const weekdayId = App.Utils.Date.getWeekdayId(App.Vars.first_weekday);
|
||||
const weekdayId = App.Utils.Date.getWeekdayId(vars('first_weekday'));
|
||||
|
||||
$selectDate.datepicker({
|
||||
dateFormat: 'dd-mm-yy',
|
||||
|
@ -171,7 +171,7 @@ App.Pages.Booking = (function () {
|
|||
|
||||
// If the manage mode is true, the appointments data should be loaded by default.
|
||||
if (manageMode) {
|
||||
applyAppointmentData(App.Vars.appointment_data, App.Vars.provider_data, App.Vars.customer_data);
|
||||
applyAppointmentData(vars('appointment_data'), vars('provider_data'), vars('customer_data'));
|
||||
} else {
|
||||
// Check if a specific service was selected (via URL parameter).
|
||||
const selectedServiceId = App.Utils.Url.queryParam('service');
|
||||
|
@ -187,8 +187,8 @@ App.Pages.Booking = (function () {
|
|||
|
||||
if (selectedProviderId && $selectProvider.find('option[value="' + selectedProviderId + '"]').length === 0) {
|
||||
// Select a service of this provider in order to make the provider available in the select box.
|
||||
for (const index in App.Vars.available_providers) {
|
||||
const provider = App.Vars.available_providers[index];
|
||||
for (const index in vars('available_providers')) {
|
||||
const provider = vars('available_providers')[index];
|
||||
|
||||
if (provider.id === selectedProviderId && provider.services.length > 0) {
|
||||
$selectService.val(provider.services[0]).trigger('change');
|
||||
|
@ -249,7 +249,7 @@ App.Pages.Booking = (function () {
|
|||
|
||||
$selectProvider.empty();
|
||||
|
||||
App.Vars.available_providers.forEach((provider) => {
|
||||
vars('available_providers').forEach((provider) => {
|
||||
// If the current provider is able to provide the selected service, add him to the list box.
|
||||
const canServeService =
|
||||
provider.services.filter((providerServiceId) => Number(providerServiceId) === Number(serviceId))
|
||||
|
@ -261,7 +261,7 @@ App.Pages.Booking = (function () {
|
|||
});
|
||||
|
||||
// Add the "Any Provider" entry.
|
||||
if ($selectProvider.find('option').length >= 1 && App.Vars.display_any_provider === '1') {
|
||||
if ($selectProvider.find('option').length >= 1 && vars('display_any_provider') === '1') {
|
||||
$selectProvider.prepend(new Option('- ' + App.Lang.any_provider + ' -', 'any-provider', true, true));
|
||||
}
|
||||
|
||||
|
@ -453,7 +453,7 @@ App.Pages.Booking = (function () {
|
|||
{
|
||||
text: App.Lang.delete,
|
||||
click: () => {
|
||||
App.Http.Booking.deletePersonalInformation(App.Vars.customer_token);
|
||||
App.Http.Booking.deletePersonalInformation(vars('customer_token'));
|
||||
}
|
||||
}
|
||||
];
|
||||
|
@ -556,14 +556,14 @@ App.Pages.Booking = (function () {
|
|||
let selectedDate = $selectDate.datepicker('getDate');
|
||||
|
||||
if (selectedDate !== null) {
|
||||
selectedDate = App.Utils.Date.format(selectedDate, App.Vars.date_format, App.Vars.time_format);
|
||||
selectedDate = App.Utils.Date.format(selectedDate, vars('date_format'), vars('time_format'));
|
||||
}
|
||||
|
||||
const serviceId = $selectService.val();
|
||||
let servicePrice = '';
|
||||
let serviceCurrency = '';
|
||||
|
||||
App.Vars.available_services.forEach((service) => {
|
||||
vars('available_services').forEach((service) => {
|
||||
if (Number(service.id) === Number(serviceId) && Number(service.price) > 0) {
|
||||
servicePrice = service.price;
|
||||
serviceCurrency = service.currency;
|
||||
|
@ -689,10 +689,10 @@ App.Pages.Booking = (function () {
|
|||
data.manage_mode = manageMode;
|
||||
|
||||
if (manageMode) {
|
||||
data.appointment.id = App.Vars.appointment_data.id;
|
||||
data.customer.id = App.Vars.customer_data.id;
|
||||
data.appointment.id = vars('appointment_data').id;
|
||||
data.customer.id = vars('customer_data').id;
|
||||
}
|
||||
$('input[name="csrfToken"]').val(App.Vars.csrf_token);
|
||||
$('input[name="csrfToken"]').val(vars('csrf_token'));
|
||||
$('input[name="post_data"]').val(JSON.stringify(data));
|
||||
}
|
||||
|
||||
|
@ -707,7 +707,7 @@ App.Pages.Booking = (function () {
|
|||
// Find selected service duration.
|
||||
const serviceId = $selectService.val();
|
||||
|
||||
const service = App.Vars.available_services.find(
|
||||
const service = vars('available_services').find(
|
||||
(availableService) => Number(availableService.id) === Number(serviceId)
|
||||
);
|
||||
|
||||
|
@ -784,7 +784,7 @@ App.Pages.Booking = (function () {
|
|||
|
||||
$serviceDescription.empty();
|
||||
|
||||
const service = App.Vars.available_services.find(function (availableService) {
|
||||
const service = vars('available_services').find(function (availableService) {
|
||||
return Number(availableService.id) === Number(serviceId);
|
||||
});
|
||||
|
||||
|
|
|
@ -16,13 +16,14 @@
|
|||
*/
|
||||
App.Pages.BookingConfirmation = (function () {
|
||||
const $addToGoogleCalendar = $('#add-to-google-calendar');
|
||||
|
||||
/**
|
||||
* Handle Authorization Result
|
||||
*
|
||||
* This method handles the authorization result. If the user granted access to his data, then the
|
||||
* appointment is going to be added to his calendar.
|
||||
*
|
||||
* @param {Boolean} authResult The user's authorization result.
|
||||
* @param {Object} authResult The user's authorization result.
|
||||
*/
|
||||
function handleAuthResult(authResult) {
|
||||
try {
|
||||
|
@ -31,15 +32,15 @@ App.Pages.BookingConfirmation = (function () {
|
|||
}
|
||||
|
||||
// The user has granted access, add the appointment to his calendar. Before making the event.insert request
|
||||
// the the event resource data must be prepared.
|
||||
const providerData = App.Vars.provider_data;
|
||||
// the event resource data must be prepared.
|
||||
const providerData = vars('provider_data');
|
||||
|
||||
const appointmentData = App.Vars.appointment_data;
|
||||
const appointmentData = vars('appointment_data');
|
||||
|
||||
// Create a valid Google Calendar API resource for the new event.
|
||||
const resource = {
|
||||
summary: App.Vars.service_data.name,
|
||||
location: App.Vars.company_name,
|
||||
summary: vars('service_data').name,
|
||||
location: vars('company_name'),
|
||||
start: {
|
||||
dateTime: moment.tz(appointmentData.start_datetime, providerData.timezone).format()
|
||||
},
|
||||
|
@ -48,8 +49,8 @@ App.Pages.BookingConfirmation = (function () {
|
|||
},
|
||||
attendees: [
|
||||
{
|
||||
email: App.Vars.provider_data.email,
|
||||
displayName: App.Vars.provider_data.first_name + ' ' + App.Vars.provider_data.last_name
|
||||
email: vars('provider_data').email,
|
||||
displayName: vars('provider_data').first_name + ' ' + vars('provider_data').last_name
|
||||
}
|
||||
]
|
||||
};
|
||||
|
@ -120,12 +121,12 @@ App.Pages.BookingConfirmation = (function () {
|
|||
* Google is necessary.
|
||||
*/
|
||||
$addToGoogleCalendar.on('click', function () {
|
||||
gapi.client.setApiKey(App.Vars.google_api_key);
|
||||
gapi.client.setApiKey(vars('google_api_key'));
|
||||
|
||||
gapi.auth.authorize(
|
||||
{
|
||||
client_id: App.Vars.google_client_id,
|
||||
scope: App.Vars.google_api_scope,
|
||||
client_id: vars('google_client_id'),
|
||||
scope: vars('google_api_scope'),
|
||||
immediate: false
|
||||
},
|
||||
handleAuthResult
|
||||
|
|
|
@ -181,7 +181,7 @@ App.Pages.BookingSettings = (function () {
|
|||
* Initialize the module.
|
||||
*/
|
||||
function initialize() {
|
||||
const bookingSettings = App.Vars.booking_settings;
|
||||
const bookingSettings = vars('booking_settings');
|
||||
|
||||
deserialize(bookingSettings);
|
||||
|
||||
|
|
|
@ -131,13 +131,13 @@ App.Pages.BusinessSettings = (function () {
|
|||
* Initialize the module.
|
||||
*/
|
||||
function initialize() {
|
||||
const businessSettings = App.Vars.business_settings;
|
||||
const businessSettings = vars('business_settings');
|
||||
|
||||
deserialize(businessSettings);
|
||||
|
||||
let companyWorkingPlan = {};
|
||||
|
||||
App.Vars.business_settings.forEach((businessSetting) => {
|
||||
vars('business_settings').forEach((businessSetting) => {
|
||||
if (businessSetting.name === 'company_working_plan') {
|
||||
companyWorkingPlan = JSON.parse(businessSetting.value);
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ App.Pages.Calendar = (function () {
|
|||
$insertWorkingPlanException.on('click', () => {
|
||||
const providerId = $('#select-filter-item').val();
|
||||
|
||||
const provider = App.Vars.available_providers.find((availableProvider) => {
|
||||
const provider = vars('available_providers').find((availableProvider) => {
|
||||
return Number(availableProvider.id) === Number(providerId);
|
||||
});
|
||||
|
||||
|
@ -75,11 +75,11 @@ App.Pages.Calendar = (function () {
|
|||
|
||||
workingPlanExceptions[date] = workingPlanException;
|
||||
|
||||
for (let index in App.Vars.available_providers) {
|
||||
const availableProvider = App.Vars.available_providers[index];
|
||||
for (let index in vars('available_providers')) {
|
||||
const availableProvider = vars('available_providers')[index];
|
||||
|
||||
if (Number(availableProvider.id) === Number(providerId)) {
|
||||
App.Vars.available_providers[index].settings.working_plan_exceptions =
|
||||
vars('available_providers')[index].settings.working_plan_exceptions =
|
||||
JSON.stringify(workingPlanExceptions);
|
||||
break;
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ App.Pages.Calendar = (function () {
|
|||
*/
|
||||
function initialize() {
|
||||
// Load and initialize the calendar view.
|
||||
if (App.Vars.calendar_view === 'table') {
|
||||
if (vars('calendar_view') === 'table') {
|
||||
App.Utils.CalendarTableView.initialize();
|
||||
} else {
|
||||
App.Utils.CalendarDefaultView.initialize();
|
||||
|
|
|
@ -274,30 +274,30 @@ App.Pages.Customers = (function () {
|
|||
|
||||
customer.appointments.forEach((appointment) => {
|
||||
if (
|
||||
App.Vars.role_slug === App.Layouts.Backend.DB_SLUG_PROVIDER &&
|
||||
parseInt(appointment.id_users_provider) !== App.Vars.user_id
|
||||
vars('role_slug') === App.Layouts.Backend.DB_SLUG_PROVIDER &&
|
||||
parseInt(appointment.id_users_provider) !== vars('user_id')
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
App.Vars.role_slug === App.Layouts.Backend.DB_SLUG_SECRETARY &&
|
||||
App.Vars.secretary_providers.indexOf(appointment.id_users_provider) === -1
|
||||
vars('role_slug') === App.Layouts.Backend.DB_SLUG_SECRETARY &&
|
||||
vars('secretary_providers').indexOf(appointment.id_users_provider) === -1
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const start = App.Utils.Date.format(
|
||||
moment(appointment.start_datetime).toDate(),
|
||||
App.Vars.date_format,
|
||||
App.Vars.time_format,
|
||||
vars('date_format'),
|
||||
vars('time_format'),
|
||||
true
|
||||
);
|
||||
|
||||
const end = App.Utils.Date.format(
|
||||
moment(appointment.end_datetime).toDate(),
|
||||
App.Vars.date_format,
|
||||
App.Vars.time_format,
|
||||
vars('date_format'),
|
||||
vars('time_format'),
|
||||
true
|
||||
);
|
||||
|
||||
|
@ -342,7 +342,7 @@ App.Pages.Customers = (function () {
|
|||
// Timezone
|
||||
|
||||
$('<small/>', {
|
||||
'text': App.Vars.timezones[appointment.provider.timezone]
|
||||
'text': vars('timezones')[appointment.provider.timezone]
|
||||
})
|
||||
]
|
||||
}).appendTo('#customer-appointments');
|
||||
|
|
|
@ -92,7 +92,7 @@ App.Pages.GeneralSettings = (function () {
|
|||
* Initialize the module.
|
||||
*/
|
||||
function initialize() {
|
||||
const generalSettings = App.Vars.general_settings;
|
||||
const generalSettings = vars('general_settings');
|
||||
|
||||
deserialize(generalSettings);
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ App.Pages.Installation = (function () {
|
|||
const url = App.Utils.Url.siteUrl('installation/perform');
|
||||
|
||||
const data = {
|
||||
csrf_token: App.Vars.csrf_token,
|
||||
csrf_token: vars('csrf_token'),
|
||||
admin: getAdminData(),
|
||||
company: getCompanyData()
|
||||
};
|
||||
|
@ -162,7 +162,7 @@ App.Pages.Installation = (function () {
|
|||
}
|
||||
|
||||
// Validate the base URL setting (must not contain any trailing slash).
|
||||
if (App.Vars.base_url.slice(-1) === '/') {
|
||||
if (vars('base_url').slice(-1) === '/') {
|
||||
App.Utils.Message.show(
|
||||
'Invalid Configuration Detected',
|
||||
'Please remove any trailing slashes from your "BASE_URL" setting of the root "config.php" file and try again.'
|
||||
|
|
|
@ -145,7 +145,7 @@ App.Pages.LegalSettings = (function () {
|
|||
$termsAndConditionsContent.trumbowyg();
|
||||
$privacyPolicyContent.trumbowyg();
|
||||
|
||||
const legalSettings = App.Vars.legal_settings;
|
||||
const legalSettings = vars('legal_settings');
|
||||
|
||||
deserialize(legalSettings);
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ App.Pages.Login = (function () {
|
|||
|
||||
App.Http.Login.validate(username, password).done((response) => {
|
||||
if (response.success) {
|
||||
window.location.href = App.Vars.dest_url;
|
||||
window.location.href = vars('dest_url');
|
||||
} else {
|
||||
$alert.text(App.Lang.login_failed);
|
||||
$alert.removeClass('d-none alert-danger alert-success').addClass('alert-danger');
|
||||
|
|
|
@ -98,7 +98,7 @@ App.Pages.Providers = (function () {
|
|||
$('#provider-services input:checkbox').prop('disabled', false);
|
||||
|
||||
// Apply default working plan
|
||||
const companyWorkingPlan = JSON.parse(App.Vars.company_working_plan);
|
||||
const companyWorkingPlan = JSON.parse(vars('company_working_plan'));
|
||||
workingPlanManager.setup(companyWorkingPlan);
|
||||
workingPlanManager.timepickers(false);
|
||||
});
|
||||
|
@ -225,7 +225,7 @@ App.Pages.Providers = (function () {
|
|||
$('.breaks tbody').empty();
|
||||
$('.working-plan-exceptions tbody').empty();
|
||||
$('.work-start, .work-end').val('');
|
||||
const companyWorkingPlan = JSON.parse(App.Vars.company_working_plan);
|
||||
const companyWorkingPlan = JSON.parse(vars('company_working_plan'));
|
||||
workingPlanManager.setup(companyWorkingPlan);
|
||||
workingPlanManager.timepickers(false);
|
||||
});
|
||||
|
@ -289,7 +289,7 @@ App.Pages.Providers = (function () {
|
|||
throw new Error(App.Lang.passwords_mismatch);
|
||||
}
|
||||
|
||||
if ($password.val().length < App.Vars.min_password_length && $password.val() !== '') {
|
||||
if ($password.val().length < vars('min_password_length') && $password.val() !== '') {
|
||||
$('#provider-password, #provider-password-confirm').addClass('is-invalid');
|
||||
throw new Error(App.Lang.password_length_notice.replace('$number', MIN_PASSWORD_LENGTH));
|
||||
}
|
||||
|
@ -533,7 +533,7 @@ App.Pages.Providers = (function () {
|
|||
filter('');
|
||||
addEventListeners();
|
||||
|
||||
App.Vars.services.forEach(function (service) {
|
||||
vars('services').forEach(function (service) {
|
||||
$('<div/>', {
|
||||
'class': 'checkbox',
|
||||
'html': [
|
||||
|
|
|
@ -292,7 +292,7 @@ App.Pages.Secretaries = (function () {
|
|||
throw new Error('Passwords mismatch!');
|
||||
}
|
||||
|
||||
if ($password.val().length < App.Vars.min_password_length && $password.val() !== '') {
|
||||
if ($password.val().length < vars('min_password_length') && $password.val() !== '') {
|
||||
$('#secretary-password, #secretary-password-confirm').addClass('is-invalid');
|
||||
throw new Error(
|
||||
'Password must be at least ' + BackendSecretaries.MIN_PASSWORD_LENGTH + ' characters long.'
|
||||
|
@ -475,7 +475,7 @@ App.Pages.Secretaries = (function () {
|
|||
filter('');
|
||||
addEventListeners();
|
||||
|
||||
App.Vars.providers.forEach((provider) => {
|
||||
vars('providers').forEach((provider) => {
|
||||
$('<div/>', {
|
||||
'class': 'checkbox',
|
||||
'html': [
|
||||
|
|
|
@ -90,8 +90,8 @@ App.Utils.CalendarDefaultView = (function () {
|
|||
|
||||
workingPlanExceptions[date] = workingPlanException;
|
||||
|
||||
for (const index in App.Vars.available_providers) {
|
||||
const availableProvider = App.Vars.available_providers[index];
|
||||
for (const index in vars('available_providers')) {
|
||||
const availableProvider = vars('available_providers')[index];
|
||||
|
||||
if (Number(availableProvider.id) === Number(provider.id)) {
|
||||
availableProvider.settings.working_plan_exceptions =
|
||||
|
@ -181,7 +181,7 @@ App.Utils.CalendarDefaultView = (function () {
|
|||
if (lastFocusedEventData.data.workingPlanException) {
|
||||
const providerId = $selectFilterItem.val();
|
||||
|
||||
const provider = App.Vars.available_providers.find(
|
||||
const provider = vars('available_providers').find(
|
||||
(availableProvider) => Number(availableProvider.id) === Number(providerId)
|
||||
);
|
||||
|
||||
|
@ -195,8 +195,8 @@ App.Utils.CalendarDefaultView = (function () {
|
|||
const workingPlanExceptions = JSON.parse(provider.settings.working_plan_exceptions) || {};
|
||||
delete workingPlanExceptions[date];
|
||||
|
||||
for (const index in App.Vars.available_providers) {
|
||||
const availableProvider = App.Vars.available_providers[index];
|
||||
for (const index in vars('available_providers')) {
|
||||
const availableProvider = vars('available_providers')[index];
|
||||
|
||||
if (Number(availableProvider.id) === Number(providerId)) {
|
||||
availableProvider.settings.working_plan_exceptions = JSON.stringify(workingPlanExceptions);
|
||||
|
@ -282,12 +282,12 @@ App.Utils.CalendarDefaultView = (function () {
|
|||
|
||||
const providerId = $selectFilterItem.val();
|
||||
|
||||
const provider = App.Vars.available_providers.find(
|
||||
const provider = vars('available_providers').find(
|
||||
(availableProvider) => Number(availableProvider.id) === Number(providerId)
|
||||
);
|
||||
|
||||
if (provider && provider.timezone) {
|
||||
$('.provider-timezone').text(App.Vars.timezones[provider.timezone]);
|
||||
$('.provider-timezone').text(vars('timezones')[provider.timezone]);
|
||||
}
|
||||
|
||||
// If the user has already the sync enabled then apply the proper style changes.
|
||||
|
@ -360,12 +360,12 @@ App.Utils.CalendarDefaultView = (function () {
|
|||
) {
|
||||
displayEdit =
|
||||
($parent.hasClass('fc-custom') || $altParent.hasClass('fc-custom')) &&
|
||||
App.Vars.privileges.appointments.edit === true
|
||||
vars('privileges').appointments.edit === true
|
||||
? 'me-2'
|
||||
: 'd-none';
|
||||
displayDelete =
|
||||
($parent.hasClass('fc-custom') || $altParent.hasClass('fc-custom')) &&
|
||||
App.Vars.privileges.appointments.delete === true
|
||||
vars('privileges').appointments.delete === true
|
||||
? 'me-2'
|
||||
: 'd-none'; // Same value at the time.
|
||||
|
||||
|
@ -378,8 +378,8 @@ App.Utils.CalendarDefaultView = (function () {
|
|||
$('<span/>', {
|
||||
'text': App.Utils.Date.format(
|
||||
event.start.format('YYYY-MM-DD HH:mm:ss'),
|
||||
App.Vars.date_format,
|
||||
App.Vars.time_format,
|
||||
vars('date_format'),
|
||||
vars('time_format'),
|
||||
true
|
||||
)
|
||||
}),
|
||||
|
@ -392,8 +392,8 @@ App.Utils.CalendarDefaultView = (function () {
|
|||
$('<span/>', {
|
||||
'text': App.Utils.Date.format(
|
||||
event.end.format('YYYY-MM-DD HH:mm:ss'),
|
||||
App.Vars.date_format,
|
||||
App.Vars.time_format,
|
||||
vars('date_format'),
|
||||
vars('time_format'),
|
||||
true
|
||||
)
|
||||
}),
|
||||
|
@ -456,7 +456,7 @@ App.Utils.CalendarDefaultView = (function () {
|
|||
) {
|
||||
displayDelete =
|
||||
($parent.hasClass('fc-custom') || $altParent.hasClass('fc-custom')) &&
|
||||
App.Vars.privileges.appointments.delete === true
|
||||
vars('privileges').appointments.delete === true
|
||||
? 'me-2'
|
||||
: 'd-none';
|
||||
|
||||
|
@ -478,8 +478,8 @@ App.Utils.CalendarDefaultView = (function () {
|
|||
$('<span/>', {
|
||||
'text': App.Utils.Date.format(
|
||||
event.data.date + ' ' + event.data.workingPlanException.start,
|
||||
App.Vars.date_format,
|
||||
App.Vars.time_format,
|
||||
vars('date_format'),
|
||||
vars('time_format'),
|
||||
true
|
||||
)
|
||||
}),
|
||||
|
@ -492,8 +492,8 @@ App.Utils.CalendarDefaultView = (function () {
|
|||
$('<span/>', {
|
||||
'text': App.Utils.Date.format(
|
||||
event.data.date + ' ' + event.data.workingPlanException.end,
|
||||
App.Vars.date_format,
|
||||
App.Vars.time_format,
|
||||
vars('date_format'),
|
||||
vars('time_format'),
|
||||
true
|
||||
)
|
||||
}),
|
||||
|
@ -504,7 +504,7 @@ App.Utils.CalendarDefaultView = (function () {
|
|||
'text': App.Lang.timezone
|
||||
}),
|
||||
$('<span/>', {
|
||||
'text': App.Vars.timezones[event.data.provider.timezone]
|
||||
'text': vars('timezones')[event.data.provider.timezone]
|
||||
}),
|
||||
$('<br/>'),
|
||||
|
||||
|
@ -551,8 +551,8 @@ App.Utils.CalendarDefaultView = (function () {
|
|||
]
|
||||
});
|
||||
} else {
|
||||
displayEdit = App.Vars.privileges.appointments.edit === true ? 'me-2' : 'd-none';
|
||||
displayDelete = App.Vars.privileges.appointments.delete === true ? 'me-2' : 'd-none';
|
||||
displayEdit = vars('privileges').appointments.edit === true ? 'me-2' : 'd-none';
|
||||
displayDelete = vars('privileges').appointments.delete === true ? 'me-2' : 'd-none';
|
||||
|
||||
$html = $('<div/>', {
|
||||
'html': [
|
||||
|
@ -563,8 +563,8 @@ App.Utils.CalendarDefaultView = (function () {
|
|||
$('<span/>', {
|
||||
'text': App.Utils.Date.format(
|
||||
event.start.format('YYYY-MM-DD HH:mm:ss'),
|
||||
App.Vars.date_format,
|
||||
App.Vars.time_format,
|
||||
vars('date_format'),
|
||||
vars('time_format'),
|
||||
true
|
||||
)
|
||||
}),
|
||||
|
@ -577,8 +577,8 @@ App.Utils.CalendarDefaultView = (function () {
|
|||
$('<span/>', {
|
||||
'text': App.Utils.Date.format(
|
||||
event.end.format('YYYY-MM-DD HH:mm:ss'),
|
||||
App.Vars.date_format,
|
||||
App.Vars.time_format,
|
||||
vars('date_format'),
|
||||
vars('time_format'),
|
||||
true
|
||||
)
|
||||
}),
|
||||
|
@ -589,7 +589,7 @@ App.Utils.CalendarDefaultView = (function () {
|
|||
'text': App.Lang.timezone
|
||||
}),
|
||||
$('<span/>', {
|
||||
'text': App.Vars.timezones[event.data.provider.timezone]
|
||||
'text': vars('timezones')[event.data.provider.timezone]
|
||||
}),
|
||||
$('<br/>'),
|
||||
|
||||
|
@ -727,7 +727,7 @@ App.Utils.CalendarDefaultView = (function () {
|
|||
* @see updateAppointmentData()
|
||||
*/
|
||||
function calendarEventResize(event, delta, revertFunc) {
|
||||
if (App.Vars.privileges.appointments.edit === false) {
|
||||
if (vars('privileges').appointments.edit === false) {
|
||||
revertFunc();
|
||||
App.Layouts.Backend.displayNotification(App.Lang.no_privileges_edit_appointments);
|
||||
return;
|
||||
|
@ -866,7 +866,7 @@ App.Utils.CalendarDefaultView = (function () {
|
|||
* @param {function} revertFunc
|
||||
*/
|
||||
function calendarEventDrop(event, delta, revertFunc) {
|
||||
if (App.Vars.privileges.appointments.edit === false) {
|
||||
if (vars('privileges').appointments.edit === false) {
|
||||
revertFunc();
|
||||
App.Layouts.Backend.displayNotification(App.Lang.no_privileges_edit_appointments);
|
||||
return;
|
||||
|
@ -1098,7 +1098,7 @@ App.Utils.CalendarDefaultView = (function () {
|
|||
const calendarView = $calendar.fullCalendar('getView');
|
||||
|
||||
if (filterType === FILTER_TYPE_PROVIDER && calendarView.name !== 'month') {
|
||||
const provider = App.Vars.available_providers.find(
|
||||
const provider = vars('available_providers').find(
|
||||
(availableProvider) => Number(availableProvider.id) === Number(recordId)
|
||||
);
|
||||
|
||||
|
@ -1126,7 +1126,7 @@ App.Utils.CalendarDefaultView = (function () {
|
|||
|
||||
// Sort the working plan starting with the first day as set in General settings to correctly align
|
||||
// breaks in the calendar display.
|
||||
const firstWeekdayNumber = App.Utils.Date.getWeekdayId(App.Vars.first_weekday);
|
||||
const firstWeekdayNumber = App.Utils.Date.getWeekdayId(vars('first_weekday'));
|
||||
const sortedWorkingPlan = App.Utils.Date.sortWeekDictionary(workingPlan, firstWeekdayNumber);
|
||||
|
||||
switch (calendarView.name) {
|
||||
|
@ -1392,7 +1392,7 @@ App.Utils.CalendarDefaultView = (function () {
|
|||
// Dynamic date formats.
|
||||
let columnFormat = {};
|
||||
|
||||
switch (App.Vars.date_format) {
|
||||
switch (vars('date_format')) {
|
||||
case 'DMY':
|
||||
columnFormat = 'ddd D/M';
|
||||
break;
|
||||
|
@ -1403,14 +1403,14 @@ App.Utils.CalendarDefaultView = (function () {
|
|||
break;
|
||||
|
||||
default:
|
||||
throw new Error('Invalid date format setting provided!', App.Vars.date_format);
|
||||
throw new Error('Invalid date format setting provided!', vars('date_format'));
|
||||
}
|
||||
|
||||
// Time formats
|
||||
let timeFormat = '';
|
||||
let slotTimeFormat = '';
|
||||
|
||||
switch (App.Vars.time_format) {
|
||||
switch (vars('time_format')) {
|
||||
case 'military':
|
||||
timeFormat = 'H:mm';
|
||||
slotTimeFormat = 'H(:mm)';
|
||||
|
@ -1420,12 +1420,12 @@ App.Utils.CalendarDefaultView = (function () {
|
|||
slotTimeFormat = 'h(:mm) a';
|
||||
break;
|
||||
default:
|
||||
throw new Error('Invalid time format setting provided!', App.Vars.time_format);
|
||||
throw new Error('Invalid time format setting provided!', vars('time_format'));
|
||||
}
|
||||
|
||||
const defaultView = window.innerWidth < 468 ? 'agendaDay' : 'agendaWeek';
|
||||
|
||||
const firstWeekday = App.Vars.first_weekday;
|
||||
const firstWeekday = vars('first_weekday');
|
||||
const firstWeekdayNumber = App.Utils.Date.getWeekdayId(firstWeekday);
|
||||
|
||||
// Initialize page calendar
|
||||
|
@ -1461,16 +1461,16 @@ App.Utils.CalendarDefaultView = (function () {
|
|||
let service;
|
||||
|
||||
if ($selectFilterItem.find('option:selected').attr('type') === FILTER_TYPE_SERVICE) {
|
||||
service = App.Vars.available_services.find(
|
||||
service = vars('available_services').find(
|
||||
(availableService) => Number(availableService.id) === Number($selectFilterItem.val())
|
||||
);
|
||||
$appointmentsModal.find('#select-service').val(service.id).trigger('change');
|
||||
} else {
|
||||
const provider = App.Vars.available_providers.find(
|
||||
const provider = vars('available_providers').find(
|
||||
(availableProvider) => Number(availableProvider.id) === Number($selectFilterItem.val())
|
||||
);
|
||||
|
||||
service = App.Vars.available_services.find(
|
||||
service = vars('available_services').find(
|
||||
(availableService) => provider.services.indexOf(availableService.id) !== -1
|
||||
);
|
||||
|
||||
|
@ -1579,11 +1579,11 @@ App.Utils.CalendarDefaultView = (function () {
|
|||
calendarWindowResize();
|
||||
|
||||
// Fill the select list boxes of the page.
|
||||
if (App.Vars.available_providers.length > 0) {
|
||||
if (vars('available_providers').length > 0) {
|
||||
$('<optgroup/>', {
|
||||
'label': App.Lang.providers,
|
||||
'type': 'providers-group',
|
||||
'html': App.Vars.available_providers.map((availableProvider) => {
|
||||
'html': vars('available_providers').map((availableProvider) => {
|
||||
const hasGoogleSync = availableProvider.settings.google_sync === '1' ? 'true' : 'false';
|
||||
|
||||
return $('<option/>', {
|
||||
|
@ -1596,11 +1596,11 @@ App.Utils.CalendarDefaultView = (function () {
|
|||
}).appendTo('#select-filter-item');
|
||||
}
|
||||
|
||||
if (App.Vars.available_services.length > 0) {
|
||||
if (vars('available_services').length > 0) {
|
||||
$('<optgroup/>', {
|
||||
'label': App.Lang.services,
|
||||
'type': 'services-group',
|
||||
'html': App.Vars.available_services.map((availableService) =>
|
||||
'html': vars('available_services').map((availableService) =>
|
||||
$('<option/>', {
|
||||
'value': availableService.id,
|
||||
'type': FILTER_TYPE_SERVICE,
|
||||
|
@ -1611,20 +1611,20 @@ App.Utils.CalendarDefaultView = (function () {
|
|||
}
|
||||
|
||||
// Check permissions.
|
||||
if (App.Vars.role_slug === App.Layouts.Backend.DB_SLUG_PROVIDER) {
|
||||
if (vars('role_slug') === App.Layouts.Backend.DB_SLUG_PROVIDER) {
|
||||
$selectFilterItem
|
||||
.find('optgroup:eq(0)')
|
||||
.find('option[value="' + App.Vars.user_id + '"]')
|
||||
.find('option[value="' + vars('user_id') + '"]')
|
||||
.prop('selected', true);
|
||||
$selectFilterItem.prop('disabled', true);
|
||||
}
|
||||
|
||||
if (App.Vars.role_slug === App.Layouts.Backend.DB_SLUG_SECRETARY) {
|
||||
if (vars('role_slug') === App.Layouts.Backend.DB_SLUG_SECRETARY) {
|
||||
// Remove the providers that are not connected to the secretary.
|
||||
$selectFilterItem.find('optgroup:eq(1)').remove();
|
||||
|
||||
$selectFilterItem.find('option[type="provider"]').each((index, option) => {
|
||||
const provider = App.Vars.secretary_providers.find(
|
||||
const provider = vars('secretary_providers').find(
|
||||
(secretaryProviderId) => Number($(option).val()) === Number(secretaryProviderId)
|
||||
);
|
||||
|
||||
|
@ -1644,8 +1644,8 @@ App.Utils.CalendarDefaultView = (function () {
|
|||
$selectFilterItem.trigger('change');
|
||||
|
||||
// Display the edit dialog if an appointment hash is provided.
|
||||
if (App.Vars.edit_appointment) {
|
||||
const appointment = App.Vars.edit_appointment;
|
||||
if (vars('edit_appointment')) {
|
||||
const appointment = vars('edit_appointment');
|
||||
|
||||
App.Components.AppointmentsModal.resetModal();
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ App.Utils.CalendarGoogleSync = (function () {
|
|||
// Disable synchronization for selected provider.
|
||||
const providerId = $('#select-filter-item').val();
|
||||
|
||||
const provider = App.Vars.available_providers.find(
|
||||
const provider = vars('available_providers').find(
|
||||
(availableProvider) => Number(availableProvider.id) === Number(providerId)
|
||||
);
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ App.Utils.CalendarTableView = (function () {
|
|||
|
||||
$dateColumn
|
||||
.find('.date-column-title')
|
||||
.text(App.Utils.Date.format(date, App.Vars.date_format, App.Vars.time_format));
|
||||
.text(App.Utils.Date.format(date, vars('date_format'), vars('time_format')));
|
||||
|
||||
$dateColumn.find('.provider-column').each((index, providerColumn) => {
|
||||
const $providerColumn = $(providerColumn);
|
||||
|
@ -164,8 +164,8 @@ App.Utils.CalendarTableView = (function () {
|
|||
|
||||
workingPlanExceptions[date] = workingPlanException;
|
||||
|
||||
for (const index in App.Vars.available_providers) {
|
||||
const availableProvider = App.Vars.available_providers[index];
|
||||
for (const index in vars('available_providers')) {
|
||||
const availableProvider = vars('available_providers')[index];
|
||||
|
||||
if (Number(availableProvider.id) === Number(provider.id)) {
|
||||
availableProvider.settings.working_plan_exceptions =
|
||||
|
@ -351,7 +351,7 @@ App.Utils.CalendarTableView = (function () {
|
|||
$selectDate = $('<input/>', {
|
||||
'type': 'text',
|
||||
'class': 'form-control d-inline-block select-date me-2',
|
||||
'value': App.Utils.Date.format(new Date(), App.Vars.date_format, App.Vars.time_format, false)
|
||||
'value': App.Utils.Date.format(new Date(), vars('date_format'), vars('time_format'), false)
|
||||
}).appendTo($calendarHeader);
|
||||
|
||||
$('<button/>', {
|
||||
|
@ -365,7 +365,7 @@ App.Utils.CalendarTableView = (function () {
|
|||
|
||||
let dateFormat;
|
||||
|
||||
switch (App.Vars.date_format) {
|
||||
switch (vars('date_format')) {
|
||||
case 'DMY':
|
||||
dateFormat = 'dd/mm/yy';
|
||||
break;
|
||||
|
@ -379,7 +379,7 @@ App.Utils.CalendarTableView = (function () {
|
|||
break;
|
||||
|
||||
default:
|
||||
throw new Error('Invalid date format setting provided: ' + App.Vars.date_format);
|
||||
throw new Error('Invalid date format setting provided: ' + vars('date_format'));
|
||||
}
|
||||
|
||||
$calendarHeader.find('.select-date').datepicker({
|
||||
|
@ -392,13 +392,13 @@ App.Utils.CalendarTableView = (function () {
|
|||
}
|
||||
});
|
||||
|
||||
const providers = App.Vars.available_providers.filter(
|
||||
const providers = vars('available_providers').filter(
|
||||
(provider) =>
|
||||
App.Vars.role_slug === App.Layouts.Backend.DB_SLUG_ADMIN ||
|
||||
(App.Vars.role_slug === App.Layouts.Backend.DB_SLUG_SECRETARY &&
|
||||
App.Vars.secretary_providers.indexOf(provider.id) !== -1) ||
|
||||
(App.Vars.role_slug === App.Layouts.Backend.DB_SLUG_PROVIDER &&
|
||||
Number(provider.id) === Number(App.Vars.user_id))
|
||||
vars('role_slug') === App.Layouts.Backend.DB_SLUG_ADMIN ||
|
||||
(vars('role_slug') === App.Layouts.Backend.DB_SLUG_SECRETARY &&
|
||||
vars('secretary_providers').indexOf(provider.id) !== -1) ||
|
||||
(vars('role_slug') === App.Layouts.Backend.DB_SLUG_PROVIDER &&
|
||||
Number(provider.id) === Number(vars('user_id')))
|
||||
);
|
||||
|
||||
// Create providers and service filters.
|
||||
|
@ -421,13 +421,13 @@ App.Utils.CalendarTableView = (function () {
|
|||
}
|
||||
}).appendTo($calendarHeader);
|
||||
|
||||
if (App.Vars.role_slug !== App.Layouts.Backend.DB_SLUG_PROVIDER) {
|
||||
if (vars('role_slug') !== App.Layouts.Backend.DB_SLUG_PROVIDER) {
|
||||
providers.forEach((provider) => {
|
||||
$filterProvider.append(new Option(provider.first_name + ' ' + provider.last_name, provider.id));
|
||||
});
|
||||
} else {
|
||||
providers.forEach((provider) => {
|
||||
if (Number(provider.id) === Number(App.Vars.user_id)) {
|
||||
if (Number(provider.id) === Number(vars('user_id'))) {
|
||||
$filterProvider.append(new Option(provider.first_name + ' ' + provider.last_name, provider.id));
|
||||
}
|
||||
});
|
||||
|
@ -435,10 +435,10 @@ App.Utils.CalendarTableView = (function () {
|
|||
|
||||
$filterProvider.select2();
|
||||
|
||||
const services = App.Vars.available_services.filter((service) => {
|
||||
const services = vars('available_services').filter((service) => {
|
||||
const provider = providers.find((provider) => provider.services.indexOf(service.id) !== -1);
|
||||
|
||||
return App.Vars.role_slug === App.Layouts.Backend.DB_SLUG_ADMIN || provider;
|
||||
return vars('role_slug') === App.Layouts.Backend.DB_SLUG_ADMIN || provider;
|
||||
});
|
||||
|
||||
$('<label/>', {
|
||||
|
@ -545,13 +545,13 @@ App.Utils.CalendarTableView = (function () {
|
|||
|
||||
$('<h5/>', {
|
||||
'class': 'date-column-title',
|
||||
'text': App.Utils.Date.format(date, App.Vars.date_format, App.Vars.time_format)
|
||||
'text': App.Utils.Date.format(date, vars('date_format'), vars('time_format'))
|
||||
}).appendTo($dateColumn);
|
||||
|
||||
const filterProviderIds = $filterProvider.val();
|
||||
const filterServiceIds = $filterService.val();
|
||||
|
||||
let providers = App.Vars.available_providers.filter((provider) => {
|
||||
let providers = vars('available_providers').filter((provider) => {
|
||||
const servedServiceIds = provider.services.filter((serviceId) => {
|
||||
const matches = filterServiceIds.filter(
|
||||
(filterServiceId) => Number(serviceId) === Number(filterServiceId)
|
||||
|
@ -573,18 +573,18 @@ App.Utils.CalendarTableView = (function () {
|
|||
);
|
||||
});
|
||||
|
||||
if (App.Vars.role_slug === 'provider') {
|
||||
App.Vars.available_providers.forEach((provider) => {
|
||||
if (Number(provider.id) === Number(App.Vars.user_id)) {
|
||||
if (vars('role_slug') === 'provider') {
|
||||
vars('available_providers').forEach((provider) => {
|
||||
if (Number(provider.id) === Number(vars('user_id'))) {
|
||||
providers = [provider];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (App.Vars.role_slug === 'secretary') {
|
||||
if (vars('role_slug') === 'secretary') {
|
||||
providers = [];
|
||||
App.Vars.available_providers.forEach((provider) => {
|
||||
if (App.Vars.secretary_providers.indexOf(provider.id) > -1) {
|
||||
vars('available_providers').forEach((provider) => {
|
||||
if (vars('secretary_providers').indexOf(provider.id) > -1) {
|
||||
providers.push(provider);
|
||||
}
|
||||
});
|
||||
|
@ -649,7 +649,7 @@ App.Utils.CalendarTableView = (function () {
|
|||
|
||||
let columnFormat = '';
|
||||
|
||||
switch (App.Vars.date_format) {
|
||||
switch (vars('date_format')) {
|
||||
case 'DMY':
|
||||
columnFormat = 'ddd D/M';
|
||||
break;
|
||||
|
@ -660,14 +660,14 @@ App.Utils.CalendarTableView = (function () {
|
|||
break;
|
||||
|
||||
default:
|
||||
throw new Error('Invalid date format setting provided!', App.Vars.date_format);
|
||||
throw new Error('Invalid date format setting provided!', vars('date_format'));
|
||||
}
|
||||
|
||||
// Time formats
|
||||
let timeFormat = '';
|
||||
let slotTimeFormat = '';
|
||||
|
||||
switch (App.Vars.time_format) {
|
||||
switch (vars('time_format')) {
|
||||
case 'military':
|
||||
timeFormat = 'H:mm';
|
||||
slotTimeFormat = 'H(:mm)';
|
||||
|
@ -677,10 +677,10 @@ App.Utils.CalendarTableView = (function () {
|
|||
slotTimeFormat = 'h(:mm) a';
|
||||
break;
|
||||
default:
|
||||
throw new Error('Invalid time format setting provided!' + App.Vars.time_format);
|
||||
throw new Error('Invalid time format setting provided!' + vars('time_format'));
|
||||
}
|
||||
|
||||
const firstWeekday = App.Vars.first_weekday;
|
||||
const firstWeekday = vars('first_weekday');
|
||||
const firstWeekdayNumber = App.Utils.Date.getWeekdayId(firstWeekday);
|
||||
|
||||
$wrapper.fullCalendar({
|
||||
|
@ -712,11 +712,11 @@ App.Utils.CalendarTableView = (function () {
|
|||
const $providerColumn = $(jsEvent.target).parents('.provider-column');
|
||||
const providerId = $providerColumn.data('provider').id;
|
||||
|
||||
const provider = App.Vars.available_providers.find(
|
||||
const provider = vars('available_providers').find(
|
||||
(provider) => Number(provider.id) === Number(providerId)
|
||||
);
|
||||
|
||||
const service = App.Vars.available_services.find(
|
||||
const service = vars('available_services').find(
|
||||
(service) => provider.services.indexOf(service.id) !== -1
|
||||
);
|
||||
|
||||
|
@ -1142,12 +1142,12 @@ App.Utils.CalendarTableView = (function () {
|
|||
) {
|
||||
displayEdit =
|
||||
($parent.hasClass('fc-custom') || $altParent.hasClass('fc-custom')) &&
|
||||
App.Vars.privileges.appointments.edit === true
|
||||
vars('privileges').appointments.edit === true
|
||||
? ''
|
||||
: 'd-none';
|
||||
displayDelete =
|
||||
($parent.hasClass('fc-custom') || $altParent.hasClass('fc-custom')) &&
|
||||
App.Vars.privileges.appointments.delete === true
|
||||
vars('privileges').appointments.delete === true
|
||||
? ''
|
||||
: 'd-none'; // Same value at the time.
|
||||
|
||||
|
@ -1159,8 +1159,8 @@ App.Utils.CalendarTableView = (function () {
|
|||
$('<span/>', {
|
||||
'text': App.Utils.Date.format(
|
||||
event.start.format('YYYY-MM-DD HH:mm:ss'),
|
||||
App.Vars.date_format,
|
||||
App.Vars.time_format,
|
||||
vars('date_format'),
|
||||
vars('time_format'),
|
||||
true
|
||||
)
|
||||
}),
|
||||
|
@ -1172,8 +1172,8 @@ App.Utils.CalendarTableView = (function () {
|
|||
$('<span/>', {
|
||||
'text': App.Utils.Date.format(
|
||||
event.end.format('YYYY-MM-DD HH:mm:ss'),
|
||||
App.Vars.date_format,
|
||||
App.Vars.time_format,
|
||||
vars('date_format'),
|
||||
vars('time_format'),
|
||||
true
|
||||
)
|
||||
}),
|
||||
|
@ -1236,13 +1236,13 @@ App.Utils.CalendarTableView = (function () {
|
|||
) {
|
||||
displayEdit =
|
||||
($parent.hasClass('fc-custom') || $altParent.hasClass('fc-custom')) &&
|
||||
App.Vars.privileges.appointments.edit === true
|
||||
vars('privileges').appointments.edit === true
|
||||
? ''
|
||||
: 'd-none'; // Same value at the time.
|
||||
|
||||
displayDelete =
|
||||
($parent.hasClass('fc-custom') || $altParent.hasClass('fc-custom')) &&
|
||||
App.Vars.privileges.appointments.delete === true
|
||||
vars('privileges').appointments.delete === true
|
||||
? ''
|
||||
: 'd-none'; // Same value at the time.
|
||||
|
||||
|
@ -1262,8 +1262,8 @@ App.Utils.CalendarTableView = (function () {
|
|||
$('<span/>', {
|
||||
'text': App.Utils.Date.format(
|
||||
event.data.date + ' ' + event.data.workingPlanException.start,
|
||||
App.Vars.date_format,
|
||||
App.Vars.time_format,
|
||||
vars('date_format'),
|
||||
vars('time_format'),
|
||||
true
|
||||
)
|
||||
}),
|
||||
|
@ -1275,8 +1275,8 @@ App.Utils.CalendarTableView = (function () {
|
|||
$('<span/>', {
|
||||
'text': App.Utils.Date.format(
|
||||
event.data.date + ' ' + event.data.workingPlanException.end,
|
||||
App.Vars.date_format,
|
||||
App.Vars.time_format,
|
||||
vars('date_format'),
|
||||
vars('time_format'),
|
||||
true
|
||||
)
|
||||
}),
|
||||
|
@ -1286,7 +1286,7 @@ App.Utils.CalendarTableView = (function () {
|
|||
'text': App.Lang.timezone
|
||||
}),
|
||||
$('<span/>', {
|
||||
'text': App.Vars.timezones[event.data.provider.timezone]
|
||||
'text': vars('timezones')[event.data.provider.timezone]
|
||||
}),
|
||||
$('<br/>'),
|
||||
|
||||
|
@ -1333,8 +1333,8 @@ App.Utils.CalendarTableView = (function () {
|
|||
]
|
||||
});
|
||||
} else {
|
||||
displayEdit = App.Vars.privileges.appointments.edit === true ? '' : 'd-none';
|
||||
displayDelete = App.Vars.privileges.appointments.delete === true ? '' : 'd-none';
|
||||
displayEdit = vars('privileges').appointments.edit === true ? '' : 'd-none';
|
||||
displayDelete = vars('privileges').appointments.delete === true ? '' : 'd-none';
|
||||
|
||||
$html = $('<div/>', {
|
||||
'html': [
|
||||
|
@ -1344,8 +1344,8 @@ App.Utils.CalendarTableView = (function () {
|
|||
$('<span/>', {
|
||||
'text': App.Utils.Date.format(
|
||||
event.start.format('YYYY-MM-DD HH:mm:ss'),
|
||||
App.Vars.date_format,
|
||||
App.Vars.time_format,
|
||||
vars('date_format'),
|
||||
vars('time_format'),
|
||||
true
|
||||
)
|
||||
}),
|
||||
|
@ -1357,8 +1357,8 @@ App.Utils.CalendarTableView = (function () {
|
|||
$('<span/>', {
|
||||
'text': App.Utils.Date.format(
|
||||
event.end.format('YYYY-MM-DD HH:mm:ss'),
|
||||
App.Vars.date_format,
|
||||
App.Vars.time_format,
|
||||
vars('date_format'),
|
||||
vars('time_format'),
|
||||
true
|
||||
)
|
||||
}),
|
||||
|
@ -1368,7 +1368,7 @@ App.Utils.CalendarTableView = (function () {
|
|||
'text': App.Lang.timezone
|
||||
}),
|
||||
$('<span/>', {
|
||||
'text': App.Vars.timezones[event.data.provider.timezone]
|
||||
'text': vars('timezones')[event.data.provider.timezone]
|
||||
}),
|
||||
$('<br/>'),
|
||||
|
||||
|
@ -1496,7 +1496,7 @@ App.Utils.CalendarTableView = (function () {
|
|||
* @see updateAppointmentData()
|
||||
*/
|
||||
function onEventResize(event, delta, revertFunc) {
|
||||
if (App.Vars.privileges.appointments.edit === false) {
|
||||
if (vars('privileges').appointments.edit === false) {
|
||||
revertFunc();
|
||||
App.Layouts.Backend.displayNotification(App.Lang.no_privileges_edit_appointments);
|
||||
return;
|
||||
|
@ -1604,7 +1604,7 @@ App.Utils.CalendarTableView = (function () {
|
|||
* on the calendar. We need to update the database with this change. This is done via an ajax call.
|
||||
*/
|
||||
function onEventDrop(event, delta, revertFunc) {
|
||||
if (App.Vars.privileges.appointments.edit === false) {
|
||||
if (vars('privileges').appointments.edit === false) {
|
||||
revertFunc();
|
||||
App.Layouts.Backend.displayNotification(App.Lang.no_privileges_edit_appointments);
|
||||
return;
|
||||
|
|
|
@ -249,7 +249,7 @@ window.GeneralFunctions = window.GeneralFunctions || {};
|
|||
* Enable Language Selection
|
||||
*
|
||||
* Enables the language selection functionality. Must be called on every page has a language selection button.
|
||||
* This method requires the global variable 'App.Vars.available_languages' to be initialized before the execution.
|
||||
* This method requires the global variable 'vars('available_languages')' to be initialized before the execution.
|
||||
*
|
||||
* @param {Object} $element Selected element button for the language selection.
|
||||
*
|
||||
|
@ -318,7 +318,7 @@ window.GeneralFunctions = window.GeneralFunctions || {};
|
|||
* @return {String} Returns the formatted date string.
|
||||
*/
|
||||
exports.formatDate = function (date, dateFormatSetting, addHours) {
|
||||
var timeFormat = App.Vars.time_format === 'regular' ? 'h:mm a' : 'HH:mm';
|
||||
var timeFormat = vars('time_format') === 'regular' ? 'h:mm a' : 'HH:mm';
|
||||
var hours = addHours ? ' ' + timeFormat : '';
|
||||
var result;
|
||||
var parsedDateMoment = moment(date);
|
||||
|
|
|
@ -19,7 +19,7 @@ window.App.Utils.Lang = (function () {
|
|||
* Enable Language Selection
|
||||
*
|
||||
* Enables the language selection functionality. Must be called on every page has a language selection button.
|
||||
* This method requires the global variable 'App.Vars.available_variables' to be initialized before the execution.
|
||||
* This method requires the global variable "vars('available_variables')" to be initialized before the execution.
|
||||
*
|
||||
* @param {Object} $target Selected element button for the language selection.
|
||||
*/
|
||||
|
@ -27,7 +27,7 @@ window.App.Utils.Lang = (function () {
|
|||
// Select Language
|
||||
const $languageList = $('<ul/>', {
|
||||
'id': 'language-list',
|
||||
'html': App.Vars.available_languages.map((availableLanguage) =>
|
||||
'html': vars('available_languages').map((availableLanguage) =>
|
||||
$('<li/>', {
|
||||
'class': 'language',
|
||||
'data-language': availableLanguage,
|
||||
|
|
|
@ -23,7 +23,7 @@ window.App.Utils.Url = (function () {
|
|||
* @return {String}
|
||||
*/
|
||||
function baseUrl(uri) {
|
||||
return `${App.Vars.base_url}/${uri}`;
|
||||
return `${vars('base_url')}/${uri}`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -34,7 +34,7 @@ window.App.Utils.Url = (function () {
|
|||
* @returns {String}
|
||||
*/
|
||||
function siteUrl(uri) {
|
||||
return `${App.Vars.base_url}${App.Vars.index_page ? '/' + App.Vars.index_page : ''}/${uri}`;
|
||||
return `${vars('base_url')}${vars('index_page') ? '/' + vars('index_page') : ''}/${uri}`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -46,14 +46,14 @@ App.Utils.WorkingPlan = (function () {
|
|||
* @param {Object} workingPlan Contains the working hours and breaks for each day of the week.
|
||||
*/
|
||||
setup(workingPlan) {
|
||||
const weekDayId = App.Utils.Date.getWeekdayId(App.Vars.first_weekday);
|
||||
const weekDayId = App.Utils.Date.getWeekdayId(vars('first_weekday'));
|
||||
const workingPlanSorted = App.Utils.Date.sortWeekDictionary(workingPlan, weekDayId);
|
||||
|
||||
$('.working-plan tbody').empty();
|
||||
$('.breaks tbody').empty();
|
||||
|
||||
// Build working plan day list starting with the first weekday as set in the General settings
|
||||
const timeFormat = App.Vars.time_format === 'regular' ? 'h:mm a' : 'HH:mm';
|
||||
const timeFormat = vars('time_format') === 'regular' ? 'h:mm a' : 'HH:mm';
|
||||
|
||||
$.each(
|
||||
workingPlanSorted,
|
||||
|
@ -294,7 +294,7 @@ App.Utils.WorkingPlan = (function () {
|
|||
* @param {Object} workingPlanException Contains exception information.
|
||||
*/
|
||||
renderWorkingPlanExceptionRow(date, workingPlanException) {
|
||||
const timeFormat = App.Vars.time_format === 'regular' ? 'h:mm a' : 'HH:mm';
|
||||
const timeFormat = vars('time_format') === 'regular' ? 'h:mm a' : 'HH:mm';
|
||||
|
||||
return $('<tr/>', {
|
||||
'data': {
|
||||
|
@ -304,7 +304,7 @@ App.Utils.WorkingPlan = (function () {
|
|||
'html': [
|
||||
$('<td/>', {
|
||||
'class': 'working-plan-exception-date',
|
||||
'text': App.Utils.Date.format(date, App.Vars.date_format, App.Vars.time_format, false)
|
||||
'text': App.Utils.Date.format(date, vars('date_format'), vars('time_format'), false)
|
||||
}),
|
||||
$('<td/>', {
|
||||
'class': 'working-plan-exception--start',
|
||||
|
@ -379,7 +379,7 @@ App.Utils.WorkingPlan = (function () {
|
|||
$('.add-break').on(
|
||||
'click',
|
||||
function () {
|
||||
const timeFormat = App.Vars.time_format === 'regular' ? 'h:mm a' : 'HH:mm';
|
||||
const timeFormat = vars('time_format') === 'regular' ? 'h:mm a' : 'HH:mm';
|
||||
|
||||
const $newBreak = $('<tr/>', {
|
||||
'html': [
|
||||
|
@ -471,7 +471,7 @@ App.Utils.WorkingPlan = (function () {
|
|||
.parent()
|
||||
.find('.break-start input, .break-end input')
|
||||
.timepicker({
|
||||
timeFormat: App.Vars.time_format === 'regular' ? 'h:mm tt' : 'HH:mm',
|
||||
timeFormat: vars('time_format') === 'regular' ? 'h:mm tt' : 'HH:mm',
|
||||
currentText: App.Lang.now,
|
||||
closeText: App.Lang.close,
|
||||
timeOnlyTitle: App.Lang.select_time,
|
||||
|
@ -543,7 +543,7 @@ App.Utils.WorkingPlan = (function () {
|
|||
$modifiedRow.find('.break-end input').val(
|
||||
startMoment
|
||||
.add(1, 'hour')
|
||||
.format(App.Vars.time_format === 'regular' ? 'h:mm a' : 'HH:mm')
|
||||
.format(vars('time_format') === 'regular' ? 'h:mm a' : 'HH:mm')
|
||||
.toLowerCase()
|
||||
);
|
||||
}
|
||||
|
@ -629,7 +629,7 @@ App.Utils.WorkingPlan = (function () {
|
|||
get() {
|
||||
const workingPlan = {};
|
||||
|
||||
const timeFormat = App.Vars.time_format === 'regular' ? 'h:mm a' : 'HH:mm';
|
||||
const timeFormat = vars('time_format') === 'regular' ? 'h:mm a' : 'HH:mm';
|
||||
|
||||
$('.working-plan input:checkbox').each(
|
||||
function (index, checkbox) {
|
||||
|
@ -652,12 +652,11 @@ App.Utils.WorkingPlan = (function () {
|
|||
workingPlan[id].breaks.push({
|
||||
start: moment(
|
||||
start,
|
||||
App.Vars.time_format === 'regular' ? 'h:mm a' : 'HH:mm'
|
||||
vars('time_format') === 'regular' ? 'h:mm a' : 'HH:mm'
|
||||
).format('HH:mm'),
|
||||
end: moment(
|
||||
end,
|
||||
App.Vars.time_format === 'regular' ? 'h:mm a' : 'HH:mm'
|
||||
).format('HH:mm')
|
||||
end: moment(end, vars('time_format') === 'regular' ? 'h:mm a' : 'HH:mm').format(
|
||||
'HH:mm'
|
||||
)
|
||||
});
|
||||
}
|
||||
}.bind(this)
|
||||
|
@ -703,7 +702,7 @@ App.Utils.WorkingPlan = (function () {
|
|||
if (disabled === false) {
|
||||
// Set timepickers where needed.
|
||||
$('.working-plan input:text').timepicker({
|
||||
timeFormat: App.Vars.time_format === 'regular' ? 'h:mm tt' : 'HH:mm',
|
||||
timeFormat: vars('time_format') === 'regular' ? 'h:mm tt' : 'HH:mm',
|
||||
currentText: App.Lang.now,
|
||||
closeText: App.Lang.close,
|
||||
timeOnlyTitle: App.Lang.select_time,
|
||||
|
@ -725,7 +724,7 @@ App.Utils.WorkingPlan = (function () {
|
|||
.val(
|
||||
startMoment
|
||||
.add(1, 'hour')
|
||||
.format(App.Vars.time_format === 'regular' ? 'h:mm a' : 'HH:mm')
|
||||
.format(vars('time_format') === 'regular' ? 'h:mm a' : 'HH:mm')
|
||||
.toLowerCase()
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue