2015-07-20 22:41:24 +03:00
|
|
|
/* ----------------------------------------------------------------------------
|
|
|
|
* Easy!Appointments - Open Source Web Scheduler
|
2015-10-09 00:12:59 +03:00
|
|
|
*
|
2015-07-20 22:41:24 +03:00
|
|
|
* @package EasyAppointments
|
|
|
|
* @author A.Tselegidis <alextselegidis@gmail.com>
|
2020-03-11 12:10:59 +03:00
|
|
|
* @copyright Copyright (c) 2013 - 2020, Alex Tselegidis
|
2015-10-09 00:12:59 +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
|
|
|
|
* ---------------------------------------------------------------------------- */
|
|
|
|
|
2016-04-02 16:36:55 +03:00
|
|
|
window.BackendServices = window.BackendServices || {};
|
|
|
|
|
2013-07-17 19:29:51 +03:00
|
|
|
/**
|
2016-05-15 13:09:13 +03:00
|
|
|
* Backend Services
|
|
|
|
*
|
2013-07-17 19:29:51 +03:00
|
|
|
* This namespace handles the js functionality of the backend services page.
|
2015-10-09 00:12:59 +03:00
|
|
|
*
|
2016-04-02 16:36:55 +03:00
|
|
|
* @module BackendServices
|
2013-07-17 19:29:51 +03:00
|
|
|
*/
|
2018-01-23 12:08:37 +03:00
|
|
|
(function (exports) {
|
2016-04-02 16:36:55 +03:00
|
|
|
'use strict';
|
|
|
|
|
2013-07-17 19:29:51 +03:00
|
|
|
/**
|
|
|
|
* Contains the basic record methods for the page.
|
2015-10-09 00:12:59 +03:00
|
|
|
*
|
2021-11-18 07:32:46 +03:00
|
|
|
* @type {ServicesHelper}
|
2013-07-17 19:29:51 +03:00
|
|
|
*/
|
2016-04-02 16:36:55 +03:00
|
|
|
var helper;
|
2015-10-09 00:12:59 +03:00
|
|
|
|
2018-01-23 12:08:37 +03:00
|
|
|
var servicesHelper = new ServicesHelper();
|
2016-07-15 21:21:25 +03:00
|
|
|
|
2013-07-17 19:29:51 +03:00
|
|
|
/**
|
|
|
|
* Default initialize method of the page.
|
2015-10-09 00:12:59 +03:00
|
|
|
*
|
2020-05-06 20:23:49 +03:00
|
|
|
* @param {Boolean} [defaultEventHandlers] Optional (true), determines whether to bind the default event handlers.
|
2013-07-17 19:29:51 +03:00
|
|
|
*/
|
2020-05-06 20:23:49 +03:00
|
|
|
exports.initialize = function (defaultEventHandlers) {
|
|
|
|
defaultEventHandlers = defaultEventHandlers || true;
|
2015-10-09 00:12:59 +03:00
|
|
|
|
2013-10-19 13:34:32 +03:00
|
|
|
// Instantiate helper object (service helper by default).
|
2016-07-15 22:09:38 +03:00
|
|
|
helper = servicesHelper;
|
2016-04-02 16:36:55 +03:00
|
|
|
helper.resetForm();
|
|
|
|
helper.filter('');
|
2020-12-08 14:23:37 +03:00
|
|
|
helper.bindEventHandlers();
|
2015-10-09 00:12:59 +03:00
|
|
|
|
2020-05-06 20:23:49 +03:00
|
|
|
if (defaultEventHandlers) {
|
|
|
|
bindEventHandlers();
|
2016-04-02 16:36:55 +03:00
|
|
|
}
|
2021-11-18 07:32:46 +03:00
|
|
|
|
|
|
|
BackendServices.updateAvailableCategories();
|
|
|
|
|
|
|
|
Backend.placeFooterToBottom();
|
2016-04-02 16:36:55 +03:00
|
|
|
};
|
2015-10-09 00:12:59 +03:00
|
|
|
|
2013-07-17 19:29:51 +03:00
|
|
|
/**
|
2016-05-15 13:09:13 +03:00
|
|
|
* Binds the default event handlers of the backend services page.
|
|
|
|
*
|
|
|
|
* Do not use this method if you include the "BackendServices" namespace on another page.
|
2013-07-17 19:29:51 +03:00
|
|
|
*/
|
2020-05-06 20:23:49 +03:00
|
|
|
function bindEventHandlers() {
|
2021-11-18 07:32:46 +03:00
|
|
|
//
|
2016-04-02 16:36:55 +03:00
|
|
|
}
|
2015-10-09 00:12:59 +03:00
|
|
|
|
2013-09-13 16:21:03 +03:00
|
|
|
/**
|
2020-12-08 14:23:37 +03:00
|
|
|
* Update the service category list box.
|
2016-05-15 13:09:13 +03:00
|
|
|
*
|
|
|
|
* Use this method every time a change is made to the service categories db table.
|
2013-09-13 16:21:03 +03:00
|
|
|
*/
|
2018-01-23 12:08:37 +03:00
|
|
|
exports.updateAvailableCategories = function () {
|
2021-11-18 07:32:46 +03:00
|
|
|
var url = GlobalVariables.baseUrl + '/index.php/service_categories/search';
|
2020-05-06 20:15:11 +03:00
|
|
|
|
2017-09-22 15:53:41 +03:00
|
|
|
var data = {
|
2016-07-15 21:52:21 +03:00
|
|
|
csrfToken: GlobalVariables.csrfToken,
|
|
|
|
key: ''
|
|
|
|
};
|
2015-10-09 00:12:59 +03:00
|
|
|
|
2021-11-06 19:38:37 +03:00
|
|
|
$.post(url, data).done(function (response) {
|
|
|
|
GlobalVariables.categories = response;
|
|
|
|
var $select = $('#service-category');
|
2020-05-12 21:52:32 +03:00
|
|
|
|
2021-11-06 19:38:37 +03:00
|
|
|
$select.empty();
|
2020-05-12 21:52:32 +03:00
|
|
|
|
2021-11-06 19:38:37 +03:00
|
|
|
response.forEach(function (category) {
|
|
|
|
$select.append(new Option(category.name, category.id));
|
2020-12-02 20:57:49 +03:00
|
|
|
});
|
2021-11-06 19:38:37 +03:00
|
|
|
|
2021-12-13 09:52:09 +03:00
|
|
|
$select.append(new Option('- ' + App.Lang.no_category + ' -', null)).val('null');
|
2021-11-06 19:38:37 +03:00
|
|
|
});
|
2017-09-22 15:53:41 +03:00
|
|
|
};
|
2016-04-02 16:36:55 +03:00
|
|
|
})(window.BackendServices);
|