process_request = null;
cached_process_id = null;
var subscribe = (function($, window, jQuery) {
var sched;
var _vars_ = {};
return {
"set_vars": function(options) {
$.extend(_vars_, options || {});
},
"get_vars": function() {
return _vars_;
},
"getCookie": function(name) {
var value = "; " + document.cookie;
var parts = value.split("; " + name + "=");
if (parts.length == 2)
return parts.pop().split(";").shift();
},
"prevent_page_load": function(btn, event_id, event_schedule_id, reg_type, action, process_type) {
var _cookie_data = decodeURIComponent(subscribe.getCookie("sdllmea"));
var _cookie_data_1 = decodeURIComponent(subscribe.getCookie("sdllmea"));
if ((_cookie_data.indexOf("logged_in") != -1 && _cookie_data.indexOf("LeMondeFO") != -1) || _cookie_data_1 != "undefined") {
// subscribe.check_closed_event(btn, event_id, event_schedule_id, reg_type, action, process_type); reg_type booking - 1, waitlist - 2
} else {
$.ajax({
url: app.get_vars().baseurl + "events/subscribe/save_link_to_cookie",
type: "POST",
data: {
event_id: event_id,
event_schedule_id: event_schedule_id
},
success: function(result) {
app._notify("error", app.get_vars()._app.notif.not_connected);
window.setTimeout(function() {
window.location.href = app.get_vars().baseurl + "login"
}, 2000);
}
});
/* enable button */
$(btn).prop("disabled", false);
}
},
"registration": {
"add_or_modify": {
"reservation": function(eventDetails, seat_feature, action, process_type) {
const reg_type = 1
const bp = false
var serverData = {
event_id: eventDetails.event_id,
//event_schedule_id: event_schedule_id,
action: action, //1-register, 2-modify, 3- cancel
seat_feature: seat_feature,
//check_subscription: check_subscription,
process_type: process_type,
session_type: subscribe.get_vars().session_type,
reg_type: reg_type,
request_type: 0,
event_category: eventDetails.event_category,
workshop_session: eventDetails.workshop_session,
bp: bp,
//is_user_moderated: is_user_moderated,
};
/* This solution fixed the bug #24568 */
if (cached_process_id) {
serverData.process_id = cached_process_id;
cached_process_id = null;
}
$.ajax({
url: app.get_vars().baseurl + 'events/subscribe/validate',
type: "POST",
data: serverData,
success: function(result) {
if(result.mtype === 'info') {
app._notify(result.mtype, result.message);
}
if (result.logged_out) {
window.location.replace('https://sdllmea-dev.wylog.com/login');
}
if (app.isalive(result)) {
if (result.mtype == "success")
{
/**
* Catch PAID event regular reservation
*/
if ( serverData.event_category === 'PAID_EVENT' && reg_type == 1 ) {
//remove the loading when modal shows up
//$('#waiting' + event_schedule_id).remove();
$(btn).prop("disabled", false);
$(btn).data('event_url') && window.open($(btn).data('event_url'), "_blank");
} else { // Regular event
let label, confBtnClass;
se = result.mdata.reservations ? result.mdata.reservations.seats_reserved : 0;
if (se > 0) {
confBtnClass = ((reg_type == 1) ? 'normal-ress' : 'reserve');
label = (reg_type == 1) ?
"Ajouter des places à ma réservation" :
app.get_vars()._app.btn._updatewaitlist;
} else {
confBtnClass = 'reserve';
label = (reg_type == 1) ?
app.get_vars()._app.btn._book :
app.get_vars()._app.btn._updatewaitlist;
}
$('#seats_reserved_text').text(seat_feature + (seat_feature>1?' places':' place'))
$('#address_text').text(eventDetails.event_address)
if(eventDetails.workshop_session== 'DISTANCE-PRESENTIEL' && subscribe.get_vars().session_type == 'soir-presentiel') {
$('#video_workshop_modal_content').hide()
$('#regular_workshop_modal_content').show()
} else if((eventDetails.workshop_session== 'DISTANCE-PRESENTIEL' && subscribe.get_vars().session_type == 'soir-distance') || eventDetails.workshop_session== 'DISTANCE') {
$('#video_workshop_modal_content').show()
$('#regular_workshop_modal_content').hide()
}
var form = $("#register-event-form");
/* Done waiting reserve */
$(".reserve-spinner").addClass("d-none");
$('.btn-reserve').removeAttr('disabled', true);
$('.btn-offer').removeAttr('disabled', true);
/* end */
bootbox.dialog({
// "title": subscribe.registration.options.title(reg_type, action, process_type),
"title": eventDetails.workshop_session == 'ENLIGNE' ?'Acheter le cours' : (eventDetails.workshop_session == 'DISTANCE-PRESENTIEL' ? 'Réserver le cours':subscribe.registration.options.title(reg_type, action, process_type)),
"className": "my-modal-with-sm event-normal-registration-modal custom-modal-ui table",
"message": form,
"cache": false,
"show": false,
/* We will show it manually later */
"buttons": [{
"label": app.get_vars()._app.btn._close,
"className": "btn btn-default-style2 btn-unlock-process",
"callback": function() {
//remove unbefore unload
$(window).off("beforeunload").off("unload");
//reset the timer when everything goes well
subscribe.button.exitp.clear({});
// clearTimeout(process_request);
$('#chkbox-error').hide();
}
}, {
// "label": label,
"label": eventDetails.workshop_session == 'ENLIGNE' ?'Acheter' : label,
"className": "btn btn-default-style mc-btn " + confBtnClass,
"callback": function() {
var seats_reserved = seat_feature //$('#number_of_seat_reserved').val();
var event_schedule = $('#schedule_id').val();
var seats_reserved_orig = parseInt($("#seats_reserved_info").data("seats_reserved"));
seats_reserved_orig = seats_reserved_orig ? seats_reserved_orig : 0;
if (parseInt(seats_reserved) >= 1 || eventDetails.workshop_session === 'ENLIGNE' || eventDetails.workshop_session === 'DISTANCE') {
$(".event-normal-registration-modal").modal('hide');
$("#chkbox-error").hide();
let validatedData = {
event_id: eventDetails.event_id,
action: action,
seat_feature: seat_feature ?? 1,
event_category: eventDetails.event_category,
process_type: process_type,
session_type: subscribe.get_vars().session_type,
reg_type: reg_type,
request_type: 0,
seats_reserved: seats_reserved ?? 1,
process_id: result.process_id,
workshop_session: eventDetails.workshop_session,
bp: bp
}
const paymentData = {
event_id: eventDetails.event_id,
seats_reserved: seats_reserved ?? 1,
booking: validatedData
}
subscribe.registration.add_or_modify.proceed_to_payment(paymentData)
//commented this to bypass saving booking before payment
//subscribe.registration.add_or_modify.confirm(eventDetails, reg_type, action, process_type, seat_feature, seats_reserved, result.process_id, bp);
} else {
$("#chkbox-error").show();
}
return false;
}
}]
}).on('shown.bs.modal', function() {
//remove the loading when modal shows up
//$('#waiting' + event_schedule_id).remove();
$('#numberofplaces').focus();
// $(this).off('shown.bs.modal');
}).on('hide.bs.modal', function(e) {
$('#chkbox-error').hide();
$(".event-normal-registration-cont-modal").modal("hide");
$('.event-normal-registration-modal').not(':last').remove();
$('.event-normal-registration-cont-modal').not(':last').remove();
$(this).off('hidden.bs.modal');
}).modal('show').init(function() {
$("#seats_reserved_info").hide().removeData("seats_reserved");
$("#numberofplaces").html('' + (
(action == 'register') ?
"- Choisir le nombre de places -" :
"- Choisir le nombre de places à ajouter -") + ' ');
//$(btn).prop("disabled", false);
//add event when browser/tab is closed or reloaded
subscribe.button.exitp.agent_closing({
process_id: result.process_id,
event_id: eventDetails.event_id,
action: 2,
process_type: process_type,
session_type: subscribe.get_vars().session_type
});
$(this).find(".bootbox-close-button").addClass("btn-unlock-process");
$(".btn-unlock-process").off("click").on("click", function() {
if (bp) {
$('.event-moderation-modal').modal("show");
}
//reset the timer when everything goes well
subscribe.button.exitp.clear({});
// clearTimeout(process_request);
subscribe.button.lock_unlock({
data: {
process_id: result.process_id,
event_id: eventDetails.event_id,
action: 2,
process_type: process_type,
session_type: subscribe.get_vars().session_type
}
});
});
//start the timer
subscribe.button.exitp.start(eventDetails.event_id, process_type, result.process_id);
subscribe.registration.options.seats(reg_type, action, process_type, result.mdata);
});
}
} else {
//remove the loading when modal shows up
//$('#waiting' + event_schedule_id).remove();
bootbox.hideAll();
app._notify(result.mtype, result.message);
//update buttons
subscribe.button.change(eventDetails.event_id, 2, null);
}
}
}
});
},
"proceed_to_payment":function(data) {
$.ajax({
url: app.get_vars().baseurl + 'events/homepage/proceed_to_payment',
type: "POST",
data: data,
success: function(res){
window.location.href = app.get_vars().baseurl+'payment'
}
});
},
"confirm": function(eventDetails, reg_type, action, process_type, seat_feature, seats_reserved, process_id, bp = false, is_user_moderated = 0) {
$('span.send_reservation_data').click();
var event_title = eventDetails.title;
var confirm_message = "Voulez-vous réserver " + seats_reserved + (
(seats_reserved[0] <= 1) ?
' place ' :
' places ') + ((event_title == null) ? ' ' : 'pour ' + event_title ) + " ?";
// if (parseInt($("#event_cancel_registration" + event_schedule_id).data("seat-feature")) == 2) {
// confirm_message = '
Voulez-vous réserver ' + seats_reserved + (
// (seats_reserved[0] <= 1) ?
// ' place ' :
// ' places ') + "pour " + event_title + " ?
";
// confirm_message += '
' + '' + '' + ' ' + $("#accordion-heading-es" + event_schedule_id).text() + ' ' + ' ' + ' ' + '' + '' + ' Nombre de places réservées : ' + seats_reserved + (
// (seats_reserved[0] <= 1) ?
// ' place ' :
// ' places ') + ' ' + ' ' + ' ' + '
';
// confirm_message += '
';
// }
app.modal.confirm_box({
title: app.get_vars()._app.modal.book_title,
className: 'my-modal-with-sm event-normal-registration-cont-modal',
message: confirm_message,
buttons: {
confirm: {
label: app.get_vars()._app.btn._confirm,
className: "btn-default-style"
},
cancel: {
label: app.get_vars()._app.btn._close,
className: "btn-default-style2"
}
},
_continue: function() {
var dialog;
$.ajax({
url: app.get_vars().baseurl + 'events/subscribe/validate',
type: "POST",
data: {
event_id: eventDetails.event_id,
//event_schedule_id: event_schedule_id,
action: action,
seat_feature: seat_feature,
//check_subscription: check_subscription,
event_category: eventDetails.event_category,
process_type: process_type,
session_type: subscribe.get_vars().session_type,
reg_type: reg_type,
request_type: 0,
seats_reserved: seats_reserved,
//seats_reserved_orig: seats_reserved_orig,
process_id: process_id,
bp: bp,
//is_user_moderated: is_user_moderated,
},
beforeSend: function() {
var dialog = bootbox.dialog({
className: "waiting-modal",
message: ' ' + app.get_vars()._app.notif.loading + '
',
closeButton: false,
onEscape: function() {}
});
//prevent page from reloading when reserving
$(window).on('beforeunload unload', function(event) {
event.preventDefault();
/* Act on the event */
subscribe.button.prevent_reload();
});
},
success: function(result) {
//remove unbefore unload
$(window).off("beforeunload").off("unload");
//reset the timer when everything goes well
subscribe.button.exitp.clear({});
// clearTimeout(process_request);
bootbox.hideAll();
$("div.waiting-modal:visible, div.modal-backdrop:visible").hide();
if (app.isalive(result)) {
//refresh buttons
subscribe.button.change(eventDetails.event_id, 2, null);
// app._notify(result.mtype, result.message);
if (result.mtype == 'error') {
if (typeof(result.mdata) != "undefined" && result.mdata == 1) {
if (reg_type == 1) {
// subscribe.registration.add_or_modify.redirect_to_waitlist(btn, event_id, event_schedule_id, 2, action, 3, seat_feature, check_subscription, seats_reserved_orig);
}
}
} else if(result.mtype == 'success') {
$.ajax({
url: app.get_vars().baseurl + 'events/homepage/proceed_to_payment',
type: "POST",
data: {
event_id: eventDetails.event_id,
seats_reserved: seats_reserved
},
success: function(res){
window.location.href = app.get_vars().baseurl+'payment'
}
});
}
}
}
});
},
_close: function() {
var this_modal = $(".event-normal-registration-cont-modal");
this_modal.modal('hide');
this_modal.not(':last').remove();
$('.event-normal-registration-modal').modal("show");
}
});
},
"redirect_to_waitlist": function(btn, event_id, event_schedule_id, reg_type, action, process_type, seat_feature, check_subscription, seats_reserved_orig) {
app.modal.confirm_box({
title: app.get_vars()._app.modal.book_title,
message: app.get_vars()._app.modal.msg.confirm_register_waitlist,
buttons: {
confirm: {
label: app.get_vars()._app.btn._confirm,
className: "btn-default-style"
},
cancel: {
label: app.get_vars()._app.btn._close,
className: "btn-default-style2"
}
},
_continue: function() {
// subscribe.check_closed_event(btn, event_id, event_schedule_id, reg_type, action, process_type, seat_feature, check_subscription, seats_reserved_orig);
}
});
}
},
"add_or_modify_offrir": {
"reservation": function(eventDetails, seat_feature, action, process_type) {
const reg_type = 1
const bp = false
var serverData = {
event_id: eventDetails.event_id,
//event_schedule_id: event_schedule_id,
action: action, //1-register, 2-modify, 3- cancel
seat_feature: seat_feature,
//check_subscription: check_subscription,
process_type: process_type,
session_type: subscribe.get_vars().session_type,
reg_type: reg_type,
request_type: 0,
event_category: eventDetails.event_category,
workshop_session: eventDetails.workshop_session,
bp: bp,
//is_user_moderated: is_user_moderated,
};
/* This solution fixed the bug #24568 */
if (cached_process_id) {
serverData.process_id = cached_process_id;
cached_process_id = null;
}
$.ajax({
url: app.get_vars().baseurl + 'events/subscribe/validate',
type: "POST",
data: serverData,
success: function(result) {
if(result.mtype === 'info') {
app._notify(result.mtype, result.message);
}
if (result.logged_out) {
window.location.replace('https://sdllmea-dev.wylog.com/login');
}
if (app.isalive(result)) {
if (result.mtype == "success")
{
/**
* Catch PAID event regular reservation
*/
if ( serverData.event_category === 'PAID_EVENT' && reg_type == 1 ) {
//remove the loading when modal shows up
//$('#waiting' + event_schedule_id).remove();
$(btn).prop("disabled", false);
$(btn).data('event_url') && window.open($(btn).data('event_url'), "_blank");
} else { // Regular event
let label, confBtnClass;
se = result.mdata.reservations ? result.mdata.reservations.seats_reserved : 0;
if (se > 0) {
confBtnClass = ((reg_type == 1) ? 'normal-ress' : 'reserve');
label = (reg_type == 1) ?
"Ajouter des places à ma réservation" :
app.get_vars()._app.btn._updatewaitlist;
} else {
confBtnClass = 'reserve';
label = (reg_type == 1) ?
app.get_vars()._app.btn._book :
app.get_vars()._app.btn._updatewaitlist;
}
$('#seats_reserved_text').text(seat_feature + (seat_feature>1?' places':' place'))
$('#address_text').text(eventDetails.event_address)
if(eventDetails.workshop_session== 'DISTANCE-PRESENTIEL' && subscribe.get_vars().session_type == 'soir-presentiel') {
$('#video_workshop_modal_content').hide()
$('#regular_workshop_modal_content').show()
} else if((eventDetails.workshop_session== 'DISTANCE-PRESENTIEL' && subscribe.get_vars().session_type == 'soir-distance') || eventDetails.workshop_session== 'DISTANCE') {
$('#video_workshop_modal_content').show()
$('#regular_workshop_modal_content').hide()
}
var form = $("#register-event-form");
/* Done waiting reserve */
$(".reserve-spinner").addClass("d-none");
$('.btn-reserve').removeAttr('disabled', true);
$('.btn-offer').removeAttr('disabled', true);
/* end */
bootbox.dialog({
// "title": subscribe.registration.options.title(reg_type, action, process_type),
"title": eventDetails.workshop_session == 'ENLIGNE' ?'Acheter le cours' : (eventDetails.workshop_session == 'DISTANCE-PRESENTIEL' ? 'Réserver le cours':subscribe.registration.options.title(reg_type, action, process_type)),
"className": "my-modal-with-sm event-normal-registration-modal custom-modal-ui table",
"message": form,
"cache": false,
"show": false,
/* We will show it manually later */
"buttons": [{
"label": app.get_vars()._app.btn._close,
"className": "btn btn-default-style2 btn-unlock-process",
"callback": function() {
//remove unbefore unload
$(window).off("beforeunload").off("unload");
//reset the timer when everything goes well
subscribe.button.exitp.clear({});
// clearTimeout(process_request);
$('#chkbox-error').hide();
}
}, {
// "label": label,
"label": "Offrir",
"className": "btn btn-default-style mc-btn " + confBtnClass,
"callback": function() {
var seats_reserved = seat_feature //$('#number_of_seat_reserved').val();
var event_schedule = $('#schedule_id').val();
var seats_reserved_orig = parseInt($("#seats_reserved_info").data("seats_reserved"));
seats_reserved_orig = seats_reserved_orig ? seats_reserved_orig : 0;
if (parseInt(seats_reserved) >= 1 || eventDetails.workshop_session === 'ENLIGNE' || eventDetails.workshop_session === 'DISTANCE') {
$(".event-normal-registration-modal").modal('hide');
$("#chkbox-error").hide();
let validatedData = {
event_id: eventDetails.event_id,
action: action,
seat_feature: seat_feature ?? 1,
event_category: eventDetails.event_category,
process_type: process_type,
session_type: subscribe.get_vars().session_type,
reg_type: reg_type,
request_type: 0,
seats_reserved: seats_reserved ?? 1,
process_id: result.process_id,
workshop_session: eventDetails.workshop_session,
bp: bp
}
const paymentData = {
event_id: eventDetails.event_id,
seats_reserved: seats_reserved ?? 1,
booking: validatedData
}
subscribe.registration.add_or_modify.proceed_to_payment(paymentData)
//commented this to bypass saving booking before payment
//subscribe.registration.add_or_modify.confirm(eventDetails, reg_type, action, process_type, seat_feature, seats_reserved, result.process_id, bp);
} else {
$("#chkbox-error").show();
}
return false;
}
}]
}).on('shown.bs.modal', function() {
//remove the loading when modal shows up
//$('#waiting' + event_schedule_id).remove();
$('#numberofplaces').focus();
// $(this).off('shown.bs.modal');
}).on('hide.bs.modal', function(e) {
$('#chkbox-error').hide();
$(".event-normal-registration-cont-modal").modal("hide");
$('.event-normal-registration-modal').not(':last').remove();
$('.event-normal-registration-cont-modal').not(':last').remove();
$(this).off('hidden.bs.modal');
}).modal('show').init(function() {
$("#seats_reserved_info").hide().removeData("seats_reserved");
$("#numberofplaces").html('' + (
(action == 'register') ?
"- Choisir le nombre de places -" :
"- Choisir le nombre de places à ajouter -") + ' ');
//$(btn).prop("disabled", false);
//add event when browser/tab is closed or reloaded
subscribe.button.exitp.agent_closing({
process_id: result.process_id,
event_id: eventDetails.event_id,
action: 2,
process_type: process_type
});
$(this).find(".bootbox-close-button").addClass("btn-unlock-process");
$(".btn-unlock-process").off("click").on("click", function() {
if (bp) {
$('.event-moderation-modal').modal("show");
}
//reset the timer when everything goes well
subscribe.button.exitp.clear({});
// clearTimeout(process_request);
subscribe.button.lock_unlock({
data: {
process_id: result.process_id,
event_id: eventDetails.event_id,
action: 2,
process_type: process_type
}
});
});
//start the timer
subscribe.button.exitp.start(eventDetails.event_id, process_type, result.process_id);
subscribe.registration.options.seats(reg_type, action, process_type, result.mdata);
});
}
} else {
//remove the loading when modal shows up
//$('#waiting' + event_schedule_id).remove();
bootbox.hideAll();
app._notify(result.mtype, result.message);
//update buttons
subscribe.button.change(eventDetails.event_id, 2, null);
}
}
}
});
},
"proceed_to_payment":function(data) {
$.ajax({
url: app.get_vars().baseurl + 'events/homepage/proceed_to_payment',
type: "POST",
data: data,
success: function(res){
window.location.href = app.get_vars().baseurl+'payment'
}
});
},
"confirm": function(eventDetails, reg_type, action, process_type, seat_feature, seats_reserved, process_id, bp = false, is_user_moderated = 0) {
$('span.send_reservation_data').click();
var event_title = eventDetails.title;
var confirm_message = "Voulez-vous réserver " + seats_reserved + (
(seats_reserved[0] <= 1) ?
' place ' :
' places ') + ((event_title == null) ? ' ' : 'pour ' + event_title ) + " ?";
// if (parseInt($("#event_cancel_registration" + event_schedule_id).data("seat-feature")) == 2) {
// confirm_message = 'Voulez-vous réserver ' + seats_reserved + (
// (seats_reserved[0] <= 1) ?
// ' place ' :
// ' places ') + "pour " + event_title + " ?
";
// confirm_message += '
' + '' + '' + ' ' + $("#accordion-heading-es" + event_schedule_id).text() + ' ' + ' ' + ' ' + '' + '' + ' Nombre de places réservées : ' + seats_reserved + (
// (seats_reserved[0] <= 1) ?
// ' place ' :
// ' places ') + ' ' + ' ' + ' ' + '
';
// confirm_message += '
';
// }
app.modal.confirm_box({
title: app.get_vars()._app.modal.book_title,
className: 'my-modal-with-sm event-normal-registration-cont-modal',
message: confirm_message,
buttons: {
confirm: {
label: app.get_vars()._app.btn._confirm,
className: "btn-default-style"
},
cancel: {
label: app.get_vars()._app.btn._close,
className: "btn-default-style2"
}
},
_continue: function() {
var dialog;
$.ajax({
url: app.get_vars().baseurl + 'events/subscribe/validate',
type: "POST",
data: {
event_id: eventDetails.event_id,
//event_schedule_id: event_schedule_id,
action: action,
seat_feature: seat_feature,
//check_subscription: check_subscription,
event_category: eventDetails.event_category,
process_type: process_type,
session_type: subscribe.get_vars().session_type,
reg_type: reg_type,
request_type: 0,
seats_reserved: seats_reserved,
//seats_reserved_orig: seats_reserved_orig,
process_id: process_id,
bp: bp,
//is_user_moderated: is_user_moderated,
},
beforeSend: function() {
var dialog = bootbox.dialog({
className: "waiting-modal",
message: ' ' + app.get_vars()._app.notif.loading + '
',
closeButton: false,
onEscape: function() {}
});
//prevent page from reloading when reserving
$(window).on('beforeunload unload', function(event) {
event.preventDefault();
/* Act on the event */
subscribe.button.prevent_reload();
});
},
success: function(result) {
//remove unbefore unload
$(window).off("beforeunload").off("unload");
//reset the timer when everything goes well
subscribe.button.exitp.clear({});
// clearTimeout(process_request);
bootbox.hideAll();
$("div.waiting-modal:visible, div.modal-backdrop:visible").hide();
if (app.isalive(result)) {
//refresh buttons
subscribe.button.change(eventDetails.event_id, 2, null);
// app._notify(result.mtype, result.message);
if (result.mtype == 'error') {
if (typeof(result.mdata) != "undefined" && result.mdata == 1) {
if (reg_type == 1) {
// subscribe.registration.add_or_modify.redirect_to_waitlist(btn, event_id, event_schedule_id, 2, action, 3, seat_feature, check_subscription, seats_reserved_orig);
}
}
} else if(result.mtype == 'success') {
$.ajax({
url: app.get_vars().baseurl + 'events/homepage/proceed_to_payment',
type: "POST",
data: {
event_id: eventDetails.event_id,
seats_reserved: seats_reserved
},
success: function(res){
window.location.href = app.get_vars().baseurl+'payment'
}
});
}
}
}
});
},
_close: function() {
var this_modal = $(".event-normal-registration-cont-modal");
this_modal.modal('hide');
this_modal.not(':last').remove();
$('.event-normal-registration-modal').modal("show");
}
});
},
"redirect_to_waitlist": function(btn, event_id, event_schedule_id, reg_type, action, process_type, seat_feature, check_subscription, seats_reserved_orig) {
app.modal.confirm_box({
title: app.get_vars()._app.modal.book_title,
message: app.get_vars()._app.modal.msg.confirm_register_waitlist,
buttons: {
confirm: {
label: app.get_vars()._app.btn._confirm,
className: "btn-default-style"
},
cancel: {
label: app.get_vars()._app.btn._close,
className: "btn-default-style2"
}
},
_continue: function() {
// subscribe.check_closed_event(btn, event_id, event_schedule_id, reg_type, action, process_type, seat_feature, check_subscription, seats_reserved_orig);
}
});
}
},
options: {
"title": function(reg_type, action) {
if (reg_type == 1 && action == "register") {
return app.get_vars()._app.modal.title.register_title;
} else if (reg_type == 2 && action == "register") {
return app.get_vars()._app.modal.title.register_waitlist_title;
} else if (reg_type == 1 && action == "modify") {
return "Ajouter des places à ma réservation";
} else if (reg_type == 2 && action == "modify") {
return "Ajouter des places sur liste d'attente";
}
},
"validate_quota": function(reg_type, quota_seats, seats_reserved, remaining_seats) {
var seats_available = 0;
if (reg_type == 1) {
//check if seats per subscriber caters the remaining seats
if (quota_seats >= seats_reserved && remaining_seats > 0) {
if (quota_seats == seats_reserved) {
seats_available = 0;
} else {
seats_available = (quota_seats > seats_reserved) ?
quota_seats - seats_reserved :
quota_seats;
seats_available = (remaining_seats >= seats_available) ?
seats_available :
remaining_seats;
}
}
} else if (reg_type == 2) {
//check if quota_waiting_list_seat caters the seats_reserved
/* !note remaining seat here means as seat_per_subscriber */
var seats_per_subscriber = remaining_seats;
if (seats_per_subscriber >= seats_reserved && seats_per_subscriber > 0 && quota_seats > 0) {
if (seats_per_subscriber == seats_reserved) {
seats_available = 0;
} else {
seats_available = (seats_per_subscriber > seats_reserved) ?
seats_per_subscriber - seats_reserved :
(
(seats_per_subscriber > quota_seats) ?
quota_seats :
seats_per_subscriber);
seats_available = (quota_seats >= seats_available) ?
seats_available :
quota_seats;
}
}
}
return seats_available;
},
"datesFR": function() {
return {
"Monday": {
fr: "lundi"
},
"Tuesday": {
fr: "mardi"
},
"Wednesday": {
fr: "mercredi"
},
"Thursday": {
fr: "jeudi"
},
"Friday": {
fr: "vendredi"
},
"Saturday": {
fr: "samedi"
},
"Sunday": {
fr: "dimanche"
},
"January": {
fr: "janvier"
},
"February": {
fr: "février"
},
"March": {
fr: "mars"
},
"April": {
fr: "avril"
},
"May": {
fr: "mai"
},
"June": {
fr: "juin"
},
"July": {
fr: "juillet"
},
"August": {
fr: "août"
},
"September": {
fr: "septembre"
},
"October": {
fr: "octobre"
},
"November": {
fr: "novembre"
},
"December": {
fr: "décembre"
}
};
},
"use_diff_address": function(data) {
//translator
var translator = $('#event-box').translate({
lang: "fr",
t: subscribe.registration.options.datesFR()
});
if (data.reservation_end_date != null && data.reservation_end_date != "") {
//display end reservation date
var endresrvationdate = data.reservation_end_date;
var monthendreservationdate = data.end_reservation_month;
var startdate = data.start_date_time;
var enddate = data.end_date_time;
var startmonth = translator.get(data.event_start_month_name);
var endmonth = translator.get(data.end_month);
if (enddate == null) {
$("#event-date-modify").text($("#accordion-heading-es" + data.event_schedule_id).text());
} else {
$('#event-date-modify').html(Helper.event_date(startdate, enddate, startmonth, endmonth));
}
$("#event-end-reservation-date").show().html("Date limite de réservation " + Helper.start_date(endresrvationdate, startmonth.toLowerCase(), endmonth.toLowerCase()));
} else {
$("#event-end-reservation-date").hide();
}
//display address if there is
if (parseInt(data.use_different_address_per_date) == 1) {
var placename = data.event_place_name;
if (placename == '') {
$("#event-date-address").show().html("Adresse : " + data.event_address + ", " + data.city);
} else {
$("#event-date-address").show().html("Adresse : " + placename + ", " + data.event_address + ", " + data.city);
}
} else {
var placename = data.event_place_name;
if (placename == '') {
$("#event-date-address").show().html("Adresse : " + data.event_address + ", " + data.city);
} else {
$("#event-date-address").show().html("Adresse : " + placename + ", " + data.event_address + ", " + data.city);
}
}
},
"seats": function(reg_type, action, process_type, data) {
//Places checkboxes
var seats_available = 0;
if (action == "register") {
// Title
$('#register-event-title').html(data.title);
//Event Details
$('#schedule_id').val(data.event_schedule_id);
//$("#event-date-modify").text($("#accordion-heading-es" + data.event_schedule_id.toLowerCase()).text());
subscribe.registration.options.use_diff_address(data);
if (reg_type == 1) { //regular registration
var seats_per_subscriber = parseInt(data.seats_per_subscriber);
var remaining_seats = parseInt(data.remaining_seat);
//check if seats per subscriber caters the remaining seats
seats_available = (seats_per_subscriber > remaining_seats) ?
remaining_seats :
seats_per_subscriber;
} else if (reg_type == 2) { // waiting list registration
var seats_per_subscriber = parseInt(data.seats_per_subscriber);
var quota_waiting_list_seat = parseInt(data.quota_waiting_list_seat);
seats_available = (seats_per_subscriber > quota_waiting_list_seat) ?
quota_waiting_list_seat :
seats_per_subscriber;
}
} else if (action == "modify") {
var seats_reserved = parseInt(data.reservations.seats_reserved);
if (reg_type == 1) {
seats_available = subscribe.registration.options.validate_quota(reg_type, parseInt(data.event_schedule.seats_per_subscriber), parseInt(data.reservations.seats_reserved), parseInt(data.event_schedule.remaining_seat));
} else if (reg_type == 2) {
//check if quota_waiting_list_seat caters the seats_reserved
seats_available = subscribe.registration.options.validate_quota(reg_type, parseInt(data.event_schedule.quota_waiting_list_seat), parseInt(data.reservations.seats_reserved), parseInt(data.event_schedule.seats_per_subscriber));
}
// Title
$('#register-event-title').html(data.event_schedule.title);
//Event Details
$("#event-date-modify").text($("#accordion-heading-es" + data.event_schedule.event_schedule_id).text());
$('#schedule_id').val(data.event_schedule.event_schedule_id);
subscribe.registration.options.use_diff_address(data.event_schedule);
$("tr#seats_reserved_info").data("seats_reserved", seats_reserved).show();
$("span#seats_reserved_text").html(`${seats_reserved} ` + (
(seats_reserved <= 1)
? ' place '
: ' places '));
}
var numberofplaces = $('#numberofplaces');
numberofplaces.on("change", function() {
$('#chkbox-error').hide();
});
for (var x = 1; x <= seats_available; x++) {
numberofplaces.append('' + x + (
(x <= 1)
? ' place '
: ' places ') + ' ');
}
},
"translate_date": {
"getscheds": function(event_id, isEventOpen) {
sched = $.ajax({
url: app.get_vars().baseurl + "events/homepage/check_all_sched",
type: "GET",
async: false,
data: {
event_id: event_id,
isEventOpen: isEventOpen
},
success: function(result) {
return result;
}
});
},
"init": function(event_schedule) {
//translator
var translator = $('#event-box').translate({
lang: "fr",
t: subscribe.registration.options.datesFR()
});
var date_in_french = "",
event_start_hour = "",
event_end_hour = "",
event_end_day = "";
// check if 12am
var patt = new RegExp("00h00");
// This is for Multidate Event
if (parseInt(event_schedule.date_feature) == 2) {
let isEventOpen = (parseInt(event_schedule.back_office_status) >= 4) ? false:true;
subscribe.registration.options.translate_date.getscheds(event_schedule.event_id, isEventOpen);
var diffyear = '';
let event_end_date = JSON.parse("["+sched.responseJSON[0].event_end_date+"]");
/**
* check: event id 727 for bug
* if there's an end date,
* meaning the start date is not equal to the end date
*/
if (event_end_date[0].end_date) {
if (sched.responseJSON[0].min_date_year != event_end_date[0].max_mdate_year) {
diffyear = sched.responseJSON[0].min_date_year;
}
evdate_start = "Du " + translator.get(sched.responseJSON[0].min_start_day) + ' ' + sched.responseJSON[0].min_start_date + ' ' + translator.get(sched.responseJSON[0].min_start_date_month).toLowerCase() + ' ' + diffyear + ' ' + sched.responseJSON[0].min_start_date_hour;
evdate_end = "au " + translator.get(event_end_date[0].max_end_date_day) + ' ' + event_end_date[0].max_mdate_date + ' ' + translator.get(event_end_date[0].max_mdate_month).toLowerCase() + ' ' + event_end_date[0].max_mdate_year + ' ' + event_end_date[0].end_mdate_hour;
date_in_french = evdate_start + ' ' + evdate_end;
} else { // same month, day and year
evdate_start = "Le " + translator.get(sched.responseJSON[0].min_start_day) + ' ' + sched.responseJSON[0].min_start_date + ' ' + translator.get(sched.responseJSON[0].min_start_date_month).toLowerCase() + ' ' + sched.responseJSON[0].min_date_year + ' ' + sched.responseJSON[0].start_date_hour;
evdate_end = ' ' + event_end_date[0].end_mdate_hour;
date_in_french = evdate_start + ' ' + evdate_end;
}
} else { //this for single date event
// console.log('Single Event',event_schedule.event_id);
if ((event_schedule.start_date_hour == "" || event_schedule.start_date_hour == null || patt.test(event_schedule.start_date_hour) == true) && (event_schedule.end_date_hour == "" || event_schedule.end_date_hour == null || patt.test(event_schedule.end_date_hour) == true)) {
event_start_hour = ' ';
} else if ((event_schedule.start_date_hour != "" || event_schedule.start_date_hour != null || patt.test(event_schedule.start_date_hour) == false) && (event_schedule.end_date_hour == "" || event_schedule.end_date_hour == null || patt.test(event_schedule.end_date_hour) == true)) {
event_start_hour = " à " + (
(event_schedule.start_date_hour != null && event_schedule.start_date_hour != "") ?
" " + event_schedule.start_date_hour :
' ');
} else if ((event_schedule.start_date_hour == "" || event_schedule.start_date_hour == null || patt.test(event_schedule.start_date_hour) == true) && (event_schedule.end_date_hour != "" || event_schedule.end_date_hour != null || patt.test(event_schedule.end_date_hour) == false)) {
event_end_hour = " à " + (
(event_schedule.end_date_hour != null && event_schedule.end_date_hour != "") ?
event_schedule.end_date_hour :
' ');
} else if ((event_schedule.start_date_hour != "" || event_schedule.start_date_hour != null || patt.test(event_schedule.start_date_hour) == false) && (event_schedule.end_date_hour != "" || event_schedule.end_date_hour != null || patt.test(event_schedule.end_date_hour) == false)) {
if (event_schedule.start_date != event_schedule.end_date) {
event_start_hour = " à " + (
(event_schedule.start_date_hour != null && event_schedule.start_date_hour != "") ?
" " + event_schedule.start_date_hour :
' ');
event_end_hour = " à " + (
(event_schedule.end_date_hour != null && event_schedule.end_date_hour != "") ?
event_schedule.end_date_hour :
' ');
} else {
event_start_hour = " de " + (
(event_schedule.start_date_hour != null && event_schedule.start_date_hour != "") ?
" " + event_schedule.start_date_hour :
' ');
event_end_hour = " à " + (
(event_schedule.end_date_hour != null && event_schedule.end_date_hour != "") ?
event_schedule.end_date_hour :
' ');
}
}
var evdate_start = '';
var evdate_end = '';
if (event_schedule.end_day != "" && event_schedule.end_day != null && parseInt(event_schedule.end_day) != 0) {
event_end_day = " au " + (
(event_schedule.end_day != null && event_schedule.end_day != "") ?
event_schedule.end_day + " " :
" ") + " ";
} else {
event_end_day = ' ';
}
if (event_schedule.start_date == event_schedule.end_date || parseInt(event_schedule.end_date) == 0) {
// Le XX Septembre XXXX 8h00 jusq'au XX October XXXX 12h00
// Du 28 octobre au 29 octobre 2016 de 20h30 Ã 23h00
date_in_french += "Le " + translator.get(event_schedule.day) + " ";
date_in_french += translator.get(event_schedule.start_day) + ' ';
date_in_french += translator.get(event_schedule.event_start_month_name).toLowerCase() + ' ' + event_schedule.end_year + ' ' + event_start_hour + ' ' + event_end_hour;
} else {
// Le 28 Septembre 1995 de 8h00 a 12h00
// Du 28 octobre 2016 de 20h30 Ã 22h30
if (event_schedule.start_month == event_schedule.end_month) {
date_in_french += " " + event_schedule.start_day + " " + event_end_day + " ";
date_in_french += translator.get(event_schedule.end_month).toLowerCase();
date_in_french += " " + event_schedule.end_year;
// ." de ".$event_schedule->start_date_hour." Ã ".$event_schedule->end_date_hour;
} else if (event_schedule.start_year != event_schedule.end_year && event_schedule.end_year == '') {
date_in_french += "Le " + translator.get(event_schedule.day) + " ";
date_in_french += event_schedule.start_day + ' ' + translator.get(event_schedule.event_start_month_name).toLowerCase();
date_in_french += " " + event_schedule.start_year + " " + event_end_day;
date_in_french += translator.get(event_schedule.end_month).toLowerCase();
date_in_french += " " + event_schedule.end_year; //." de ".$event_schedule->start_date_hour." Ã ".$event_schedule->end_date_hour;
date_in_french += " " + event_start_hour;
} else if (event_schedule.end_year != null && event_schedule.start_year != event_schedule.end_year) {
date_in_french += "Du " + translator.get(event_schedule.day) + " ";
date_in_french += event_schedule.start_day + ' ' + translator.get(event_schedule.event_start_month_name).toLowerCase();
date_in_french += " " + event_schedule.start_year;
date_in_french += " " + event_start_hour;
date_in_french += " au " + translator.get(event_schedule.endday) + " ";
date_in_french += event_schedule.end_day + ' ' + translator.get(event_schedule.end_month).toLowerCase();
date_in_french += " " + event_schedule.end_year; //." de ".$event_schedule->start_date_hour." Ã ".$event_schedule->end_date_hour;
date_in_french += " " + event_end_hour;
} else {
evdate_start = "Du " + translator.get(event_schedule.day) + ' ' + event_schedule.start_day + ' ' + translator.get(event_schedule.event_start_month_name).toLowerCase();
evdate_end = "au " + translator.get(event_schedule.endday) + ' ' + event_schedule.end_day + ' ' + translator.get(event_schedule.end_month).toLowerCase() + ' ' + event_schedule.end_year;
if (evdate_start != '' && evdate_end != '') {
date_in_french = evdate_start + ' ' + (
event_start_hour != '' ?
event_start_hour :
'') + ' ' + (
evdate_end != '' ?
evdate_end :
'') + ' ' + event_end_hour;
} else {
date_in_french += (
(event_start_hour != null && event_start_hour != "") ?
event_start_hour :
" ") + " " + (
(event_end_hour != null && event_end_hour != "") ?
event_end_hour :
" ");
}
}
}
}
return date_in_french;
},
french: function(date) {
var eng = [
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December',
'/'
];
var fr = [
'janvier',
'février',
'mars',
'avril',
'mai',
'juin',
'juillet',
'août',
'septembre',
'octobre',
'novembre',
'décembre',
' '
];
return (date != null && date != "") ?
date.replace(eng, fr) + " " :
" ";
}
},
"create_list": {
"check_uncheck": function(e, event_schedule_id, index) {
var checked = $("#invitee" + event_schedule_id + '-' + index);
if (checked.prop("checked")) { //unchecked
if (index == 1) {
$(".invitee" + event_schedule_id).prop("checked", false);
} else {
$("#invitee" + event_schedule_id + '-' + 1).prop("checked", false);
checked.prop("checked", false);
}
//when nothing is clicked
if ($(".invitee" + event_schedule_id + ":checked").length <= 0) {
$("#cancel-event-message").html("Vérifiez le nombre de places que vous souhaitez annuler. ");
}
} else { //checked
$("#cancel-event-ermsg").remove();
if (index == 1) {
$(".invitee" + event_schedule_id).prop("checked", true);
} else {
$("#invitee" + event_schedule_id + '-' + 1).prop("checked", false);
checked.prop("checked", true);
}
}
},
"seats_reserved": function(reservation) {
if (reservation.seats_reserved > 0) {
var labelText = (parseInt(reservation.reg_type) == 1) ?
"Ma réservation complète" :
"Mon inscription complète",
html = "";
for (var x = 1; x <= reservation.seats_reserved; x++) {
if (x > 1) {
labelText = (parseInt(reservation.reg_type) == 1) ?
"La réservation de mon invité " + (
x - 1) :
"L’inscription de mon invité " + (
x - 1);
}
html += '' +
' ' +
' ' +
labelText +
' ';
}
return html;
}
}
},
"refresh_buttons": function(result) {
var shown_dates = [];
$.each($("#event-desc").find("a.accordion-toggle"), function(index, value) {
var _this = $(this);
if (!_this.hasClass("collapsed")) {
shown_dates.push(_this.parent().parent().prop("id"));
}
});
localStorage.setItem("collapsed-dates", JSON.stringify(shown_dates));
localStorage.setItem("result", JSON.stringify(result));
window.setTimeout(function() {
location.reload();
}, 250);
// location.reload();
}
},
"cancel": {
"event": function(btn, event_id, event_schedule_id, reg_type, process_type, action, seat_feature, bp = false) {
var serverData = {
event_id: event_id,
event_schedule_id: event_schedule_id,
reg_type: reg_type,
event_category: $(btn).data('event-cat'),
action: action,
process_type: process_type,
bp: bp
};
/* This solution fixed the bug #24568 */
if (cached_process_id)
serverData.process_id = cached_process_id;
cached_process_id = null;
$.ajax({
url: app.get_vars().baseurl + "events/subscribe/validate",
type: "POST",
data: serverData,
success: function(result) {
if (app.isalive(result)) {
if (result.mtype == "success") {
if (typeof(result.mdata.seats_reserved) != "undefined") {
/**
* Catch PAID event cancel regular reservation
* process_type: 2 = cancel regular reservation
*/
if ( serverData.event_category === 'PAID_EVENT' && process_type == 2 ) {
//remove the loading when modal shows up
$('#waiting' + event_schedule_id).remove();
$(".cancel-registration-modal").modal("hide");
$(btn).prop("disabled", false);
$(btn).data('event_url') && window.open($(btn).data('event_url'), "_blank");
} else { // Regular event
bootbox.dialog({
"title": (reg_type == 1) ?
"MODIFIER OU ANNULER MA RÉSERVATION" :
"Modifier ou annuler mon inscription sur liste d'attente",
// ? "ANNULER VOTRE RÉSERVATION"
// : "ANNULER MON INSCRIPTION SUR LISTE D’ATTENTE",
"className": "my-modal-with-sm cancel-registration-modal",
"message": $("#cancel-registration-form"),
"show": false,
/* We will show it manually later */
"buttons": [{
"label": app.get_vars()._app.btn._close,
"className": "btn btn-default-style2 btn-unlock-process",
"callback": function() {
//remove prevent page reload
$(window).off("beforeunload").off("unload");
//reset the timer when everything goes well
subscribe.button.exitp.clear({});
// clearTimeout(process_request);
$('#cancel-guest-list').empty();
$('#cancel-guest-checkboxes').empty();
}
}, {
"label": app.get_vars()._app.btn._confirm,
"className": "btn btn-default-style",
"callback": function() {
var cancellation_info = {
"event_schedule_id": event_schedule_id,
"process_type": process_type,
"seats_reserved": result.mdata.seats_reserved,
"action": action,
"seats_cancelled": $('.invitee' + event_schedule_id + ':checked').length,
"event_id": event_id,
"seat_feature": seat_feature,
"event_category": $(btn).data('event-cat'),
"process_id": result.process_id,
"reg_type": reg_type //3=cancellation
};
$("#cancel-event-message").html("");
if (cancellation_info.seats_cancelled > 0) {
$(this).modal('hide');
subscribe.registration.cancel.confirm(btn, cancellation_info);
} else {
$("#cancel-event-message").html("Vérifiez le nombre de places que vous souhaitez annuler. ");
}
return false;
}
}]
}).on('shown.bs.modal', function() {
//remove the loading when modal shows up
$('#waiting' + event_schedule_id).remove();
$(this).off('shown.bs.modal');
}).on('hide.bs.modal', function(e) {
$('#cancel-event-message').html("");
var cont_modal = $(".cancel-registration-cont-modal");
cont_modal.modal("hide");
$('.cancel-registration-modal').not(':last').remove();
cont_modal.not(':last').remove();
app.modal.focusout_solution("off");
$(this).data('bs.modal', null);
$(this).off('hidden.bs.modal');
}).modal('show').init(function() {
$("#accordion_cancel_event_list").empty();
app.modal.focusout_solution("on");
$(btn).prop("disabled", false);
$(this).find(".bootbox-close-button").addClass("btn-unlock-process");
$(".btn-unlock-process").off("click").on("click", function() {
//if by pass is active
if (bp) {
$('.event-moderation-modal').modal("show");
}
//reset the timer when everything goes well
subscribe.button.exitp.clear({});
// clearTimeout(process_request);
subscribe.button.lock_unlock({
data: {
process_id: result.process_id,
event_id: event_id,
action: 2,
process_type: process_type
}
});
});
//add event when browser/tab is closed or reloaded
subscribe.button.exitp.agent_closing({
process_id: result.process_id,
event_id: event_id,
action: 2,
process_type: process_type
});
//start the timer
subscribe.button.exitp.start(event_id, process_type, result.process_id);
$('#cancel-event-title').html($("#event-title").text());
//display reservations
$('#accordion_cancel_event_list').html('' + '' + ' ' + $("#accordion-heading-es" + event_schedule_id).text() + ' ' + '
' + ' ' + '' + '
Je souhaite annuler :
' + '
' + '' + '
' + subscribe.registration.options.create_list.seats_reserved(result.mdata) + ' ' + '
');
});
}
} else {
$(btn).prop("disabled", false);
//remove the loading when modal shows up
$('#waiting' + event_schedule_id).remove();
$(".cancel-registration-modal").modal("hide");
//update button status
subscribe.button.change(event_id, 2, null);
}
} else {
$(btn).prop("disabled", false);
//remove the loading when modal shows up
$('#waiting' + event_schedule_id).remove();
app._notify(result.mtype, result.message);
//update button status
subscribe.button.change(event_id, 2, null);
}
} //is alive
} //end of success
});
},
"confirm": function(btn, cancellation_info) {
var confirm_message = "";
//reload grid
if (typeof cancellation_info.seats_cancelled == 'undefined') {
confirm_message = "Vous êtes sur le point d'annuler votre réservation sur l'événement " + $("#event-title").text();
} else {
confirm_message = "Souhaitez-vous confirmer l’annulation de " + cancellation_info.seats_cancelled + (
(cancellation_info.seats_cancelled <= 1) ?
' place ' :
' places ') + "pour " + $("#event-title").text() + "?";
}
app.modal.confirm_box({
title: app.get_vars()._app.modal.title.cancellation_title,
message: confirm_message,
className: ' my-modal-with-sm cancel-registration-cont-modal',
buttons: {
confirm: {
label: app.get_vars()._app.btn._confirm,
className: "btn-default-style"
},
cancel: {
label: app.get_vars()._app.btn._close,
className: "btn-default-style2"
}
},
_continue: function() {
$.ajax({
url: app.get_vars().baseurl + "events/subscribe/validate",
type: "POST",
data: cancellation_info,
beforeSend: function() {
var dialog = bootbox.dialog({
className: 'waiting-modal',
message: ' ' + app.get_vars()._app.notif.loading + '
',
closeButton: false
});
//prevent page from reloading when reserving
$(window).on('beforeunload unload', function(event) {
event.preventDefault();
/* Act on the event */
subscribe.button.prevent_reload();
});
},
success: function(result) {
//remove unbefore unload
$(window).off("beforeunload").off("unload");
//reset the timer when everything goes well
subscribe.button.exitp.clear({});
// clearTimeout(process_request);
bootbox.hideAll();
$("div.waiting-modal:visible, div.modal-backdrop:visible").hide();
if (app.isalive(result)) {
//update button status
subscribe.button.change(cancellation_info.event_id, 2, null);
app._notify(result.mtype, result.message);
if (result.mtype == "success") {
$("#event_cancel_registration").remove();
}
}
}
});
},
_close: function() {
var cont_modal = $(".cancel-registration-cont-modal");
cont_modal.modal("hide");
cont_modal.not(':last').remove();
$('.cancel-registration-modal').modal("show");
}
});
}
}
},
"button": {
"prevent_reload": function() {
// console.log('prevent reload executed...');
return "Still processing...";
},
"exitp": {
agent_closing: function(data) { //basically, browser closing
// console.log('agent closing executed....pr => ' + process_request);
var onBeforeUnLoadEvent = false;
window.onunload = window.onbeforeunload = function() {
if (!onBeforeUnLoadEvent) {
onBeforeUnLoadEvent = true;
//your code here
subscribe.button.lock_unlock({
data: data,
async: false,
success: function() {
// console.log('closing user agent instance...');
}
});
} //end of if
};
},
init: function(event_id, process_type, process_id) {
// console.log('init executed....pr => ' + process_request);
if (typeof process_id != "undefined") {
cached_process_id = process_id;
}
$.ajax({
async: true,
type: "POST",
url: app.get_vars().baseurl + 'events/subscribe/exitp',
data: {
event_id: event_id,
process_type: process_type,
process_id: process_id
},
error: function() {
// console.log('Close notification error');
},
success: function(data) {
if (data)
subscribe.button.exitp.start(event_id, process_type, process_id);
else
clearTimeout(process_request);
}
});
},
start: function(event_id, process_type, process_id) {
// console.log('start executed...pr => ' + process_request);
clearTimeout(process_request);
// check time every after 1mins
process_request = setTimeout(function() {
subscribe.button.exitp.init(event_id, process_type, process_id);
}, 1 * 60 * 1000);
},
clear: function() {
// clears the unload and onbeforeunload event
// resolves Dev # 15880 issue regarding prevent page load because data will not be saved
window.onunload = window.onbeforeunload = null;
window.clearTimeout(process_request);
}
},
"not_allowed_to_book": function() {
app._notify("warning", "Les réservations pour cet événement sont limitées à une seule date par abonné. Si vous souhaitez changer de date de réservation, vous devez annuler votre réservation en cours puis effectuer une nouvelle réservation sur la date désirée.")
},
"register_or_modify": function(e, reg_type, action, process_type, seat_feature, check_subscription) {
// action def : 1=register, 2=modify
var btn_action = (parseInt(action) == 1) ?
"register" :
(
(parseInt(action) == 2) ?
"modify" :
"cancel"),
_this = $(e.target),
event_id = _this.data('event-id'),
event_schedule_id = _this.data('event-schedule-id');
const eventCat = $(e.target).data('event-cat');
if (eventCat && EVENT_CAT.includes(eventCat)) {
// Add waiting text and disable button to avoid click bubbling
_this.html(' ' + _this.text()).prop("disabled", true);
// register
if (parseInt(action) == 1) {
// Check if reservation is possible
if (eventCat && eventCat === 'PAID_EVENT') {
subscribe.registration.add_or_modify.reservation(e.target, event_id, event_schedule_id, reg_type, btn_action, process_type, seat_feature, check_subscription, false);
} else {
subscribe.button.moderation.check(event_id, event_schedule_id).done(function(jsondata) {
if (jsondata.allowed) {
subscribe.registration.add_or_modify.reservation(e.target, event_id, event_schedule_id, reg_type, btn_action, process_type, seat_feature, check_subscription, false, jsondata.is_user_moderated);
} else {
_this.prop("disabled", false);
$("#waiting" + event_schedule_id).remove();
subscribe.button.moderation.message(jsondata);
}
});
}
} else {
//modify reservation
if (eventCat && eventCat === 'PAID_EVENT') {
subscribe.registration.add_or_modify.reservation(e.target, event_id, event_schedule_id, reg_type, btn_action, process_type, seat_feature, check_subscription, false);
} else {
subscribe.button.moderation.check(event_id, event_schedule_id).done(function(jsondata) {
subscribe.registration.add_or_modify.reservation(e.target, event_id, event_schedule_id, reg_type, btn_action, process_type, seat_feature, check_subscription, false, jsondata.is_user_moderated);
});
}
}
} else {
app._notify("error", "Cannot process request, unknown event category.")
}
},
/**
* Moderation Object
*/
"moderation": {
/**
* Check if reservation is to be moderated
*
* @param {*} event_id
* @param {*} event_schedule_id
* @param {*} subscribe
*
* access private member
*/
"check": function(event_id, event_schedule_id) {
return $.ajax({
url: app.get_vars().baseurl + `checking_moderation/${event_id}/${event_schedule_id}`,
type: "GET",
async: false
});
},
/**
* Display dialog box when reservation is moderated
*
* @param {*} jsondata
*/
"message": function(jsondata) {
var msg = `You can not reserve any seats for this event since this one have been moderated and you reach the quota of reservation or of noshow
You can have access to all your moderation information in clicking on the button "my reservation".
However you can at least reserve in the waiting list without warranty that some seats will be vacant in last minutes.
Thank you for your understanding
`;
if (jsondata.nr_exceeded) {
/*Set the data for the dynamic fields*/
/*Name of user*/
// $('.first_name').html(app.get_vars()._app.msg.first_name);
/*Set dynamic data*/
$('span.mod_nr_count').html(jsondata.mod_nr_count);
$('span.res_period2').html(jsondata.res_period2);
$('span.max_res').html(jsondata.max_res);
$('span.res_period').html(jsondata.res_period);
$('span.when_can_reserve').html(jsondata.when_can_reserve);
msg = $('#moderated_msg').html();
} else if (jsondata.ns_exceeded) {
/*Name of user*/
$('.noshow-subscriber-firstname').html(app.get_vars()._app.msg.first_name);
/*Set dynamic data*/
$('span.mod_max_noshow').html(jsondata.max_ns);
$('span.mod_noshow_period').html(jsondata.ns_period);
$('span.mod_noshow_when_can_reserve').html(Helper.moderation_date(jsondata.ns_period2.resumeReservationOn, jsondata.ns_period2.event_start_month_name));
msg = $('#noshow_moderated_msg').html();
}
bootbox.dialog({
"title": "Réservation non autorisée",
"className": "my-modal-with-sm event-moderation-modal",
"message": msg,
"show": true,
buttons: subscribe.button.moderation.buttons.create(jsondata)
}).on('hide.bs.modal', function(e) {
$(".event-normal-registration-modal").modal("hide");
$('.event-moderation-modal').not(':last').remove();
$('.event-normal-registration-modal').not(':last').remove();
$(this).off('hidden.bs.modal');
});
/**
* Make sure to disable modify WL res once there is no remaining seat in WL
*/
if (jsondata.wldata == null || !jsondata.wldata.canReserveInWL) {
$("button.wl-custom-btn").prop("disabled", true);
}
},
/**
* Create buttons depending on the status of the action [cancel,modify,register] for Waiting list
* @type {Object}
*/
"buttons": {
/**
* Create buttons for the modal
* @param {Object} jsondata Json returned from the server
* @return {Object}
*/
create: function(jsondata) {
var btns = [{
"label": "RETOUR",
"className": "btn myreservation-btn2 btn-default-style2",
"callback": function() {
window.location.href = app.get_vars().baseurl;
}
}];
var my_resBtn = [{
"label": "RETOUR",
"className": "btn myreservation-btn btn-default-style2",
"callback": function() {
window.location.href = app.get_vars().baseurl;
}
}];
/**
* Check if subscriber can still reserve to Waiting list (if seats are avaible for WL) or not
*/
if (jsondata.wldata == null || !jsondata.wldata.canReserveInWL && jsondata.wldata.ps.action == 'full') {
return btns;
}else if(jsondata.wldata == null || jsondata.wldata.canReserveInWL && jsondata.wldata.ps.action == 'cancel'){
return subscribe.button.moderation.buttons.defineBtns(jsondata, my_resBtn);
}
else {
return subscribe.button.moderation.buttons.defineBtns(jsondata, btns);
}
},
"defineBtns": function(jsondata, btns) {
var action = "",
label = "",
process_type = "",
classN;
if (jsondata.wldata.ps.action == "register") {
action = "register";
label = "S'INSCRIRE SUR LISTE D'ATTENTE";
process_type = 3;
classN = "moderationWL-btn";
} else if (jsondata.wldata.ps.action == "modify" || jsondata.wldata.ps.action == "cancel") {
label = "Ajouter des places sur liste d'attente";
classN = "moderation-btn";
if (jsondata.wldata.data.number_of_places == jsondata.wldata.data.seats_per_subscriber) {
classN = "moderation-btn disabled full-wl-btn-mod-modal";
label = "INSCRIT SUR LISTE D'ATTENTE";
}
action = "modify";
process_type = 7;
}
btns.push({
"label": label,
"className": "btn " + classN + " btn btn-default-style reserve wl-custom-btn",
"callback": function() {
if (jsondata.wldata.data.length != 0 && (jsondata.wldata.data.number_of_places == jsondata.wldata.data.seats_per_subscriber)) {
return false
}
subscribe.registration.add_or_modify.reservation(null, jsondata.wldata.ps.event_id, jsondata.wldata.ps.event_schedule_id, jsondata.wldata.ps.reg_type, action, process_type, 1, 1, true, 1);
}
});
if (jsondata.wldata.ps.action == "cancel") {
btns.push({
"label": "MODIFIER OU ANNULER MON INSCRIPTION SUR LISTE D'ATTENTE",
// "label": "ANNULER MON INSCRIPTION SUR LISTE D’ATTENTE",
"className": "btn moderation-btn btn-default-style2 btn-block btn-cancel-wl-registration cancel-btn-mod-modal",
"callback": function() {
subscribe.registration.cancel.event(null, jsondata.wldata.ps.event_id, jsondata.wldata.ps.event_schedule_id, jsondata.wldata.ps.reg_type, (parseInt(jsondata.wldata.ps.reg_type) == 1 ? 2 : 4), "cancel", 1, true, 1);
}
});
}
return btns;
}
}
},
"cancel_reservation": function(e, event_id, event_schedule_id, reg_type) {
var _this = $(e.target),
button_page = _this.data('page');
_this.html(' ' + _this.text()).prop("disabled", true);
//reg_type = 3 means cancellaltion
const eventCat = _this.data('event-cat');
if (eventCat && EVENT_CAT.includes(eventCat)) {
if (eventCat === 'PAID_EVENT' && _this.hasClass('cancel-reservation') && !_this.hasClass('btn-cancel-wl-registration')) {
subscribe.button.pe_cancellation();
$('#waiting' + event_schedule_id).remove();
_this.prop("disabled", false);
} else {
subscribe.registration.cancel.event(e.target, event_id, event_schedule_id, reg_type, (
parseInt(reg_type) == 1 ?
2 :
4), "cancel", parseInt(_this.data("seat-feature")));
}
} else {
app._notify("error", "Cannot process request, unknown event category.")
}
},
"lock_unlock": function(options) {
var opt = {
url: app.get_vars().baseurl + "events/subscribe/revalidate",
type: "POST",
data: {},
success: function(result) {
// console.log(result);
}
};
if (typeof options != "undefined" && options != null) {
if (typeof options.data.process_id != "undefined") {
cached_process_id = options.data.process_id;
}
$.extend(true, opt, options);
}
$.ajax(opt);
},
"redirect": function(event_id, redirect) {
$.ajax({
url: app.get_vars().baseurl + "events/subscribe/save_link_to_cookie",
type: "POST",
data: {
event_id,
redirect
},
success: function(result) {
app._notify("error", "Vous n'êtes pas connecté");
window.setTimeout(function() {
window.location.href = redirect;
}, 1000);
}
}).fail(function(jqXHR, textStatus, errorThrown) {
app._notify("error", "Vous n'êtes pas connecté");
window.setTimeout(function() {
window.location.href = redirect;
}, 1000);
});
},
"setButtonStatus": function(id, page, target, eventDetails) {
var displayCancelButton = 0,
disbledbtns = {
"bos1": app.get_vars()._app.btn.coming_soon,
"bos3": app.get_vars()._app.btn._full,
"bos4": app.get_vars()._app.btn._closed,
"bos7": app.get_vars()._app.btn._terminee,
"bos8": app.get_vars()._app.btn._cancelled
};
$.map(eventDetails.event_status, function(value, key) {
$('.tooltip').remove();
$('.arrow').remove();
$('.tooltip-inner').remove();
$('.tooltip').remove();
$('.arrow').remove();
$('.tooltip-inner').remove();
var event_sched_btn = target;
//set date
$("#hp-event-date" + value.event_schedule_id).text(subscribe.registration.options.translate_date.init(value));
//get city
var eventtype_and_city = $("#hp-event-type-city" + value.event_schedule_id);
if (value.date_feature == '2' && value.use_different_address_per_date == '1') {
eventtype_and_city.html("" + eventtype_and_city.html() + " " + (
(value.event_venue != null && value.event_venue != "") ?
"
" :
""));
} else if (value.date_feature == '2' && value.use_different_address_per_date == '0') {
eventtype_and_city.html("" + eventtype_and_city.html() + " " + (
(value.event_venue != null && value.event_venue != "") ?
" - " + value.event_venue.toUpperCase() + "
" :
""));
} else {
eventtype_and_city.html("" + eventtype_and_city.html() + " " + (
(value.event_venue != null && value.event_venue != "") ?
" - " + value.event_venue.toUpperCase() + "
" :
""));
}
$('#event' + value.event_schedule_id).mouseover(function() {
$('.tooltip').remove();
$('.arrow').remove();
$('.tooltip-inner').remove();
$('#event' + value.event_schedule_id).tooltip('show');
});
$('#event' + value.event_schedule_id).mouseleave(function() {
$('#event' + value.event_schedule_id).not('.in');
$('#event' + value.event_schedule_id).tooltip('hide');
$('#event' + value.event_schedule_id).tooltip('dispose');
$('.tooltip').remove();
$('.arrow').remove();
$('.tooltip-inner').remove();
});
var booking_type = parseInt(value.booking_type),
back_office_status = parseInt(value.back_office_status);
displayCancelButton += booking_type;
seat_feature = value.seat_feature;
is_multiple_reservation = value.is_multiple_reservation;
is_multiple_waitlist_reservation = value.is_multiple_waitlist_reservation;
var can_still_book = 0,
showCancelBtn = 1,
cancelBtnWithModify = "Date limite d'annulation de la réservation",
fav;
if (value.event_category === 'ONLINE_EVENT') {
onlineEvent.prepareBtns(event_sched_btn, page, value);
} else {
//remove event from the list once it is deleted in the backoffice
if ((typeof disbledbtns["bos" + back_office_status] != "undefined" && disbledbtns["bos" + back_office_status] != "") && parseInt(value.book_waiting_list) == 0) {
if (page == 1 && value.is_user_active) {
/* check if there are reservations */
var btnText = disbledbtns["bos" + back_office_status],
disabled = "disabled",
href = "",
// btnClass = 'modify-reservation disabled',
btnClass = 'disabled',
btnSubText = "";
if (value.is_favorite == '1') {
var fav = ' ';
}
//Cancel & Locked - Homepage Button
if (
(value.event_status == 'CANCEL' && back_office_status != 4) ||
(value.event_status == 'CANCEL' && value.date_feature == 2 && page != 1)
) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
if (value.is_passed !== '1') {
btnText = app.get_vars()._app.btn._cancelled;
cancelledClass = 'cancelled_event disabled';
} else {
btnText = app.get_vars()._app.btn._closed;
cancelledClass = 'disabled';
}
} else {
cancelledClass = ' ';
}
if (booking_type > 0) {
if (booking_type == 1) {
if (value.is_favorite == '1') {
var fav = ' btn-favorite';
}
btnClass = 'modify-reservation';
btnText = "Modifier ou annuler ma réservation",
disabled = " ";
btnSubText = (
(back_office_status != 1 && typeof value.reservation_end_date != "undefined" && value.reservation_end_date != null && value.reservation_end_date != "") ?
"Date limite de modification de la réservation : " + Helper.start_date(value.reservation_end_date, value.end_reservation_month) + "" :
"");
} else {
if (value.is_favorite == '1') {
var fav = ' btn-favorite';
}
btnClass = ' modify-waitlistreservation';
btnText = "Modifier ou annuler mon inscription sur liste d'attente",
disabled = " ";
btnSubText = (
(back_office_status != 1 && typeof value.reservation_end_date != "undefined" && value.reservation_end_date != null && value.reservation_end_date != "") ?
"Date limite de modification de l'inscription sur liste d'attente : " + Helper.start_date(value.reservation_end_date, value.end_reservation_month) + "" :
"");
if (value.event_status == 'CANCEL' && back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
}
}
href = `href="${app.get_vars().baseurl}event_details?event_id=${value.event_id}"`;
}
event_sched_btn.append("" + btnText + " " + btnSubText);
} else {
//Cancel & Locked - Homepage Button
if (
(value.event_status == 'CANCEL' && back_office_status != 4) ||
(value.event_status == 'CANCEL' && value.date_feature == 2 && page != 1)
) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
if (value.is_passed !== '1') {
btnText = app.get_vars()._app.btn._cancelled;
cancelledClass = 'cancelled_event disabled';
} else {
btnText = app.get_vars()._app.btn._closed;
cancelledClass = 'disabled';
}
} else {
btnText = disbledbtns["bos" + back_office_status];
cancelledClass = 'disabled';
}
event_sched_btn.append("" + btnText + " ");
}
//user can reserve if there is/are still places available
} else if ((back_office_status == 2 && parseInt(value.book_waiting_list) == 0 && parseInt(value.remaining_seat) > 0) || booking_type == 1) {
showCancelBtn = (value.is_user_active) ?
subscribe.button.show_cancel_btn_or_not(booking_type, value.event_status, value.remaining_seat) :
1;
var disableBtn = "",
btnText = app.get_vars()._app.btn._book,
btnType = "",
onClick = "",
btnClass = "";
if (booking_type == 1 && value.is_user_active) { //subscriber is registered
can_still_book = subscribe.registration.options.validate_quota(booking_type, parseInt(value.seats_per_subscriber), parseInt(value.seats_reserved), parseInt(value.remaining_seat));
if (can_still_book > 0 && value.event_status != 'FULL') {
if (value.is_favorite == '1') {
var fav = ' btn-favorite';
}
var btnclosed = ' ';
disableBtn = "";
btnText = "Ajouter des places à ma réservation";
btnType = "reg-modify";
data_attrib = `data-reg-type="${REG_TYPE.normal_reg}"` +
` data-action="${SUBSCRIBE_ACTION.modify}"` +
` data-process-type="${PROCESS_TYPE.modify_reg}"` +
` data-seat-feature="${value.seat_feature}"` +
` data-show-cancel-btn="${showCancelBtn}"`;
event_listener_class = 'register-or-modify';
onClick = "";
cancelBtnWithModify = "Date limite de modification de la réservation";
} else {
if (value.is_favorite == '1') {
var fav = ' ';
}
var btnclosed = 'btnclosed ';
disableBtn = "disabled";
btnText = (typeof disbledbtns["bos" + back_office_status] != "undefined") ?
disbledbtns["bos" + back_office_status] :
"RÉSERVÉ";
btnType = "disabled";
cancelBtnWithModify = "Date limite d'annulation de la réservation ";
}
var style;
if (btnType == 'reg-book') {
style = 'style="letter-spacing:4px;"';
} else {
style = '';
}
if (value.is_favorite == '1') {
var fav = ' btn-favorite';
}
if (
(value.event_status == 'CANCEL' && back_office_status != 4) ||
(value.event_status == 'CANCEL' && value.date_feature == 2 && page != 1)
) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
btnText = app.get_vars()._app.btn._cancelled;
cancelledClass = 'cancelled_event disabled';
} else {
btnText = 'Modifier ou annuler ma réservation';
cancelledClass = '';
// cancelledClass = 'disabled';
}
cancelBtnWithModify = "Date limite de modification de la réservation";
event_sched_btn.append("" + btnText + " " + (
(typeof value.reservation_end_date != "undefined" && value.reservation_end_date != null && value.reservation_end_date != "") ?
"" + cancelBtnWithModify + " : " + Helper.start_date(value.reservation_end_date, value.end_reservation_month) + "" :
""))
if (value.event_status == 'CANCEL' && back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
}
} else {
if (value.is_user_active) {
/* This code fragment is used to determine
whether a subscriber can book for more than 1 per event or not
*/
data_attrib = `data-reg-type="${REG_TYPE.normal_reg}"` +
` data-action="${SUBSCRIBE_ACTION.register}"` +
` data-process-type="${PROCESS_TYPE.event_reg}"` +
` data-seat-feature="${value.seat_feature}"` +
` data-show-cancel-btn="${showCancelBtn}"`;
event_listener_class = 'register-or-modify';
onClick = "";
if (!eventDetails.allowed_to_book) {
event_listener_class = "not-allowed-to-book";
onClick = "";
btnClass = "btn-disabled";
} else {
disableBtn = "";
if (value.is_favorite == '1') {
var fav = ' btn-favorite';
}
}
/* END of code fragment */
var cancelledClass ="";
cancelBtnWithModify = booking_type ? "Date limite de modification de la réservation" : "Date limite de réservation";
var fav = (value.is_favorite == '1') ? ' btn-favorite' : ' ';
if (booking_type == 1) {
btnClass = 'modify-reservation';
btnText = "Ajouter des places à ma réservation";
} else if (booking_type == 2) {
btnClass = ' modify-waitlistreservation';
btnText = "Ajouter des places sur liste d'attente";
}
if (
(value.event_status == 'CANCEL' && back_office_status != 4) ||
(value.event_status == 'CANCEL' && value.date_feature == 2 && page != 1)
) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
btnText = app.get_vars()._app.btn._cancelled;
cancelledClass = 'cancelled_event disabled';
disableBtn = 'disabled="disabled"';
var hreflink = ''
} else {
cancelledClass = "";
hreflink = ' href = " ' + app.get_vars().baseurl + "event_details?event_id=" + value.event_id + ' " ';
}
var eventRate ="";
var paidEvent = "";
if( value.event_category == 'PAID_EVENT'){
let amount = parseFloat(value.rate);
paidEvent='paid_btn';
eventRate= amount ? amount.toFixed(2).replace(".", ",") + "€" : "";
}
if(subscription=='disabled'){
btnClass = "btn-disabled";
hreflink = "";
}
event_sched_btn.append("" + btnText + " " + eventRate+" " + (
(typeof value.reservation_end_date != "undefined" && value.reservation_end_date != null && value.reservation_end_date != "") ?
"" + cancelBtnWithModify + " : " + Helper.start_date(value.reservation_end_date, value.end_reservation_month) + "" :
""));
if (value.event_status == 'CANCEL' && back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
}
} else {
//when user not active redirect to login page
if (value.is_favorite == '1') {
var buttonText = "";
var cancelledClass = "";
if (value.event_status == 'CANCEL' && back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
buttonText = app.get_vars()._app.btn._cancelled;
cancelledClass = 'cancelled_event disabled';
var disabledbtn = 'disabled';
} else {
buttonText = app.get_vars()._app.btn._book;
}
var eventRate ="";
var paidEvent = "";
if( value.event_category == 'PAID_EVENT'){
let amount = parseFloat(value.rate);
paidEvent='paid_btn';
eventRate= amount ? amount.toFixed(2).replace(".", ",") + "€" : "";
}
event_sched_btn.append(" " + buttonText + " " + eventRate + " " + (
(typeof value.reservation_end_date != "undefined" && value.reservation_end_date != null && value.reservation_end_date != "") ?
"Date limite de réservation : " + Helper.start_date(value.reservation_end_date, value.end_reservation_month) + "" :
""));
if (value.event_status == 'CANCEL' && back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
}
} else {
var buttonText, paidEvent = "", eventRate = "" ,amount;
var cancelledClass = "";
if (value.event_status == 'CANCEL' && back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
buttonText = app.get_vars()._app.btn._cancelled;
cancelledClass = 'cancelled_event disabled';
var buttonType = 'disabled="disabled"';
} else {
buttonType = '';
buttonText = app.get_vars()._app.btn._book;
}
var eventRate ="";
var paidEvent = "";
if( value.event_category == 'PAID_EVENT'){
let amount = parseFloat(value.rate);
paidEvent='paid_btn';
eventRate= amount ? amount.toFixed(2).replace(".", ",") + "€" : "";
}
event_sched_btn.append("" + buttonText +" "+ eventRate +" " + (
(typeof value.reservation_end_date != "undefined" && value.reservation_end_date != null && value.reservation_end_date != "") ?
"Date limite de réservation : " + Helper.start_date(value.reservation_end_date, value.end_reservation_month) + "" :
"")) + "";
if (value.event_status == 'CANCEL' && back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
}
}
}
}
//when event is locked yet,..
} else if (back_office_status == 3 || parseInt(value.book_waiting_list) > 0 || booking_type == 2) {
var disableBtn = "",
btnText = app.get_vars()._app.btn._bookwaitlist,
btnType = "",
onClick = "",
btnClass = "";
if (booking_type == 2 && value.is_user_active) { //subscriber is booked in the waiting list
can_still_book = subscribe.registration.options.validate_quota(booking_type, parseInt(value.quota_waiting_list_seat), parseInt(value.seats_reserved), parseInt(value.seats_per_subscriber));
cancelBtnWithModify = "Date limite de modification de la réservation";
if (can_still_book > 0) {
btnClass = ' modify-waitlistreservation ';
disableBtn = "";
btnText = "Ajouter des places sur liste d'attente";
btnType = "wl-modify";
data_attrib = `data-reg-type="${REG_TYPE.waitlist_reg}"` +
` data-action="${SUBSCRIBE_ACTION.modify}"` +
` data-process-type="${PROCESS_TYPE.modify_wl_reg}"` +
` data-seat-feature="${value.seat_feature}"` +
` data-show-cancel-btn="${showCancelBtn}"`;
event_listener_class = 'register-or-modify';
onClick = "";
cancelBtnWithModify = "Date limite de modification de l'inscription sur liste d'attente";
if (value.is_favorite == '1') {
var fav = ' btn-favorite';
}
} else {
btnClass = 'modify-reservation';
disableBtn = "disabled";
btnText = (typeof disbledbtns["bos" + back_office_status] != "undefined") ?
disbledbtns["bos" + back_office_status] :
"INSCRIT SUR LISTE D'ATTENTE";
btnType = "disabled";
cancelBtnWithModify = "Date limite d'annulation d'inscription sur liste d'attente";
if (value.is_favorite == '1') {
var fav = ' ';
}
}
if (value.is_favorite == '1') {
var fav = ' btn-favorite';
}
cancelBtnWithModify = "Date limite de modification de l'inscription sur liste d'attente";
event_sched_btn.append("Modifier ou annuler mon inscription sur liste d'attente " + (
(typeof value.reservation_end_date != "undefined" && value.reservation_end_date != null && value.reservation_end_date != "") ?
"" + cancelBtnWithModify + " : " + Helper.start_date(value.reservation_end_date, value.end_reservation_month) + "" :
""));
if (value.event_status == 'CANCEL' && back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
}
} else {
if (value.is_user_active) { //if user is active
/* This code fragment is used to determine
whether a subscriber can book for more than 1 per event or not
*/
data_attrib = `data-reg-type="${REG_TYPE.waitlist_reg}"` +
` data-action="${SUBSCRIBE_ACTION.register}"` +
` data-process-type="${PROCESS_TYPE.waitlist_reg}"` +
` data-seat-feature="${value.seat_feature}"` +
` data-show-cancel-btn="${showCancelBtn}"`;
event_listener_class = 'register-or-modify';
onClick = "";
if (!eventDetails.allowed_to_book_for_wl) {
event_listener_class = "not-allowed-to-book";
onClick = "";
btnClass = "btn-disabled modify-reservation btn-reg-waitlist_detailsp";
if (value.is_favorite == '1') {
var fav = ' ';
}
} else {
disableBtn = "";
if (page == 1) {
btnClass = 'btn-reg-waitlist';
} else {
btnClass = 'btn-reg-waitlist_detailsp modify-reservation';
}
// btnClass = 'modify-reservation';
if (value.is_favorite == '1') {
var fav = ' btn-favorite';
}
}
/* END of code fragment */
if (booking_type > 0) {
cancelBtnWithModify = "Date limite de modification de la réservation";
} else {
cancelBtnWithModify = "Date limite d'inscription sur liste d'attente";
}
if (booking_type == 1) {
btnClass = 'modify-reservation';
btnText = "Ajouter des places à ma réservation";
} else if (booking_type == 2) {
btnClass = ' modify-waitlistreservation';
btnText = "Ajouter des places sur liste d'attente";
}
if (value.event_status == 'CANCEL' && back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
btnText = app.get_vars()._app.btn._cancelled;
cancelledClass = 'cancelled_event disabled';
} else {
cancelledClass = '';
// cancelledClass = 'disabled';
}
hrefLink = 'href='+ app.get_vars().baseurl + "event_details?event_id=" + value.event_id
if(subscription=='disabled'){
btnClass = 'btn-disabled modify-reservation';
disableBtn = 'disabled="disabled"'
hreflink = "";
}
event_sched_btn.append(" " + btnText + " " + (
(typeof value.reservation_end_date != "undefined" && value.reservation_end_date != null && value.reservation_end_date != "") ?
"" + cancelBtnWithModify + " : " + Helper.start_date(value.reservation_end_date, value.end_reservation_month) + "" :
""));
if (value.event_status == 'CANCEL' && back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
}
} else {
//when user not active redirect to login page
if (value.is_favorite == '1') {
event_sched_btn.append(" " + app.get_vars()._app.btn._bookwaitlist + " " + (
(typeof value.reservation_end_date != "undefined" && value.reservation_end_date != null && value.reservation_end_date != "") ?
"Date limite d'inscription sur liste d'attente : " + Helper.start_date(value.reservation_end_date, value.end_reservation_month) + "" :
""));
if (value.event_status == 'CANCEL' && back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
}
} else {
event_sched_btn.append(" " + app.get_vars()._app.btn._bookwaitlist + " " + (
(typeof value.reservation_end_date != "undefined" && value.reservation_end_date != null && value.reservation_end_date != "") ?
"Date limite d'inscription sur liste d'attente : " + Helper.start_date(value.reservation_end_date, value.end_reservation_month) + "" :
""));
if (value.event_status == 'CANCEL' && back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
}
}
}
}
} else {
if ((value.event_status == 'CANCEL' && back_office_status != 4) && (value.event_status == 'CANCEL' && value.date_feature == 2 && page != 1)) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
btnText = app.get_vars()._app.btn._cancelled;
cancelledClass = 'cancelled_event disabled';
// btnClass = 'modify-reservation';
event_sched_btn.replaceWith($("" + btnText + " " + (
(typeof value.reservation_end_date != "undefined" && value.reservation_end_date != null && value.reservation_end_date != "") ?
"" + cancelBtnWithModify + " : " + Helper.start_date(value.reservation_end_date, value.end_reservation_month) + "" :
"")));
if (value.event_status == 'CANCEL' && back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
}
} else if (value.event_status == 'CANCEL' && back_office_status == 4 && value.date_feature == 2) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
btnText = app.get_vars()._app.btn._cancelled;
cancelledClass = 'cancelled_event disabled';
// btnClass = 'modify-reservation';
event_sched_btn.append(" " + btnText + " " + (
(typeof value.reservation_end_date != "undefined" && value.reservation_end_date != null && value.reservation_end_date != "") ?
"" + cancelBtnWithModify + " : " + Helper.start_date(value.reservation_end_date, value.end_reservation_month) + "" :
""));
if (value.event_status == 'CANCEL' && back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
}
} else {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
btnText = app.get_vars()._app.btn._cancelled;
cancelledClass = 'cancelled_event disabled';
// btnClass = 'modify-reservation';
event_sched_btn.append($("" + btnText + " " + (
(typeof value.reservation_end_date != "undefined" && value.reservation_end_date != null && value.reservation_end_date != "") ?
"" + cancelBtnWithModify + " : " + Helper.start_date(value.reservation_end_date, value.end_reservation_month) + "" :
"")));
if (value.event_status == 'CANCEL' && back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
}
}
}
if (page == 1 && back_office_status == 1) {
if (typeof value.reservation_start_date != "undefined" && value.reservation_start_date != null && value.reservation_start_date != "") {
event_sched_btn.append("Ouverture des réservations : " + Helper.start_date(value.reservation_start_date, value.reservation_start_month) + " ");
if (value.event_status == 'CANCEL' && back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
}
} else {
event_sched_btn.append("Ouverture des réservations : " + Helper.start_date(value.reservation_start_date, value.end_reservation_month) + " ");
if (value.event_status == 'CANCEL' && back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
}
}
}
}
});
},
"change": function(id, page, target, updateBtn) {
$.ajax({
url: app.get_vars().baseurl + "events/homepage/check_bo_status",
type: 'GET',
data: {
query_id: id,
page: page
},
/* query_id can be the event_id or the event_schedule_id */
success: function(result) {
// if(app.isalive(result)) {
var displayCancelButton = 0,
event_sched = "",
disbledbtns = {
"bos1": app.get_vars()._app.btn.coming_soon,
"bos3": app.get_vars()._app.btn._full,
"bos4": app.get_vars()._app.btn._closed,
"bos7": app.get_vars()._app.btn._terminee,
"bos8": app.get_vars()._app.btn._cancelled
},
seat_feature = 1,
is_multiple_reservation = 0,
is_multiple_waitlist_reservation = 0,
data_attrib = '',
event_listener_class = '';
$.map(result.event_status, function(value, key) {
$('.tooltip').remove();
$('.arrow').remove();
$('.tooltip-inner').remove();
if (page == 2) { //event detailed page
var event_sched_date = $("#accordion-heading-es" + value.event_schedule_id);
var event_sched_btn = $("#event_schedule_id" + value.event_schedule_id);
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
} else { // Home page
$('.tooltip').remove();
$('.arrow').remove();
$('.tooltip-inner').remove();
var event_sched_btn = target;
//set date
$("#hp-event-date" + value.event_schedule_id).text(subscribe.registration.options.translate_date.init(value));
//get city
var eventtype_and_city = $("#hp-event-type-city" + value.event_schedule_id);
if (value.date_feature == '2') {
eventtype_and_city.html("" + eventtype_and_city.html() + " " + (
(value.event_venue != null && value.event_venue != "") ?
"
" :
""));
} else {
eventtype_and_city.html("" + eventtype_and_city.html() + " " + (
(value.event_venue != null && value.event_venue != "") ?
" - " + value.event_venue.toUpperCase() + "
" :
""));
}
$('#event' + value.event_schedule_id).mouseover(function() {
$('.tooltip').remove();
$('.arrow').remove();
$('.tooltip-inner').remove();
$('#event' + value.event_schedule_id).tooltip('show');
});
$('#event' + value.event_schedule_id).mouseleave(function() {
$('#event' + value.event_schedule_id).not('.in');
$('#event' + value.event_schedule_id).tooltip('hide');
$('#event' + value.event_schedule_id).tooltip('dispose');
$('.tooltip').remove();
$('.arrow').remove();
$('.tooltip-inner').remove();
});
}
var booking_type = parseInt(value.booking_type),
back_office_status = parseInt(value.back_office_status);
displayCancelButton += booking_type;
seat_feature = value.seat_feature;
is_multiple_reservation = value.is_multiple_reservation;
is_multiple_waitlist_reservation = value.is_multiple_waitlist_reservation;
var can_still_book = 0,
showCancelBtn = 1,
cancelBtnWithModify = "Date limite d'annulation de la réservation",
fav,
cancelledClass= '';
//remove event from the list once it is deleted in the backoffice
if (parseInt(value.status) == 0 || (back_office_status == 6 || back_office_status == 0)) {
if (page == 2) {
$("#accordion-group-es" + value.event_schedule_id).remove();
}
} else if ((typeof disbledbtns["bos" + back_office_status] != "undefined" && disbledbtns["bos" + back_office_status] != "") && parseInt(value.book_waiting_list) == 0) {
var fav = '';
var btnTextt = '';
if (page == 2 && value.is_user_active) { //event detailed page
if (booking_type == 2) {
cancelBtnWithModify = "Date limite d'annulation d'inscription sur liste d'attente";
}
if (value.is_favorite == '1') {
fav = '';
}
if (
(value.event_status == 'CANCEL' && value.back_office_status != 4) ||
(value.event_status == 'CANCEL' && value.date_feature == 2 && page != 1)
) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
btnTextt = app.get_vars()._app.btn._cancelled;
cancelledClass = 'cancelled_event disabled';
}
//event sched is 1= Published, 3=Lokced/Complete, 7=Terminee, 4 = Closed/Passed
event_sched_btn.replaceWith($("" + (btnTextt == app.get_vars()._app.btn._cancelled ? app.get_vars()._app.btn._cancelled : disbledbtns["bos" + back_office_status]) + " "));
} else { // HP
if (page == 1 && value.is_user_active) {
/* check if there are reservations */
var btnText = disbledbtns["bos" + back_office_status],
disabled = "disabled",
href = "",
btnClass = 'modify-reservation disabled',
btnSubText = "",
fav = ' ';
if (value.is_favorite == '1') {
fav = ' ';
}
//Cancel & Locked - Homepage Button
if (
(value.event_status == 'CANCEL' && value.back_office_status != 4) ||
(value.event_status == 'CANCEL' && value.date_feature == 2 && page != 1)
) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
var cur_date = new Date();
var start_date_time = (value.start_date_hour) ? value.start_date_hour.split("h") : '';
var end_date_time = (value.end_date_hour) ? value.end_date_hour.split("h") : '';
var start_date_time_h = '',
start_date_time_m = '',
end_date_time_h = '',
end_date_time_m = '';
if (start_date_time) {
start_date_time_h = start_date_time[0];
start_date_time_m = start_date_time[1];
}
if (end_date_time) {
end_date_time_h = end_date_time[0];
end_date_time_m = end_date_time[1];
}
var start_date = new Date(value.start_year + ', ' + value.start_month + ', ' + value.start_day + ', ' + start_date_time_h + ', ' + start_date_time_m);
var end_date = new Date(value.end_year + ', ' + value.end_month + ', ' + value.end_day + ', ' + end_date_time_h + ', ' + end_date_time_m);
// console.log(new Date(end_date));
if (!end_date) {
if (cur_date > end_date) {
btnText = app.get_vars()._app.btn._closed;
cancelledClass = '';
} else {
btnText = app.get_vars()._app.btn._cancelled;
cancelledClass = 'cancelled_event disabled';
}
} else {
if (cur_date > start_date) {
btnText = app.get_vars()._app.btn._closed;
cancelledClass = '';
} else {
btnText = app.get_vars()._app.btn._cancelled;
cancelledClass = 'cancelled_event disabled';
}
}
} else {
cancelledClass = ' ';
}
if (booking_type > 0) {
if (booking_type == 1) {
if (value.is_favorite == '1') {
fav = ' btn-favorite';
}
btnClass = 'modify-reservation';
btnText = "Ajouter des places à ma réservation",
disabled = " ";
btnSubText = (
(back_office_status != 1 && typeof value.reservation_end_date != "undefined" && value.reservation_end_date != null && value.reservation_end_date != "") ?
"Date limite de modification de la réservation : " + Helper.start_date(value.reservation_end_date, value.end_reservation_month) + "" :
"");
} else {
if (value.is_favorite == '1') {
fav = ' btn-favorite';
}
btnClass = ' modify-waitlistreservation';
btnText = "Ajouter des places sur liste d'attente",
disabled = " ";
btnSubText = (
(back_office_status != 1 && typeof value.reservation_end_date != "undefined" && value.reservation_end_date != null && value.reservation_end_date != "") ?
"Date limite de modification de l'inscription sur liste d'attente : " + Helper.start_date(value.reservation_end_date, value.end_reservation_month) + "" :
"");
if (value.event_status == 'CANCEL' && value.back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
}
}
href = `href="${app.get_vars().baseurl}event_details?event_id=${value.event_id}`;
href = app.get_vars().baseurl + "event_details?event_id=" + value.event_id;
}
event_sched_btn.append("" + btnText + " " + btnSubText);
} else {
//Cancel & Locked - Homepage Button
if (
(value.event_status == 'CANCEL' && value.back_office_status != 4) ||
(value.event_status == 'CANCEL' && value.date_feature == 2 && page != 1)
) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
var cur_date = new Date();
var start_date_time = (value.start_date_hour) ? value.start_date_hour.split("h") : '';
var end_date_time = (value.end_date_hour) ? value.end_date_hour.split("h") : '';
var start_date_time_h = '',
start_date_time_m = '',
end_date_time_h = '',
end_date_time_m = '';
if (start_date_time) {
start_date_time_h = start_date_time[0];
start_date_time_m = start_date_time[1];
}
if (end_date_time) {
end_date_time_h = end_date_time[0];
end_date_time_m = end_date_time[1];
}
var start_date = new Date(value.start_year + ', ' + value.start_month + ', ' + value.start_day + ', ' + start_date_time_h + ', ' + start_date_time_m);
var end_date = new Date(value.end_year + ', ' + value.end_month + ', ' + value.end_day + ', ' + end_date_time_h + ', ' + end_date_time_m);
// console.log(new Date(end_date));
if (!end_date) {
if (cur_date > end_date) {
btnText = app.get_vars()._app.btn._closed;
cancelledClass = 'disabled';
} else {
btnText = app.get_vars()._app.btn._cancelled;
cancelledClass = 'cancelled_event disabled';
}
} else {
if (cur_date > start_date) {
btnText = app.get_vars()._app.btn._closed;
cancelledClass = 'disabled';
} else {
btnText = app.get_vars()._app.btn._cancelled;
cancelledClass = 'cancelled_event disabled';
}
}
} else {
btnText = disbledbtns["bos" + back_office_status];
cancelledClass = 'disabled';
}
event_sched_btn.append("" + btnText + " ");
}
}
//user can reserve if there is/are still places available
} else if ((back_office_status == 2 && parseInt(value.book_waiting_list) == 0 && parseInt(value.remaining_seat) > 0) || booking_type == 1) {
showCancelBtn = (value.is_user_active) ?
subscribe.button.show_cancel_btn_or_not(booking_type, value.event_status, value.remaining_seat) :
1;
var disableBtn = "",
btnText = app.get_vars()._app.btn._book,
btnType = "",
onClick = "",
btnClass = "",
fav = "";
if (booking_type == 1 && value.is_user_active) { //subscriber is registered
can_still_book = subscribe.registration.options.validate_quota(booking_type, parseInt(value.seats_per_subscriber), parseInt(value.seats_reserved), parseInt(value.remaining_seat));
if (can_still_book > 0 && value.event_status != 'FULL') {
if (value.is_favorite == '1') {
fav = ' btn-favorite';
}
var btnclosed = ' ';
disableBtn = "";
btnText = "Ajouter des places à ma réservation";
btnType = "reg-modify";
data_attrib = `data-reg-type="${REG_TYPE.normal_reg}"` +
` data-action="${SUBSCRIBE_ACTION.modify}"` +
` data-process-type="${PROCESS_TYPE.modify_reg}"` +
` data-seat-feature="${value.seat_feature}"` +
` data-show-cancel-btn="${showCancelBtn}"`;
event_listener_class = 'register-or-modify';
onClick = "";
cancelBtnWithModify = "Date limite de modification de la réservation";
} else {
if (value.is_favorite == '1') {
fav = ' ';
}
var btnclosed = 'btnclosed ';
disableBtn = "disabled";
btnText = (typeof disbledbtns["bos" + back_office_status] != "undefined") ?
disbledbtns["bos" + back_office_status] :
"RÉSERVÉ";
btnType = "disabled";
cancelBtnWithModify = "Date limite d'annulation de la réservation ";
}
var style;
if (btnType == 'reg-book') {
style = 'style="letter-spacing:4px;"';
} else {
style = '';
}
if (page == 2) { //event detailed page
event_sched_btn.replaceWith($("" + btnText + " ").prop("disabled", (
(disableBtn != "") ?
true :
false)));
} else { //HP
if (value.is_favorite == '1') {
var fav = ' btn-favorite';
}
if (
(value.event_status == 'CANCEL' && value.back_office_status != 4) ||
(value.event_status == 'CANCEL' && value.date_feature == 2 && page != 1)
) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
btnText = app.get_vars()._app.btn._cancelled;
cancelledClass = 'cancelled_event disabled';
} else {
btnText = 'Ajouter des places à ma réservation';
cancelledClass = '';
// cancelledClass = 'disabled';
}
cancelBtnWithModify = "Date limite de modification de la réservation";
event_sched_btn.append("" + btnText + " " + (
(typeof value.reservation_end_date != "undefined" && value.reservation_end_date != null && value.reservation_end_date != "") ?
"" + cancelBtnWithModify + " : " + Helper.start_date(value.reservation_end_date, value.end_reservation_month) + "" :
""))
if (value.event_status == 'CANCEL' && value.back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
}
}
} else {
if (value.is_user_active) {
/* This code fragment is used to determine
whether a subscriber can book for more than 1 per event or not
*/
data_attrib = `data-reg-type="${REG_TYPE.normal_reg}"` +
` data-action="${SUBSCRIBE_ACTION.register}"` +
` data-process-type="${PROCESS_TYPE.event_reg}"` +
` data-seat-feature="${value.seat_feature}"` +
` data-show-cancel-btn="${showCancelBtn}"`;
event_listener_class = 'register-or-modify';
onClick = "";
if (!result.allowed_to_book) {
event_listener_class = "not-allowed-to-book";
onClick = "";
btnClass = "btn-disabled";
} else {
disableBtn = "";
if (value.is_favorite == '1') {
var fav = ' btn-favorite';
}
}
/* END of code fragment */
if (page == 2) { //event detailed page
if (
(value.event_status == 'CANCEL' && value.back_office_status != 4) ||
(value.event_status == 'CANCEL' && value.date_feature == 2 && page != 1)
) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
btnText = app.get_vars()._app.btn._cancelled;
cancelledClass = 'cancelled_event disabled';
disableBtn = 'disabled';
} else {
cancelledClass = '';
// cancelledClass = 'disabled';
}
event_sched_btn.replaceWith($("" + btnText + " " + (
(typeof value.reservation_end_date != "undefined" && value.reservation_end_date != null && value.reservation_end_date != "") ?
"Date limite de réservation : " + Helper.start_date(value.reservation_end_date, value.end_reservation_month) + "" :
"")).prop("disabled", (
(disableBtn != "") ?
true :
false)));
if (value.event_status == 'CANCEL' && value.back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
}
} else { //on HP
if (booking_type > 0) {
cancelBtnWithModify = "Date limite de modification de la réservation";
} else {
cancelBtnWithModify = "Date limite de réservation";
}
if (booking_type == 1) {
btnClass = 'modify-reservation';
btnText = "Ajouter des places à ma réservation";
if (value.is_favorite == '1') {
var fav = ' btn-favorite';
} else {
fav = ' ';
}
} else if (booking_type == 2) {
if (value.is_favorite == '1') {
var fav = ' btn-favorite';
} else {
fav = ' ';
}
btnClass = ' modify-waitlistreservation';
btnText = "Ajouter des places sur liste d'attente";
}
if (
(value.event_status == 'CANCEL' && value.back_office_status != 4) ||
(value.event_status == 'CANCEL' && value.date_feature == 2 && page != 1)
) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
btnText = app.get_vars()._app.btn._cancelled;
cancelledClass = 'cancelled_event disabled';
disableBtn = 'disabled="disabled"';
var hreflink = ''
} else {
cancelledClass = "";
hreflink = ' href = " ' + app.get_vars().baseurl + "event_details?event_id=" + value.event_id + ' " ';
}
event_sched_btn.append("" + btnText + " " + (
(typeof value.reservation_end_date != "undefined" && value.reservation_end_date != null && value.reservation_end_date != "") ?
"" + cancelBtnWithModify + " : " + Helper.start_date(value.reservation_end_date, value.end_reservation_month) + "" :
""));
if (value.event_status == 'CANCEL' && value.back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
}
}
} else {
//when user not active redirect to login page
if (value.is_favorite == '1') {
var buttonText = "";
var cancelledClass = "";
if (value.event_status == 'CANCEL' && value.back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
buttonText = app.get_vars()._app.btn._cancelled;
cancelledClass = 'cancelled_event disabled';
var disabledbtn = 'disabled';
} else {
buttonText = app.get_vars()._app.btn._book;
}
event_sched_btn.append(" " + buttonText + " " + (
(typeof value.reservation_end_date != "undefined" && value.reservation_end_date != null && value.reservation_end_date != "") ?
"Date limite de réservation : " + Helper.start_date(value.reservation_end_date, value.end_reservation_month) + "" :
""));
if (value.event_status == 'CANCEL' && value.back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
}
} else {
var buttonText = "";
var cancelledClass = "";
if (value.event_status == 'CANCEL' && value.back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
buttonText = app.get_vars()._app.btn._cancelled;
cancelledClass = 'cancelled_event disabled';
var buttonType = 'disabled="disabled"';
} else {
buttonType = '';
buttonText = app.get_vars()._app.btn._book;
}
event_sched_btn.append(" " + buttonText + " " + (
(typeof value.reservation_end_date != "undefined" && value.reservation_end_date != null && value.reservation_end_date != "") ?
"Date limite de réservation : " + Helper.start_date(value.reservation_end_date, value.end_reservation_month) + "" :
"")) + "";
if (value.event_status == 'CANCEL' && value.back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
}
}
}
}
//when event is locked yet,..
} else if (back_office_status == 3 || parseInt(value.book_waiting_list) > 0 || booking_type == 2) {
var disableBtn = "",
btnText = app.get_vars()._app.btn._bookwaitlist,
btnType = "",
onClick = "",
btnClass = "",
fav="";
if (booking_type == 2 && value.is_user_active) { //subscriber is booked in the waiting list
can_still_book = subscribe.registration.options.validate_quota(booking_type, parseInt(value.quota_waiting_list_seat), parseInt(value.seats_reserved), parseInt(value.seats_per_subscriber));
cancelBtnWithModify = "Date limite de modification de la réservation";
if (can_still_book > 0) {
btnClass = ' modify-waitlistreservation ';
disableBtn = "";
btnText = "Ajouter des places sur liste d'attente";
btnType = "wl-modify";
data_attrib = `data-reg-type="${REG_TYPE.waitlist_reg}"` +
` data-action="${SUBSCRIBE_ACTION.modify}"` +
` data-process-type="${PROCESS_TYPE.modify_wl_reg}"` +
` data-seat-feature="${value.seat_feature}"` +
` data-show-cancel-btn="${showCancelBtn}"`;
event_listener_class = 'register-or-modify';
onClick = "";
cancelBtnWithModify = "Date limite de modification de l'inscription sur liste d'attente";
if (value.is_favorite == '1') {
fav = ' btn-favorite';
}
} else {
btnClass = 'modify-reservation';
disableBtn = "disabled";
btnText = (typeof disbledbtns["bos" + back_office_status] != "undefined") ?
disbledbtns["bos" + back_office_status] :
"INSCRIT SUR LISTE D'ATTENTE";
btnType = "disabled";
cancelBtnWithModify = "Date limite d'annulation d'inscription sur liste d'attente";
if (value.is_favorite == '1') {
fav = ' ';
}
}
if (page == 2) { //event detailed page
event_sched_btn.replaceWith($("" + btnText + " ").prop("disabled", (
(disableBtn != "") ?
true :
false)));
} else { //event home page
if (value.is_favorite == '1') {
fav = ' btn-favorite';
}
cancelBtnWithModify = "Date limite de modification de l'inscription sur liste d'attente";
event_sched_btn.append("Ajouter des places sur liste d'attente " + (
(typeof value.reservation_end_date != "undefined" && value.reservation_end_date != null && value.reservation_end_date != "") ?
"" + cancelBtnWithModify + " : " + Helper.start_date(value.reservation_end_date, value.end_reservation_month) + "" :
""));
if (value.event_status == 'CANCEL' && value.back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
}
}
} else {
if (value.is_user_active) { //if user is active
/* This code fragment is used to determine
whether a subscriber can book for more than 1 per event or not
*/
data_attrib = `data-reg-type="${REG_TYPE.waitlist_reg}"` +
` data-action="${SUBSCRIBE_ACTION.register}"` +
` data-process-type="${PROCESS_TYPE.waitlist_reg}"` +
` data-seat-feature="${value.seat_feature}"` +
` data-show-cancel-btn="${showCancelBtn}"`;
event_listener_class = 'register-or-modify'
onClick = "";
var fav = "";
if (!result.allowed_to_book_for_wl) {
event_listener_class = "not-allowed-to-book";
onClick = "";
btnClass = "btn-disabled modify-reservation btn-reg-waitlist_detailsp";
if (value.is_favorite == '1') {
fav = ' ';
}
} else {
disableBtn = "";
if (page == 1) {
btnClass = 'btn-reg-waitlist';
} else {
btnClass = 'btn-reg-waitlist_detailsp modify-reservation';
}
// btnClass = 'modify-reservation';
if (value.is_favorite == '1') {
fav = ' btn-favorite';
}
}
/* END of code fragment */
if (page == 2) { //event detailed page
//event is locked but there are still places available for waitiling list
event_sched_btn.replaceWith($("" + btnText + " " + (
(typeof value.reservation_end_date != "undefined" && value.reservation_end_date != null && value.reservation_end_date != "") ?
"Date limite d'inscription sur liste d'attente : " + Helper.start_date(value.reservation_end_date, value.end_reservation_month) + "" :
"")).addClass('').prop("disabled", (
(disableBtn != "") ?
true :
false)));
if (value.event_status == 'CANCEL' && value.back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
}
} else { //event home page
if (booking_type > 0) {
cancelBtnWithModify = "Date limite de modification de la réservation";
} else {
cancelBtnWithModify = "Date limite d'inscription sur liste d'attente";
}
if (booking_type == 1) {
btnClass = 'modify-reservation';
btnText = "Ajouter des places à ma réservation";
} else if (booking_type == 2) {
btnClass = ' modify-waitlistreservation';
btnText = "Ajouter des places sur liste d'attente";
}
if (value.event_status == 'CANCEL' && value.back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
btnText = app.get_vars()._app.btn._cancelled;
cancelledClass = 'cancelled_event disabled';
} else {
cancelledClass = '';
// cancelledClass = 'disabled';
}
// btnClass = 'modify-reservation';
event_sched_btn.append(" " + btnText + " " + (
(typeof value.reservation_end_date != "undefined" && value.reservation_end_date != null && value.reservation_end_date != "") ?
"" + cancelBtnWithModify + " : " + Helper.start_date(value.reservation_end_date, value.end_reservation_month) + "" :
""));
if (value.event_status == 'CANCEL' && value.back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
}
}
} else {
//when user not active redirect to login page
if (value.is_favorite == '1') {
event_sched_btn.append(" " + app.get_vars()._app.btn._bookwaitlist + " " + (
(typeof value.reservation_end_date != "undefined" && value.reservation_end_date != null && value.reservation_end_date != "") ?
"Date limite d'inscription sur liste d'attente : " + Helper.start_date(value.reservation_end_date, value.end_reservation_month) + "" :
""));
if (value.event_status == 'CANCEL' && value.back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
}
} else {
event_sched_btn.append(" " + app.get_vars()._app.btn._bookwaitlist + " " + (
(typeof value.reservation_end_date != "undefined" && value.reservation_end_date != null && value.reservation_end_date != "") ?
"Date limite d'inscription sur liste d'attente : " + Helper.start_date(value.reservation_end_date, value.end_reservation_month) + "" :
""));
if (value.event_status == 'CANCEL' && value.back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
}
}
}
}
} else {
if ((value.event_status == 'CANCEL' && value.back_office_status != 4) && (value.event_status == 'CANCEL' && value.date_feature == 2 && page != 1)) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
btnText = app.get_vars()._app.btn._cancelled;
cancelledClass = 'cancelled_event disabled';
// btnClass = 'modify-reservation';
event_sched_btn.replaceWith($("" + btnText + " " + (
(typeof value.reservation_end_date != "undefined" && value.reservation_end_date != null && value.reservation_end_date != "") ?
"" + cancelBtnWithModify + " : " + Helper.start_date(value.reservation_end_date, value.end_reservation_month) + "" :
"")));
if (value.event_status == 'CANCEL' && value.back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
}
} else if (value.event_status == 'CANCEL' && value.back_office_status == 4 && value.date_feature == 2) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
btnText = app.get_vars()._app.btn._cancelled;
cancelledClass = 'cancelled_event disabled';
// btnClass = 'modify-reservation';
event_sched_btn.append(" " + btnText + " " + (
(typeof value.reservation_end_date != "undefined" && value.reservation_end_date != null && value.reservation_end_date != "") ?
"" + cancelBtnWithModify + " : " + Helper.start_date(value.reservation_end_date, value.end_reservation_month) + "" :
""));
if (value.event_status == 'CANCEL' && value.back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
}
} else {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
btnText = app.get_vars()._app.btn._cancelled;
cancelledClass = 'cancelled_event disabled';
// btnClass = 'modify-reservation';
event_sched_btn.append($("" + btnText + " " + (
(typeof value.reservation_end_date != "undefined" && value.reservation_end_date != null && value.reservation_end_date != "") ?
"" + cancelBtnWithModify + " : " + Helper.start_date(value.reservation_end_date, value.end_reservation_month) + "" :
"")));
if (value.event_status == 'CANCEL' && value.back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
}
}
}
if (page == 1 && back_office_status == 1) {
if (typeof value.reservation_start_date != "undefined" && value.reservation_start_date != null && value.reservation_start_date != "") {
event_sched_btn.append("Ouverture des réservations : " + Helper.start_date(value.reservation_start_date, value.reservation_start_month) + " ");
if (value.event_status == 'CANCEL' && value.back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
}
} else {
event_sched_btn.append("Ouverture des réservations : " + Helper.start_date(value.reservation_start_date, value.end_reservation_month) + " ");
if (value.event_status == 'CANCEL' && value.back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
}
}
}
if (page == 2 && value.is_user_active && back_office_status > 1) {
var btnClass = "";
//display cancel button if there is/are reservation
$("#event_cancel_registration" + value.event_schedule_id).remove();
/* Cancel button will be hidden once a seat is available for reservation */
if (subscribe.button.show_cancel_btn_or_not(booking_type, value.event_status, value.remaining_seat) == 1) {
if (booking_type == 1) {
btnClass = 'btn-cancel-registration';
} else {
btnClass = 'btn-cancel-wl-registration';
}
data_attrib = `data-event-id="${value.event_id}"` +
` data-event-schedule-id="${value.event_schedule_id}"` +
` data-reg-type="${booking_type}"`;
event_listener_class = 'cancel-reservation';
$('' + (
(booking_type == 1) ?
"Modifier ou annuler ma réservation" :
"MODIFIER OU ANNULER MON INSCRIPTION SUR LISTE D'ATTENTE") + ' ' + (
// ? "ANNULER MA RÉSERVATION"
// : "ANNULER MON INSCRIPTION SUR LISTE D’ATTENTE") + '' + (
(typeof value.reservation_end_date != "undefined" && value.reservation_end_date != null && value.reservation_end_date != "") ?
'' + cancelBtnWithModify + ' : ' + Helper.start_date(value.reservation_end_date, value.end_reservation_month) + '' :
'')).insertAfter($("#event_schedule_id" + value.event_schedule_id));
if (value.event_status == 'CANCEL' && value.back_office_status != 4) {
$("#res-date-" + value.event_schedule_id).remove(); //remove texts
}
}
}
// Add event category
let resBtns = $('button.btn, a.btn');
resBtns.attr('data-event-cat', value.event_category);
if (value.event_url) resBtns.attr('data-event_url', value.event_url);
});
} // end of sucess
});
},
"show_cancel_btn_or_not": function(booking_type, event_status, remaining_seat) {
remaining_seat = (remaining_seat != "" && remaining_seat != null) ?
parseInt(remaining_seat) :
0;
if (booking_type == 1) { //normal registration
return 1;
} else if (booking_type == 2) { //waitinglist registration
if (event_status == 'AVAILABLE' && remaining_seat > 0) {
//the subscriber is currently registered for waitinglist then suddenly seats are open for reservation
return 2;
} else {
return 1;
}
}
return 0;
},
/**
* Since there's no cancellation with Paid Event
* We will just show a prompt or dialog instead of redirecting subscriber to La Botique
*/
"pe_cancellation": () => {
$("#pe-cancel-reservation-modal").modal('show');
}
},
"show_moderation_details" : function() {
$.ajax({
url: app.get_vars().baseurl + "getMyReservationsInfo/",
type: "GET",
cache: false,
async: false,
data: {},
beforeSend: function() {
// $("#events_list").append(' '+app.get_vars()._app.notif.loading+'
');
},
success: function(result1) {
if (app.isalive(result1)) {
try {
if (result1.res_period) {
$('.mod_count').html(result1.max_res);
$('.remaining_res_based_on_mod').html(`${result1.remaining_res_current_period} ${result1.res_period}`);
/*Set dynamic data*/
$("span.total_reservation_count").text(result1.total_reservation_count);
$('span.total_reservation_mod_event_count').html(result1.total_reservation_mod_event_count);
$('span.remaining_res_current_period').html(result1.remaining_res_current_period);
$('span.remaining_res_next_period').html(result1.remaining_res_next_period);
$('span.res_period2').html(result1.res_period2);
$('span.res_period3').html(result1.res_period3);
$('span.when_can_reserve').html(result1.when_can_reserve);
if (result1.remaining_res == 0) {
$('.nr_exceeded_msg').removeAttr('hidden');
}
// $('.my_res_gen_header').append(
// `* Out of ${result1.max_res} maximum reservations, you have ${result1.remaining_res} remaining reservations left for moderated events for ${result1.res_period} `
// )
}
// if (result1.nshow_period) {
// $('.my_res_gen_header').append(
// `* Out of ${result1.max_noshow} maximum noshow(s), you have ${result1.total_noshow} noshow(s) for the past ${result1.nshow_period} . If you reach the limit for the said period, you will not be allowed to reserve on moderated events `
// )
// }
} catch (e) {} finally {
}
}
}
});
},
"show_general_setting_moderation":function () {
$.ajax({
url: app.get_vars().baseurl + "getModerationGeneralSettings/",
type: "GET",
cache: false,
async: false,
data: {},
beforeSend: function() {
// $("#events_list").append(' '+app.get_vars()._app.notif.loading+'
');
},
success: function(result) {
// console.log(result.max_res);
$('.mod_count').html(result.max_res);
}
});
},
"register": function() {
let action = 'register'
let seat = null
if($(window).width()>=767) {
seat = $('#number_of_seat_reserved').val()
} else {
seat = $('#number_of_seat_reserved_mobile').val()
}
if(seat === null) {
$('#number_of_seat_reserved_mobile').focus()
$('#number_of_seat_reserved').focus()
//$('#seat_reserved_error_message_mobile').text('Ce champ est obligatoire')
return false
} else {
/* Add spinner loader when processing reservation */
$(".reserve-spinner").removeClass("d-none");
$('.btn-reserve').attr('disabled', true);
$('.btn-offer').attr('disabled', true);
/* end */
}
subscribe.registration.add_or_modify.reservation(eventDetails, seat, action, 1);
},
// FOR OFFRIR BUTTON
"offrir": function() {
let action = 'register'
let seat = null
if($(window).width()>=767) {
seat = $('#number_of_seat_reserved').val()
} else {
seat = $('#number_of_seat_reserved_mobile').val()
}
if(seat === null) {
$('#number_of_seat_reserved_mobile').focus()
$('#number_of_seat_reserved').focus()
//$('#seat_reserved_error_message_mobile').text('Ce champ est obligatoire')
return false
} else {
/* Add spinner loader when processing reservation */
$(".reserve-spinner").removeClass("d-none");
$('.btn-reserve').attr('disabled', true);
$('.btn-offer').attr('disabled', true);
/* end */
}
subscribe.registration.add_or_modify_offrir.reservation(eventDetails, seat, action, 1);
}
}
// Pass in jQuery.
})(jQuery, this);
$(document).ready(function() {
//getReservationInfo
subscribe.show_general_setting_moderation();
if(typeof GAUID != "undefined" && GAUID != "") {
subscribe.show_moderation_details();
}
// Open All Accordion Panel
$('.accordion-body:not(".in")').collapse('show');
$('.accordion-heading').click(function() {
if (!$(this).next().hasClass('in')) {
$(this).collapse("hide");
}
$(this).next().collapse('toggle');
});
/* Redirect to event */
$(document).on('click', '.subscribe-btn-redirect', function(event) {
event.preventDefault();
subscribe.button.redirect(this.dataset.eventId, this.dataset.redirect);
});
/* Choose a reservation to cancel*/
$(document).on('click', '.subscribe-check-uncheck', function(event) {
/* Act on the event */
if ($(this).hasClass("has-child-checkbox")) {
$('input.invitee' + this.dataset.eventScheduleId + '-' + this.dataset.index)
.prop("checked",
!$('input.invitee' + this.dataset.eventScheduleId + '-' + this.dataset.index).prop("checked"));
}
subscribe.registration.options.create_list.check_uncheck(
this,
this.dataset.eventScheduleId,
this.dataset.index
);
});
/*Register or modify action */
$(document).on('click', '.register-or-modify'/*, .not-premium*/, function(event) {
subscribe.button.register_or_modify(
event,
this.dataset.regType,
this.dataset.action,
this.dataset.processType,
this.dataset.seatFeature,
this.dataset.showCancelBtn,
);
});
/* Cancel reservation */
$(document).on('click', '.cancel-reservation', function(event) {
subscribe.button.cancel_reservation(
event,
this.dataset.eventId,
this.dataset.eventScheduleId,
this.dataset.regType,
);
});
/* Not allowed to book */
$(document).on('click', '.not-allowed-to-book', function(event) {
subscribe.button.not_allowed_to_book()
});
$('.dummy-btn').on('click', function() {
$('html, body').animate({
scrollTop: $("#info-box").offset().top
}, 100);
});
$('.btn-reserve').on('click', function() {
subscribe.register();
$('#workshopDetailedBox').modal('hide');
});
$('.btn-offer').on('click', function(){
subscribe.register();
$('#workshopDetailedBox').modal('hide');
});
$('.offrir-btn').on('click', function(){
subscribe.offrir();
$('#workshopDetailedBox').modal('hide');
})
// $('mc-btn-scroll').on('click', function(){
// $('body').scrollTo('#info-box');
// });
$('#number_of_seat_reserved').on('change', function(){
$('#seat_reserved_error_message').text('')
});
(function(){
// Reset reservation cookie when reloaded
const queryString = window.location.href;
const urlParams = new URLSearchParams(queryString);
const href = queryString.replace(/[\/]*$/, '');
const event_id = urlParams.get('event_id') ? urlParams.get('event_id') : href.substring(href.lastIndexOf('/') + 1);
subscribe.button.lock_unlock({
data: {
event_id,
process_id: 3,
process_type: 1,
action: 2
},
async: false,
success: function(data) {
console.log(data)
}
});
})()
});