2015-07-20 22:41:24 +03:00
|
|
|
/* ----------------------------------------------------------------------------
|
|
|
|
* Easy!Appointments - Open Source Web Scheduler
|
2015-10-06 00:30:56 +03:00
|
|
|
*
|
2015-07-20 22:41:24 +03:00
|
|
|
* @package EasyAppointments
|
|
|
|
* @author A.Tselegidis <alextselegidis@gmail.com>
|
2016-01-02 15:47:04 +02:00
|
|
|
* @copyright Copyright (c) 2013 - 2016, Alex Tselegidis
|
2015-10-06 00:30:56 +03:00
|
|
|
* @license http://opensource.org/licenses/GPL-3.0 - GPLv3
|
2015-07-20 22:41:24 +03:00
|
|
|
* @link http://easyappointments.org
|
|
|
|
* @since v1.0.0
|
|
|
|
* ---------------------------------------------------------------------------- */
|
|
|
|
|
2013-06-12 18:31:16 +03:00
|
|
|
/**
|
2016-04-02 13:25:29 +03:00
|
|
|
* Backend Calendar
|
|
|
|
*
|
2016-07-17 14:46:38 +03:00
|
|
|
* This module contains functions that are used by the backend calendar page.
|
2015-10-06 00:30:56 +03:00
|
|
|
*
|
2016-07-17 14:46:38 +03:00
|
|
|
* @module BackendCalendar
|
2013-06-12 18:31:16 +03:00
|
|
|
*/
|
2016-04-02 13:25:29 +03:00
|
|
|
window.BackendCalendar = window.BackendCalendar || {};
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2016-04-02 13:25:29 +03:00
|
|
|
(function(exports) {
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2016-04-02 13:25:29 +03:00
|
|
|
'use strict';
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2016-04-02 13:25:29 +03:00
|
|
|
// Variables
|
|
|
|
var lastFocusedEventData; // Contains event data for later use.
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-06-12 18:31:16 +03:00
|
|
|
/**
|
2016-05-15 14:05:28 +03:00
|
|
|
* Bind Event Handlers
|
|
|
|
*
|
|
|
|
* This method binds the default event handlers for the backend calendar page. If you do not need the
|
|
|
|
* default handlers then initialize the page by setting the "defaultEventHandlers" argument to "false".
|
2013-06-12 18:31:16 +03:00
|
|
|
*/
|
2016-04-02 13:25:29 +03:00
|
|
|
function _bindEventHandlers() {
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2016-07-17 14:46:38 +03:00
|
|
|
var $calendarPage = $('#calendar-page');
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-06-24 12:52:23 +03:00
|
|
|
/**
|
|
|
|
* Event: Reload Button "Click"
|
2015-10-06 00:30:56 +03:00
|
|
|
*
|
2016-05-15 14:05:28 +03:00
|
|
|
* When the user clicks the reload button an the calendar items need to be refreshed.
|
2013-06-24 12:52:23 +03:00
|
|
|
*/
|
|
|
|
$('#reload-appointments').click(function() {
|
2015-10-06 00:30:56 +03:00
|
|
|
$('#select-filter-item').trigger('change');
|
2013-06-24 12:52:23 +03:00
|
|
|
});
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-06-13 19:25:34 +03:00
|
|
|
/**
|
2013-06-18 19:06:34 +03:00
|
|
|
* Event: Popover Close Button "Click"
|
2015-10-06 00:30:56 +03:00
|
|
|
*
|
2013-06-13 19:25:34 +03:00
|
|
|
* Hides the open popover element.
|
|
|
|
*/
|
2016-07-17 14:46:38 +03:00
|
|
|
$calendarPage.on('click', '.close-popover', function() {
|
2015-10-06 00:30:56 +03:00
|
|
|
$(this).parents().eq(2).remove();
|
2013-06-13 19:25:34 +03:00
|
|
|
});
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-06-13 19:25:34 +03:00
|
|
|
/**
|
2013-06-18 19:06:34 +03:00
|
|
|
* Event: Popover Edit Button "Click"
|
2015-10-06 00:30:56 +03:00
|
|
|
*
|
2013-06-13 19:25:34 +03:00
|
|
|
* Enables the edit dialog of the selected calendar event.
|
|
|
|
*/
|
2016-07-17 14:46:38 +03:00
|
|
|
$calendarPage.on('click', '.edit-popover', function() {
|
2013-06-13 19:25:34 +03:00
|
|
|
$(this).parents().eq(2).remove(); // Hide the popover
|
2015-10-06 00:30:56 +03:00
|
|
|
|
|
|
|
var $dialog;
|
|
|
|
|
2016-04-02 13:25:29 +03:00
|
|
|
if (lastFocusedEventData.data.is_unavailable == false) {
|
|
|
|
var appointment = lastFocusedEventData.data;
|
2013-07-10 16:57:24 +03:00
|
|
|
$dialog = $('#manage-appointment');
|
|
|
|
|
2016-04-02 13:25:29 +03:00
|
|
|
_resetAppointmentDialog();
|
2013-07-10 16:57:24 +03:00
|
|
|
|
2016-05-15 14:05:28 +03:00
|
|
|
// Apply appointment data and show modal dialog.
|
2013-12-20 19:44:44 +02:00
|
|
|
$dialog.find('.modal-header h3').text(EALang['edit_appointment_title']);
|
2013-07-10 16:57:24 +03:00
|
|
|
$dialog.find('#appointment-id').val(appointment['id']);
|
2013-09-27 15:49:29 +03:00
|
|
|
$dialog.find('#select-service').val(appointment['id_services']).trigger('change');
|
2013-07-10 16:57:24 +03:00
|
|
|
$dialog.find('#select-provider').val(appointment['id_users_provider']);
|
|
|
|
|
2013-07-15 10:32:19 +03:00
|
|
|
// Set the start and end datetime of the appointment.
|
2013-07-10 16:57:24 +03:00
|
|
|
var startDatetime = Date.parseExact(appointment['start_datetime'],
|
2015-12-11 01:04:40 +02:00
|
|
|
'yyyy-MM-dd HH:mm:ss');
|
2016-02-07 16:52:27 +02:00
|
|
|
$dialog.find('#start-datetime').datetimepicker('setDate', startDatetime);
|
2013-07-10 16:57:24 +03:00
|
|
|
|
|
|
|
var endDatetime = Date.parseExact(appointment['end_datetime'],
|
2015-12-11 01:04:40 +02:00
|
|
|
'yyyy-MM-dd HH:mm:ss');
|
2016-02-07 16:52:27 +02:00
|
|
|
$dialog.find('#end-datetime').datetimepicker('setDate', endDatetime);
|
2013-07-10 16:57:24 +03:00
|
|
|
|
|
|
|
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']);
|
2013-11-24 17:45:44 +02:00
|
|
|
$dialog.find('#appointment-notes').val(appointment['notes']);
|
|
|
|
$dialog.find('#customer-notes').val(customer['notes']);
|
2013-07-10 16:57:24 +03:00
|
|
|
} else {
|
2016-04-02 13:25:29 +03:00
|
|
|
var unavailable = lastFocusedEventData.data;
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-07-10 16:57:24 +03:00
|
|
|
// Replace string date values with actual date objects.
|
2016-04-02 13:25:29 +03:00
|
|
|
unavailable.start_datetime = GeneralFunctions.clone(lastFocusedEventData.start);
|
|
|
|
unavailable.end_datetime = GeneralFunctions.clone(lastFocusedEventData.end);
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-07-10 16:57:24 +03:00
|
|
|
$dialog = $('#manage-unavailable');
|
2016-04-02 13:25:29 +03:00
|
|
|
_resetUnavailableDialog();
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2016-05-15 14:05:28 +03:00
|
|
|
// Apply unvailable data to dialog.
|
2013-07-10 16:57:24 +03:00
|
|
|
$dialog.find('.modal-header h3').text('Edit Unavailable Period');
|
2016-02-07 16:52:27 +02:00
|
|
|
$dialog.find('#unavailable-start').datetimepicker('setDate', unavailable.start_datetime);
|
2013-07-10 16:57:24 +03:00
|
|
|
$dialog.find('#unavailable-id').val(unavailable.id);
|
2016-02-07 16:52:27 +02:00
|
|
|
$dialog.find('#unavailable-end').datetimepicker('setDate', unavailable.end_datetime);
|
2013-07-10 16:57:24 +03:00
|
|
|
$dialog.find('#unavailable-notes').val(unavailable.notes);
|
|
|
|
}
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-07-15 10:32:19 +03:00
|
|
|
// :: DISPLAY EDIT DIALOG
|
2013-07-06 03:00:04 +03:00
|
|
|
$dialog.modal('show');
|
2013-06-13 19:25:34 +03:00
|
|
|
});
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-06-19 22:29:00 +03:00
|
|
|
/**
|
2013-06-28 17:23:17 +03:00
|
|
|
* Event: Popover Delete Button "Click"
|
2015-10-06 00:30:56 +03:00
|
|
|
*
|
2016-05-15 14:05:28 +03:00
|
|
|
* Displays a prompt on whether the user wants the appoinmtent to be deleted. If he confirms the
|
|
|
|
* deletion then an ajax call is made to the server and deletes the appointment from the database.
|
2013-06-19 22:29:00 +03:00
|
|
|
*/
|
2016-07-17 14:46:38 +03:00
|
|
|
$calendarPage.on('click', '.delete-popover', function() {
|
2013-06-19 22:29:00 +03:00
|
|
|
$(this).parents().eq(2).remove(); // Hide the popover
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2016-04-02 13:25:29 +03:00
|
|
|
if (lastFocusedEventData.data.is_unavailable == false) {
|
2013-12-19 18:28:19 +02:00
|
|
|
var messageButtons = {};
|
|
|
|
messageButtons['OK'] = function() {
|
2015-05-20 23:26:11 +03:00
|
|
|
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_appointment';
|
2013-12-19 18:28:19 +02:00
|
|
|
|
2015-10-06 00:30:56 +03:00
|
|
|
var postData = {
|
2015-05-28 00:42:40 +03:00
|
|
|
'csrfToken': GlobalVariables.csrfToken,
|
2016-04-02 13:25:29 +03:00
|
|
|
'appointment_id' : lastFocusedEventData.data['id'],
|
2013-12-19 18:28:19 +02:00
|
|
|
'delete_reason': $('#delete-reason').val()
|
|
|
|
};
|
|
|
|
|
|
|
|
$.post(postUrl, postData, function(response) {
|
2013-06-24 09:04:30 +03:00
|
|
|
$('#message_box').dialog('close');
|
2013-12-19 18:28:19 +02:00
|
|
|
|
|
|
|
if (response.exceptions) {
|
|
|
|
response.exceptions = GeneralFunctions.parseExceptions(response.exceptions);
|
2016-05-15 14:05:28 +03:00
|
|
|
GeneralFunctions.displayMessageBox(GeneralFunctions.EXCEPTIONS_TITLE,
|
|
|
|
GeneralFunctions.EXCEPTIONS_MESSAGE);
|
2013-12-19 18:28:19 +02:00
|
|
|
$('#message_box').append(GeneralFunctions.exceptionsToHtml(response.exceptions));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (response.warnings) {
|
|
|
|
response.warnings = GeneralFunctions.parseExceptions(response.warnings);
|
2016-05-15 14:05:28 +03:00
|
|
|
GeneralFunctions.displayMessageBox(GeneralFunctions.WARNINGS_TITLE,
|
|
|
|
GeneralFunctions.WARNINGS_MESSAGE);
|
2013-12-19 18:28:19 +02:00
|
|
|
$('#message_box').append(GeneralFunctions.exceptionsToHtml(response.warnings));
|
|
|
|
}
|
|
|
|
|
2015-10-06 00:30:56 +03:00
|
|
|
// Refresh calendar event items.
|
2013-12-19 18:28:19 +02:00
|
|
|
$('#select-filter-item').trigger('change');
|
2015-10-09 00:12:59 +03:00
|
|
|
}, 'json').fail(GeneralFunctions.ajaxFailureHandler);
|
2013-07-10 16:57:24 +03:00
|
|
|
};
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-12-20 19:44:44 +02:00
|
|
|
messageButtons[EALang['cancel']] = function() {
|
2013-12-19 18:28:19 +02:00
|
|
|
$('#message_box').dialog('close');
|
|
|
|
};
|
2013-07-10 16:57:24 +03:00
|
|
|
|
2015-10-06 00:30:56 +03:00
|
|
|
GeneralFunctions.displayMessageBox(EALang['delete_appointment_title'],
|
2013-12-20 19:44:44 +02:00
|
|
|
EALang['write_appointment_removal_reason'], messageButtons);
|
2016-05-15 14:05:28 +03:00
|
|
|
|
2013-10-18 17:56:12 +03:00
|
|
|
$('#message_box').append('<textarea id="delete-reason" rows="3"></textarea>');
|
2015-10-06 00:30:56 +03:00
|
|
|
$('#delete-reason').css('width', '100%');
|
2013-07-10 16:57:24 +03:00
|
|
|
} else {
|
|
|
|
// Do not display confirmation promt.
|
2016-07-15 21:52:21 +03:00
|
|
|
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_delete_unavailable';
|
|
|
|
var postData = {
|
|
|
|
csrfToken: GlobalVariables.csrfToken,
|
|
|
|
unavailable_id : lastFocusedEventData.data.id
|
|
|
|
};
|
2013-07-10 16:57:24 +03:00
|
|
|
|
|
|
|
$.post(postUrl, postData, function(response) {
|
2013-06-19 22:29:00 +03:00
|
|
|
$('#message_box').dialog('close');
|
2013-07-10 16:57:24 +03:00
|
|
|
|
|
|
|
if (response.exceptions) {
|
|
|
|
response.exceptions = GeneralFunctions.parseExceptions(response.exceptions);
|
2013-09-27 15:49:29 +03:00
|
|
|
GeneralFunctions.displayMessageBox(GeneralFunctions.EXCEPTIONS_TITLE, GeneralFunctions.EXCEPTIONS_MESSAGE);
|
2013-07-10 16:57:24 +03:00
|
|
|
$('#message_box').append(GeneralFunctions.exceptionsToHtml(response.exceptions));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (response.warnings) {
|
|
|
|
response.warnings = GeneralFunctions.parseExceptions(response.warnings);
|
2013-10-27 19:41:37 +02:00
|
|
|
GeneralFunctions.displayMessageBox(GeneralFunctions.WARNINGS_TITLE, GeneralFunctions.WARNINGS_MESSAGE);
|
2013-07-10 16:57:24 +03:00
|
|
|
$('#message_box').append(GeneralFunctions.exceptionsToHtml(response.warnings));
|
|
|
|
}
|
|
|
|
|
2015-10-06 00:30:56 +03:00
|
|
|
// Refresh calendar event items.
|
2013-07-10 16:57:24 +03:00
|
|
|
$('#select-filter-item').trigger('change');
|
2015-10-09 00:12:59 +03:00
|
|
|
}, 'json').fail(GeneralFunctions.ajaxFailureHandler);
|
2013-07-10 16:57:24 +03:00
|
|
|
}
|
2013-06-19 22:29:00 +03:00
|
|
|
});
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-06-13 19:25:34 +03:00
|
|
|
/**
|
2013-06-18 19:06:34 +03:00
|
|
|
* Event: Manage Appointments Dialog Cancel Button "Click"
|
2015-10-06 00:30:56 +03:00
|
|
|
*
|
2013-06-29 00:54:12 +03:00
|
|
|
* Closes the dialog without saving any changes to the database.
|
2013-06-13 19:25:34 +03:00
|
|
|
*/
|
2013-07-09 17:46:48 +03:00
|
|
|
$('#manage-appointment #cancel-appointment').click(function() {
|
2013-06-13 19:25:34 +03:00
|
|
|
$('#manage-appointment').modal('hide');
|
|
|
|
});
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-06-13 19:25:34 +03:00
|
|
|
/**
|
2013-06-18 19:06:34 +03:00
|
|
|
* Event: Manage Appointments Dialog Save Button "Click"
|
2015-10-06 00:30:56 +03:00
|
|
|
*
|
2016-05-15 14:05:28 +03:00
|
|
|
* Stores the appointment changes or inserts a new appointment depending the dialog mode.
|
2013-06-13 19:25:34 +03:00
|
|
|
*/
|
2013-07-09 17:46:48 +03:00
|
|
|
$('#manage-appointment #save-appointment').click(function() {
|
2013-06-29 00:54:12 +03:00
|
|
|
// Before doing anything the appointment data need to be validated.
|
2016-04-02 13:25:29 +03:00
|
|
|
if (!_validateAppointmentForm()) {
|
2016-05-15 14:05:28 +03:00
|
|
|
return;
|
2013-06-29 00:54:12 +03:00
|
|
|
}
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2016-05-15 14:05:28 +03:00
|
|
|
// Prepare appointment data for AJAX request.
|
2013-07-06 03:00:04 +03:00
|
|
|
var $dialog = $('#manage-appointment');
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2016-05-15 14:05:28 +03:00
|
|
|
// ID must exist on the object in order for the model to update the record and not to perform
|
|
|
|
// an insert operation.
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2016-01-11 00:54:17 +02:00
|
|
|
var startDatetime = $dialog.find('#start-datetime')
|
2016-07-15 21:52:21 +03:00
|
|
|
.datepicker('getDate').toString('yyyy-MM-dd HH:mm:ss');
|
|
|
|
var endDatetime = $dialog.find('#end-datetime')
|
2016-01-11 00:54:17 +02:00
|
|
|
.datepicker('getDate').toString('yyyy-MM-dd HH:mm:ss');
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-07-06 03:00:04 +03:00
|
|
|
var appointment = {
|
2016-05-15 14:05:28 +03:00
|
|
|
id_services: $dialog.find('#select-service').val(),
|
|
|
|
id_users_provider: $dialog.find('#select-provider').val(),
|
|
|
|
start_datetime: startDatetime,
|
|
|
|
end_datetime: endDatetime,
|
|
|
|
notes: $dialog.find('#appointment-notes').val(),
|
|
|
|
is_unavailable: false
|
2013-06-18 19:06:34 +03:00
|
|
|
};
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-07-06 03:00:04 +03:00
|
|
|
if ($dialog.find('#appointment-id').val() !== '') {
|
2013-06-29 00:54:12 +03:00
|
|
|
// Set the id value, only if we are editing an appointment.
|
2013-07-06 03:00:04 +03:00
|
|
|
appointment['id'] = $dialog.find('#appointment-id').val();
|
2013-06-29 00:54:12 +03:00
|
|
|
}
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-07-06 03:00:04 +03:00
|
|
|
var customer = {
|
2016-05-15 14:05:28 +03:00
|
|
|
first_name: $dialog.find('#first-name').val(),
|
|
|
|
last_name: $dialog.find('#last-name').val(),
|
|
|
|
email: $dialog.find('#email').val(),
|
|
|
|
phone_number: $dialog.find('#phone-number').val(),
|
|
|
|
address: $dialog.find('#address').val(),
|
|
|
|
city: $dialog.find('#city').val(),
|
|
|
|
zip_code: $dialog.find('#zip-code').val(),
|
|
|
|
notes: $dialog.find('#customer-notes').val()
|
2013-06-18 19:06:34 +03:00
|
|
|
};
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-07-06 03:00:04 +03:00
|
|
|
if ($dialog.find('#customer-id').val() !== '') {
|
2013-06-29 00:54:12 +03:00
|
|
|
// Set the id value, only if we are editing an appointment.
|
2013-07-06 03:00:04 +03:00
|
|
|
customer['id'] = $dialog.find('#customer-id').val();
|
|
|
|
appointment['id_users_customer'] = customer['id'];
|
2013-06-29 00:54:12 +03:00
|
|
|
}
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2016-05-15 14:05:28 +03:00
|
|
|
// Define success callback.
|
2015-10-06 00:30:56 +03:00
|
|
|
var successCallback = function(response) {
|
2013-12-05 23:53:27 +02:00
|
|
|
if (!GeneralFunctions.handleAjaxExceptions(response)) {
|
2013-12-20 19:44:44 +02:00
|
|
|
$dialog.find('.modal-message').text(EALang['unexpected_issues_occurred']);
|
2016-01-24 16:40:06 +02:00
|
|
|
$dialog.find('.modal-message').addClass('alert-danger').removeClass('hidden');
|
2014-01-11 02:07:25 +02:00
|
|
|
return false;
|
2013-06-18 19:06:34 +03:00
|
|
|
}
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-06-18 19:06:34 +03:00
|
|
|
// Display success message to the user.
|
2013-12-20 19:44:44 +02:00
|
|
|
$dialog.find('.modal-message').text(EALang['appointment_saved']);
|
2016-01-24 16:40:06 +02:00
|
|
|
$dialog.find('.modal-message').addClass('alert-success').removeClass('alert-danger hidden');
|
2013-10-27 19:41:37 +02:00
|
|
|
$dialog.find('.modal-body').scrollTop(0);
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2016-05-15 14:05:28 +03:00
|
|
|
// Close the modal dialog and refresh the calendar appointments after one second.
|
2013-06-18 19:06:34 +03:00
|
|
|
setTimeout(function() {
|
2016-01-24 16:40:06 +02:00
|
|
|
$dialog.find('.alert').addClass('hidden');
|
2013-07-06 03:00:04 +03:00
|
|
|
$dialog.modal('hide');
|
2013-06-18 19:06:34 +03:00
|
|
|
$('#select-filter-item').trigger('change');
|
|
|
|
}, 2000);
|
|
|
|
};
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2016-05-15 14:05:28 +03:00
|
|
|
// Define error callback.
|
2013-06-18 19:06:34 +03:00
|
|
|
var errorCallback = function() {
|
2013-12-20 19:44:44 +02:00
|
|
|
$dialog.find('.modal-message').text(EALang['server_communication_error']);
|
2016-01-24 16:40:06 +02:00
|
|
|
$dialog.find('.modal-message').addClass('alert-danger').removeClass('hidden');
|
2013-10-27 19:41:37 +02:00
|
|
|
$dialog.find('.modal-body').scrollTop(0);
|
2013-06-18 19:06:34 +03:00
|
|
|
};
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2016-05-15 14:05:28 +03:00
|
|
|
// Save appointment data.
|
2016-04-02 13:25:29 +03:00
|
|
|
_saveAppointment(appointment, customer, successCallback, errorCallback);
|
2015-10-06 00:30:56 +03:00
|
|
|
});
|
|
|
|
|
2013-07-10 16:57:24 +03:00
|
|
|
/**
|
|
|
|
* Event: Manage Unavailable Dialog Save Button "Click"
|
2015-10-06 00:30:56 +03:00
|
|
|
*
|
2013-07-10 16:57:24 +03:00
|
|
|
* Stores the unavailable period changes or inserts a new record.
|
|
|
|
*/
|
2013-07-09 17:46:48 +03:00
|
|
|
$('#manage-unavailable #save-unavailable').click(function() {
|
2016-07-15 21:52:21 +03:00
|
|
|
var $dialog = $('#manage-unavailable');
|
|
|
|
var start = $dialog.find('#unavailable-start').datetimepicker('getDate');
|
|
|
|
var end = $dialog.find('#unavailable-end').datetimepicker('getDate');
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-07-09 17:46:48 +03:00
|
|
|
if (start > end) {
|
|
|
|
// Start time is after end time - display message to user.
|
2016-01-24 16:40:06 +02:00
|
|
|
$dialog.find('.modal-message')
|
|
|
|
.text(EALang['start_date_before_end_error'])
|
|
|
|
.addClass('alert-danger')
|
|
|
|
.removeClass('hidden');
|
2013-07-09 17:46:48 +03:00
|
|
|
return;
|
|
|
|
}
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-07-09 17:46:48 +03:00
|
|
|
// Unavailable period records go to the appointments table.
|
|
|
|
var unavailable = {
|
2016-05-15 14:05:28 +03:00
|
|
|
start_datetime: start.toString('yyyy-MM-dd HH:mm'),
|
|
|
|
end_datetime: end.toString('yyyy-MM-dd HH:mm'),
|
|
|
|
notes: $dialog.find('#unavailable-notes').val(),
|
|
|
|
id_users_provider: $('#select-filter-item').val() // curr provider
|
2013-07-09 17:46:48 +03:00
|
|
|
};
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-07-10 16:57:24 +03:00
|
|
|
if ($dialog.find('#unavailable-id').val() !== '') {
|
|
|
|
// Set the id value, only if we are editing an appointment.
|
|
|
|
unavailable.id = $dialog.find('#unavailable-id').val();
|
|
|
|
}
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-07-09 17:46:48 +03:00
|
|
|
var successCallback = function(response) {
|
|
|
|
if (response.exceptions) {
|
|
|
|
response.exceptions = GeneralFunctions.parseExceptions(response.exceptions);
|
2016-05-15 14:05:28 +03:00
|
|
|
GeneralFunctions.displayMessageBox(GeneralFunctions.EXCEPTIONS_TITLE,
|
|
|
|
GeneralFunctions.EXCEPTIONS_MESSAGE);
|
2013-07-09 17:46:48 +03:00
|
|
|
$('#message_box').append(GeneralFunctions.exceptionsToHtml(response.exceptions));
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2016-01-24 16:40:06 +02:00
|
|
|
$dialog.find('.modal-message')
|
|
|
|
.text(EALang['unexpected_issues_occurred'])
|
|
|
|
.addClass('alert-danger')
|
|
|
|
.removeClass('hidden');
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-07-09 17:46:48 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (response.warnings) {
|
|
|
|
response.warnings = GeneralFunctions.parseExceptions(response.warnings);
|
2016-05-15 14:05:28 +03:00
|
|
|
GeneralFunctions.displayMessageBox(GeneralFunctions.WARNINGS_TITLE,
|
|
|
|
GeneralFunctions.WARNINGS_MESSAGE);
|
2013-07-09 17:46:48 +03:00
|
|
|
$('#message_box').append(GeneralFunctions.exceptionsToHtml(response.warnings));
|
|
|
|
}
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-07-10 16:57:24 +03:00
|
|
|
// Display success message to the user.
|
2016-01-24 16:40:06 +02:00
|
|
|
$dialog.find('.modal-message')
|
|
|
|
.text(EALang['unavailable_saved'])
|
|
|
|
.addClass('alert-success')
|
|
|
|
.removeClass('alert-danger hidden');
|
|
|
|
|
2016-05-15 14:05:28 +03:00
|
|
|
// Close the modal dialog and refresh the calendar appointments after one second.
|
2013-07-10 16:57:24 +03:00
|
|
|
setTimeout(function() {
|
2016-01-24 16:40:06 +02:00
|
|
|
$dialog.find('.alert').addClass('hidden');
|
2013-07-10 16:57:24 +03:00
|
|
|
$dialog.modal('hide');
|
|
|
|
$('#select-filter-item').trigger('change');
|
|
|
|
}, 2000);
|
2013-07-09 17:46:48 +03:00
|
|
|
};
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-07-09 17:46:48 +03:00
|
|
|
var errorCallback = function(jqXHR, textStatus, errorThrown) {
|
|
|
|
GeneralFunctions.displayMessageBox('Communication Error', 'Unfortunately ' +
|
|
|
|
'the operation could not complete due to server communication errors.');
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-12-20 19:44:44 +02:00
|
|
|
$dialog.find('.modal-message').txt(EALang['service_communication_error']);
|
2016-01-24 16:40:06 +02:00
|
|
|
$dialog.find('.modal-message').addClass('alert-danger').removeClass('hidden');
|
2013-07-09 17:46:48 +03:00
|
|
|
};
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2016-04-02 13:25:29 +03:00
|
|
|
_saveUnavailable(unavailable, successCallback, errorCallback);
|
2013-07-09 17:46:48 +03:00
|
|
|
});
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-07-10 16:57:24 +03:00
|
|
|
/**
|
|
|
|
* Event: Manage Unavailable Dialog Cancel Button "Click"
|
2015-10-06 00:30:56 +03:00
|
|
|
*
|
2013-07-10 16:57:24 +03:00
|
|
|
* Closes the dialog without saveing any changes to the database.
|
|
|
|
*/
|
2013-07-09 17:46:48 +03:00
|
|
|
$('#manage-unavailable #cancel-unavailable').click(function() {
|
|
|
|
$('#manage-unavailable').modal('hide');
|
|
|
|
});
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2016-07-17 15:23:18 +03:00
|
|
|
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-06-29 00:54:12 +03:00
|
|
|
/**
|
2013-07-03 20:27:00 +03:00
|
|
|
* Event: Insert Appointment Button "Click"
|
2015-10-06 00:30:56 +03:00
|
|
|
*
|
2016-05-15 14:05:28 +03:00
|
|
|
* When the user presses this button, the manage appointment dialog opens and lets the user to
|
|
|
|
* create a new appointment.
|
2013-06-29 00:54:12 +03:00
|
|
|
*/
|
|
|
|
$('#insert-appointment').click(function() {
|
2016-04-02 13:25:29 +03:00
|
|
|
_resetAppointmentDialog();
|
2013-07-06 03:00:04 +03:00
|
|
|
var $dialog = $('#manage-appointment');
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2016-05-15 14:05:28 +03:00
|
|
|
// Set the selected filter item and find the next appointment time as the default modal values.
|
2013-11-22 18:19:52 +02:00
|
|
|
if ($('#select-filter-item option:selected').attr('type') == 'provider') {
|
2015-10-06 00:30:56 +03:00
|
|
|
var $providerOption = $dialog.find('#select-provider option[value="'
|
2013-11-22 18:19:52 +02:00
|
|
|
+ $('#select-filter-item').val() + '"]');
|
2016-05-15 14:05:28 +03:00
|
|
|
if ($providerOption.length === 0) { // Change the services until you find the correct.
|
2013-11-22 18:19:52 +02:00
|
|
|
$.each($dialog.find('#select-service option'), function() {
|
|
|
|
$(this).prop('selected', true).parent().change();
|
2015-10-06 00:30:56 +03:00
|
|
|
if ($providerOption.length > 0)
|
2013-11-22 18:19:52 +02:00
|
|
|
return false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
$providerOption.prop('selected', true);
|
|
|
|
} else {
|
2015-10-06 00:30:56 +03:00
|
|
|
$dialog.find('#select-service option[value="'
|
2013-11-22 18:19:52 +02:00
|
|
|
+ $('#select-filter-item').val() + '"]').prop('selected', true);
|
2015-10-06 00:30:56 +03:00
|
|
|
}
|
|
|
|
|
2013-11-22 18:19:52 +02:00
|
|
|
var serviceDuration = 0;
|
|
|
|
$.each(GlobalVariables.availableServices, function(index, service) {
|
|
|
|
if (service['id'] == $dialog.find('#select-service').val()) {
|
|
|
|
serviceDuration = service['duration'];
|
|
|
|
return false; // exit loop
|
|
|
|
}
|
|
|
|
});
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2016-07-15 21:52:21 +03:00
|
|
|
var start = new Date();
|
|
|
|
var currentMin = parseInt(start.toString('mm'));
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2016-05-15 14:05:28 +03:00
|
|
|
if (currentMin > 0 && currentMin < 15) {
|
2013-11-22 18:19:52 +02:00
|
|
|
start.set({ 'minute': 15 });
|
2016-05-15 14:05:28 +03:00
|
|
|
} else if (currentMin > 15 && currentMin < 30) {
|
2013-11-22 18:19:52 +02:00
|
|
|
start.set({ 'minute': 30 });
|
2016-05-15 14:05:28 +03:00
|
|
|
} else if (currentMin > 30 && currentMin < 45) {
|
2013-11-22 18:19:52 +02:00
|
|
|
start.set({ 'minute': 45 });
|
2016-05-15 14:05:28 +03:00
|
|
|
} else {
|
2013-11-22 18:19:52 +02:00
|
|
|
start.addHours(1).set({ 'minute': 0 });
|
2016-05-15 14:05:28 +03:00
|
|
|
}
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2015-12-11 01:04:40 +02:00
|
|
|
$dialog.find('#start-datetime').val(GeneralFunctions.formatDate(start, GlobalVariables.dateFormat, true));
|
2015-12-13 23:00:20 +02:00
|
|
|
$dialog.find('#end-datetime').val(GeneralFunctions.formatDate(start.addMinutes(serviceDuration),
|
2015-12-11 01:04:40 +02:00
|
|
|
GlobalVariables.dateFormat, true));
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-11-22 18:19:52 +02:00
|
|
|
// Display modal form.
|
2013-12-20 19:44:44 +02:00
|
|
|
$dialog.find('.modal-header h3').text(EALang['new_appointment_title']);
|
2013-07-06 03:00:04 +03:00
|
|
|
$dialog.modal('show');
|
2013-06-29 00:54:12 +03:00
|
|
|
});
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-06-29 00:54:12 +03:00
|
|
|
/**
|
|
|
|
* Event : Insert Unavailable Time Period Button "Click"
|
2015-10-06 00:30:56 +03:00
|
|
|
*
|
2016-05-15 14:05:28 +03:00
|
|
|
* When the user clicks this button a popup dialog appears and the use can set a time period where
|
|
|
|
* he cannot accept any appointments.
|
2013-06-29 00:54:12 +03:00
|
|
|
*/
|
|
|
|
$('#insert-unavailable').click(function() {
|
2016-04-02 13:25:29 +03:00
|
|
|
_resetUnavailableDialog();
|
2013-07-09 17:46:48 +03:00
|
|
|
var $dialog = $('#manage-unavailable');
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-11-23 21:10:31 +02:00
|
|
|
// Set the default datetime values.
|
2016-07-15 21:52:21 +03:00
|
|
|
var start = new Date();
|
|
|
|
var currentMin = parseInt(start.toString('mm'));
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2016-05-15 14:05:28 +03:00
|
|
|
if (currentMin > 0 && currentMin < 15) {
|
2013-11-23 21:10:31 +02:00
|
|
|
start.set({ 'minute': 15 });
|
2016-05-15 14:05:28 +03:00
|
|
|
} else if (currentMin > 15 && currentMin < 30) {
|
2013-11-23 21:10:31 +02:00
|
|
|
start.set({ 'minute': 30 });
|
2016-05-15 14:05:28 +03:00
|
|
|
} else if (currentMin > 30 && currentMin < 45) {
|
2013-11-23 21:10:31 +02:00
|
|
|
start.set({ 'minute': 45 });
|
2016-05-15 14:05:28 +03:00
|
|
|
} else {
|
2013-11-23 21:10:31 +02:00
|
|
|
start.addHours(1).set({ 'minute': 0 });
|
2016-05-15 14:05:28 +03:00
|
|
|
}
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2015-12-13 23:00:20 +02:00
|
|
|
$dialog.find('#unavailable-start').val(GeneralFunctions.formatDate(start, GlobalVariables.dateFormat, true));
|
|
|
|
$dialog.find('#unavailable-end').val(GeneralFunctions.formatDate(start.addHours(1), GlobalVariables.dateFormat, true));
|
2013-12-20 19:44:44 +02:00
|
|
|
$dialog.find('.modal-header h3').text(EALang['new_unavailable_title']);
|
2013-07-09 17:46:48 +03:00
|
|
|
$dialog.modal('show');
|
2013-06-29 00:54:12 +03:00
|
|
|
});
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-09-26 19:06:57 +03:00
|
|
|
/**
|
|
|
|
* Event: Pick Existing Customer Button "Click"
|
|
|
|
*/
|
|
|
|
$('#select-customer').click(function() {
|
|
|
|
var $list = $('#existing-customers-list');
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-09-26 19:06:57 +03:00
|
|
|
if (!$list.is(':visible')) {
|
2013-12-20 19:44:44 +02:00
|
|
|
$(this).text(EALang['hide']);
|
2013-09-26 19:06:57 +03:00
|
|
|
$list.empty();
|
|
|
|
$list.slideDown('slow');
|
|
|
|
$('#filter-existing-customers').fadeIn('slow');
|
|
|
|
$('#filter-existing-customers').val('');
|
|
|
|
$.each(GlobalVariables.customers, function(index, c) {
|
2015-10-06 00:30:56 +03:00
|
|
|
$list.append('<div data-id="' + c.id + '">'
|
2013-09-26 19:06:57 +03:00
|
|
|
+ c.first_name + ' ' + c.last_name + '</div>');
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
$list.slideUp('slow');
|
|
|
|
$('#filter-existing-customers').fadeOut('slow');
|
2013-12-20 19:44:44 +02:00
|
|
|
$(this).text(EALang['select']);
|
2013-09-26 19:06:57 +03:00
|
|
|
}
|
|
|
|
});
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-09-26 19:06:57 +03:00
|
|
|
/**
|
|
|
|
* Event: Select Existing Customer From List "Click"
|
|
|
|
*/
|
2016-07-17 14:46:38 +03:00
|
|
|
$calendarPage.on('click', '#existing-customers-list div', function() {
|
2013-09-26 19:06:57 +03:00
|
|
|
var id = $(this).attr('data-id');
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-09-26 19:06:57 +03:00
|
|
|
$.each(GlobalVariables.customers, function(index, c) {
|
|
|
|
if (c.id == id) {
|
|
|
|
$('#customer-id').val(c.id);
|
|
|
|
$('#first-name').val(c.first_name);
|
|
|
|
$('#last-name').val(c.last_name);
|
|
|
|
$('#email').val(c.email);
|
|
|
|
$('#phone-number').val(c.phone_number);
|
|
|
|
$('#address').val(c.address);
|
|
|
|
$('#city').val(c.city);
|
|
|
|
$('#zip-code').val(c.zip_code);
|
2014-01-11 02:07:25 +02:00
|
|
|
$('#customer-notes').val(c.notes);
|
2013-09-26 19:06:57 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-09-26 19:06:57 +03:00
|
|
|
$('#select-customer').trigger('click'); // hide list
|
|
|
|
});
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-09-26 19:06:57 +03:00
|
|
|
/**
|
|
|
|
* Event: Filter Existing Customers "Change"
|
|
|
|
*/
|
|
|
|
$('#filter-existing-customers').keyup(function() {
|
2016-07-15 21:52:21 +03:00
|
|
|
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
|
|
|
|
};
|
2016-03-10 20:45:17 +02:00
|
|
|
|
2016-03-22 23:45:02 +02:00
|
|
|
// Try to get the updated customer list.
|
2016-03-10 20:45:17 +02:00
|
|
|
$.ajax({
|
2016-03-22 23:45:02 +02:00
|
|
|
type: 'POST',
|
|
|
|
url: postUrl,
|
|
|
|
data: postData,
|
|
|
|
dataType: 'json',
|
|
|
|
timeout: 1000,
|
|
|
|
global: false,
|
|
|
|
success: function(response) {
|
2016-03-10 20:45:17 +02:00
|
|
|
$list.empty();
|
|
|
|
$.each(response, function(index, c) {
|
|
|
|
$list.append('<div data-id="' + c.id + '">'
|
2016-03-22 23:45:02 +02:00
|
|
|
+ c.first_name + ' ' + c.last_name + '</div>');
|
2016-03-10 20:45:17 +02:00
|
|
|
|
2016-03-22 23:45:02 +02:00
|
|
|
// Verify if this customer is on the old customer list.
|
|
|
|
var result = $.grep(GlobalVariables.customers,
|
|
|
|
function(e){ return e.id == c.id; });
|
2016-03-10 20:45:17 +02:00
|
|
|
|
2016-03-22 23:45:02 +02:00
|
|
|
// Add it to the customer list.
|
2016-03-10 20:45:17 +02:00
|
|
|
if(result.length == 0){
|
|
|
|
GlobalVariables.customers.push(c);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2016-03-22 23:45:02 +02:00
|
|
|
error: function(jqXHR, textStatus, errorThrown) {
|
|
|
|
// If there is any error on the request, search by the local client database.
|
2016-03-10 20:45:17 +02:00
|
|
|
$list.empty();
|
|
|
|
$.each(GlobalVariables.customers, function(index, c) {
|
|
|
|
if (c.first_name.toLowerCase().indexOf(key) != -1
|
|
|
|
|| c.last_name.toLowerCase().indexOf(key) != -1
|
|
|
|
|| c.email.toLowerCase().indexOf(key) != -1
|
|
|
|
|| c.phone_number.toLowerCase().indexOf(key) != -1
|
|
|
|
|| c.address.toLowerCase().indexOf(key) != -1
|
|
|
|
|| c.city.toLowerCase().indexOf(key) != -1
|
|
|
|
|| c.zip_code.toLowerCase().indexOf(key) != -1
|
|
|
|
|| c.notes.toLowerCase().indexOf(key) != -1) {
|
|
|
|
$list.append('<div data-id="' + c.id + '">'
|
|
|
|
+ c.first_name + ' ' + c.last_name + '</div>');
|
|
|
|
}
|
|
|
|
});
|
2013-09-26 19:06:57 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-09-26 19:06:57 +03:00
|
|
|
/**
|
|
|
|
* Event: Selected Service "Change"
|
2015-10-06 00:30:56 +03:00
|
|
|
*
|
2016-05-15 14:05:28 +03:00
|
|
|
* When the user clicks on a service, its available providers should become visible. Also we need to
|
|
|
|
* update the start and end time of the appointment.
|
2013-09-26 19:06:57 +03:00
|
|
|
*/
|
|
|
|
$('#select-service').change(function() {
|
|
|
|
var sid = $('#select-service').val();
|
|
|
|
$('#select-provider').empty();
|
|
|
|
|
2015-10-27 01:48:06 +03:00
|
|
|
// Automatically update the service duration.
|
|
|
|
$.each(GlobalVariables.availableServices, function(indexService, service) {
|
|
|
|
if (service.id == sid) {
|
|
|
|
var start = $('#start-datetime').datepicker('getDate');
|
|
|
|
$('#end-datetime').datepicker('setDate', new Date(start.getTime() + service.duration * 60000));
|
|
|
|
return false; // break loop
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Update the providers select box.
|
2013-09-26 19:06:57 +03:00
|
|
|
$.each(GlobalVariables.availableProviders, function(indexProvider, provider) {
|
|
|
|
$.each(provider.services, function(indexService, serviceId) {
|
2016-05-15 14:05:28 +03:00
|
|
|
// If the current provider is able to provide the selected service, add him to the listbox.
|
2015-10-06 00:30:56 +03:00
|
|
|
if (serviceId == sid) {
|
|
|
|
var optionHtml = '<option value="' + provider['id'] + '">'
|
|
|
|
+ provider['first_name'] + ' ' + provider['last_name']
|
2013-09-26 19:06:57 +03:00
|
|
|
+ '</option>';
|
|
|
|
$('#select-provider').append(optionHtml);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-09-27 15:49:29 +03:00
|
|
|
/**
|
|
|
|
* Event: Enter New Customer Button "Click"
|
|
|
|
*/
|
|
|
|
$('#new-customer').click(function() {
|
|
|
|
$('#manage-appointment').find('#customer-id, #first-name, #last-name, #email, '
|
2013-11-24 17:45:44 +02:00
|
|
|
+ '#phone-number, #address, #city, #zip-code, #customer-notes').val('');
|
2013-09-27 15:49:29 +03:00
|
|
|
});
|
2016-04-02 13:25:29 +03:00
|
|
|
}
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-06-13 19:25:34 +03:00
|
|
|
/**
|
2016-05-15 14:05:28 +03:00
|
|
|
* Save Appointment
|
|
|
|
*
|
|
|
|
* This method stores the changes of an already registered appointment into the database, via an ajax call.
|
2015-10-06 00:30:56 +03:00
|
|
|
*
|
2016-05-15 14:05:28 +03:00
|
|
|
* @param {Object} appointment Contain the new appointment data. The ID of the appointment MUST be
|
|
|
|
* already included. The rest values must follow the database structure.
|
|
|
|
* @param {Object} customer Optional, contains the customer data.
|
|
|
|
* @param {Function} successCallback Optional, if defined, this function is going to be executed on post success.
|
|
|
|
* @param {Function} errorCallback Optional, if defined, this function is going to be executed on post failure.
|
2013-06-13 19:25:34 +03:00
|
|
|
*/
|
2016-04-02 13:25:29 +03:00
|
|
|
function _saveAppointment(appointment, customer, successCallback, errorCallback) {
|
2016-07-15 21:52:21 +03:00
|
|
|
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_appointment';
|
|
|
|
var postData = {
|
|
|
|
csrfToken: GlobalVariables.csrfToken,
|
|
|
|
appointment_data: JSON.stringify(appointment)
|
|
|
|
};
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-07-06 03:00:04 +03:00
|
|
|
if (customer !== undefined) {
|
|
|
|
postData['customer_data'] = JSON.stringify(customer);
|
2013-06-18 19:06:34 +03:00
|
|
|
}
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-06-18 19:06:34 +03:00
|
|
|
$.ajax({
|
2016-04-02 13:25:29 +03:00
|
|
|
url: postUrl,
|
|
|
|
type: 'POST',
|
|
|
|
data: postData,
|
|
|
|
dataType: 'json'
|
|
|
|
})
|
|
|
|
.done(function(response) {
|
2013-06-18 19:06:34 +03:00
|
|
|
if (successCallback !== undefined) {
|
|
|
|
successCallback(response);
|
|
|
|
}
|
2016-04-02 13:25:29 +03:00
|
|
|
})
|
|
|
|
.fail(function(jqXHR, textStatus, errorThrown) {
|
2013-06-18 19:06:34 +03:00
|
|
|
if (errorCallback !== undefined) {
|
|
|
|
errorCallback();
|
|
|
|
}
|
2016-04-02 13:25:29 +03:00
|
|
|
});
|
|
|
|
}
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-07-09 17:46:48 +03:00
|
|
|
/**
|
2015-10-06 00:30:56 +03:00
|
|
|
* Save unavailable period to database.
|
|
|
|
*
|
2016-05-15 14:05:28 +03:00
|
|
|
* @param {Object} unavailable Containts the unavailable period data.
|
|
|
|
* @param {Function} successCallback The ajax success callback function.
|
|
|
|
* @param {Function} errorCallback The ajax failure callback function.
|
2013-07-09 17:46:48 +03:00
|
|
|
*/
|
2016-04-02 13:25:29 +03:00
|
|
|
function _saveUnavailable(unavailable, successCallback, errorCallback) {
|
2016-07-15 21:52:21 +03:00
|
|
|
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_save_unavailable';
|
|
|
|
var postData = {
|
|
|
|
csrfToken: GlobalVariables.csrfToken,
|
|
|
|
unavailable: JSON.stringify(unavailable)
|
|
|
|
};
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-07-09 17:46:48 +03:00
|
|
|
$.ajax({
|
2016-05-15 14:05:28 +03:00
|
|
|
type: 'POST',
|
|
|
|
url: postUrl,
|
|
|
|
data: postData,
|
|
|
|
success: successCallback,
|
|
|
|
error: errorCallback
|
2013-07-09 17:46:48 +03:00
|
|
|
});
|
2016-07-17 14:46:38 +03:00
|
|
|
}
|
2013-06-19 22:29:00 +03:00
|
|
|
|
2013-06-29 00:54:12 +03:00
|
|
|
/**
|
2016-05-15 14:05:28 +03:00
|
|
|
* Reset Apppointment Dialog
|
|
|
|
*
|
|
|
|
* This method resets the manage appointment dialog modal to its initial state. After that you can make
|
|
|
|
* any modification might be necessary in order to bring the dialog to the desired state.
|
2013-06-29 00:54:12 +03:00
|
|
|
*/
|
2016-04-02 13:25:29 +03:00
|
|
|
function _resetAppointmentDialog() {
|
2013-07-06 03:00:04 +03:00
|
|
|
var $dialog = $('#manage-appointment');
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2016-05-15 14:05:28 +03:00
|
|
|
// Empty form fields.
|
2013-07-06 03:00:04 +03:00
|
|
|
$dialog.find('input, textarea').val('');
|
2013-09-27 15:49:29 +03:00
|
|
|
$dialog.find('.modal-message').fadeOut();
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2016-05-15 14:05:28 +03:00
|
|
|
// Prepare service and provider select boxes.
|
2013-07-06 03:00:04 +03:00
|
|
|
$dialog.find('#select-service').val(
|
|
|
|
$dialog.find('#select-service').eq(0).attr('value'));
|
2015-10-06 00:30:56 +03:00
|
|
|
|
|
|
|
// Fill the providers listbox with providers that can serve the appointment's
|
2013-06-29 00:54:12 +03:00
|
|
|
// service and then select the user's provider.
|
2013-11-23 21:10:31 +02:00
|
|
|
$dialog.find('#select-provider').empty();
|
2013-06-29 00:54:12 +03:00
|
|
|
$.each(GlobalVariables.availableProviders, function(index, provider) {
|
2015-10-06 00:30:56 +03:00
|
|
|
var canProvideService = false;
|
2013-06-29 00:54:12 +03:00
|
|
|
|
2013-07-06 03:00:04 +03:00
|
|
|
$.each(provider['services'], function(index, serviceId) {
|
|
|
|
if (serviceId == $dialog.find('#select-service').val()) {
|
2013-06-29 00:54:12 +03:00
|
|
|
canProvideService = true;
|
2013-09-25 18:43:17 +03:00
|
|
|
return false;
|
2013-06-29 00:54:12 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
if (canProvideService) { // Add the provider to the listbox.
|
2015-10-06 00:30:56 +03:00
|
|
|
var option = new Option(provider['first_name']
|
2013-06-29 00:54:12 +03:00
|
|
|
+ ' ' + provider['last_name'], provider['id']);
|
2013-07-06 03:00:04 +03:00
|
|
|
$dialog.find('#select-provider').append(option);
|
2013-06-29 00:54:12 +03:00
|
|
|
}
|
|
|
|
});
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2016-05-15 14:05:28 +03:00
|
|
|
// Close existing customers-filter frame.
|
2013-11-22 18:19:52 +02:00
|
|
|
$('#existing-customers-list').slideUp('slow');
|
|
|
|
$('#filter-existing-customers').fadeOut('slow');
|
2013-12-20 19:44:44 +02:00
|
|
|
$('#select-customer').text(EALang['select']);
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2016-05-15 14:05:28 +03:00
|
|
|
// Setup start and datetimepickers.
|
|
|
|
// Get the selected service duration. It will be needed in order to calculate the appointment end datetime.
|
2013-06-29 00:54:12 +03:00
|
|
|
var serviceDuration = 0;
|
|
|
|
$.each(GlobalVariables.availableServices, function(index, service) {
|
2013-07-06 03:00:04 +03:00
|
|
|
if (service['id'] == $dialog.find('#select-service').val()) {
|
2013-06-29 00:54:12 +03:00
|
|
|
serviceDuration = service['duration'];
|
2013-09-25 18:43:17 +03:00
|
|
|
return false;
|
2013-06-29 00:54:12 +03:00
|
|
|
}
|
|
|
|
});
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2016-07-15 21:52:21 +03:00
|
|
|
var startDatetime = new Date().addMinutes(GlobalVariables.bookAdvanceTimeout);
|
|
|
|
var endDatetime = new Date().addMinutes(GlobalVariables.bookAdvanceTimeout).addMinutes(serviceDuration);
|
|
|
|
var dateFormat;
|
2015-12-11 01:04:40 +02:00
|
|
|
|
|
|
|
switch(GlobalVariables.dateFormat) {
|
|
|
|
case 'DMY':
|
|
|
|
dateFormat = 'dd/mm/yy';
|
|
|
|
break;
|
|
|
|
case 'MDY':
|
|
|
|
dateFormat = 'mm/dd/yy';
|
|
|
|
break;
|
|
|
|
case 'YMD':
|
|
|
|
dateFormat = 'yy/mm/dd';
|
|
|
|
break;
|
2016-01-11 00:54:17 +02:00
|
|
|
default:
|
|
|
|
throw new Error('Invalid GlobalVariables.dateFormat value.');
|
2015-12-11 01:04:40 +02:00
|
|
|
}
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-07-06 03:00:04 +03:00
|
|
|
$dialog.find('#start-datetime').datetimepicker({
|
2015-12-13 23:00:20 +02:00
|
|
|
dateFormat: dateFormat,
|
|
|
|
|
2013-12-20 19:44:44 +02:00
|
|
|
// Translation
|
2015-10-06 00:30:56 +03:00
|
|
|
dayNames: [EALang['sunday'], EALang['monday'], EALang['tuesday'], EALang['wednesday'],
|
2013-12-20 19:44:44 +02:00
|
|
|
EALang['thursday'], EALang['friday'], EALang['saturday']],
|
2015-10-06 00:30:56 +03:00
|
|
|
dayNamesShort: [EALang['sunday'].substr(0,3), EALang['monday'].substr(0,3),
|
|
|
|
EALang['tuesday'].substr(0,3), EALang['wednesday'].substr(0,3),
|
2013-12-20 19:44:44 +02:00
|
|
|
EALang['thursday'].substr(0,3), EALang['friday'].substr(0,3),
|
|
|
|
EALang['saturday'].substr(0,3)],
|
2015-10-06 00:30:56 +03:00
|
|
|
dayNamesMin: [EALang['sunday'].substr(0,2), EALang['monday'].substr(0,2),
|
|
|
|
EALang['tuesday'].substr(0,2), EALang['wednesday'].substr(0,2),
|
2013-12-20 19:44:44 +02:00
|
|
|
EALang['thursday'].substr(0,2), EALang['friday'].substr(0,2),
|
|
|
|
EALang['saturday'].substr(0,2)],
|
|
|
|
monthNames: [EALang['january'], EALang['february'], EALang['march'], EALang['april'],
|
|
|
|
EALang['may'], EALang['june'], EALang['july'], EALang['august'], EALang['september'],
|
|
|
|
EALang['october'], EALang['november'], EALang['december']],
|
|
|
|
prevText: EALang['previous'],
|
|
|
|
nextText: EALang['next'],
|
|
|
|
currentText: EALang['now'],
|
|
|
|
closeText: EALang['close'],
|
|
|
|
timeOnlyTitle: EALang['select_time'],
|
|
|
|
timeText: EALang['time'],
|
|
|
|
hourText: EALang['hour'],
|
2014-01-04 19:25:21 +02:00
|
|
|
minuteText: EALang['minutes'],
|
|
|
|
firstDay: 1
|
2013-06-29 00:54:12 +03:00
|
|
|
});
|
2016-01-11 00:54:17 +02:00
|
|
|
$dialog.find('#start-datetime').datepicker('setDate', startDatetime);
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-07-06 03:00:04 +03:00
|
|
|
$dialog.find('#end-datetime').datetimepicker({
|
2016-05-15 14:05:28 +03:00
|
|
|
dateFormat: dateFormat,
|
2015-12-13 23:00:20 +02:00
|
|
|
|
2013-12-20 19:44:44 +02:00
|
|
|
// Translation
|
2015-10-06 00:30:56 +03:00
|
|
|
dayNames: [EALang['sunday'], EALang['monday'], EALang['tuesday'], EALang['wednesday'],
|
2013-12-20 19:44:44 +02:00
|
|
|
EALang['thursday'], EALang['friday'], EALang['saturday']],
|
2015-10-06 00:30:56 +03:00
|
|
|
dayNamesShort: [EALang['sunday'].substr(0,3), EALang['monday'].substr(0,3),
|
|
|
|
EALang['tuesday'].substr(0,3), EALang['wednesday'].substr(0,3),
|
2013-12-20 19:44:44 +02:00
|
|
|
EALang['thursday'].substr(0,3), EALang['friday'].substr(0,3),
|
|
|
|
EALang['saturday'].substr(0,3)],
|
2015-10-06 00:30:56 +03:00
|
|
|
dayNamesMin: [EALang['sunday'].substr(0,2), EALang['monday'].substr(0,2),
|
|
|
|
EALang['tuesday'].substr(0,2), EALang['wednesday'].substr(0,2),
|
2013-12-20 19:44:44 +02:00
|
|
|
EALang['thursday'].substr(0,2), EALang['friday'].substr(0,2),
|
|
|
|
EALang['saturday'].substr(0,2)],
|
|
|
|
monthNames: [EALang['january'], EALang['february'], EALang['march'], EALang['april'],
|
|
|
|
EALang['may'], EALang['june'], EALang['july'], EALang['august'], EALang['september'],
|
|
|
|
EALang['october'], EALang['november'], EALang['december']],
|
|
|
|
prevText: EALang['previous'],
|
|
|
|
nextText: EALang['next'],
|
|
|
|
currentText: EALang['now'],
|
|
|
|
closeText: EALang['close'],
|
|
|
|
timeOnlyTitle: EALang['select_time'],
|
|
|
|
timeText: EALang['time'],
|
|
|
|
hourText: EALang['hour'],
|
2014-01-04 19:25:21 +02:00
|
|
|
minuteText: EALang['minutes'],
|
|
|
|
firstDay: 1
|
2013-06-29 00:54:12 +03:00
|
|
|
});
|
2016-01-11 00:54:17 +02:00
|
|
|
$dialog.find('#end-datetime').datepicker('setDate', endDatetime);
|
2016-04-02 13:25:29 +03:00
|
|
|
}
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-06-29 00:54:12 +03:00
|
|
|
/**
|
|
|
|
* Validate the manage appointment dialog data. Validation checks need to
|
|
|
|
* run every time the data are going to be saved.
|
2015-10-06 00:30:56 +03:00
|
|
|
*
|
2016-05-15 14:05:28 +03:00
|
|
|
* @returns {Boolean} Returns the validation result.
|
2013-06-29 00:54:12 +03:00
|
|
|
*/
|
2016-04-02 13:25:29 +03:00
|
|
|
function _validateAppointmentForm() {
|
2013-07-06 03:00:04 +03:00
|
|
|
var $dialog = $('#manage-appointment');
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-06-29 00:54:12 +03:00
|
|
|
// Reset previous validation css formating.
|
2016-01-24 16:40:06 +02:00
|
|
|
$dialog.find('.form-group').removeClass('has-error');
|
|
|
|
$dialog.find('.modal-message').addClass('hidden');
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-06-29 00:54:12 +03:00
|
|
|
try {
|
2016-05-15 14:05:28 +03:00
|
|
|
// Check required fields.
|
2013-06-29 00:54:12 +03:00
|
|
|
var missingRequiredField = false;
|
2016-05-15 14:05:28 +03:00
|
|
|
|
2013-07-06 03:00:04 +03:00
|
|
|
$dialog.find('.required').each(function() {
|
2013-10-17 18:31:43 +03:00
|
|
|
if ($(this).val() == '' || $(this).val() == null) {
|
2016-01-24 16:40:06 +02:00
|
|
|
$(this).parents('.form-group').addClass('has-error');
|
2013-06-29 00:54:12 +03:00
|
|
|
missingRequiredField = true;
|
|
|
|
}
|
2015-10-06 00:30:56 +03:00
|
|
|
});
|
2016-05-15 14:05:28 +03:00
|
|
|
|
2013-06-29 00:54:12 +03:00
|
|
|
if (missingRequiredField) {
|
2015-10-06 00:30:56 +03:00
|
|
|
throw EALang['fields_are_required'];
|
2013-06-29 00:54:12 +03:00
|
|
|
}
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2016-05-15 14:05:28 +03:00
|
|
|
// Check email address.
|
2013-07-06 03:00:04 +03:00
|
|
|
if (!GeneralFunctions.validateEmail($dialog.find('#email').val())) {
|
2016-01-24 16:40:06 +02:00
|
|
|
$dialog.find('#email').parents('.form-group').eq(1).addClass('has-error');
|
2014-01-11 02:07:25 +02:00
|
|
|
throw EALang['invalid_email'];
|
2013-06-29 00:54:12 +03:00
|
|
|
}
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2016-05-15 14:05:28 +03:00
|
|
|
// Check appointment start and end time.
|
2016-07-15 21:52:21 +03:00
|
|
|
var start = $('#start-datetime').datepicker('getDate');
|
|
|
|
var end = $('#end-datetime').datepicker('getDate');
|
2013-11-22 18:19:52 +02:00
|
|
|
if (start > end) {
|
2016-01-24 16:40:06 +02:00
|
|
|
$dialog.find('#start-datetime').parents('.form-group').addClass('has-error');
|
|
|
|
$dialog.find('#end-datetime').parents('.form-group').addClass('has-error');
|
2014-01-11 02:07:25 +02:00
|
|
|
throw EALang['start_date_before_end_error'];
|
2013-11-22 18:19:52 +02:00
|
|
|
}
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-06-29 00:54:12 +03:00
|
|
|
return true;
|
|
|
|
} catch(exc) {
|
2016-01-24 16:40:06 +02:00
|
|
|
$dialog.find('.modal-message').addClass('alert-danger').text(exc).removeClass('hidden');
|
2013-06-29 00:54:12 +03:00
|
|
|
return false;
|
|
|
|
}
|
2016-04-02 13:25:29 +03:00
|
|
|
}
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-07-05 11:39:52 +03:00
|
|
|
/**
|
2016-05-15 14:05:28 +03:00
|
|
|
* Reset unavailable dialog form.
|
|
|
|
*
|
|
|
|
* Reset the "#manage-unavailable" dialog. Use this method to bring the dialog to the initial state
|
|
|
|
* before it becomes visible to the user.
|
2013-07-05 11:39:52 +03:00
|
|
|
*/
|
2016-04-02 13:25:29 +03:00
|
|
|
function _resetUnavailableDialog() {
|
2013-07-09 17:46:48 +03:00
|
|
|
var $dialog = $('#manage-unavailable');
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2014-01-04 19:25:21 +02:00
|
|
|
$dialog.find('#unavailable-id').val('');
|
|
|
|
|
2013-07-09 17:46:48 +03:00
|
|
|
// Set default time values
|
2016-07-15 21:52:21 +03:00
|
|
|
var start = GeneralFunctions.formatDate(new Date(), GlobalVariables.dateFormat, true);
|
|
|
|
var end = GeneralFunctions.formatDate(new Date().addHours(1), GlobalVariables.dateFormat, true);
|
|
|
|
var dateFormat;
|
2015-12-13 23:00:20 +02:00
|
|
|
|
|
|
|
switch(GlobalVariables.dateFormat) {
|
|
|
|
case 'DMY':
|
|
|
|
dateFormat = 'dd/mm/yy';
|
|
|
|
break;
|
|
|
|
case 'MDY':
|
|
|
|
dateFormat = 'mm/dd/yy';
|
|
|
|
break;
|
|
|
|
case 'YMD':
|
|
|
|
dateFormat = 'yy/mm/dd';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-07-09 17:46:48 +03:00
|
|
|
$dialog.find('#unavailable-start').datetimepicker({
|
2015-12-13 23:00:20 +02:00
|
|
|
dateFormat: dateFormat,
|
|
|
|
|
2013-12-20 19:44:44 +02:00
|
|
|
// Translation
|
2015-10-06 00:30:56 +03:00
|
|
|
dayNames: [EALang['sunday'], EALang['monday'], EALang['tuesday'], EALang['wednesday'],
|
2013-12-20 19:44:44 +02:00
|
|
|
EALang['thursday'], EALang['friday'], EALang['saturday']],
|
2015-10-06 00:30:56 +03:00
|
|
|
dayNamesShort: [EALang['sunday'].substr(0,3), EALang['monday'].substr(0,3),
|
|
|
|
EALang['tuesday'].substr(0,3), EALang['wednesday'].substr(0,3),
|
2013-12-20 19:44:44 +02:00
|
|
|
EALang['thursday'].substr(0,3), EALang['friday'].substr(0,3),
|
|
|
|
EALang['saturday'].substr(0,3)],
|
2015-10-06 00:30:56 +03:00
|
|
|
dayNamesMin: [EALang['sunday'].substr(0,2), EALang['monday'].substr(0,2),
|
|
|
|
EALang['tuesday'].substr(0,2), EALang['wednesday'].substr(0,2),
|
2013-12-20 19:44:44 +02:00
|
|
|
EALang['thursday'].substr(0,2), EALang['friday'].substr(0,2),
|
|
|
|
EALang['saturday'].substr(0,2)],
|
|
|
|
monthNames: [EALang['january'], EALang['february'], EALang['march'], EALang['april'],
|
|
|
|
EALang['may'], EALang['june'], EALang['july'], EALang['august'], EALang['september'],
|
|
|
|
EALang['october'], EALang['november'], EALang['december']],
|
|
|
|
prevText: EALang['previous'],
|
|
|
|
nextText: EALang['next'],
|
|
|
|
currentText: EALang['now'],
|
|
|
|
closeText: EALang['close'],
|
|
|
|
timeOnlyTitle: EALang['select_time'],
|
|
|
|
timeText: EALang['time'],
|
|
|
|
hourText: EALang['hour'],
|
2014-01-04 19:25:21 +02:00
|
|
|
minuteText: EALang['minutes'],
|
|
|
|
firstDay: 1
|
2013-07-09 17:46:48 +03:00
|
|
|
});
|
|
|
|
$dialog.find('#unavailable-start').val(start);
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-07-09 17:46:48 +03:00
|
|
|
$dialog.find('#unavailable-end').datetimepicker({
|
2015-12-13 23:00:20 +02:00
|
|
|
dateFormat: dateFormat,
|
|
|
|
|
2013-12-20 19:44:44 +02:00
|
|
|
// Translation
|
2015-10-06 00:30:56 +03:00
|
|
|
dayNames: [EALang['sunday'], EALang['monday'], EALang['tuesday'], EALang['wednesday'],
|
2013-12-20 19:44:44 +02:00
|
|
|
EALang['thursday'], EALang['friday'], EALang['saturday']],
|
2015-10-06 00:30:56 +03:00
|
|
|
dayNamesShort: [EALang['sunday'].substr(0,3), EALang['monday'].substr(0,3),
|
|
|
|
EALang['tuesday'].substr(0,3), EALang['wednesday'].substr(0,3),
|
2013-12-20 19:44:44 +02:00
|
|
|
EALang['thursday'].substr(0,3), EALang['friday'].substr(0,3),
|
|
|
|
EALang['saturday'].substr(0,3)],
|
2015-10-06 00:30:56 +03:00
|
|
|
dayNamesMin: [EALang['sunday'].substr(0,2), EALang['monday'].substr(0,2),
|
|
|
|
EALang['tuesday'].substr(0,2), EALang['wednesday'].substr(0,2),
|
2013-12-20 19:44:44 +02:00
|
|
|
EALang['thursday'].substr(0,2), EALang['friday'].substr(0,2),
|
|
|
|
EALang['saturday'].substr(0,2)],
|
|
|
|
monthNames: [EALang['january'], EALang['february'], EALang['march'], EALang['april'],
|
|
|
|
EALang['may'], EALang['june'], EALang['july'], EALang['august'], EALang['september'],
|
|
|
|
EALang['october'], EALang['november'], EALang['december']],
|
|
|
|
prevText: EALang['previous'],
|
|
|
|
nextText: EALang['next'],
|
|
|
|
currentText: EALang['now'],
|
|
|
|
closeText: EALang['close'],
|
|
|
|
timeOnlyTitle: EALang['select_time'],
|
|
|
|
timeText: EALang['time'],
|
|
|
|
hourText: EALang['hour'],
|
2014-01-04 19:25:21 +02:00
|
|
|
minuteText: EALang['minutes'],
|
|
|
|
firstDay: 1
|
2013-07-09 17:46:48 +03:00
|
|
|
});
|
|
|
|
$dialog.find('#unavailable-end').val(end);
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2013-07-09 17:46:48 +03:00
|
|
|
// Clear the unavailable notes field.
|
|
|
|
$dialog.find('#unavailable-notes').val('');
|
2016-04-02 13:25:29 +03:00
|
|
|
}
|
2015-10-06 00:30:56 +03:00
|
|
|
|
2016-04-02 13:25:29 +03:00
|
|
|
/**
|
2016-05-15 14:05:28 +03:00
|
|
|
* Initialize Module
|
|
|
|
*
|
|
|
|
* This function makes the necessary initialization for the default backend calendar page. If this module
|
|
|
|
* is used in another page then this function might not be needed.
|
2016-04-02 13:25:29 +03:00
|
|
|
*
|
2016-07-17 14:46:38 +03:00
|
|
|
* @param {String} view Optional (default), the calendar view to be loaded.
|
2016-04-02 13:25:29 +03:00
|
|
|
*/
|
2016-07-17 14:46:38 +03:00
|
|
|
exports.initialize = function(view) {
|
|
|
|
// Load and initialize the calendar view.
|
|
|
|
if (view === 'table') {
|
|
|
|
BackendCalendarTableView.initialize();
|
|
|
|
} else {
|
|
|
|
BackendCalendarDefaultView.initialize();
|
2016-04-02 13:25:29 +03:00
|
|
|
}
|
|
|
|
|
2016-07-17 15:23:18 +03:00
|
|
|
BackendCalendarGoogleSync.initialize();
|
|
|
|
|
2016-07-17 14:46:38 +03:00
|
|
|
_bindEventHandlers(); // General event handling.
|
2016-04-02 13:25:29 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
})(window.BackendCalendar);
|