Etes-vous sûr de vouloir désactiver la comptabilisation des "No-Show"? Pour information cette option permet de prendre en compte les absences dans le système de modération pour chaque abonné.
',
"_continue": function() {
$(this).prop("checked", false);
Attendance.toggleNoshowStatus(($(this).prop("checked")) ? 1 : 0);
},
"_close": function() {
$('input[name=noshow_status]').prop("checked", true);
},
"id": "noshow_status_conf_modal",
"className": "noshow_status_conf_modal"
});
} else {
Attendance.toggleNoshowStatus(($(this).prop("checked")) ? 1 : 0);
$('input.n-present').trigger('focusout');
}
} else {
app._notify('error', 'Action non autorisée, les modifications n\'ont pas été enregistrées.')
}
});
$('.n-present').on('focusout change', function(event) {
event.preventDefault();
/* Validate max and min values*/
max = parseInt($(this).attr('max'));
min = parseInt($(this).attr('min'));
if (this.value < min) {
this.value = 0;
}
if (this.value > max) {
this.value = max;
}
/* Act on the event */
var row_data = $('#no_show_list').DataTable().row($(this).attr('data-td-index')).data();
// console.log($($('#no_show_list').DataTable().row($(this).attr('data-td-index')).node()).addClass('asd'));
// console.log(identify_row_class(row_data[9], $(this).val()));
$($('#no_show_list').DataTable().row($(this).attr('data-td-index')).node()).removeClass(
'no_present_row partial_present_row full_present_row'
)
var attendance = (($(this).val()) ? parseInt($(this).val()) : 0);
$($('#no_show_list').DataTable().row($(this).attr('data-td-index')).node()).addClass(
identify_row_class(row_data[9], attendance)
)
var noshow_data = {
'event_schedule_id': eventScheduleId,
'event_id': eventId,
'user_id': row_data[0],
'registration_id': row_data[1],
'civility': row_data[2],
'email_address': row_data[3],
'comment': row_data[4],
'last_name': row_data[6],
'first_name': row_data[7],
'type': row_data[8],
'no_of_place': row_data[9],
'attendance': attendance,
}
update_row = true;
if (row_id) {
if (row_id == row_data[1] && row_attendance != attendance) {
update_row = true;
// console.log("updated");
} else if (row_id != row_data[1]) {
update_row = true;
} else {
update_row = false;
// console.log("not updated");
}
}
if (update_row) {
// app.btn_loader('.btn_no_show');
$.ajax({
url: base_url + 'save_noshow_data/',
type: 'POST',
// dataType: 'default: Intelligent Guess (Other values: xml, json, script, or html)',
data: noshow_data
})
.done(function($data) {
// to be used in checking if data is
// already updated by a different type of listener
row_id = row_data[1];
row_attendance = attendance;
row_event_type = event.type;
Attendance.reloadHeaderValues(eventScheduleId);
$('.page-loader').remove();
// app.rmbtn_loader('.btn_no_show');
})
.fail(function() {
// console.log("error");
})
.always(function() {
// console.log("complete");
});
}
});
$("#noshow_walk_in_form input:not('.civility')").on('click input focusout', function(event) {
event.preventDefault();
/* Act on the event */
inputIsValid($(this));
});
}
function trigger_validation(form_id) {
$(`${form_id} input:not('.civility')`).trigger('click');
}
function init_plugins() {
function wcqib_refresh_quantity_increments() {
jQuery("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").each(function(a, b) {
var c = jQuery(b);
c.addClass("buttons_added"), c.children().first().before(''), c.children().last().after('')
})
}
String.prototype.getDecimals || (String.prototype.getDecimals = function() {
var a = this,
b = ("" + a).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);
return b ? Math.max(0, (b[1] ? b[1].length : 0) - (b[2] ? +b[2] : 0)) : 0
}), jQuery(document).ready(function() {
wcqib_refresh_quantity_increments()
}), jQuery(document).on("updated_wc_div", function() {
wcqib_refresh_quantity_increments()
}), jQuery(document).on("click", ".plus, .minus", function() {
var a = jQuery(this).closest(".quantity").find(".qty"),
b = parseFloat(a.val()),
c = parseFloat(a.attr("max")),
d = parseFloat(a.attr("min")),
e = a.attr("step");
b && "" !== b && "NaN" !== b || (b = 0), "" !== c && "NaN" !== c || (c = ""), "" !== d && "NaN" !== d || (d = 0), "any" !== e && "" !== e && void 0 !== e && "NaN" !== parseFloat(e) || (e = 1), jQuery(this).is(".plus") ? c && b >= c ? a.val(c) : a.val((b + parseFloat(e)).toFixed(e.getDecimals())) : d && b <= d ? a.val(d) : b > 0 && a.val((b - parseFloat(e)).toFixed(e.getDecimals())), a.trigger("change")
});
}
function identify_row_class(no_of_place, attendance) {
var row_class;
if (no_of_place == attendance) {
row_class = 'full_present_row';
} else {
if (attendance == 0) {
row_class = 'no_present_row';
} else if (attendance < no_of_place) {
row_class = 'partial_present_row';
} else {
row_class = 'full_present_row';
}
if (no_of_place == 'n/a') {
row_class = 'full_present_row';
}
}
return row_class;
}
function inputIsValid(input) {
if (!input[0].checkValidity()) {
input.parent().addClass('has-error');
if (!input.val()) {
input.parent().children('.help-block').html('Ce champ est obligatoire.');
} else {
input.parent().children('.help-block').html('');
}
} else {
input.parent().removeClass('has-error');
input.parent().children('.help-block').html('');
}
}
function resetFields(input) {
input.parent().removeClass('has-error');
input.parent().children('.help-block').html('');
}
function allInputsAreValid() {
if ($('.has-error').html()) {
return false;
}
return true;
}
/**
* Generate message validation for email if email exist or not, but no blocking
*
* @param {string} post = email string
* @return {void} [description]
*/
function checkIfEmailExist(post) {
/**
* Let's cache the span icon
* @type {[type]}
*/
var _emailSpanIcon = $("span#sucessEmailValidation");
post.on("focusout", function() {
/**
* Check if email is empty then remove check icon first
*/
if ($(this).val() == '')
_emailSpanIcon.addClass('hidden');
/**
* Main email subscriber validations
* - Font Color
* - Validation messages
* - Add check Icon for unregistered/registered email subscribers
* @type {[type]}
*/
$.ajax({
url: app.get_vars().baseurl + 'validateExtraPeopleIfEmailsExists',
type: 'POST',
data: 'email_address=' + $(this).val()
}).done(function(response) {
$email = $("#email_address");
if (response.commandValidate) {
/**
* Add error class to higlight field
* @param {[type]} response [description]
* @return {[type]} [description]
*/
if (response.highlightError)
$email.parent().addClass('has-error');
/**
* Add check/Remove check icon for registered/unregistered email subscriber's
*/
if (response.sucessEmailValidation)
_emailSpanIcon.removeClass('hidden');
if (!response.sucessEmailValidation)
_emailSpanIcon.addClass('hidden');
//Add div message blocks and font Color validation email
$email.parent().children('.help-block').html(response.message).css({
"color": response.color
});
}
});
})
}
Attendance = {
/**
* toggle noshow status
* @param {*} e
*/
initNoshowStatus: function(status) {
$.ajax({
url: base_url + 'getNoshowStatus/' + eventScheduleId,
type: 'GET'
})
.done(function(result) {
if (result.noshow_stat) {
if (parseInt(result.is_passed_start_date) == 0) {
$('input[name=noshow_status]').prop('checked', false);
$('input[name=noshow_status]').attr('disabled', 'disabled');
// turn noshow off
Attendance.toggleNoshowStatus(0);
app._notify("info", "Vous pouvez uniquement activer le statut noshow après le début de l'événement.");
} else {
$('input[name=noshow_status]').prop('checked',
parseInt(result.noshow_stat) ? true : false);
}
}
});
},
/**
* toggle noshow status
* @param {*} e
*/
toggleNoshowStatus: function(status) {
$.ajax({
url: base_url + 'toggleNoshowStatus/' + eventScheduleId,
type: 'POST',
data: {
'no_show_stat': status
}
})
.done(function(result) {
if (!$('input[name=noshow_status]').attr("disabled")) {
app._notify(result.mtype, result.message);
}
});
},
/**
* Display modal attendance prepare for uploading
* @param {*} e
*/
Import_modal: function(e) {
//Call upload attendance modal
var UploadModalAttendance = $("#UploadModalAttendance");
//Show modal for import selection
UploadModalAttendance.modal("show");
//Call Import function
$("#buttonImportAttendance").off("click").on("click", function() {
UploadModalAttendance.modal("hide");
Attendance.Import();
})
},
/**
* Import file globally
*/
Import: function() {
if (typeof FormData !== 'undefined') {
var eventfiles = document.getElementById("AttendanceUpload");
if (eventfiles.files.length > 0) {
var file = (eventfiles.files[0].name).split(".");
if (file[file.length - 1] != "" && (file[file.length - 1] == "xlsx" || file[file.length - 1] == "xls")) {
app.modal.confirm_box({
"message": "Êtes-vous sûr de vouloir importer ce fichier?
" + app.get_vars()._app.cma_msg.note + "",
"_continue": function() {
$('.loader-container').prepend(app.get_loader2('Importing...'));
setTimeout(function(){
var formData = new FormData($("#formAttendance")[0]);
$.ajax({
url: app.get_vars().baseurl + "attendance/upload",
type: "post",
data: formData,
async: false,
cache: false,
contentType: false,
processData: false,
success: function(result, textStatus, jQxhr) {
//Hide confirm upload message
$(".subscriberConfirmBox").modal('hide');
//Import success then reset modal and input values
if (result.mtype == 'success') {
$("#AttendanceUpload").val('');
$("#UploadModalAttendance").modal('hide');
app._notify(result.mtype, result.message);
}
//If error with subscriber's
if (result.subscriber) {
//Show modal warning for error input present and display list of failed by emails
$("#SubscriberModalWarning").modal("show");
//loop subscriber emails
$.each(result.subscriber, function(i, subscribers) {
$(".subscribersFailed").append("