mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-12-22 22:52:35 +03:00
Changed object properties reference style.
This commit is contained in:
parent
89890dab4f
commit
7bfff7bfe0
9 changed files with 77 additions and 77 deletions
|
@ -117,12 +117,12 @@ window.Backend = window.Backend || {};
|
|||
var customActionsHtml = '';
|
||||
|
||||
$.each(actions, function(index, action) {
|
||||
var actionId = action['label'].toLowerCase().replace(' ', '-');
|
||||
var actionId = action.label.toLowerCase().replace(' ', '-');
|
||||
customActionsHtml += '<button id="' + actionId + '" class="btn btn-default btn-xs">'
|
||||
+ action['label'] + '</button>';
|
||||
+ action.label + '</button>';
|
||||
|
||||
$(document).off('click', '#' + actionId);
|
||||
$(document).on('click', '#' + actionId, action['function']);
|
||||
$(document).on('click', '#' + actionId, action.function);
|
||||
});
|
||||
|
||||
var notificationHtml =
|
||||
|
|
|
@ -34,20 +34,20 @@ window.BackendCalendarApi = window.BackendCalendarApi || {};
|
|||
* @param {Function} errorCallback Optional, if defined, this function is going to be executed on post failure.
|
||||
*/
|
||||
exports.saveAppointment = function(appointment, customer, successCallback, errorCallback) {
|
||||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_appointment';
|
||||
var postData = {
|
||||
var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_appointment';
|
||||
var data = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
appointment_data: JSON.stringify(appointment)
|
||||
};
|
||||
|
||||
if (customer !== undefined) {
|
||||
postData['customer_data'] = JSON.stringify(customer);
|
||||
data.customer_data = JSON.stringify(customer);
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: postUrl,
|
||||
url: url,
|
||||
type: 'POST',
|
||||
data: postData,
|
||||
data: data,
|
||||
dataType: 'json'
|
||||
})
|
||||
.done(function(response) {
|
||||
|
|
|
@ -63,7 +63,7 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa
|
|||
|
||||
if ($dialog.find('#appointment-id').val() !== '') {
|
||||
// Set the id value, only if we are editing an appointment.
|
||||
appointment['id'] = $dialog.find('#appointment-id').val();
|
||||
appointment.id = $dialog.find('#appointment-id').val();
|
||||
}
|
||||
|
||||
var customer = {
|
||||
|
@ -79,8 +79,8 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa
|
|||
|
||||
if ($dialog.find('#customer-id').val() !== '') {
|
||||
// Set the id value, only if we are editing an appointment.
|
||||
customer['id'] = $dialog.find('#customer-id').val();
|
||||
appointment['id_users_customer'] = customer['id'];
|
||||
customer.id = $dialog.find('#customer-id').val();
|
||||
appointment.id_users_customer = customer.id;
|
||||
}
|
||||
|
||||
// Define success callback.
|
||||
|
@ -144,8 +144,8 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa
|
|||
|
||||
var serviceDuration = 0;
|
||||
$.each(GlobalVariables.availableServices, function(index, service) {
|
||||
if (service['id'] == $dialog.find('#select-service').val()) {
|
||||
serviceDuration = service['duration'];
|
||||
if (service.id == $dialog.find('#select-service').val()) {
|
||||
serviceDuration = service.duration;
|
||||
return false; // exit loop
|
||||
}
|
||||
});
|
||||
|
@ -299,8 +299,8 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa
|
|||
$.each(provider.services, function(indexService, serviceId) {
|
||||
// If the current provider is able to provide the selected service, add him to the listbox.
|
||||
if (serviceId == sid) {
|
||||
var optionHtml = '<option value="' + provider['id'] + '">'
|
||||
+ provider['first_name'] + ' ' + provider['last_name']
|
||||
var optionHtml = '<option value="' + provider.id + '">'
|
||||
+ provider.first_name + ' ' + provider.last_name
|
||||
+ '</option>';
|
||||
$('#select-provider').append(optionHtml);
|
||||
}
|
||||
|
@ -340,7 +340,7 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa
|
|||
$.each(GlobalVariables.availableProviders, function(index, provider) {
|
||||
var canProvideService = false;
|
||||
|
||||
$.each(provider['services'], function(index, serviceId) {
|
||||
$.each(provider.services, function(index, serviceId) {
|
||||
if (serviceId == $dialog.find('#select-service').val()) {
|
||||
canProvideService = true;
|
||||
return false;
|
||||
|
@ -348,8 +348,8 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa
|
|||
});
|
||||
|
||||
if (canProvideService) { // Add the provider to the listbox.
|
||||
var option = new Option(provider['first_name']
|
||||
+ ' ' + provider['last_name'], provider['id']);
|
||||
var option = new Option(provider.first_name
|
||||
+ ' ' + provider.last_name, provider.id);
|
||||
$dialog.find('#select-provider').append(option);
|
||||
}
|
||||
});
|
||||
|
@ -363,8 +363,8 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa
|
|||
// Get the selected service duration. It will be needed in order to calculate the appointment end datetime.
|
||||
var serviceDuration = 0;
|
||||
$.each(GlobalVariables.availableServices, function(index, service) {
|
||||
if (service['id'] == $dialog.find('#select-service').val()) {
|
||||
serviceDuration = service['duration'];
|
||||
if (service.id == $dialog.find('#select-service').val()) {
|
||||
serviceDuration = service.duration;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -94,11 +94,11 @@ window.BackendCalendarGoogleSync = window.BackendCalendarGoogleSync || {};
|
|||
// Update page elements and make an AJAX call to remove the google sync setting of the
|
||||
// selected provider.
|
||||
$.each(GlobalVariables.availableProviders, function(index, provider) {
|
||||
if (provider['id'] == $('#select-filter-item').val()) {
|
||||
provider['settings']['google_sync'] = '0';
|
||||
provider['settings']['google_token'] = null;
|
||||
if (provider.id == $('#select-filter-item').val()) {
|
||||
provider.settings.google_sync = '0';
|
||||
provider.settings.google_token = null;
|
||||
|
||||
_disableProviderSync(provider['id']);
|
||||
_disableProviderSync(provider.id);
|
||||
|
||||
$('#enable-sync').removeClass('btn-danger enabled');
|
||||
$('#enable-sync span:eq(1)').text(EALang.enable_sync);
|
||||
|
|
|
@ -261,30 +261,30 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
|
|||
|
||||
// Apply appointment data and show modal dialog.
|
||||
$dialog.find('.modal-header h3').text(EALang.edit_appointment_title);
|
||||
$dialog.find('#appointment-id').val(appointment['id']);
|
||||
$dialog.find('#select-service').val(appointment['id_services']).trigger('change');
|
||||
$dialog.find('#select-provider').val(appointment['id_users_provider']);
|
||||
$dialog.find('#appointment-id').val(appointment.id);
|
||||
$dialog.find('#select-service').val(appointment.id_services).trigger('change');
|
||||
$dialog.find('#select-provider').val(appointment.id_users_provider);
|
||||
|
||||
// Set the start and end datetime of the appointment.
|
||||
var startDatetime = Date.parseExact(appointment['start_datetime'],
|
||||
var startDatetime = Date.parseExact(appointment.start_datetime,
|
||||
'yyyy-MM-dd HH:mm:ss');
|
||||
$dialog.find('#start-datetime').datetimepicker('setDate', startDatetime);
|
||||
|
||||
var endDatetime = Date.parseExact(appointment['end_datetime'],
|
||||
var endDatetime = Date.parseExact(appointment.end_datetime,
|
||||
'yyyy-MM-dd HH:mm:ss');
|
||||
$dialog.find('#end-datetime').datetimepicker('setDate', endDatetime);
|
||||
|
||||
var customer = appointment['customer'];
|
||||
$dialog.find('#customer-id').val(appointment['id_users_customer']);
|
||||
$dialog.find('#first-name').val(customer['first_name']);
|
||||
$dialog.find('#last-name').val(customer['last_name']);
|
||||
$dialog.find('#email').val(customer['email']);
|
||||
$dialog.find('#phone-number').val(customer['phone_number']);
|
||||
$dialog.find('#address').val(customer['address']);
|
||||
$dialog.find('#city').val(customer['city']);
|
||||
$dialog.find('#zip-code').val(customer['zip_code']);
|
||||
$dialog.find('#appointment-notes').val(appointment['notes']);
|
||||
$dialog.find('#customer-notes').val(customer['notes']);
|
||||
var customer = appointment.customer;
|
||||
$dialog.find('#customer-id').val(appointment.id_users_customer);
|
||||
$dialog.find('#first-name').val(customer.first_name);
|
||||
$dialog.find('#last-name').val(customer.last_name);
|
||||
$dialog.find('#email').val(customer.email);
|
||||
$dialog.find('#phone-number').val(customer.phone_number);
|
||||
$dialog.find('#address').val(customer.address);
|
||||
$dialog.find('#city').val(customer.city);
|
||||
$dialog.find('#zip-code').val(customer.zip_code);
|
||||
$dialog.find('#appointment-notes').val(appointment.notes);
|
||||
$dialog.find('#customer-notes').val(customer.notes);
|
||||
} else {
|
||||
var unavailable = lastFocusedEventData;
|
||||
|
||||
|
@ -311,7 +311,7 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
|
|||
/**
|
||||
* Event: Popover Delete Button "Click"
|
||||
*
|
||||
* Displays a prompt on whether the user wants the appoinmtent to be deleted. If he confirms the
|
||||
* Displays a prompt on whether the user wants the appointment to be deleted. If he confirms the
|
||||
* deletion then an ajax call is made to the server and deletes the appointment from the database.
|
||||
*/
|
||||
$calendar.on('click', '.delete-popover', function() {
|
||||
|
@ -325,7 +325,7 @@ window.BackendCalendarTableView = window.BackendCalendarTableView || {};
|
|||
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_appointment';
|
||||
var postData = {
|
||||
csrfToken: GlobalVariables.csrfToken,
|
||||
appointment_id : lastFocusedEventData['id'],
|
||||
appointment_id : lastFocusedEventData.id,
|
||||
delete_reason: $('#delete-reason').val()
|
||||
};
|
||||
|
||||
|
|
|
@ -170,12 +170,12 @@ window.FrontendBook = window.FrontendBook || {};
|
|||
$('#select-provider').empty();
|
||||
|
||||
$.each(GlobalVariables.availableProviders, function(indexProvider, provider) {
|
||||
$.each(provider['services'], function(indexService, serviceId) {
|
||||
$.each(provider.services'], function(indexService, serviceId) {
|
||||
// If the current provider is able to provide the selected service,
|
||||
// add him to the listbox.
|
||||
if (serviceId == currServiceId) {
|
||||
var optionHtml = '<option value="' + provider['id'] + '">'
|
||||
+ provider['first_name'] + ' ' + provider['last_name']
|
||||
var optionHtml = '<option value="' + provider.id'] + '">'
|
||||
+ provider.first_name'] + ' ' + provider.last_name']
|
||||
+ '</option>';
|
||||
$('#select-provider').append(optionHtml);
|
||||
}
|
||||
|
@ -444,7 +444,7 @@ window.FrontendBook = window.FrontendBook || {};
|
|||
// the appointment.
|
||||
var postData = {};
|
||||
|
||||
postData['customer'] = {
|
||||
postData.customer = {
|
||||
last_name: $('#last-name').val(),
|
||||
first_name: $('#first-name').val(),
|
||||
email: $('#email').val(),
|
||||
|
@ -454,7 +454,7 @@ window.FrontendBook = window.FrontendBook || {};
|
|||
zip_code: $('#zip-code').val()
|
||||
};
|
||||
|
||||
postData['appointment'] = {
|
||||
postData.appointment = {
|
||||
start_datetime: $('#select-date').datepicker('getDate').toString('yyyy-MM-dd')
|
||||
+ ' ' + Date.parse($('.selected-hour').text()).toString('HH:mm') + ':00',
|
||||
end_datetime: _calcEndDatetime(),
|
||||
|
@ -464,11 +464,11 @@ window.FrontendBook = window.FrontendBook || {};
|
|||
id_services: $('#select-service').val()
|
||||
};
|
||||
|
||||
postData['manage_mode'] = FrontendBook.manageMode;
|
||||
postData.manage_mode = FrontendBook.manageMode;
|
||||
|
||||
if (FrontendBook.manageMode) {
|
||||
postData['appointment']['id'] = GlobalVariables.appointmentData['id'];
|
||||
postData['customer']['id'] = GlobalVariables.customerData['id'];
|
||||
postData.appointment.id = GlobalVariables.appointmentData.id;
|
||||
postData.customer.id = GlobalVariables.customerData.id;
|
||||
}
|
||||
$('input[name="csrfToken"]').val(GlobalVariables.csrfToken);
|
||||
$('input[name="post_data"]').val(JSON.stringify(postData));
|
||||
|
@ -519,24 +519,24 @@ window.FrontendBook = window.FrontendBook || {};
|
|||
function _applyAppointmentData(appointment, provider, customer) {
|
||||
try {
|
||||
// Select Service & Provider
|
||||
$('#select-service').val(appointment['id_services']).trigger('change');
|
||||
$('#select-provider').val(appointment['id_users_provider']);
|
||||
$('#select-service').val(appointment.id_services).trigger('change');
|
||||
$('#select-provider').val(appointment.id_users_provider);
|
||||
|
||||
// Set Appointment Date
|
||||
$('#select-date').datepicker('setDate',
|
||||
Date.parseExact(appointment['start_datetime'], 'yyyy-MM-dd HH:mm:ss'));
|
||||
Date.parseExact(appointment.start_datetime, 'yyyy-MM-dd HH:mm:ss'));
|
||||
FrontendBookApi.getAvailableHours($('#select-date').val());
|
||||
|
||||
// Apply Customer's Data
|
||||
$('#last-name').val(customer['last_name']);
|
||||
$('#first-name').val(customer['first_name']);
|
||||
$('#email').val(customer['email']);
|
||||
$('#phone-number').val(customer['phone_number']);
|
||||
$('#address').val(customer['address']);
|
||||
$('#city').val(customer['city']);
|
||||
$('#zip-code').val(customer['zip_code']);
|
||||
var appointmentNotes = (appointment['notes'] !== null)
|
||||
? appointment['notes'] : '';
|
||||
$('#last-name').val(customer.last_name);
|
||||
$('#first-name').val(customer.first_name);
|
||||
$('#email').val(customer.email);
|
||||
$('#phone-number').val(customer.phone_number);
|
||||
$('#address').val(customer.address);
|
||||
$('#city').val(customer.city);
|
||||
$('#zip-code').val(customer.zip_code);
|
||||
var appointmentNotes = (appointment.notes !== null)
|
||||
? appointment.notes : '';
|
||||
$('#notes').val(appointmentNotes);
|
||||
|
||||
FrontendBook.updateConfirmFrame();
|
||||
|
|
|
@ -40,13 +40,13 @@ window.FrontendBookApi = window.FrontendBookApi || {};
|
|||
// Find the selected service duration (it is going to be send within the "postData" object).
|
||||
var selServiceDuration = 15; // Default value of duration (in minutes).
|
||||
$.each(GlobalVariables.availableServices, function(index, service) {
|
||||
if (service['id'] == $('#select-service').val()) {
|
||||
selServiceDuration = service['duration'];
|
||||
if (service.id == $('#select-service').val()) {
|
||||
selServiceDuration = service.duration;
|
||||
}
|
||||
});
|
||||
|
||||
// If the manage mode is true then the appointment's start date should return as available too.
|
||||
var appointmentId = FrontendBook.manageMode ? GlobalVariables.appointmentData['id'] : undefined;
|
||||
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';
|
||||
|
@ -86,7 +86,7 @@ window.FrontendBookApi = window.FrontendBookApi || {};
|
|||
$('.available-hour').removeClass('selected-hour');
|
||||
$('.available-hour').filter(function() {
|
||||
return $(this).text() === Date.parseExact(
|
||||
GlobalVariables.appointmentData['start_datetime'],
|
||||
GlobalVariables.appointmentData.start_datetime,
|
||||
'yyyy-MM-dd HH:mm:ss').toString('h:mm tt');
|
||||
}).addClass('selected-hour');
|
||||
} else {
|
||||
|
|
|
@ -45,28 +45,28 @@ $(document).ready(function() {
|
|||
// must be prepared.
|
||||
var appointmentData = GlobalVariables.appointmentData;
|
||||
|
||||
appointmentData['start_datetime'] = GeneralFunctions.ISODateString(
|
||||
Date.parseExact(appointmentData['start_datetime'],
|
||||
appointmentData.start_datetime = GeneralFunctions.ISODateString(
|
||||
Date.parseExact(appointmentData.start_datetime,
|
||||
'yyyy-MM-dd HH:mm:ss'));
|
||||
appointmentData['end_datetime'] = GeneralFunctions.ISODateString(
|
||||
Date.parseExact(appointmentData['end_datetime'],
|
||||
appointmentData.end_datetime = GeneralFunctions.ISODateString(
|
||||
Date.parseExact(appointmentData.end_datetime,
|
||||
'yyyy-MM-dd HH:mm:ss'));
|
||||
|
||||
// Create a valid Google Calendar API resource for the new event.
|
||||
var resource = {
|
||||
summary: GlobalVariables.serviceData['name'],
|
||||
summary: GlobalVariables.serviceData.name,
|
||||
location: GlobalVariables.companyName,
|
||||
start: {
|
||||
dateTime: appointmentData['start_datetime']
|
||||
dateTime: appointmentData.start_datetime
|
||||
},
|
||||
end: {
|
||||
dateTime: appointmentData['end_datetime']
|
||||
dateTime: appointmentData.end_datetime
|
||||
},
|
||||
attendees: [
|
||||
{
|
||||
email: GlobalVariables.providerData['email'],
|
||||
displayName: GlobalVariables.providerData['first_name'] + ' '
|
||||
+ GlobalVariables.providerData['last_name']
|
||||
email: GlobalVariables.providerData.email,
|
||||
displayName: GlobalVariables.providerData.first_name + ' '
|
||||
+ GlobalVariables.providerData.last_name
|
||||
}
|
||||
]
|
||||
};
|
||||
|
|
|
@ -242,7 +242,7 @@ window.GeneralFunctions = window.GeneralFunctions || {};
|
|||
html +=
|
||||
'<div id="error-technical" class="accordion-body collapse">' +
|
||||
'<div class="accordion-inner">' +
|
||||
'<pre>' + exception['message'] + '</pre>' +
|
||||
'<pre>' + exception.message + '</pre>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue