You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
4576 lines
264 KiB
4576 lines
264 KiB
let fieldInstance = 0;
|
|
let venuePhotoCount = 0;
|
|
var events = (function ($, window, jQuery) {
|
|
var _vars_ = {},
|
|
change_eligible = false;
|
|
|
|
return {
|
|
"set_vars": function (options) {
|
|
$.extend(_vars_, options || {});
|
|
},
|
|
|
|
"get_vars": function () {
|
|
return _vars_;
|
|
},
|
|
"_progress_bar" : {
|
|
_action : function(elem,action){
|
|
$(elem).modal(action);
|
|
}
|
|
},
|
|
|
|
"_toggle_sched" : function (event_id, select_all_checked) {
|
|
all_scheds = $('#ev'+event_id).toArray();
|
|
|
|
|
|
inputs = $('.ev'+event_id+'sched input[type=checkbox]').toArray();
|
|
if (select_all_checked == 1) {
|
|
for (var i = 0; i < inputs.length; i++) {
|
|
if (inputs[i].checked == false) {
|
|
inputs[i].checked = true;
|
|
}
|
|
}
|
|
} else {
|
|
for (var i = 0; i < inputs.length; i++) {
|
|
if (inputs[i].checked == true) {
|
|
inputs[i].checked = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
events._init_cstat(event_id);
|
|
},
|
|
|
|
"_init_cstat" : function (event_id) {
|
|
total_evscheds = $('input.evsched'+event_id+'').toArray();
|
|
checked_evscheds = $('input.evsched'+event_id+':checked').toArray();
|
|
if (total_evscheds.length == checked_evscheds.length) {
|
|
$('#evsched_all_chckbox'+event_id).prop('checked', true);
|
|
} else {
|
|
$('#evsched_all_chckbox'+event_id).prop('checked', false);
|
|
}
|
|
events._init_cstat_all();
|
|
events.toggle_change_stat_button();
|
|
},
|
|
|
|
"_init_cstat_all" : function () {
|
|
all_evscheds = $('input.ev_scheds_cb').toArray();
|
|
chkd_evscheds = $('input.ev_scheds_cb:checked').toArray();
|
|
if (
|
|
(all_evscheds.length == chkd_evscheds.length) &&
|
|
(all_evscheds.length || chkd_evscheds.length)
|
|
) {
|
|
$('#events-select-all').prop('checked', true);
|
|
} else {
|
|
$('#events-select-all').prop('checked', false);
|
|
}
|
|
events.toggle_change_stat_button();
|
|
},
|
|
|
|
"_init_expand_all" : function () {
|
|
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;
|
|
if (
|
|
(!all_expanded_rows)
|
|
) {
|
|
$('#collapse_all').hide();
|
|
$('#events-select-all').hide();
|
|
$('#expand_all').show();
|
|
$('#events-select-all').prop('checked', false);
|
|
} else {
|
|
if (
|
|
(all_expandable_rows == all_expanded_rows)
|
|
) {
|
|
$('#collapse_all').show();
|
|
$('#events-select-all').show();
|
|
$('#expand_all').hide();
|
|
}
|
|
}
|
|
},
|
|
|
|
"toggle_change_stat_button" : function () {
|
|
var checked_scheds = $('input.ev_scheds_cb:checked').toArray();
|
|
if (checked_scheds.length > 0) {
|
|
$('#toggle_change_stat_form').removeAttr('disabled');
|
|
} else {
|
|
$('#toggle_change_stat_form').attr('disabled','disabled');
|
|
}
|
|
},
|
|
|
|
"_add" : {
|
|
"modal" : function(eventCategory, eventType) {
|
|
/* Show and hide fields for specific workshop type */
|
|
events.toggleDetailFields(eventType)
|
|
$("#tbody").empty();
|
|
$('#course_url_container').empty()
|
|
$('#course_url_container_distance').empty()
|
|
$('#similar-field').val([])
|
|
$('.multiselect-selected-text').text("None selected")
|
|
$("#tbody_award").empty();
|
|
$('#commentTBody').empty()
|
|
$("#tbody_works").empty();
|
|
$("#tbody_venue_img").empty();
|
|
$('#learning_outcome').empty()
|
|
$('#trailer_video').empty()
|
|
events.set_vars({"event_id": null})
|
|
events.set_vars({"workshop_session": eventType})
|
|
events.set_vars({"similars": null})
|
|
event_similar.get_similar_workshops(0)
|
|
app.modal.focusout_solution("on");
|
|
app.modal.activate_tinymce("on");
|
|
var form = $("#eventForm");
|
|
events.set_vars({"isEdit": false});
|
|
events.set_vars({"editedDate": null})
|
|
events.set_vars({"similars": null})
|
|
form.trigger("reset");
|
|
$('#comments_tab').hide()
|
|
bootbox.dialog({
|
|
"title": app.get_vars().events.title.add_new_event,
|
|
"className" : "my-modal-with-large",
|
|
"message": form,
|
|
animate: true,
|
|
"show": false, /* We will show it manually later */
|
|
"buttons" : [
|
|
{
|
|
"label": app.get_vars()._app.btn._close,
|
|
"class": "btn btn-default",
|
|
"callback": function () {
|
|
}
|
|
},
|
|
{
|
|
"label": app.get_vars().events.btn.save_new_event,
|
|
"class": "btn btn-success w-mb",
|
|
"callback": function () {
|
|
events.validation._validate('add');
|
|
return false;
|
|
}
|
|
}
|
|
]
|
|
}).on('shown.bs.modal', function() {
|
|
$("#title").focus();
|
|
//displayHack : recalculate the dimensions of event_schedule_list table/grid
|
|
$("#event_schedule_list").DataTable().columns.adjust();
|
|
})
|
|
.on('hide.bs.modal', function(e) {
|
|
events.reset.on_modalClose($(this));
|
|
})
|
|
.modal('show') // show before init
|
|
.init(function(){
|
|
// Add selected category
|
|
form.data('event_category', eventCategory);
|
|
event_category.set_date_feature(eventCategory);
|
|
events.reset.on_addInit($(this));
|
|
if(events.get_vars().workshop_session == 'ENLIGNE') {
|
|
$('#event_status').val('AVAILABLE').change()
|
|
$("#back_office_status").val(2).change()
|
|
}
|
|
});
|
|
/* Fix bug on disabled add images button */
|
|
if($('#tbody_venue_img tr').length === 3) {
|
|
$('#addBtn_venue_img').attr('disabled', 'disabled')
|
|
} else {
|
|
$('#addBtn_venue_img').removeAttr('disabled')
|
|
}
|
|
if($('#tbody_works tr').length === 4) {
|
|
$('#addBtn_work').attr('disabled', 'disabled')
|
|
} else {
|
|
$('#addBtn_work').removeAttr('disabled')
|
|
}
|
|
/* end */
|
|
},
|
|
|
|
"save" : function(form){
|
|
let hostname = new URL(window.location.href).hostname;
|
|
let formData = form.serializeArray();
|
|
formData.push({ name: "domain", value: hostname });
|
|
$.ajax({
|
|
url: app.get_vars().baseurl+"event_duplicate",
|
|
type: "post",
|
|
data: formData,
|
|
success: function( result, textStatus, jQxhr ){
|
|
if(app.isalive(result)){
|
|
if(result.mtype == "success"){
|
|
var http_result = events.server.request("add", "add_event", events.server.data("add"), "");
|
|
http_result.success(function(result){
|
|
//console.log(result)
|
|
if(app.isalive(result)) {
|
|
events.server.reset("view", result);
|
|
localStorage.setItem("result", JSON.stringify(result));
|
|
if (result.mtype == "success") {
|
|
location.reload();
|
|
} else {
|
|
// Hide progress bar
|
|
events._progress_bar._action(".upload_progress","hide");
|
|
|
|
var x = 0;
|
|
$.map(result.mdetail, function (input, i) {
|
|
app._form._populate_field_error(input.field, input.message, x);
|
|
x++;
|
|
});
|
|
}
|
|
}
|
|
|
|
}).error(function(xhr){
|
|
console.log(xhr);
|
|
events._progress_bar._action(".upload_progress","hide");
|
|
});
|
|
|
|
} else if(result.mtype == "error"){
|
|
app._notify(result.mtype, result.message);
|
|
app._form._populate_field_error(result.field, result.message, 0);
|
|
events._progress_bar._action(".upload_progress","hide");
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
},
|
|
|
|
"_edit" : {
|
|
"modal" : function(event_id, workshop_session){
|
|
events.set_vars({"workshop_session": workshop_session == 'null'?'PRESENTIEL':workshop_session})
|
|
events.toggleDetailFields(workshop_session)
|
|
app.modal.focusout_solution("on");
|
|
app.modal.activate_tinymce("on");
|
|
$('#similar-field').val([])
|
|
$('.multiselect-selected-text').text("None selected")
|
|
var form = $("#eventForm");
|
|
form.trigger("reset");
|
|
events.set_vars({"isEdit": true});
|
|
events.set_vars({"editedDate": null})
|
|
form.data("event_id", event_id);
|
|
$('#comments_tab').show()
|
|
bootbox.dialog({
|
|
"onEscape": function() {
|
|
//reset attachements with status = 2
|
|
// events._edit._reset_attachment();
|
|
},
|
|
"title": app.get_vars().events.title.update_event,
|
|
"className" : "my-modal-with-large",
|
|
"message": form,
|
|
"show": false, /* We will show it manually later */
|
|
"buttons" : [
|
|
{
|
|
"label": app.get_vars()._app.btn._close,
|
|
"class": "btn btn-default w-mb",
|
|
"callback": function () {
|
|
//reset attachements with status = 2
|
|
// events._edit._reset_attachment();
|
|
}
|
|
}, {
|
|
"label": app.get_vars().events.btn.save_new_event,
|
|
"className": "btn btn-primary w-mb edit-save-event",
|
|
"callback": function () {
|
|
events.validation._validate('edit');
|
|
return false;
|
|
}
|
|
}
|
|
]
|
|
}).on('shown.bs.modal', function(){
|
|
$("#title").focus();
|
|
//displayHack : recalculate the dimensions of event_schedule_list table/grid
|
|
$("#event_schedule_list").DataTable().columns.adjust();
|
|
|
|
}).on('hide.bs.modal', function(e) {
|
|
events.reset.on_modalClose($(this));
|
|
})
|
|
.modal('show')
|
|
.init(function(){
|
|
//combined seats
|
|
$("#total_combined_seat").val("").prop('disabled', true);
|
|
//set event form
|
|
events._view.fill_up_event_form(event_id);
|
|
//open first tab
|
|
$('.nav-tabs a[href="#home"]').tab('show');
|
|
//submit form on keypress or enter
|
|
app._form._form_submit_on_keypress("eventForm", function(){
|
|
events.validation._validate('edit');
|
|
}, ["editspeaker", "speaker"]);
|
|
if(events.get_vars().workshop_session != 'PRESENTIEL') {
|
|
$('#event_status').val('AVAILABLE').change()
|
|
$("#back_office_status").val(2).change()
|
|
}
|
|
});
|
|
/* Fix bug on disabled add images button */
|
|
if($('#tbody_venue_img tr').length === 3) {
|
|
$('#addBtn_venue_img').attr('disabled', 'disabled')
|
|
} else {
|
|
$('#addBtn_venue_img').removeAttr('disabled')
|
|
}
|
|
if($('#tbody_works tr').length === 4) {
|
|
$('#addBtn_work').attr('disabled', 'disabled')
|
|
} else {
|
|
$('#addBtn_work').removeAttr('disabled')
|
|
}
|
|
/* end */
|
|
/* Fix Bug incorrect label */
|
|
$('#addComment').text('Add comment')
|
|
$('#comment_form_label>b').text('Add Comment')
|
|
},
|
|
|
|
// "_reset_attachment" : function(){
|
|
// Helper.help.ajax_loader( app.get_vars().baseurl+"reset_attachment/"+events.get_vars().event_id, 'post' ,
|
|
// false, "", function(result){
|
|
// if(app.isalive(result)){}
|
|
// });
|
|
// },
|
|
"save" : function(form){
|
|
var url_param = $("form#eventForm").data("event_id");
|
|
let formData = events.server.data("edit")
|
|
if(events._edit.isStartDateUpdated()) {
|
|
bootbox.confirm({
|
|
title: app.get_vars().events.title.send_update_event_email,
|
|
message: app.get_vars().events.cma_msg.send_update_event_email,
|
|
className : "my-modal-with-small",
|
|
buttons: {
|
|
confirm: {
|
|
label: 'Oui',
|
|
className: 'btn btn-primary'
|
|
},
|
|
cancel: {
|
|
label: 'Non',
|
|
className: 'btn btn-default w-mb'
|
|
}
|
|
},
|
|
callback: function (result) {
|
|
if(result) {
|
|
formData.append('sendUpdateEmail', true)
|
|
formData.append('editedDate', JSON.stringify(events.get_vars().editedDate))
|
|
}
|
|
events._edit.updateEvent(formData, url_param)
|
|
}
|
|
});
|
|
} else {
|
|
events._edit.updateEvent(formData, url_param)
|
|
}
|
|
},
|
|
"isStartDateUpdated": function() {
|
|
let origDetails = events.get_vars().prev_details;
|
|
let isDateEdited = false;
|
|
if(events.get_vars().editedDate)
|
|
isDateEdited = true;
|
|
return origDetails.bostatus == 2 && origDetails.eventStatus == 'AVAILABLE' && isDateEdited
|
|
},
|
|
"updateEvent": function(formData, url_param) {
|
|
var http_result = events.server.request("edit", "update_event", formData, url_param);
|
|
http_result.success(function(result){
|
|
if(app.isalive(result)) {
|
|
events.server.reset("view", result);
|
|
localStorage.setItem("result", JSON.stringify(result));
|
|
if (result.mtype == "success") {
|
|
location.reload();
|
|
} else {
|
|
var x = 0;
|
|
$.map(result.mdetail, function (input, i) {
|
|
app._form._populate_field_error(input.field, input.message, x);
|
|
x++;
|
|
});
|
|
events._progress_bar._action(".upload_progress","hide");
|
|
}
|
|
}
|
|
}).error(function(xhr){
|
|
console.log(xhr);
|
|
});
|
|
},
|
|
"getEditedDate": function(type, value) {
|
|
if(events.get_vars().isEdit) {
|
|
events.set_vars({"editedDate":{
|
|
"type": type,
|
|
"date": app._form.format_inputs("datetime", value)
|
|
}})
|
|
}
|
|
},
|
|
},
|
|
"toggleDetailFields": function(eventType) {
|
|
if(eventType === 'ENLIGNE') {
|
|
// SHOW
|
|
$('#videos_tab, #apprendre-block,#attachement-online').show()
|
|
$('#description_online_tab').show()
|
|
$('div#event_total_seats_available').show()
|
|
$('#image_attachment_limit').text('1')
|
|
// HIDE
|
|
$('#event_reservation_date, #event_start_end_date, #div_hours_per_session, #event_total_session_seats_available, #div_session_date').hide()
|
|
$('#soir_presentiel_tab, #soir_distance_tab').hide()
|
|
$('#event_status option[value="SOON"]').hide()
|
|
$('#event_status option[value="PAST"]').hide()
|
|
$('#event_status option[value="CANCEL"]').hide()
|
|
$('#locations_tab').hide()
|
|
$('.showon-preferentiele').hide()
|
|
$('#description_regular_tab').hide()
|
|
$('div.regular-block').hide()
|
|
$('div#live_video_dates').hide()
|
|
$('#desc-title-tab').text('Détail du cours');
|
|
|
|
} else if(eventType === 'DISTANCE-PRESENTIEL') {
|
|
// SHOW
|
|
$('#soir_presentiel_tab, #soir_distance_tab, #description_online_tab, #locations_tab').show()
|
|
$('#event_reservation_date, #event_start_end_date, #div_hours_per_session, #event_total_session_seats_available, #div_session_date').show()
|
|
$('#event_status option[value="SOON"]').show()
|
|
$('#event_status option[value="PAST"]').show()
|
|
$('#event_status option[value="CANCEL"]').show()
|
|
$('.showon-preferentiele').show()
|
|
$('#image_attachment_limit').text('2')
|
|
$('div#live_video_dates').show()
|
|
// HIDE
|
|
$('div#event_total_seats_available').hide()
|
|
$('div.regular-block').hide()
|
|
$('#videos_tab').hide()
|
|
$('#description_regular_tab').hide()
|
|
$('#apprendre-block').hide()
|
|
$('#attachement-online').hide()
|
|
$('#desc-title-tab').text('Détail du cours');
|
|
} else if(eventType === 'DISTANCE') {
|
|
// SHOW
|
|
$('#videos_tab').show()
|
|
$('#description_online_tab').show()
|
|
$('div#live_video_dates').show()
|
|
$('#image_attachment_limit').text('2')
|
|
$('.showon-preferentiele').show()
|
|
$('div.regular-block').show()
|
|
// HIDE
|
|
$('#event_reservation_date, #event_start_end_date, #div_hours_per_session, #event_total_session_seats_available, #div_session_date').show()
|
|
$('#soir_presentiel_tab, #soir_distance_tab').hide()
|
|
$('#event_status option[value="SOON"]').hide()
|
|
$('#event_status option[value="PAST"]').hide()
|
|
$('#event_status option[value="CANCEL"]').hide()
|
|
$('#locations_tab').hide()
|
|
// $('.showon-preferentiele').hide()
|
|
$('#description_regular_tab').hide()
|
|
$('div#event_total_seats_available').show()
|
|
$('div.regular-block').show()
|
|
$('#attachement-online').hide()
|
|
$('#apprendre-block').hide()
|
|
|
|
$('#desc-title-tab').text('Détail du cours');
|
|
} else {
|
|
//event type = PRESENTIEL
|
|
// SHOW
|
|
$('div#event_total_seats_available').show()
|
|
$('#event_reservation_date, #event_start_end_date, #div_hours_per_session, #event_total_session_seats_available, #div_session_date').show()
|
|
$('#event_status option[value="SOON"]').show()
|
|
$('#event_status option[value="PAST"]').show()
|
|
$('#event_status option[value="CANCEL"]').show()
|
|
$('#image_attachment_limit').text('2')
|
|
$('#locations_tab').show()
|
|
$('.showon-preferentiele').show()
|
|
$('#description_regular_tab').show()
|
|
$('div.regular-block').show()
|
|
// HIDE
|
|
$('#videos_tab, #apprendre-block, #attachement-online').hide()
|
|
$('#soir_presentiel_tab, #soir_distance_tab').hide()
|
|
$('#description_online_tab').hide()
|
|
|
|
$('#desc-title-tab').text("Description de l'atelier")
|
|
}
|
|
},
|
|
|
|
|
|
"_view" : {
|
|
"modal" : function(event_id){
|
|
var http_data = new FormData();
|
|
http_data.append("event_id", event_id);
|
|
var http_result = events.server.request("view", "preview_event", http_data, event_id);
|
|
http_result.success(function(result){
|
|
if(app.isalive(result)) {
|
|
events.server.reset("view", result);
|
|
if (result.mtype == "success") {
|
|
//set content in a dialog
|
|
try {
|
|
bootbox.hideAll();
|
|
bootbox.dialog({
|
|
"title": "Prévisualisation",
|
|
"className": 'preview_event_content_modal my-modal-with-large',
|
|
"size" : "large",
|
|
"message": '<div id="preview_event_content" style="width : 100%; min-height : 350px; max-height: 660px; ' +
|
|
'overflow-x: hidden !important; overflow-y: auto;" src="" frameborder="0.5" allowfullscreen>'+ '<div id="event-details-box"></div>' +'</div>',
|
|
"buttons": [
|
|
{
|
|
"label": app.get_vars()._app.btn._close,
|
|
"class": "btn btn-default w-mb",
|
|
"callback": function () {
|
|
}
|
|
}
|
|
]
|
|
}).on('shown.bs.modal', function () {
|
|
$('#preview_event_content #event-details-box').load(app.get_vars().baseurl+'event_details?event_id='+event_id+'&preview_event #event-box');
|
|
if(result.sched.length !== 0) {
|
|
var reserveBtnLabel =''
|
|
if(result.sched[0].event_status === 'CANCEL') {
|
|
reserveBtnLabel = 'Annule';
|
|
}
|
|
if(result.sched[0].event_status === 'AVAILABLE') {
|
|
reserveBtnLabel = 'Réserver';
|
|
}
|
|
if(result.sched[0].event_status === 'PAST' || result.sched[0].back_office_status === '4') {
|
|
reserveBtnLabel = 'Fermé';
|
|
}
|
|
if(result.sched[0].event_status === 'SOON') {
|
|
reserveBtnLabel = "S'inscrire"
|
|
}
|
|
if(result.sched[0].remaining_combined_seat == 0) {
|
|
reserveBtnLabel = "Complet"
|
|
}
|
|
} else {
|
|
reserveBtnLabel = "S'inscrire"
|
|
}
|
|
var previewcontent;
|
|
// Extract array string awards
|
|
var finalAwards = ''
|
|
var workshop_author = ''
|
|
var avl_seats = ''
|
|
var number_of_sessions = ''
|
|
var hours_per_session = ''
|
|
var workshop_author_description = ''
|
|
var rate = ''
|
|
var remaining_combined_seat = ''
|
|
|
|
moment.locale('fr')
|
|
let html = ""
|
|
let videoLists = ""
|
|
|
|
workshop_author = result.mdata.workshop_author
|
|
avl_seats = result.mdata.total_available_seat
|
|
number_of_sessions = result.mdata.number_of_sessions
|
|
hours_per_session = result.mdata.hours_per_session
|
|
workshop_author_description = result.mdata.workshop_author_description
|
|
rate = result.mdata.event_rate
|
|
remaining_combined_seat = result.mdata.remaining_combined_seat
|
|
|
|
// Author awards
|
|
if(result.mdata.workshop_author_awards !== null) {
|
|
var strAwards = result.mdata.workshop_author_awards;
|
|
for (let i = 0; i < strAwards.length; i++) {
|
|
finalAwards = finalAwards + '<li>'+strAwards[i]+'</li>'
|
|
}
|
|
}
|
|
|
|
if(result.sched.length !== 0) {
|
|
//Event sessions list
|
|
result.sched.forEach((d) => {
|
|
const ms = moment.duration(moment(d.end_date_time).diff(moment(d.start_date_time)))
|
|
//:${ms.minutes()}
|
|
html += `<div class="mc-event-sched">
|
|
<span class="event-date">${(moment(d.start_date_time).format('dddd DD MMM YYYY')).replace(".", '')}</span>
|
|
<span class="event-time"> — ${d.start_date_hour} à ${d.end_date_hour}</span>
|
|
<div class="event-duration">Durée ${ms.hours()}h${ms.minutes()>0?(ms.minutes().toString()+'0').slice(0,2):''}</div>
|
|
</div>`;
|
|
})
|
|
}
|
|
|
|
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<videos.length; i++) {
|
|
let hms = null
|
|
hms = videos[i].duration.split(':')
|
|
h += parseInt(hms[0])
|
|
m += parseInt(hms[1])
|
|
s += parseInt(hms[2])
|
|
}
|
|
m = m + Math.floor(s/60)
|
|
hour = h + Math.floor(m/60)
|
|
minute = m % 60
|
|
} else {
|
|
hour = 0
|
|
minute = 0
|
|
}
|
|
} else {
|
|
// Convert decimal to time format
|
|
let totalH = Math.round((result.mdata.hours_per_session) * 100) / 100;
|
|
var hour = Math.floor(totalH);
|
|
var decimal = totalH - hour;
|
|
var min = 1 / 60;
|
|
// Round to nearest minute
|
|
decimal = min * Math.round(decimal / min);
|
|
var minute = Math.floor(decimal * 60);
|
|
}
|
|
|
|
|
|
// Display Author Works
|
|
var finalWorks = ''
|
|
for (let i = 0; i < result.author_works.length; i++) {
|
|
finalWorks = finalWorks + `<div class="col-lg-3 col-md-3"><div class="card text-center"><img class="card-img-top" src="${app.get_vars().baseurl}resources/images/frontoffice/banner/${result.author_works[i].image}"><div class="card-body"><p class="card-text book-title">${result.author_works[i].work.substr(0, 36)} ${result.author_works[i].work.length < 36 ? '' : '...'}</p></div><div class="card-footer"><a class="mc-card-link align-self-center" href="${result.author_works[i].link}" target="_blank">Acheter</a></div></div></div>`
|
|
}
|
|
|
|
// Extract location of event
|
|
var obj = '';
|
|
var lat = '';
|
|
var lng = '';
|
|
var address = '';
|
|
if(result.mdata.event_place_name !== '') {
|
|
var string = result.mdata.event_place_name;
|
|
obj = JSON.parse(string);
|
|
lat = obj.geometry.lat;
|
|
lng = obj.geometry.lng;
|
|
address = obj.address;
|
|
var str = obj.address
|
|
str = str.replace(/\s+/g, '%20');
|
|
}
|
|
|
|
// For special event
|
|
var wDate =''
|
|
if(result.sched[0]) {
|
|
wDate = result.sched[0].start_date_hour
|
|
}
|
|
else {
|
|
wDate = '00h00'
|
|
}
|
|
|
|
// Preview Banner Image or Video display
|
|
let thumbnail = '';
|
|
if(result.mdata.workshop_session == null || result.mdata.workshop_session == 'PRESENTIEL') {
|
|
thumbnail = `<img src='${app.get_vars().baseurl}resources/images/frontoffice/events/${result.mdata.file_name}' class="card-img-top" alt='${result.mdata.title}'></img>`;
|
|
} else {
|
|
thumbnail = `<div align="center" class="embed-responsive embed-responsive-16by9 w-100" id="trailer_video">${JSON.parse(result.mdata.trailer)}</div>`
|
|
}
|
|
|
|
// for Preview Video Lists
|
|
if( result.event_videos.length !== 0) {
|
|
let num = 1;
|
|
result.event_videos.forEach((v) => {
|
|
arr = v.duration.split(':');
|
|
hrs = parseInt(arr[0]);
|
|
min = parseInt(arr[1]);
|
|
sec = parseInt(arr[2]);
|
|
videoLists += `<div class="video-part-item">
|
|
<div class="d-flex">
|
|
<span class="video-title">${num}. ${v.title}</span>
|
|
<span class="v-separator">|</span>
|
|
<span class="video-duration">${hrs === 0 ? '': hrs + 'h'}${min === 0 ? '' : hrs === 0 && min < 10 ? min + 'min': min < 10 ? '0' + min + 'min' : min + 'min'}${sec === 0 ? '' : hrs === 0 && min === 0 ? sec + 's' : sec < 10 ? '0' + sec : sec}</span>
|
|
</div>
|
|
<p class="video-details">${v.description}</p></div>`
|
|
num++
|
|
})
|
|
}
|
|
|
|
// for Preview Box Label
|
|
let bLabel = ""
|
|
if (result.mdata.workshop_session == 'ENLIGNE') {
|
|
bLabel = "Cours en ligne"
|
|
} else if (result.mdata.workshop_session == 'DISTANCE') {
|
|
bLabel = "Atelier à distance"
|
|
} else if (result.mdata.workshop_session == 'DISTANCIEL') {
|
|
bLabel = "Atelier Distanciel"
|
|
} else if (result.mdata.workshop_session == 'DISTANCE-PRESENTIEL') {
|
|
bLabel = "Atelier à Distance + Presentiel"
|
|
} else {
|
|
bLabel = "Atelier en présentiel"
|
|
}
|
|
// for Preview Outcome Learning Lists
|
|
if(result.mdata.learning_outcome !== null ) {
|
|
var learning_outcome = result.mdata.learning_outcome.split('\"');
|
|
var htmlOutcome = ''
|
|
for (let i = 0; i < learning_outcome.length; i++) {
|
|
if(learning_outcome[i] !== '[' && learning_outcome[i] !== ',' && learning_outcome[i] !== ']') {
|
|
htmlOutcome += `<div class="appendre-item">
|
|
<img class="mc-icon" src="${app.get_vars().baseurl}resources/images/frontoffice/icons/fleche-open.svg" />
|
|
<div class="ml-2">${learning_outcome[i]}</div>
|
|
</div>`
|
|
}
|
|
}
|
|
}
|
|
|
|
previewcontent ='<div class="row bg-primary d-flex align-items-center" style="padding: 50px 50px;">'+
|
|
'<div class="col-lg-6 mc-detail-section">'+
|
|
'<div>'+
|
|
'<div class="mc-event-speaker">'+workshop_author+'</div>'+
|
|
'<div class="mc-event-title">'+result.mdata.title+'</div>'+
|
|
`<div class="mc-sub-details ${result.mdata.workshop_session === "ENLIGNE" ? 'd-none': ''}">`+
|
|
'<div>'+result.mdata.event_venue+'</div>'+
|
|
`<div class="with-lines">${result.mdata.event_id === '108' || result.mdata.event_id === '37' ?'Le '+moment(result.mdata.start_date_time).format('DD MMMM') + ' à ' + wDate : avl_seats + ' places maximum' }</div>`+
|
|
`<div>${number_of_sessions > 1 ? number_of_sessions + " séances " : number_of_sessions + " séance "} ${hour}h${minute == 0 ? '' : minute < 10 ? '0' + minute : minute } d’atelier</div>`+
|
|
'</div>'+
|
|
`<div class="banner-info ${result.mdata.workshop_session === "ENLIGNE" ? '': 'd-none'}">` +
|
|
'<div class="flex-item">' +
|
|
`<img class="mc-icon" src="${app.get_vars().baseurl}resources/images/frontoffice/icons/video.svg" />` +
|
|
`<div>${result.event_videos.length > 1 ? result.event_videos.length + " vidéos " : result.event_videos.length + " vidéo "} ${hour}h${minute == 0 ? '' : minute < 10 ? '0' + minute : minute } d’atelier</div>` +
|
|
'</div>' +
|
|
'<div class="flex-item">' +
|
|
`<img class="mc-icon" src="${app.get_vars().baseurl}resources/images/frontoffice/icons/hourglass-outline.svg" />` +
|
|
`<div>${result.event_videos.length > 1 ? result.event_videos.length + " exercices pratiques " : result.event_videos.length + " exercice pratique"}</div>` +
|
|
'</div>' +
|
|
`<div class="flex-item d-none">` +
|
|
`<img class="mc-icon" src="${app.get_vars().baseurl}resources/images/frontoffice/icons/Calendar.svg" />` +
|
|
'<div>Inpetraverim Cato</div>' +
|
|
'</div>' +
|
|
'</div>' +
|
|
`<a class="btn mc-btn-status btn-reserve ${result.mdata.workshop_session === "ENLIGNE" ? 'd-none': ''}" href="#info-box">`+reserveBtnLabel+'</a>'+
|
|
`<a class="btn mc-btn-status btn-reserve ${result.mdata.workshop_session === "ENLIGNE" ? '': 'd-none'} ">Acheter le cours</a>`+
|
|
'</div>'+
|
|
'</div>'+
|
|
'<div class="col-lg-6 mc-img-section">'+
|
|
`<div class="overlay-video ${result.mdata.workshop_session === "ENLIGNE" ? '': 'd-none'}">
|
|
<div class="overlay-content">
|
|
<img class="mc-icon" src="${app.get_vars().baseurl}resources/images/frontoffice/icons/icon-video.svg">
|
|
<div>Lire la bande-annonce</div>
|
|
</div>
|
|
</div>`+
|
|
`${thumbnail}` +
|
|
'</div>'+
|
|
'</div>'+
|
|
'<div class="row" style="padding: 50px 50px;">'+
|
|
'<div class="col-lg-8">'+
|
|
'<div class="mc-content-text">'+
|
|
`<div class="mc-block-title mb-3">Détails de l'atelier</div>`+
|
|
'<p>'+result.mdata.description+'</p>'+
|
|
'</div>'+
|
|
`<div class="mc-event-video ${result.event_videos.length == 0 ? 'd-none': ''}">` +
|
|
`<div class="mc-block-title mb-3">${result.event_videos.length == 0 ? '' : result.event_videos.length} vidéos <span class="font-weight-normal">${hour}h${minute == 0 ? '' : minute < 10 ? '0' + minute : minute } de cours</span></div><br>` +
|
|
`<div class="video-part-lists">
|
|
${videoLists}
|
|
</div>` +
|
|
'</div><br>' +
|
|
`<div class="mc-event-apprendre ${result.mdata.learning_outcome == null || result.mdata.learning_outcome.length < 1 || result.mdata.learning_outcome == '[]' ? 'd-none': ''}">` +
|
|
'<div class="mc-block-title mb-3">Ce que vous allez apprendre</div><br>' +
|
|
'<div class="appendre-lists">'+
|
|
`${htmlOutcome}` +
|
|
'</div>' +
|
|
'</div><br><br>' +
|
|
'<div class="mc-event-author">' +
|
|
`<div class="mc-block-title mb-3">${result.mdata.author_label == null ? 'Auteur' : result.mdata.author_label}</div><br>`+
|
|
'<div class="mc-content-text">' +
|
|
'<p>'+workshop_author_description+'</p>'+
|
|
'</div>' +
|
|
'</div>' +
|
|
`<div class="mc-author-awards ${finalAwards === '<li></li>' || finalAwards === '' ? 'd-none' : ''}">`+
|
|
'<div class="mc-block-subtitle mb-3">RECOMPENSES</div><br>'+
|
|
'<ul>'+finalAwards+'</ul>'+
|
|
'<br></div>'+
|
|
`<div class="author-works-carousel card-deck ${finalWorks === '' ? 'd-none' : ''}" id="author_works_list">`+
|
|
`<div class="mc-block-subtitle mb-3">OEUVRES DE L'AUTEUR</div><br>`+
|
|
'<div class="row">'+finalWorks+'</div>'+
|
|
'<br><br><br></div>'+
|
|
`<div class="mc-event-location mb-5 ${result.mdata.event_place_name === '' || result.mdata.event_id === '108' || result.mdata.event_id === '37' ? 'd-none' : ''}">`+
|
|
'<div class="mc-block-title mb-3">Lieu de l’atelier</div><br>'+
|
|
'<div class="event-venue font-weight-bold">'+ result.mdata.event_address +'</div>' +
|
|
'<div class="event-address">'+address+'</div><br>'+
|
|
'<div class="event-map">' +
|
|
'<iframe src="https://maps.google.com/maps?q='+str+'&t=&z=10&ie=UTF8&iwloc=&output=embed&z=13" width="90%" height="300" frameborder="0" style="border:0"></iframe>'+
|
|
'<style>.gmap_canvas {overflow:hidden;background:none!important;height:300px;width:100%;}</style>' +
|
|
'</div>'+
|
|
'</div>'+
|
|
'</div>'+
|
|
'<div class="col-lg-4">'+
|
|
`<div class="box-label ${result.mdata.workshop_session == null || result.mdata.workshop_session == 'PRESENTIEL' ? 'd-none': ''}">${bLabel}</div>
|
|
<div class="info-box-visual">
|
|
<div class="${reserveBtnLabel !== "S'inscrire" ? '' : 'd-none'}">
|
|
<div class="mc-price"><span>${rate} MGA</span> par personne</div>
|
|
<div class="mc-price-mention mb-0">reduction de ${result.mdata.discount_apply}MGA pour</div>
|
|
<div class="mc-price-mention">les abonnés du Company For Madagascar</div>
|
|
<div class="card-block position-relative">
|
|
<div class="position-absolute ${result.mdata.workshop_session === "ENLIGNE" ? 'd-none': ''}">
|
|
<a data-toggle="collapse" href="#otherSched" role="button" aria-expanded="false" aria-controls="otherSched">
|
|
<div class="link-label">Détails</div>
|
|
<div class="arrow">></div>
|
|
</a>
|
|
</div>
|
|
<div class="mc-session">
|
|
<span class="font-weight-bold ${result.mdata.workshop_session === "PRESENTIEL" || result.mdata.workshop_session === null ? '': 'd-none'}">${number_of_sessions > 1 ? number_of_sessions + " séances" : number_of_sessions + " séance" }</span>
|
|
<span class="font-weight-bold ${result.mdata.workshop_session === "ENLIGNE" ? '': 'd-none'}">${result.event_videos.length > 1 ? result.event_videos.length + " videos" : result.event_videos.length + " video" }</span>
|
|
${hour}h${minute == 0 ? '' : minute < 10 ? '0' + minute : minute } ${result.mdata.workshop_session === "PRESENTIEL" || result.mdata.workshop_session === null ? "d'atelier": "de cours"}
|
|
<div class="${result.mdata.workshop_session === "ENLIGNE" ? 'd-none': ''}">
|
|
<div class="date-duration ${result.mdata.event_id === '108' || result.mdata.event_id === '37' ? '' : 'd-none'}">
|
|
${'Le '+moment(result.mdata.start_date_time).format('DD MMMM YYYY') }
|
|
</div>
|
|
<div class="date-duration ${result.mdata.event_id !== '108' || result.mdata.event_id === '37' ? '' : 'd-none'}">
|
|
${'Du '+moment(result.mdata.start_date_time).format('DD MMMM')} au ${moment(result.mdata.end_date_time).format('DD MMMM YYYY')}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="collapse ${result.sched.length !== 0 && result.mdata.workshop_session !== "ENLIGNE" ? '' : 'd-none'}" id="otherSched">
|
|
${html}
|
|
</div>
|
|
<div class="card-block venue ${result.mdata.workshop_session === "ENLIGNE" ? 'd-none': ''}">
|
|
<div class="font-weight-bold blocktitle ${result.mdata.event_id === '108' || result.mdata.event_id === '37' ? 'd-none' : ''}">Lieu de l’atelier</div>
|
|
<div class="event-location ${result.mdata.event_id === '108' || result.mdata.event_id === '37' ? 'font-weight-bold' : ''}">${result.mdata.event_address}</div>
|
|
</div>
|
|
<div class="card-block ${reserveBtnLabel === 'Fermé' || result.mdata.workshop_session === "ENLIGNE" ? 'd-none' : ''}" id="nombre-places">
|
|
<div class="font-weight-bold blocktitle ${result.mdata.event_id === '108' || result.mdata.event_id === '37' ? 'd-none' : ''}">Nombre de places</div>
|
|
<div class="available-slot ${result.mdata.event_id === '108' || result.mdata.event_id === '37' ? 'd-none' : ''}"><span id="remaining_seat">${remaining_combined_seat}</span> places restantes</div>
|
|
<div class="selectdiv">
|
|
<select class="form-control" id="number_of_seat_reserved" name="number_of_seat_reserved" required="" disabled>
|
|
<option disabled="" selected="" value="">- sélectionner -</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="mc-btn-group ${result.mdata.workshop_session === "ENLIGNE" ? 'border-top' : ''}">
|
|
<button type="button" class="btn btn-default btn-block btn-le-cours ${result.mdata.workshop_session === "ENLIGNE" ? '': 'd-none'}">Acheter le cours</button>
|
|
<button type="button" class="btn btn-block subscribe-btn ${result.mdata.workshop_session === "ENLIGNE" ? 'd-none': ''} " disabled>${reserveBtnLabel}</button>
|
|
<button class="btn btn-default btn-block offer-btn" disabled="">
|
|
<img src="${app.get_vars().baseurl}/resources/images/frontoffice/icons/Offrir.svg" height="24px">Offrir l’atelier
|
|
</button>
|
|
</div>
|
|
<div class="contact-block d-flex align-items-center">
|
|
<div class="contact-img">
|
|
<img src="${app.get_vars().baseurl}/resources/images/frontoffice/icons/contact.svg">
|
|
</div>
|
|
<div class="contact-text">
|
|
Vous avez une question ? <br>
|
|
<a href="#">Nous contacter</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="${reserveBtnLabel === "S'inscrire" ? '' : 'd-none'}">
|
|
<div class="info-box-title">Date à venir</div>
|
|
<div class="premier-date">Premier semestre 2022</div>
|
|
<div class="card-block">
|
|
<div class="register-text">Inscrivez-vous pour être tenu informé de la disponibilité de l’atelier</div>
|
|
<input type="textbox" id="workshop_informer_email" name="workshop_informer_email" class="form-control textboxes mt-3" placeholder="Email">
|
|
</div>
|
|
<div class="mc-btn-group">
|
|
<button class="btn btn-default btn-block subscribe-btn" id="reg-workshop-informer" data-event-id="42">S'inscrire</button>
|
|
</div>
|
|
</div>
|
|
</div>`
|
|
'</div>'+
|
|
'</div>'+
|
|
'</div>';
|
|
// previewcontent ='<div class="row" id="event-box">' +
|
|
// '<div class="event_details_preview col-md-8">' +
|
|
// '<h5 id="event-title" class="mt-4">'+result.mdata["title"]+'</h5>'+
|
|
// '<div class="mt-4" id="event-image-preview">' +
|
|
// '</div>' +
|
|
// '<div id="event-description">'+result.mdata["description"]+'</div>' +
|
|
// '<div id="speaker-box">' +
|
|
// '<h3 class="text-heading">INTERVENANT(S)</h3>' +
|
|
// '<hr class="line">' +
|
|
// '<div>' +
|
|
// '<ul id="speakerlist">'+
|
|
|
|
// '</ul>'+
|
|
// '</div>'+
|
|
// '</div>' +
|
|
// '<div id="sponsors-box">'+
|
|
// '<h3 class="text-heading">PARTENAIRES</h3>' +
|
|
// '<hr class="line">' +
|
|
// '<div class="row" id="sponsorslist" style="">' +
|
|
// '</div>'+
|
|
// '</div>' +
|
|
// '</div>' +
|
|
// '<div class="event_infodates_preview">' +
|
|
// '<div style="text-align: left;" id="eventInfo" class="col-md-3">' +
|
|
// '<h3 id="text-heading">INFORMATIONS</h3>' +
|
|
// '<hr class="line mt-3 mb-3">' +
|
|
// '<span id="event-date"></span>'+
|
|
// '<div class="event-address-info mb-2">' +
|
|
// '' +result.mdata["event_place_name"]+
|
|
// '<br>' +result.mdata["event_address"]+
|
|
// '<br>' +result.mdata["event_postal_code"]+' '+result.mdata["city"]+
|
|
// '<br>' +rate+
|
|
// '</div>' +
|
|
// // '<span class="favorites">'+favtext+'</span>'+
|
|
// '<span id="event-desc">' +
|
|
// '</span>'+
|
|
|
|
// '</div>' +
|
|
// '</div>' +
|
|
// '</div>';
|
|
$("div#preview_event_content").html(previewcontent);
|
|
//
|
|
// if(result.mdata['date_feature']==2){
|
|
// var dates_html=""
|
|
// var i;
|
|
// var count=result.mdata['event_sched'];
|
|
//
|
|
// var frenchmonth = [ "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre" ];
|
|
//
|
|
//
|
|
// for(i=0; count > i ; i++) {
|
|
//
|
|
// var startdate = new Date(result.sched[i]['start_date_time']);
|
|
// var startmonth = frenchmonth[startdate.getMonth()];
|
|
// var enddate = new Date(result.sched[i]['end_date_time']);
|
|
// var endmonth = frenchmonth[enddate.getMonth()];
|
|
//
|
|
// dates_html += '<div class="accordion-group mt-3 mb-3" id="accordion-group-es269">' +
|
|
// '<div class="accordion-heading">' +
|
|
// '<a class="accordion-toggle collapsed" data-toggle="collapse" data-parent="#accordionUser" href="#" aria-expanded="false">' +
|
|
// '<strong>' + Helper.event_preview_date(result.sched[i]['start_date_time'],result.sched[i]['end_date_time'],startmonth,endmonth) + '</strong>' +
|
|
// '</a>' +
|
|
// '</div>' +
|
|
// '<div id="collapse269" class="accordion-body panel-collapse collapse show" style="">' +
|
|
// '<br>' +
|
|
// '<div class="accordion-inner">' +
|
|
// '<button onclick="subscribe.button.redirect(250);" id="event_schedule_id269" data-eventscheduleid="269" data-event_id="250" class="btn btn-default-style btn-block btn-book2 btn-register '+favclass+' " data-page="details" data-btntype="reg-book" data-bostatus="2">Réserver</button>' +
|
|
// '</div>' +
|
|
// '</div>' +
|
|
// '</div>';
|
|
// $("span#event-desc").html(dates_html);
|
|
// }
|
|
// }else{
|
|
// var dates_html=""
|
|
// var i;
|
|
// var count=result.mdata['event_sched'];
|
|
//
|
|
// var frenchmonth = [ "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre" ];
|
|
//
|
|
// for(i=0; count > i ; i++) {
|
|
//
|
|
// var startdate = new Date(result.sched[i]['start_date_time']);
|
|
// var startmonth = frenchmonth[startdate.getMonth()];
|
|
// var enddate = new Date(result.sched[i]['end_date_time']);
|
|
// var endmonth = frenchmonth[enddate.getMonth()];
|
|
//
|
|
// $('#event-date').append('<strong>' + Helper.event_preview_date(result.sched[i]['start_date_time'],result.sched[i]['end_date_time'],startmonth,endmonth) + '</strong>');
|
|
// dates_html += '<div class="accordion-group mt-3 mb-3" id="accordion-group-es269">' +
|
|
// '<div id="collapse269" class="accordion-body panel-collapse collapse show" style="">' +
|
|
// '<br>' +
|
|
// '<div class="accordion-inner">' +
|
|
// '<button class="btn btn-default-style btn-block '+favclass+'">Réserver </button>' +
|
|
// '</div>' +
|
|
// '</div>' +
|
|
// '</div>';
|
|
// $("span#event-desc").html(dates_html);
|
|
// }
|
|
// }
|
|
//
|
|
// // SPEAKER
|
|
// if(result.speakers.length!=null){
|
|
// var speakers_html="";
|
|
// var s;
|
|
// var s_count = result.speakers.length;
|
|
// if(s_count==0){
|
|
// $("#speaker-box").hide();
|
|
// }
|
|
//
|
|
// for(s=0; s_count > s ; s++) {
|
|
// speakers_html += '<li>' +
|
|
// '<span class="text-heading2">'+result.speakers[s]['speaker']+'</span><br/>'+
|
|
// '<span class="text-normal"></span>'+
|
|
// '</li>';
|
|
// $("ul#speakerlist").html(speakers_html);
|
|
// }
|
|
//
|
|
// }
|
|
//
|
|
// // SPONSOR
|
|
// if(result.sponsor.length!=null){
|
|
// var sponsor_html="";
|
|
// var sp;
|
|
// var sp_count = result.sponsor.length;
|
|
// if(sp_count==0){
|
|
// $("#sponsors-box").hide();
|
|
// }
|
|
// for(sp=0; sp_count > sp ; sp++) {
|
|
// sponsor_html +=
|
|
// '<img class="img-responsive col-sm-5 col-md-3" src="resources/images/frontoffice/sponsors/'+result.sponsor[sp]['file']+'" alt="" style="display: inline-block" data-count=""/>';
|
|
//
|
|
// $("div#sponsorslist").html(sponsor_html);
|
|
// }
|
|
//
|
|
// }
|
|
//
|
|
//
|
|
// //VIDEO AUDIO
|
|
// var attachment;
|
|
// if(result.mdata["attachment_event_id"]>=1&&result.mdata["other_mime_type"]=='video/mp4'){
|
|
// attachment ='<video width="100%" height="auto" style="margin: 0 auto" controls="controls" controlsList="nodownload">' +
|
|
// '<source src="resources/images/frontoffice/events/'+result.mdata["other_attachment"]+'" type="video/mp4">'+
|
|
// 'Your browser does not support the video tag.'+
|
|
// '</video>';
|
|
// $('#event-image-preview').html(attachment);
|
|
// }else if(result.mdata["attachment_event_id"]>=1&&result.mdata["other_mime_type"]=='audio/mp3'){
|
|
// attachment= '<img style="width: 100%;" class="img-responsive" alt="" src="resources/images/frontoffice/events/'+result.mdata["file_name"]+' "><br><audio controls="controls" style="width: 100%;" controlsList="nodownload"> '+
|
|
// '<source src="resources/images/frontoffice/events/'+result.mdata["other_attachment"]+'"/>'+
|
|
// 'Your browser does not support the audio tag.'+
|
|
// '</audio>';
|
|
// $('#event-image-preview').html(attachment);
|
|
// }else{
|
|
// attachment = '<img style="width: 100%;" class="img-responsive" alt="" src="resources/images/frontoffice/events/'+result.mdata["file_name"]+' ">';
|
|
// $('#event-image-preview').html(attachment);
|
|
// }
|
|
//
|
|
//
|
|
// $(this).off('shown.bs.modal');
|
|
});
|
|
} catch (e) {
|
|
}
|
|
}
|
|
}
|
|
|
|
}).error(function(xhr){
|
|
console.log(xhr);
|
|
});
|
|
},
|
|
|
|
"fill_up_event_form" : function(event_id){
|
|
var http_data = new FormData();
|
|
http_data.append("event_id", event_id);
|
|
events.set_vars({"event_id": event_id})
|
|
$('#commentTBody').empty()
|
|
$('#learning_outcome').empty()
|
|
$('#trailer_video').empty()
|
|
$('#course_url_container').empty()
|
|
$('#course_url_container_distance').empty()
|
|
var http_result = events.server.request("view", "event_information", http_data, event_id);
|
|
http_result.success(function(result){
|
|
if(app.isalive(result)) {
|
|
events.server.reset("view", result);
|
|
if (result.mtype == "success") {
|
|
//set content grid
|
|
try {
|
|
const eventForm = $("#eventForm");
|
|
events.set_vars({"prev_details": {
|
|
bostatus: !result.mdata.back_office_status ? 0 : result.mdata.back_office_status,
|
|
eventStatus: result.mdata.event_status,
|
|
startDate: result.mdata.start_date_time,
|
|
endDate: result.mdata.end_date_time
|
|
}});
|
|
var event_data = result.mdata,
|
|
form_fields = ["title", "event_type_id", "city_location", "location",
|
|
"code_postal", "city_name", "address","rate", "is_favorite","workshop_author", "author_label", "number_of_sessions",
|
|
"hours_per_session", "workshop_event_type", "total_available_seat", "reservation_start_date",
|
|
"reservation_end_date", "event_status","back_office_status", "start_date_time", "end_date_time",
|
|
"remaining_combined_seat", "discounted_price","discount_apply","learning_outcome", "trailer","event_videos",
|
|
"d_discount_apply", "d_rate", "d_total_available_seat", "d_discounted_price", "p_remaining_combined_seat",
|
|
"p_discount_apply", "p_rate", "p_total_available_seat", "p_discounted_price", "d_remaining_combined_seat"];
|
|
$("#reamaining_seat").val('0')
|
|
if (result.mdata.back_office_status == 0) {
|
|
$("#back_office_status").val(result.mdata.back_office_status).change()
|
|
}
|
|
$.map(form_fields, function (field) {
|
|
//console.log(field)
|
|
if (field == "rate") {
|
|
// eventForm.find("#" + field).val(app._form.format_inputs("unformat_euro", event_data[field]));
|
|
eventForm.find("#" + field).val(event_data[field]);
|
|
} else if(field == "is_favorite"){
|
|
eventForm.find("#is_favorite").prop("checked", parseInt(event_data[field]));
|
|
} else if(field == "start_date_time" || field == "end_date_time" || field == "reservation_start_date" || field == "reservation_end_date") {
|
|
if(event_data[field]) {
|
|
eventForm.find("#" + field).val(app._form.format_inputs('unformat_datetime',event_data[field]));
|
|
}
|
|
} else if(field == "number_of_sessions") {
|
|
if(event_data[field]>0) {
|
|
eventForm.find("#" + field).val(event_data[field]);
|
|
} else {
|
|
eventForm.find("#" + field).val('');
|
|
}
|
|
} else if(field == "location") {
|
|
if(event_data[field]) {
|
|
const mapData = JSON.parse(event_data[field])
|
|
events.set_vars({"map": mapData});
|
|
$("#pac-input").val(mapData.address);
|
|
$("#location").val(event_data[field]);
|
|
events.getAddress(mapData);
|
|
}
|
|
} else if(field=="learning_outcome") {
|
|
if(event_data[field]) {
|
|
const outcome = JSON.parse(event_data[field])
|
|
outcome.forEach(item => {
|
|
event_outcome.add_learning(item)
|
|
})
|
|
}
|
|
} else if(field=="trailer") {
|
|
if(event_data[field]) {
|
|
event_attachment.append_trailer(JSON.parse(event_data[field]))
|
|
event_attachment.current_trailer = event_data[field]
|
|
}
|
|
} else if(field=="event_videos") {
|
|
if(event_data[field].length>0) {
|
|
event_data[field].forEach(video => {
|
|
event_video.append_video(video)
|
|
})
|
|
}
|
|
} else {
|
|
eventForm.find("#" + field).val(event_data[field]);
|
|
}
|
|
});
|
|
|
|
/* Add default label value for previously created event */
|
|
if($("#author_label").val() === '') {
|
|
$("#author_label").val('Auteur')
|
|
}
|
|
|
|
console.log($("#author_label").val())
|
|
/* Disable change status ateleir for cancelled events */
|
|
if(result.mdata.event_status === "CANCEL") {
|
|
$('#event_status').attr('disabled', 'true');
|
|
$('.edit-save-event').attr('disabled', 'true');
|
|
} else {
|
|
$('#event_status').removeAttr('disabled');
|
|
$('.edit-save-event').removeAttr('disabled');
|
|
}
|
|
/* Set display value for the remaining set */
|
|
var rem_seat = result.mdata.remaining_combined_seat;
|
|
$('#reamaining_seat').val(rem_seat);
|
|
|
|
if(result.mdata.similar_events) {
|
|
events.set_vars({"similars": result.mdata.similar_events})
|
|
} else {
|
|
events.set_vars({"similars": null})
|
|
}
|
|
//Enable this to filter similar workshop by category
|
|
//event_similar.get_similar_workshops(result.mdata.event_type_id?result.mdata.event_type_id:0)
|
|
//Disable if enabled the above
|
|
event_similar.get_similar_workshops(0)
|
|
|
|
if(event_data['workshop_banner']) {
|
|
src = 'resources/images/frontoffice/banner/'+event_data['workshop_banner']
|
|
$(".cr-image").attr('src',src);
|
|
}
|
|
|
|
if(event_data['schedules']) {
|
|
$("#tbody").empty()
|
|
//fieldInstance = 0;
|
|
event_data['schedules'].forEach(element => {
|
|
personalization.add_session(fieldInstance, element)
|
|
fieldInstance++;
|
|
});
|
|
}
|
|
|
|
if(event_data['workshop_author_awards']) {
|
|
const awards = JSON.parse(event_data['workshop_author_awards'])
|
|
$("#tbody_award").empty()
|
|
awards.forEach(element => {
|
|
personalization.add_author_award(fieldInstance, element)
|
|
fieldInstance++;
|
|
});
|
|
}
|
|
if(event_data['works']) {
|
|
$("#tbody_works").empty()
|
|
//fieldInstance = 0;
|
|
event_data['works'].forEach(element => {
|
|
personalization.add_author_works(fieldInstance, element)
|
|
fieldInstance++;
|
|
});
|
|
}
|
|
if(event_data['venue_photos']) {
|
|
$("#tbody_venue_img").empty();
|
|
event_data['venue_photos'].forEach(element => {
|
|
personalization.add_venue_img(venuePhotoCount, element)
|
|
venuePhotoCount++;
|
|
});
|
|
}
|
|
if(event_data['comments']) {
|
|
event_data['comments'].forEach(e => {
|
|
e.date = moment(e.date).format('YYYY-MM-DD')
|
|
e.rate = e.rate==0?'':e.rate
|
|
event_comment.add_comment(e)
|
|
})
|
|
}
|
|
// Add event_category in form data
|
|
eventForm.data('event_category', event_data['event_category']);
|
|
// Set event_id
|
|
//events.set_vars({"event_id": event_data.event_id});
|
|
events.set_vars({"event_title": event_data.event_title});
|
|
events.set_vars({"prev_event_status": event_data.event_status});
|
|
// Load default value oninit of wysiwyg editor
|
|
events._load("#description", function () {
|
|
tinyMCE.activeEditor.setContent(event_data["description"]);
|
|
});
|
|
// Load default value oninit of wysiwyg editor
|
|
events._load("#workshop_author_description", function () {
|
|
tinyMCE.activeEditor.setContent(event_data["workshop_author_description"]);
|
|
});
|
|
tinymce.EditorManager.execCommand('mceAddEditor', true, 'description');
|
|
// Load event schedules
|
|
event_schedule.model.action.init_schedule_form(event_data);
|
|
// Load event attachment
|
|
event_attachment.grid.init("editEvent");
|
|
// Load event speaker
|
|
event_speaker.grid.init("editEvent");
|
|
// Load event sponsor
|
|
event_sponsor.grid.init("editEvent");
|
|
// Lastly, focus the first field in the form
|
|
$("#title").focus();
|
|
} catch (e) {}
|
|
}
|
|
}
|
|
}).error(function(xhr){
|
|
console.log(xhr);
|
|
});
|
|
}
|
|
},
|
|
|
|
"_view_subscriber" : {
|
|
"view" : function(event_id) {
|
|
$("#view_subscriber").modal('show');
|
|
$("#subscribers_list_view > tbody").html("");
|
|
|
|
events._view_subscriber.getSubscribers(event_id)
|
|
},
|
|
// Load subscriber for multiple reservations
|
|
"view_sched_list" : function(event_id, subscriber) {
|
|
$("#view_subscriber_sched").modal('show');
|
|
$("#subscribers_list_sched_view > tbody").html("");
|
|
events._view_subscriber.getSubscriberSched(event_id, subscriber)
|
|
},
|
|
"edit" : function() {
|
|
$("#edit-subscriber-info").modal('show');
|
|
},
|
|
"_cancel" : {
|
|
"confirm" : function(registration_id){
|
|
let subscribers = events.get_vars()._subscribers
|
|
for(let i=0; i<subscribers.length; i++) {
|
|
if(parseInt(subscribers[i].registration_id) === parseInt(registration_id)) {
|
|
const subscriber = subscribers[i]
|
|
const name = subscriber.subscriber_first_name + ' ' + subscriber.subscriber_last_name
|
|
app.modal.confirm_box({
|
|
"message" :`<b>Cancel reservation of ${name}</b> ?<br/><br>
|
|
<span class='label label-danger' style='font-size: 12px; white-space: inherit;'>
|
|
Please click continue to proceed.
|
|
</span>`,
|
|
"_continue" : function() {
|
|
events._view_subscriber._cancel.cancel(subscriber)
|
|
},
|
|
"id" : "delete_cancel_box",
|
|
"className" : "delete_cancel_box"
|
|
});
|
|
break
|
|
}
|
|
}
|
|
},
|
|
|
|
"cancel" : function(subscriber) {
|
|
$.ajax({
|
|
url: app.get_vars().baseurl+"cancel_event_registration/"+subscriber.registration_id,
|
|
type: "POST",
|
|
data: subscriber,
|
|
success: function(result) {
|
|
if(result.mtype == "success") {
|
|
app._notify(result.mtype, result.message);
|
|
events._view_subscriber.getSubscriberSched(subscriber.event_id, subscriber.subscriber)
|
|
events._view_subscriber.getSubscribers(subscriber.event_id)
|
|
} else if(result.mtype == "error"){
|
|
app._notify(result.mtype, result.message);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
},
|
|
// Load subscriber for multiple reservations
|
|
"getSubscriberSched": function (event_id, subscriber) {
|
|
$.ajax({
|
|
url: app.get_vars().baseurl+"event_subscribers_list/"+event_id,
|
|
type: "GET",
|
|
success: function(result) {
|
|
if(result) {
|
|
events.set_vars({_subscribers: result.mdata})
|
|
events._view_subscriber.loadSubscriberSched(result.mdata, subscriber)
|
|
} else {
|
|
//no subscriber
|
|
events.set_vars({_subscribers: []})
|
|
events._view_subscriber.loadSubscriberSched(null)
|
|
}
|
|
}
|
|
});
|
|
},
|
|
// Load subscriber for multiple reservations
|
|
"loadSubscriberSched": function(subscribers, subscriber) {
|
|
var html = ""
|
|
if(subscribers) {
|
|
for(i=0; i< subscribers.length; i++) {
|
|
let disabled = ''
|
|
if(subscribers[i].status_text === 'Annulé') {
|
|
disabled = 'disabled=true'
|
|
} else {
|
|
disabled = 'onclick="events._view_subscriber._cancel.confirm('+subscribers[i].registration_id+')"'
|
|
}
|
|
// console.log("Number : "+subscribers[i].subscriber)
|
|
if(subscribers[i].subscriber == subscriber) {
|
|
for(x=0; x<subscribers[i].seats_reserved; x++) {
|
|
html = html + `<tr>
|
|
<td>1</td>
|
|
<td>${subscribers[i].booking_date}</td>
|
|
<td>${subscribers[i].booking_hour}</td>
|
|
<td>${subscribers[i].status_text}</td>
|
|
<td>
|
|
<p class="custom-popover-tooltip col-lg-1" data-placement="top" data-toggle="tooltip" data-title="Cancel" title="" data-original-title="Modifier">
|
|
<span ${disabled} class="btn btn-success btn-bo-cancel btn-xs">Annuler la reservation</span>
|
|
</p>
|
|
</td>
|
|
</tr>`
|
|
}
|
|
}
|
|
};
|
|
}
|
|
$("#subscribers_list_sched_view > tbody").html("");
|
|
$("#subscribers_list_sched_view tbody").append(html)
|
|
},
|
|
"getSubscribers": function (event_id) {
|
|
// $('#export_subscribers').attr('disabled', 'disabled')
|
|
// $('#export_subscribers').removeAttr("href");
|
|
// $('#export_subscribers').removeAttr('disabled')
|
|
$('#export_subscribers').attr('onClick', 'events._view_subscriber.exportSubscribers(this, '+event_id+')');
|
|
$.ajax({
|
|
url: app.get_vars().baseurl+"event_subscribers_list/"+event_id,
|
|
type: "GET",
|
|
success: function(result) {
|
|
if(result.mtype == 'success') {
|
|
events.set_vars({_subscribers: result.mdata})
|
|
events._view_subscriber.loadSubscribers(result.mdata)
|
|
} else {
|
|
//no subscriber
|
|
events.set_vars({_subscribers: []})
|
|
events._view_subscriber.loadSubscribers(null)
|
|
}
|
|
}
|
|
});
|
|
},
|
|
"loadSubscribers": function(subscribers) {
|
|
|
|
/**
|
|
* Create a temporary storage to gather unique subscribers
|
|
*/
|
|
var uniqueSubscribers = []
|
|
var keyTracker = []
|
|
if(subscribers) {
|
|
|
|
for(i=0; i< subscribers.length; i++) {
|
|
if(keyTracker.includes(subscribers[i].subscriber)){
|
|
// Do Nothing
|
|
} else{
|
|
keyTracker.push(subscribers[i].subscriber)
|
|
uniqueSubscribers.push(
|
|
{
|
|
"firstname": subscribers[i].subscriber_first_name,
|
|
"surname": subscribers[i].subscriber_last_name,
|
|
"email": subscribers[i].email_address,
|
|
"address": subscribers[i].address,
|
|
"phone": subscribers[i].phone,
|
|
"subscriber": subscribers[i].subscriber,
|
|
"registration_id": subscribers[i].registration_id,
|
|
"status_text": subscribers[i].status_text,
|
|
"event_id": subscribers[i].event_id,
|
|
"total_seats_reserved": subscribers[i].total_seats_reserved
|
|
}
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Display all the unique data's in the table
|
|
*/
|
|
//$("#subscribers_list_view > tbody").html("");
|
|
var html = ""
|
|
for(i=0; i< uniqueSubscribers.length; i++) {
|
|
html = html + `<tr>
|
|
<td>${uniqueSubscribers[i].firstname}</td>
|
|
<td>${uniqueSubscribers[i].surname}</td>
|
|
<td>${uniqueSubscribers[i].email}</td>
|
|
<td>${uniqueSubscribers[i].address}</td>
|
|
<td>${uniqueSubscribers[i].phone}</td>
|
|
<td>${uniqueSubscribers[i].total_seats_reserved}</td>
|
|
<td>
|
|
<p class="custom-popover-tooltip col-sm-1 col-xs-1" data-placement="top" data-toggle="tooltip">
|
|
<span onclick="events._view_subscriber.view_sched_list(${uniqueSubscribers[i].event_id}, ${uniqueSubscribers[i].subscriber})" class="btn btn-success btn-xs"><span class="fa fa-fw fa-list "></span></span>
|
|
</p>
|
|
|
|
</td>
|
|
</tr>`
|
|
};
|
|
$("#subscribers_list_view > tbody").html("");
|
|
$("#subscribers_list_view tbody").append(html)
|
|
},
|
|
"exportSubscribers": function(subscriber, event_id) {
|
|
$(subscriber).attr("href", app.get_vars().baseurl+"export_subscribers_info?event_id="+event_id);
|
|
}
|
|
|
|
},
|
|
|
|
"_delete" : {
|
|
"confirm" : function(event_id, order){
|
|
var selectedEvent = (events.get_vars()._events).row(order).data();
|
|
app.modal.confirm_box({
|
|
"message" : app.get_vars().events.cma_msg.delete_event+" \"<b>"+selectedEvent.event_title+"</b>\" ?<br/><br><span class='label label-danger' style='font-size: 12px;'>"+app.get_vars()._app.cma_msg.note+"</span>",
|
|
"_continue" : function() {
|
|
events._delete.save(event_id);
|
|
},
|
|
"id" : "delete_confirm_box",
|
|
"className" : "delete_confirm_box"
|
|
});
|
|
},
|
|
|
|
"save" : function(event_id){
|
|
var http_data = new FormData();
|
|
http_data.append("ask", "x0dkdp");
|
|
var http_result = events.server.request("delete", "delete_event", http_data, event_id);
|
|
http_result.success(function(result){
|
|
if(app.isalive(result)) {
|
|
events.server.reset("delete", result);
|
|
if (result.mtype == "success") {
|
|
//reload grid
|
|
(events.get_vars()._events).ajax.reload(null, false);
|
|
//window.setTimeout(function(){window.location.href = app.get_vars().baseurl+"event";},1000);
|
|
}
|
|
}
|
|
}).error(function(xhr){
|
|
console.log(xhr);
|
|
});
|
|
}
|
|
},
|
|
|
|
"_export" : function(ev){
|
|
var event = $(ev);
|
|
var data = (events.get_vars()._events).ajax.params();
|
|
$(ev).attr("href", app.get_vars().baseurl+"export_events_info/"+event.data("esid")+"/"+event.data("eid")+"?" + $.param(data));
|
|
},
|
|
|
|
"_load": function (selector, initcallback) {
|
|
//Edit on
|
|
tinymce.init({
|
|
selector: selector,
|
|
content_css : app.get_vars().baseurl+"resources/styles/backoffice/tinyMCE.css",
|
|
entity_encoding : "raw",
|
|
height: 400,
|
|
fontsize_formats: "8pt 9pt 10pt 11pt 12pt 26pt 36pt",
|
|
theme: 'modern',
|
|
language: 'fr_FR',
|
|
force_br_newlines: !0,
|
|
force_p_newlines: !1,
|
|
forced_root_block: "",
|
|
plugins: [
|
|
'autolink lists link charmap anchor',
|
|
'searchreplace visualblocks',
|
|
'insertdatetime table contextmenu paste'
|
|
],
|
|
toolbar: 'undo redo pastetext | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link | sizeselect | fontsizeselect',
|
|
fontsize_formats: "8pt 10pt 12pt 14pt 18pt 24pt 36pt",
|
|
init_instance_callback : (typeof initcallback != "undefined")?initcallback:function(){}
|
|
});
|
|
},
|
|
|
|
"validation" : {
|
|
|
|
"_validate" : function(action){
|
|
const fieldRequiredDependsOnBOStatus = function(element) {
|
|
//var data = (events.get_vars().event_schedule_list)[0].data(),
|
|
is_not_valid = false;
|
|
//check if back office status >=1
|
|
//$.map(data, function(value, key){
|
|
// if(typeof value.back_office_status != "undefined" && value.back_office_status !=0 && value.back_office_status != null){
|
|
// is_not_valid = true; //bo status >=1 so, all fields must undergo validation
|
|
// return false;
|
|
// }
|
|
//});
|
|
const bos = $('#back_office_status').val()
|
|
|
|
if(typeof bos != "undefined" && bos !=0 && bos != null){
|
|
is_not_valid = true; //bo status >=1 so, all fields must undergo validation
|
|
//return false;
|
|
}
|
|
return is_not_valid;
|
|
};
|
|
const isRequired = fieldRequiredDependsOnBOStatus() && (events.get_vars().workshop_session != 'ENLIGNE')
|
|
const isRequiredPresentiel = fieldRequiredDependsOnBOStatus() && (events.get_vars().workshop_session != 'DISTANCE-PRESENTIEL')
|
|
event_speaker.grid.remove_inline_edit();
|
|
var options = {
|
|
"tab" : "#home",
|
|
boot_box: {
|
|
"message": (action == "add")
|
|
? app.get_vars().events.cma_msg.add_new_event
|
|
: app.get_vars().events.cma_msg.save_changes
|
|
,
|
|
"_continue": function () {
|
|
var _form_ = $("form#eventForm");
|
|
(action == "add")
|
|
? events._add.save(_form_)
|
|
: events._edit.save(_form_)
|
|
}
|
|
},
|
|
"validation" : {
|
|
"custom" : {
|
|
"rules": {
|
|
"use_diff_address": {
|
|
"_fnc": function (value, element, options) {
|
|
var use_diff_address = $('input[type=checkbox][name="use_different_address_per_date"]:checked').val();
|
|
if(use_diff_address == "1") {
|
|
return event_schedule.validate.check_address();//valid or not
|
|
}
|
|
return true; //means valid
|
|
},
|
|
msg: "Addresse per date is required!"
|
|
},
|
|
"date_feature_single": {
|
|
"_fnc": function (value, element, options) {
|
|
var date_feature = $('input[type=radio][name="date_feature"]:checked').val();
|
|
if(date_feature == "1") {
|
|
var eventSchedule = (events.get_vars().event_schedule_list[0]).data().count();
|
|
if(typeof eventSchedule != "undefined"){
|
|
if(eventSchedule == 1){
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
return true; //means valid
|
|
},
|
|
msg: app.get_vars().events.val.date_feature_single
|
|
},
|
|
"date_feature_multiple": {
|
|
"_fnc": function (value, element, options) {
|
|
var date_feature = $('input[type=radio][name="date_feature"]:checked').val();
|
|
if(date_feature == "2") {
|
|
var eventSchedule = (events.get_vars().event_schedule_list[0]).data().count();
|
|
if(typeof eventSchedule != "undefined"){
|
|
if(eventSchedule > 1){
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
return true; //means valid
|
|
},
|
|
msg: app.get_vars().events.val.date_feature_multiple
|
|
},
|
|
|
|
"combine_seats_required": {
|
|
"_fnc": function (value, element, options) {
|
|
var seat_feature = $('input[type=radio][name="seat_feature"]:checked').val();
|
|
if(seat_feature == "2") {
|
|
var combinedSeat = $("input#total_combined_seat").val().trim();
|
|
var isEditEvent = events.get_vars().event_id;
|
|
if(parseInt(combinedSeat) >= 0 && isEditEvent !=null && combinedSeat!=""){
|
|
return true;
|
|
} else if(isEditEvent ==null && parseInt(combinedSeat) >0 && combinedSeat !=""){
|
|
return true;
|
|
}
|
|
return false
|
|
}
|
|
return true; //means valid
|
|
},
|
|
msg: app.get_vars().events.val.combine_seats_required
|
|
},
|
|
|
|
"seat_feature_required": {
|
|
"_fnc": function (value, element, options) {
|
|
var date_feature = $('input[type=radio][name="date_feature"]:checked').val();
|
|
if(date_feature == "2") {
|
|
var seat_feature = $('input[type=radio][name="seat_feature"]:checked').val();
|
|
if(typeof seat_feature != "undefined"){
|
|
if(seat_feature != ""){
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
return true; //means valid
|
|
},
|
|
msg: app.get_vars().events.val.seat_feature_required
|
|
}
|
|
},
|
|
"informal_val": {
|
|
"_rules": function () {
|
|
app._form._resetFormValidation("#eventForm");
|
|
var error = [], message = "";
|
|
//get description
|
|
var is_not_valid = fieldRequiredDependsOnBOStatus();
|
|
if(is_not_valid) {//if bo status >=1, means must undergo a validation
|
|
//check event description
|
|
var mail_content = tinyMCE.get('description').getContent();
|
|
if (mail_content == null || mail_content.trim() == "") {
|
|
message += " * " + app.get_vars().events.val.email_desc + "<br/>";
|
|
error.push(function () {
|
|
$('.nav-tabs a[href="#description_tab"]').tab('show');
|
|
tinymce.execCommand('mceFocus', false, 'description');
|
|
});
|
|
}
|
|
//author contenct
|
|
var author_content = tinyMCE.get('workshop_author_description').getContent();
|
|
if (author_content == null || author_content.trim() == "") {
|
|
message += " * " + app.get_vars().events.val.author_desc + "<br/>";
|
|
error.push(function () {
|
|
$('.nav-tabs a[href="#author_tab"]').tab('show');
|
|
tinymce.execCommand('mceFocus', false, 'workshop_author_description');
|
|
});
|
|
}
|
|
//check event_file_attachment
|
|
if(!event_attachment.upload.validate.check_file_attachment()
|
|
|| (events.get_vars().workshop_session == 'ENLIGNE' && !event_attachment.upload.validate.check_video_attachment())){
|
|
message += " * " + app.get_vars().events._file.required_attachment + "<br/>";
|
|
error.push(function () {
|
|
$('.nav-tabs a[href="#photo_video"]').tab('show');
|
|
});
|
|
}
|
|
// let location_input = $('#location').val();
|
|
// if(location_input == null || location_input.trim() == ""){
|
|
// message += " * " + app.get_vars().events.val.location + "<br/>";
|
|
// error.push(function () {
|
|
// $('.nav-tabs a[href="#location_tab"]').tab('show');
|
|
// });
|
|
// }
|
|
}
|
|
if(!$("#workshop_author").val()) {
|
|
message += " * Impossible de publier l'événement. Auteur necéssaire. <br/>";
|
|
error.push(function () {
|
|
$('.nav-tabs a[href="#author_tab"]').tab('show');
|
|
});
|
|
}
|
|
|
|
if(!$("#author_label").val()) {
|
|
message += " * Impossible de publier l'événement. Auteur étiquette necéssaire. <br/>";
|
|
error.push(function () {
|
|
$('.nav-tabs a[href="#author_tab"]').tab('show');
|
|
});
|
|
}
|
|
|
|
if(events.get_vars().workshop_session == 'DISTANCE-PRESENTIEL') {
|
|
/** Atelier a distance tab */
|
|
if(fieldRequiredDependsOnBOStatus() && (!$("#d_rate").val() || !$("#d_total_available_seat").val() || !$("#d_discounted_price").val() || !$("#d_discount_apply").val())) {
|
|
message += " * Impossible de publier l'événement. Soir atelier distance necéssaire. <br/>";
|
|
error.push(function () {
|
|
$('.nav-tabs a[href="#soir_atelier_distance"]').tab('show');
|
|
});
|
|
}
|
|
|
|
/** Atelier en presentiel tab */
|
|
if(fieldRequiredDependsOnBOStatus() && (!$("#p_rate").val() || !$("#p_total_available_seat").val() || !$("#p_discounted_price").val() || !$("#p_discount_apply").val())) {
|
|
message += " * Impossible de publier l'événement. Soir atelier presentiel necéssaire. <br/>";
|
|
error.push(function () {
|
|
$('.nav-tabs a[href="#soir_atelier_presentiel"]').tab('show');
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
if (message != "") {
|
|
app._notify("error", message);
|
|
}
|
|
|
|
return error;
|
|
},
|
|
|
|
"_callback": function (error) {
|
|
//open tab
|
|
if (error.length >= 1) {
|
|
for (i = 0; i < error.length; i++) {
|
|
error[i]();
|
|
return false;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
},
|
|
"form_id": "form#eventForm",
|
|
"ignore" : ".ignore",
|
|
"rules": {
|
|
"title": {
|
|
"required": false,
|
|
"minlength": 2
|
|
},
|
|
"event_type_id": {
|
|
"required": {
|
|
depends : fieldRequiredDependsOnBOStatus
|
|
}
|
|
},
|
|
"workshop_event_type": {
|
|
"required": {
|
|
depends : fieldRequiredDependsOnBOStatus
|
|
}
|
|
},
|
|
"city_location": {
|
|
"required": {
|
|
depends : fieldRequiredDependsOnBOStatus
|
|
}
|
|
},
|
|
"rate": {
|
|
"required": isRequiredPresentiel,
|
|
"digits" : true
|
|
},
|
|
"city_name": {
|
|
"required": {
|
|
depends : fieldRequiredDependsOnBOStatus
|
|
}
|
|
},
|
|
"address": {
|
|
"required": isRequired
|
|
},
|
|
"date_feature" : {
|
|
"required" : true,
|
|
"date_feature_single" : {
|
|
depends : fieldRequiredDependsOnBOStatus
|
|
},
|
|
"date_feature_multiple" : true
|
|
},
|
|
"seat_feature" : {
|
|
"combine_seats_required" : true,
|
|
"seat_feature_required" : true
|
|
},
|
|
"use_different_address_per_date" : {
|
|
"use_diff_address" : {
|
|
depends : fieldRequiredDependsOnBOStatus
|
|
}
|
|
},
|
|
"total_available_seat": {
|
|
"required": isRequired && isRequiredPresentiel,
|
|
"digits" : true
|
|
},
|
|
"number_of_sessions": {
|
|
"required": isRequired,
|
|
"digits" : true
|
|
},
|
|
"hours_per_session": {
|
|
"required": isRequired
|
|
},
|
|
"reservation_start_date": {
|
|
"required": isRequired
|
|
},
|
|
"reservation_end_date": {
|
|
"required": isRequired
|
|
},
|
|
"start_date_time": {
|
|
"required": isRequired
|
|
},
|
|
"end_date_time": {
|
|
"required": isRequired
|
|
},
|
|
"discounted_price": {
|
|
"required": isRequiredPresentiel,
|
|
"digits" : true
|
|
},
|
|
"discount_apply": {
|
|
"required": isRequiredPresentiel,
|
|
"digits" : true
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
app._form._validate(options);
|
|
},
|
|
|
|
// validation for multiple change status
|
|
"_check_change_stat_eligibility" : function(ev_sched_id, category){
|
|
// get event and event schedule ifo
|
|
$.ajax({
|
|
type: "GET",
|
|
async: false,
|
|
url: app.get_vars().baseurl+"event_schedule_information/"+ ev_sched_id,
|
|
success: function(data, status){
|
|
switch (category) {
|
|
case 'is_sched_started':
|
|
var start_datetime = new Date(data.mdata.start_date_time);
|
|
var nowDate= new Date();
|
|
if (start_datetime >= nowDate) {
|
|
return true;
|
|
}
|
|
return false;
|
|
break;
|
|
case 'event_info_complete':
|
|
$.get(app.get_vars().baseurl+"event_info/"+ data.mdata.event_id,
|
|
function(evdata, status){
|
|
var city_location_filled = evdata.mdata.city_location != null || evdata.mdata.city_location != ''? true:false;
|
|
var event_type_id_filled = evdata.mdata.event_type_id != null || evdata.mdata.event_type_id != ''? true:false;
|
|
var location_filled = evdata.mdata.location != null || evdata.mdata.location != ''? true:false;
|
|
var code_postal_filled = evdata.mdata.code_postal != null || evdata.mdata.code_postal != ''? true:false;
|
|
var address_filled = evdata.mdata.address != null || evdata.mdata.address != ''? true:false;
|
|
var city_name_filled = evdata.mdata.city_name != null || evdata.mdata.city_name != ''? true:false;
|
|
if (
|
|
city_location_filled &&
|
|
event_type_id_filled &&
|
|
location_filled &&
|
|
code_postal_filled &&
|
|
address_filled &&
|
|
city_name_filled
|
|
) {
|
|
return true;
|
|
}
|
|
return false;
|
|
});
|
|
break;
|
|
case 'encourse_to_publi':
|
|
$.ajax({
|
|
type: "GET",
|
|
async: false,
|
|
url:app.get_vars().baseurl+"event_info/"+ data.mdata.event_id,
|
|
success: function(evdata, status){
|
|
if (
|
|
evdata.mdata.city_location &&
|
|
evdata.mdata.event_type_id &&
|
|
evdata.mdata.location &&
|
|
evdata.mdata.code_postal &&
|
|
evdata.mdata.address &&
|
|
evdata.mdata.city_name &&
|
|
data.mdata.reservation_start_date &&
|
|
data.mdata.start_date_time
|
|
) {
|
|
change_eligible = true;
|
|
} else {
|
|
change_eligible = false;
|
|
}
|
|
// console.log(change_eligible);
|
|
}
|
|
});
|
|
|
|
break;
|
|
|
|
case 'encourse_to_ouvert':
|
|
$.ajax({
|
|
type: "GET",
|
|
async: false,
|
|
url:app.get_vars().baseurl+"event_info/"+ data.mdata.event_id,
|
|
success: function(evdata, status){
|
|
if (
|
|
evdata.mdata.city_location &&
|
|
evdata.mdata.event_type_id &&
|
|
evdata.mdata.location &&
|
|
evdata.mdata.code_postal &&
|
|
evdata.mdata.address &&
|
|
evdata.mdata.city_name &&
|
|
!data.mdata.reservation_start_date &&
|
|
data.mdata.start_date_time
|
|
) {
|
|
change_eligible = true;
|
|
} else {
|
|
// app._notify("warning", " Attention : Il n'est pas possible de changer le statut de votre sélection de En cours de création à Ouvert.");
|
|
change_eligible = false;
|
|
}
|
|
// console.log(change_eligible);
|
|
}
|
|
});
|
|
|
|
// $.get(app.get_vars().baseurl+"event_info/"+ data.mdata.event_id,
|
|
// );
|
|
break;
|
|
|
|
case 'termine_to_ouvert':
|
|
$.ajax({
|
|
type: "GET",
|
|
async: false,
|
|
url:app.get_vars().baseurl+"is_seats_available/"+ ev_sched_id +"/2",
|
|
success: function(evdata, status){
|
|
var wl_avail = evdata.available;
|
|
if (data.mdata.event_status != 'CANCEL' && wl_avail) {
|
|
change_eligible = true;
|
|
} else {
|
|
// app._notify("warning", " Attention : Il n'est pas possible de changer le statut de votre sélection de Terminé à Ouvert.");
|
|
change_eligible = false;
|
|
}
|
|
// console.log(change_eligible);
|
|
}
|
|
});
|
|
|
|
break;
|
|
|
|
case 'termine_to_verro':
|
|
$.ajax({
|
|
type: "GET",
|
|
async: false,
|
|
url:app.get_vars().baseurl+"is_seats_available/"+ ev_sched_id +"/2",
|
|
success: function(evdata, status){
|
|
var wl_avail = evdata.available;
|
|
if (!wl_avail) {
|
|
change_eligible = true;
|
|
} else {
|
|
// app._notify("warning", " Attention : Il n'est pas possible de changer le statut de votre sélection de Terminé à Ouvert.");
|
|
change_eligible = false;
|
|
}
|
|
// console.log(change_eligible);
|
|
}
|
|
});
|
|
break;
|
|
|
|
case 'archive_to_ferme':
|
|
case 'termine_to_ferme':
|
|
var nowDate= new Date();
|
|
var start_datetime = new Date(data.mdata.start_date_time);
|
|
var end_datetime = new Date(data.mdata.end_date_time);
|
|
if (end_datetime != null && end_datetime != '') {
|
|
change_eligible = end_datetime < nowDate;
|
|
} else if (start_datetime != null && start_datetime != '') {
|
|
change_eligible = start_datetime < nowDate;
|
|
} else {
|
|
// if (category == 'archive_to_ferme') {
|
|
// app._notify("warning", " Attention : Il n'est pas possible de changer le statut de votre sélection de Archivé à Fermé.");
|
|
// } else {
|
|
// app._notify("warning", " Attention : Il n'est pas possible de changer le statut de votre sélection de Terminé à Fermé.");
|
|
// }
|
|
change_eligible = false;
|
|
}
|
|
break;
|
|
|
|
default:
|
|
}
|
|
}
|
|
});
|
|
}
|
|
},
|
|
|
|
"server" : {
|
|
"data" : function(action){
|
|
var eventForm = $("form#eventForm");
|
|
eventForm.find(".filechooser").prop('disabled', true);
|
|
var formData = new FormData($("form#eventForm")[0]);
|
|
|
|
/*index 0 = key, index 1 = values */
|
|
for(var data of formData.entries()) {
|
|
if(data[0] == "rate"){
|
|
formData.set(data[0], app._form.format_inputs("euro", data[1]));
|
|
} else if(data[0] == "description"){
|
|
formData.set(data[0], tinyMCE.get("description").getContent());
|
|
} else if(data[0] == "workshop_author_description"){
|
|
formData.set(data[0], tinyMCE.get("workshop_author_description").getContent());
|
|
} else if(data[0] == "reservation_start_date" || data[0] == "reservation_end_date"
|
|
|| data[0] == "start_date_time" || data[0] == "end_date_time") {
|
|
formData.set(data[0], app._form.format_inputs("datetime", data[1]));
|
|
}
|
|
}
|
|
|
|
formData.append('event_category', eventForm.data('event_category'));
|
|
|
|
const sessions_dates = events.formatSessionDates();
|
|
formData.append('session_dates', JSON.stringify(sessions_dates));
|
|
const author_awards = events.formatAuthorAwards();
|
|
formData.append('workshop_author_awards', JSON.stringify(author_awards));
|
|
const author_works = events.formatAuthorWorks();
|
|
formData.append('author_works', JSON.stringify(author_works));
|
|
const venue_photos = events.formatVenuePhotos();
|
|
formData.append('venue_photos', JSON.stringify(venue_photos));
|
|
formData.append('similar_events', JSON.stringify($('#similar-field').val()));
|
|
formData.append('comments', JSON.stringify(event_comment.format_comments()))
|
|
formData.append('workshop_session', events.get_vars().workshop_session)
|
|
formData.append('event_videos', event_video.format_videos())
|
|
formData.append('trailer', event_attachment.current_trailer)
|
|
formData.append('learning_outcome', event_outcome.format_learning())
|
|
if(events.get_vars().workshop_session == 'ENLIGNE') {
|
|
formData.append('tag', 'Cours en ligne')
|
|
} else if(events.get_vars().workshop_session == 'DISTANCE-PRESENTIEL' || events.get_vars().workshop_session == 'DISTANCE') {
|
|
formData.append('tag', 'Cours du soir')
|
|
formData.append('night_class_prices', events.server.formatNightClassPrices())
|
|
} else {
|
|
formData.append('tag', 'Atelier')
|
|
}
|
|
if(action == "add") {
|
|
formData.append('event_schedule', JSON.stringify(event_schedule.model.action.client.clean_event_dates()));
|
|
formData.append('event_speaker', JSON.stringify(event_speaker.model.action.client.clean_event_speaker_data()));
|
|
formData = event_sponsor.model.action.client.clean_event_sponsor_data(formData);
|
|
formData = event_attachment.model.action.client.clean_event_attachment_data(formData);
|
|
} else {
|
|
var total_combined_seat = $("#total_combined_seat");
|
|
formData.append('avl_com_seats', total_combined_seat.data("avl_com_seats"));
|
|
formData.append('rem_com_seats', total_combined_seat.data("rem_com_seats"));
|
|
}
|
|
eventForm.find(".filechooser").prop('disabled', false);
|
|
// Display the key/value pairs
|
|
/*for (var pair of formData.entries()) {
|
|
console.log(pair[0]+ ', ' + pair[1]);
|
|
}*/
|
|
return formData;
|
|
},
|
|
"formatNightClassPrices": function () {
|
|
const prices = {
|
|
distance: {
|
|
rate: $('#d_rate').val(),
|
|
total_available_seat: $('#d_total_available_seat').val(),
|
|
discounted_price: $('#d_discounted_price').val(),
|
|
discount_apply: $('#d_discount_apply').val()
|
|
},
|
|
presentiel:{
|
|
rate: $('#p_rate').val(),
|
|
total_available_seat: $('#p_total_available_seat').val(),
|
|
discounted_price: $('#p_discounted_price').val(),
|
|
discount_apply: $('#p_discount_apply').val()
|
|
}
|
|
}
|
|
return JSON.stringify(prices)
|
|
},
|
|
|
|
"request" : function(action, http_url, http_data, url_param="") {
|
|
$("body").attr("onbeforeunload", "return events.server.prevent_reload()");
|
|
var ajx_opts = {
|
|
// async:false,
|
|
type : "post",
|
|
cache: false,
|
|
processData: false,
|
|
contentType: false,
|
|
data : http_data,
|
|
url : app.get_vars().baseurl+http_url+((url_param!="")?"/"+url_param: "")
|
|
};
|
|
//use xhr only for certain server requests
|
|
if(action!= "delete" && action!= "view"){
|
|
events.server.status(action);
|
|
ajx_opts["xhr"] = function() {
|
|
myXhr = $.ajaxSettings.xhr();
|
|
if(myXhr.upload){
|
|
myXhr.upload.addEventListener('progress',function(e){
|
|
events.server.progress(e, action);
|
|
}, false);
|
|
}
|
|
return myXhr;
|
|
}
|
|
}
|
|
return $.ajax(ajx_opts);
|
|
},
|
|
|
|
"progress" : function(event, action){
|
|
var progress=Math.round((event.loaded/event.total) * 100);
|
|
var upload_progress = $("#upload_progress_sponsor");
|
|
upload_progress.css("width", progress + '%');
|
|
upload_progress.find("#upload_progress_sponsor_text").text('Saving data '+progress + '%');
|
|
},
|
|
|
|
"status" : function(action){
|
|
bootbox.dialog({
|
|
message: '<div class="progress" style="margin-bottom: 4px !important;">'
|
|
+'<div class="progress-bar" id="upload_progress_sponsor" role="progressbar" aria-valuenow="0"'
|
|
+'aria-valuemin="0" aria-valuemax="100" style="width:50%">'
|
|
+'<span id="upload_progress_sponsor_text"></span>'
|
|
+'</div>'
|
|
+'</div>',
|
|
"className" : "my-modal-with-xsm upload_progress",
|
|
closeButton: false
|
|
});
|
|
},
|
|
|
|
"prevent_reload" : function(){
|
|
return "Would you like to abort process?";
|
|
},
|
|
|
|
"reset" : function(action, result){
|
|
//remove unbefore unload
|
|
$("body").removeAttr("onbeforeunload");
|
|
//hide progress message
|
|
if(action!= "delete" && action!= "view"){
|
|
$(".upload_progress").modal("hide");
|
|
}
|
|
|
|
//notify user
|
|
if(result.mtype != "success"){
|
|
app._notify(result.mtype, result.message);
|
|
}
|
|
else if(action!= "view" && result.mtype == "success") {
|
|
app._notify(result.mtype, result.message);
|
|
}
|
|
}
|
|
},
|
|
|
|
showChildEvent : function ( rowdata , row) {
|
|
const gridCols = event_category.event_maingrid_subgrid_cols(rowdata);
|
|
var notIncludedCols = ["reservation_end_date", "seats_per_subscriber", "total_quota_waiting_list_seat","total_available_seat", "event_schedule_id"],
|
|
requiredCols = gridCols.requiredColsTd,
|
|
rows ="";
|
|
|
|
$.map(rowdata.action.event_schedule, function(value, key) {
|
|
rem_seats = 0, total_avail_seat = 0;
|
|
checkbox_evsched ='';
|
|
if (authorize(PAGE_CODE['events'], PRIVS[PAGE_CODE['events']]['sched_edit'])) {
|
|
checkbox_evsched ='<td><input type="checkbox" class="ev' + (value.event_schedule_id) + ' ev_scheds_cb evsched'+rowdata.action.event_id+'" onclick="events._init_cstat('+rowdata.action.event_id+')" name="ev_sched_ids[]" value="' + (value.event_schedule_id) + '" /></td>';
|
|
}
|
|
|
|
rows += '<tr data-event-id="'+ (rowdata.action.event_id) +'" id="ev' + (value.event_schedule_id) + '" class="ev'
|
|
+ (rowdata.action.event_id) + 'sched" > '
|
|
+ checkbox_evsched;
|
|
rows += '<td>'+(key+1)+'</td>';
|
|
$.map(requiredCols, function(val, index) { //only required columns are allowed
|
|
var col_id = '';
|
|
if (notIncludedCols.indexOf(index) == -1) { // do not allow notIncludedCols
|
|
var newValue = value[val];
|
|
if (val=="event_status") { //get translation for event_status
|
|
newValue = app.get_vars().events.event_status[newValue.toLowerCase()];
|
|
} else if(val=="back_office_status") { //get translation for back_office_status
|
|
newValue = app.get_vars().events.bo_status['bostat'+newValue];
|
|
col_id = val;
|
|
}
|
|
if (val == 'remaining_seat') {
|
|
if (value.date_feature == 1) {
|
|
rem_seats = (!newValue)? 0: newValue;
|
|
total_avail_seat = (!value.total_available_seat) ? 0 : value.total_available_seat;
|
|
rows +='<td id='+ col_id +'>'+(rem_seats)+' / '+(total_avail_seat)+'</td>';
|
|
} else {
|
|
rem_seats = (!value.rem_seats) ? 0 : value.rem_seats;
|
|
total_avail_seat = (!value.avl_seats) ? 0 : value.avl_seats;
|
|
rows +='<td id='+ col_id +'>'+(rem_seats)+' / '+(total_avail_seat)+'</td>';
|
|
}
|
|
|
|
if (rowdata.event_category == 'REGULAR_EVENT') {
|
|
// insert noshow data
|
|
noshow_value = 'Désactivé';
|
|
$.ajax({
|
|
url: app.get_vars().baseurl+'getNoshowInfo/'+value.event_schedule_id,
|
|
async: false
|
|
})
|
|
.done(function(data) {
|
|
if (data.total_noshow && data.total_bookings) {
|
|
if (data.no_show_stat!=0) {
|
|
noshow_value = `${data.total_noshow}/${data.total_bookings}`;
|
|
}
|
|
}
|
|
});
|
|
|
|
rows += `<td>${noshow_value}</td>`;
|
|
}
|
|
} else {
|
|
rows +='<td id='+ col_id +'>'+(newValue)+'</td>';
|
|
}
|
|
}
|
|
});
|
|
|
|
var disableBtn = (parseInt(value.back_office_status) != 4 && parseInt(value.back_office_status) >0 && moment() < moment(value.start_date_time, "DD/MM/YYYY HH[h]mm") )?false:true;
|
|
|
|
// rows += '<td class="custom-popover-tooltip" style="padding-left:0px;margin-left:0px;">';
|
|
// if (authorize(PAGE_CODE['events'], PRIVS[PAGE_CODE['events']]['sched_edit'])) {
|
|
// rows += app.grid.create_action_btn(app.get_vars()._app.action._edit, "pencil", "success", "event_schedule.modal.init(\'editSchedule\', \'"+row+"_"+key+"\', "+rowdata.use_different_address_per_date+");");
|
|
// }
|
|
// if (authorize(PAGE_CODE['events'], PRIVS[PAGE_CODE['events']]['sched_export_subs_list_btn'])) {
|
|
// rows += "<a href='#' data-esid='"+value.event_schedule_id+"' data-eid='"+rowdata.action.event_id+"' onclick='events._export(this)'>" + app.grid.create_action_btn(app.get_vars()._app.action._export, "file-excel-o","info", null)+"</a>";
|
|
// }
|
|
// if (authorize(PAGE_CODE['noshow'], PRIVS[PAGE_CODE['noshow']]['view']) && rowdata.event_category == 'REGULAR_EVENT') {
|
|
// rows += app.grid.create_action_btn(app.get_vars()._app.action._noshow, "list-alt", "success", "event_resend_email.redirect_noshow("+rowdata.action.event_id+","+value.event_schedule_id+");");
|
|
// }
|
|
// if (authorize(PAGE_CODE['events'], PRIVS[PAGE_CODE['events']]['sched_resend_email_btn']) && rowdata.event_category != 'ONLINE_EVENT') {
|
|
// rows += app.grid.create_action_btn(app.get_vars()._app.action._resend, "send", "success", ((disableBtn)?"":"event_resend_email.modal("+value.event_schedule_id+");") , ((disableBtn)?"disabled":""));
|
|
// }
|
|
// if (authorize(PAGE_CODE['events'], PRIVS[PAGE_CODE['events']]['sched_email_template_btn']) && rowdata.event_category != 'ONLINE_EVENT') {
|
|
// rows += app.grid.create_action_btn(app.get_vars()._app.action._email, "envelope", "success", ((disableBtn)?"":"assign_email_template.email_template_modal("+rowdata.action.event_id+", "+value.event_schedule_id+",\'schedule\')") , ((disableBtn)?"disabled":""));
|
|
// }
|
|
// if (authorize(PAGE_CODE['events'], PRIVS[PAGE_CODE['events']]['sched_email_reminder_btn']) && rowdata.event_category != 'ONLINE_EVENT') {
|
|
// rows += app.grid.create_action_btn( app.get_vars()._app.action._configure_email, "cog", "success", ((disableBtn)?"":"email_reminder.init("+value.event_schedule_id+", \'"+row+"_"+key+"\');"), ((disableBtn)?"disabled":""));
|
|
// }
|
|
// rows += '</td> </tr>';
|
|
});
|
|
action_th = authorize(PAGE_CODE['events'], PRIVS[PAGE_CODE['events']]['sched_edit'])?'<th style="width:'+gridCols.actionWidth+'%;">Actions</th>':'<th style="">Actions</th>';
|
|
|
|
disabled_chbox_class = '';
|
|
checkbox_all = '';
|
|
|
|
if (!rows) {
|
|
disabled_chbox_class = 'disabled="disabled"';
|
|
}
|
|
|
|
if (authorize(PAGE_CODE['events'], PRIVS[PAGE_CODE['events']]['sched_edit'])) {
|
|
checkbox_all = '<th><input name="evsched_all_chckbox[]" type="checkbox" '+disabled_chbox_class+' id="evsched_all_chckbox'+rowdata.action.event_id+'" onclick="events._toggle_sched(' + (rowdata.action.event_id) + ', this.checked)" /></th>';
|
|
}
|
|
|
|
return '<table id="event_schedule_table" cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;"'+
|
|
'class="table table-responsive table-bordered table-striped nowrap">'+
|
|
'<thead>'+
|
|
checkbox_all +
|
|
'<th>#</th>' +
|
|
gridCols.requiredColsTh +
|
|
// action_th +
|
|
'</thead>'+
|
|
'<tbody>'+
|
|
((rows!="")
|
|
? rows
|
|
: '<tr class="odd"><td valign="top" colspan="10" class="dataTables_empty">Aucun résultat.</td></tr>')
|
|
+'</tbody>'+
|
|
'</table>';
|
|
},
|
|
|
|
"load" : function(){
|
|
var table = $('#events_list').DataTable({
|
|
"dom" : '<"top"lf>rt<"bottom"ip><"clear">',
|
|
"autoWidth": false,
|
|
"select" : true,
|
|
"responsive": false,
|
|
"processing": true, //Feature control the processing indicator.
|
|
"serverSide": true, //Feature control DataTables' server-side processing mode.
|
|
"order": [], //Initial no order.
|
|
"oLanguage": fr_onload_lang.oLanguage,
|
|
// Load data for the table's content from an Ajax source
|
|
"ajax": {
|
|
"url": app.get_vars().baseurl+"list_event/0",
|
|
"type": "POST",
|
|
"data" : function(d){
|
|
|
|
// add the cancel option to edit form if not yet added
|
|
if ($('#cancel-option').length===0) {
|
|
$('select[name=event_status]').append('<option id="cancel-option" value="CANCEL">Annulé</option>');
|
|
}
|
|
$('#collapse_all').hide();
|
|
$('#events-select-all').hide();
|
|
$('#expand_all').show();
|
|
$('#events-select-all').prop('checked', false);
|
|
|
|
var da_ta = $("#custom_filter_search_form").serializeArray();
|
|
if(da_ta.length > 0) {
|
|
var x=0;
|
|
$.map(da_ta, function(val, index){
|
|
if(val.name != "custom_filter_search" && x==0){
|
|
d.keyname = val.name;
|
|
x++;
|
|
}
|
|
d[val.name] = val.value;
|
|
});
|
|
}
|
|
}
|
|
},
|
|
"columns": [
|
|
{
|
|
"className": 'details-control',
|
|
"orderable": false,
|
|
"data": null,
|
|
"defaultContent": ''
|
|
},
|
|
// { "data": "event_order" },
|
|
{ "data": "event_title", render : function(data, type, full, meta){
|
|
return '<span style="font-weight: bold;">'+data !== null ? data : ''+'</span>';
|
|
}},
|
|
{ "data": "event_category", "orderable": true, render : function(data, type, full, meta) {
|
|
return EVENT_CATEGORY[full.event_category];
|
|
}},
|
|
{ "data": "event_type", "orderable": true },
|
|
{ "data": "city", "orderable": true },
|
|
{ "data": "date_created", "orderable": true },
|
|
{ "data": "author", "orderable": true },
|
|
{ "data": "action" , "orderable": false, render : function(data, type, full, meta) {
|
|
var action_btns = "";
|
|
if (authorize(PAGE_CODE['events'], PRIVS[PAGE_CODE['events']]['edit'])) {
|
|
action_btns +=app.grid.create_action_btn(app.get_vars()._app.action._edit, "pencil", "success", "events._edit.modal("+full.action.event_id+", '"+full.action.workshop_session+"')");
|
|
}
|
|
if (authorize(PAGE_CODE['events'], PRIVS[PAGE_CODE['events']]['delete'])) {
|
|
action_btns +=app.grid.create_action_btn(app.get_vars()._app.action._delete, "trash", "danger", "events._delete.confirm("+full.action.event_id+", "+meta.row+")");
|
|
}
|
|
if (authorize(PAGE_CODE['events'], PRIVS[PAGE_CODE['events']]['preview_event'])) {
|
|
action_btns +=app.grid.create_action_btn(app.get_vars()._app.action._openpreview, "eye","info", "events._view.modal("+full.action.event_id+")");
|
|
}
|
|
if (authorize(PAGE_CODE['events'], PRIVS[PAGE_CODE['events']]['sched_export_subs_list_btn'])) {
|
|
if(data.event_schedule.length > 0) {
|
|
action_btns += "<a href='#' data-esid='"+data.event_schedule[0].event_schedule_id+"' data-eid='"+full.action.event_id+"' onclick='events._export(this)'>" + app.grid.create_action_btn(app.get_vars()._app.action._export, "file-excel-o","info", null)+"</a>";
|
|
}
|
|
}
|
|
if (authorize(PAGE_CODE['events'], PRIVS[PAGE_CODE['events']]['sched_email_template_btn']) && full.event_category != 'ONLINE_EVENT') {
|
|
if(data.event_schedule.length > 0) {
|
|
action_btns += app.grid.create_action_btn(app.get_vars()._app.action._email, "envelope", "success", "assign_email_template.email_template_modal("+full.action.event_id+", "+data.event_schedule[0].event_schedule_id+",'schedule')");
|
|
}
|
|
}
|
|
if (authorize(PAGE_CODE['events'], PRIVS[PAGE_CODE['events']]['preview_event'])) {
|
|
action_btns += "<a href='#' disabled onclick='events._view_subscriber.view("+full.action.event_id+")'>" + app.grid.create_action_btn(app.get_vars()._app.action._view_subscriber, "user","info", null)+"</a>";
|
|
}
|
|
if (action_btns) {
|
|
return '<div class="row" align="left;" style="margin: 0px;">'+action_btns+'</div>';
|
|
}
|
|
return '<div class="row">'+'</div>';
|
|
}
|
|
}
|
|
],
|
|
"fnDrawCallback": function() {
|
|
app._tooltip._hide();
|
|
$('#events_list tbody tr td').each( function(x, y) {
|
|
var _this = $(this);
|
|
if(_this.hasClass('truncate-content-text')){
|
|
_this.css('max-width', '190px');
|
|
this.setAttribute( 'title', _this.text());
|
|
this.setAttribute( 'data-toggle',"tooltip");
|
|
}
|
|
});
|
|
|
|
$('#events_list tbody tr').off('click', 'td.details-control').on('click', 'td.details-control',
|
|
function () {
|
|
var tr = $(this).closest('tr');
|
|
var row = table.row( tr );
|
|
if ( !row.child.isShown() ) {
|
|
// Open this row
|
|
row.child( events.showChildEvent(row.data(), row.index())).show();
|
|
tr.addClass('shown');
|
|
app._tooltip._pop();
|
|
}else {
|
|
// This row is already open - close it
|
|
row.child.hide();
|
|
tr.removeClass('shown');
|
|
}
|
|
events._init_expand_all();
|
|
events._init_cstat_all();
|
|
events.toggle_change_stat_button();
|
|
} );
|
|
|
|
$('.paginate_button').on('click', function(){
|
|
$('#collapse_all').hide();
|
|
$('#events-select-all').hide();
|
|
$('#expand_all').show();
|
|
$('#events-select-all').prop('checked', false); // Unchecks it
|
|
});
|
|
|
|
app._tooltip._pop();
|
|
},
|
|
//Set column definition initialisation properties.
|
|
"columnDefs": [
|
|
{ "targets": [7], width: "10px"},
|
|
{ "targets": [6], width: "10px"},
|
|
{ "targets": [2], width: "10px", className : "truncate-content-text custom-popover-tooltip"},
|
|
{ "targets": [3], width: "10px"},
|
|
{ "targets": [4], width: "10px"},
|
|
{ "targets": [5], width: "20px"},
|
|
{ "targets": [1], width: "10px", className : "truncate-content-text custom-popover-tooltip"}
|
|
],
|
|
"initComplete": function(settings, json) {
|
|
//run tooltip
|
|
app._tooltip._hide();
|
|
app._tooltip._pop();
|
|
|
|
$("#events_list_length").css({"float":"left"});
|
|
$("#events_list_length select").css({"width":"6.4rem"});
|
|
|
|
//add custom button beside searchbox
|
|
$('.dataTables_filter').html('').each(function () {
|
|
add_button = '';
|
|
cstat_button = '';
|
|
btns = '';
|
|
if (authorize(PAGE_CODE['events'], PRIVS[PAGE_CODE['events']]['add'])) {
|
|
let datalen = EVENT_CATEGORY.length, i = 0;
|
|
// Add event category in a dropdown
|
|
|
|
if (datalen > 1) {
|
|
for (const [key, value] of Object.entries(EVENT_CATEGORY)) {
|
|
btns += `<li data-event_category='${key}' onclick="events._add.modal('${key}');">
|
|
<a class='' href='#'>${value} <span class='spinner-msg'></span></a></li>`;
|
|
if(i == 0 || (i+1) != datalen){ btns += '<li class="divider"></li>'
|
|
}
|
|
}
|
|
add_button = ` <div class="btn-group dropdown pull-right">
|
|
<button class="btn btn-primary btn-sm" type="button" id="dropdownMenu2" data-toggle="dropdown">
|
|
<i class="fa fa-plus fa-1"></i> ${app.get_vars().events.btn.add_event}
|
|
</button>
|
|
<button type="button" class="btn btn-primary dropdown-toggle btn-sm" data-toggle="dropdown">
|
|
<span class="caret"></span>
|
|
<span class="sr-only">Toggle Dropdown</span>
|
|
</button>
|
|
<ul class ="dropdown-menu" id="event_category" role="menu">
|
|
<li><a class="" href="#"><p><i class="fa fa-spin fa-spinner"></i> Loading...</p></a></li>
|
|
</ul>
|
|
</div>`;
|
|
} else {
|
|
add_button =`
|
|
<div class="dropdown inline-block">
|
|
<button class="btn btn-primary btn-sm dropdown-toggle" type="button" data-toggle="dropdown" id="mc-event-type">${app.get_vars().events.btn.add_event}
|
|
<span class="caret"></span>
|
|
</button>
|
|
<div class="custom-dropdown event-type-select d-none">
|
|
<div class="dropdown-submenu">
|
|
<button class="btn-submenu" id="btn-submenu-1" data-toggle="collapse" data-target="#atelier-presentiel-type" aria-expanded="false" aria-controls="atelier-presentiel-type">
|
|
<i class="fa fa-tasks"></i>
|
|
<span class="btn-label">Atelier</span>
|
|
<span class="caret"></span>
|
|
</button>
|
|
<div class="collapse atelier-type" id="atelier-presentiel-type">
|
|
<div>
|
|
<button data-event_category='REGULAR_EVENT' onclick="events._add.modal('REGULAR_EVENT','PRESENTIEL')">
|
|
<i class="fa fa-users"></i>
|
|
<span class="btn-label">Atelier Présentiel</span>
|
|
</button>
|
|
</div>
|
|
<div>
|
|
<button data-event_category='REGULAR_EVENT' onclick="events._add.modal('REGULAR_EVENT','DISTANCIEL')">
|
|
<i class="fa fa-desktop"></i>
|
|
<span class="btn-label">Atelier Distanciel</span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<button data-event_category='REGULAR_EVENT' onclick="events._add.modal('REGULAR_EVENT', 'ENLIGNE')">
|
|
<i class="fa fa-toggle-right"></i>
|
|
<span class="btn-label">Cours en ligne</span>
|
|
</button>
|
|
</div>
|
|
<div class="dropdown-submenu">
|
|
<button class="btn-submenu" id="btn-submenu-3" data-toggle="collapse" data-target="#soir-type" aria-expanded="false" aria-controls="soir-type">
|
|
<i class="fa fa-tasks"></i>
|
|
<span class="btn-label">Cours du soir</span>
|
|
<span class="caret"></span>
|
|
</button>
|
|
<div class="collapse atelier-type" id="soir-type">
|
|
<div>
|
|
<button data-event_category='REGULAR_EVENT' onclick="events._add.modal('REGULAR_EVENT','DISTANCE-PRESENTIEL')">
|
|
<i class="fa fa-users"></i>
|
|
<span class="btn-label">Atelier à Distance + Presentiel</span>
|
|
</button>
|
|
</div>
|
|
<div>
|
|
<button data-event_category='REGULAR_EVENT' onclick="events._add.modal('REGULAR_EVENT','DISTANCE')">
|
|
<i class="fa fa-desktop"></i>
|
|
<span class="btn-label">Atelier à Distance</span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>`;
|
|
}
|
|
}
|
|
if (authorize(PAGE_CODE['events'], PRIVS[PAGE_CODE['events']]['global_change_stat'])) {
|
|
cstat_button = '<button disabled id="toggle_change_stat_form" class="btn btn-primary btn-sm mr-xs add"><span class="glyphicon glyphicon-check"></span> Changer le statut</button>';
|
|
}
|
|
|
|
$(this).html('<div class="col-sm-6 col-xs-3 col-md-4 col-lg-4 search text-left">' +
|
|
'<form class="form-inline" role="form" name="custom_filter_search_form" id="custom_filter_search_form" action="javascript:;">'+
|
|
events._grid.create_custom_filter() +
|
|
'</form></div><div class="">' + cstat_button + add_button + '</div>');
|
|
|
|
$('#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('')
|
|
// $('<button type="submit" id="toggle_change_stat_form" class="btn btn-primary btn-sm mr-xs add"><span class="glyphicon glyphicon-check"></span> changer le statut</button>').insertAfter('div.search');
|
|
// add the change status form
|
|
|
|
form = '<div class="row"><div class="col-sm-12 col-xs-12 col-md-12 col-lg-12">'+
|
|
'<form role="form" class="change_status_form " id="change_status_form" action="javascript:;">' +
|
|
// '<div class="">'+
|
|
'<select class="form-control mr-xs add input-sm" id="back_office_status_all" name="back_office_status_all">'+
|
|
'<option value="0">En cours de création</option>'+
|
|
'<option value="1">Publié</option>'+
|
|
'<option value="2">Ouvert</option>'+
|
|
'<option value="3">Verrouillé</option>'+
|
|
'<option value="4">Fermé</option>'+
|
|
'<option value="5">Archivé</option>'+
|
|
'<option value="7">Terminé</option>'+
|
|
'</select>'+
|
|
// '</div>'+
|
|
'</form>'
|
|
+'</div></div>';
|
|
|
|
$('#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: '<i class="fa fa-times"></i> Annuler'
|
|
},
|
|
confirm: {
|
|
label: '<i class="fa fa-check"></i> 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('.<br />');
|
|
// app._notify("success", "You can change the status of the following: "+alL_status_ids_str);
|
|
if (alL_confmsgs) {
|
|
alL_confmsgs = alL_confmsgs + '.<br />';
|
|
}
|
|
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: '<i class="fa fa-times"></i> Annuler'
|
|
},
|
|
confirm: {
|
|
label: '<i class="fa fa-check"></i> 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 '<select onchange="events._grid.filter_by(this);" name="custom_filter_search" class="form-control input-sm" aria-controls="events_list">' +
|
|
'<option value="all">'+app.get_vars().events._filter.all+'</option>' +
|
|
'<option value="title">'+app.get_vars().events._filter.event_title+'</option>' +
|
|
'<option value="start_date_time">'+app.get_vars().events._filter.month_year+'</option>' +
|
|
'<option value="event_type_id">'+app.get_vars().events._filter.event_type+'</option>' +
|
|
'<option value="city_location">'+app.get_vars().events._filter.event_location+'</option>' +
|
|
'<option value="back_office_status">'+app.get_vars().events._filter.bo_status+'</option>' +
|
|
'<option value="event_status">'+app.get_vars().events._filter.event_status+'</option>' +
|
|
'<option value="workshop_session">'+app.get_vars().events._filter.workshop_session+'</option>' +
|
|
((Object.entries(EVENT_CATEGORY) > 1) ? '<option value="event_category">'+app.get_vars().events._filter.event_category+'</option>' : '') +
|
|
'</select>' +
|
|
'<span id="custom_search_filter"><input type="search" class="form-control input-sm" ' +
|
|
'placeholder="'+app.get_vars().events._filter.research+'" aria-controls="events_list"></span>' +
|
|
'</select>';
|
|
},
|
|
|
|
filter_by : function(obj){
|
|
var table = $('#events_list').DataTable();
|
|
|
|
switch($(obj).val()){
|
|
case "title" :
|
|
$("#custom_search_filter").html('<input type="search" class="form-control input-sm" placeholder="'+app.get_vars().events._filter.event_title+'" ' +
|
|
'aria-controls="events_list" value="">');
|
|
break;
|
|
|
|
case "start_date_time" :
|
|
$("#custom_search_filter").html('<input value="" type="search" onmousedown="events._grid.bind_date_picker(this);" ' +
|
|
'class="form-control input-sm" placeholder="'+app.get_vars().events._filter.month_year+' (MM/YYYY)" aria-controls="events_list">');
|
|
break;
|
|
|
|
case "event_type_id" :
|
|
var d = $("#event_type_id").clone();
|
|
d.find("option:eq(0)").remove();
|
|
d.prepend("<option value=''>"+app.get_vars().events._filter.all+"</option>");
|
|
$("#custom_search_filter").html('<select onchange="(events.get_vars()._events).draw();" name="filter_by_event_type_id" ' +
|
|
'class="form-control input-sm" aria-controls="events_list">'+d.html()+
|
|
'</select><input type="search" value="" class="form-control input-sm" placeholder="'+app.get_vars().events._filter.event_title+'" ' +
|
|
'aria-controls="events_list">');
|
|
break;
|
|
|
|
case "city_location" :
|
|
var d = $("#city_location").clone();
|
|
d.find("option:eq(0)").remove();
|
|
d.prepend("<option value=''>"+app.get_vars().events._filter.all+"</option>");
|
|
$("#custom_search_filter").html('<select onchange="(events.get_vars()._events).draw();" name="filter_by_city_location_id" ' +
|
|
'class="form-control input-sm" aria-controls="events_list">'+d.html()+
|
|
'</select><input type="search" value="" class="form-control input-sm" placeholder="'+app.get_vars().events._filter.event_title+'" ' +
|
|
'aria-controls="events_list">');
|
|
break;
|
|
|
|
case "back_office_status" :
|
|
var d = $("#back_office_status").clone();
|
|
d.find("option:eq(0)").remove();
|
|
d.prepend("<option value=''>"+app.get_vars().events._filter.all+"</option>");
|
|
$("#custom_search_filter").html('<select onchange="(events.get_vars()._events).draw();" name="filter_by_back_office_status" ' +
|
|
'class="form-control input-sm" aria-controls="events_list">'+d.html()+
|
|
'</select><input type="search" value="" class="form-control input-sm" placeholder="'+app.get_vars().events._filter.event_title+'" ' +
|
|
'aria-controls="events_list">');
|
|
break;
|
|
|
|
case "event_status" :
|
|
var d = $("#event_status").clone();
|
|
d.find("option:eq(0)").remove();
|
|
d.prepend("<option value=''>"+app.get_vars().events._filter.all+"</option>");
|
|
$("#custom_search_filter").html('<select onchange="(events.get_vars()._events).draw();" name="filter_by_event_status" ' +
|
|
'class="form-control input-sm" aria-controls="events_list">'+d.html()+
|
|
'</select><input type="search" value="" class="form-control input-sm" placeholder="'+app.get_vars().events._filter.event_title+'" ' +
|
|
'aria-controls="events_list">');
|
|
break;
|
|
|
|
case "event_category" :
|
|
var options = `<option value=''>${app.get_vars().events._filter.all}</option>`;
|
|
for (const [key, value] of Object.entries(EVENT_CATEGORY)) {
|
|
options += `<option value='${key.toUpperCase()}'>${value}</option>`;
|
|
}
|
|
$("#custom_search_filter").html('<select onchange="(events.get_vars()._events).draw();" name="filter_by_event_category" ' +
|
|
'class="form-control input-sm" aria-controls="events_list">'+options+
|
|
'</select><input type="search" value="" class="form-control input-sm" placeholder="'+app.get_vars().events._filter.event_title+'" ' +
|
|
'aria-controls="events_list">');
|
|
break;
|
|
case "workshop_session" :
|
|
var options = `<option value=''>${app.get_vars().events._filter.all}</option>`+
|
|
'<option value="PRESENTIEL">Atelier Présentiel</option><option value="DISTANCIEL">Atelier Distanciel</option><option value="ENLIGNE">Atelier Cours en ligne</option><option value="DISTANCE-PRESENTIEL">Atelier à Distance + Presentiel</option><option value="DISTANCE">Atelier à Distance</option>'
|
|
$("#custom_search_filter").html('<select onchange="(events.get_vars()._events).draw();" name="filter_by_workshop_type" ' +
|
|
'class="form-control input-sm" aria-controls="events_list">'+options+
|
|
'</select><input type="search" value="" class="form-control input-sm" placeholder="'+app.get_vars().events._filter.workshop_session+'" ' +
|
|
'aria-controls="events_list">');
|
|
break;
|
|
|
|
default :
|
|
$("#custom_search_filter").html('<input value="" type="search" class="form-control input-sm" placeholder="'+app.get_vars().events._filter.research+'" ' +
|
|
'aria-controls="events_list">');
|
|
(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<table.rows.length;i++) {
|
|
const trs = table.getElementsByTagName("tr")[i];
|
|
const startDate=trs.cells[0]
|
|
const endDate=trs.cells[1]
|
|
const startInput = startDate.getElementsByTagName('input')[0]
|
|
const endInput = endDate.getElementsByTagName('input')[0]
|
|
sessions_dates.push({
|
|
'start_date_time': app._form.format_inputs('datetime',$('#'+startInput.id).val()),
|
|
'end_date_time': app._form.format_inputs('datetime',$('#'+endInput.id).val())
|
|
})
|
|
}
|
|
return sessions_dates
|
|
},
|
|
"formatAuthorAwards": function () {
|
|
let awards = []
|
|
const table=document.getElementById("tbody_award");
|
|
for(let i=0;i<table.rows.length;i++) {
|
|
const trs = table.getElementsByTagName("tr")[i];
|
|
const award=trs.cells[0]
|
|
const awardInput = award.getElementsByTagName('input')[0]
|
|
awards.push($('#'+awardInput.id).val())
|
|
}
|
|
return awards
|
|
},
|
|
"formatAuthorWorks": function () {
|
|
let works = []
|
|
const table=document.getElementById("tbody_works");
|
|
for(let i=0;i<table.rows.length;i++) {
|
|
const trs = table.getElementsByTagName("tr")[i];
|
|
const work=trs.cells[0]
|
|
const image=trs.cells[1]
|
|
const link=trs.cells[2]
|
|
const id=trs.cells[4]
|
|
const workInput = work.getElementsByTagName('input')[0]
|
|
const imageInput = image.getElementsByTagName('input')[0]
|
|
const linkInput = link.getElementsByTagName('input')[0]
|
|
const idInput = id.getElementsByTagName('input')[0]
|
|
const idArry = imageInput.id.split("-");
|
|
works.push({
|
|
'work': $('#'+workInput.id).val(),
|
|
'image': $('#image-work-'+idArry[1]).attr('src'),
|
|
'link': $('#'+linkInput.id).val(),
|
|
'id': $('#'+idInput.id).val()
|
|
})
|
|
}
|
|
return works
|
|
},
|
|
"formatVenuePhotos": function () {
|
|
let photos = []
|
|
const table=document.getElementById("tbody_venue_img");
|
|
for(let i=0;i<table.rows.length;i++) {
|
|
const trs = table.getElementsByTagName("tr")[i];
|
|
const photo=trs.cells[0]
|
|
const photoId=trs.cells[2]
|
|
const photoInput = photo.getElementsByTagName('input')[0]
|
|
const idInput = photoId.getElementsByTagName('input')[0]
|
|
const idArry = photoInput.id.split("-");
|
|
if($('#image-venue-'+idArry[1]).attr('src') != '') {
|
|
photos.push({
|
|
'photo': $('#image-venue-'+idArry[1]).attr('src'),
|
|
'id': $('#'+idInput.id).val()
|
|
})
|
|
}
|
|
}
|
|
return photos
|
|
},
|
|
"getBase64Image": async function (imageInput, imageId, tbInput) {
|
|
let image=''
|
|
if (imageInput.files && imageInput.files[0]) {
|
|
var reader = new FileReader();
|
|
reader.onload = function (e) {
|
|
image = e.target.result;
|
|
if(image.indexOf("data:image") >=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 += '<tr><td>'+( i + 1)+'</td><td>'+app.get_vars().set_preferences[res[i].name]+'</td><td>'+res[i].type.toUpperCase()+'</td><td><input value='+res[i].id+' name="req" type="checkbox" '+req+' /></td></tr>';
|
|
};
|
|
registration_form_list.append(cnt);
|
|
}
|
|
});
|
|
},
|
|
banner_load_box_cropper : function()
|
|
{
|
|
|
|
$uploadCrop = container.croppie({
|
|
viewport: {
|
|
// width: 750,
|
|
// height: 180,
|
|
width: 800,
|
|
height: 270,
|
|
type: 'square'
|
|
},
|
|
showZoomer: true
|
|
// enableResize: true,
|
|
//enableOrientation: true
|
|
,
|
|
boundary: {
|
|
// width: 800,
|
|
// height: 220,
|
|
width: 850,
|
|
height: 330,
|
|
}
|
|
});
|
|
|
|
upload.on('change', function () { personalization.banner_readFile(this); });
|
|
container.on('click', function(){
|
|
$uploadCrop.croppie('result', {
|
|
type: 'canvas',
|
|
size: 'original',
|
|
format : 'jpg'
|
|
}).then(function (resp) {
|
|
$('#imagebase64').val(resp)})
|
|
})
|
|
// upload_result.on('click', function (ev) {
|
|
// var dialog = bootbox.dialog({
|
|
// message: '<p class="text-center"><i class="fa fa-spin fa-spinner"/>'+app.get_vars()._app.notif.loading+'</p>',
|
|
// closeButton: false
|
|
// });
|
|
|
|
// if( $(".cr-image").attr('src') == undefined || $(".cr-image").attr('src') == "")
|
|
// {
|
|
// var formData1 = new FormData( $("#eventForm")[0] );
|
|
// formData1.append('description', tinyMCE.activeEditor.getContent({format : 'raw'}) )
|
|
// $.ajax({
|
|
// url: app.get_vars().baseurl+"personalize/upload_description",
|
|
// type : 'POST',
|
|
// data : formData1,
|
|
// async : false,
|
|
// cache : false,
|
|
// contentType : false,
|
|
// processData : false,
|
|
// success: function(res) {
|
|
// $('#uploadBannerModal').modal('hide');
|
|
// $(".cr-image").attr('src','');
|
|
// $("textarea#description").val('');
|
|
// dialog.modal('hide')
|
|
// location.reload();
|
|
// }
|
|
// });
|
|
// }
|
|
// else
|
|
// {
|
|
// $uploadCrop.croppie('result', {
|
|
// type: 'canvas',
|
|
// size: 'original',
|
|
// format : 'jpg'
|
|
// }).then(function (resp) {
|
|
// $('#imagebase64').val(resp);
|
|
// if (typeof FormData !== 'undefined') {
|
|
// var formData2 = new FormData( $("#form_banner")[0] );
|
|
// //formData2.append('description', tinyMCE.activeEditor.getContent({format : 'raw'}) )
|
|
// // if( document.getElementById("upload").value != "" )
|
|
// // {
|
|
// // $.ajax({
|
|
// // url : app.get_vars().baseurl+"personalize/upload_banner",
|
|
// // type : 'POST',
|
|
// // data : formData2,
|
|
// // async : false,
|
|
// // cache : false,
|
|
// // contentType : false,
|
|
// // processData : false,
|
|
// // success: function( data, textStatus, jQxhr )
|
|
// // {
|
|
// // $('#image_banner').attr('src', app.get_vars().baseurl+''+banner_folder+''+data['banner']);
|
|
// // $('#image_label').html(data['description']);
|
|
// // $('#uploadBannerModal').modal('hide');
|
|
// // $(".cr-image").attr('src','');
|
|
// // $("textarea#description").val('');
|
|
// // location.reload();
|
|
// // dialog.modal('hide')
|
|
// // },
|
|
// // error: function( jqXhr, textStatus, errorThrown )
|
|
// // {
|
|
// // console.log( errorThrown );
|
|
// // dialog.modal('hide')
|
|
// // }
|
|
// // });
|
|
// // }
|
|
// }
|
|
// });
|
|
// }
|
|
|
|
// });
|
|
},
|
|
banner_readFile : function(input)
|
|
{
|
|
if (input.files && input.files[0]) {
|
|
var reader = new FileReader();
|
|
reader.onload = function (e) {
|
|
$uploadCrop.croppie('bind', {
|
|
url: e.target.result
|
|
});
|
|
$('#imagebase64').val(e.target.result);
|
|
//$('.upload-go').addClass('ready');
|
|
}
|
|
reader.readAsDataURL(input.files[0]);
|
|
}
|
|
},
|
|
banner_get_image : function(type)
|
|
{
|
|
var banner = $('#image_banner');
|
|
var label = $('#image_label');
|
|
var container_image = $('#container-image');
|
|
var upload_btn = $('#upload');
|
|
|
|
// container_image.click(function(){
|
|
// upload_btn.trigger('click');
|
|
// })
|
|
|
|
$.ajax({
|
|
url: app.get_vars().baseurl+"personalize/get_banner",
|
|
type: 'POST',
|
|
dataType: "json",
|
|
success: function(res) {
|
|
// if( res['image'] !== undefined )
|
|
banner.attr('src', res['image'])
|
|
// else
|
|
// banner.attr('src', app.get_vars().baseurl+'resources/images/frontoffice/homepage/caroussel.png')
|
|
// if( res['description'] !== undefined && res['description'] !== "" )
|
|
label.html(res['description']);
|
|
if(!type){
|
|
tinymce.get('description').setContent( res['description'] )
|
|
}
|
|
// else
|
|
// label.html( "<p> En remerciement de votre fidélité, <em>Company For Madagascar</em> vous propose d'assister gratuitement aux spectacles et événements ci-dessous. </p>" +
|
|
// "<p> Réservez vos places en vous connectant au moyen de vos identifiants <em>LeMonde.fr</em> </p>" );
|
|
|
|
|
|
}
|
|
});
|
|
},
|
|
tinymce_mentios_legales : function(element,height)
|
|
{
|
|
|
|
tinymce.init({
|
|
code_dialog_height: 500,
|
|
force_hex_style_colors : true,
|
|
//force_p_newlines : true,
|
|
//invalid_elements : "id",
|
|
//forced_root_block : false,
|
|
force_br_newlines : true,
|
|
force_p_newlines : false,
|
|
forced_root_block : '', // Needed for 3.x
|
|
selector: element,
|
|
language: 'fr_FR',
|
|
height: height,
|
|
menubar: false,
|
|
plugins: [
|
|
'advlist autolink lists link image charmap print preview anchor',
|
|
'searchreplace visualblocks code fullscreen',
|
|
'insertdatetime media table contextmenu paste code',
|
|
'anchor code',
|
|
'textcolor colorpicker',
|
|
],
|
|
toolbar: 'code | anchor | undo redo | insert | styleselect | bold italic | fontselect | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
|
|
font_formats: 'Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;AkrutiKndPadmini=Akpdmi-n',
|
|
content_css: [
|
|
'//fonts.googleapis.com/css?family=Lato:300,300i,400,400i',
|
|
'//www.tinymce.com/css/codepen.min.css']
|
|
});
|
|
},
|
|
tinymce_mentios_legales_set_content : function()
|
|
{
|
|
|
|
var status , description;
|
|
var status_mentios_legales = $("#status_mentios_legales");
|
|
|
|
$.ajax({
|
|
url: app.get_vars().baseurl+"personalization/append_mentions_legales",
|
|
type: 'GET',
|
|
dataType: 'json',
|
|
success: function(res) {
|
|
status = res.status;
|
|
description = res.description;
|
|
|
|
status_mentios_legales.val(status);
|
|
//tinymce.activeEditor.setContent(description);
|
|
tinymce.get('tinymce_mentios_legales').setContent(description)
|
|
}
|
|
});
|
|
},
|
|
tinymce_mentios_legales_update_content : function()
|
|
{
|
|
var update_button = $("#update_mentions_legales");
|
|
|
|
update_button.on('click', function () {
|
|
var description = tinyMCE.activeEditor.getContent({format : 'raw'}) ;
|
|
var update_button = $("#update_mentions_legales");
|
|
//var description = tinymce.get('tinymce_mentios_legales').getContent() ;
|
|
var status = $("#status_mentios_legales").val();
|
|
var json = {'description':description, 'status':status};
|
|
|
|
|
|
$.ajax({
|
|
url: app.get_vars().baseurl+"personalization/update_mentions_legales",
|
|
type: 'POST',
|
|
data : json,
|
|
success: function(result) {
|
|
app._notify(result.mtype, result.message);
|
|
}
|
|
});
|
|
});
|
|
},
|
|
/**
|
|
* Terms and Privacy
|
|
*/
|
|
tinymce_privacy : function(element,height)
|
|
{
|
|
tinymce.init({
|
|
code_dialog_height: 500,
|
|
force_hex_style_colors : true,
|
|
force_br_newlines : true,
|
|
force_p_newlines : false,
|
|
forced_root_block : '', // Needed for 3.x
|
|
selector: element,
|
|
language: 'fr_FR',
|
|
height: height,
|
|
menubar: false,
|
|
plugins: [
|
|
'advlist autolink lists link image charmap print preview anchor',
|
|
'searchreplace visualblocks code fullscreen',
|
|
'insertdatetime media table contextmenu paste code',
|
|
'anchor code',
|
|
'textcolor colorpicker',
|
|
],
|
|
toolbar: 'code | anchor | undo redo | insert | styleselect | bold italic | fontselect | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
|
|
font_formats: 'Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;AkrutiKndPadmini=Akpdmi-n',
|
|
content_css: [
|
|
'//fonts.googleapis.com/css?family=Lato:300,300i,400,400i',
|
|
'//www.tinymce.com/css/codepen.min.css']
|
|
});
|
|
},
|
|
tinymce_privacy_set_content : function()
|
|
{
|
|
|
|
var status , description;
|
|
var status_privacy = $("#status_privacy");
|
|
console.log(app.get_vars().baseurl+"personalization/append_privacy");
|
|
$.ajax({
|
|
url: app.get_vars().baseurl+"personalization/append_privacy",
|
|
type: 'GET',
|
|
dataType: 'json',
|
|
success: function(res) {
|
|
status = res.status;
|
|
description = res.description;
|
|
status_privacy.val(status);
|
|
// tinyMCE.activeEditor.setContent('');
|
|
// tinymce.get('tinymce_privacy').setContent(description)
|
|
tinymce.init({
|
|
selector:'#tinymce_privacy',
|
|
code_dialog_height: 500,
|
|
force_hex_style_colors : true,
|
|
force_br_newlines : true,
|
|
force_p_newlines : false,
|
|
forced_root_block : '', // Needed for 3.x
|
|
language: 'fr_FR',
|
|
height: 500,
|
|
menubar: false,
|
|
plugins: [
|
|
'advlist autolink lists link image charmap print preview anchor',
|
|
'searchreplace visualblocks code fullscreen',
|
|
'insertdatetime media table contextmenu paste code',
|
|
'anchor code',
|
|
'textcolor colorpicker',
|
|
],
|
|
toolbar: 'code | anchor | undo redo | insert | styleselect | bold italic | fontselect | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
|
|
font_formats: 'Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;AkrutiKndPadmini=Akpdmi-n',
|
|
content_css: [
|
|
'//fonts.googleapis.com/css?family=Lato:300,300i,400,400i',
|
|
'//www.tinymce.com/css/codepen.min.css'],
|
|
init_instance_callback : function(editor) {
|
|
editor.setContent(description);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
},
|
|
/** end */
|
|
|
|
event_logo_load : function(){
|
|
var logo_prev = $('#logo_prev');
|
|
var input_choose = $('[name="logo"]');
|
|
var form_logo = $('#form_logo');
|
|
var append_logo = $("img#prev_logo");
|
|
|
|
|
|
logo_prev.imagepreview({
|
|
input: '[name="logo"]',
|
|
// reset: '#reset1',
|
|
preview: '#logo_prev'
|
|
});
|
|
input_choose.on('change', function () {
|
|
var formData = new FormData( $('#form_logo')[0] );
|
|
|
|
$.ajax({
|
|
url : app.get_vars().baseurl+"personalize/upload_logo",
|
|
type : 'POST',
|
|
data : formData,
|
|
async : false,
|
|
cache : false,
|
|
contentType : false,
|
|
processData : false,
|
|
success: function( result, textStatus, jQxhr )
|
|
{
|
|
|
|
append_logo.attr('src' , result.image)
|
|
app._notify(result.mtype, result.message);
|
|
form_logo.trigger('reset');
|
|
|
|
if( result.mtype == "error")
|
|
logo_prev.hide()
|
|
},
|
|
error: function( jqXhr, textStatus, errorThrown )
|
|
{
|
|
console.log( errorThrown );
|
|
}
|
|
});
|
|
});
|
|
|
|
$.ajax({
|
|
url: app.get_vars().baseurl+"personalize/upload_get_logo",
|
|
type: 'GET',
|
|
success: function(result) {
|
|
console.log(result);
|
|
if( result.length ){
|
|
logo_prev.show();
|
|
append_logo.attr('src' , result)
|
|
}
|
|
}
|
|
});
|
|
},
|
|
announcement_content: function (element, height) {
|
|
function image_upload_handler (blobInfo, success, failure, progress) {
|
|
var xhr, formData;
|
|
xhr = new XMLHttpRequest();
|
|
xhr.withCredentials = false;
|
|
xhr.open('POST', app.get_vars().baseurl + "personalization/post_acceptor", true);
|
|
|
|
xhr.upload.onprogress = function (e) {
|
|
progress(e.loaded / e.total * 100);
|
|
};
|
|
|
|
xhr.onload = function() {
|
|
var json;
|
|
|
|
if (xhr.status === 403) {
|
|
failure('HTTP Error: ' + xhr.status, { remove: true });
|
|
return;
|
|
}
|
|
|
|
if (xhr.status < 200 || xhr.status >= 300) {
|
|
failure('HTTP Error: ' + xhr.status);
|
|
return;
|
|
}
|
|
|
|
json = JSON.parse(xhr.responseText);
|
|
|
|
if (!json || typeof json.location != 'string') {
|
|
failure('Invalid JSON: ' + xhr.responseText);
|
|
return;
|
|
}
|
|
|
|
success(json.location);
|
|
};
|
|
|
|
xhr.onerror = function () {
|
|
failure('Image upload failed due to a XHR Transport error. Code: ' + xhr.status);
|
|
};
|
|
|
|
formData = new FormData();
|
|
formData.append('file', blobInfo.blob(), blobInfo.filename());
|
|
|
|
// append CSRF token in the form data
|
|
formData.append('csrf_token', $('meta[name="csrf_token"]').attr('content'));
|
|
|
|
|
|
|
|
xhr.send(formData);
|
|
};
|
|
tinymce.init({
|
|
selector:element,
|
|
code_dialog_height: 500,
|
|
force_hex_style_colors: true,
|
|
//force_p_newlines : true,
|
|
//invalid_elements : "id",
|
|
//forced_root_block : false,
|
|
force_br_newlines: true,
|
|
force_p_newlines: false,
|
|
forced_root_block: '', // Needed for 3.x
|
|
language: 'fr_FR',
|
|
height: height,
|
|
menubar: false,
|
|
plugins: [
|
|
'advlist autolink lists link image charmap print preview anchor',
|
|
'searchreplace visualblocks code fullscreen',
|
|
'insertdatetime media table contextmenu paste code',
|
|
'anchor code',
|
|
'textcolor colorpicker',
|
|
],
|
|
a11y_advanced_options: true,
|
|
|
|
convert_urls : false,
|
|
relative_urls: false,
|
|
remove_script_host: false,
|
|
paste_data_images: true,
|
|
|
|
/* enable title field in the Image dialog*/
|
|
image_title: true,
|
|
/* enable automatic uploads of images represented by blob or data URIs*/
|
|
automatic_uploads: true,
|
|
// images_upload_url: app.get_vars().baseurl + "personalization/post_acceptor",
|
|
images_upload_handler: image_upload_handler,
|
|
/*
|
|
URL of our upload handler (for more details check: https://www.tiny.cloud/docs/configure/file-image-upload/#images_upload_url)
|
|
images_upload_url: 'postAcceptor.php',
|
|
here we add custom filepicker only to Image dialog
|
|
*/
|
|
file_picker_types: 'image',
|
|
/* and here's our custom image picker*/
|
|
file_picker_callback: function (cb, value, meta) {
|
|
var input = document.createElement('input');
|
|
input.setAttribute('type', 'file');
|
|
input.setAttribute('accept', 'image/*');
|
|
|
|
/*
|
|
Note: In modern browsers input[type="file"] is functional without
|
|
even adding it to the DOM, but that might not be the case in some older
|
|
or quirky browsers like IE, so you might want to add it to the DOM
|
|
just in case, and visually hide it. And do not forget do remove it
|
|
once you do not need it anymore.
|
|
*/
|
|
|
|
input.onchange = function () {
|
|
var file = this.files[0];
|
|
|
|
var reader = new FileReader();
|
|
reader.onload = function () {
|
|
/*
|
|
Note: Now we need to register the blob in TinyMCEs image blob
|
|
registry. In the next release this part hopefully won't be
|
|
necessary, as we are looking to handle it internally.
|
|
*/
|
|
var id = 'blobid' + (new Date()).getTime();
|
|
var blobCache = tinymce.activeEditor.editorUpload.blobCache;
|
|
var base64 = reader.result.split(',')[1];
|
|
var blobInfo = blobCache.create(id, file, base64);
|
|
blobCache.add(blobInfo);
|
|
|
|
/* call the callback and populate the Title field with the file name */
|
|
cb(blobInfo.blobUri(), { title: file.name });
|
|
};
|
|
reader.readAsDataURL(file);
|
|
};
|
|
|
|
input.click();
|
|
},
|
|
toolbar: 'code | anchor | undo redo | insert | styleselect | bold italic | fontselect | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
|
|
font_formats: 'Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;AkrutiKndPadmini=Akpdmi-n',
|
|
content_css: [
|
|
'//fonts.googleapis.com/css?family=Lato:300,300i,400,400i',
|
|
'//www.tinymce.com/css/codepen.min.css']
|
|
});
|
|
|
|
},
|
|
announcement_content_edit: function (element, height) {
|
|
function image_upload_handler (blobInfo, success, failure, progress) {
|
|
var xhr, formData;
|
|
xhr = new XMLHttpRequest();
|
|
xhr.withCredentials = false;
|
|
xhr.open('POST', app.get_vars().baseurl + "personalization/post_acceptor", true);
|
|
|
|
xhr.upload.onprogress = function (e) {
|
|
progress(e.loaded / e.total * 100);
|
|
};
|
|
|
|
xhr.onload = function() {
|
|
var json;
|
|
|
|
if (xhr.status === 403) {
|
|
failure('HTTP Error: ' + xhr.status, { remove: true });
|
|
return;
|
|
}
|
|
|
|
if (xhr.status < 200 || xhr.status >= 300) {
|
|
failure('HTTP Error: ' + xhr.status);
|
|
return;
|
|
}
|
|
|
|
json = JSON.parse(xhr.responseText);
|
|
|
|
if (!json || typeof json.location != 'string') {
|
|
failure('Invalid JSON: ' + xhr.responseText);
|
|
return;
|
|
}
|
|
|
|
success(json.location);
|
|
};
|
|
|
|
xhr.onerror = function () {
|
|
failure('Image upload failed due to a XHR Transport error. Code: ' + xhr.status);
|
|
};
|
|
|
|
formData = new FormData();
|
|
formData.append('file', blobInfo.blob(), blobInfo.filename());
|
|
|
|
// append CSRF token in the form data
|
|
formData.append('csrf_token', $('meta[name="csrf_token"]').attr('content'));
|
|
|
|
|
|
|
|
xhr.send(formData);
|
|
};
|
|
tinymce.init({
|
|
selector:element,
|
|
code_dialog_height: 500,
|
|
force_hex_style_colors: true,
|
|
//force_p_newlines : true,
|
|
//invalid_elements : "id",
|
|
//forced_root_block : false,
|
|
force_br_newlines: true,
|
|
force_p_newlines: false,
|
|
forced_root_block: '', // Needed for 3.x
|
|
language: 'fr_FR',
|
|
height: height,
|
|
menubar: false,
|
|
plugins: [
|
|
'advlist autolink lists link image charmap print preview anchor',
|
|
'searchreplace visualblocks code fullscreen',
|
|
'insertdatetime media table contextmenu paste code',
|
|
'anchor code',
|
|
'textcolor colorpicker',
|
|
],
|
|
a11y_advanced_options: true,
|
|
|
|
convert_urls : false,
|
|
relative_urls: false,
|
|
remove_script_host: false,
|
|
paste_data_images: true,
|
|
|
|
/* enable title field in the Image dialog*/
|
|
image_title: true,
|
|
/* enable automatic uploads of images represented by blob or data URIs*/
|
|
automatic_uploads: true,
|
|
// images_upload_url: app.get_vars().baseurl + "personalization/post_acceptor",
|
|
images_upload_handler: image_upload_handler,
|
|
/*
|
|
URL of our upload handler (for more details check: https://www.tiny.cloud/docs/configure/file-image-upload/#images_upload_url)
|
|
images_upload_url: 'postAcceptor.php',
|
|
here we add custom filepicker only to Image dialog
|
|
*/
|
|
file_picker_types: 'image',
|
|
/* and here's our custom image picker*/
|
|
file_picker_callback: function (cb, value, meta) {
|
|
var input = document.createElement('input');
|
|
input.setAttribute('type', 'file');
|
|
input.setAttribute('accept', 'image/*');
|
|
|
|
/*
|
|
Note: In modern browsers input[type="file"] is functional without
|
|
even adding it to the DOM, but that might not be the case in some older
|
|
or quirky browsers like IE, so you might want to add it to the DOM
|
|
just in case, and visually hide it. And do not forget do remove it
|
|
once you do not need it anymore.
|
|
*/
|
|
|
|
input.onchange = function () {
|
|
var file = this.files[0];
|
|
|
|
var reader = new FileReader();
|
|
reader.onload = function () {
|
|
/*
|
|
Note: Now we need to register the blob in TinyMCEs image blob
|
|
registry. In the next release this part hopefully won't be
|
|
necessary, as we are looking to handle it internally.
|
|
*/
|
|
var id = 'blobid' + (new Date()).getTime();
|
|
var blobCache = tinymce.activeEditor.editorUpload.blobCache;
|
|
var base64 = reader.result.split(',')[1];
|
|
var blobInfo = blobCache.create(id, file, base64);
|
|
blobCache.add(blobInfo);
|
|
|
|
/* call the callback and populate the Title field with the file name */
|
|
cb(blobInfo.blobUri(), { title: file.name });
|
|
};
|
|
reader.readAsDataURL(file);
|
|
};
|
|
|
|
input.click();
|
|
},
|
|
toolbar: 'code | anchor | undo redo | insert | styleselect | bold italic | fontselect | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
|
|
font_formats: 'Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;AkrutiKndPadmini=Akpdmi-n',
|
|
content_css: [
|
|
'//fonts.googleapis.com/css?family=Lato:300,300i,400,400i',
|
|
'//www.tinymce.com/css/codepen.min.css']
|
|
});
|
|
|
|
// Prevent bootstrap dialog from blocking focusin
|
|
$(document).on('focusin', function(e) {
|
|
if ($(e.target).closest(".tox-tinymce-aux, .moxman-window, .tam-assetmanager-root").length) {
|
|
e.stopImmediatePropagation();
|
|
}
|
|
});
|
|
|
|
|
|
},
|
|
tinymce_announcement_content: function () {
|
|
var t, a, n, save_button = $("#save_announcement");
|
|
|
|
save_button.on('click', function () {
|
|
var save_button = $("#save_announcement");
|
|
var description = tinyMCE.activeEditor.getContent({format: 'raw'});
|
|
var announcement_title = $("#announcement_title").val();
|
|
var announcement_expiration = $("#announcement_expiration").val();
|
|
//var description = tinymce.get('tinymce_mentios_legales').getContent() ;
|
|
var status = $("#announcement_status").val();
|
|
var json = {
|
|
'announcement_title': announcement_title,
|
|
'content': description,
|
|
'announcement_expiration': announcement_expiration,
|
|
'status': status
|
|
};
|
|
|
|
if(description!=''&&announcement_title!=''&&announcement_expiration!=''){
|
|
$.ajax({
|
|
url: app.get_vars().baseurl + "personalization/personalization/check_enable_announcement",
|
|
type: "GET",
|
|
success: function(e) {
|
|
if(e=='full'){
|
|
bootbox.dialog({
|
|
title: "Edit Announcement",
|
|
className: "my-modal-with-sm event-normal-registration-modal table",
|
|
message: 'There are is an existing announcement that was ENABLED. Saving this announcement will DISABLE the active announcement.',
|
|
cache: !1,
|
|
show: !1,
|
|
size: 'large',
|
|
buttons: [{
|
|
label: "RETOUR",
|
|
className: "btn btn-default",
|
|
callback: function() {
|
|
announcement_table.ajax.reload();
|
|
}
|
|
}, {
|
|
label: "CONFIRMER",
|
|
className: "btn btn-primary",
|
|
callback: function() {
|
|
$.trim($("#announcement_title").val()), a = $.trim($("#announcement_expiration").val()), n = tinymce.get("announcement_content").getContent(), "Choisissez un sujet de question ..." == a || "" == t || "" == n || "" == a ? app._notify("error", "Merci de remplir les champs suivants.") : $.ajax({
|
|
url: app.get_vars().baseurl + "personalization/save_announcement",
|
|
type: 'POST',
|
|
data: json,
|
|
success: function (result) {
|
|
announcement_table.ajax.reload();
|
|
app._notify(result.mtype, result.message);
|
|
$("#announcement_title").val("");
|
|
$("#announcement_expiration").val("");
|
|
$("#announcement_content").val("");
|
|
tinyMCE.activeEditor.setContent('');
|
|
}
|
|
});
|
|
|
|
}
|
|
}]
|
|
}).on("shown.bs.modal", function() {
|
|
|
|
|
|
|
|
}).on("hide.bs.modal", function() {
|
|
|
|
|
|
|
|
}).modal("show")
|
|
}else{
|
|
$.trim($("#announcement_title").val()), a = $.trim($("#announcement_expiration").val()), n = tinymce.get("announcement_content").getContent(), "Choisissez un sujet de question ..." == a || "" == t || "" == n || "" == a ? app._notify("error", "Merci de remplir les champs suivants.") : $.ajax({
|
|
url: app.get_vars().baseurl + "personalization/save_announcement",
|
|
type: 'POST',
|
|
data: json,
|
|
success: function (result) {
|
|
announcement_table.ajax.reload();
|
|
app._notify(result.mtype, result.message);
|
|
$("#announcement_title").val("");
|
|
$("#announcement_expiration").val("");
|
|
$("#announcement_content").val("");
|
|
tinyMCE.activeEditor.setContent('');
|
|
}
|
|
});
|
|
}
|
|
}
|
|
})
|
|
}else{
|
|
app._notify('error', 'All fields are required.');
|
|
}
|
|
});
|
|
},
|
|
"update_homepage_title": function(text) {
|
|
if(text) {
|
|
$.ajax({
|
|
url: app.get_vars().baseurl + "personalization/update-homepage-title",
|
|
type: "POST",
|
|
data: {title: text},
|
|
success: function(result) {
|
|
app._notify(result.mtype, "Successfully saved");
|
|
}
|
|
});
|
|
}else{
|
|
app._notify('error', 'Field is required.');
|
|
}
|
|
},
|
|
"get_homepage_title": function() {
|
|
$.ajax({
|
|
url: app.get_vars().baseurl + "personalization/get-homepage-title",
|
|
type: "GET",
|
|
success: function(result) {
|
|
console.log(result)
|
|
}
|
|
});
|
|
},
|
|
"add_session": function(fieldInstance, schedule) {
|
|
$('#tbody').append(
|
|
'<tr id="row'+fieldInstance+'">' +
|
|
'<td class="row-index text-center">'+
|
|
'<div class="input-group">'+
|
|
'<input type="text" class="form-control datetimepicker multiple-session-date" required name="start_session_date-'+fieldInstance+'" id="start_session_date-'+fieldInstance+'">'+
|
|
'<div class="input-group-addon">'+
|
|
'<span class="glyphicon glyphicon-calendar"></span>'+
|
|
'</div>'+
|
|
'</div>'+
|
|
'</td>'+
|
|
'<td class="row-index text-center">'+
|
|
'<div class="input-group">'+
|
|
'<input type="text" class="form-control datetimepicker multiple-session-date" required name="end_session_date-'+fieldInstance+'" id="end_session_date-'+fieldInstance+'">'+
|
|
'<div class="input-group-addon">'+
|
|
'<span class="glyphicon glyphicon-calendar"></span>'+
|
|
'</div>'+
|
|
'</div>'+
|
|
'</td>'+
|
|
'<td class="text-center">'+
|
|
'<button class="btn btn-danger remove" type="button">Supprimer</button>'+
|
|
'</td>'+
|
|
'<td class="text-center" style="display:none">'+
|
|
'<input type="hidden" name="event_schedule_id-'+fieldInstance+'" id="event_schedule_id-'+fieldInstance+'">'+
|
|
'</td>'+
|
|
'</tr>');
|
|
if(schedule) {
|
|
$("#event_schedule_id-"+fieldInstance).val(schedule.event_schedule_id)
|
|
$("#start_session_date-"+fieldInstance).val(schedule.start_date_time)
|
|
$("#end_session_date-"+fieldInstance).val(schedule.end_date_time)
|
|
}
|
|
|
|
},
|
|
"add_author_award": function(fieldInstance, award) {
|
|
$('#tbody_award').append(
|
|
'<tr id="row'+fieldInstance+'">' +
|
|
'<td class="row-index text-center">'+
|
|
'<div class="">'+
|
|
'<input type="text" class="form-control" required name="author_award-'+fieldInstance+'" id="author_award-'+fieldInstance+'">'+
|
|
'</div>'+
|
|
'</td>'+
|
|
'<td class="text-center">'+
|
|
'<button class="btn btn-danger remove" type="button">Supprimer</button>'+
|
|
'</td>'+
|
|
'</tr>');
|
|
|
|
if(award) {
|
|
$("#author_award-"+fieldInstance).val(award)
|
|
}
|
|
},
|
|
"add_author_works": function(fieldInstance, work) {
|
|
$('#tbody_works').append(
|
|
'<tr id="row'+fieldInstance+'">' +
|
|
'<td class="row-index text-center">'+
|
|
'<div class="">'+
|
|
'<input type="text" class="form-control" required name="author_work-'+fieldInstance+'" id="author_work-'+fieldInstance+'">'+
|
|
'</div>'+
|
|
'</td>'+
|
|
'<td class="row-index text-center">'+
|
|
'<div class="">'+
|
|
'<img src="" class="" style="display:none" id="image-work-'+fieldInstance+'">'+
|
|
'<input type="file" class="form-control author-image" required onchange="events.getBase64Image(this, '+fieldInstance+', \'work\')" name="author_work_image-'+fieldInstance+'" id="author_work_image-'+fieldInstance+'">'+
|
|
'</div>'+
|
|
'</td>'+
|
|
'<td class="row-index text-center">'+
|
|
'<div class="">'+
|
|
'<input type="text" class="form-control" required name="author_work_link-'+fieldInstance+'" id="author_work_link-'+fieldInstance+'">'+
|
|
'</div>'+
|
|
'</td>'+
|
|
'<td class="text-center">'+
|
|
'<button class="btn btn-danger remove" type="button">Supprimer</button>'+
|
|
'</td>'+
|
|
'<td class="text-center" style="display:none">'+
|
|
'<input type="hidden" name="author_work_id-'+fieldInstance+'" id="author_work_id-'+fieldInstance+'">'+
|
|
'</td>'+
|
|
'</tr>');
|
|
|
|
if(work) {
|
|
//todo
|
|
if(work.image) {
|
|
let workImage = app.get_vars().baseurl+'resources/images/frontoffice/banner/'+work.image
|
|
$('#image-work-'+fieldInstance).css({display:'block', height: '200px'});
|
|
$("#image-work-"+fieldInstance).attr('src', workImage)
|
|
$('#author_work_image-'+fieldInstance).attr({'required': false})
|
|
}
|
|
$("#author_work-"+fieldInstance).val(work.work)
|
|
$("#author_work_link-"+fieldInstance).val(work.link)
|
|
$("#author_work_id-"+fieldInstance).val(work.id)
|
|
}
|
|
if($('#tbody_works tr').length === 4) {
|
|
$('#addBtn_work').attr('disabled', 'disabled')
|
|
}
|
|
},
|
|
"add_venue_img": function(venuePhotoCount, venueImg) {
|
|
$('#tbody_venue_img').append(
|
|
'<tr id="row'+venuePhotoCount+'">' +
|
|
'<td class="row-index text-center">'+
|
|
'<div class="">'+
|
|
'<img src="" class="" style="display:none" id="image-venue-'+venuePhotoCount+'">'+
|
|
'<input type="file" class="form-control venue_img-image" required onchange="events.getBase64Image(this, '+venuePhotoCount+', \'venue\')" name="venue_img_image-'+venuePhotoCount+'" id="venue_img_image-'+venuePhotoCount+'">'+
|
|
'</div>'+
|
|
'</td>'+
|
|
'<td class="text-center">'+
|
|
'<button class="btn btn-danger remove" type="button">Supprimer</button>'+
|
|
'</td>'+
|
|
'<td class="text-center" style="display:none">'+
|
|
'<input type="hidden" name="venue_img_id-'+venuePhotoCount+'" id="venue_img_id-'+venuePhotoCount+'">'+
|
|
'</td>'+
|
|
'</tr>');
|
|
|
|
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 <tr> id.
|
|
var id = $(this).attr('id');
|
|
|
|
// Getting the <p> inside the .row-index class.
|
|
var idx = $(this).children('.row-index').children('p');
|
|
|
|
// Gets the row number from <tr> 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 <tr> id.
|
|
var id = $(this).attr('id');
|
|
|
|
// Getting the <p> inside the .row-index class.
|
|
var idx = $(this).children('.row-index').children('p');
|
|
|
|
// Gets the row number from <tr> 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 <tr> id.
|
|
var id = $(this).attr('id');
|
|
|
|
// Getting the <p> inside the .row-index class.
|
|
var idx = $(this).children('.row-index').children('p');
|
|
|
|
// Gets the row number from <tr> 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 <tr> id.
|
|
var id = $(this).attr('id');
|
|
|
|
// Getting the <p> inside the .row-index class.
|
|
var idx = $(this).children('.row-index').children('p');
|
|
|
|
// Gets the row number from <tr> 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);
|
|
}
|
|
});
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|