easyappointments/assets/js/frontend_book.js

725 lines
28 KiB
JavaScript
Raw Normal View History

2015-07-20 22:41:24 +03:00
/* ----------------------------------------------------------------------------
* Easy!Appointments - Open Source Web Scheduler
*
2015-07-20 22:41:24 +03:00
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) 2013 - 2020, Alex Tselegidis
* @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-26 22:51:16 +03:00
window.FrontendBook = window.FrontendBook || {};
/**
2016-04-26 22:51:16 +03:00
* Frontend Book
*
* This module contains functions that implement the book appointment page functionality. Once the
* initialize() method is called the page is fully functional and can serve the appointment booking
* process.
*
2016-04-26 22:51:16 +03:00
* @module FrontendBook
*/
2018-01-23 12:08:37 +03:00
(function (exports) {
2016-04-26 22:51:16 +03:00
'use strict';
/**
* Contains terms and conditions consent.
*
* @type {Object}
*/
var termsAndConditionsConsent;
/**
* Contains privacy policy consent.
*
* @type {Object}
*/
var privacyPolicyConsent;
/**
* Determines the functionality of the page.
*
* @type {Boolean}
*/
2016-04-26 22:51:16 +03:00
exports.manageMode = false;
/**
* This method initializes the book appointment page.
*
* @param {Boolean} bindEventHandlers (OPTIONAL) Determines whether the default
2016-10-10 19:29:48 +03:00
* event handlers will be bound to the dom elements.
* @param {Boolean} manageMode (OPTIONAL) Determines whether the customer is going
* to make changes to an existing appointment rather than booking a new one.
*/
2018-01-23 12:08:37 +03:00
exports.initialize = function (bindEventHandlers, manageMode) {
2016-04-26 22:51:16 +03:00
bindEventHandlers = bindEventHandlers || true;
manageMode = manageMode || false;
2016-01-01 22:57:44 +02:00
if (window.console === undefined) {
2018-01-23 12:08:37 +03:00
window.console = function () {
}; // IE compatibility
2016-01-01 22:57:44 +02:00
}
2020-03-29 17:20:30 +03:00
if (GlobalVariables.displayCookieNotice) {
cookieconsent.initialise({
palette: {
popup: {
background: '#ffffffbd',
text: '#666666'
},
button: {
background: '#3DD481',
text: '#ffffff'
}
},
content: {
message: EALang.website_using_cookies_to_ensure_best_experience,
dismiss: 'OK'
},
});
$('.cc-link').replaceWith(
$('<a/>', {
'data-toggle': 'modal',
'data-target': '#cookie-notice-modal',
'href': '#',
'class': 'cc-link',
'text': $('.cc-link').text()
})
);
}
2016-01-01 22:57:44 +02:00
FrontendBook.manageMode = manageMode;
// Initialize page's components (tooltips, datepickers etc).
$('.book-step').qtip({
position: {
my: 'top center',
at: 'bottom center'
},
style: {
classes: 'qtip-green qtip-shadow custom-qtip'
}
});
var fDay = GlobalVariables.firstWeekday;
var fDaynum = GeneralFunctions.getWeekDayId(fDay);
$('#select-date').datepicker({
dateFormat: 'dd-mm-yy',
firstDay: fDaynum,
minDate: 0,
defaultDate: Date.today(),
dayNames: [
2018-01-23 12:08:37 +03:00
EALang.sunday, EALang.monday, EALang.tuesday, EALang.wednesday,
EALang.thursday, EALang.friday, EALang.saturday],
dayNamesShort: [EALang.sunday.substr(0, 3), EALang.monday.substr(0, 3),
EALang.tuesday.substr(0, 3), EALang.wednesday.substr(0, 3),
EALang.thursday.substr(0, 3), EALang.friday.substr(0, 3),
EALang.saturday.substr(0, 3)],
dayNamesMin: [EALang.sunday.substr(0, 2), EALang.monday.substr(0, 2),
EALang.tuesday.substr(0, 2), EALang.wednesday.substr(0, 2),
EALang.thursday.substr(0, 2), EALang.friday.substr(0, 2),
EALang.saturday.substr(0, 2)],
monthNames: [EALang.january, EALang.february, EALang.march, EALang.april,
2018-01-23 12:08:37 +03:00
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,
2018-01-23 12:08:37 +03:00
onSelect: function (dateText, instance) {
FrontendBookApi.getAvailableHours($(this).datepicker('getDate').toString('yyyy-MM-dd'));
FrontendBook.updateConfirmFrame();
},
2018-01-23 12:08:37 +03:00
onChangeMonthYear: function (year, month, instance) {
var currentDate = new Date(year, month - 1, 1);
FrontendBookApi.getUnavailableDates($('#select-provider').val(), $('#select-service').val(),
2018-01-23 12:08:37 +03:00
currentDate.toString('yyyy-MM-dd'));
}
});
2020-03-29 17:20:30 +03:00
$('#select-timezone').val(Intl.DateTimeFormat().resolvedOptions().timeZone);
// Bind the event handlers (might not be necessary every time we use this class).
if (bindEventHandlers) {
2016-04-26 22:51:16 +03:00
_bindEventHandlers();
}
// If the manage mode is true, the appointments data should be loaded by default.
if (FrontendBook.manageMode) {
2016-04-26 22:51:16 +03:00
_applyAppointmentData(GlobalVariables.appointmentData,
2018-01-23 12:08:37 +03:00
GlobalVariables.providerData, GlobalVariables.customerData);
} else {
var $selectProvider = $('#select-provider');
2018-01-23 12:08:37 +03:00
var $selectService = $('#select-service');
// Check if a specific service was selected (via URL parameter).
var selectedServiceId = GeneralFunctions.getUrlParameter(location.href, 'service');
if (selectedServiceId && $selectService.find('option[value="' + selectedServiceId + '"]').length > 0) {
$selectService.val(selectedServiceId);
}
$selectService.trigger('change'); // Load the available hours.
2020-03-29 17:20:30 +03:00
// Check if a specific provider was selected.
var selectedProviderId = GeneralFunctions.getUrlParameter(location.href, 'provider');
2018-01-23 12:08:37 +03:00
if (selectedProviderId && $selectProvider.find('option[value="' + selectedProviderId + '"]').length === 0) {
2020-03-29 17:20:30 +03:00
// Select a service of this provider in order to make the provider available in the select box.
for (var index in GlobalVariables.availableProviders) {
2018-01-23 12:08:37 +03:00
var provider = GlobalVariables.availableProviders[index];
if (provider.id === selectedProviderId && provider.services.length > 0) {
$selectService
.val(provider.services[0])
.trigger('change');
}
}
}
if (selectedProviderId && $selectProvider.find('option[value="' + selectedProviderId + '"]').length > 0) {
$selectProvider
.val(selectedProviderId)
.trigger('change');
}
}
2016-04-26 22:51:16 +03:00
};
/**
2016-04-26 22:51:16 +03:00
* This method binds the necessary event handlers for the book appointments page.
*/
2016-04-26 22:51:16 +03:00
function _bindEventHandlers() {
2020-03-29 17:20:30 +03:00
/**
* Event: Timezone "Changed"
*/
$('#select-timezone').on('change', function () {
var date = $('#select-date').datepicker('getDate');
if (!date) {
return;
}
FrontendBookApi.getAvailableHours(date.toString('yyyy-MM-dd'));
FrontendBook.updateConfirmFrame();
});
/**
* Event: Selected Provider "Changed"
*
* Whenever the provider changes the available appointment date - time periods must be updated.
*/
2018-01-23 12:08:37 +03:00
$('#select-provider').change(function () {
FrontendBookApi.getUnavailableDates($(this).val(), $('#select-service').val(),
2018-01-23 12:08:37 +03:00
$('#select-date').datepicker('getDate').toString('yyyy-MM-dd'));
FrontendBook.updateConfirmFrame();
});
/**
* Event: Selected Service "Changed"
*
* When the user clicks on a service, its available providers should
* become visible.
*/
2018-01-23 12:08:37 +03:00
$('#select-service').change(function () {
var currServiceId = $('#select-service').val();
$('#select-provider').empty();
2018-01-23 12:08:37 +03:00
$.each(GlobalVariables.availableProviders, function (indexProvider, provider) {
$.each(provider.services, function (indexService, serviceId) {
// If the current provider is able to provide the selected service,
// add him to the listbox.
if (serviceId == currServiceId) {
var optionHtml = '<option value="' + provider.id + '">'
2018-01-23 12:08:37 +03:00
+ provider.first_name + ' ' + provider.last_name
+ '</option>';
$('#select-provider').append(optionHtml);
}
});
});
// Add the "Any Provider" entry.
if ($('#select-provider option').length >= 1) {
$('#select-provider').append(new Option('- ' + EALang.any_provider + ' -', 'any-provider'));
}
FrontendBookApi.getUnavailableDates($('#select-provider').val(), $(this).val(),
2018-01-23 12:08:37 +03:00
$('#select-date').datepicker('getDate').toString('yyyy-MM-dd'));
FrontendBook.updateConfirmFrame();
2018-01-23 12:08:37 +03:00
_updateServiceDescription($('#select-service').val(), $('#service-description'));
});
/**
* Event: Next Step Button "Clicked"
*
* This handler is triggered every time the user pressed the "next" button on the book wizard.
2016-10-10 19:29:48 +03:00
* Some special tasks might be performed, depending the current wizard step.
*/
2018-01-23 12:08:37 +03:00
$('.button-next').click(function () {
// If we are on the first step and there is not provider selected do not continue
// with the next step.
if ($(this).attr('data-step_index') === '1' && $('#select-provider').val() == null) {
return;
}
// If we are on the 2nd tab then the user should have an appointment hour
// selected.
if ($(this).attr('data-step_index') === '2') {
if ($('.selected-hour').length == 0) {
if ($('#select-hour-prompt').length == 0) {
$('#available-hours').append('<br><br>'
2018-01-23 12:08:37 +03:00
+ '<span id="select-hour-prompt" class="text-danger">'
+ EALang.appointment_hour_missing
+ '</span>');
}
return;
}
}
// If we are on the 3rd tab then we will need to validate the user's
// input before proceeding to the next step.
if ($(this).attr('data-step_index') === '3') {
2016-04-26 22:51:16 +03:00
if (!_validateCustomerForm()) {
return; // Validation failed, do not continue.
} else {
FrontendBook.updateConfirmFrame();
var $acceptToTermsAndConditions = $('#accept-to-terms-and-conditions');
if ($acceptToTermsAndConditions.length && $acceptToTermsAndConditions.prop('checked') === true) {
var newTermsAndConditionsConsent = {
first_name: $('#first-name').val(),
last_name: $('#last-name').val(),
email: $('#email').val(),
type: 'terms-and-conditions'
};
if (JSON.stringify(newTermsAndConditionsConsent) !== JSON.stringify(termsAndConditionsConsent)) {
termsAndConditionsConsent = newTermsAndConditionsConsent;
FrontendBookApi.saveConsent(termsAndConditionsConsent);
}
}
var $acceptToPrivacyPolicy = $('#accept-to-privacy-policy');
if ($acceptToPrivacyPolicy.length && $acceptToPrivacyPolicy.prop('checked') === true) {
var newPrivacyPolicyConsent = {
first_name: $('#first-name').val(),
last_name: $('#last-name').val(),
email: $('#email').val(),
type: 'privacy-policy'
};
if (JSON.stringify(newPrivacyPolicyConsent) !== JSON.stringify(privacyPolicyConsent)) {
privacyPolicyConsent = newPrivacyPolicyConsent;
FrontendBookApi.saveConsent(privacyPolicyConsent);
}
}
}
}
// Display the next step tab (uses jquery animation effect).
var nextTabIndex = parseInt($(this).attr('data-step_index')) + 1;
2018-01-23 12:08:37 +03:00
$(this).parents().eq(1).hide('fade', function () {
$('.active-step').removeClass('active-step');
$('#step-' + nextTabIndex).addClass('active-step');
$('#wizard-frame-' + nextTabIndex).show('fade');
});
});
/**
* Event: Back Step Button "Clicked"
*
* This handler is triggered every time the user pressed the "back" button on the
* book wizard.
*/
2018-01-23 12:08:37 +03:00
$('.button-back').click(function () {
var prevTabIndex = parseInt($(this).attr('data-step_index')) - 1;
2018-01-23 12:08:37 +03:00
$(this).parents().eq(1).hide('fade', function () {
$('.active-step').removeClass('active-step');
$('#step-' + prevTabIndex).addClass('active-step');
$('#wizard-frame-' + prevTabIndex).show('fade');
});
});
/**
* Event: Available Hour "Click"
*
* Triggered whenever the user clicks on an available hour
* for his appointment.
*/
2018-01-23 12:08:37 +03:00
$('#available-hours').on('click', '.available-hour', function () {
$('.selected-hour').removeClass('selected-hour');
$(this).addClass('selected-hour');
FrontendBook.updateConfirmFrame();
});
if (FrontendBook.manageMode) {
/**
* Event: Cancel Appointment Button "Click"
*
* When the user clicks the "Cancel" button this form is going to be submitted. We need
* the user to confirm this action because once the appointment is cancelled, it will be
* delete from the database.
*
* @param {jQuery.Event} event
*/
2018-01-23 12:08:37 +03:00
$('#cancel-appointment').click(function (event) {
var buttons = [
{
text: 'OK',
2018-01-23 12:08:37 +03:00
click: function () {
if ($('#cancel-reason').val() === '') {
$('#cancel-reason').css('border', '2px solid red');
return;
}
$('#cancel-appointment-form textarea').val($('#cancel-reason').val());
$('#cancel-appointment-form').submit();
}
},
{
text: EALang.cancel,
2018-01-23 12:08:37 +03:00
click: function () {
$('#message_box').dialog('close');
}
}
];
GeneralFunctions.displayMessageBox(EALang.cancel_appointment_title,
2018-01-23 12:08:37 +03:00
EALang.write_appointment_removal_reason, buttons);
$('#message_box').append('<textarea id="cancel-reason" rows="3"></textarea>');
$('#cancel-reason').css('width', '100%');
2014-01-04 00:26:10 +02:00
return false;
});
$('#delete-personal-information').on('click', function () {
var buttons = [
{
text: EALang.delete,
click: function () {
FrontendBookApi.deletePersonalInformation(GlobalVariables.customerToken);
}
},
{
text: EALang.cancel,
click: function () {
$('#message_box').dialog('close');
}
}
];
GeneralFunctions.displayMessageBox(EALang.delete_personal_information,
EALang.delete_personal_information_prompt, buttons);
});
}
/**
* Event: Book Appointment Form "Submit"
*
* Before the form is submitted to the server we need to make sure that
* in the meantime the selected appointment date/time wasn't reserved by
* another customer or event.
*
* @param {jQuery.Event} event
*/
2018-01-23 12:08:37 +03:00
$('#book-appointment-submit').click(function (event) {
FrontendBookApi.registerAppointment();
});
/**
* Event: Refresh captcha image.
*
* @param {jQuery.Event} event
*/
2018-01-23 12:08:37 +03:00
$('.captcha-title small').click(function (event) {
$('.captcha-image').attr('src', GlobalVariables.baseUrl + '/index.php/captcha?' + Date.now());
});
2018-01-23 12:08:37 +03:00
$('#select-date').on('mousedown', '.ui-datepicker-calendar td', function (event) {
setTimeout(function () {
FrontendBookApi.applyPreviousUnavailableDates(); // New jQuery UI version will replace the td elements.
}, 300); // There is no draw event unfortunately.
})
}
/**
2016-10-10 19:29:48 +03:00
* This function validates the customer's data input. The user cannot continue
* without passing all the validation checks.
*
* @return {Boolean} Returns the validation result.
*/
2016-04-26 22:51:16 +03:00
function _validateCustomerForm() {
$('#wizard-frame-3 .has-error').removeClass('has-error');
$('#wizard-frame-3 label.text-danger').removeClass('text-danger');
try {
// Validate required fields.
var missingRequiredField = false;
2018-01-23 12:08:37 +03:00
$('.required').each(function () {
if ($(this).val() == '') {
2015-04-09 22:50:16 +03:00
$(this).parents('.form-group').addClass('has-error');
missingRequiredField = true;
}
});
if (missingRequiredField) {
throw EALang.fields_are_required;
}
var $acceptToTermsAndConditions = $('#accept-to-terms-and-conditions');
if ($acceptToTermsAndConditions.length && !$acceptToTermsAndConditions.prop('checked')) {
$acceptToTermsAndConditions.parents('label').addClass('text-danger');
throw EALang.fields_are_required;
}
var $acceptToPrivacyPolicy = $('#accept-to-privacy-policy');
if ($acceptToPrivacyPolicy.length && !$acceptToPrivacyPolicy.prop('checked')) {
$acceptToPrivacyPolicy.parents('label').addClass('text-danger');
throw EALang.fields_are_required;
}
// Validate email address.
if (!GeneralFunctions.validateEmail($('#email').val())) {
2015-04-09 22:50:16 +03:00
$('#email').parents('.form-group').addClass('has-error');
throw EALang.invalid_email;
}
return true;
2018-01-23 12:08:37 +03:00
} catch (exc) {
$('#form-message').text(exc);
return false;
}
2016-04-26 22:51:16 +03:00
}
/**
* Every time this function is executed, it updates the confirmation page with the latest
2016-10-10 19:29:48 +03:00
* customer settings and input for the appointment booking.
*/
2018-01-23 12:08:37 +03:00
exports.updateConfirmFrame = function () {
2017-10-31 14:56:29 +03:00
if ($('.selected-hour').text() === '') {
return;
}
// Appointment Details
var selectedDate = $('#select-date').datepicker('getDate');
if (selectedDate !== null) {
selectedDate = GeneralFunctions.formatDate(selectedDate, GlobalVariables.dateFormat);
}
2016-07-15 21:52:21 +03:00
var selServiceId = $('#select-service').val();
var servicePrice = '';
var serviceCurrency = '';
2018-01-23 12:08:37 +03:00
$.each(GlobalVariables.availableServices, function (index, service) {
if (service.id == selServiceId && service.price != '' && service.price != null && service.price != '0.00' && service.price != '0,00') {
servicePrice = '<br>' + service.price;
serviceCurrency = service.currency;
return false; // break loop
}
});
var html =
'<h4>' + $('#select-service option:selected').text() + '</h4>' +
'<p>'
2018-01-23 12:08:37 +03:00
+ '<strong class="text-primary">'
+ $('#select-provider option:selected').text() + '<br>'
2020-03-29 17:20:30 +03:00
+ selectedDate + ' ' + $('.selected-hour').text() + '<br>' + $('#select-timezone option:selected').text()
2018-01-23 12:08:37 +03:00
+ servicePrice + ' ' + serviceCurrency
+ '</strong>' +
'</p>';
$('#appointment-details').html(html);
// Customer Details
2016-10-10 19:29:48 +03:00
var firstName = GeneralFunctions.escapeHtml($('#first-name').val());
var lastName = GeneralFunctions.escapeHtml($('#last-name').val());
2016-07-15 21:52:21 +03:00
var phoneNumber = GeneralFunctions.escapeHtml($('#phone-number').val());
var email = GeneralFunctions.escapeHtml($('#email').val());
var address = GeneralFunctions.escapeHtml($('#address').val());
var city = GeneralFunctions.escapeHtml($('#city').val());
var zipCode = GeneralFunctions.escapeHtml($('#zip-code').val());
html =
2016-10-10 19:29:48 +03:00
'<h4>' + firstName + ' ' + lastName + '</h4>' +
'<p>' +
EALang.phone_number + ': ' + phoneNumber +
2018-01-23 12:08:37 +03:00
'<br/>' +
EALang.email + ': ' + email +
'<br/>' +
EALang.address + ': ' + address +
'<br/>' +
EALang.city + ': ' + city +
'<br/>' +
EALang.zip_code + ': ' + zipCode +
'</p>';
$('#customer-details').html(html);
// Update appointment form data for submission to server when the user confirms
// the appointment.
var postData = {};
postData.customer = {
2016-04-26 22:51:16 +03:00
last_name: $('#last-name').val(),
first_name: $('#first-name').val(),
email: $('#email').val(),
phone_number: $('#phone-number').val(),
address: $('#address').val(),
city: $('#city').val(),
2020-03-29 17:20:30 +03:00
zip_code: $('#zip-code').val(),
timezone: $('#select-timezone').val()
};
postData.appointment = {
2016-04-26 22:51:16 +03:00
start_datetime: $('#select-date').datepicker('getDate').toString('yyyy-MM-dd')
2018-01-23 12:08:37 +03:00
+ ' ' + Date.parse($('.selected-hour').text()).toString('HH:mm') + ':00',
2016-04-26 22:51:16 +03:00
end_datetime: _calcEndDatetime(),
notes: $('#notes').val(),
is_unavailable: false,
id_users_provider: $('#select-provider').val(),
id_services: $('#select-service').val()
};
postData.manage_mode = FrontendBook.manageMode;
if (FrontendBook.manageMode) {
postData.appointment.id = GlobalVariables.appointmentData.id;
postData.customer.id = GlobalVariables.customerData.id;
}
2015-05-28 00:26:36 +03:00
$('input[name="csrfToken"]').val(GlobalVariables.csrfToken);
$('input[name="post_data"]').val(JSON.stringify(postData));
2016-10-10 19:29:48 +03:00
};
/**
* This method calculates the end datetime of the current appointment.
2016-10-10 19:29:48 +03:00
* End datetime is depending on the service and start datetime fields.
*
* @return {String} Returns the end datetime in string format.
*/
2016-04-26 22:51:16 +03:00
function _calcEndDatetime() {
// Find selected service duration.
var selServiceDuration = undefined;
2018-01-23 12:08:37 +03:00
$.each(GlobalVariables.availableServices, function (index, service) {
if (service.id == $('#select-service').val()) {
selServiceDuration = service.duration;
return false; // Stop searching ...
}
});
// Add the duration to the start datetime.
var startDatetime = $('#select-date').datepicker('getDate').toString('dd-MM-yyyy')
2018-01-23 12:08:37 +03:00
+ ' ' + Date.parse($('.selected-hour').text()).toString('HH:mm');
startDatetime = Date.parseExact(startDatetime, 'dd-MM-yyyy HH:mm');
var endDatetime = undefined;
if (selServiceDuration !== undefined && startDatetime !== null) {
2018-01-23 12:08:37 +03:00
endDatetime = startDatetime.add({'minutes': parseInt(selServiceDuration)});
} else {
endDatetime = new Date();
}
return endDatetime.toString('yyyy-MM-dd HH:mm:ss');
2016-04-26 22:51:16 +03:00
}
/**
* This method applies the appointment's data to the wizard so
* that the user can start making changes on an existing record.
*
* @param {Object} appointment Selected appointment's data.
* @param {Object} provider Selected provider's data.
* @param {Object} customer Selected customer's data.
*
* @return {Boolean} Returns the operation result.
*/
2016-04-26 22:51:16 +03:00
function _applyAppointmentData(appointment, provider, customer) {
try {
// Select Service & Provider
$('#select-service').val(appointment.id_services).trigger('change');
$('#select-provider').val(appointment.id_users_provider);
// Set Appointment Date
$('#select-date').datepicker('setDate',
2018-01-23 12:08:37 +03:00
Date.parseExact(appointment.start_datetime, 'yyyy-MM-dd HH:mm:ss'));
FrontendBookApi.getAvailableHours($('#select-date').val());
// Apply Customer's Data
$('#last-name').val(customer.last_name);
$('#first-name').val(customer.first_name);
$('#email').val(customer.email);
$('#phone-number').val(customer.phone_number);
$('#address').val(customer.address);
$('#city').val(customer.city);
$('#zip-code').val(customer.zip_code);
var appointmentNotes = (appointment.notes !== null)
2018-01-23 12:08:37 +03:00
? appointment.notes : '';
$('#notes').val(appointmentNotes);
FrontendBook.updateConfirmFrame();
return true;
2018-01-23 12:08:37 +03:00
} catch (exc) {
return false;
}
2016-04-26 22:51:16 +03:00
}
/**
* This method updates a div's html content with a brief description of the
2016-10-10 19:29:48 +03:00
* user selected service (only if available in db). This is useful for the
* customers upon selecting the correct service.
*
* @param {Number} serviceId The selected service record id.
* @param {Object} $div The destination div jquery object (e.g. provide $('#div-id')
* object as value).
*/
2016-04-26 22:51:16 +03:00
function _updateServiceDescription(serviceId, $div) {
var html = '';
2018-01-23 12:08:37 +03:00
$.each(GlobalVariables.availableServices, function (index, service) {
if (service.id == serviceId) { // Just found the service.
2013-11-23 21:10:31 +02:00
html = '<strong>' + service.name + ' </strong>';
if (service.description != '' && service.description != null) {
html += '<br>' + service.description + '<br>';
}
if (service.duration != '' && service.duration != null) {
2017-09-14 16:18:36 +03:00
html += '[' + EALang.duration + ' ' + service.duration + ' ' + EALang.minutes + ']';
}
if (service.price != '' && service.price != null && service.price != '0.00' && service.price != '0,00') {
2018-01-23 12:08:37 +03:00
html += '[' + EALang.price + ' ' + service.price + ' ' + service.currency + ']';
}
if (service.location != '' && service.location != null) {
html += '[' + EALang.location + ' ' + service.location + ']';
}
html += '<br>';
return false;
}
});
$div.html(html);
if (html != '') {
$div.show();
} else {
$div.hide();
}
2016-04-26 22:51:16 +03:00
}
2016-04-26 22:51:16 +03:00
})(window.FrontendBook);