mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-25 17:33:19 +03:00
Removed the use of jQuery methods for array and data processing wherever possible, along with other improvements in the javascript code.
This commit is contained in:
parent
25e8bbed31
commit
03b4adc6ad
19 changed files with 397 additions and 507 deletions
|
@ -26,9 +26,6 @@ window.Backend = window.Backend || {};
|
||||||
* Main javascript code for the backend of Easy!Appointments.
|
* Main javascript code for the backend of Easy!Appointments.
|
||||||
*/
|
*/
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
window.console = window.console || function () {
|
|
||||||
}; // IE compatibility
|
|
||||||
|
|
||||||
$(window)
|
$(window)
|
||||||
.on('resize', function () {
|
.on('resize', function () {
|
||||||
Backend.placeFooterToBottom();
|
Backend.placeFooterToBottom();
|
||||||
|
|
|
@ -292,26 +292,27 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa
|
||||||
*/
|
*/
|
||||||
$('#select-service').change(function () {
|
$('#select-service').change(function () {
|
||||||
var serviceId = $('#select-service').val();
|
var serviceId = $('#select-service').val();
|
||||||
|
|
||||||
$('#select-provider').empty();
|
$('#select-provider').empty();
|
||||||
|
|
||||||
// Automatically update the service duration.
|
// Automatically update the service duration.
|
||||||
$.each(GlobalVariables.availableServices, function (indexService, availableService) {
|
var service = GlobalVariables.availableServices.find(function (availableService) {
|
||||||
if (Number(availableService.id) === serviceId) {
|
return Number(availableService.id) === Number(serviceId);
|
||||||
var start = $('#start-datetime').datetimepicker('getDate');
|
|
||||||
$('#end-datetime').datetimepicker('setDate', new Date(start.getTime() + availableService.duration * 60000));
|
|
||||||
return false; // break loop
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var start = $('#start-datetime').datetimepicker('getDate');
|
||||||
|
$('#end-datetime').datetimepicker('setDate', new Date(start.getTime() + service.duration * 60000));
|
||||||
|
|
||||||
// Update the providers select box.
|
// Update the providers select box.
|
||||||
$.each(GlobalVariables.availableProviders, function (indexProvider, provider) {
|
|
||||||
$.each(provider.services, function (indexService, providerServiceId) {
|
GlobalVariables.availableProviders.forEach(function (provider) {
|
||||||
|
provider.services.forEach(function (providerServiceId) {
|
||||||
if (GlobalVariables.user.role_slug === Backend.DB_SLUG_PROVIDER && Number(provider.id) !== GlobalVariables.user.id) {
|
if (GlobalVariables.user.role_slug === Backend.DB_SLUG_PROVIDER && Number(provider.id) !== GlobalVariables.user.id) {
|
||||||
return true; // continue
|
return; // continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GlobalVariables.user.role_slug === Backend.DB_SLUG_SECRETARY && GlobalVariables.secretaryProviders.indexOf(provider.id) === -1) {
|
if (GlobalVariables.user.role_slug === Backend.DB_SLUG_SECRETARY && GlobalVariables.secretaryProviders.indexOf(provider.id) === -1) {
|
||||||
return true; // continue
|
return; // continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the current provider is able to provide the selected service, add him to the listbox.
|
// If the current provider is able to provide the selected service, add him to the listbox.
|
||||||
|
@ -359,22 +360,18 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa
|
||||||
// Fill the providers listbox with providers that can serve the appointment's
|
// Fill the providers listbox with providers that can serve the appointment's
|
||||||
// service and then select the user's provider.
|
// service and then select the user's provider.
|
||||||
$dialog.find('#select-provider').empty();
|
$dialog.find('#select-provider').empty();
|
||||||
$.each(GlobalVariables.availableProviders, function (index, provider) {
|
GlobalVariables.availableProviders.forEach(function (provider, index) {
|
||||||
var canProvideService = false;
|
var canProvideService = false;
|
||||||
|
|
||||||
var serviceId = $dialog.find('#select-service').val();
|
var serviceId = $dialog.find('#select-service').val();
|
||||||
|
|
||||||
$.each(provider.services, function (index, providerServiceId) {
|
var canProvideService = provider.services.filter(function(providerServiceId) {
|
||||||
if (Number(providerServiceId) === Number(serviceId)) {
|
return Number(providerServiceId) === Number(serviceId)
|
||||||
canProvideService = true;
|
}).length > 0;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (canProvideService) { // Add the provider to the listbox.
|
if (canProvideService) { // Add the provider to the listbox.
|
||||||
var option = new Option(provider.first_name
|
$dialog.find('#select-provider')
|
||||||
+ ' ' + provider.last_name, provider.id);
|
.append(new Option(provider.first_name + ' ' + provider.last_name, provider.id));
|
||||||
$dialog.find('#select-provider').append(option);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -386,16 +383,15 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa
|
||||||
// Setup start and datetimepickers.
|
// Setup start and datetimepickers.
|
||||||
// Get the selected service duration. It will be needed in order to calculate the appointment end datetime.
|
// Get the selected service duration. It will be needed in order to calculate the appointment end datetime.
|
||||||
var serviceId = $dialog.find('#select-service').val();
|
var serviceId = $dialog.find('#select-service').val();
|
||||||
var serviceDuration = 0;
|
|
||||||
$.each(GlobalVariables.availableServices, function (index, service) {
|
var service = GlobalVariables.availableServices.forEach(function(service) {
|
||||||
if (Number(service.id) === Number(serviceId)) {
|
return Number(service.id) === Number(serviceId);
|
||||||
serviceDuration = service.duration;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var duration = service ? service.duration : 0;
|
||||||
|
|
||||||
var startDatetime = new Date().addMinutes(GlobalVariables.bookAdvanceTimeout);
|
var startDatetime = new Date().addMinutes(GlobalVariables.bookAdvanceTimeout);
|
||||||
var endDatetime = new Date().addMinutes(GlobalVariables.bookAdvanceTimeout).addMinutes(serviceDuration);
|
var endDatetime = new Date().addMinutes(GlobalVariables.bookAdvanceTimeout).addMinutes(duration);
|
||||||
var dateFormat;
|
var dateFormat;
|
||||||
|
|
||||||
switch (GlobalVariables.dateFormat) {
|
switch (GlobalVariables.dateFormat) {
|
||||||
|
@ -446,13 +442,12 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa
|
||||||
var serviceId = $('#select-service').val();
|
var serviceId = $('#select-service').val();
|
||||||
|
|
||||||
// Automatically update the #end-datetime DateTimePicker based on service duration.
|
// Automatically update the #end-datetime DateTimePicker based on service duration.
|
||||||
$.each(GlobalVariables.availableServices, function (indexService, availableService) {
|
var service = GlobalVariables.availableServices.find(function (availableService) {
|
||||||
if (Number(availableService.id) === Number(serviceId)) {
|
return Number(availableService.id) === Number(serviceId);
|
||||||
var start = $('#start-datetime').datetimepicker('getDate');
|
|
||||||
$('#end-datetime').datetimepicker('setDate', new Date(start.getTime() + availableService.duration * 60000));
|
|
||||||
return false; // break loop
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var start = $('#start-datetime').datetimepicker('getDate');
|
||||||
|
$('#end-datetime').datetimepicker('setDate', new Date(start.getTime() + service.duration * 60000));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$dialog.find('#start-datetime').datetimepicker('setDate', startDatetime);
|
$dialog.find('#start-datetime').datetimepicker('setDate', startDatetime);
|
||||||
|
@ -505,9 +500,9 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa
|
||||||
// Check required fields.
|
// Check required fields.
|
||||||
var missingRequiredField = false;
|
var missingRequiredField = false;
|
||||||
|
|
||||||
$dialog.find('.required').each(function () {
|
$dialog.find('.required').each(function (index, requiredField) {
|
||||||
if ($(this).val() === '' || $(this).val() === null) {
|
if ($(requiredField).val() === '' || $(requiredField).val() === null) {
|
||||||
$(this).closest('.form-group').addClass('has-error');
|
$(requiredField).closest('.form-group').addClass('has-error');
|
||||||
missingRequiredField = true;
|
missingRequiredField = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -54,7 +54,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
|
||||||
* Hides the open popover element.
|
* Hides the open popover element.
|
||||||
*/
|
*/
|
||||||
$calendarPage.on('click', '.close-popover', function () {
|
$calendarPage.on('click', '.close-popover', function () {
|
||||||
$(this).parents().eq(2).remove();
|
$(this).parents('.popover').popover('destroy');
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,7 +63,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
|
||||||
* Enables the edit dialog of the selected calendar event.
|
* Enables the edit dialog of the selected calendar event.
|
||||||
*/
|
*/
|
||||||
$calendarPage.on('click', '.edit-popover', function () {
|
$calendarPage.on('click', '.edit-popover', function () {
|
||||||
$(this).parents().eq(2).remove(); // Hide the popover
|
$(this).parents('.popover').popover('destroy');
|
||||||
|
|
||||||
var $dialog;
|
var $dialog;
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
|
||||||
* deletion then an AJAX call is made to the server and deletes the appointment from the database.
|
* deletion then an AJAX call is made to the server and deletes the appointment from the database.
|
||||||
*/
|
*/
|
||||||
$calendarPage.on('click', '.delete-popover', function () {
|
$calendarPage.on('click', '.delete-popover', function () {
|
||||||
$(this).parents().eq(2).remove(); // Hide the popover.
|
$(this).parents('.popover').popover('destroy');
|
||||||
|
|
||||||
var url;
|
var url;
|
||||||
var data;
|
var data;
|
||||||
|
@ -277,7 +277,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
|
||||||
* above the calendar item.
|
* above the calendar item.
|
||||||
*/
|
*/
|
||||||
function calendarEventClick(event, jsEvent, view) {
|
function calendarEventClick(event, jsEvent, view) {
|
||||||
$('.popover').remove(); // Close all open popovers.
|
$('.popover').popover('destroy'); // Close all open popovers.
|
||||||
|
|
||||||
var $html;
|
var $html;
|
||||||
var displayEdit;
|
var displayEdit;
|
||||||
|
@ -833,13 +833,13 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
|
||||||
$(window).trigger('resize'); // Places the footer on the bottom.
|
$(window).trigger('resize'); // Places the footer on the bottom.
|
||||||
|
|
||||||
// Remove all open popovers.
|
// Remove all open popovers.
|
||||||
$('.close-popover').each(function () {
|
$('.close-popover').each(function (index, closePopoverButton) {
|
||||||
$(this).parents().eq(2).remove();
|
$(closePopoverButton).parents('.popover').popover('destroy');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add new pop overs.
|
// Add new pop overs.
|
||||||
$('.fv-events').each(function (index, eventHandle) {
|
$('.fv-events').each(function (index, eventElement) {
|
||||||
$(eventHandle).popover();
|
$(eventElement).popover();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -853,11 +853,11 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
|
||||||
*/
|
*/
|
||||||
function convertTitlesToHtml() {
|
function convertTitlesToHtml() {
|
||||||
// Convert the titles to html code.
|
// Convert the titles to html code.
|
||||||
$('.fc-custom').each(function () {
|
$('.fc-custom').each(function (index, customEventElement) {
|
||||||
var title = $(this).find('.fc-event-title').text();
|
var title = $(customEventElement).find('.fc-event-title').text();
|
||||||
$(this).find('.fc-event-title').html(title);
|
$(customEventElement).find('.fc-event-title').html(title);
|
||||||
var time = $(this).find('.fc-event-time').text();
|
var time = $(customEventElement).find('.fc-event-time').text();
|
||||||
$(this).find('.fc-event-time').html(time);
|
$(customEventElement).find('.fc-event-time').html(time);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -889,9 +889,10 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
|
||||||
.done(function (response) {
|
.done(function (response) {
|
||||||
// Add appointments to calendar.
|
// Add appointments to calendar.
|
||||||
var calendarEvents = [];
|
var calendarEvents = [];
|
||||||
|
|
||||||
var $calendar = $('#calendar');
|
var $calendar = $('#calendar');
|
||||||
|
|
||||||
$.each(response.appointments, function (index, appointment) {
|
response.appointments.forEach(function (appointment) {
|
||||||
var event = {
|
var event = {
|
||||||
id: appointment.id,
|
id: appointment.id,
|
||||||
title: appointment.service.name + ' - '
|
title: appointment.service.name + ' - '
|
||||||
|
@ -923,9 +924,9 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
|
||||||
var calendarView = $calendar.fullCalendar('getView').name;
|
var calendarView = $calendar.fullCalendar('getView').name;
|
||||||
|
|
||||||
if (filterType === FILTER_TYPE_PROVIDER && calendarView !== 'month') {
|
if (filterType === FILTER_TYPE_PROVIDER && calendarView !== 'month') {
|
||||||
$.each(GlobalVariables.availableProviders, function (index, provider) {
|
GlobalVariables.availableProviders.forEach(function (provider, index) {
|
||||||
if (Number(provider.id) === Number(recordId)) {
|
if (Number(provider.id) === Number(recordId)) {
|
||||||
var workingPlan={};
|
var workingPlan = {};
|
||||||
var workingPlanBulk = jQuery.parseJSON(provider.settings.working_plan);
|
var workingPlanBulk = jQuery.parseJSON(provider.settings.working_plan);
|
||||||
var extraWorkingPlan = jQuery.parseJSON(provider.settings.extra_working_plan);
|
var extraWorkingPlan = jQuery.parseJSON(provider.settings.extra_working_plan);
|
||||||
var unavailablePeriod;
|
var unavailablePeriod;
|
||||||
|
@ -941,7 +942,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
|
||||||
.getWeekdayName(parseInt($calendar.fullCalendar('getView').start.format('d')));
|
.getWeekdayName(parseInt($calendar.fullCalendar('getView').start.format('d')));
|
||||||
|
|
||||||
// Add custom unavailable periods.
|
// Add custom unavailable periods.
|
||||||
$.each(response.unavailables, function (index, unavailable) {
|
response.unavailables.forEach(function (unavailable, index) {
|
||||||
var notes = unavailable.notes ? ' - ' + unavailable.notes : '';
|
var notes = unavailable.notes ? ' - ' + unavailable.notes : '';
|
||||||
|
|
||||||
if (unavailable.notes.length > 30) {
|
if (unavailable.notes.length > 30) {
|
||||||
|
@ -1048,7 +1049,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
|
||||||
var breakStart;
|
var breakStart;
|
||||||
var breakEnd;
|
var breakEnd;
|
||||||
|
|
||||||
$.each(workingPlan[selectedDayName].breaks, function (index, currentBreak) {
|
workingPlan[selectedDayName].breaks.forEach(function (currentBreak) {
|
||||||
var breakStartString = currentBreak.start.split(':');
|
var breakStartString = currentBreak.start.split(':');
|
||||||
breakStart = calendarDateStart.clone();
|
breakStart = calendarDateStart.clone();
|
||||||
breakStart.hour(parseInt(breakStartString[0]));
|
breakStart.hour(parseInt(breakStartString[0]));
|
||||||
|
@ -1080,7 +1081,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
|
||||||
|
|
||||||
// Add custom unavailable periods (they are always displayed on the calendar, even if
|
// Add custom unavailable periods (they are always displayed on the calendar, even if
|
||||||
// the provider won't work on that day).
|
// the provider won't work on that day).
|
||||||
$.each(response.unavailables, function (index, unavailable) {
|
response.unavailables.forEach(function (unavailable) {
|
||||||
var notes = unavailable.notes ? ' - ' + unavailable.notes : '';
|
var notes = unavailable.notes ? ' - ' + unavailable.notes : '';
|
||||||
|
|
||||||
if (unavailable.notes.length > 30) {
|
if (unavailable.notes.length > 30) {
|
||||||
|
@ -1107,13 +1108,13 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
|
||||||
if (extraWorkingPlan && currentDateStart.format('YYYY-MM-DD') in extraWorkingPlan) {
|
if (extraWorkingPlan && currentDateStart.format('YYYY-MM-DD') in extraWorkingPlan) {
|
||||||
workingDay = extraWorkingPlan[currentDateStart.format('YYYY-MM-DD')]
|
workingDay = extraWorkingPlan[currentDateStart.format('YYYY-MM-DD')]
|
||||||
|
|
||||||
var start_extra = currentDateStart.format('YYYY-MM-DD') + ' ' + extraWorkingPlan[currentDateStart.format('YYYY-MM-DD')].start;
|
var extraPeriodStart = currentDateStart.format('YYYY-MM-DD') + ' ' + extraWorkingPlan[currentDateStart.format('YYYY-MM-DD')].start;
|
||||||
var end_extra = currentDateStart.format('YYYY-MM-DD') + ' ' + extraWorkingPlan[currentDateStart.format('YYYY-MM-DD')].end;
|
var extraPeriodEnd = currentDateStart.format('YYYY-MM-DD') + ' ' + extraWorkingPlan[currentDateStart.format('YYYY-MM-DD')].end;
|
||||||
|
|
||||||
var extraPeriod = {
|
var extraPeriod = {
|
||||||
title: EALang.extra_period,
|
title: EALang.extra_period,
|
||||||
start: moment(start_extra, 'YYYY-MM-DD HH:mm', true),
|
start: moment(extraPeriodStart, 'YYYY-MM-DD HH:mm', true),
|
||||||
end: moment(end_extra, 'YYYY-MM-DD HH:mm', true).add(1, 'day'),
|
end: moment(extraPeriodEnd, 'YYYY-MM-DD HH:mm', true).add(1, 'day'),
|
||||||
allDay: true,
|
allDay: true,
|
||||||
color: '#879DB4',
|
color: '#879DB4',
|
||||||
editable: false,
|
editable: false,
|
||||||
|
@ -1189,7 +1190,7 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
|
||||||
var breakStart;
|
var breakStart;
|
||||||
var breakEnd;
|
var breakEnd;
|
||||||
|
|
||||||
$.each(workingDay.breaks, function (index, currentBreak) {
|
workingDay.breaks.forEach(function (currentBreak, index) {
|
||||||
var breakStartString = currentBreak.start.split(':');
|
var breakStartString = currentBreak.start.split(':');
|
||||||
breakStart = currentDateStart.clone();
|
breakStart = currentDateStart.clone();
|
||||||
breakStart.hour(parseInt(breakStartString[0]));
|
breakStart.hour(parseInt(breakStartString[0]));
|
||||||
|
@ -1417,16 +1418,11 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
|
||||||
if (GlobalVariables.user.role_slug === Backend.DB_SLUG_SECRETARY) {
|
if (GlobalVariables.user.role_slug === Backend.DB_SLUG_SECRETARY) {
|
||||||
// Remove the providers that are not connected to the secretary.
|
// Remove the providers that are not connected to the secretary.
|
||||||
$('#select-filter-item option[type="provider"]').each(function (index, option) {
|
$('#select-filter-item option[type="provider"]').each(function (index, option) {
|
||||||
var found = false;
|
var provider = GlobalVariables.secretaryProviders.find(function(secretaryProviderId) {
|
||||||
|
return Number($(option).val()) === Number(secretaryProviderId);
|
||||||
$.each(GlobalVariables.secretaryProviders, function (index, secretaryProviderId) {
|
|
||||||
if (Number($(option).val()) === Number(secretaryProviderId)) {
|
|
||||||
found = true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!found) {
|
if (!provider) {
|
||||||
$(option).remove();
|
$(option).remove();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -71,9 +71,8 @@ window.BackendCalendarGoogleSync = window.BackendCalendarGoogleSync || {};
|
||||||
$.post(url, data)
|
$.post(url, data)
|
||||||
.done(function (response) {
|
.done(function (response) {
|
||||||
$('#google-calendar').empty();
|
$('#google-calendar').empty();
|
||||||
$.each(response, function () {
|
response.forEach(response, function (event) {
|
||||||
var option = '<option value="' + this.id + '">' + this.summary + '</option>';
|
$('#google-calendar').append(new Option(event.summary, event.id));
|
||||||
$('#google-calendar').append(option);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#select-google-calendar').modal('show');
|
$('#select-google-calendar').modal('show');
|
||||||
|
@ -92,21 +91,21 @@ window.BackendCalendarGoogleSync = window.BackendCalendarGoogleSync || {};
|
||||||
// Disable synchronization for selected provider.
|
// Disable synchronization for selected provider.
|
||||||
// Update page elements and make an AJAX call to remove the google sync setting of the
|
// Update page elements and make an AJAX call to remove the google sync setting of the
|
||||||
// selected provider.
|
// selected provider.
|
||||||
$.each(GlobalVariables.availableProviders, function (index, provider) {
|
var providerId = $('#select-filter-item').val();
|
||||||
if (Number(provider.id) === Number($('#select-filter-item').val())) {
|
|
||||||
provider.settings.google_sync = '0';
|
|
||||||
provider.settings.google_token = null;
|
|
||||||
|
|
||||||
disableProviderSync(provider.id);
|
var provider = GlobalVariables.availableProviders.find(function (availableProvider) {
|
||||||
|
return Number(provider.id) === Number(providerId);
|
||||||
$('#enable-sync').removeClass('btn-danger enabled');
|
|
||||||
$('#enable-sync span:eq(1)').text(EALang.enable_sync);
|
|
||||||
$('#google-sync').prop('disabled', true);
|
|
||||||
$('#select-filter-item option:selected').attr('google-sync', 'false');
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
provider.settings.google_sync = '0';
|
||||||
|
provider.settings.google_token = null;
|
||||||
|
|
||||||
|
disableProviderSync(provider.id);
|
||||||
|
|
||||||
|
$('#enable-sync').removeClass('btn-danger enabled');
|
||||||
|
$('#enable-sync span:eq(1)').text(EALang.enable_sync);
|
||||||
|
$('#google-sync').prop('disabled', true);
|
||||||
|
$('#select-filter-item option:selected').attr('google-sync', 'false');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -89,22 +89,22 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
|
||||||
var $providerColumn = $(providerColumn);
|
var $providerColumn = $(providerColumn);
|
||||||
var provider = $providerColumn.data('provider');
|
var provider = $providerColumn.data('provider');
|
||||||
|
|
||||||
$providerColumn.find('.calendar-wrapper').fullCalendar('removeEvents');
|
// $providerColumn.find('.calendar-wrapper').fullCalendar('removeEvents');
|
||||||
|
|
||||||
createNonWorkingHours($providerColumn.find('.calendar-wrapper'), JSON.parse($providerColumn.data('provider').settings.working_plan));
|
// createNonWorkingHours($providerColumn.find('.calendar-wrapper'), JSON.parse($providerColumn.data('provider').settings.working_plan));
|
||||||
|
|
||||||
// Add the appointments to the column.
|
// Add the appointments to the column.
|
||||||
createAppointments($providerColumn, response.appointments);
|
// createAppointments($providerColumn, response.appointments);
|
||||||
|
|
||||||
// Add the unavailabilities to the column.
|
// Add the unavailabilities to the column.
|
||||||
createUnavailabilities($providerColumn, response.unavailabilities);
|
// createUnavailabilities($providerColumn, response.unavailabilities);
|
||||||
|
|
||||||
// Add the provider breaks to the column.
|
// Add the provider breaks to the column.
|
||||||
var workingPlan = JSON.parse(provider.settings.working_plan);
|
var workingPlan = JSON.parse(provider.settings.working_plan);
|
||||||
var day = date.toString('dddd').toLowerCase();
|
var day = date.toString('dddd').toLowerCase();
|
||||||
if (workingPlan[day]) {
|
if (workingPlan[day]) {
|
||||||
var breaks = workingPlan[day].breaks;
|
var breaks = workingPlan[day].breaks;
|
||||||
createBreaks($providerColumn, breaks);
|
// createBreaks($providerColumn, breaks);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -132,7 +132,7 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
|
||||||
* Hides the open popover element.
|
* Hides the open popover element.
|
||||||
*/
|
*/
|
||||||
$calendar.on('click', '.close-popover', function () {
|
$calendar.on('click', '.close-popover', function () {
|
||||||
$(this).parents().eq(2).popover('destroy');
|
$(this).parents('.popover').popover('destroy');
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -141,7 +141,7 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
|
||||||
* Enables the edit dialog of the selected table event.
|
* Enables the edit dialog of the selected table event.
|
||||||
*/
|
*/
|
||||||
$calendar.on('click', '.edit-popover', function () {
|
$calendar.on('click', '.edit-popover', function () {
|
||||||
$(this).parents().eq(2).remove(); // Hide the popover
|
$(this).parents('.popover').popover('destroy');
|
||||||
|
|
||||||
var $dialog;
|
var $dialog;
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
|
||||||
* deletion then an ajax call is made to the server and deletes the appointment from the database.
|
* deletion then an ajax call is made to the server and deletes the appointment from the database.
|
||||||
*/
|
*/
|
||||||
$calendar.on('click', '.delete-popover', function () {
|
$calendar.on('click', '.delete-popover', function () {
|
||||||
$(this).parents().eq(2).remove(); // Hide the popover.
|
$(this).parents('.popover').popover('destroy'); // Hide the popover.
|
||||||
|
|
||||||
var url;
|
var url;
|
||||||
var data;
|
var data;
|
||||||
|
@ -448,12 +448,14 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
|
||||||
*/
|
*/
|
||||||
function createView(startDate, endDate) {
|
function createView(startDate, endDate) {
|
||||||
// Disable date navigation.
|
// Disable date navigation.
|
||||||
$('#calendar .calendar-header .btn').addClass('disabled').prop('disabled', true);
|
$('#calendar .calendar-header .btn')
|
||||||
|
.addClass('disabled')
|
||||||
|
.prop('disabled', true);
|
||||||
|
|
||||||
// Remember provider calendar view mode.
|
// Remember provider calendar view mode.
|
||||||
var providerView = {};
|
var providerView = {};
|
||||||
$('.provider-column').each(function () {
|
$('.provider-column').each(function (index, providerColumn) {
|
||||||
var $providerColumn = $(this);
|
var $providerColumn = $(providerColumn);
|
||||||
var providerId = $providerColumn.data('provider').id;
|
var providerId = $providerColumn.data('provider').id;
|
||||||
providerView[providerId] = $providerColumn.find('.calendar-wrapper').fullCalendar('getView').name;
|
providerView[providerId] = $providerColumn.find('.calendar-wrapper').fullCalendar('getView').name;
|
||||||
});
|
});
|
||||||
|
@ -491,8 +493,8 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
|
||||||
$('#calendar .calendar-header .btn').removeClass('disabled').prop('disabled', false);
|
$('#calendar .calendar-header .btn').removeClass('disabled').prop('disabled', false);
|
||||||
|
|
||||||
// Apply provider calendar view mode.
|
// Apply provider calendar view mode.
|
||||||
$('.provider-column').each(function () {
|
$('.provider-column').each(function (index, providerColumn) {
|
||||||
var $providerColumn = $(this);
|
var $providerColumn = $(providerColumn);
|
||||||
var providerId = $providerColumn.data('provider').id;
|
var providerId = $providerColumn.data('provider').id;
|
||||||
$providerColumn.find('.calendar-wrapper')
|
$providerColumn.find('.calendar-wrapper')
|
||||||
.fullCalendar('changeView', providerView[providerId] || 'agendaDay');
|
.fullCalendar('changeView', providerView[providerId] || 'agendaDay');
|
||||||
|
@ -1002,7 +1004,7 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
|
||||||
* above the calendar item.
|
* above the calendar item.
|
||||||
*/
|
*/
|
||||||
function onEventClick(event, jsEvent) {
|
function onEventClick(event, jsEvent) {
|
||||||
$('.popover').remove(); // Close all open popovers.
|
$('.popover').popover('destroy'); // Close all open popovers.
|
||||||
|
|
||||||
var $html;
|
var $html;
|
||||||
var displayEdit;
|
var displayEdit;
|
||||||
|
|
|
@ -64,12 +64,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
var categoryId = $(this).attr('data-id');
|
var categoryId = $(this).attr('data-id');
|
||||||
var category = {};
|
|
||||||
$.each(instance.filterResults, function (index, item) {
|
var category = instance.filterResults.find(function (filterResult) {
|
||||||
if (item.id === categoryId) {
|
return Number(filterResult.id) === Number(categoryId);
|
||||||
category = item;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
instance.display(category);
|
instance.display(category);
|
||||||
|
@ -182,7 +179,8 @@
|
||||||
this.filterResults = response;
|
this.filterResults = response;
|
||||||
|
|
||||||
$('#filter-categories .results').empty();
|
$('#filter-categories .results').empty();
|
||||||
$.each(response, function (index, category) {
|
|
||||||
|
response.forEach(function(category) {
|
||||||
$('#filter-categories .results')
|
$('#filter-categories .results')
|
||||||
.append(this.getFilterHtml(category))
|
.append(this.getFilterHtml(category))
|
||||||
.append($('<hr/>'));
|
.append($('<hr/>'));
|
||||||
|
@ -284,9 +282,9 @@
|
||||||
try {
|
try {
|
||||||
var missingRequired = false;
|
var missingRequired = false;
|
||||||
|
|
||||||
$('#categories .required').each(function () {
|
$('#categories .required').each(function (index, requiredField) {
|
||||||
if (!$(this).val()) {
|
if (!$(requiredField).val()) {
|
||||||
$(this).closest('.form-group').addClass('has-error');
|
$(requiredField).closest('.form-group').addClass('has-error');
|
||||||
missingRequired = true;
|
missingRequired = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -350,21 +348,16 @@
|
||||||
|
|
||||||
$('#filter-categories .selected').removeClass('selected');
|
$('#filter-categories .selected').removeClass('selected');
|
||||||
|
|
||||||
$('#filter-categories .category-row').each(function () {
|
$('#filter-categories .category-row[data-id="' + id + '"]').addClass('selected');
|
||||||
if ($(this).attr('data-id') === id) {
|
|
||||||
$(this).addClass('selected');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (display) {
|
if (display) {
|
||||||
$.each(this.filterResults, function (index, category) {
|
var category = this.filterResults.find(function (category) {
|
||||||
if (category.id === id) {
|
return Number(category.id) === Number(id);
|
||||||
this.display(category);
|
|
||||||
$('#edit-category, #delete-category').prop('disabled', false);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
|
this.display(category);
|
||||||
|
|
||||||
|
$('#edit-category, #delete-category').prop('disabled', false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -64,12 +64,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
var customerId = $(this).attr('data-id');
|
var customerId = $(this).attr('data-id');
|
||||||
var customer = {};
|
var customer = instance.filterResults.find(function (filterResult) {
|
||||||
$.each(instance.filterResults, function (index, item) {
|
return Number(filterResult.id) === Number(customerId);
|
||||||
if (Number(item.id) === Number(customerId)) {
|
|
||||||
customer = item;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
instance.display(customer);
|
instance.display(customer);
|
||||||
|
@ -88,19 +84,15 @@
|
||||||
$(this).addClass('selected');
|
$(this).addClass('selected');
|
||||||
|
|
||||||
var customerId = $('#filter-customers .selected').attr('data-id');
|
var customerId = $('#filter-customers .selected').attr('data-id');
|
||||||
var appointmentId = $(this).attr('data-id');
|
|
||||||
var appointment = {};
|
|
||||||
|
|
||||||
$.each(instance.filterResults, function (index, customer) {
|
var customer = instance.filterResults.find(function (filterResult) {
|
||||||
if (customer.id === customerId) {
|
return Number(filterResult.id) === Number(customerId);
|
||||||
$.each(customer.appointments, function (index, customerAppointment) {
|
});
|
||||||
if (Number(customerAppointment.id) === Number(appointmentId)) {
|
|
||||||
appointment = customerAppointment;
|
var appointmentId = $(this).attr('data-id');
|
||||||
return false;
|
|
||||||
}
|
var appointment = customer.appointments.find(function (customerAppointment) {
|
||||||
});
|
return Number(customerAppointment.id) === Number(appointmentId);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
instance.displayAppointment(appointment);
|
instance.displayAppointment(appointment);
|
||||||
|
@ -253,9 +245,9 @@
|
||||||
// Validate required fields.
|
// Validate required fields.
|
||||||
var missingRequired = false;
|
var missingRequired = false;
|
||||||
|
|
||||||
$('.required').each(function () {
|
$('.required').each(function (index, requiredField) {
|
||||||
if ($(this).val() === '') {
|
if ($(requiredField).val() === '') {
|
||||||
$(this).closest('.form-group').addClass('has-error');
|
$(requiredField).closest('.form-group').addClass('has-error');
|
||||||
missingRequired = true;
|
missingRequired = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -319,13 +311,13 @@
|
||||||
$('#timezone').val(customer.timezone);
|
$('#timezone').val(customer.timezone);
|
||||||
|
|
||||||
$('#customer-appointments').empty();
|
$('#customer-appointments').empty();
|
||||||
$.each(customer.appointments, function (index, appointment) {
|
customer.appointments.forEach(function (appointment) {
|
||||||
if (GlobalVariables.user.role_slug === Backend.DB_SLUG_PROVIDER && parseInt(appointment.id_users_provider) !== GlobalVariables.user.id) {
|
if (GlobalVariables.user.role_slug === Backend.DB_SLUG_PROVIDER && parseInt(appointment.id_users_provider) !== GlobalVariables.user.id) {
|
||||||
return true; // continue
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GlobalVariables.user.role_slug === Backend.DB_SLUG_SECRETARY && GlobalVariables.secretaryProviders.indexOf(appointment.id_users_provider) === -1) {
|
if (GlobalVariables.user.role_slug === Backend.DB_SLUG_SECRETARY && GlobalVariables.secretaryProviders.indexOf(appointment.id_users_provider) === -1) {
|
||||||
return true; // continue
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var start = GeneralFunctions.formatDate(Date.parse(appointment.start_datetime), GlobalVariables.dateFormat, true);
|
var start = GeneralFunctions.formatDate(Date.parse(appointment.start_datetime), GlobalVariables.dateFormat, true);
|
||||||
|
@ -377,7 +369,8 @@
|
||||||
this.filterResults = response;
|
this.filterResults = response;
|
||||||
|
|
||||||
$('#filter-customers .results').empty();
|
$('#filter-customers .results').empty();
|
||||||
$.each(response, function (index, customer) {
|
|
||||||
|
response.forEach(function (customer) {
|
||||||
$('#filter-customers .results')
|
$('#filter-customers .results')
|
||||||
.append(this.getFilterHtml(customer))
|
.append(this.getFilterHtml(customer))
|
||||||
.append($('<hr/>'));
|
.append($('<hr/>'));
|
||||||
|
@ -454,21 +447,16 @@
|
||||||
|
|
||||||
$('#filter-customers .selected').removeClass('selected');
|
$('#filter-customers .selected').removeClass('selected');
|
||||||
|
|
||||||
$('#filter-customers .entry').each(function () {
|
$('#filter-customers .entry[data-id="' + id + '"]').addClass('selected');
|
||||||
if (Number($(this).attr('data-id')) === Number(id)) {
|
|
||||||
$(this).addClass('selected');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (display) {
|
if (display) {
|
||||||
$.each(this.filterResults, function (index, customer) {
|
var customer = this.filterResults.find(function (filterResult) {
|
||||||
if (Number(customer.id) === Number(id)) {
|
return Number(filterResult.id) === Number(id);
|
||||||
this.display(customer);
|
});
|
||||||
$('#edit-customer, #delete-customer').prop('disabled', false);
|
|
||||||
return false;
|
this.display(customer);
|
||||||
}
|
|
||||||
}.bind(this));
|
$('#edit-customer, #delete-customer').prop('disabled', false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -41,10 +41,10 @@ window.BackendServices = window.BackendServices || {};
|
||||||
defaultEventHandlers = defaultEventHandlers || true;
|
defaultEventHandlers = defaultEventHandlers || true;
|
||||||
|
|
||||||
// Fill available service categories listbox.
|
// Fill available service categories listbox.
|
||||||
$.each(GlobalVariables.categories, function (index, category) {
|
GlobalVariables.categories.forEach(function (category) {
|
||||||
var option = new Option(category.name, category.id);
|
$('#service-category').append(new Option(category.name, category.id));
|
||||||
$('#service-category').append(option);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#service-category').append(new Option('- ' + EALang.no_category + ' -', null)).val('null');
|
$('#service-category').append(new Option('- ' + EALang.no_category + ' -', null)).val('null');
|
||||||
|
|
||||||
// Instantiate helper object (service helper by default).
|
// Instantiate helper object (service helper by default).
|
||||||
|
@ -102,11 +102,13 @@ window.BackendServices = window.BackendServices || {};
|
||||||
.done(function (response) {
|
.done(function (response) {
|
||||||
GlobalVariables.categories = response;
|
GlobalVariables.categories = response;
|
||||||
var $select = $('#service-category');
|
var $select = $('#service-category');
|
||||||
|
|
||||||
$select.empty();
|
$select.empty();
|
||||||
$.each(response, function (index, category) {
|
|
||||||
var option = new Option(category.name, category.id);
|
response.forEach(function (category) {
|
||||||
$select.append(option);
|
$select.append(new Option(category.name, category.id));
|
||||||
});
|
});
|
||||||
|
|
||||||
$select.append(new Option('- ' + EALang.no_category + ' -', null)).val('null');
|
$select.append(new Option('- ' + EALang.no_category + ' -', null)).val('null');
|
||||||
})
|
})
|
||||||
.fail(GeneralFunctions.ajaxFailureHandler);
|
.fail(GeneralFunctions.ajaxFailureHandler);
|
||||||
|
|
|
@ -62,12 +62,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
var serviceId = $(this).attr('data-id');
|
var serviceId = $(this).attr('data-id');
|
||||||
var service = {};
|
|
||||||
$.each(instance.filterResults, function (index, item) {
|
var service = instance.filterResults.find(function (filterResult) {
|
||||||
if (item.id === serviceId) {
|
return Number(filterResult.id) === Number(serviceId);
|
||||||
service = item;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add dedicated provider link.
|
// Add dedicated provider link.
|
||||||
|
@ -251,9 +248,9 @@
|
||||||
// validate required fields.
|
// validate required fields.
|
||||||
var missingRequired = false;
|
var missingRequired = false;
|
||||||
|
|
||||||
$('#services .required').each(function () {
|
$('#services .required').each(function (index, requiredField) {
|
||||||
if (!$(this).val()) {
|
if (!$(requiredField).val()) {
|
||||||
$(this).closest('.form-group').addClass('has-error');
|
$(requiredField).closest('.form-group').addClass('has-error');
|
||||||
missingRequired = true;
|
missingRequired = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -329,7 +326,8 @@
|
||||||
this.filterResults = response;
|
this.filterResults = response;
|
||||||
|
|
||||||
$('#filter-services .results').empty();
|
$('#filter-services .results').empty();
|
||||||
$.each(response, function (index, service) {
|
|
||||||
|
response.forEach(function (service, index) {
|
||||||
$('#filter-services .results')
|
$('#filter-services .results')
|
||||||
.append(ServicesHelper.prototype.getFilterHtml(service))
|
.append(ServicesHelper.prototype.getFilterHtml(service))
|
||||||
.append( $('<hr/>'))
|
.append( $('<hr/>'))
|
||||||
|
@ -403,21 +401,16 @@
|
||||||
|
|
||||||
$('#filter-services .selected').removeClass('selected');
|
$('#filter-services .selected').removeClass('selected');
|
||||||
|
|
||||||
$('#filter-services .service-row').each(function () {
|
$('#filter-services .service-row[data-id="' + id + '"]').addClass('selected');
|
||||||
if (Number($(this).attr('data-id')) === Number(id)) {
|
|
||||||
$(this).addClass('selected');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (display) {
|
if (display) {
|
||||||
$.each(this.filterResults, function (index, service) {
|
var service = this.filterResults.find(function (filterResult) {
|
||||||
if (Number(service.id) === Number(id)) {
|
return Number(filterResult.id) === Number(id);
|
||||||
this.display(service);
|
});
|
||||||
$('#edit-service, #delete-service').prop('disabled', false);
|
|
||||||
return false;
|
this.display(service);
|
||||||
}
|
|
||||||
}.bind(this));
|
$('#edit-service, #delete-service').prop('disabled', false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -46,19 +46,18 @@ window.BackendSettings = window.BackendSettings || {};
|
||||||
*
|
*
|
||||||
* @param {bool} bindEventHandlers Optional (true), determines whether to bind the default event handlers.
|
* @param {bool} bindEventHandlers Optional (true), determines whether to bind the default event handlers.
|
||||||
*/
|
*/
|
||||||
exports.initialize = function (bindEventHandlers) {
|
exports.initialize = function (defaultEventHandlers) {
|
||||||
bindEventHandlers = bindEventHandlers || true;
|
defaultEventHandlers = defaultEventHandlers || true;
|
||||||
|
|
||||||
$('#cookie-notice-content, #terms-and-conditions-content, #privacy-policy-content').trumbowyg();
|
$('#cookie-notice-content, #terms-and-conditions-content, #privacy-policy-content').trumbowyg();
|
||||||
|
|
||||||
// Apply setting values from database.
|
// Apply setting values from database.
|
||||||
$.each(GlobalVariables.settings.system, function (index, setting) {
|
var workingPlan = {};
|
||||||
|
|
||||||
|
GlobalVariables.settings.system.forEach(function (setting) {
|
||||||
$('input[data-field="' + setting.name + '"]').val(setting.value);
|
$('input[data-field="' + setting.name + '"]').val(setting.value);
|
||||||
$('select[data-field="' + setting.name + '"]').val(setting.value);
|
$('select[data-field="' + setting.name + '"]').val(setting.value);
|
||||||
});
|
|
||||||
|
|
||||||
var workingPlan = {};
|
|
||||||
$.each(GlobalVariables.settings.system, function (index, setting) {
|
|
||||||
if (setting.name === 'company_working_plan') {
|
if (setting.name === 'company_working_plan') {
|
||||||
workingPlan = $.parseJSON(setting.value);
|
workingPlan = $.parseJSON(setting.value);
|
||||||
}
|
}
|
||||||
|
@ -121,7 +120,6 @@ window.BackendSettings = window.BackendSettings || {};
|
||||||
$('#zip-code').val(GlobalVariables.settings.user.zip_code);
|
$('#zip-code').val(GlobalVariables.settings.user.zip_code);
|
||||||
$('#notes').val(GlobalVariables.settings.user.notes);
|
$('#notes').val(GlobalVariables.settings.user.notes);
|
||||||
$('#timezone').val(GlobalVariables.settings.user.timezone);
|
$('#timezone').val(GlobalVariables.settings.user.timezone);
|
||||||
|
|
||||||
$('#username').val(GlobalVariables.settings.user.settings.username);
|
$('#username').val(GlobalVariables.settings.user.settings.username);
|
||||||
$('#password, #retype-password').val('');
|
$('#password, #retype-password').val('');
|
||||||
$('#calendar-view').val(GlobalVariables.settings.user.settings.calendar_view);
|
$('#calendar-view').val(GlobalVariables.settings.user.settings.calendar_view);
|
||||||
|
@ -135,7 +133,7 @@ window.BackendSettings = window.BackendSettings || {};
|
||||||
// Set default settings helper.
|
// Set default settings helper.
|
||||||
settings = new SystemSettings();
|
settings = new SystemSettings();
|
||||||
|
|
||||||
if (bindEventHandlers) {
|
if (defaultEventHandlers) {
|
||||||
bindEventHandlers();
|
bindEventHandlers();
|
||||||
var $link = $('#settings-page .nav li').not('.hidden').first().find('a');
|
var $link = $('#settings-page .nav li').not('.hidden').first().find('a');
|
||||||
$link.tab('show');
|
$link.tab('show');
|
||||||
|
|
|
@ -67,10 +67,10 @@
|
||||||
var settings = [];
|
var settings = [];
|
||||||
|
|
||||||
// General Settings Tab
|
// General Settings Tab
|
||||||
$('#general').find('input, select').each(function () {
|
$('#general').find('input, select').each(function (index, field) {
|
||||||
settings.push({
|
settings.push({
|
||||||
name: $(this).attr('data-field'),
|
name: $(field).attr('data-field'),
|
||||||
value: $(this).val()
|
value: $(field).val()
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -153,9 +153,9 @@
|
||||||
try {
|
try {
|
||||||
// Validate required fields.
|
// Validate required fields.
|
||||||
var missingRequired = false;
|
var missingRequired = false;
|
||||||
$('#general .required').each(function () {
|
$('#general .required').each(function (index, requiredField) {
|
||||||
if (!$(this).val()) {
|
if (!$(requiredField).val()) {
|
||||||
$(this).closest('.form-group').addClass('has-error');
|
$(requiredField).closest('.form-group').addClass('has-error');
|
||||||
missingRequired = true;
|
missingRequired = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -96,9 +96,9 @@
|
||||||
try {
|
try {
|
||||||
// Validate required fields.
|
// Validate required fields.
|
||||||
var missingRequired = false;
|
var missingRequired = false;
|
||||||
$('#user .required').each(function () {
|
$('#user .required').each(function (index, requiredField) {
|
||||||
if (!$(this).val()) {
|
if (!$(requiredField).val()) {
|
||||||
$(this).closest('.form-group').addClass('has-error');
|
$(requiredField).closest('.form-group').addClass('has-error');
|
||||||
missingRequired = true;
|
missingRequired = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -150,6 +150,8 @@ window.BackendUsers = window.BackendUsers || {};
|
||||||
.done(function (response) {
|
.done(function (response) {
|
||||||
GlobalVariables.providers = response;
|
GlobalVariables.providers = response;
|
||||||
|
|
||||||
|
$('#secretary-providers').empty();
|
||||||
|
|
||||||
GlobalVariables.providers.forEach(function(provider) {
|
GlobalVariables.providers.forEach(function(provider) {
|
||||||
$('<div/>', {
|
$('<div/>', {
|
||||||
'class': 'checkbox',
|
'class': 'checkbox',
|
||||||
|
|
|
@ -56,25 +56,21 @@
|
||||||
*
|
*
|
||||||
* Display the selected admin data to the user.
|
* Display the selected admin data to the user.
|
||||||
*/
|
*/
|
||||||
$('#admins').on('click', '.admin-row', function (e) {
|
$('#admins').on('click', '.admin-row', function (event) {
|
||||||
if ($('#filter-admins .filter').prop('disabled')) {
|
if ($('#filter-admins .filter').prop('disabled')) {
|
||||||
$('#filter-admins .results').css('color', '#AAA');
|
$('#filter-admins .results').css('color', '#AAA');
|
||||||
return; // exit because we are currently on edit mode
|
return; // exit because we are currently on edit mode
|
||||||
}
|
}
|
||||||
|
|
||||||
var adminId = $(e.currentTarget).attr('data-id');
|
var adminId = $(event.currentTarget).attr('data-id');
|
||||||
var admin = {};
|
|
||||||
|
|
||||||
$.each(this.filterResults, function (index, item) {
|
var admin = this.filterResults.find(function (filterResult) {
|
||||||
if (item.id === adminId) {
|
return Number(filterResult.id) === Number(adminId);
|
||||||
admin = item;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.display(admin);
|
this.display(admin);
|
||||||
$('#filter-admins .selected').removeClass('selected');
|
$('#filter-admins .selected').removeClass('selected');
|
||||||
$(e.currentTarget).addClass('selected');
|
$(event.currentTarget).addClass('selected');
|
||||||
$('#edit-admin, #delete-admin').prop('disabled', false);
|
$('#edit-admin, #delete-admin').prop('disabled', false);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
|
@ -245,9 +241,9 @@
|
||||||
// Validate required fields.
|
// Validate required fields.
|
||||||
var missingRequired = false;
|
var missingRequired = false;
|
||||||
|
|
||||||
$('#admins .required').each(function () {
|
$('#admins .required').each(function (index, requiredField) {
|
||||||
if (!$(this).val()) {
|
if (!$(requiredField).val()) {
|
||||||
$(this).closest('.form-group').addClass('has-error');
|
$(requiredField).closest('.form-group').addClass('has-error');
|
||||||
missingRequired = true;
|
missingRequired = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -362,7 +358,8 @@
|
||||||
this.filterResults = response;
|
this.filterResults = response;
|
||||||
|
|
||||||
$('#filter-admins .results').empty();
|
$('#filter-admins .results').empty();
|
||||||
$.each(response, function (index, admin) {
|
|
||||||
|
response.forEach(function (admin) {
|
||||||
$('#filter-admins .results')
|
$('#filter-admins .results')
|
||||||
.append(this.getFilterHtml(admin))
|
.append(this.getFilterHtml(admin))
|
||||||
.append($('<hr/>'));
|
.append($('<hr/>'));
|
||||||
|
@ -439,21 +436,16 @@
|
||||||
|
|
||||||
$('#filter-admins .selected').removeClass('selected');
|
$('#filter-admins .selected').removeClass('selected');
|
||||||
|
|
||||||
$('.admin-row').each(function () {
|
$('#filter-admins .admin-row[data-id="' + id + '"]').addClass('selected');
|
||||||
if (Number($(this).attr('data-id')) === Number(id)) {
|
|
||||||
$(this).addClass('selected');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (display) {
|
if (display) {
|
||||||
$.each(this.filterResults, function (index, admin) {
|
var admin = this.filterResults.find(function (filterResult) {
|
||||||
if (Number(admin.id) === Number(id)) {
|
return Number(filterResult.id) === Number(id);
|
||||||
this.display(admin);
|
});
|
||||||
$('#edit-admin, #delete-admin').prop('disabled', false);
|
|
||||||
return false;
|
this.display(admin);
|
||||||
}
|
|
||||||
}.bind(this));
|
$('#edit-admin, #delete-admin').prop('disabled', false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -58,25 +58,20 @@
|
||||||
*
|
*
|
||||||
* Display the selected provider data to the user.
|
* Display the selected provider data to the user.
|
||||||
*/
|
*/
|
||||||
$('#providers').on('click', '.provider-row', function (e) {
|
$('#providers').on('click', '.provider-row', function (event) {
|
||||||
if ($('#filter-providers .filter').prop('disabled')) {
|
if ($('#filter-providers .filter').prop('disabled')) {
|
||||||
$('#filter-providers .results').css('color', '#AAA');
|
$('#filter-providers .results').css('color', '#AAA');
|
||||||
return; // Exit because we are currently on edit mode.
|
return; // Exit because we are currently on edit mode.
|
||||||
}
|
}
|
||||||
|
|
||||||
var providerId = $(e.currentTarget).attr('data-id');
|
var providerId = $(event.currentTarget).attr('data-id');
|
||||||
var provider = {};
|
var provider = this.filterResults.find(function (filterResult) {
|
||||||
|
return Number(filterResult.id) === Number(providerId);
|
||||||
$.each(this.filterResults, function (index, item) {
|
|
||||||
if (item.id === providerId) {
|
|
||||||
provider = item;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.display(provider);
|
this.display(provider);
|
||||||
$('#filter-providers .selected').removeClass('selected');
|
$('#filter-providers .selected').removeClass('selected');
|
||||||
$(e.currentTarget).addClass('selected');
|
$(event.currentTarget).addClass('selected');
|
||||||
$('#edit-provider, #delete-provider').prop('disabled', false);
|
$('#edit-provider, #delete-provider').prop('disabled', false);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
|
@ -172,9 +167,9 @@
|
||||||
|
|
||||||
// Include provider services.
|
// Include provider services.
|
||||||
provider.services = [];
|
provider.services = [];
|
||||||
$('#provider-services input:checkbox').each(function () {
|
$('#provider-services input:checkbox').each(function (index, checkbox) {
|
||||||
if ($(this).prop('checked')) {
|
if ($(checkbox).prop('checked')) {
|
||||||
provider.services.push($(this).attr('data-id'));
|
provider.services.push($(checkbox).attr('data-id'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -297,9 +292,9 @@
|
||||||
try {
|
try {
|
||||||
// Validate required fields.
|
// Validate required fields.
|
||||||
var missingRequired = false;
|
var missingRequired = false;
|
||||||
$('#providers .required').each(function () {
|
$('#providers .required').each(function (index, requiredField) {
|
||||||
if (!$(this).val()) {
|
if (!$(requiredField).val()) {
|
||||||
$(this).closest('.form-group').addClass('has-error');
|
$(requiredField).closest('.form-group').addClass('has-error');
|
||||||
missingRequired = true;
|
missingRequired = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -421,26 +416,30 @@
|
||||||
|
|
||||||
$('#provider-services a').remove();
|
$('#provider-services a').remove();
|
||||||
$('#provider-services input:checkbox').prop('checked', false);
|
$('#provider-services input:checkbox').prop('checked', false);
|
||||||
$.each(provider.services, function (index, serviceId) {
|
|
||||||
$('#provider-services input:checkbox').each(function () {
|
|
||||||
if (Number($(this).attr('data-id')) === Number(serviceId)) {
|
|
||||||
$(this).prop('checked', true);
|
|
||||||
// Add dedicated service-provider link.
|
|
||||||
dedicatedUrl = GlobalVariables.baseUrl + '/index.php?provider=' + encodeURIComponent(provider.id)
|
|
||||||
+ '&service=' + encodeURIComponent(serviceId);
|
|
||||||
|
|
||||||
$link = $('<a/>', {
|
provider.services.forEach(function (providerServiceId) {
|
||||||
'href': dedicatedUrl,
|
var $checkbox = $('#provider-services input[data-id="' + providerServiceId + '"]');
|
||||||
'html': [
|
|
||||||
$('<span/>', {
|
|
||||||
'class': 'glyphicon glyphicon-link'
|
|
||||||
})
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
$(this).parent().append($link);
|
if (!$checkbox.length) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$checkbox.prop('checked', true);
|
||||||
|
|
||||||
|
// Add dedicated service-provider link.
|
||||||
|
dedicatedUrl = GlobalVariables.baseUrl + '/index.php?provider=' + encodeURIComponent(provider.id)
|
||||||
|
+ '&service=' + encodeURIComponent(providerServiceId);
|
||||||
|
|
||||||
|
$link = $('<a/>', {
|
||||||
|
'href': dedicatedUrl,
|
||||||
|
'html': [
|
||||||
|
$('<span/>', {
|
||||||
|
'class': 'glyphicon glyphicon-link'
|
||||||
|
})
|
||||||
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$checkbox.parent().append($link);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Display working plan
|
// Display working plan
|
||||||
|
@ -476,7 +475,7 @@
|
||||||
this.filterResults = response;
|
this.filterResults = response;
|
||||||
|
|
||||||
$('#filter-providers .results').empty();
|
$('#filter-providers .results').empty();
|
||||||
$.each(response, function (index, provider) {
|
response.forEach(function (provider) {
|
||||||
$('#filter-providers .results')
|
$('#filter-providers .results')
|
||||||
.append(this.getFilterHtml(provider))
|
.append(this.getFilterHtml(provider))
|
||||||
.append($('<hr/>'));
|
.append($('<hr/>'));
|
||||||
|
@ -617,22 +616,17 @@
|
||||||
display = display || false;
|
display = display || false;
|
||||||
|
|
||||||
// Select record in filter results.
|
// Select record in filter results.
|
||||||
$('#filter-providers .provider-row').each(function () {
|
$('#filter-providers .provider-row[data-id="' + id + '"]').addClass('selected');
|
||||||
if (Number($(this).attr('data-id')) === Number(id)) {
|
|
||||||
$(this).addClass('selected');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Display record in form (if display = true).
|
// Display record in form (if display = true).
|
||||||
if (display) {
|
if (display) {
|
||||||
$.each(this.filterResults, function (index, provider) {
|
var provider = this.filterResults.find(function (filterResult) {
|
||||||
if (Number(provider.id) === Number(id)) {
|
return Number(filterResult.id) === Number(id);
|
||||||
this.display(provider);
|
|
||||||
$('#edit-provider, #delete-provider').prop('disabled', false);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
|
this.display(provider);
|
||||||
|
|
||||||
|
$('#edit-provider, #delete-provider').prop('disabled', false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -58,26 +58,22 @@
|
||||||
*
|
*
|
||||||
* Display the selected secretary data to the user.
|
* Display the selected secretary data to the user.
|
||||||
*/
|
*/
|
||||||
$('#secretaries').on('click', '.secretary-row', function (e) {
|
$('#secretaries').on('click', '.secretary-row', function (event) {
|
||||||
if ($('#filter-secretaries .filter').prop('disabled')) {
|
if ($('#filter-secretaries .filter').prop('disabled')) {
|
||||||
$('#filter-secretaries .results').css('color', '#AAA');
|
$('#filter-secretaries .results').css('color', '#AAA');
|
||||||
return; // exit because we are currently on edit mode
|
return; // exit because we are currently on edit mode
|
||||||
}
|
}
|
||||||
|
|
||||||
var secretaryId = $(e.currentTarget).attr('data-id');
|
var secretaryId = $(event.currentTarget).attr('data-id');
|
||||||
var secretary = {};
|
|
||||||
|
|
||||||
$.each(this.filterResults, function (index, item) {
|
var secretary = this.filterResults.find(function (filterResult) {
|
||||||
if (item.id === secretaryId) {
|
return Number(filterResult.id) === Number(secretaryId);
|
||||||
secretary = item;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.display(secretary);
|
this.display(secretary);
|
||||||
|
|
||||||
$('#filter-secretaries .selected').removeClass('selected');
|
$('#filter-secretaries .selected').removeClass('selected');
|
||||||
$(e.currentTarget).addClass('selected');
|
$(event.currentTarget).addClass('selected');
|
||||||
$('#edit-secretary, #delete-secretary').prop('disabled', false);
|
$('#edit-secretary, #delete-secretary').prop('disabled', false);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
|
@ -163,9 +159,9 @@
|
||||||
|
|
||||||
// Include secretary services.
|
// Include secretary services.
|
||||||
secretary.providers = [];
|
secretary.providers = [];
|
||||||
$('#secretary-providers input:checkbox').each(function () {
|
$('#secretary-providers input:checkbox').each(function (index, checkbox) {
|
||||||
if ($(this).prop('checked')) {
|
if ($(checkbox).prop('checked')) {
|
||||||
secretary.providers.push($(this).attr('data-id'));
|
secretary.providers.push($(checkbox).attr('data-id'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -258,9 +254,9 @@
|
||||||
try {
|
try {
|
||||||
// Validate required fields.
|
// Validate required fields.
|
||||||
var missingRequired = false;
|
var missingRequired = false;
|
||||||
$('#secretaries .required').each(function () {
|
$('#secretaries .required').each(function (index, requiredField) {
|
||||||
if (!$(this).val()) {
|
if (!$(requiredField).val()) {
|
||||||
$(this).closest('.form-group').addClass('has-error');
|
$(requiredField).closest('.form-group').addClass('has-error');
|
||||||
missingRequired = true;
|
missingRequired = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -353,12 +349,15 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#secretary-providers input:checkbox').prop('checked', false);
|
$('#secretary-providers input:checkbox').prop('checked', false);
|
||||||
$.each(secretary.providers, function (index, providerId) {
|
|
||||||
$('#secretary-providers input:checkbox').each(function () {
|
secretary.providers.forEach(function (secretaryProviderId) {
|
||||||
if (Number($(this).attr('data-id')) === Number(providerId)) {
|
var $checkbox = $('#secretary-providers input[data-id="' + secretaryProviderId + '"]');
|
||||||
$(this).prop('checked', true);
|
|
||||||
}
|
if (!$checkbox.length) {
|
||||||
});
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$checkbox.prop('checked', true);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -386,7 +385,8 @@
|
||||||
this.filterResults = response;
|
this.filterResults = response;
|
||||||
|
|
||||||
$('#filter-secretaries .results').empty();
|
$('#filter-secretaries .results').empty();
|
||||||
$.each(response, function (index, secretary) {
|
|
||||||
|
response.forEach(function (secretary) {
|
||||||
$('#filter-secretaries .results')
|
$('#filter-secretaries .results')
|
||||||
.append(this.getFilterHtml(secretary))
|
.append(this.getFilterHtml(secretary))
|
||||||
.append($('<hr/>'));
|
.append($('<hr/>'));
|
||||||
|
@ -462,21 +462,16 @@
|
||||||
|
|
||||||
$('#filter-secretaries .selected').removeClass('selected');
|
$('#filter-secretaries .selected').removeClass('selected');
|
||||||
|
|
||||||
$('#filter-secretaries .secretary-row').each(function () {
|
$('#filter-secretaries .secretary-row[data-id="' + id + '"]').addClass('selected');
|
||||||
if (Number($(this).attr('data-id')) === Number(id)) {
|
|
||||||
$(this).addClass('selected');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (display) {
|
if (display) {
|
||||||
$.each(this.filterResults, function (index, secretary) {
|
var secretary = this.filterResults.find(function (filterResult) {
|
||||||
if (Number(secretary.id) === Number(id)) {
|
return Number(filterResult.id) === Number(id);
|
||||||
this.display(secretary);
|
|
||||||
$('#edit-secretary, #delete-secretary').prop('disabled', false);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
|
this.display(secretary);
|
||||||
|
|
||||||
|
$('#edit-secretary, #delete-secretary').prop('disabled', false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ window.FrontendBook = window.FrontendBook || {};
|
||||||
/**
|
/**
|
||||||
* This method initializes the book appointment page.
|
* This method initializes the book appointment page.
|
||||||
*
|
*
|
||||||
* @param {Boolean} bindEventHandlers (OPTIONAL) Determines whether the default
|
* @param {Boolean} defaultEventHandlers (OPTIONAL) Determines whether the default
|
||||||
* event handlers will be bound to the dom elements.
|
* event handlers will be bound to the dom elements.
|
||||||
* @param {Boolean} manageMode (OPTIONAL) Determines whether the customer is going
|
* @param {Boolean} manageMode (OPTIONAL) Determines whether the customer is going
|
||||||
* to make changes to an existing appointment rather than booking a new one.
|
* to make changes to an existing appointment rather than booking a new one.
|
||||||
|
@ -57,11 +57,6 @@ window.FrontendBook = window.FrontendBook || {};
|
||||||
defaultEventHandlers = defaultEventHandlers || true;
|
defaultEventHandlers = defaultEventHandlers || true;
|
||||||
manageMode = manageMode || false;
|
manageMode = manageMode || false;
|
||||||
|
|
||||||
if (window.console) {
|
|
||||||
window.console = function () {
|
|
||||||
}; // IE compatibility
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GlobalVariables.displayCookieNotice) {
|
if (GlobalVariables.displayCookieNotice) {
|
||||||
cookieconsent.initialise({
|
cookieconsent.initialise({
|
||||||
palette: {
|
palette: {
|
||||||
|
@ -231,18 +226,18 @@ window.FrontendBook = window.FrontendBook || {};
|
||||||
*/
|
*/
|
||||||
$('#select-service').change(function () {
|
$('#select-service').change(function () {
|
||||||
var serviceId = $('#select-service').val();
|
var serviceId = $('#select-service').val();
|
||||||
|
|
||||||
$('#select-provider').empty();
|
$('#select-provider').empty();
|
||||||
|
|
||||||
$.each(GlobalVariables.availableProviders, function (indexProvider, provider) {
|
GlobalVariables.availableProviders.forEach(function (provider) {
|
||||||
$.each(provider.services, function (indexService, providerServiceId) {
|
// If the current provider is able to provide the selected service, add him to the list box.
|
||||||
// If the current provider is able to provide the selected service, add him to the listbox.
|
var canServeService = provider.services.filter(function (providerServiceId) {
|
||||||
if (Number(providerServiceId) === Number(serviceId)) {
|
return Number(providerServiceId) === Number(serviceId);
|
||||||
var optionHtml = '<option value="' + provider.id + '">'
|
}).length > 0;
|
||||||
+ provider.first_name + ' ' + provider.last_name
|
|
||||||
+ '</option>';
|
if (canServeService) {
|
||||||
$('#select-provider').append(optionHtml);
|
$('#select-provider').append(new Option(provider.first_name + ' ' + provider.last_name, provider.id));
|
||||||
}
|
}
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add the "Any Provider" entry.
|
// Add the "Any Provider" entry.
|
||||||
|
@ -464,9 +459,9 @@ window.FrontendBook = window.FrontendBook || {};
|
||||||
try {
|
try {
|
||||||
// Validate required fields.
|
// Validate required fields.
|
||||||
var missingRequiredField = false;
|
var missingRequiredField = false;
|
||||||
$('.required').each(function () {
|
$('.required').each(function (index, requiredField) {
|
||||||
if (!$(this).val()) {
|
if (!$(requiredField).val()) {
|
||||||
$(this).parents('.form-group').addClass('has-error');
|
$(requiredField).parents('.form-group').addClass('has-error');
|
||||||
missingRequiredField = true;
|
missingRequiredField = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -528,6 +523,8 @@ window.FrontendBook = window.FrontendBook || {};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#appointment-details').empty();
|
||||||
|
|
||||||
$('<div/>', {
|
$('<div/>', {
|
||||||
'html': [
|
'html': [
|
||||||
$('<h4/>', {
|
$('<h4/>', {
|
||||||
|
@ -548,7 +545,7 @@ window.FrontendBook = window.FrontendBook || {};
|
||||||
$('<br/>'),
|
$('<br/>'),
|
||||||
$('<span/>', {
|
$('<span/>', {
|
||||||
'text': $('#select-timezone option:selected').text()
|
'text': $('#select-timezone option:selected').text()
|
||||||
+ servicePrice + ' ' + serviceCurrency
|
+ ' - ' + servicePrice + ' ' + serviceCurrency
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
@ -567,6 +564,8 @@ window.FrontendBook = window.FrontendBook || {};
|
||||||
var city = GeneralFunctions.escapeHtml($('#city').val());
|
var city = GeneralFunctions.escapeHtml($('#city').val());
|
||||||
var zipCode = GeneralFunctions.escapeHtml($('#zip-code').val());
|
var zipCode = GeneralFunctions.escapeHtml($('#zip-code').val());
|
||||||
|
|
||||||
|
$('#customer-details').empty();
|
||||||
|
|
||||||
$('<div/>', {
|
$('<div/>', {
|
||||||
'html': [
|
'html': [
|
||||||
$('<h4/>)', {
|
$('<h4/>)', {
|
||||||
|
@ -644,13 +643,9 @@ window.FrontendBook = window.FrontendBook || {};
|
||||||
function calculateEndDatetime() {
|
function calculateEndDatetime() {
|
||||||
// Find selected service duration.
|
// Find selected service duration.
|
||||||
var serviceId = $('#select-service').val();
|
var serviceId = $('#select-service').val();
|
||||||
var serviceDuration;
|
|
||||||
|
|
||||||
$.each(GlobalVariables.availableServices, function (index, service) {
|
var service = GlobalVariables.availableServices.find(function (availableService) {
|
||||||
if (Number(service.id) === Number(serviceId)) {
|
return Number(availableService.id) === Number(serviceId);
|
||||||
serviceDuration = service.duration;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add the duration to the start datetime.
|
// Add the duration to the start datetime.
|
||||||
|
@ -659,8 +654,8 @@ window.FrontendBook = window.FrontendBook || {};
|
||||||
startDatetime = Date.parseExact(startDatetime, 'dd-MM-yyyy HH:mm');
|
startDatetime = Date.parseExact(startDatetime, 'dd-MM-yyyy HH:mm');
|
||||||
var endDatetime;
|
var endDatetime;
|
||||||
|
|
||||||
if (serviceDuration && startDatetime) {
|
if (service.duration && startDatetime) {
|
||||||
endDatetime = startDatetime.add({'minutes': parseInt(serviceDuration)});
|
endDatetime = startDatetime.add({'minutes': parseInt(service.duration)});
|
||||||
} else {
|
} else {
|
||||||
endDatetime = new Date();
|
endDatetime = new Date();
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,9 +76,9 @@ $(function () {
|
||||||
|
|
||||||
// Check for empty fields.
|
// Check for empty fields.
|
||||||
var missingRequired = false;
|
var missingRequired = false;
|
||||||
$('input').each(function () {
|
$('input').each(function (index, field) {
|
||||||
if (!$(this).val()) {
|
if (!$(field).val()) {
|
||||||
$(this).closest('.form-group').addClass('has-error');
|
$(field).closest('.form-group').addClass('has-error');
|
||||||
missingRequired = true;
|
missingRequired = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -45,8 +45,8 @@
|
||||||
* @param {Object} workingPlan Contains the working hours and breaks for each day of the week.
|
* @param {Object} workingPlan Contains the working hours and breaks for each day of the week.
|
||||||
*/
|
*/
|
||||||
WorkingPlan.prototype.setup = function (workingPlan) {
|
WorkingPlan.prototype.setup = function (workingPlan) {
|
||||||
var fDaynum = GeneralFunctions.getWeekDayId(GlobalVariables.firstWeekday);
|
var weekDayId = GeneralFunctions.getWeekDayId(GlobalVariables.firstWeekday);
|
||||||
var workingPlanSorted = GeneralFunctions.sortWeekDictionary(workingPlan,fDaynum);
|
var workingPlanSorted = GeneralFunctions.sortWeekDictionary(workingPlan, weekDayId);
|
||||||
|
|
||||||
$('.working-plan tbody').empty();
|
$('.working-plan tbody').empty();
|
||||||
$('.breaks tbody').empty();
|
$('.breaks tbody').empty();
|
||||||
|
@ -57,7 +57,7 @@
|
||||||
$.each(workingPlanSorted, function (index, workingDay) {
|
$.each(workingPlanSorted, function (index, workingDay) {
|
||||||
var day = this.convertValueToDay(index);
|
var day = this.convertValueToDay(index);
|
||||||
|
|
||||||
var dayTranslatedName = GeneralFunctions.upperCaseFirstLetter(day)
|
var dayDisplayName = GeneralFunctions.upperCaseFirstLetter(day)
|
||||||
|
|
||||||
$('<tr/>', {
|
$('<tr/>', {
|
||||||
'html': [
|
'html': [
|
||||||
|
@ -70,10 +70,10 @@
|
||||||
'html': [
|
'html': [
|
||||||
$('<input/>', {
|
$('<input/>', {
|
||||||
'type': 'checkbox',
|
'type': 'checkbox',
|
||||||
'id': index,
|
'id': index
|
||||||
}),
|
}),
|
||||||
$('<span/>', {
|
$('<span/>', {
|
||||||
'text': dayTranslatedName
|
'text': dayDisplayName
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
@ -108,19 +108,16 @@
|
||||||
|
|
||||||
// Sort day's breaks according to the starting hour
|
// Sort day's breaks according to the starting hour
|
||||||
workingDay.breaks.sort(function (break1, break2) {
|
workingDay.breaks.sort(function (break1, break2) {
|
||||||
// We can do a direct string comparison since we have time based on 24 hours clock.
|
// We can do a direct string comparison since we have time based on 24 hours clock.
|
||||||
return (break1.start).localeCompare(break2.start);
|
return (break1.start).localeCompare(break2.start);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add the day's breaks on the breaks table.
|
workingDay.breaks.forEach(function (workingDayBreak) {
|
||||||
var timeFormat = GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm';
|
|
||||||
|
|
||||||
workingDay.breaks.forEach(function(workingDayBreak, index) {
|
|
||||||
$('<tr/>', {
|
$('<tr/>', {
|
||||||
'html': [
|
'html': [
|
||||||
$('<td/>', {
|
$('<td/>', {
|
||||||
'class': 'break-day editable',
|
'class': 'break-day editable',
|
||||||
'text': dayTranslatedName
|
'text': dayDisplayName
|
||||||
}),
|
}),
|
||||||
$('<td/>', {
|
$('<td/>', {
|
||||||
'class': 'break-start editable',
|
'class': 'break-start editable',
|
||||||
|
@ -141,11 +138,7 @@
|
||||||
'class': 'glyphicon glyphicon-pencil'
|
'class': 'glyphicon glyphicon-pencil'
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
})
|
}),
|
||||||
]
|
|
||||||
}),
|
|
||||||
$('<td/>', {
|
|
||||||
'html': [
|
|
||||||
$('<button/>', {
|
$('<button/>', {
|
||||||
'type': 'button',
|
'type': 'button',
|
||||||
'class': 'btn btn-default btn-sm delete-break',
|
'class': 'btn btn-default btn-sm delete-break',
|
||||||
|
@ -155,11 +148,7 @@
|
||||||
'class': 'glyphicon glyphicon-trash'
|
'class': 'glyphicon glyphicon-trash'
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
})
|
}),
|
||||||
]
|
|
||||||
}),
|
|
||||||
$('<td/>', {
|
|
||||||
'html': [
|
|
||||||
$('<button/>', {
|
$('<button/>', {
|
||||||
'type': 'button',
|
'type': 'button',
|
||||||
'class': 'btn btn-default btn-sm save-break hidden',
|
'class': 'btn btn-default btn-sm save-break hidden',
|
||||||
|
@ -169,11 +158,7 @@
|
||||||
'class': 'glyphicon glyphicon-ok'
|
'class': 'glyphicon glyphicon-ok'
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
})
|
}),
|
||||||
]
|
|
||||||
}),
|
|
||||||
$('<td/>', {
|
|
||||||
'html': [
|
|
||||||
$('<button/>', {
|
$('<button/>', {
|
||||||
'type': 'button',
|
'type': 'button',
|
||||||
'class': 'btn btn-default btn-sm cancel-break hidden',
|
'class': 'btn btn-default btn-sm cancel-break hidden',
|
||||||
|
@ -210,7 +195,6 @@
|
||||||
WorkingPlan.prototype.setupExtraPeriods = function (extraWorkingPlan) {
|
WorkingPlan.prototype.setupExtraPeriods = function (extraWorkingPlan) {
|
||||||
$.each(extraWorkingPlan, function (index, extraWorkingDay) {
|
$.each(extraWorkingPlan, function (index, extraWorkingDay) {
|
||||||
if (extraWorkingDay) {
|
if (extraWorkingDay) {
|
||||||
|
|
||||||
$('#' + index).prop('checked', true);
|
$('#' + index).prop('checked', true);
|
||||||
$('#' + index + '-start').val(Date.parse(extraWorkingDay.start).toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm').toUpperCase());
|
$('#' + index + '-start').val(Date.parse(extraWorkingDay.start).toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm').toUpperCase());
|
||||||
$('#' + index + '-end').val(Date.parse(extraWorkingDay.end).toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm').toUpperCase());
|
$('#' + index + '-end').val(Date.parse(extraWorkingDay.end).toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm').toUpperCase());
|
||||||
|
@ -244,11 +228,7 @@
|
||||||
'class': 'glyphicon glyphicon-pencil'
|
'class': 'glyphicon glyphicon-pencil'
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
})
|
}),
|
||||||
]
|
|
||||||
}),
|
|
||||||
$('<td/>', {
|
|
||||||
'html': [
|
|
||||||
$('<button/>', {
|
$('<button/>', {
|
||||||
'type': 'button',
|
'type': 'button',
|
||||||
'class': 'btn btn-default btn-sm delete-extra',
|
'class': 'btn btn-default btn-sm delete-extra',
|
||||||
|
@ -258,11 +238,7 @@
|
||||||
'class': 'glyphicon glyphicon-trash'
|
'class': 'glyphicon glyphicon-trash'
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
})
|
}),
|
||||||
]
|
|
||||||
}),
|
|
||||||
$('<td/>', {
|
|
||||||
'html': [
|
|
||||||
$('<button/>', {
|
$('<button/>', {
|
||||||
'type': 'button',
|
'type': 'button',
|
||||||
'class': 'btn btn-default btn-sm save-extra hidden',
|
'class': 'btn btn-default btn-sm save-extra hidden',
|
||||||
|
@ -272,11 +248,7 @@
|
||||||
'class': 'glyphicon glyphicon-ok'
|
'class': 'glyphicon glyphicon-ok'
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
})
|
}),
|
||||||
]
|
|
||||||
}),
|
|
||||||
$('<td/>', {
|
|
||||||
'html': [
|
|
||||||
$('<button/>', {
|
$('<button/>', {
|
||||||
'type': 'button',
|
'type': 'button',
|
||||||
'class': 'btn btn-default btn-sm cancel-extra hidden',
|
'class': 'btn btn-default btn-sm cancel-extra hidden',
|
||||||
|
@ -395,7 +367,7 @@
|
||||||
*
|
*
|
||||||
* Enable or disable the time selection for each day.
|
* Enable or disable the time selection for each day.
|
||||||
*/
|
*/
|
||||||
$('.working-plan tbody').on( "click", "input:checkbox", function () {
|
$('.working-plan tbody').on("click", "input:checkbox", function () {
|
||||||
var id = $(this).attr('id');
|
var id = $(this).attr('id');
|
||||||
|
|
||||||
if ($(this).prop('checked') === true) {
|
if ($(this).prop('checked') === true) {
|
||||||
|
@ -416,79 +388,67 @@
|
||||||
$('.add-break').click(function () {
|
$('.add-break').click(function () {
|
||||||
var timeFormat = GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm';
|
var timeFormat = GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm';
|
||||||
|
|
||||||
var $newBreak = $('<tr/>', {
|
var $newBreak = $('<tr/>', {
|
||||||
'html': [
|
'html': [
|
||||||
$('<td/>', {
|
$('<td/>', {
|
||||||
'class': 'break-day editable',
|
'class': 'break-day editable',
|
||||||
'text': EALang.sunday
|
'text': EALang.sunday
|
||||||
}),
|
}),
|
||||||
$('<td/>', {
|
$('<td/>', {
|
||||||
'class': 'break-start editable',
|
'class': 'break-start editable',
|
||||||
'text': '9:00 AM'
|
'text': '9:00 AM'
|
||||||
}),
|
}),
|
||||||
$('<td/>', {
|
$('<td/>', {
|
||||||
'class': 'break-end editable',
|
'class': 'break-end editable',
|
||||||
'text': '10:00 AM'
|
'text': '10:00 AM'
|
||||||
}),
|
}),
|
||||||
$('<td/>', {
|
$('<td/>', {
|
||||||
'html': [
|
'html': [
|
||||||
$('<button/>', {
|
$('<button/>', {
|
||||||
'type': 'button',
|
'type': 'button',
|
||||||
'class': 'btn btn-default btn-sm edit-break',
|
'class': 'btn btn-default btn-sm edit-break',
|
||||||
'title': EALang.edit,
|
'title': EALang.edit,
|
||||||
'html': [
|
'html': [
|
||||||
$('<span/>', {
|
$('<span/>', {
|
||||||
'class': 'glyphicon glyphicon-pencil'
|
'class': 'glyphicon glyphicon-pencil'
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
})
|
}),
|
||||||
]
|
$('<button/>', {
|
||||||
}),
|
'type': 'button',
|
||||||
$('<td/>', {
|
'class': 'btn btn-default btn-sm delete-break',
|
||||||
'html': [
|
'title': EALang.delete,
|
||||||
$('<button/>', {
|
'html': [
|
||||||
'type': 'button',
|
$('<span/>', {
|
||||||
'class': 'btn btn-default btn-sm delete-break',
|
'class': 'glyphicon glyphicon-trash'
|
||||||
'title': EALang.delete,
|
})
|
||||||
'html': [
|
]
|
||||||
$('<span/>', {
|
}),
|
||||||
'class': 'glyphicon glyphicon-trash'
|
$('<button/>', {
|
||||||
})
|
'type': 'button',
|
||||||
]
|
'class': 'btn btn-default btn-sm save-break hidden',
|
||||||
})
|
'title': EALang.save,
|
||||||
]
|
'html': [
|
||||||
}),
|
$('<span/>', {
|
||||||
$('<td/>', {
|
'class': 'glyphicon glyphicon-ok'
|
||||||
'html': [
|
})
|
||||||
$('<button/>', {
|
]
|
||||||
'type': 'button',
|
}),
|
||||||
'class': 'btn btn-default btn-sm save-break hidden',
|
$('<button/>', {
|
||||||
'title': EALang.save,
|
'type': 'button',
|
||||||
'html': [
|
'class': 'btn btn-default btn-sm cancel-break hidden',
|
||||||
$('<span/>', {
|
'title': EALang.cancel,
|
||||||
'class': 'glyphicon glyphicon-ok'
|
'html': [
|
||||||
})
|
$('<span/>', {
|
||||||
]
|
'class': 'glyphicon glyphicon-ban-circle'
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
}),
|
})
|
||||||
$('<td/>', {
|
]
|
||||||
'html': [
|
})
|
||||||
$('<button/>', {
|
]
|
||||||
'type': 'button',
|
})
|
||||||
'class': 'btn btn-default btn-sm cancel-break hidden',
|
.appendTo('.breaks tbody');
|
||||||
'title': EALang.cancel,
|
|
||||||
'html': [
|
|
||||||
$('<span/>', {
|
|
||||||
'class': 'glyphicon glyphicon-ban-circle'
|
|
||||||
})
|
|
||||||
]
|
|
||||||
})
|
|
||||||
]
|
|
||||||
})
|
|
||||||
]
|
|
||||||
})
|
|
||||||
.appendTo('.breaks tbody');
|
|
||||||
|
|
||||||
// Bind editable and event handlers.
|
// Bind editable and event handlers.
|
||||||
this.editableBreakDay($newBreak.find('.break-day'));
|
this.editableBreakDay($newBreak.find('.break-day'));
|
||||||
|
@ -503,9 +463,10 @@
|
||||||
* Enables the row editing for the "Breaks" table rows.
|
* Enables the row editing for the "Breaks" table rows.
|
||||||
*/
|
*/
|
||||||
$(document).on('click', '.edit-break', function () {
|
$(document).on('click', '.edit-break', function () {
|
||||||
// Reset previous editable tds
|
// Reset previous editable table cells.
|
||||||
var $previousEdt = $(this).closest('table').find('.editable').get();
|
var $previousEdits = $(this).closest('table').find('.editable');
|
||||||
$.each($previousEdt, function (index, editable) {
|
|
||||||
|
$previousEdits.each(function (index, editable) {
|
||||||
if (editable.reset) {
|
if (editable.reset) {
|
||||||
editable.reset();
|
editable.reset();
|
||||||
}
|
}
|
||||||
|
@ -525,9 +486,10 @@
|
||||||
$(this).parent().parent().find('.break-day select').focus();
|
$(this).parent().parent().find('.break-day select').focus();
|
||||||
|
|
||||||
// Show save - cancel buttons.
|
// Show save - cancel buttons.
|
||||||
$(this).closest('table').find('.edit-break, .delete-break').addClass('hidden');
|
var $tr = $(this).closest('tr');
|
||||||
$(this).parent().find('.save-break, .cancel-break').removeClass('hidden');
|
$tr.find('.edit-break, .delete-break').addClass('hidden');
|
||||||
$(this).closest('tr').find('select,input:text').addClass('form-control input-sm')
|
$tr.find('.save-break, .cancel-break').removeClass('hidden');
|
||||||
|
$tr.find('select,input:text').addClass('form-control input-sm')
|
||||||
|
|
||||||
$('.add-break').prop('disabled', true);
|
$('.add-break').prop('disabled', true);
|
||||||
});
|
});
|
||||||
|
@ -548,8 +510,8 @@
|
||||||
*
|
*
|
||||||
* @param {jQuery.Event} e
|
* @param {jQuery.Event} e
|
||||||
*/
|
*/
|
||||||
$(document).on('click', '.cancel-break', function (e) {
|
$(document).on('click', '.cancel-break', function (event) {
|
||||||
var element = e.target;
|
var element = event.target;
|
||||||
var $modifiedRow = $(element).closest('tr');
|
var $modifiedRow = $(element).closest('tr');
|
||||||
this.enableCancel = true;
|
this.enableCancel = true;
|
||||||
$modifiedRow.find('.cancel-editable').trigger('click');
|
$modifiedRow.find('.cancel-editable').trigger('click');
|
||||||
|
@ -567,12 +529,12 @@
|
||||||
*
|
*
|
||||||
* @param {jQuery.Event} e
|
* @param {jQuery.Event} e
|
||||||
*/
|
*/
|
||||||
$(document).on('click', '.save-break', function (e) {
|
$(document).on('click', '.save-break', function (event) {
|
||||||
// Break's start time must always be prior to break's end.
|
// Break's start time must always be prior to break's end.
|
||||||
var element = e.target,
|
var element = event.target;
|
||||||
$modifiedRow = $(element).closest('tr'),
|
var $modifiedRow = $(element).closest('tr');
|
||||||
start = Date.parse($modifiedRow.find('.break-start input').val()),
|
var start = Date.parse($modifiedRow.find('.break-start input').val());
|
||||||
end = Date.parse($modifiedRow.find('.break-end input').val());
|
var end = Date.parse($modifiedRow.find('.break-end input').val());
|
||||||
|
|
||||||
if (start > end) {
|
if (start > end) {
|
||||||
$modifiedRow.find('.break-end input').val(start.addHours(1).toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm'));
|
$modifiedRow.find('.break-end input').val(start.addHours(1).toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm'));
|
||||||
|
@ -589,7 +551,6 @@
|
||||||
// Refresh working plan to have the new break sorted in the break list.
|
// Refresh working plan to have the new break sorted in the break list.
|
||||||
var workingPlan = this.get();
|
var workingPlan = this.get();
|
||||||
this.setup(workingPlan);
|
this.setup(workingPlan);
|
||||||
|
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -601,8 +562,6 @@
|
||||||
$('.add-extra-periods').click(function () {
|
$('.add-extra-periods').click(function () {
|
||||||
var today = GeneralFunctions.formatDate(new Date(), GlobalVariables.dateFormat, false);
|
var today = GeneralFunctions.formatDate(new Date(), GlobalVariables.dateFormat, false);
|
||||||
|
|
||||||
var timeFormat = GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm';
|
|
||||||
|
|
||||||
var $newExtraPeriod = $('<tr/>', {
|
var $newExtraPeriod = $('<tr/>', {
|
||||||
'html': [
|
'html': [
|
||||||
$('<td/>', {
|
$('<td/>', {
|
||||||
|
@ -628,11 +587,7 @@
|
||||||
'class': 'glyphicon glyphicon-pencil'
|
'class': 'glyphicon glyphicon-pencil'
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
})
|
}),
|
||||||
]
|
|
||||||
}),
|
|
||||||
$('<td/>', {
|
|
||||||
'html': [
|
|
||||||
$('<button/>', {
|
$('<button/>', {
|
||||||
'type': 'button',
|
'type': 'button',
|
||||||
'class': 'btn btn-default btn-sm delete-extra',
|
'class': 'btn btn-default btn-sm delete-extra',
|
||||||
|
@ -642,11 +597,7 @@
|
||||||
'class': 'glyphicon glyphicon-trash'
|
'class': 'glyphicon glyphicon-trash'
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
})
|
}),
|
||||||
]
|
|
||||||
}),
|
|
||||||
$('<td/>', {
|
|
||||||
'html': [
|
|
||||||
$('<button/>', {
|
$('<button/>', {
|
||||||
'type': 'button',
|
'type': 'button',
|
||||||
'class': 'btn btn-default btn-sm save-extra hidden',
|
'class': 'btn btn-default btn-sm save-extra hidden',
|
||||||
|
@ -656,11 +607,7 @@
|
||||||
'class': 'glyphicon glyphicon-ok'
|
'class': 'glyphicon glyphicon-ok'
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
})
|
}),
|
||||||
]
|
|
||||||
}),
|
|
||||||
$('<td/>', {
|
|
||||||
'html': [
|
|
||||||
$('<button/>', {
|
$('<button/>', {
|
||||||
'type': 'button',
|
'type': 'button',
|
||||||
'class': 'btn btn-default btn-sm cancel-extra hidden',
|
'class': 'btn btn-default btn-sm cancel-extra hidden',
|
||||||
|
@ -672,7 +619,7 @@
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
})
|
}),
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
.appendTo('.extra-periods tbody');
|
.appendTo('.extra-periods tbody');
|
||||||
|
@ -690,9 +637,10 @@
|
||||||
* Enables the row editing for the "Extra Period" table rows.
|
* Enables the row editing for the "Extra Period" table rows.
|
||||||
*/
|
*/
|
||||||
$(document).on('click', '.edit-extra', function () {
|
$(document).on('click', '.edit-extra', function () {
|
||||||
// Reset previous editable tds
|
// Reset previous editable table cells.
|
||||||
var $previousEdt = $(this).closest('table').find('.editable').get();
|
var $previousEdits = $(this).closest('table').find('.editable');
|
||||||
$.each($previousEdt, function (index, editable) {
|
|
||||||
|
$previousEdits.each(function (index, editable) {
|
||||||
if (editable.reset) {
|
if (editable.reset) {
|
||||||
editable.reset();
|
editable.reset();
|
||||||
}
|
}
|
||||||
|
@ -750,9 +698,10 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
// Show save - cancel buttons.
|
// Show save - cancel buttons.
|
||||||
$(this).closest('table').find('.edit-extra, .delete-extra').addClass('hidden');
|
var $tr = $(this).closest('tr');
|
||||||
$(this).parent().find('.save-extra, .cancel-extra').removeClass('hidden');
|
$tr.find('.edit-extra, .delete-extra').addClass('hidden');
|
||||||
$(this).closest('tr').find('select,input:text').addClass('form-control input-sm')
|
$tr.find('.save-extra, .cancel-extra').removeClass('hidden');
|
||||||
|
$tr.find('select,input:text').addClass('form-control input-sm')
|
||||||
|
|
||||||
$('.add-extra-periods').prop('disabled', true);
|
$('.add-extra-periods').prop('disabled', true);
|
||||||
});
|
});
|
||||||
|
@ -773,8 +722,8 @@
|
||||||
*
|
*
|
||||||
* @param {jQuery.Event} e
|
* @param {jQuery.Event} e
|
||||||
*/
|
*/
|
||||||
$(document).on('click', '.cancel-extra', function (e) {
|
$(document).on('click', '.cancel-extra', function (event) {
|
||||||
var element = e.target;
|
var element = event.target;
|
||||||
var $modifiedRow = $(element).closest('tr');
|
var $modifiedRow = $(element).closest('tr');
|
||||||
this.enableCancel = true;
|
this.enableCancel = true;
|
||||||
$modifiedRow.find('.cancel-editable').trigger('click');
|
$modifiedRow.find('.cancel-editable').trigger('click');
|
||||||
|
@ -792,12 +741,12 @@
|
||||||
*
|
*
|
||||||
* @param {jQuery.Event} e
|
* @param {jQuery.Event} e
|
||||||
*/
|
*/
|
||||||
$(document).on('click', '.save-extra', function (e) {
|
$(document).on('click', '.save-extra', function (event) {
|
||||||
// Break's start time must always be prior to break's end.
|
// Break's start time must always be prior to break's end.
|
||||||
var element = e.target,
|
var element = event.target;
|
||||||
$modifiedRow = $(element).closest('tr'),
|
var $modifiedRow = $(element).closest('tr');
|
||||||
start = Date.parse($modifiedRow.find('.extra-start input').val()),
|
var start = Date.parse($modifiedRow.find('.extra-start input').val());
|
||||||
end = Date.parse($modifiedRow.find('.extra-end input').val());
|
var end = Date.parse($modifiedRow.find('.extra-end input').val());
|
||||||
|
|
||||||
if (start > end) {
|
if (start > end) {
|
||||||
$modifiedRow.find('.extra-end input').val(start.addHours(1).toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm').toUpperCase());
|
$modifiedRow.find('.extra-end input').val(start.addHours(1).toString(GlobalVariables.timeFormat === 'regular' ? 'h:mm tt' : 'HH:mm').toUpperCase());
|
||||||
|
|
Loading…
Reference in a new issue