This commit is contained in:
60
assets/js/http/account_http_client.js
Normal file
60
assets/js/http/account_http_client.js
Normal file
@ -0,0 +1,60 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.5.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Account HTTP client.
|
||||
*
|
||||
* This module implements the account related HTTP requests.
|
||||
*/
|
||||
App.Http.Account = (function () {
|
||||
/**
|
||||
* Save account.
|
||||
*
|
||||
* @param {Object} account
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function save(account) {
|
||||
const url = App.Utils.Url.siteUrl('account/save');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
account,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate username.
|
||||
*
|
||||
* @param {Number} userId
|
||||
* @param {String} username
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function validateUsername(userId, username) {
|
||||
const url = App.Utils.Url.siteUrl('account/validate_username');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
user_id: userId,
|
||||
username,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
return {
|
||||
save,
|
||||
validateUsername,
|
||||
};
|
||||
})();
|
133
assets/js/http/admins_http_client.js
Normal file
133
assets/js/http/admins_http_client.js
Normal file
@ -0,0 +1,133 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.5.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Admins HTTP client.
|
||||
*
|
||||
* This module implements the admins related HTTP requests.
|
||||
*/
|
||||
App.Http.Admins = (function () {
|
||||
/**
|
||||
* Save (create or update) a admin.
|
||||
*
|
||||
* @param {Object} admin
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function save(admin) {
|
||||
return admin.id ? update(admin) : store(admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an admin.
|
||||
*
|
||||
* @param {Object} admin
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function store(admin) {
|
||||
const url = App.Utils.Url.siteUrl('admins/store');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
admin: admin,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an admin.
|
||||
*
|
||||
* @param {Object} admin
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function update(admin) {
|
||||
const url = App.Utils.Url.siteUrl('admins/update');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
admin: admin,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an admin.
|
||||
*
|
||||
* @param {Number} adminId
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function destroy(adminId) {
|
||||
const url = App.Utils.Url.siteUrl('admins/destroy');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
admin_id: adminId,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search admins by keyword.
|
||||
*
|
||||
* @param {String} keyword
|
||||
* @param {Number} [limit]
|
||||
* @param {Number} [offset]
|
||||
* @param {String} [orderBy]
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function search(keyword, limit = null, offset = null, orderBy = null) {
|
||||
const url = App.Utils.Url.siteUrl('admins/search');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
keyword,
|
||||
limit,
|
||||
offset,
|
||||
order_by: orderBy || undefined,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an admin.
|
||||
*
|
||||
* @param {Number} adminId
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function find(adminId) {
|
||||
const url = App.Utils.Url.siteUrl('admins/find');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
admin_id: adminId,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
return {
|
||||
save,
|
||||
store,
|
||||
update,
|
||||
destroy,
|
||||
search,
|
||||
find,
|
||||
};
|
||||
})();
|
39
assets/js/http/api_settings_http_client.js
Normal file
39
assets/js/http/api_settings_http_client.js
Normal file
@ -0,0 +1,39 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.5.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* API Settings HTTP client.
|
||||
*
|
||||
* This module implements the API settings related HTTP requests.
|
||||
*/
|
||||
App.Http.ApiSettings = (function () {
|
||||
/**
|
||||
* Save API settings.
|
||||
*
|
||||
* @param {Object} apiSettings
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function save(apiSettings) {
|
||||
const url = App.Utils.Url.siteUrl('api_settings/save');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
api_settings: apiSettings,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
return {
|
||||
save,
|
||||
};
|
||||
})();
|
133
assets/js/http/appointments_http_client.js
Normal file
133
assets/js/http/appointments_http_client.js
Normal file
@ -0,0 +1,133 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.5.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Appointments HTTP client.
|
||||
*
|
||||
* This module implements the appointments related HTTP requests.
|
||||
*/
|
||||
App.Http.Appointments = (function () {
|
||||
/**
|
||||
* Save (create or update) an appointment.
|
||||
*
|
||||
* @param {Object} appointment
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function save(appointment) {
|
||||
return appointment.id ? update(appointment) : store(appointment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an appointment.
|
||||
*
|
||||
* @param {Object} appointment
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function store(appointment) {
|
||||
const url = App.Utils.Url.siteUrl('appointments/store');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
appointment: appointment,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an appointment.
|
||||
*
|
||||
* @param {Object} appointment
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function update(appointment) {
|
||||
const url = App.Utils.Url.siteUrl('appointments/update');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
appointment: appointment,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an appointment.
|
||||
*
|
||||
* @param {Number} appointmentId
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function destroy(appointmentId) {
|
||||
const url = App.Utils.Url.siteUrl('appointments/destroy');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
appointment_id: appointmentId,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search appointments by keyword.
|
||||
*
|
||||
* @param {String} keyword
|
||||
* @param {Number} [limit]
|
||||
* @param {Number} [offset]
|
||||
* @param {String} [orderBy]
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function search(keyword, limit = null, offset = null, orderBy = null) {
|
||||
const url = App.Utils.Url.siteUrl('appointments/search');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
keyword,
|
||||
limit,
|
||||
offset,
|
||||
order_by: orderBy || undefined,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an appointment.
|
||||
*
|
||||
* @param {Number} appointmentId
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function find(appointmentId) {
|
||||
const url = App.Utils.Url.siteUrl('appointments/find');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
appointment_id: appointmentId,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
return {
|
||||
save,
|
||||
store,
|
||||
update,
|
||||
destroy,
|
||||
search,
|
||||
find,
|
||||
};
|
||||
})();
|
133
assets/js/http/blocked_periods_http_client.js
Normal file
133
assets/js/http/blocked_periods_http_client.js
Normal file
@ -0,0 +1,133 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.5.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Blocked-periods HTTP client.
|
||||
*
|
||||
* This module implements the blocked-periods related HTTP requests.
|
||||
*/
|
||||
App.Http.BlockedPeriods = (function () {
|
||||
/**
|
||||
* Save (create or update) a blocked-period.
|
||||
*
|
||||
* @param {Object} blockedPeriod
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function save(blockedPeriod) {
|
||||
return blockedPeriod.id ? update(blockedPeriod) : store(blockedPeriod);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a blocked-period.
|
||||
*
|
||||
* @param {Object} blockedPeriod
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function store(blockedPeriod) {
|
||||
const url = App.Utils.Url.siteUrl('blocked_periods/store');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
blocked_period: blockedPeriod,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a blocked-period.
|
||||
*
|
||||
* @param {Object} blockedPeriod
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function update(blockedPeriod) {
|
||||
const url = App.Utils.Url.siteUrl('blocked_periods/update');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
blocked_period: blockedPeriod,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a blocked-period.
|
||||
*
|
||||
* @param {Number} blockedPeriodId
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function destroy(blockedPeriodId) {
|
||||
const url = App.Utils.Url.siteUrl('blocked_periods/destroy');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
blocked_period_id: blockedPeriodId,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search blocked-periods by keyword.
|
||||
*
|
||||
* @param {String} keyword
|
||||
* @param {Number} [limit]
|
||||
* @param {Number} [offset]
|
||||
* @param {String} [orderBy]
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function search(keyword, limit = null, offset = null, orderBy = null) {
|
||||
const url = App.Utils.Url.siteUrl('blocked_periods/search');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
keyword,
|
||||
limit,
|
||||
offset,
|
||||
order_by: orderBy || undefined,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a blocked-period.
|
||||
*
|
||||
* @param {Number} blockedPeriodId
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function find(blockedPeriodId) {
|
||||
const url = App.Utils.Url.siteUrl('blocked_periods/find');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
blocked_period_id: blockedPeriodId,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
return {
|
||||
save,
|
||||
store,
|
||||
update,
|
||||
destroy,
|
||||
search,
|
||||
find,
|
||||
};
|
||||
})();
|
400
assets/js/http/booking_http_client.js
Normal file
400
assets/js/http/booking_http_client.js
Normal file
@ -0,0 +1,400 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.5.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Booking HTTP client.
|
||||
*
|
||||
* This module implements the booking related HTTP requests.
|
||||
*
|
||||
* Old Name: FrontendBookApi
|
||||
*/
|
||||
App.Http.Booking = (function () {
|
||||
const $selectDate = $('#select-date');
|
||||
const $selectService = $('#select-service');
|
||||
const $selectProvider = $('#select-provider');
|
||||
const $availableHours = $('#available-hours');
|
||||
const $captchaHint = $('#captcha-hint');
|
||||
const $captchaTitle = $('.captcha-title');
|
||||
|
||||
const MONTH_SEARCH_LIMIT = 2; // Months in the future
|
||||
|
||||
const moment = window.moment;
|
||||
|
||||
let unavailableDatesBackup;
|
||||
let selectedDateStringBackup;
|
||||
let processingUnavailableDates = false;
|
||||
let searchedMonthStart;
|
||||
let searchedMonthCounter = 0;
|
||||
|
||||
/**
|
||||
* Get Available Hours
|
||||
*
|
||||
* This function makes an AJAX call and returns the available hours for the selected service,
|
||||
* provider and date.
|
||||
*
|
||||
* @param {String} selectedDate The selected date of the available hours we need.
|
||||
*/
|
||||
function getAvailableHours(selectedDate) {
|
||||
$availableHours.empty();
|
||||
|
||||
// Find the selected service duration (it is going to be send within the "data" object).
|
||||
const serviceId = $selectService.val();
|
||||
|
||||
// Default value of duration (in minutes).
|
||||
let serviceDuration = 15;
|
||||
|
||||
const service = vars('available_services').find(
|
||||
(availableService) => Number(availableService.id) === Number(serviceId),
|
||||
);
|
||||
|
||||
if (service) {
|
||||
serviceDuration = service.duration;
|
||||
}
|
||||
|
||||
// If the manage mode is true then the appointment's start date should return as available too.
|
||||
const appointmentId = vars('manage_mode') ? vars('appointment_data').id : null;
|
||||
|
||||
// Make ajax post request and get the available hours.
|
||||
const url = App.Utils.Url.siteUrl('booking/get_available_hours');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
service_id: $selectService.val(),
|
||||
provider_id: $selectProvider.val(),
|
||||
selected_date: selectedDate,
|
||||
service_duration: serviceDuration,
|
||||
manage_mode: Number(vars('manage_mode') || 0),
|
||||
appointment_id: appointmentId,
|
||||
};
|
||||
|
||||
$.post(url, data).done((response) => {
|
||||
$availableHours.empty();
|
||||
|
||||
// The response contains the available hours for the selected provider and service. Fill the available
|
||||
// hours div with response data.
|
||||
if (response.length > 0) {
|
||||
let providerId = $selectProvider.val();
|
||||
|
||||
if (providerId === 'any-provider') {
|
||||
for (const availableProvider of vars('available_providers')) {
|
||||
if (availableProvider.services.indexOf(Number(serviceId)) !== -1) {
|
||||
providerId = availableProvider.id; // Use first available provider.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const provider = vars('available_providers').find(
|
||||
(availableProvider) => Number(providerId) === Number(availableProvider.id),
|
||||
);
|
||||
|
||||
if (!provider) {
|
||||
throw new Error('Could not find provider.');
|
||||
}
|
||||
|
||||
const providerTimezone = provider.timezone;
|
||||
const selectedTimezone = $('#select-timezone').val();
|
||||
const timeFormat = vars('time_format') === 'regular' ? 'h:mm a' : 'HH:mm';
|
||||
|
||||
response.forEach((availableHour) => {
|
||||
const availableHourMoment = moment
|
||||
.tz(selectedDate + ' ' + availableHour + ':00', providerTimezone)
|
||||
.tz(selectedTimezone);
|
||||
|
||||
if (availableHourMoment.format('YYYY-MM-DD') !== selectedDate) {
|
||||
return; // Due to the selected timezone the available hour belongs to another date.
|
||||
}
|
||||
|
||||
$availableHours.append(
|
||||
$('<button/>', {
|
||||
'class': 'btn btn-outline-secondary w-100 shadow-none available-hour',
|
||||
'data': {
|
||||
'value': availableHour,
|
||||
},
|
||||
'text': availableHourMoment.format(timeFormat),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
if (App.Pages.Booking.manageMode) {
|
||||
// Set the appointment's start time as the default selection.
|
||||
$('.available-hour')
|
||||
.removeClass('selected-hour')
|
||||
.filter(
|
||||
(index, availableHourEl) =>
|
||||
$(availableHourEl).text() ===
|
||||
moment(vars('appointment_data').start_datetime).format(timeFormat),
|
||||
)
|
||||
.addClass('selected-hour');
|
||||
} else {
|
||||
// Set the first available hour as the default selection.
|
||||
$('.available-hour:eq(0)').addClass('selected-hour');
|
||||
}
|
||||
|
||||
App.Pages.Booking.updateConfirmFrame();
|
||||
}
|
||||
|
||||
if (!$availableHours.find('.available-hour').length) {
|
||||
$availableHours.text(lang('no_available_hours'));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an appointment to the database.
|
||||
*
|
||||
* This method will make an ajax call to the appointments controller that will register
|
||||
* the appointment to the database.
|
||||
*/
|
||||
function registerAppointment() {
|
||||
const $captchaText = $('.captcha-text');
|
||||
|
||||
if ($captchaText.length > 0) {
|
||||
$captchaText.removeClass('is-invalid');
|
||||
if ($captchaText.val() === '') {
|
||||
$captchaText.addClass('is-invalid');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const formData = JSON.parse($('input[name="post_data"]').val());
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
post_data: formData,
|
||||
};
|
||||
|
||||
if ($captchaText.length > 0) {
|
||||
data.captcha = $captchaText.val();
|
||||
}
|
||||
|
||||
if (vars('manage_mode')) {
|
||||
data.exclude_appointment_id = vars('appointment_data').id;
|
||||
}
|
||||
|
||||
const url = App.Utils.Url.siteUrl('booking/register');
|
||||
|
||||
const $layer = $('<div/>');
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
method: 'post',
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
beforeSend: () => {
|
||||
$layer.appendTo('body').css({
|
||||
background: 'white',
|
||||
position: 'fixed',
|
||||
top: '0',
|
||||
left: '0',
|
||||
height: '100vh',
|
||||
width: '100vw',
|
||||
opacity: '0.5',
|
||||
});
|
||||
},
|
||||
})
|
||||
.done((response) => {
|
||||
if (response.captcha_verification === false) {
|
||||
$captchaHint.text(lang('captcha_is_wrong')).fadeTo(400, 1);
|
||||
|
||||
setTimeout(() => {
|
||||
$captchaHint.fadeTo(400, 0);
|
||||
}, 3000);
|
||||
|
||||
$captchaTitle.find('button').trigger('click');
|
||||
|
||||
$captchaText.addClass('is-invalid');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
window.location.href = App.Utils.Url.siteUrl('booking_confirmation/of/' + response.appointment_hash);
|
||||
})
|
||||
.fail(() => {
|
||||
$captchaTitle.find('button').trigger('click');
|
||||
})
|
||||
.always(() => {
|
||||
$layer.remove();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the unavailable dates of a provider.
|
||||
*
|
||||
* This method will fetch the unavailable dates of the selected provider and service and then it will
|
||||
* select the first available date (if any). It uses the "FrontendBookApi.getAvailableHours" method to
|
||||
* fetch the appointment* hours of the selected date.
|
||||
*
|
||||
* @param {Number} providerId The selected provider ID.
|
||||
* @param {Number} serviceId The selected service ID.
|
||||
* @param {String} selectedDateString Y-m-d value of the selected date.
|
||||
* @param {Number} [monthChangeStep] Whether to add or subtract months.
|
||||
*/
|
||||
function getUnavailableDates(providerId, serviceId, selectedDateString, monthChangeStep = 1) {
|
||||
if (processingUnavailableDates) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!providerId || !serviceId) {
|
||||
return;
|
||||
}
|
||||
|
||||
const appointmentId = App.Pages.Booking.manageMode ? vars('appointment_data').id : null;
|
||||
|
||||
const url = App.Utils.Url.siteUrl('booking/get_unavailable_dates');
|
||||
|
||||
const data = {
|
||||
provider_id: providerId,
|
||||
service_id: serviceId,
|
||||
selected_date: encodeURIComponent(selectedDateString),
|
||||
csrf_token: vars('csrf_token'),
|
||||
manage_mode: Number(App.Pages.Booking.manageMode),
|
||||
appointment_id: appointmentId,
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'GET',
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
})
|
||||
.done((response) => {
|
||||
// In case the current month has no availability, the app will try the next one or the one after in order to
|
||||
// find a date that has at least one slot
|
||||
|
||||
if (response.is_month_unavailable) {
|
||||
if (!searchedMonthStart) {
|
||||
searchedMonthStart = selectedDateString;
|
||||
}
|
||||
|
||||
if (searchedMonthCounter >= MONTH_SEARCH_LIMIT) {
|
||||
// Need to mark the current month dates as unavailable
|
||||
const selectedDateMoment = moment(searchedMonthStart);
|
||||
const startOfMonthMoment = selectedDateMoment.clone().startOf('month');
|
||||
const endOfMonthMoment = selectedDateMoment.clone().endOf('month');
|
||||
const unavailableDates = [];
|
||||
|
||||
while (startOfMonthMoment.isSameOrBefore(endOfMonthMoment)) {
|
||||
unavailableDates.push(startOfMonthMoment.format('YYYY-MM-DD'));
|
||||
startOfMonthMoment.add(Math.abs(monthChangeStep), 'days'); // Move to the next day
|
||||
}
|
||||
|
||||
applyUnavailableDates(unavailableDates, searchedMonthStart, true);
|
||||
searchedMonthStart = undefined;
|
||||
searchedMonthCounter = 0;
|
||||
|
||||
return; // Stop searching
|
||||
}
|
||||
|
||||
searchedMonthCounter++;
|
||||
|
||||
const selectedDateMoment = moment(selectedDateString);
|
||||
selectedDateMoment.add(1, 'month');
|
||||
|
||||
const nextSelectedDate = selectedDateMoment.format('YYYY-MM-DD');
|
||||
getUnavailableDates(providerId, serviceId, nextSelectedDate, monthChangeStep);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
unavailableDatesBackup = response;
|
||||
selectedDateStringBackup = selectedDateString;
|
||||
applyUnavailableDates(response, selectedDateString, true);
|
||||
})
|
||||
.fail(() => {
|
||||
$selectDate.parent().fadeTo(400, 1);
|
||||
});
|
||||
}
|
||||
|
||||
function applyPreviousUnavailableDates() {
|
||||
applyUnavailableDates(unavailableDatesBackup, selectedDateStringBackup);
|
||||
}
|
||||
|
||||
function applyUnavailableDates(unavailableDates, selectedDateString, setDate) {
|
||||
setDate = setDate || false;
|
||||
|
||||
$selectDate.parent().fadeTo(400, 1);
|
||||
|
||||
processingUnavailableDates = true;
|
||||
|
||||
// Select first enabled date.
|
||||
const selectedDateMoment = moment(selectedDateString);
|
||||
const selectedDate = selectedDateMoment.toDate();
|
||||
const numberOfDays = selectedDateMoment.daysInMonth();
|
||||
|
||||
// If all the days are unavailable then hide the appointments hours.
|
||||
if (unavailableDates.length === numberOfDays) {
|
||||
$availableHours.text(lang('no_available_hours'));
|
||||
}
|
||||
|
||||
// Grey out unavailable dates.
|
||||
$selectDate[0]._flatpickr.set(
|
||||
'disable',
|
||||
unavailableDates.map((unavailableDate) => new Date(unavailableDate + 'T00:00')),
|
||||
);
|
||||
|
||||
if (setDate && !vars('manage_mode')) {
|
||||
for (let i = 1; i <= numberOfDays; i++) {
|
||||
const currentDate = new Date(selectedDate.getFullYear(), selectedDate.getMonth(), i);
|
||||
|
||||
if (unavailableDates.indexOf(moment(currentDate).format('YYYY-MM-DD')) === -1) {
|
||||
App.Utils.UI.setDateTimePickerValue($selectDate, currentDate);
|
||||
getAvailableHours(moment(currentDate).format('YYYY-MM-DD'));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const dateQueryParam = App.Utils.Url.queryParam('date');
|
||||
|
||||
if (dateQueryParam) {
|
||||
const dateQueryParamMoment = moment(dateQueryParam);
|
||||
|
||||
if (
|
||||
dateQueryParamMoment.isValid() &&
|
||||
!unavailableDates.includes(dateQueryParam) &&
|
||||
dateQueryParamMoment.format('YYYY-MM') === selectedDateMoment.format('YYYY-MM')
|
||||
) {
|
||||
App.Utils.UI.setDateTimePickerValue($selectDate, dateQueryParamMoment.toDate());
|
||||
}
|
||||
}
|
||||
|
||||
searchedMonthStart = undefined;
|
||||
searchedMonthCounter = 0;
|
||||
processingUnavailableDates = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete personal information.
|
||||
*
|
||||
* @param {Number} customerToken Customer unique token.
|
||||
*/
|
||||
function deletePersonalInformation(customerToken) {
|
||||
const url = App.Utils.Url.siteUrl('privacy/delete_personal_information');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
customer_token: customerToken,
|
||||
};
|
||||
|
||||
$.post(url, data).done(() => {
|
||||
window.location.href = vars('base_url');
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
registerAppointment,
|
||||
getAvailableHours,
|
||||
getUnavailableDates,
|
||||
applyPreviousUnavailableDates,
|
||||
deletePersonalInformation,
|
||||
};
|
||||
})();
|
39
assets/js/http/booking_settings_http_client.js
Normal file
39
assets/js/http/booking_settings_http_client.js
Normal file
@ -0,0 +1,39 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.5.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Booking Settings HTTP client.
|
||||
*
|
||||
* This module implements the booking settings related HTTP requests.
|
||||
*/
|
||||
App.Http.BookingSettings = (function () {
|
||||
/**
|
||||
* Save booking settings.
|
||||
*
|
||||
* @param {Object} bookingSettings
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function save(bookingSettings) {
|
||||
const url = App.Utils.Url.siteUrl('booking_settings/save');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
booking_settings: bookingSettings,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
return {
|
||||
save,
|
||||
};
|
||||
})();
|
58
assets/js/http/business_settings_http_client.js
Normal file
58
assets/js/http/business_settings_http_client.js
Normal file
@ -0,0 +1,58 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.5.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Business Settings HTTP client.
|
||||
*
|
||||
* This module implements the business settings related HTTP requests.
|
||||
*/
|
||||
App.Http.BusinessSettings = (function () {
|
||||
/**
|
||||
* Save business settings.
|
||||
*
|
||||
* @param {Object} businessSettings
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function save(businessSettings) {
|
||||
const url = App.Utils.Url.siteUrl('business_settings/save');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
business_settings: businessSettings,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply global working plan.
|
||||
*
|
||||
* @param {Object} workingPlan
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function applyGlobalWorkingPlan(workingPlan) {
|
||||
const url = App.Utils.Url.siteUrl('business_settings/apply_global_working_plan');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
working_plan: JSON.stringify(workingPlan),
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
return {
|
||||
save,
|
||||
applyGlobalWorkingPlan,
|
||||
};
|
||||
})();
|
108
assets/js/http/caldav_http_client.js
Normal file
108
assets/js/http/caldav_http_client.js
Normal file
@ -0,0 +1,108 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.5.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Caldav HTTP client.
|
||||
*
|
||||
* This module implements the Caldav Calendar related HTTP requests.
|
||||
*/
|
||||
App.Http.Caldav = (function () {
|
||||
/**
|
||||
* Select the Caldav Calendar for the synchronization with a provider.
|
||||
*
|
||||
* @param {Number} providerId
|
||||
* @param {String} caldavCalendarId
|
||||
*
|
||||
* @return {*|jQuery}
|
||||
*/
|
||||
function selectCaldavCalendar(providerId, caldavCalendarId) {
|
||||
const url = App.Utils.Url.siteUrl('caldav/select_caldav_calendar');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
provider_id: providerId,
|
||||
calendar_id: caldavCalendarId,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable the Caldav Calendar syncing of a provider.
|
||||
*
|
||||
* @param {Number} providerId
|
||||
*
|
||||
* @return {*|jQuery}
|
||||
*/
|
||||
function disableProviderSync(providerId) {
|
||||
const url = App.Utils.Url.siteUrl('caldav/disable_provider_sync');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
provider_id: providerId,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the available Caldav Calendars of the connected provider's account.
|
||||
*
|
||||
* @param {Number} providerId
|
||||
*
|
||||
* @return {*|jQuery}
|
||||
*/
|
||||
function getCaldavCalendars(providerId) {
|
||||
const url = App.Utils.Url.siteUrl('caldav/get_caldav_calendars');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
provider_id: providerId,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger the sync process between Easy!Appointments and Caldav Calendar.
|
||||
*
|
||||
* @param {Number} providerId
|
||||
*
|
||||
* @return {*|jQuery}
|
||||
*/
|
||||
function syncWithCaldav(providerId) {
|
||||
const url = App.Utils.Url.siteUrl('caldav/sync/' + providerId);
|
||||
|
||||
return $.get(url);
|
||||
}
|
||||
|
||||
function connectToServer(providerId, caldavUrl, caldavUsername, caldavPassword) {
|
||||
const url = App.Utils.Url.siteUrl('caldav/connect_to_server');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
provider_id: providerId,
|
||||
caldav_url: caldavUrl,
|
||||
caldav_username: caldavUsername,
|
||||
caldav_password: caldavPassword,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
return {
|
||||
getCaldavCalendars,
|
||||
selectCaldavCalendar,
|
||||
disableProviderSync,
|
||||
syncWithCaldav,
|
||||
connectToServer,
|
||||
};
|
||||
})();
|
255
assets/js/http/calendar_http_client.js
Normal file
255
assets/js/http/calendar_http_client.js
Normal file
@ -0,0 +1,255 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.5.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Calendar HTTP client.
|
||||
*
|
||||
* This module implements the calendar related HTTP requests.
|
||||
*
|
||||
* Old Name: BackendCalendarApi
|
||||
*/
|
||||
App.Http.Calendar = (function () {
|
||||
/**
|
||||
* Save Appointment
|
||||
*
|
||||
* This method stores the changes of an already registered appointment into the database, via an ajax call.
|
||||
*
|
||||
* @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.
|
||||
*
|
||||
* @return {*|jQuery}
|
||||
*/
|
||||
function saveAppointment(appointment, customer, successCallback, errorCallback) {
|
||||
const url = App.Utils.Url.siteUrl('calendar/save_appointment');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
appointment_data: appointment,
|
||||
};
|
||||
|
||||
if (customer) {
|
||||
data.customer_data = customer;
|
||||
}
|
||||
|
||||
return $.post(url, data)
|
||||
.done((response) => {
|
||||
if (successCallback) {
|
||||
successCallback(response);
|
||||
}
|
||||
})
|
||||
.fail(() => {
|
||||
if (errorCallback) {
|
||||
errorCallback();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an appointment.
|
||||
*
|
||||
* @param {Number} appointmentId
|
||||
* @param {String} cancellationReason
|
||||
*
|
||||
* @return {*|jQuery}
|
||||
*/
|
||||
function deleteAppointment(appointmentId, cancellationReason) {
|
||||
const url = App.Utils.Url.siteUrl('calendar/delete_appointment');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
appointment_id: appointmentId,
|
||||
cancellation_reason: cancellationReason,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save unavailability period to database.
|
||||
*
|
||||
* @param {Object} unavailability Contains the unavailability period data.
|
||||
* @param {Function} [successCallback] The ajax success callback function.
|
||||
* @param {Function} [errorCallback] The ajax failure callback function.
|
||||
*
|
||||
* @return {*|jQuery}
|
||||
*/
|
||||
function saveUnavailability(unavailability, successCallback, errorCallback) {
|
||||
const url = App.Utils.Url.siteUrl('calendar/save_unavailability');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
unavailability: unavailability,
|
||||
};
|
||||
|
||||
return $.post(url, data)
|
||||
.done((response) => {
|
||||
if (successCallback) {
|
||||
successCallback(response);
|
||||
}
|
||||
})
|
||||
.fail(() => {
|
||||
if (errorCallback) {
|
||||
errorCallback();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an unavailability.
|
||||
*
|
||||
* @param {Number} unavailabilityId
|
||||
*
|
||||
* @return {*|jQuery}
|
||||
*/
|
||||
function deleteUnavailability(unavailabilityId) {
|
||||
const url = App.Utils.Url.siteUrl('calendar/delete_unavailability');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
unavailability_id: unavailabilityId,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save working plan exception of work to database.
|
||||
*
|
||||
* @param {Date} date Contains the working plan exceptions data.
|
||||
* @param {Object} workingPlanException Contains the working plan exceptions data.
|
||||
* @param {Number} providerId Contains the working plan exceptions data.
|
||||
* @param {Function} successCallback The ajax success callback function.
|
||||
* @param {Function} errorCallback The ajax failure callback function.
|
||||
* @param {Date} [originalDate] On edit, provide the original date.
|
||||
*
|
||||
* @return {*|jQuery}
|
||||
*/
|
||||
function saveWorkingPlanException(
|
||||
date,
|
||||
workingPlanException,
|
||||
providerId,
|
||||
successCallback,
|
||||
errorCallback,
|
||||
originalDate,
|
||||
) {
|
||||
const url = App.Utils.Url.siteUrl('calendar/save_working_plan_exception');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
date: date,
|
||||
working_plan_exception: workingPlanException,
|
||||
provider_id: providerId,
|
||||
original_date: originalDate,
|
||||
};
|
||||
|
||||
return $.post(url, data)
|
||||
.done((response) => {
|
||||
if (successCallback) {
|
||||
successCallback(response);
|
||||
}
|
||||
})
|
||||
.fail(() => {
|
||||
if (errorCallback) {
|
||||
errorCallback();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete working plan exception
|
||||
*
|
||||
* @param {String} date
|
||||
* @param {Number} providerId
|
||||
* @param {Function} [successCallback]
|
||||
* @param {Function} [errorCallback]
|
||||
*
|
||||
* @return {*|jQuery}
|
||||
*/
|
||||
function deleteWorkingPlanException(date, providerId, successCallback, errorCallback) {
|
||||
const url = App.Utils.Url.siteUrl('calendar/delete_working_plan_exception');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
date: date,
|
||||
provider_id: providerId,
|
||||
};
|
||||
|
||||
return $.post(url, data)
|
||||
.done((response) => {
|
||||
if (successCallback) {
|
||||
successCallback(response);
|
||||
}
|
||||
})
|
||||
.fail(() => {
|
||||
if (errorCallback) {
|
||||
errorCallback();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the appointments for the displayed calendar period.
|
||||
*
|
||||
* @param {Number} recordId Record ID (provider or service).
|
||||
* @param {String} filterType The filter type, could be either "provider" or "service".
|
||||
* @param {String} startDate Visible start date of the calendar.
|
||||
* @param {String} endDate Visible end date of the calendar.
|
||||
*
|
||||
* @returns {jQuery.jqXHR}
|
||||
*/
|
||||
function getCalendarAppointments(recordId, startDate, endDate, filterType) {
|
||||
const url = App.Utils.Url.siteUrl('calendar/get_calendar_appointments');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
record_id: recordId,
|
||||
start_date: moment(startDate).format('YYYY-MM-DD'),
|
||||
end_date: moment(endDate).format('YYYY-MM-DD'),
|
||||
filter_type: filterType,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the calendar appointments for the table view (different data structure).
|
||||
*
|
||||
* @param {Date} startDate
|
||||
* @param {Date} endDate
|
||||
*
|
||||
* @return {*|jQuery}
|
||||
*/
|
||||
function getCalendarAppointmentsForTableView(startDate, endDate) {
|
||||
const url = App.Utils.Url.siteUrl('calendar/get_calendar_appointments_for_table_view');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
start_date: moment(startDate).format('YYYY-MM-DD'),
|
||||
end_date: moment(endDate).format('YYYY-MM-DD'),
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
return {
|
||||
saveAppointment,
|
||||
deleteAppointment,
|
||||
saveUnavailability,
|
||||
deleteUnavailability,
|
||||
saveWorkingPlanException,
|
||||
deleteWorkingPlanException,
|
||||
getCalendarAppointments,
|
||||
getCalendarAppointmentsForTableView,
|
||||
};
|
||||
})();
|
133
assets/js/http/customers_http_client.js
Normal file
133
assets/js/http/customers_http_client.js
Normal file
@ -0,0 +1,133 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.5.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Customers HTTP client.
|
||||
*
|
||||
* This module implements the customers related HTTP requests.
|
||||
*/
|
||||
App.Http.Customers = (function () {
|
||||
/**
|
||||
* Save (create or update) a customer.
|
||||
*
|
||||
* @param {Object} customer
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function save(customer) {
|
||||
return customer.id ? update(customer) : store(customer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a customer.
|
||||
*
|
||||
* @param {Object} customer
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function store(customer) {
|
||||
const url = App.Utils.Url.siteUrl('customers/store');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
customer: customer,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a customer.
|
||||
*
|
||||
* @param {Object} customer
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function update(customer) {
|
||||
const url = App.Utils.Url.siteUrl('customers/update');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
customer: customer,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a customer.
|
||||
*
|
||||
* @param {Number} customerId
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function destroy(customerId) {
|
||||
const url = App.Utils.Url.siteUrl('customers/destroy');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
customer_id: customerId,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search customers by keyword.
|
||||
*
|
||||
* @param {String} keyword
|
||||
* @param {Number} [limit]
|
||||
* @param {Number} [offset]
|
||||
* @param {String} [orderBy]
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function search(keyword, limit = null, offset = null, orderBy = null) {
|
||||
const url = App.Utils.Url.siteUrl('customers/search');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
keyword,
|
||||
limit,
|
||||
offset,
|
||||
order_by: orderBy || undefined,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a customer.
|
||||
*
|
||||
* @param {Number} customerId
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function find(customerId) {
|
||||
const url = App.Utils.Url.siteUrl('customers/find');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
customer_id: customerId,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
return {
|
||||
save,
|
||||
store,
|
||||
update,
|
||||
destroy,
|
||||
search,
|
||||
find,
|
||||
};
|
||||
})();
|
39
assets/js/http/general_settings_http_client.js
Normal file
39
assets/js/http/general_settings_http_client.js
Normal file
@ -0,0 +1,39 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.5.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* General Settings HTTP client.
|
||||
*
|
||||
* This module implements the general settings related HTTP requests.
|
||||
*/
|
||||
App.Http.GeneralSettings = (function () {
|
||||
/**
|
||||
* Save general settings.
|
||||
*
|
||||
* @param {Object} generalSettings
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function save(generalSettings) {
|
||||
const url = App.Utils.Url.siteUrl('general_settings/save');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
general_settings: generalSettings,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
return {
|
||||
save,
|
||||
};
|
||||
})();
|
39
assets/js/http/google_analytics_settings_http_client.js
Normal file
39
assets/js/http/google_analytics_settings_http_client.js
Normal file
@ -0,0 +1,39 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.5.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Google Analytics Settings HTTP client.
|
||||
*
|
||||
* This module implements the Google Analytics settings related HTTP requests.
|
||||
*/
|
||||
App.Http.GoogleAnalyticsSettings = (function () {
|
||||
/**
|
||||
* Save Google Analytics settings.
|
||||
*
|
||||
* @param {Object} googleAnalyticsSettings
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function save(googleAnalyticsSettings) {
|
||||
const url = App.Utils.Url.siteUrl('google_analytics_settings/save');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
google_analytics_settings: googleAnalyticsSettings,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
return {
|
||||
save,
|
||||
};
|
||||
})();
|
93
assets/js/http/google_http_client.js
Normal file
93
assets/js/http/google_http_client.js
Normal file
@ -0,0 +1,93 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.5.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Google HTTP client.
|
||||
*
|
||||
* This module implements the Google Calendar related HTTP requests.
|
||||
*/
|
||||
App.Http.Google = (function () {
|
||||
/**
|
||||
* Select the Google Calendar for the synchronization with a provider.
|
||||
*
|
||||
* @param {Number} providerId
|
||||
* @param {String} googleCalendarId
|
||||
*
|
||||
* @return {*|jQuery}
|
||||
*/
|
||||
function selectGoogleCalendar(providerId, googleCalendarId) {
|
||||
const url = App.Utils.Url.siteUrl('google/select_google_calendar');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
provider_id: providerId,
|
||||
calendar_id: googleCalendarId,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable the Google Calendar syncing of a provider.
|
||||
*
|
||||
* @param {Number} providerId
|
||||
*
|
||||
* @return {*|jQuery}
|
||||
*/
|
||||
function disableProviderSync(providerId) {
|
||||
const url = App.Utils.Url.siteUrl('google/disable_provider_sync');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
provider_id: providerId,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the available Google Calendars of the connected provider's account.
|
||||
*
|
||||
* @param {Number} providerId
|
||||
*
|
||||
* @return {*|jQuery}
|
||||
*/
|
||||
function getGoogleCalendars(providerId) {
|
||||
const url = App.Utils.Url.siteUrl('google/get_google_calendars');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
provider_id: providerId,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger the sync process between Easy!Appointments and Google Calendar.
|
||||
*
|
||||
* @param {Number} providerId
|
||||
*
|
||||
* @return {*|jQuery}
|
||||
*/
|
||||
function syncWithGoogle(providerId) {
|
||||
const url = App.Utils.Url.siteUrl('google/sync/' + providerId);
|
||||
|
||||
return $.get(url);
|
||||
}
|
||||
|
||||
return {
|
||||
getGoogleCalendars,
|
||||
selectGoogleCalendar,
|
||||
disableProviderSync,
|
||||
syncWithGoogle,
|
||||
};
|
||||
})();
|
58
assets/js/http/ldap_settings_http_client.js
Normal file
58
assets/js/http/ldap_settings_http_client.js
Normal file
@ -0,0 +1,58 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.5.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* LDAP Settings HTTP client.
|
||||
*
|
||||
* This module implements the LDAP settings related HTTP requests.
|
||||
*/
|
||||
App.Http.LdapSettings = (function () {
|
||||
/**
|
||||
* Save LDAP settings.
|
||||
*
|
||||
* @param {Object} ldapSettings
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function save(ldapSettings) {
|
||||
const url = App.Utils.Url.siteUrl('ldap_settings/save');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
ldap_settings: ldapSettings,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search LDAP server.
|
||||
*
|
||||
* @param {String} keyword
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function search(keyword) {
|
||||
const url = App.Utils.Url.siteUrl('ldap_settings/search');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
keyword,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
return {
|
||||
save,
|
||||
search,
|
||||
};
|
||||
})();
|
39
assets/js/http/legal_settings_http_client.js
Normal file
39
assets/js/http/legal_settings_http_client.js
Normal file
@ -0,0 +1,39 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.5.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Legal Settings HTTP client.
|
||||
*
|
||||
* This module implements the legal settings related HTTP requests.
|
||||
*/
|
||||
App.Http.LegalSettings = (function () {
|
||||
/**
|
||||
* Save legal settings.
|
||||
*
|
||||
* @param {Object} legalSettings
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function save(legalSettings) {
|
||||
const url = App.Utils.Url.siteUrl('legal_settings/save');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
legal_settings: legalSettings,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
return {
|
||||
save,
|
||||
};
|
||||
})();
|
37
assets/js/http/localization_http_client.js
Normal file
37
assets/js/http/localization_http_client.js
Normal file
@ -0,0 +1,37 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.5.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Localization HTTP client.
|
||||
*
|
||||
* This module implements the account related HTTP requests.
|
||||
*/
|
||||
App.Http.Localization = (function () {
|
||||
/**
|
||||
* Change language.
|
||||
*
|
||||
* @param {String} language
|
||||
*/
|
||||
function changeLanguage(language) {
|
||||
const url = App.Utils.Url.siteUrl('localization/change_language');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
language,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
return {
|
||||
changeLanguage,
|
||||
};
|
||||
})();
|
41
assets/js/http/login_http_client.js
Normal file
41
assets/js/http/login_http_client.js
Normal file
@ -0,0 +1,41 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.5.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Login HTTP client.
|
||||
*
|
||||
* This module implements the account login related HTTP requests.
|
||||
*/
|
||||
App.Http.Login = (function () {
|
||||
/**
|
||||
* Perform an account recovery.
|
||||
*
|
||||
* @param {String} username
|
||||
* @param {String} password
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function validate(username, password) {
|
||||
const url = App.Utils.Url.siteUrl('login/validate');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
username,
|
||||
password,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
return {
|
||||
validate,
|
||||
};
|
||||
})();
|
39
assets/js/http/matomo_analytics_settings_http_client.js
Normal file
39
assets/js/http/matomo_analytics_settings_http_client.js
Normal file
@ -0,0 +1,39 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.5.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Matomo Analytics Settings HTTP client.
|
||||
*
|
||||
* This module implements the Matomo Analytics settings related HTTP requests.
|
||||
*/
|
||||
App.Http.MatomoAnalyticsSettings = (function () {
|
||||
/**
|
||||
* Save Matomo Analytics settings.
|
||||
*
|
||||
* @param {Object} matomoAnalyticsSettings
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function save(matomoAnalyticsSettings) {
|
||||
const url = App.Utils.Url.siteUrl('matomo_analytics_settings/save');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
matomo_analytics_settings: matomoAnalyticsSettings,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
return {
|
||||
save,
|
||||
};
|
||||
})();
|
133
assets/js/http/providers_http_client.js
Normal file
133
assets/js/http/providers_http_client.js
Normal file
@ -0,0 +1,133 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.5.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Providers HTTP client.
|
||||
*
|
||||
* This module implements the providers related HTTP requests.
|
||||
*/
|
||||
App.Http.Providers = (function () {
|
||||
/**
|
||||
* Save (create or update) a provider.
|
||||
*
|
||||
* @param {Object} provider
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function save(provider) {
|
||||
return provider.id ? update(provider) : store(provider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a provider.
|
||||
*
|
||||
* @param {Object} provider
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function store(provider) {
|
||||
const url = App.Utils.Url.siteUrl('providers/store');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
provider: provider,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a provider.
|
||||
*
|
||||
* @param {Object} provider
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function update(provider) {
|
||||
const url = App.Utils.Url.siteUrl('providers/update');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
provider: provider,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a provider.
|
||||
*
|
||||
* @param {Number} providerId
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function destroy(providerId) {
|
||||
const url = App.Utils.Url.siteUrl('providers/destroy');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
provider_id: providerId,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search providers by keyword.
|
||||
*
|
||||
* @param {String} keyword
|
||||
* @param {Number} [limit]
|
||||
* @param {Number} [offset]
|
||||
* @param {String} [orderBy]
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function search(keyword, limit = null, offset = null, orderBy = null) {
|
||||
const url = App.Utils.Url.siteUrl('providers/search');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
keyword,
|
||||
limit,
|
||||
offset,
|
||||
order_by: orderBy || undefined,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a provider.
|
||||
*
|
||||
* @param {Number} providerId
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function find(providerId) {
|
||||
const url = App.Utils.Url.siteUrl('providers/find');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
provider_id: providerId,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
return {
|
||||
save,
|
||||
store,
|
||||
update,
|
||||
destroy,
|
||||
search,
|
||||
find,
|
||||
};
|
||||
})();
|
41
assets/js/http/recovery_http_client.js
Normal file
41
assets/js/http/recovery_http_client.js
Normal file
@ -0,0 +1,41 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.5.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Recovery HTTP client.
|
||||
*
|
||||
* This module implements the account recovery related HTTP requests.
|
||||
*/
|
||||
App.Http.Recovery = (function () {
|
||||
/**
|
||||
* Perform an account recovery.
|
||||
*
|
||||
* @param {String} username
|
||||
* @param {String} email
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function perform(username, email) {
|
||||
const url = App.Utils.Url.siteUrl('recovery/perform');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
username,
|
||||
email,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
return {
|
||||
perform,
|
||||
};
|
||||
})();
|
133
assets/js/http/secretaries_http_client.js
Normal file
133
assets/js/http/secretaries_http_client.js
Normal file
@ -0,0 +1,133 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.5.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Secretaries HTTP client.
|
||||
*
|
||||
* This module implements the secretaries related HTTP requests.
|
||||
*/
|
||||
App.Http.Secretaries = (function () {
|
||||
/**
|
||||
* Save (create or update) a secretary.
|
||||
*
|
||||
* @param {Object} secretary
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function save(secretary) {
|
||||
return secretary.id ? update(secretary) : store(secretary);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a secretary.
|
||||
*
|
||||
* @param {Object} secretary
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function store(secretary) {
|
||||
const url = App.Utils.Url.siteUrl('secretaries/store');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
secretary: secretary,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a secretary.
|
||||
*
|
||||
* @param {Object} secretary
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function update(secretary) {
|
||||
const url = App.Utils.Url.siteUrl('secretaries/update');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
secretary: secretary,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a secretary.
|
||||
*
|
||||
* @param {Number} secretaryId
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function destroy(secretaryId) {
|
||||
const url = App.Utils.Url.siteUrl('secretaries/destroy');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
secretary_id: secretaryId,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search secretaries by keyword.
|
||||
*
|
||||
* @param {String} keyword
|
||||
* @param {Number} [limit]
|
||||
* @param {Number} [offset]
|
||||
* @param {String} [orderBy]
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function search(keyword, limit = null, offset = null, orderBy = null) {
|
||||
const url = App.Utils.Url.siteUrl('secretaries/search');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
keyword,
|
||||
limit,
|
||||
offset,
|
||||
order_by: orderBy || undefined,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a secretary.
|
||||
*
|
||||
* @param {Number} secretaryId
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function find(secretaryId) {
|
||||
const url = App.Utils.Url.siteUrl('secretaries/find');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
secretary_id: secretaryId,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
return {
|
||||
save,
|
||||
store,
|
||||
update,
|
||||
destroy,
|
||||
search,
|
||||
find,
|
||||
};
|
||||
})();
|
133
assets/js/http/service_categories_http_client.js
Normal file
133
assets/js/http/service_categories_http_client.js
Normal file
@ -0,0 +1,133 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.5.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Service-categories HTTP client.
|
||||
*
|
||||
* This module implements the service-categories related HTTP requests.
|
||||
*/
|
||||
App.Http.ServiceCategories = (function () {
|
||||
/**
|
||||
* Save (create or update) a service-category.
|
||||
*
|
||||
* @param {Object} serviceCategory
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function save(serviceCategory) {
|
||||
return serviceCategory.id ? update(serviceCategory) : store(serviceCategory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a service-category.
|
||||
*
|
||||
* @param {Object} serviceCategory
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function store(serviceCategory) {
|
||||
const url = App.Utils.Url.siteUrl('service_categories/store');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
service_category: serviceCategory,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a service-category.
|
||||
*
|
||||
* @param {Object} serviceCategory
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function update(serviceCategory) {
|
||||
const url = App.Utils.Url.siteUrl('service_categories/update');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
service_category: serviceCategory,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a service-category.
|
||||
*
|
||||
* @param {Number} serviceCategoryId
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function destroy(serviceCategoryId) {
|
||||
const url = App.Utils.Url.siteUrl('service_categories/destroy');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
service_category_id: serviceCategoryId,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search service-categories by keyword.
|
||||
*
|
||||
* @param {String} keyword
|
||||
* @param {Number} [limit]
|
||||
* @param {Number} [offset]
|
||||
* @param {String} [orderBy]
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function search(keyword, limit = null, offset = null, orderBy = null) {
|
||||
const url = App.Utils.Url.siteUrl('service_categories/search');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
keyword,
|
||||
limit,
|
||||
offset,
|
||||
order_by: orderBy || undefined,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a service-category.
|
||||
*
|
||||
* @param {Number} serviceCategoryId
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function find(serviceCategoryId) {
|
||||
const url = App.Utils.Url.siteUrl('service_categories/find');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
service_category_id: serviceCategoryId,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
return {
|
||||
save,
|
||||
store,
|
||||
update,
|
||||
destroy,
|
||||
search,
|
||||
find,
|
||||
};
|
||||
})();
|
133
assets/js/http/services_http_client.js
Normal file
133
assets/js/http/services_http_client.js
Normal file
@ -0,0 +1,133 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.5.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Services HTTP client.
|
||||
*
|
||||
* This module implements the services related HTTP requests.
|
||||
*/
|
||||
App.Http.Services = (function () {
|
||||
/**
|
||||
* Save (create or update) a service.
|
||||
*
|
||||
* @param {Object} service
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function save(service) {
|
||||
return service.id ? update(service) : store(service);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an service.
|
||||
*
|
||||
* @param {Object} service
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function store(service) {
|
||||
const url = App.Utils.Url.siteUrl('services/store');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
service: service,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an service.
|
||||
*
|
||||
* @param {Object} service
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function update(service) {
|
||||
const url = App.Utils.Url.siteUrl('services/update');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
service: service,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an service.
|
||||
*
|
||||
* @param {Number} serviceId
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function destroy(serviceId) {
|
||||
const url = App.Utils.Url.siteUrl('services/destroy');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
service_id: serviceId,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search services by keyword.
|
||||
*
|
||||
* @param {String} keyword
|
||||
* @param {Number} [limit]
|
||||
* @param {Number} [offset]
|
||||
* @param {String} [orderBy]
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function search(keyword, limit = null, offset = null, orderBy = null) {
|
||||
const url = App.Utils.Url.siteUrl('services/search');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
keyword,
|
||||
limit,
|
||||
offset,
|
||||
order_by: orderBy || undefined,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an service.
|
||||
*
|
||||
* @param {Number} serviceId
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function find(serviceId) {
|
||||
const url = App.Utils.Url.siteUrl('services/find');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
service_id: serviceId,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
return {
|
||||
save,
|
||||
store,
|
||||
update,
|
||||
destroy,
|
||||
search,
|
||||
find,
|
||||
};
|
||||
})();
|
133
assets/js/http/settings_http_client.js
Normal file
133
assets/js/http/settings_http_client.js
Normal file
@ -0,0 +1,133 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.5.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Settings HTTP client.
|
||||
*
|
||||
* This module implements the settings related HTTP requests.
|
||||
*/
|
||||
App.Http.Settings = (function () {
|
||||
/**
|
||||
* Save (create or update) a setting.
|
||||
*
|
||||
* @param {Object} setting
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function save(setting) {
|
||||
return setting.id ? update(setting) : create(setting);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an setting.
|
||||
*
|
||||
* @param {Object} setting
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function create(setting) {
|
||||
const url = App.Utils.Url.siteUrl('settings/create');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
setting: setting,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an setting.
|
||||
*
|
||||
* @param {Object} setting
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function update(setting) {
|
||||
const url = App.Utils.Url.siteUrl('settings/update');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
setting: setting,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an setting.
|
||||
*
|
||||
* @param {Number} settingId
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function destroy(settingId) {
|
||||
const url = App.Utils.Url.siteUrl('settings/destroy');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
setting_id: settingId,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search settings by keyword.
|
||||
*
|
||||
* @param {String} keyword
|
||||
* @param {Number} [limit]
|
||||
* @param {Number} [offset]
|
||||
* @param {String} [orderBy]
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function search(keyword, limit = null, offset = null, orderBy = null) {
|
||||
const url = App.Utils.Url.siteUrl('settings/search');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
keyword,
|
||||
limit,
|
||||
offset,
|
||||
order_by: orderBy || undefined,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an setting.
|
||||
*
|
||||
* @param {Number} settingId
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function find(settingId) {
|
||||
const url = App.Utils.Url.siteUrl('settings/find');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
setting_id: settingId,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
return {
|
||||
save,
|
||||
create,
|
||||
update,
|
||||
destroy,
|
||||
search,
|
||||
find,
|
||||
};
|
||||
})();
|
133
assets/js/http/unavailabilities_http_client.js
Normal file
133
assets/js/http/unavailabilities_http_client.js
Normal file
@ -0,0 +1,133 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.5.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Unavailabilities HTTP client.
|
||||
*
|
||||
* This module implements the unavailabilities related HTTP requests.
|
||||
*/
|
||||
App.Http.Unavailabilities = (function () {
|
||||
/**
|
||||
* Save (create or update) an unavailability.
|
||||
*
|
||||
* @param {Object} unavailability
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function save(unavailability) {
|
||||
return unavailability.id ? update(unavailability) : store(unavailability);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an unavailability.
|
||||
*
|
||||
* @param {Object} unavailability
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function store(unavailability) {
|
||||
const url = App.Utils.Url.siteUrl('unavailabilities/store');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
unavailability: unavailability,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an unavailability.
|
||||
*
|
||||
* @param {Object} unavailability
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function update(unavailability) {
|
||||
const url = App.Utils.Url.siteUrl('unavailabilities/update');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
unavailability: unavailability,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an unavailability.
|
||||
*
|
||||
* @param {Number} unavailabilityId
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function destroy(unavailabilityId) {
|
||||
const url = App.Utils.Url.siteUrl('unavailabilities/destroy');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
unavailability_id: unavailabilityId,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search unavailabilities by keyword.
|
||||
*
|
||||
* @param {String} keyword
|
||||
* @param {Number} [limit]
|
||||
* @param {Number} [offset]
|
||||
* @param {String} [orderBy]
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function search(keyword, limit = null, offset = null, orderBy = null) {
|
||||
const url = App.Utils.Url.siteUrl('unavailabilities/search');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
keyword,
|
||||
limit,
|
||||
offset,
|
||||
order_by: orderBy || undefined,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an unavailability.
|
||||
*
|
||||
* @param {Number} unavailabilityId
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function find(unavailabilityId) {
|
||||
const url = App.Utils.Url.siteUrl('unavailabilities/find');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
unavailability_id: unavailabilityId,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
return {
|
||||
save,
|
||||
store,
|
||||
update,
|
||||
destroy,
|
||||
search,
|
||||
find,
|
||||
};
|
||||
})();
|
133
assets/js/http/webhooks_http_client.js
Normal file
133
assets/js/http/webhooks_http_client.js
Normal file
@ -0,0 +1,133 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Easy!Appointments - Online Appointment Scheduler
|
||||
*
|
||||
* @package EasyAppointments
|
||||
* @author A.Tselegidis <alextselegidis@gmail.com>
|
||||
* @copyright Copyright (c) Alex Tselegidis
|
||||
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
||||
* @link https://easyappointments.org
|
||||
* @since v1.5.0
|
||||
* ---------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Webhooks HTTP client.
|
||||
*
|
||||
* This module implements the webhooks related HTTP requests.
|
||||
*/
|
||||
App.Http.Webhooks = (function () {
|
||||
/**
|
||||
* Save (create or update) a webhook.
|
||||
*
|
||||
* @param {Object} webhook
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function save(webhook) {
|
||||
return webhook.id ? update(webhook) : store(webhook);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an webhook.
|
||||
*
|
||||
* @param {Object} webhook
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function store(webhook) {
|
||||
const url = App.Utils.Url.siteUrl('webhooks/store');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
webhook: webhook,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an webhook.
|
||||
*
|
||||
* @param {Object} webhook
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function update(webhook) {
|
||||
const url = App.Utils.Url.siteUrl('webhooks/update');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
webhook: webhook,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an webhook.
|
||||
*
|
||||
* @param {Number} webhookId
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function destroy(webhookId) {
|
||||
const url = App.Utils.Url.siteUrl('webhooks/destroy');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
webhook_id: webhookId,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search webhooks by keyword.
|
||||
*
|
||||
* @param {String} keyword
|
||||
* @param {Number} [limit]
|
||||
* @param {Number} [offset]
|
||||
* @param {String} [orderBy]
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function search(keyword, limit = null, offset = null, orderBy = null) {
|
||||
const url = App.Utils.Url.siteUrl('webhooks/search');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
keyword,
|
||||
limit,
|
||||
offset,
|
||||
order_by: orderBy || undefined,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an webhook.
|
||||
*
|
||||
* @param {Number} webhookId
|
||||
*
|
||||
* @return {Object}
|
||||
*/
|
||||
function find(webhookId) {
|
||||
const url = App.Utils.Url.siteUrl('webhooks/find');
|
||||
|
||||
const data = {
|
||||
csrf_token: vars('csrf_token'),
|
||||
webhook_id: webhookId,
|
||||
};
|
||||
|
||||
return $.post(url, data);
|
||||
}
|
||||
|
||||
return {
|
||||
save,
|
||||
store,
|
||||
update,
|
||||
destroy,
|
||||
search,
|
||||
find,
|
||||
};
|
||||
})();
|
Reference in New Issue
Block a user