Refactored js code.
This commit is contained in:
parent
ad4e23302e
commit
279b931d80
15 changed files with 311 additions and 309 deletions
|
@ -23,8 +23,8 @@ window.BackendCalendar = window.BackendCalendar || {};
|
|||
'use strict';
|
||||
|
||||
// Constants
|
||||
var FILTER_TYPE_PROVIDER = 'provider',
|
||||
FILTER_TYPE_SERVICE = 'service';
|
||||
var FILTER_TYPE_PROVIDER = 'provider';
|
||||
var FILTER_TYPE_SERVICE = 'service';
|
||||
|
||||
// Variables
|
||||
var lastFocusedEventData; // Contains event data for later use.
|
||||
|
@ -241,11 +241,11 @@ window.BackendCalendar = window.BackendCalendar || {};
|
|||
$('#delete-reason').css('width', '100%');
|
||||
} else {
|
||||
// Do not display confirmation promt.
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_unavailable',
|
||||
postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
unavailable_id : lastFocusedEventData.data.id
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_unavailable';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
unavailable_id : lastFocusedEventData.data.id
|
||||
};
|
||||
|
||||
$.post(postUrl, postData, function(response) {
|
||||
$('#message_box').dialog('close');
|
||||
|
@ -296,8 +296,8 @@ window.BackendCalendar = window.BackendCalendar || {};
|
|||
// an insert operation.
|
||||
|
||||
var startDatetime = $dialog.find('#start-datetime')
|
||||
.datepicker('getDate').toString('yyyy-MM-dd HH:mm:ss'),
|
||||
endDatetime = $dialog.find('#end-datetime')
|
||||
.datepicker('getDate').toString('yyyy-MM-dd HH:mm:ss');
|
||||
var endDatetime = $dialog.find('#end-datetime')
|
||||
.datepicker('getDate').toString('yyyy-MM-dd HH:mm:ss');
|
||||
|
||||
var appointment = {
|
||||
|
@ -369,9 +369,9 @@ window.BackendCalendar = window.BackendCalendar || {};
|
|||
* Stores the unavailable period changes or inserts a new record.
|
||||
*/
|
||||
$('#manage-unavailable #save-unavailable').click(function() {
|
||||
var $dialog = $('#manage-unavailable'),
|
||||
start = $dialog.find('#unavailable-start').datetimepicker('getDate'),
|
||||
end = $dialog.find('#unavailable-end').datetimepicker('getDate');
|
||||
var $dialog = $('#manage-unavailable');
|
||||
var start = $dialog.find('#unavailable-start').datetimepicker('getDate');
|
||||
var end = $dialog.find('#unavailable-end').datetimepicker('getDate');
|
||||
|
||||
if (start > end) {
|
||||
// Start time is after end time - display message to user.
|
||||
|
@ -485,11 +485,11 @@ window.BackendCalendar = window.BackendCalendar || {};
|
|||
// Display the calendar selection dialog. First we will get a list of the available
|
||||
// user's calendars and then we will display a selection modal so the user can select
|
||||
// the sync calendar.
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_get_google_calendars',
|
||||
postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
provider_id: $('#select-filter-item').val()
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_get_google_calendars';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
provider_id: $('#select-filter-item').val()
|
||||
};
|
||||
|
||||
$.post(postUrl, postData, function(response) {
|
||||
if (!GeneralFunctions.handleAjaxExceptions(response)) {
|
||||
|
@ -565,8 +565,8 @@ window.BackendCalendar = window.BackendCalendar || {};
|
|||
}
|
||||
});
|
||||
|
||||
var start = new Date(),
|
||||
currentMin = parseInt(start.toString('mm'));
|
||||
var start = new Date();
|
||||
var currentMin = parseInt(start.toString('mm'));
|
||||
|
||||
if (currentMin > 0 && currentMin < 15) {
|
||||
start.set({ 'minute': 15 });
|
||||
|
@ -598,8 +598,8 @@ window.BackendCalendar = window.BackendCalendar || {};
|
|||
var $dialog = $('#manage-unavailable');
|
||||
|
||||
// Set the default datetime values.
|
||||
var start = new Date(),
|
||||
currentMin = parseInt(start.toString('mm'));
|
||||
var start = new Date();
|
||||
var currentMin = parseInt(start.toString('mm'));
|
||||
|
||||
if (currentMin > 0 && currentMin < 15) {
|
||||
start.set({ 'minute': 15 });
|
||||
|
@ -668,13 +668,13 @@ window.BackendCalendar = window.BackendCalendar || {};
|
|||
* Event: Filter Existing Customers "Change"
|
||||
*/
|
||||
$('#filter-existing-customers').keyup(function() {
|
||||
var key = $(this).val().toLowerCase(),
|
||||
$list = $('#existing-customers-list'),
|
||||
postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_customers',
|
||||
postData = {
|
||||
'csrfToken': GlobalVariables.csrfToken,
|
||||
'key': key
|
||||
};
|
||||
var key = $(this).val().toLowerCase();
|
||||
var $list = $('#existing-customers-list');
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_customers';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
key: key
|
||||
};
|
||||
|
||||
// Try to get the updated customer list.
|
||||
$.ajax({
|
||||
|
@ -765,12 +765,12 @@ window.BackendCalendar = window.BackendCalendar || {};
|
|||
* Event: Select Google Calendar "Click"
|
||||
*/
|
||||
$('#select-calendar').click(function() {
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_select_google_calendar',
|
||||
postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
provider_id: $('#select-filter-item').val(),
|
||||
calendar_id: $('#google-calendar').val()
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_select_google_calendar';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
provider_id: $('#select-filter-item').val(),
|
||||
calendar_id: $('#google-calendar').val()
|
||||
};
|
||||
$.post(postUrl, postData, function(response) {
|
||||
if (!GeneralFunctions.handleAjaxExceptions(response)) {
|
||||
return;
|
||||
|
@ -814,14 +814,14 @@ window.BackendCalendar = window.BackendCalendar || {};
|
|||
* @param {Date} endDate Visible end date of the calendar.
|
||||
*/
|
||||
function _refreshCalendarAppointments($calendar, recordId, filterType, startDate, endDate) {
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_get_calendar_appointments',
|
||||
postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
record_id: recordId,
|
||||
start_date: startDate.toString('yyyy-MM-dd'),
|
||||
end_date: endDate.toString('yyyy-MM-dd'),
|
||||
filter_type: filterType
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_get_calendar_appointments';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
record_id: recordId,
|
||||
start_date: startDate.toString('yyyy-MM-dd'),
|
||||
end_date: endDate.toString('yyyy-MM-dd'),
|
||||
filter_type: filterType
|
||||
};
|
||||
|
||||
$.post(postUrl, postData, function(response) {
|
||||
if (!GeneralFunctions.handleAjaxExceptions(response)) {
|
||||
|
@ -829,8 +829,8 @@ window.BackendCalendar = window.BackendCalendar || {};
|
|||
}
|
||||
|
||||
// Add appointments to calendar.
|
||||
var calendarEvents = [],
|
||||
$calendar = $('#calendar');
|
||||
var calendarEvents = [];
|
||||
var $calendar = $('#calendar');
|
||||
|
||||
$.each(response.appointments, function(index, appointment) {
|
||||
var event = {
|
||||
|
@ -917,8 +917,8 @@ window.BackendCalendar = window.BackendCalendar || {};
|
|||
}
|
||||
|
||||
// Add unavailable period after work ends.
|
||||
var calendarDateEnd = $calendar.fullCalendar('getView').end,
|
||||
workDateEnd = Date.parseExact(
|
||||
var calendarDateEnd = $calendar.fullCalendar('getView').end;
|
||||
var workDateEnd = Date.parseExact(
|
||||
calendarDateStart.toString('dd/MM/yyyy') + ' '
|
||||
+ workingPlan[selDayName].end,
|
||||
'dd/MM/yyyy HH:mm'); // Use calendarDateStart ***
|
||||
|
@ -936,7 +936,8 @@ window.BackendCalendar = window.BackendCalendar || {};
|
|||
}
|
||||
|
||||
// Add unavailable periods for breaks.
|
||||
var breakStart, breakEnd;
|
||||
var breakStart;
|
||||
var breakEnd;
|
||||
$.each(workingPlan[selDayName].breaks, function(index, currBreak) {
|
||||
breakStart = Date.parseExact(calendarDateStart.toString('dd/MM/yyyy')
|
||||
+ ' ' + currBreak.start, 'dd/MM/yyyy HH:mm');
|
||||
|
@ -957,8 +958,8 @@ window.BackendCalendar = window.BackendCalendar || {};
|
|||
break;
|
||||
|
||||
case 'agendaWeek':
|
||||
var currDateStart = GeneralFunctions.clone($calendar.fullCalendar('getView').start),
|
||||
currDateEnd = GeneralFunctions.clone(currDateStart).addDays(1);
|
||||
var currDateStart = GeneralFunctions.clone($calendar.fullCalendar('getView').start);
|
||||
var currDateEnd = GeneralFunctions.clone(currDateStart).addDays(1);
|
||||
|
||||
// Add custom unavailable periods (they are always displayed on the calendar, even if
|
||||
// the provider won't work on that day).
|
||||
|
@ -997,8 +998,8 @@ window.BackendCalendar = window.BackendCalendar || {};
|
|||
return; // Go to the next loop.
|
||||
}
|
||||
|
||||
var start,
|
||||
end;
|
||||
var start;
|
||||
var end;
|
||||
|
||||
// Add unavailable period before work starts.
|
||||
start = Date.parseExact(currDateStart.toString('dd/MM/yyyy')
|
||||
|
@ -1033,7 +1034,8 @@ window.BackendCalendar = window.BackendCalendar || {};
|
|||
}
|
||||
|
||||
// Add unavailable periods during day breaks.
|
||||
var breakStart, breakEnd;
|
||||
var breakStart;
|
||||
var breakEnd;
|
||||
$.each(workingDay.breaks, function(index, currBreak) {
|
||||
breakStart = Date.parseExact(currDateStart.toString('dd/MM/yyyy')
|
||||
+ ' ' + currBreak.start, 'dd/MM/yyyy HH:mm');
|
||||
|
@ -1074,11 +1076,11 @@ window.BackendCalendar = window.BackendCalendar || {};
|
|||
* @param {Function} errorCallback Optional, if defined, this function is going to be executed on post failure.
|
||||
*/
|
||||
function _saveAppointment(appointment, customer, successCallback, errorCallback) {
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_appointment',
|
||||
postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
appointment_data: JSON.stringify(appointment)
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_appointment';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
appointment_data: JSON.stringify(appointment)
|
||||
};
|
||||
|
||||
if (customer !== undefined) {
|
||||
postData['customer_data'] = JSON.stringify(customer);
|
||||
|
@ -1110,11 +1112,11 @@ window.BackendCalendar = window.BackendCalendar || {};
|
|||
* @param {Function} errorCallback The ajax failure callback function.
|
||||
*/
|
||||
function _saveUnavailable(unavailable, successCallback, errorCallback) {
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_unavailable',
|
||||
postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
unavailable: JSON.stringify(unavailable)
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_unavailable';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
unavailable: JSON.stringify(unavailable)
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
|
@ -1183,8 +1185,8 @@ window.BackendCalendar = window.BackendCalendar || {};
|
|||
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_appointment';
|
||||
var postData = {
|
||||
'csrfToken': GlobalVariables.csrfToken,
|
||||
'appointment_data': JSON.stringify(appointment)
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
appointment_data: JSON.stringify(appointment)
|
||||
};
|
||||
|
||||
$.post(postUrl, postData, function(response) {
|
||||
|
@ -1238,8 +1240,8 @@ window.BackendCalendar = window.BackendCalendar || {};
|
|||
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_unavailable';
|
||||
var postData = {
|
||||
'csrfToken': GlobalVariables.csrfToken,
|
||||
'unavailable': JSON.stringify(unavailable)
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
unavailable: JSON.stringify(unavailable)
|
||||
};
|
||||
|
||||
$.post(postUrl, postData, function(response) {
|
||||
|
@ -1295,9 +1297,9 @@ window.BackendCalendar = window.BackendCalendar || {};
|
|||
function _calendarEventClick(event, jsEvent, view) {
|
||||
$('.popover').remove(); // Close all open popovers.
|
||||
|
||||
var html,
|
||||
displayEdit,
|
||||
displayDelete;
|
||||
var html;
|
||||
var displayEdit;
|
||||
var displayDelete;
|
||||
|
||||
// Depending where the user clicked the event (title or empty space) we
|
||||
// need to use different selectors to reach the parent element.
|
||||
|
@ -1458,11 +1460,11 @@ window.BackendCalendar = window.BackendCalendar || {};
|
|||
event.data['start_datetime'] = appointment['start_datetime'];
|
||||
event.data['end_datetime'] = appointment['end_datetime'];
|
||||
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_appointment',
|
||||
postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
appointment_data: JSON.stringify(appointment)
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_appointment';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
appointment_data: JSON.stringify(appointment)
|
||||
};
|
||||
|
||||
$.post(postUrl, postData, function(response) {
|
||||
$('#notification').hide('blind');
|
||||
|
@ -1489,7 +1491,7 @@ window.BackendCalendar = window.BackendCalendar || {};
|
|||
start_datetime: event.start.toString('yyyy-MM-dd HH:mm:ss'),
|
||||
end_datetime: event.end.toString('yyyy-MM-dd HH:mm:ss'),
|
||||
id_users_provider: event.data.id_users_provider
|
||||
}
|
||||
};
|
||||
|
||||
var successCallback = function(response) {
|
||||
if (response.exceptions) {
|
||||
|
@ -1519,11 +1521,11 @@ window.BackendCalendar = window.BackendCalendar || {};
|
|||
event.data['start_datetime'] = unavailable['start_datetime'];
|
||||
event.data['end_datetime'] = unavailable['end_datetime'];
|
||||
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_unavailable',
|
||||
postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
unavailable: JSON.stringify(unavailable)
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_unavailable';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
unavailable: JSON.stringify(unavailable)
|
||||
};
|
||||
|
||||
$.post(postUrl, postData, function(response) {
|
||||
$('#notification').hide('blind');
|
||||
|
@ -1586,11 +1588,11 @@ window.BackendCalendar = window.BackendCalendar || {};
|
|||
function _disableProviderSync(providerId) {
|
||||
// Make an ajax call to the server in order to disable the setting
|
||||
// from the database.
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_disable_provider_sync',
|
||||
postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
provider_id: providerId
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_disable_provider_sync';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
provider_id: providerId
|
||||
};
|
||||
|
||||
$.post(postUrl, postData, function(response) {
|
||||
if (response.exceptions) {
|
||||
|
@ -1654,9 +1656,9 @@ window.BackendCalendar = window.BackendCalendar || {};
|
|||
}
|
||||
});
|
||||
|
||||
var startDatetime = new Date().addMinutes(GlobalVariables.bookAdvanceTimeout),
|
||||
endDatetime = new Date().addMinutes(GlobalVariables.bookAdvanceTimeout).addMinutes(serviceDuration),
|
||||
dateFormat;
|
||||
var startDatetime = new Date().addMinutes(GlobalVariables.bookAdvanceTimeout);
|
||||
var endDatetime = new Date().addMinutes(GlobalVariables.bookAdvanceTimeout).addMinutes(serviceDuration);
|
||||
var dateFormat;
|
||||
|
||||
switch(GlobalVariables.dateFormat) {
|
||||
case 'DMY':
|
||||
|
@ -1766,8 +1768,8 @@ window.BackendCalendar = window.BackendCalendar || {};
|
|||
}
|
||||
|
||||
// Check appointment start and end time.
|
||||
var start = $('#start-datetime').datepicker('getDate'),
|
||||
end = $('#end-datetime').datepicker('getDate');
|
||||
var start = $('#start-datetime').datepicker('getDate');
|
||||
var end = $('#end-datetime').datepicker('getDate');
|
||||
if (start > end) {
|
||||
$dialog.find('#start-datetime').parents('.form-group').addClass('has-error');
|
||||
$dialog.find('#end-datetime').parents('.form-group').addClass('has-error');
|
||||
|
@ -1793,9 +1795,9 @@ window.BackendCalendar = window.BackendCalendar || {};
|
|||
$dialog.find('#unavailable-id').val('');
|
||||
|
||||
// Set default time values
|
||||
var start = GeneralFunctions.formatDate(new Date(), GlobalVariables.dateFormat, true),
|
||||
end = GeneralFunctions.formatDate(new Date().addHours(1), GlobalVariables.dateFormat, true),
|
||||
dateFormat;
|
||||
var start = GeneralFunctions.formatDate(new Date(), GlobalVariables.dateFormat, true);
|
||||
var end = GeneralFunctions.formatDate(new Date().addHours(1), GlobalVariables.dateFormat, true);
|
||||
var dateFormat;
|
||||
|
||||
switch(GlobalVariables.dateFormat) {
|
||||
case 'DMY':
|
||||
|
@ -1908,18 +1910,18 @@ window.BackendCalendar = window.BackendCalendar || {};
|
|||
switch(GlobalVariables.dateFormat) {
|
||||
case 'DMY':
|
||||
columnFormat = {
|
||||
'month': 'ddd',
|
||||
'week': 'ddd dd/MM',
|
||||
'day': 'dddd dd/MM'
|
||||
month: 'ddd',
|
||||
week: 'ddd dd/MM',
|
||||
day: 'dddd dd/MM'
|
||||
};
|
||||
|
||||
break;
|
||||
case 'MDY':
|
||||
case 'YMD':
|
||||
columnFormat = {
|
||||
'month': 'ddd',
|
||||
'week': 'ddd MM/dd',
|
||||
'day': 'dddd MM/dd'
|
||||
month: 'ddd',
|
||||
week: 'ddd MM/dd',
|
||||
day: 'dddd MM/dd'
|
||||
};
|
||||
break;
|
||||
default:
|
||||
|
@ -2064,8 +2066,8 @@ window.BackendCalendar = window.BackendCalendar || {};
|
|||
|
||||
// Display the edit dialog if an appointment hash is provided.
|
||||
if (GlobalVariables.editAppointment != null) {
|
||||
var $dialog = $('#manage-appointment'),
|
||||
appointment = GlobalVariables.editAppointment;
|
||||
var $dialog = $('#manage-appointment');
|
||||
var appointment = GlobalVariables.editAppointment;
|
||||
_resetAppointmentDialog();
|
||||
|
||||
$dialog.find('.modal-header h3').text(EALang['edit_appointment_title']);
|
||||
|
|
|
@ -161,11 +161,11 @@
|
|||
* @param {Boolean} display Optional (false), if true then the selected record will be displayed on the form.
|
||||
*/
|
||||
CategoriesHelper.prototype.filter = function(key, selectId, display) {
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_service_categories',
|
||||
postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
key: key
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_service_categories';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
key: key
|
||||
};
|
||||
|
||||
$.post(postUrl, postData, function(response) {
|
||||
if (!GeneralFunctions.handleAjaxExceptions(response)) {
|
||||
|
@ -198,11 +198,11 @@
|
|||
* @param {Object} category Contains the category data.
|
||||
*/
|
||||
CategoriesHelper.prototype.save = function(category) {
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_service_category',
|
||||
postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
category: JSON.stringify(category)
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_service_category';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
category: JSON.stringify(category)
|
||||
};
|
||||
|
||||
$.post(postUrl, postData, function(response) {
|
||||
if (!GeneralFunctions.handleAjaxExceptions(response)) {
|
||||
|
@ -223,11 +223,11 @@
|
|||
* @param Number} id Record ID to be deleted.
|
||||
*/
|
||||
CategoriesHelper.prototype.delete = function(id) {
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_service_category',
|
||||
postData = {
|
||||
'csrfToken': GlobalVariables.csrfToken,
|
||||
'category_id': id
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_service_category';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
category_id: id
|
||||
};
|
||||
|
||||
$.post(postUrl, postData, function(response) {
|
||||
if (!GeneralFunctions.handleAjaxExceptions(response)) {
|
||||
|
|
|
@ -60,8 +60,8 @@
|
|||
return; // Do nothing when user edits a customer record.
|
||||
}
|
||||
|
||||
var customerId = $(this).attr('data-id'),
|
||||
customer = {};
|
||||
var customerId = $(this).attr('data-id');
|
||||
var customer = {};
|
||||
$.each(instance.filterResults, function(index, item) {
|
||||
if (item.id == customerId) {
|
||||
customer = item;
|
||||
|
@ -84,9 +84,9 @@
|
|||
$('#customer-appointments .selected').removeClass('selected');
|
||||
$(this).addClass('selected');
|
||||
|
||||
var customerId = $('#filter-customers .selected').attr('data-id'),
|
||||
appointmentId = $(this).attr('data-id'),
|
||||
appointment = {};
|
||||
var customerId = $('#filter-customers .selected').attr('data-id');
|
||||
var appointmentId = $(this).attr('data-id');
|
||||
var appointment = {};
|
||||
|
||||
$.each(instance.filterResults, function(index, c) {
|
||||
if (c.id === customerId) {
|
||||
|
@ -144,14 +144,14 @@
|
|||
*/
|
||||
$('#save-customer').click(function() {
|
||||
var customer = {
|
||||
'first_name': $('#first-name').val(),
|
||||
'last_name': $('#last-name').val(),
|
||||
'email': $('#email').val(),
|
||||
'phone_number': $('#phone-number').val(),
|
||||
'address': $('#address').val(),
|
||||
'city': $('#city').val(),
|
||||
'zip_code': $('#zip-code').val(),
|
||||
'notes': $('#notes').val()
|
||||
first_name: $('#first-name').val(),
|
||||
last_name: $('#last-name').val(),
|
||||
email: $('#email').val(),
|
||||
phone_number: $('#phone-number').val(),
|
||||
address: $('#address').val(),
|
||||
city: $('#city').val(),
|
||||
zip_code: $('#zip-code').val(),
|
||||
notes: $('#notes').val()
|
||||
};
|
||||
|
||||
if ($('#customer-id').val() != '') {
|
||||
|
@ -167,8 +167,8 @@
|
|||
* Event: Delete Customer Button "Click"
|
||||
*/
|
||||
$('#delete-customer').click(function() {
|
||||
var customerId = $('#customer-id').val(),
|
||||
messageBtns = {};
|
||||
var customerId = $('#customer-id').val();
|
||||
var messageBtns = {};
|
||||
|
||||
messageBtns[EALang['delete']] = function() {
|
||||
instance.delete(customerId);
|
||||
|
@ -190,11 +190,11 @@
|
|||
* @param {Object} customer Contains the customer data.
|
||||
*/
|
||||
CustomersHelper.prototype.save = function(customer) {
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_customer',
|
||||
postData = {
|
||||
'csrfToken': GlobalVariables.csrfToken,
|
||||
'customer': JSON.stringify(customer)
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_customer';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
customer: JSON.stringify(customer)
|
||||
};
|
||||
|
||||
$.post(postUrl, postData, function(response) {
|
||||
if (!GeneralFunctions.handleAjaxExceptions(response)) {
|
||||
|
@ -214,11 +214,11 @@
|
|||
* @param {Number} id Record id to be deleted.
|
||||
*/
|
||||
CustomersHelper.prototype.delete = function(id) {
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_customer',
|
||||
postData = {
|
||||
'csrfToken': GlobalVariables.csrfToken,
|
||||
'customer_id': id
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_customer';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
customer_id: id
|
||||
};
|
||||
|
||||
$.post(postUrl, postData, function(response) {
|
||||
if (!GeneralFunctions.handleAjaxExceptions(response)) {
|
||||
|
@ -309,9 +309,9 @@
|
|||
$('#customer-appointments').data('jsp').destroy();
|
||||
$('#customer-appointments').empty();
|
||||
$.each(customer.appointments, function(index, appointment) {
|
||||
var start = GeneralFunctions.formatDate(Date.parse(appointment.start_datetime), GlobalVariables.dateFormat, true),
|
||||
end = GeneralFunctions.formatDate(Date.parse(appointment.end_datetime), GlobalVariables.dateFormat, true),
|
||||
html =
|
||||
var start = GeneralFunctions.formatDate(Date.parse(appointment.start_datetime), GlobalVariables.dateFormat, true);
|
||||
var end = GeneralFunctions.formatDate(Date.parse(appointment.end_datetime), GlobalVariables.dateFormat, true);
|
||||
var html =
|
||||
'<div class="appointment-row" data-id="' + appointment.id + '">' +
|
||||
start + ' - ' + end + '<br>' +
|
||||
appointment.service.name + ', ' +
|
||||
|
@ -335,11 +335,11 @@
|
|||
CustomersHelper.prototype.filter = function(key, selectId, display) {
|
||||
display = display || false;
|
||||
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_customers',
|
||||
postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
key: key
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_customers';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
key: key
|
||||
};
|
||||
|
||||
$.post(postUrl, postData, function(response) {
|
||||
if (!GeneralFunctions.handleAjaxExceptions(response)) {
|
||||
|
@ -429,8 +429,8 @@
|
|||
* @param {Object} appointment Appointment data
|
||||
*/
|
||||
CustomersHelper.prototype.displayAppointment = function(appointment) {
|
||||
var start = GeneralFunctions.formatDate(Date.parse(appointment.start_datetime), GlobalVariables.dateFormat, true),
|
||||
end = GeneralFunctions.formatDate(Date.parse(appointment.end_datetime), GlobalVariables.dateFormat, true);
|
||||
var start = GeneralFunctions.formatDate(Date.parse(appointment.start_datetime), GlobalVariables.dateFormat, true);
|
||||
var end = GeneralFunctions.formatDate(Date.parse(appointment.end_datetime), GlobalVariables.dateFormat, true);
|
||||
|
||||
var html =
|
||||
'<div>' +
|
||||
|
|
|
@ -105,11 +105,11 @@ window.BackendServices = window.BackendServices || {};
|
|||
* Use this method every time a change is made to the service categories db table.
|
||||
*/
|
||||
exports.updateAvailableCategories = function() {
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_service_categories',
|
||||
postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
key: ''
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_service_categories';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
key: ''
|
||||
};
|
||||
|
||||
$.post(postUrl, postData, function(response) {
|
||||
if (!GeneralFunctions.handleAjaxExceptions(response)) {
|
||||
|
|
|
@ -60,8 +60,8 @@
|
|||
return; // exit because we are on edit mode
|
||||
}
|
||||
|
||||
var serviceId = $(this).attr('data-id'),
|
||||
service = {};
|
||||
var serviceId = $(this).attr('data-id');
|
||||
var service = {};
|
||||
$.each(instance.filterResults, function(index, item) {
|
||||
if (item.id === serviceId) {
|
||||
service = item;
|
||||
|
@ -150,8 +150,8 @@
|
|||
* Event: Delete Service Button "Click"
|
||||
*/
|
||||
$('#delete-service').click(function() {
|
||||
var serviceId = $('#service-id').val(),
|
||||
messageBtns = {};
|
||||
var serviceId = $('#service-id').val();
|
||||
var messageBtns = {};
|
||||
|
||||
messageBtns[EALang['delete']] = function() {
|
||||
instance.delete(serviceId);
|
||||
|
@ -174,11 +174,11 @@
|
|||
* then the update operation is going to be executed.
|
||||
*/
|
||||
ServicesHelper.prototype.save = function(service) {
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_service',
|
||||
postData = {
|
||||
'csrfToken': GlobalVariables.csrfToken,
|
||||
'service': JSON.stringify(service)
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_service';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
service: JSON.stringify(service)
|
||||
};
|
||||
|
||||
$.post(postUrl, postData, function(response) {
|
||||
if (!GeneralFunctions.handleAjaxExceptions(response)) {
|
||||
|
@ -198,11 +198,11 @@
|
|||
* @param {Number} id Record ID to be deleted.
|
||||
*/
|
||||
ServicesHelper.prototype.delete = function(id) {
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_service',
|
||||
postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
service_id: id
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_service';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
service_id: id
|
||||
};
|
||||
|
||||
$.post(postUrl, postData, function(response) {
|
||||
if (!GeneralFunctions.handleAjaxExceptions(response)) {
|
||||
|
@ -293,11 +293,11 @@
|
|||
ServicesHelper.prototype.filter = function(key, selectId, display) {
|
||||
display = display || false;
|
||||
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_services',
|
||||
postData = {
|
||||
'csrfToken': GlobalVariables.csrfToken,
|
||||
'key': key
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_services';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
key: key
|
||||
};
|
||||
|
||||
$.post(postUrl, postData, function(response) {
|
||||
if (!GeneralFunctions.handleAjaxExceptions(response)) {
|
||||
|
|
|
@ -194,12 +194,12 @@ window.BackendSettings = window.BackendSettings || {};
|
|||
return;
|
||||
}
|
||||
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_validate_username',
|
||||
postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
username: $input.val(),
|
||||
user_id: $input.parents().eq(2).find('#user-id').val()
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_validate_username';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
username: $input.val(),
|
||||
user_id: $input.parents().eq(2).find('#user-id').val()
|
||||
};
|
||||
|
||||
$.post(postUrl, postData, function(response) {
|
||||
if (!GeneralFunctions.handleAjaxExceptions(response)) {
|
||||
|
|
|
@ -28,12 +28,12 @@
|
|||
* @param {Array} settings Contains the system settings data.
|
||||
*/
|
||||
SystemSettings.prototype.save = function(settings) {
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_settings',
|
||||
postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
settings: JSON.stringify(settings),
|
||||
type: BackendSettings.SETTINGS_SYSTEM
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_settings';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
settings: JSON.stringify(settings),
|
||||
type: BackendSettings.SETTINGS_SYSTEM
|
||||
};
|
||||
|
||||
$.post(postUrl, postData, function(response) {
|
||||
if (!GeneralFunctions.handleAjaxExceptions(response)) {
|
||||
|
|
|
@ -62,12 +62,12 @@
|
|||
return; // Validation failed, do not procceed.
|
||||
}
|
||||
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_settings',
|
||||
postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
type: BackendSettings.SETTINGS_USER,
|
||||
settings: JSON.stringify(settings)
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_settings';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
type: BackendSettings.SETTINGS_USER,
|
||||
settings: JSON.stringify(settings)
|
||||
};
|
||||
|
||||
$.post(postUrl, postData, function(response) {
|
||||
if (!GeneralFunctions.handleAjaxExceptions(response)) {
|
||||
|
|
|
@ -142,11 +142,11 @@ window.BackendUsers = window.BackendUsers || {};
|
|||
helper = new SecretariesHelper();
|
||||
|
||||
// Update the list with the all the available providers.
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_providers',
|
||||
postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
key: ''
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_providers';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
key: ''
|
||||
};
|
||||
$.post(postUrl, postData, function(response) {
|
||||
if (!GeneralFunctions.handleAjaxExceptions(response)) {
|
||||
return;
|
||||
|
@ -200,12 +200,12 @@ window.BackendUsers = window.BackendUsers || {};
|
|||
return;
|
||||
}
|
||||
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_validate_username',
|
||||
postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
username: $input.val(),
|
||||
user_id: userId
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_validate_username';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
username: $input.val(),
|
||||
user_id: userId
|
||||
};
|
||||
|
||||
$.post(postUrl, postData, function(response) {
|
||||
if (!GeneralFunctions.handleAjaxExceptions(response)) {
|
||||
|
|
|
@ -61,8 +61,8 @@
|
|||
return; // exit because we are currently on edit mode
|
||||
}
|
||||
|
||||
var adminId = $(e.currentTarget).attr('data-id'),
|
||||
admin = {};
|
||||
var adminId = $(e.currentTarget).attr('data-id');
|
||||
var admin = {};
|
||||
|
||||
$.each(this.filterResults, function(index, item) {
|
||||
if (item.id === adminId) {
|
||||
|
@ -109,8 +109,8 @@
|
|||
* Event: Delete Admin Button "Click"
|
||||
*/
|
||||
$('#admins').on('click', '#delete-admin', function() {
|
||||
var adminId = $('#admin-id').val(),
|
||||
messageBtns = {};
|
||||
var adminId = $('#admin-id').val();
|
||||
var messageBtns = {};
|
||||
|
||||
messageBtns[EALang['delete']] = function() {
|
||||
this.delete(adminId);
|
||||
|
@ -184,11 +184,11 @@
|
|||
* then the update operation is going to be executed.
|
||||
*/
|
||||
AdminsHelper.prototype.save = function(admin) {
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_admin',
|
||||
postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
admin: JSON.stringify(admin)
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_admin';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
admin: JSON.stringify(admin)
|
||||
};
|
||||
|
||||
$.post(postUrl, postData, function(response) {
|
||||
if (!GeneralFunctions.handleAjaxExceptions(response)) {
|
||||
|
@ -207,11 +207,11 @@
|
|||
* @param {Number} id Record id to be deleted.
|
||||
*/
|
||||
AdminsHelper.prototype.delete = function(id) {
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_admin',
|
||||
postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
admin_id: id
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_admin';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
admin_id: id
|
||||
};
|
||||
|
||||
$.post(postUrl, postData, function(response) {
|
||||
if (!GeneralFunctions.handleAjaxExceptions(response)) {
|
||||
|
@ -339,11 +339,11 @@
|
|||
AdminsHelper.prototype.filter = function(key, selectId, display) {
|
||||
display = display || false;
|
||||
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_admins',
|
||||
postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
key: key
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_admins';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
key: key
|
||||
};
|
||||
|
||||
$.post(postUrl, postData, function(response) {
|
||||
if (!GeneralFunctions.handleAjaxExceptions(response)) {
|
||||
|
@ -378,8 +378,8 @@
|
|||
* @return {String} The html code that represents the record on the filter results list.
|
||||
*/
|
||||
AdminsHelper.prototype.getFilterHtml = function(admin) {
|
||||
var name = admin.first_name + ' ' + admin.last_name,
|
||||
info = admin.email;
|
||||
var name = admin.first_name + ' ' + admin.last_name;
|
||||
var info = admin.email;
|
||||
|
||||
info = (admin.mobile_number != '' && admin.mobile_number != null)
|
||||
? info + ', ' + admin.mobile_number : info;
|
||||
|
|
|
@ -63,8 +63,8 @@
|
|||
return; // Exit because we are currently on edit mode.
|
||||
}
|
||||
|
||||
var providerId = $(e.currentTarget).attr('data-id'),
|
||||
provider = {};
|
||||
var providerId = $(e.currentTarget).attr('data-id');
|
||||
var provider = {};
|
||||
|
||||
$.each(this.filterResults, function(index, item) {
|
||||
if (item.id === providerId) {
|
||||
|
@ -236,11 +236,11 @@
|
|||
* then the update operation is going to be executed.
|
||||
*/
|
||||
ProvidersHelper.prototype.save = function(provider) {
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_provider',
|
||||
postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
provider: JSON.stringify(provider)
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_provider';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
provider: JSON.stringify(provider)
|
||||
};
|
||||
|
||||
$.post(postUrl, postData, function(response) {
|
||||
if (!GeneralFunctions.handleAjaxExceptions(response)) {
|
||||
|
@ -259,11 +259,11 @@
|
|||
* @param {Number} id Record id to be deleted.
|
||||
*/
|
||||
ProvidersHelper.prototype.delete = function(id) {
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_provider',
|
||||
postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
provider_id: id
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_provider';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
provider_id: id
|
||||
};
|
||||
|
||||
$.post(postUrl, postData, function(response) {
|
||||
if (!GeneralFunctions.handleAjaxExceptions(response)) {
|
||||
|
@ -412,11 +412,11 @@
|
|||
ProvidersHelper.prototype.filter = function(key, selectId, display) {
|
||||
display = display || false;
|
||||
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_providers',
|
||||
postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
key: key
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_providers';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
key: key
|
||||
};
|
||||
|
||||
$.post(postUrl, postData, function(response) {
|
||||
if (!GeneralFunctions.handleAjaxExceptions(response)) {
|
||||
|
|
|
@ -63,8 +63,8 @@
|
|||
return; // exit because we are currently on edit mode
|
||||
}
|
||||
|
||||
var secretaryId = $(e.currentTarget).attr('data-id'),
|
||||
secretary = {};
|
||||
var secretaryId = $(e.currentTarget).attr('data-id');
|
||||
var secretary = {};
|
||||
|
||||
$.each(this.filterResults, function(index, item) {
|
||||
if (item.id === secretaryId) {
|
||||
|
@ -114,8 +114,8 @@
|
|||
* Event: Delete Secretary Button "Click"
|
||||
*/
|
||||
$('#secretaries').on('click', '#delete-secretary', function() {
|
||||
var secretaryId = $('#secretary-id').val(),
|
||||
messageBtns = {};
|
||||
var secretaryId = $('#secretary-id').val();
|
||||
var messageBtns = {};
|
||||
|
||||
messageBtns[EALang['delete']] = function() {
|
||||
this.delete(secretaryId);
|
||||
|
@ -197,11 +197,11 @@
|
|||
* then the update operation is going to be executed.
|
||||
*/
|
||||
SecretariesHelper.prototype.save = function(secretary) {
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_secretary',
|
||||
postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
secretary: JSON.stringify(secretary)
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_secretary';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
secretary: JSON.stringify(secretary)
|
||||
};
|
||||
|
||||
$.post(postUrl, postData, function(response) {
|
||||
if (!GeneralFunctions.handleAjaxExceptions(response)) {
|
||||
|
@ -220,11 +220,11 @@
|
|||
* @param {Number} id Record id to be deleted.
|
||||
*/
|
||||
SecretariesHelper.prototype.delete = function(id) {
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_secretary',
|
||||
postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
secretary_id: id
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_secretary';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
secretary_id: id
|
||||
};
|
||||
|
||||
$.post(postUrl, postData, function(response) {
|
||||
if (!GeneralFunctions.handleAjaxExceptions(response)) {
|
||||
|
@ -361,11 +361,11 @@
|
|||
SecretariesHelper.prototype.filter = function(key, selectId, display) {
|
||||
display = display || false;
|
||||
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_secretaries',
|
||||
postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
key: key
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_secretaries';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
key: key
|
||||
};
|
||||
|
||||
$.post(postUrl, postData, function(response) {
|
||||
if (!GeneralFunctions.handleAjaxExceptions(response)) {
|
||||
|
@ -400,8 +400,8 @@
|
|||
* @return {String} The html code that represents the record on the filter results list.
|
||||
*/
|
||||
SecretariesHelper.prototype.getFilterHtml = function(secretary) {
|
||||
var name = secretary.first_name + ' ' + secretary.last_name,
|
||||
info = secretary.email;
|
||||
var name = secretary.first_name + ' ' + secretary.last_name;
|
||||
var info = secretary.email;
|
||||
|
||||
info = (secretary.mobile_number != '' && secretary.mobile_number != null)
|
||||
? info + ', ' + secretary.mobile_number : info;
|
||||
|
|
|
@ -344,9 +344,9 @@ window.FrontendBook = window.FrontendBook || {};
|
|||
selectedDate = GeneralFunctions.formatDate(selectedDate, GlobalVariables.dateFormat);
|
||||
}
|
||||
|
||||
var selServiceId = $('#select-service').val(),
|
||||
servicePrice,
|
||||
serviceCurrency;
|
||||
var selServiceId = $('#select-service').val();
|
||||
var servicePrice;
|
||||
var serviceCurrency;
|
||||
|
||||
$.each(GlobalVariables.availableServices, function(index, service) {
|
||||
if (service.id == selServiceId) {
|
||||
|
@ -369,13 +369,13 @@ window.FrontendBook = window.FrontendBook || {};
|
|||
$('#appointment-details').html(html);
|
||||
|
||||
// Customer Details
|
||||
var firstname = GeneralFunctions.escapeHtml($('#first-name').val()),
|
||||
lastname = GeneralFunctions.escapeHtml($('#last-name').val()),
|
||||
phoneNumber = GeneralFunctions.escapeHtml($('#phone-number').val()),
|
||||
email = GeneralFunctions.escapeHtml($('#email').val()),
|
||||
address = GeneralFunctions.escapeHtml($('#address').val()),
|
||||
city = GeneralFunctions.escapeHtml($('#city').val()),
|
||||
zipCode = GeneralFunctions.escapeHtml($('#zip-code').val()),
|
||||
var firstname = GeneralFunctions.escapeHtml($('#first-name').val());
|
||||
var lastname = GeneralFunctions.escapeHtml($('#last-name').val());
|
||||
var phoneNumber = GeneralFunctions.escapeHtml($('#phone-number').val());
|
||||
var email = GeneralFunctions.escapeHtml($('#email').val());
|
||||
var address = GeneralFunctions.escapeHtml($('#address').val());
|
||||
var city = GeneralFunctions.escapeHtml($('#city').val());
|
||||
var zipCode = GeneralFunctions.escapeHtml($('#zip-code').val());
|
||||
|
||||
html =
|
||||
'<h4>' + firstname + ' ' + lastname + '</h4>' +
|
||||
|
|
|
@ -45,16 +45,16 @@ window.FrontendBookApi = window.FrontendBookApi || {};
|
|||
var appointmentId = FrontendBook.manageMode ? GlobalVariables.appointmentData['id'] : undefined;
|
||||
|
||||
// Make ajax post request and get the available hours.
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/appointments/ajax_get_available_hours',
|
||||
postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
service_id: $('#select-service').val(),
|
||||
provider_id: $('#select-provider').val(),
|
||||
selected_date: selDate,
|
||||
service_duration: selServiceDuration,
|
||||
manage_mode: FrontendBook.manageMode,
|
||||
appointment_id: appointmentId
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/appointments/ajax_get_available_hours';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
service_id: $('#select-service').val(),
|
||||
provider_id: $('#select-provider').val(),
|
||||
selected_date: selDate,
|
||||
service_duration: selServiceDuration,
|
||||
manage_mode: FrontendBook.manageMode,
|
||||
appointment_id: appointmentId
|
||||
};
|
||||
|
||||
$.post(postUrl, postData, function(response) {
|
||||
if (!GeneralFunctions.handleAjaxExceptions(response)) {
|
||||
|
@ -115,11 +115,11 @@ window.FrontendBookApi = window.FrontendBookApi || {};
|
|||
}
|
||||
}
|
||||
|
||||
var formData = jQuery.parseJSON($('input[name="post_data"]').val()),
|
||||
postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
post_data: formData
|
||||
};
|
||||
var formData = jQuery.parseJSON($('input[name="post_data"]').val());
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
post_data: formData
|
||||
};
|
||||
|
||||
if ($captchaText.length > 0) {
|
||||
postData.captcha = $captchaText.val();
|
||||
|
@ -129,8 +129,8 @@ window.FrontendBookApi = window.FrontendBookApi || {};
|
|||
postData.exclude_appointment_id = GlobalVariables.appointmentData.id;
|
||||
}
|
||||
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/appointments/ajax_register_appointment',
|
||||
$layer = $('<div/>');
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/appointments/ajax_register_appointment';
|
||||
var $layer = $('<div/>');
|
||||
|
||||
$.ajax({
|
||||
url: postUrl,
|
||||
|
@ -197,13 +197,13 @@ window.FrontendBookApi = window.FrontendBookApi || {};
|
|||
* @param {String} selectedDateString Y-m-d value of the selected date.
|
||||
*/
|
||||
exports.getUnavailableDates = function(providerId, serviceId, selectedDateString) {
|
||||
var url = GlobalVariables.baseUrl + '/index.php/appointments/ajax_get_unavailable_dates',
|
||||
data = {
|
||||
provider_id: providerId,
|
||||
service_id: serviceId,
|
||||
selected_date: encodeURIComponent(selectedDateString),
|
||||
csrfToken: GlobalVariables.csrfToken
|
||||
};
|
||||
var url = GlobalVariables.baseUrl + '/index.php/appointments/ajax_get_unavailable_dates';
|
||||
var data = {
|
||||
provider_id: providerId,
|
||||
service_id: serviceId,
|
||||
selected_date: encodeURIComponent(selectedDateString),
|
||||
csrfToken: GlobalVariables.csrfToken
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
|
@ -213,8 +213,8 @@ window.FrontendBookApi = window.FrontendBookApi || {};
|
|||
})
|
||||
.done(function(response) {
|
||||
// Select first enabled date.
|
||||
var selectedDate = Date.parse(selectedDateString),
|
||||
numberOfDays = new Date(selectedDate.getFullYear(), selectedDate.getMonth() + 1, 0).getDate();
|
||||
var selectedDate = Date.parse(selectedDateString);
|
||||
var numberOfDays = new Date(selectedDate.getFullYear(), selectedDate.getMonth() + 1, 0).getDate();
|
||||
|
||||
for (var i=1; i<=numberOfDays; i++) {
|
||||
var currentDate = new Date(selectedDate.getFullYear(), selectedDate.getMonth(), i);
|
||||
|
|
|
@ -115,9 +115,9 @@ window.GeneralFunctions = window.GeneralFunctions || {};
|
|||
*/
|
||||
exports.getUrlParameter = function(url, parameterName) {
|
||||
parameterName = parameterName.replace(/[\[]/,'\\\[').replace(/[\]]/,'\\\]');
|
||||
var regexS = '[\\#&]' + parameterName + '=([^&#]*)',
|
||||
regex = new RegExp(regexS),
|
||||
results = regex.exec(url);
|
||||
var regexS = '[\\#&]' + parameterName + '=([^&#]*)';
|
||||
var regex = new RegExp(regexS);
|
||||
var results = regex.exec(url);
|
||||
return (results == null) ? '' : results[1];
|
||||
};
|
||||
|
||||
|
@ -340,11 +340,11 @@ window.GeneralFunctions = window.GeneralFunctions || {};
|
|||
|
||||
$(document).on('click', 'li.language', function() {
|
||||
// Change language with ajax call and refresh page.
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_change_language',
|
||||
postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
language: $(this).attr('data-language'),
|
||||
};
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_change_language';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
language: $(this).attr('data-language'),
|
||||
};
|
||||
$.post(postUrl, postData, function(response) {
|
||||
if (!GeneralFunctions.handleAjaxExceptions(response)) {
|
||||
return;
|
||||
|
@ -394,8 +394,8 @@ window.GeneralFunctions = window.GeneralFunctions || {};
|
|||
* @return {String} Returns the formatted date string.
|
||||
*/
|
||||
exports.formatDate = function(date, dateFormatSetting, addHours) {
|
||||
var format, result,
|
||||
hours = addHours ? ' HH:mm' : '';
|
||||
var format, result;
|
||||
var hours = addHours ? ' HH:mm' : '';
|
||||
|
||||
switch(dateFormatSetting) {
|
||||
case 'DMY':
|
||||
|
|
Loading…
Reference in a new issue