`;
})
}
if(result.mdata.workshop_session === 'ENLIGNE') {
if(result.event_videos.length !== 0) {
let videos = result.event_videos
let h = 0
let m = 0
let s = 0
for(let i=0; i
');
$('#mc-event-type').on('click', function() {
$('.custom-dropdown.event-type-select').toggleClass('d-none');
});
/**Atelier sub menu */
// $('#btn-submenu-1').on("click", function(e){
// $(this).next('ul').toggle();
// $('#btn-submenu-2').next('ul').hide()
// e.stopPropagation();
// e.preventDefault();
// });
// /**Atelier sub menu */
// $('#btn-submenu-2').on("click", function(e){
// $(this).next('ul').toggle();
// $('#btn-submenu-1').next('ul').hide()
// e.stopPropagation();
// e.preventDefault();
// });
if (Object.entries(EVENT_CATEGORY) > 1) $("#event_category").html(btns);
});
// $('div.search form').append('')
// $('').insertAfter('div.search');
// add the change status form
form = '
'+
''
+'
';
$('#toggle_change_stat_form').on('click', function(event) {
event.preventDefault();
/* Act on the event */
var target_stat_element,
checked_scheds,
disalL_statuses = [],
alL_statuses = [],
alL_status_ids = [],
target_status_str = '',
target_status,
change_stat_confmgs = [];
var ch_stat_box = bootbox.confirm({
title: 'Sélectionnez un statut',
message: form,
size: 'small',
className: 'modal modal-success',
buttons: {
cancel: {
label: ' Annuler'
},
confirm: {
label: ' Continuer'
}
},
callback: function (result) {
if (result == true) {
/* Act on the event */
target_stat_element = $('select#back_office_status_all');
// get all checked schedules
checked_scheds = $('input.ev_scheds_cb:checked').toArray();
target_status = target_stat_element.val();
for (var y = 0; y < checked_scheds.length; y++) {
var ev_started = false;
// get the backoffice status
parent_id = checked_scheds[y].className.split(" ")[0];
event_bo_status = $('#' +parent_id + ' #back_office_status').html();
// switch for target status and action per current status
var ev_sched = checked_scheds[y], current_status = event_bo_status;
// validate event schedule if has the posibility to be changed from current status to target one
switch (target_status) {
case '0': //En cours de création
target_status_str = 'En cours de création';
switch (current_status) {
case 'Publié':
change_stat_confmgs.push('Attention : Le fait de changer de statut de "Publié" à "En cours de création" '
+' votre selection ne sera plus visible pour cet évenement');
alL_statuses.push('Publié');
alL_status_ids.push(ev_sched.value);
// Confirmation pop up Cancel & OK
// Attention : Le fait de changer de statut de \"Publié\" à \"En cours de création\" votre selection ne sera plus visible pour cet évenement. Souhaitez vous continuer ?
break;
case 'Ouvert':
change_stat_confmgs.push('Attention : Le fait de changer de statut de Ouvert à En cours de création votre selection ne sera plus visible pour cet évenement');
alL_statuses.push('Ouvert');
alL_status_ids.push(ev_sched.value);
// Confirmation pop up Cancel & OK
// Attention : Le fait de changer de statut de "Current status" à {Target status} votre selection ne sera plus visible pour cet évenement. Souhaitez vous continuer ?
break;
case 'Verrouillé':
disalL_statuses.push('Verrouillé');
// Information pop up OK
// Attention : Il n'est pas possible de changer le statut de votre sélection de {Current status}
break;
case 'Fermé':
disalL_statuses.push('Fermé');
// Information pop up OK
// Attention : Il n'est pas possible de changer le statut de votre sélection de {Current status}
break;
case 'Archivé':
disalL_statuses.push('Archivé');
// Information pop up OK
// Attention : Il n'est pas possible de changer le statut de votre sélection de {Current status}
break;
case 'Terminé':
disalL_statuses.push('Terminé');
// Information pop up OK
// Attention : Il n'est pas possible de changer le statut de votre sélection de {Current status}
break;
default:
}
break;
case '1': //Publié
target_status_str = 'Publié';
switch (current_status) {
case 'En cours de création':
events.validation._check_change_stat_eligibility(ev_sched.value, 'encourse_to_publi');
// console.log(change_eligible);
if (change_eligible) {
// change_stat_confmgs.push();
alL_statuses.push('En cours de création');
alL_status_ids.push(ev_sched.value);
change_eligible = false;
} else {
disalL_statuses.push('En cours de création')
// need specific notification here;
}
// Confirmation pop up Cancel & OK
// Check if all event and event schedule requirements are ok
// Etes vous sur de vouloir changer de statut de {Current status} à {Target Status} ?
break;
case 'Ouvert':
disalL_statuses.push('Ouvert');
// Information pop up OK
// Attention : Il n'est pas possible de changer le statut de votre sélection de {Current status} à {Target status}. Le statut "ouvert" est automatiquement défini lorsque la période de reservation a déjà commencé. Vous devez changer la ou les dates de réservation pour changer le statut à "Publié".
break;
case 'Verrouillé':
disalL_statuses.push('Verrouillé');
// Information pop up OK
// Attention : Il n'est pas possible de changer le statut de votre sélection de {Current status}
break;
case 'Fermé':
disalL_statuses.push('Fermé');
// Information pop up OK
// Attention : Il n'est pas possible de changer le statut de votre sélection de {Current status}
break;
case 'Archivé':
disalL_statuses.push('Archivé');
// Information pop up OK
// Attention : Il n'est pas possible de changer le statut de votre sélection de {Current status}
break;
case 'Terminé':
ev_started = events.validation._check_change_stat_eligibility(ev_sched.value, 'is_sched_started');
if (!ev_started) {
alL_statuses.push('Terminé');
alL_status_ids.push(ev_sched.value);
change_eligible = false;
} else {
disalL_statuses.push('Terminé')
// need specific notification here;
}
// Confirmation pop up Cancel & OK
// Check if the start reservation date are not yet start
// Etes vous sur de vouloir changer de statut de {Current status} à {Target Status} ?
break;
default:
}
break;
case '2': //Ouvert
target_status_str = 'Ouvert';
switch (current_status) {
case 'En cours de création':
events.validation._check_change_stat_eligibility(ev_sched.value, 'encourse_to_ouvert');
// console.log(change_eligible);
if (change_eligible) {
alL_statuses.push('En cours de création');
alL_status_ids.push(ev_sched.value);
change_eligible = false;
} else {
disalL_statuses.push('En cours de création')
// need specific notification here;
}
// Confirmation pop up Cancel & OK
// Check if all the event schedule date range for the booking
// Etes vous sur de vouloir changer de statut de {Current status} à {Target Status} ?
break;
case 'Publié':
disalL_statuses.push('Publié');
// Information pop up OK
// Attention : Il n'est pas possible de changer le statut de votre sélection de {Current status} à {Target status}. Le statut "ouvert" sera automatiquement défini lorsque la période de reservation aura commencé. Vous devez changer la ou les dates de réservation pour changer le statut à "Ouvert".
break;
case 'Verrouillé':
disalL_statuses.push('Verrouillé');
// Information pop up OK
// Attention : Il n'est pas possible de changer le statut de votre sélection de {Current status}
break;
case 'Fermé':
disalL_statuses.push('Fermé');
// Information pop up OK
// Attention : Il n'est pas possible de changer le statut de votre sélection de {Current status}
break;
case 'Archivé':
disalL_statuses.push('Archivé');
// Information pop up OK
// Attention : Il n'est pas possible de changer le statut de votre sélection de {Current status}
break;
case 'Terminé':
events.validation._check_change_stat_eligibility(ev_sched.value, 'termine_to_ouvert');
// console.log(change_eligible);
if (change_eligible) {
alL_statuses.push('Terminé');
alL_status_ids.push(ev_sched.value);
change_eligible = false;
} else {
disalL_statuses.push('Terminé')
}
// Confirmation pop up Cancel & OK
// Check if event is eligible to the Ouvert status
// Etes vous sur de vouloir changer de statut de {Current status} à {Target Status} ?
break;
default:
}
break;
case '3': //Verrouillé
target_status_str = 'Verrouillé';
switch (current_status) {
case 'En cours de création':
disalL_statuses.push('En cours de création');
// Information pop up OK
// Attention : Il n'est pas possible de changer le statut de votre sélection de {Current status} à {Target status}.
break;
case 'Publié':
disalL_statuses.push('Publié');
// Information pop up OK
// Attention : Il n'est pas possible de changer le statut de votre sélection de {Current status}
break;
case 'Ouvert':
disalL_statuses.push('Ouvert');
// Information pop up OK
// Attention : Il n'est pas possible de changer le statut de votre sélection de {Current status}
break;
case 'Fermé':
disalL_statuses.push('Fermé');
// Information pop up OK
// Attention : Il n'est pas possible de changer le statut de votre sélection de {Current status}
break;
case 'Archivé':
disalL_statuses.push('Archivé');
// Information pop up OK
// Attention : Il n'est pas possible de changer le statut de votre sélection de {Current status}
break;
case 'Terminé':
events.validation._check_change_stat_eligibility(ev_sched.value, 'termine_to_verro');
if (change_eligible) {
alL_statuses.push('Terminé');
alL_status_ids.push(ev_sched.value);
change_eligible = false;
} else {
disalL_statuses.push('Terminé')
// need specific notification here;
}
// Confirmation pop up Cancel & OK
// Check if event is eligible to the Verrouillé status
// Etes vous sur de vouloir changer de statut de {Current status} à {Target Status} ?
break;
default:
}
break;
case '4': //Fermé
target_status_str = 'Fermé';
switch (current_status) {
case 'En cours de création':
disalL_statuses.push('En cours de création');
// Information pop up OK
// Attention : Il n'est pas possible de changer le statut de votre sélection de {Current status} à {Target status}.
break;
case 'Publié':
disalL_statuses.push('Publié');
// Information pop up OK
// Attention : Il n'est pas possible de changer le statut de votre sélection de {Current status} à {Target status}.
break;
case 'Ouvert':
disalL_statuses.push('Ouvert');
// Information pop up OK
// Attention : Il n'est pas possible de changer le statut de votre sélection de {Current status}
break;
case 'Verrouillé':
disalL_statuses.push('Verrouillé');
// Information pop up OK
// Attention : Il n'est pas possible de changer le statut de votre sélection de {Current status}
break;
case 'Archivé':
events.validation._check_change_stat_eligibility(ev_sched.value, 'archive_to_ferme');
$.when(change_eligible).done(function (data){
// console.log(change_eligible);
if (change_eligible) {
alL_statuses.push('Archivé');
alL_status_ids.push(ev_sched.value);
change_eligible = false;
} else {
disalL_statuses.push('Archivé')
// need specific notification here;
}
});
// Confirmation pop up Cancel & OK
// Check if event is eligible to the Fermé status
// Etes vous sur de vouloir changer de statut de {Current status} à {Target `Status} ?`
break;
case 'Terminé':
events.validation._check_change_stat_eligibility(ev_sched.value, 'termine_to_ferme');
// console.log(change_eligible);
if (change_eligible) {
alL_statuses.push('Terminé');
alL_status_ids.push(ev_sched.value);
change_eligible = false;
} else {
disalL_statuses.push('Terminé')
// need specific notification here;
}
// Confirmation pop up Cancel & OK
// Check if event is eligible to the Fermé status
// Etes vous sur de vouloir changer de statut de {Current status} à {Target `Status} ?`
break;
default:
}
break;
case '5': //Archivé
target_status_str = 'Archivé';
switch (current_status) {
case 'En cours de création':
alL_statuses.push('En cours de création');
alL_status_ids.push(ev_sched.value);
// Confirmation pop up Cancel & OK
// Etes vous sur de vouloir changer de statut de {Current status} à {Target Status} ?
break;
case 'Publié':
change_stat_confmgs.push('Attention : Le fait de changer de statut de Publié à Archivé votre selection ne sera plus visible pour cet évenement');
alL_statuses.push('Publié');
alL_status_ids.push(ev_sched.value);
// Confirmation pop up Cancel & OK
// Attention : Le fait de changer de statut de "Current status" à {Target status} votre selection ne sera plus visible pour cet évenement. Souhaitez vous continuer ?
break;
case 'Ouvert':
disalL_statuses.push('Ouvert');
// Information pop up OK
// Attention : Vous ne pouvez pas archiver un évènement ouvert à la réservation.
break;
case 'Verrouillé':
disalL_statuses.push('Verrouillé');
// Information pop up OK
// Attention : Il n'est pas possible de changer le statut de votre sélection de {Current status}
break;
case 'Fermé':
alL_statuses.push('Fermé');
alL_status_ids.push(ev_sched.value);
// Confirmation pop up Cancel & OK
// Etes vous sur de vouloir changer de statut de {Current status} à {Target Status} ?
break;
case 'Terminé':
alL_statuses.push('Terminé');
alL_status_ids.push(ev_sched.value);
// Confirmation pop up Cancel & OK
// Etes vous sur de vouloir changer de statut de {Current status} à {Target Status} ?
break;
default:
}
break;
case '7': //Terminé
target_status_str = 'Terminé';
switch (current_status) {
case 'En cours de création':
disalL_statuses.push('En cours de création');
// Information pop up OK
// Attention : Il n'est pas possible de changer le statut de votre sélection de {Current status} à {Target status}.
break;
case 'Publié':
alL_statuses.push('Publié');
alL_status_ids.push(ev_sched.value);
// Confirmation pop up Cancel & OK
// Etes vous sur de vouloir changer de statut de {Current status} à {Target Status} ?
break;
case 'Ouvert':
alL_statuses.push('Ouvert');
alL_status_ids.push(ev_sched.value);
// Confirmation pop up Cancel & OK
// Etes vous sur de vouloir changer de statut de {Current status} à {Target Status} ?
break;
case 'Verrouillé':
disalL_statuses.push('Verrouillé');
// Information pop up OK
// Attention : Il n'est pas possible de changer le statut de votre sélection de {Current status}
break;
case 'Fermé':
disalL_statuses.push('Fermé');
// Information pop up OK
// Attention : Il n'est pas possible de changer le statut de votre sélection de {Current status}
break;
case 'Archivé':
disalL_statuses.push('Archivé');
// Information pop up OK
// Attention : Il n'est pas possible de changer le statut de votre sélection de {Current status}
break;
default:
}
break;
default:
}
}
}
}
});
ch_stat_box.on('hidden.bs.modal', function(e) {
// Warning message for statuses that can't be changed
if (disalL_statuses.length > 0) {
// remove duplicates
var uniqueStats = [];
$.each(disalL_statuses, function(i, el){
if($.inArray(el, uniqueStats) === -1) uniqueStats.push(el);
});
disall_stat_str = uniqueStats.join(', ');
bootbox.alert({
title:'Attention!!',
message: "Il n'est pas possible de changer le statut de votre sélection de "+disall_stat_str+" à "+target_status_str+".",
backdrop: false,
size: 'medium'
});
// app._notify("warning", );
}
if (alL_status_ids.length > 0 && disalL_statuses.length == 0) {
// output event schedules that can be changed to a specific target status
// remove duplicates
var uniqueStats = [], uniqueStatsName = [], uniqueConfMsgs = [];
$.each(alL_status_ids, function(i, el){
if($.inArray(el, uniqueStats) === -1) uniqueStats.push(el);
});
$.each(alL_statuses, function(i, el){
if($.inArray(el, uniqueStatsName) === -1) uniqueStatsName.push(el);
});
$.each(change_stat_confmgs, function(i, el){
if($.inArray(el, uniqueConfMsgs) === -1) uniqueConfMsgs.push(el);
});
alL_status_ids_str = uniqueStats.join(', ');
alL_status_str = uniqueStatsName.join(', ');
alL_confmsgs = uniqueConfMsgs.join('. ');
// app._notify("success", "You can change the status of the following: "+alL_status_ids_str);
if (alL_confmsgs) {
alL_confmsgs = alL_confmsgs + '. ';
}
bootbox.confirm({
title: 'Confirmer le changement de statut',
message: alL_confmsgs+"Etes vous sur de vouloir changer de statut de "+alL_status_str+" à "+target_status_str+' ?' ,
size: 'medium',
className: 'modal modal-success',
buttons: {
cancel: {
label: ' Annuler'
},
confirm: {
label: ' Continuer'
}
},
callback: function (result) {
if (result == true) {
$.ajax({
type: "POST",
data: {alL_status_ids:alL_status_ids, target_status:target_status},
url: app.get_vars().baseurl + 'multi_update_evsched_status',
success: function(result){
$("#events_list").DataTable().ajax.reload(null, false);
app._notify(result.mtype, result.message);
}
});
}
}
});
}
});
});
// check schedule on every check of schedule
$('button[name=change_bo_status_all]').on('click', function(event) {
event.preventDefault();
});
// $(form).insertAfter('div#events_list_filter');
/*
Checked
Can reserve more than 1 date per event schedule?
Can reserve more than 1 date per event schedule?
by default
*/
// $("input[name='is_multiple_reservation'], input[name='is_multiple_waitlist_reservation']").prop("checked",true);
//fire search filter event
app.grid.search_filter("events_list", events.get_vars()._events);
}
});
Helper.dtable.console_alert("table#events_list", function(err){
console.log(err);
});
events.set_vars({_events : table});
},
"_grid" : {
create_custom_filter : function(){
return '' +
'' +
'';
},
filter_by : function(obj){
var table = $('#events_list').DataTable();
switch($(obj).val()){
case "title" :
$("#custom_search_filter").html('');
break;
case "start_date_time" :
$("#custom_search_filter").html('');
break;
case "event_type_id" :
var d = $("#event_type_id").clone();
d.find("option:eq(0)").remove();
d.prepend("");
$("#custom_search_filter").html('');
break;
case "city_location" :
var d = $("#city_location").clone();
d.find("option:eq(0)").remove();
d.prepend("");
$("#custom_search_filter").html('');
break;
case "back_office_status" :
var d = $("#back_office_status").clone();
d.find("option:eq(0)").remove();
d.prepend("");
$("#custom_search_filter").html('');
break;
case "event_status" :
var d = $("#event_status").clone();
d.find("option:eq(0)").remove();
d.prepend("");
$("#custom_search_filter").html('');
break;
case "event_category" :
var options = ``;
for (const [key, value] of Object.entries(EVENT_CATEGORY)) {
options += ``;
}
$("#custom_search_filter").html('');
break;
case "workshop_session" :
var options = ``+
''
$("#custom_search_filter").html('');
break;
default :
$("#custom_search_filter").html('');
(events.get_vars()._events).search( '' ).columns().search( '' ).draw();
break;
};
app.grid.search_filter("events_list", events.get_vars()._events);
},
bind_date_picker : function(obj){
$(obj).datetimepicker({
"locale": 'fr',
"sideBySide": false,
"useCurrent" : true,
"format": "MM/Y"
}).off("dp.change").on("dp.change", function (e) {
(events.get_vars()._events).search(this.value).draw();
});
}
},
"reset" : {
"on_modalClose" : function(_this){
try {
//destroy event schedule list table
$("#event_schedule_list").DataTable().clear();
$("#event_speaker_list").DataTable().clear();
$("#event_file_attachment_list").DataTable().clear();
$("#event_sponsor_list").DataTable().clear();
// Reset to original fields
$("#eventForm").removeData('event_category');
event_category.resetFields();
tinymce.EditorManager.execCommand('mceRemoveEditor',true, 'description');
tinymce.EditorManager.execCommand('mceRemoveEditor',true, 'workshop_author_description');
// tinymce.remove();
$("div#description").html('').focus();
$("div#workshop_author_description").html('').focus();
events.set_vars({"event_id" : null});
app._form._resetFormValidation("#eventForm");
app._form._reset(_this);
$("#single-dated-event").attr("disabled", false);
$(".event-address").prop('disabled', false);
//reset event schedule/dates
event_schedule.model.action.client.reset();
event_speaker.model.action.client.reset();
event_attachment.model.action.client.reset();
event_sponsor.model.action.client.reset();
$(_this).data('bs.modal', null);
app.modal.focusout_solution("off");
app.modal.activate_tinymce("off");
pseat_feature_counter=0;
} catch (e) {}
$(_this).off('hidden.bs.modal');
},
"on_addInit" : function(_this){
//load wysiwyg html editor
try {
events._load("#description");
tinymce.EditorManager.execCommand('mceAddEditor',true, 'description');
events._load("#workshop_author_description");
tinymce.EditorManager.execCommand('mceAddEditor',true, 'workshop_author_description');
$('.nav-tabs a[href="#home"]').tab('show');
// events._dtimepicker.config();
//submit form on keypress or enter
app._form._form_submit_on_keypress("eventForm", function(){
events.validation._validate('add');
}, ["editspeaker","speaker"]);
events.set_vars({"event_id" : null});
$("#multiple_date_form").hide();
event_schedule.model.init();
event_speaker.model.init();
event_attachment.model.init();
event_sponsor.model.init();
$("#total_combined_seat").val("").prop('disabled', true).removeData();
} catch (e) {}
}
},
"getAddress" : function(mapLoc) {
// new map
const map = new google.maps.Map(document.getElementById("map"), {
center: { lat: mapLoc ? mapLoc.geometry.lat : -33.8688, lng: mapLoc ? mapLoc.geometry.lng :151.2195 },
zoom: 13,
mapTypeId: "roadmap",
});
// Create the search box and link it to the UI element.
const input = document.getElementById("pac-input");
const searchBox = new google.maps.places.SearchBox(input);
//map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);
// Bias the SearchBox results towards current map's viewport.
map.addListener("bounds_changed", () => {
searchBox.setBounds(map.getBounds());
});
let markers = [];
if(mapLoc) {
// const icon = {
// url: mapLoc.icon,
// size: new google.maps.Size(71, 71),
// origin: new google.maps.Point(0, 0),
// anchor: new google.maps.Point(17, 34),
// scaledSize: new google.maps.Size(25, 25),
// };
// Create a marker for each place.
markers.push(
new google.maps.Marker({
map,
// icon,
title: mapLoc.address,
position: mapLoc.geometry
})
);
}
// Listen for the event fired when the user selects a prediction and retrieve
// more details for that place.
searchBox.addListener("places_changed", () => {
const places = searchBox.getPlaces();
events.set_vars({"map": {
address: places[0].formatted_address,
icon: places[0].icon,
geometry: {
lat: places[0].geometry.location.lat(),
lng: places[0].geometry.location.lng()
}
}});
$('#location').val(JSON.stringify(events.get_vars().map));
map.setZoom(15)
if (places.length == 0) {
$("#location").val('');
events.set_vars({"map": null});
return;
}
// Clear out the old markers.
markers.forEach((marker) => {
marker.setMap(null);
});
markers = [];
// For each place, get the icon, name and location.
const bounds = new google.maps.LatLngBounds();
places.forEach((place) => {
if (!place.geometry || !place.geometry.location) {
console.log("Returned place contains no geometry");
return;
}
// const icon = {
// url: mapLoc ? mapLoc.icon : place.icon,
// size: new google.maps.Size(71, 71),
// origin: new google.maps.Point(0, 0),
// anchor: new google.maps.Point(17, 34),
// scaledSize: new google.maps.Size(25, 25),
// };
// Create a marker for each place.
markers.push(
new google.maps.Marker({
map,
// icon,
title: place.name,
position: place.geometry.location,
})
);
if (place.geometry.viewport) {
// Only geocodes have viewport.
bounds.union(place.geometry.viewport);
} else {
bounds.extend(place.geometry.location);
}
});
map.fitBounds(bounds);
});
},
"formatSessionDates": function () {
let sessions_dates = []
const table=document.getElementById("tbody");
for(let i=0;i=0) {
$('#image-'+tbInput+'-'+imageId).css({display:'block', height: '200px'});
$('#image-'+tbInput+'-'+imageId).attr('src', image)
} else {
$('#image-'+tbInput+'-'+imageId).css({display:'none'})
$('#image-'+tbInput+'-'+imageId).attr('src', '')
imageInput.value = ''
app._notify("error", "Type de fichier invalide");
}
}
reader.readAsDataURL(imageInput.files[0]);
} else {
$('#image-'+tbInput+'-'+imageId).css({display:'none'});
$('#image-'+tbInput+'-'+imageId).attr('src', '')
if(tbInput == 'work') {
$('#author_work_image-'+imageId).attr({'required': true})
} else {
$('#venue_img_image-'+imageId).attr({'required': true})
}
}
return image
}
};//end of return
// Pass in jQuery.
})(jQuery, this);
var personalization = (function ($, window, jQuery) {
var _vars_ = {};
var $uploadCrop;
var upload = $('#upload');
var container = $('#container-image');
var upload_result = $('.upload-result');
var form = $('#form');
var banner_folder = 'resources/images/frontoffice/banner/';
return {
"set_vars": function (options) {
$.extend(_vars_, options || {});
},
"get_vars" : function(){
return _vars_;
},
set_require: function()
{
var set_require = $("#set_require");
var validated;
set_require.on('click', function (ev) {
$('#registration_form_list input[type=checkbox]').each(function(){
var req = !this.checked ? 0 : 1;
var ids = this.value;
var json = {
"req": req,
"ids": ids
}
$.ajax({
url: app.get_vars().baseurl+"personalize/update_reg_form",
type: 'POST',
data : json,
dataType: "json",
success: function(result) {
validated = true;
}
});
})
app._notify("success", "Mise à jour réussie");
});
},
registration : function()
{
var registration_form_list = $("#registration_form_list");
var cnt;
$.ajax({
url: app.get_vars().baseurl+"personalize/get_reg_form",
type: 'GET',
dataType: 'json',
success: function(res) {
for (var i = 0; i < res.length; i++) {
var req = res[i].is_required == 1 ? "checked=checked" : "";
var name = res[i].name.toUpperCase();
cnt += '
');
if(venueImg) {
if(venueImg.photo) {
let venuePhoto = app.get_vars().baseurl+'resources/images/frontoffice/events/'+venueImg.photo
$('#image-venue-'+venuePhotoCount).css({display:'block', height: '200px'});
$("#image-venue-"+venuePhotoCount).attr('src', venuePhoto)
$('#venue_img_image-'+venuePhotoCount).attr({'required': false})
}
$("#avenue_img_id-"+venuePhotoCount).val(venueImg.id)
}
if($('#tbody_venue_img tr').length === 3) {
$('#addBtn_venue_img').attr('disabled', 'disabled')
} else {
$('#addBtn_venue_img').removeAttr('disabled')
}
}
};
})(jQuery, this);
$(document).ready(function(){
//load datatable
events.load();
var table = $('#events_list').DataTable();
// Handle click on "Select all" control
$('#events-select-all').on('click', function(){
var rows, checked;
rows = $('#events_list').find('tbody tr');
checked = $(this).prop('checked');
$.each(rows, function() {
var checkbox = $($(this).find('td').eq(0)).find('input:not(:disabled)').prop('checked', checked);
});
events.toggle_change_stat_button();
});
$('#collapse_all').hide();
$('#events-select-all').hide();
$('#expand_all').on('click',function () {
$('#events-select-all').show();
var table = $('#events_list').DataTable();
$('#collapse_all').show();
$('#expand_all').hide();
// Expand row details
var all_expandable_rows = $('table#events_list > tbody > tr[role="row"]').toArray().length;
var all_expanded_rows = $('table#events_list > tbody > tr[role="row"].shown').toArray().length;
var all_unexpanded_rows = $('table#events_list > tbody > tr[role="row"]:not(.shown)').toArray().length;
table.rows(':not(.parent):not(.shown)').nodes().to$().find('td:first-child').trigger('click');
});
$('#collapse_all').on('click',function () {
$('#events-select-all').hide();
var table = $('#events_list').DataTable();
$('#collapse_all').hide();
$('#expand_all').show();
table.rows(':not(.parent).shown').nodes().to$().find('td:first-child').trigger('click');
$('#events-select-all').prop('checked', false); // Unchecks it
})
$('#events_list_length select').on('change',function () {
$('#collapse_all').hide();
$('#expand_all').show();
$('#events-select-all').hide();
$('#events-select-all').prop('checked', false); // Unchecks it
})
$("input[type='number']").on('blur', function() {
var _this = $(this),
_parse_int = parseInt(_this.val().trim());
if(_parse_int >= 0){
_this.val(_parse_int);
} else {
_this.val("");
}
});
// $("#rate").on("blur" , function(){
// var _this = $(this).val().trim();
// if(_this!="" && parseInt(_this) >=0) {
// var new_val = accounting.formatMoney(_this, "", 2, " ", ",");
// new_val = new_val.replace(",00", "");
// $(this).val(new_val);
// }else{
// $(this).val("");
// }
// }).on("click", function(){
// var _this = $(this).val().trim();
// if(_this !="" && parseInt(_this) >=0) {
// var new_val = _this.replace(",", ".");
// new_val = accounting.unformat(new_val, "", 2, " ", ",");
// $(this).val(new_val);
// }else{
// $(this).val("");
// }
// });
/*display result message once modal is reloaded*/
try{
var result = localStorage.getItem("result");
localStorage.clear();
if(typeof result == "string" && result != null && result.length > 0){
result = JSON.parse(result);
app._notify(result.mtype, result.message);
}
} catch(e){localStorage.clear();}
$("#pac-input").on("input", function(){
events.getAddress(null)
})
// load get featured banner
personalization.banner_load_box_cropper();
personalization.banner_get_image(true);
// jQuery button click event to add a row
// Denotes total number of rows
$('#addBtn').click(function(){
personalization.add_session(fieldInstance)
fieldInstance++;
$('#number_of_sessions').val($('#tbody tr').length)
});
$("#tbody").on("focus", ".multiple-session-date", function(){
$('.multiple-session-date').datetimepicker({
"locale": 'fr',
"sideBySide": false,
"useCurrent" : false,
"keepInvalid" : true,
"showClose" : true,
"focusOnShow":true,
"format": "DD/MM/YYYY HH"+"[h]"+"mm"
}).on('dp.change', function(e){
const idArry = this.id.split("-");
switch (idArry[0]) {
case 'start_session_date':
//if(!$('#end_session_date-'+idArry[1]).val()) {
$('#end_session_date-'+idArry[1]).data("DateTimePicker").minDate(moment(e.date.startOf('day').valueOf()));
$('#end_session_date-'+idArry[1]).data("DateTimePicker").maxDate(moment(e.date.endOf('day').valueOf()));
if(events.get_vars().isEdit) {
events._edit.getEditedDate('session', $('#'+this.id).val())
}
//}
break;
case 'end_session_date':
//if(!$('#start_session_date-'+idArry[1]).val()) {
//$('#start_session_date-'+idArry[1]).data("DateTimePicker").minDate(moment(e.date.startOf('day').valueOf()));
$('#start_session_date-'+idArry[1]).data("DateTimePicker").maxDate(moment(e.date.endOf('day').valueOf()));
//}
if(events.get_vars().isEdit) {
events._edit.getEditedDate('session', $('#'+this.id).val())
}
break;
default:
}
})
});
// jQuery button click event to remove a row.
$('#tbody').on('click', '.remove', function () {
// Getting all the rows next to the row
// containing the clicked button
var child = $(this).closest('tr').nextAll();
// Iterating across all the rows
// obtained to change the index
child.each(function () {
// Getting
id.
var id = $(this).attr('id');
// Getting the
inside the .row-index class.
var idx = $(this).children('.row-index').children('p');
// Gets the row number from
id.
var dig = parseInt(id.substring(1));
// Modifying row index.
idx.html(`Row ${dig - 1}`);
// Modifying row id.
$(this).attr('id', `R${dig - 1}`);
});
// Removing the current row.
$(this).closest('tr').remove();
$('#number_of_sessions').val(parseInt($('#number_of_sessions').val()-1)== 0?'':parseInt($('#number_of_sessions').val()-1));
// Decreasing total number of rows by 1.
//rowIdx--;
});
$('#number_of_sessions').on('change', function(){
const nos = parseInt($('#number_of_sessions').val());
const trCount = $('#tbody tr').length
if(nos > trCount) {
for(let i=trCount; i < nos; i++) {
personalization.add_session(i);
fieldInstance++;
}
}
});
$('#hours_per_session').on('keyup', () => {
let val = $('#hours_per_session').val();
if(isNaN(val)){
val = val.replace(/[^0-9\.]/g,'');
if(val.split('.').length>2)
val =val.replace(/\.+$/,"");
}
$('#hours_per_session').val(val);
})
// jQuery button click event to add a row author award
// Denotes total number of rows
$('#addBtn_award').click(function(){
personalization.add_author_award(fieldInstance)
fieldInstance++;
// $('#number_of_sessions').val($('#tbody tr').length)
});
// jQuery button click event to remove a row.
$('#tbody_award').on('click', '.remove', function () {
// Getting all the rows next to the row
// containing the clicked button
var child = $(this).closest('tr').nextAll();
// Iterating across all the rows
// obtained to change the index
child.each(function () {
// Getting
id.
var id = $(this).attr('id');
// Getting the
inside the .row-index class.
var idx = $(this).children('.row-index').children('p');
// Gets the row number from
id.
var dig = parseInt(id.substring(1));
// Modifying row index.
idx.html(`Row ${dig - 1}`);
// Modifying row id.
$(this).attr('id', `R${dig - 1}`);
});
// Removing the current row.
$(this).closest('tr').remove();
// Decreasing total number of rows by 1.
//rowIdx--;
});
// jQuery button click event to add a row author works
// Denotes total number of rows
$('#addBtn_work').click(function(){
personalization.add_author_works(fieldInstance)
fieldInstance++;
});
// jQuery button click event to remove a row.
$('#tbody_works').on('click', '.remove', function () {
// Getting all the rows next to the row
// containing the clicked button
var child = $(this).closest('tr').nextAll();
// Iterating across all the rows
// obtained to change the index
child.each(function () {
// Getting
id.
var id = $(this).attr('id');
// Getting the
inside the .row-index class.
var idx = $(this).children('.row-index').children('p');
// Gets the row number from
id.
var dig = parseInt(id.substring(1));
// Modifying row index.
idx.html(`Row ${dig - 1}`);
// Modifying row id.
$(this).attr('id', `R${dig - 1}`);
});
// Removing the current row.
$(this).closest('tr').remove();
// Decreasing total number of rows by 1.
//rowIdx--;
$('#addBtn_work').removeAttr('disabled', 'disabled')
});
// jQuery button click event to add a row venue image
// Denotes total number of rows
$('#addBtn_venue_img').click(function(){
venuePhotoCount++;
personalization.add_venue_img(venuePhotoCount)
});
// jQuery button click event to remove a row.
$('#tbody_venue_img').on('click', '.remove', function () {
// Getting all the rows next to the row
// containing the clicked button
var child = $(this).closest('tr').nextAll();
// Iterating across all the rows
// obtained to change the index
child.each(function () {
// Getting
id.
var id = $(this).attr('id');
// Getting the
inside the .row-index class.
var idx = $(this).children('.row-index').children('p');
// Gets the row number from
id.
var dig = parseInt(id.substring(1));
// Modifying row index.
idx.html(`Row ${dig - 1}`);
// Modifying row id.
$(this).attr('id', `R${dig - 1}`);
});
// Removing the current row.
$(this).closest('tr').remove();
// Decreasing total number of rows by 1.
//rowIdx--;
$('#addBtn_venue_img').removeAttr('disabled', 'disabled')
});
$('select#event_status').on('change', function(e) {
let form = $("#eventForm");
let eventId = form.data("event_id");
let eventStatus = e.target.value;
let prevEventStatus = events.get_vars().prev_event_status;
if (eventId && prevEventStatus === 'SOON' && eventStatus === 'AVAILABLE') {
app.modal.confirm_box({
"message" : "L'ouverture de cet événement enverra des e-mails à ceux qui se sont déjà pré-inscrits",
"_close": () => {
$(e.target).val(prevEventStatus);
}
});
} else if(eventId && prevEventStatus === 'CANCEL') {
$(e.target).val(prevEventStatus);
} else if(eventId && eventStatus === 'CANCEL') {
app.modal.confirm_box({
"message" : 'Êtes-vous sûr de vouloir annuler cet ateliers? Attention, une fois la statut "Annulé" confirmé, cette action est irréversible.',
"_close": () => {
$(e.target).val(prevEventStatus);
}
});
}
});
});