This commit introduces a mobile login feature with validation messages for username and password fields, improving user experience. It also updates the header and footer to conditionally render elements based on mobile entry status, ensuring a cohesive design. Additionally, CSS styles are added to enhance the mobile interface, and the version code is incremented to 4.72.689 to reflect these changes.
3751 lines
148 KiB
PHP
3751 lines
148 KiB
PHP
|
||
<?php
|
||
global $vPage, $strCode, $vDomaine, $tabEvenement, $strStep, $strLangue, $arrTermesModalButtons, $strValidationMembership;
|
||
|
||
if (isset($tabEvenement['general']) && trim($tabEvenement['general']['eve_plugins']) != '') {
|
||
echo trim($tabEvenement['general']['eve_plugins']);
|
||
}
|
||
|
||
?>
|
||
|
||
<?php echo $vGoogleAnalytics;
|
||
|
||
if ($strLangue == 'fr') {
|
||
$mem_login = "compte";
|
||
} else {
|
||
$mem_login = "account";
|
||
}
|
||
$message_login = afficheTexte('listeatt_textlogin', 0, 1, 1);
|
||
|
||
|
||
$message = str_replace('%url%', $mem_login, $message_login);
|
||
|
||
?>
|
||
<script>
|
||
$('.btn_liste_attente').click(function (e) {
|
||
e.preventDefault();
|
||
let epr_id = $(this).data('epr_id');
|
||
$.ajax({
|
||
url: '../ajax_liste_attente.php', // Remplacez par votre script de validation
|
||
type: 'POST',
|
||
data: {
|
||
epr_id: epr_id,
|
||
lang: "<?php echo($strLangue);?>",
|
||
textnew: "<?php afficheTexte('listeatt_textnew', 1, 1, 1); ?>",
|
||
textins: "<?php afficheTexte('listeatt_textins', 1, 1, 1); ?>",
|
||
textlogin: "<?php echo $message ?>"
|
||
}, // Ajoutez vos paramètres nécessaires
|
||
dataType: 'json',
|
||
success: function (response) {
|
||
let message = "";
|
||
|
||
if (response.success) {
|
||
message = response.message;
|
||
} else {
|
||
message = response.message;
|
||
}
|
||
|
||
// Appel de Bootbox après que le message est défini
|
||
bootbox.confirm({
|
||
title: "<?php echo ($strLangue == 'fr') ? 'Liste' : 'Waitlist'; ?>",
|
||
message: message,
|
||
buttons: {
|
||
confirm: {
|
||
label: '<?php echo ($strLangue == 'fr') ? 'Ok' : 'OK'; ?>',
|
||
className: 'btn btn-success rounded-0'
|
||
},
|
||
cancel: {
|
||
label: '',
|
||
className: 'd-none' // Cache le bouton Annuler
|
||
}
|
||
},
|
||
callback: function (result) {
|
||
|
||
}
|
||
});
|
||
},
|
||
error: function () {
|
||
let message = "<?php echo ($strLangue == 'fr') ? 'Erreur de connexion au serveur' : 'Server connection error'; ?>";
|
||
|
||
bootbox.alert({
|
||
title: "<?php echo ($strLangue == 'fr') ? 'Erreur' : 'Error'; ?>",
|
||
message: message
|
||
});
|
||
}
|
||
});
|
||
});
|
||
|
||
</script>
|
||
<script>
|
||
window.fbAsyncInit = function () {
|
||
FB.init({
|
||
appId: '<?php echo fxGetVariable('fb_app_id'); ?>',
|
||
autoLogAppEvents: true,
|
||
xfbml: true,
|
||
version: 'v3.2'
|
||
});
|
||
};
|
||
|
||
(function (d, s, id) {
|
||
var js, fjs = d.getElementsByTagName(s)[0];
|
||
if (d.getElementById(id)) {
|
||
return;
|
||
}
|
||
js = d.createElement(s);
|
||
js.id = id;
|
||
js.src = "https://connect.facebook.net/<?php echo $strLangue; ?>_CA/sdk.js";
|
||
fjs.parentNode.insertBefore(js, fjs);
|
||
}(document, 'script', 'facebook-jssdk'));
|
||
</script>
|
||
<script src="https://www.google.com/recaptcha/api.js?render=<?php echo RECAPTCHA_SITE_KEY; ?>&hl=<?php echo $strLangue;
|
||
if ($strLangue == 'fr') {
|
||
echo '-CA';
|
||
} ?>"></script>
|
||
<script src="<?php echo $vDomaine; ?>/plugins/select2-4.0.13/dist/js/i18n/<?php echo $strLangue; ?>.js"></script>
|
||
<?php
|
||
if ($strLangue == 'fr') {
|
||
?>
|
||
<script type="text/javascript"
|
||
src="<?php echo $vDomaine; ?>/plugins/bootstrap-select/js/i18n/defaults-fr_FR.js"></script>
|
||
<script type="text/javascript" src="<?php echo $vDomaine; ?>/plugins/jqery.validate-1.19.1/messages_fr.js"></script>
|
||
<script src="<?php echo $vDomaine; ?>/plugins/flatpickr-4.6.13/dist/l10n/fr.js"></script>
|
||
<?php
|
||
} else {
|
||
?>
|
||
<script type="text/javascript"
|
||
src="<?php echo $vDomaine; ?>/plugins/bootstrap-select/js/i18n/defaults-en_US.min.js"></script>
|
||
<?php
|
||
}
|
||
?>
|
||
<script type="text/javascript">
|
||
$(function () {
|
||
var $preloader = $('#preloader');
|
||
var $preloader_text = $('#preloader_text');
|
||
var $body = $('body');
|
||
|
||
try {
|
||
$("input[type='text']").each(function () {
|
||
$(this).attr("autocomplete", "<?php echo uniqid(); ?>");
|
||
});
|
||
} catch (e) {
|
||
}
|
||
$("form").keypress(function (e) {
|
||
//Enter key
|
||
if ($(this).attr("id") !== "frm_contact") {
|
||
if (e.which == 13) {
|
||
return false;
|
||
} }
|
||
});
|
||
bsCustomFileInput.init();
|
||
$('[data-toggle="tooltip"]').tooltip({
|
||
boundary: 'window'
|
||
});
|
||
$('[data-toggle="popover"]').popover({
|
||
container: 'body',
|
||
html: true,
|
||
placement: 'bottom',
|
||
sanitize: false
|
||
});
|
||
// if (/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent)) {
|
||
// $('.selectpicker').selectpicker('mobile');
|
||
// }
|
||
//$('[data-toggle="popover-x"]').popoverX({placement: 'auto'});
|
||
$(".btn_delete_part_supplementaire").click(function (event) {
|
||
event.preventDefault();
|
||
var strAnswer = confirm("Are you sure you want to delete?");
|
||
if (strAnswer == true) {
|
||
window.location = $(this).attr('href');
|
||
}
|
||
});
|
||
$(".btn_page_prec").click(function () {
|
||
document.location.href = $(this).data('code');
|
||
return false;
|
||
});
|
||
$('.select2-single').select2({
|
||
language: '<?php echo $strLangue; ?>',
|
||
minimumResultsForSearch: Infinity,
|
||
theme: "bootstrap4",
|
||
width: 'elemment'
|
||
});
|
||
$('.select2-multi').select2({
|
||
language: '<?php echo $strLangue; ?>',
|
||
minimumResultsForSearch: Infinity,
|
||
theme: "bootstrap4",
|
||
width: 'elemment'
|
||
});
|
||
$('.select2-multi').on('select2:opening select2:closing', function (event) {
|
||
var $searchfield = $(this).parent().find('.select2-search__field');
|
||
$searchfield.prop('disabled', true);
|
||
});
|
||
<?php
|
||
if (isset($_SESSION['com_info'])) {
|
||
?>
|
||
$('.btn_logout').click(function (e) {
|
||
e.preventDefault();
|
||
|
||
bootbox.confirm({
|
||
title: "<?php afficheTexte('confirm-logout-title', 1, 1, 1); ?>",
|
||
message: "<?php afficheTexte('confirm-logout-message', 1, 1, 1); ?>",
|
||
buttons: {
|
||
confirm: {
|
||
label: '<?php afficheTexte('confirm-logout-btn-confirm', 1, 1, 1); ?>',
|
||
className: 'btn btn-primary rounded-0'
|
||
},
|
||
cancel: {
|
||
label: '<?php afficheTexte('confirm-logout-btn-cancel', 1, 1, 1); ?>',
|
||
className: 'btn btn-secondary rounded-0'
|
||
}
|
||
},
|
||
callback: function (result) {
|
||
if (result === true) {
|
||
document.location.href = '<?php echo $vDomaine; ?>/logout.php?lang=<?php echo $strLangue; ?>';
|
||
}
|
||
}
|
||
});
|
||
});
|
||
<?php
|
||
}
|
||
|
||
switch ($vPage) {
|
||
case 'compte.php':
|
||
case 'mobile.php':
|
||
if ($footer_script == true) {
|
||
?>
|
||
|
||
if ($('#frm_inscr_mobile_login').length) {
|
||
$('#frm_inscr_mobile_login').validate({
|
||
messages: {
|
||
txt_login: "<?php echo ($strLangue === 'fr') ? 'Veuillez entrer votre nom d\'usager' : 'Please enter your username'; ?>",
|
||
txt_password: "<?php echo ($strLangue === 'fr') ? 'Veuillez entrer votre mot de passe' : 'Please enter your password'; ?>"
|
||
}
|
||
});
|
||
}
|
||
|
||
$('.btn_update_prod').click(function () {
|
||
var $id = $(this).data('id');
|
||
var $key = $(this).data('key');
|
||
var $table = $(this).data('table');
|
||
var $preloader = $('#preloader');
|
||
|
||
bootbox.confirm({
|
||
title: "ATTENTION",
|
||
message: "Êtes-vous certain de vouloir mettre en PROD ?",
|
||
buttons: {
|
||
confirm: {
|
||
label: 'Oui',
|
||
className: 'btn btn-primary rounded-0'
|
||
},
|
||
cancel: {
|
||
label: 'Non',
|
||
className: 'btn btn-secondary rounded-0'
|
||
}
|
||
},
|
||
callback: function (result) {
|
||
if (result === true) {
|
||
$preloader.show();
|
||
$.post('<?php echo $vDomaine; ?>/superadm/ajax_update_prod.php', 't=' + $table + '&id=' + $id + '&key=' + $key, function ($resultajax) {
|
||
|
||
window.location.reload();
|
||
|
||
}, 'json');
|
||
}
|
||
}
|
||
});
|
||
});
|
||
|
||
$(".btn_activation").on("click", function (event) {
|
||
event.preventDefault();
|
||
var $preloader = $('#preloader');
|
||
$preloader.show();
|
||
var $link = $(this);
|
||
var $action = $link.data('action');
|
||
var $table = $link.data('table');
|
||
var $field = $link.data('field');
|
||
var $key = $link.data('key');
|
||
var $valeur = $link.data('valeur');
|
||
var $id = $link.data('id');
|
||
|
||
$.post('<?php echo $vDomaine; ?>/superadm/enregistrer.php', 'action=' + $action + '&table=' + $table + '&field=' + $field + '&key=' + $key + '&valeur=' + $valeur + '&id=' + $id, function ($result) {
|
||
if ($result.state == 'success') {
|
||
$link.toggleClass('btn-danger');
|
||
$link.toggleClass('btn-success');
|
||
|
||
if ($result.pnq_cadeau != '') { // insérer la date du update
|
||
var $field_date = '#' + $field + '_date_' + $id;
|
||
$($field_date).text($result.pnq_cadeau);
|
||
}
|
||
|
||
if ($valeur == 1) {
|
||
$link.data('valeur', 0);
|
||
$link.html('<i class="fa fa-check" aria-hidden="true"></i>');
|
||
} else {
|
||
$link.data('valeur', 1);
|
||
$link.html('<i class="fa fa-times" aria-hidden="true"></i>');
|
||
}
|
||
} else {
|
||
alert($result.state);
|
||
}
|
||
|
||
$preloader.fadeOut();
|
||
}, 'json');
|
||
});
|
||
|
||
|
||
$(".btn_remis").on("click", function (event) {
|
||
event.preventDefault();
|
||
var $preloader = $('#preloader');
|
||
$preloader.show();
|
||
var $link = $(this);
|
||
var $action = $link.data('action');
|
||
var $table = $link.data('table');
|
||
var $field = $link.data('field');
|
||
var $key = $link.data('key');
|
||
var $valeur = $link.data('valeur');
|
||
var $id = $link.data('id');
|
||
|
||
// console.log('https://ms1inscriptiondev.interne.ca/superadm/enregistrer.php?action=' + $action + '&table=' + $table + '&field=' + $field + '&key=' + $key + '&valeur=' + $valeur + '&id=' + $id );
|
||
|
||
$.post('<?php echo $vDomaine; ?>/superadm/enregistrer.php', 'par_id=<?php echo($_SESSION['com_info']['com_id']); ?> & par=<?php echo($_SESSION['com_info']['com_prenom'] . ' ' . $_SESSION['com_info']['com_nom']); ?> & action=' + $action + '&table=' + $table + '&field=' + $field + '&key=' + $key + '&valeur=' + $valeur + '&id=' + $id, function ($result) {
|
||
if ($result.state == 'success') {
|
||
$link.toggleClass('btn-primary');
|
||
$link.toggleClass('btn-success');
|
||
//console.log($result);
|
||
|
||
var $field_date = '#date_' + $id;
|
||
$($field_date).text($result.result.no_bib_remis_date
|
||
);
|
||
var $field_par = '#par_' + $id;
|
||
$($field_par).text($result.result.no_bib_remis_par
|
||
);
|
||
|
||
|
||
if ($valeur == 1) {
|
||
$link.data('valeur', 0);
|
||
$link.html('<i class="fa fa-check" aria-hidden="true"></i>');
|
||
} else {
|
||
$link.data('valeur', 1);
|
||
$link.html('<i class="fa fa-sharp fa-regular fa-square fa-2xs" aria-hidden="true"></i>');
|
||
}
|
||
} else {
|
||
alert($result.state);
|
||
}
|
||
|
||
$preloader.fadeOut();
|
||
}, 'json');
|
||
});
|
||
|
||
$('body').on("click", ".link_confirmation", function (e) {
|
||
e.preventDefault();
|
||
|
||
var $no_panier = $(this).data('no_panier');
|
||
var $no_commande = $(this).data('no_commande');
|
||
var $lng = $(this).data('lng');
|
||
|
||
bootbox.confirm({
|
||
title: "Confirmation",
|
||
message: "<?php if ($strLangue == 'fr') { ?>Êtes-vous certain de vouloir envoyer la confirmation de la commande<?php } else { ?>Are you sure you want to send the confirmation for order<?php } ?> <strong>" + $no_commande + "</strong> ?",
|
||
buttons: {
|
||
confirm: {
|
||
label: '<?php if ($strLangue == 'fr') { ?>Renvoyer<?php } else { ?>Resend<?php } ?>',
|
||
className: 'btn btn-primary rounded-0'
|
||
},
|
||
cancel: {
|
||
label: '<?php afficheTexte('confirm-logout-btn-cancel', 1, 1, 1); ?>',
|
||
className: 'btn btn-secondary rounded-0'
|
||
}
|
||
},
|
||
callback: function (result) {
|
||
if (result === true) {
|
||
$.post('<?php echo $vDomaine; ?>/ajax_confirmation.php', 'no_panier=' + $no_panier + '&lng=' + $lng, function ($result) {
|
||
bootbox.alert($result.state);
|
||
}, 'json');
|
||
}
|
||
}
|
||
});
|
||
});
|
||
$(".btn_edit_event_promo").click(function () {
|
||
intEprId = $(this).data('epr_id');
|
||
intPecId = $(this).val();
|
||
code = $(this).data('eve_code');
|
||
|
||
if ('<?php echo $strLangue ?>' == 'fr') {
|
||
strpath = '/reserver/';
|
||
} else {
|
||
strpath = '/book/';
|
||
}
|
||
|
||
document.location.href = '<?php echo $vDomaine; ?>' + strpath + code + '/' + intEprId + '?promoteur=1&action=mod&pec_id=' + intPecId;
|
||
});
|
||
<?php
|
||
}
|
||
?>
|
||
$(".btn_edit_event_client").click(function () {
|
||
intEprId = $(this).data('epr_id');
|
||
intPecId = $(this).val();
|
||
code = $(this).data('eve_code');
|
||
|
||
if ('<?php echo $strLangue ?>' == 'fr') {
|
||
strpath = '/reserver/';
|
||
} else {
|
||
strpath = '/book/';
|
||
}
|
||
|
||
document.location.href = '<?php echo $vDomaine; ?>' + strpath + code + '/' + intEprId + '?action=mod&pec_id=' + intPecId;
|
||
});
|
||
$(".liste_inscriptions").click(function () {
|
||
$("#table_liste").toggle();
|
||
});
|
||
$(".btn_modifier_compte").click(function () {
|
||
if ('<?php echo $strLangue ?>' == 'fr') {
|
||
document.location.href = '/compte/modifiercompte';
|
||
} else {
|
||
document.location.href = '/account/modifiercompte'
|
||
}
|
||
});
|
||
<?php
|
||
if (isset($arrFormsTransfert) && count($arrFormsTransfert) > 0) {
|
||
foreach ($arrFormsTransfert as $pec_id) {
|
||
?>
|
||
$('#frm_xfer_<?php echo $pec_id; ?>')
|
||
.validate({
|
||
rules: {
|
||
tra_nom_<?php echo $pec_id; ?>: "required",
|
||
tra_prenom_<?php echo $pec_id; ?>: "required",
|
||
tra_courriel_<?php echo $pec_id; ?>: {
|
||
required: true,
|
||
email: true
|
||
}
|
||
},
|
||
messages: {
|
||
tra_nom_<?php echo $pec_id; ?>: "<?php afficheTexte('transfert_validation-tra_nom-required'); ?>",
|
||
tra_prenom_<?php echo $pec_id; ?>: "<?php afficheTexte('transfert_validation-tra_prenom-required'); ?>",
|
||
tra_courriel_<?php echo $pec_id; ?>: {
|
||
required: "<?php afficheTexte('transfert_validation-tra_courriel-required'); ?>",
|
||
email: "<?php afficheTexte('transfert_validation-tra_courriel-email'); ?>"
|
||
}
|
||
},
|
||
/* errorLabelContainer: $(this).prev(), */
|
||
submitHandler: function (form) {
|
||
var $postData = $(form).serialize();
|
||
var $list = $('.xfer_list_<?php echo $pec_id; ?>');
|
||
|
||
$.post($(form).attr('action'), $postData + '&ajax=1', function (data) {
|
||
$(form).prev().slideUp(750, function () {
|
||
$(form).prev().hide();
|
||
$(form).prev().html(data.message);
|
||
$(form).prev().slideDown('slow');
|
||
});
|
||
$body.stop().animate({
|
||
scrollTop: ($(form).prev().offset().top - 100)
|
||
}, 1500);
|
||
|
||
if (data.state == 'success') {
|
||
$list.slideUp(750, function () {
|
||
$list.hide();
|
||
$list.html(data.liste);
|
||
$list.slideDown('slow');
|
||
});
|
||
|
||
$(form).trigger('reset');
|
||
}
|
||
}, 'json');
|
||
|
||
return false;
|
||
}
|
||
});
|
||
<?php
|
||
}
|
||
?>
|
||
$body.on("click", ".btn_cancel_transfert", function () {
|
||
var $no_transfert = $(this).data('no_transfert');
|
||
var $list = $(this).closest('div.xfer_list');
|
||
|
||
if (confirm("<?php if ($strLangue == 'fr') { ?>Êtes-vous certain de vouloir annuler cette demande de transfert ?<?php } else { ?>Are you sure you want to cancel this transfer request?<?php } ?>")) {
|
||
$.post('<?php echo $vDomaine; ?>/ajax_transfert.php', 'a=<?php echo urlencode(base64_encode('cancel')); ?>&id=' + $no_transfert + '&lang=<?php echo $strLangue; ?>&ajax=1', function ($result) {
|
||
if ($result.state == 'success') {
|
||
$list.prev().slideUp(750, function () {
|
||
$list.prev().hide();
|
||
$list.prev().html($result.message);
|
||
$list.prev().slideDown('slow');
|
||
});
|
||
$body.stop().animate({
|
||
scrollTop: ($list.prev().offset().top - 100)
|
||
}, 1500);
|
||
|
||
$list.slideUp(750, function () {
|
||
$list.hide();
|
||
$list.html($result.liste);
|
||
$list.slideDown('slow');
|
||
});
|
||
} else {
|
||
$list.prev().slideUp(750, function () {
|
||
$list.prev().hide();
|
||
$list.prev().html($result.message);
|
||
$list.prev().slideDown('slow');
|
||
});
|
||
$body.stop().animate({
|
||
scrollTop: ($list.prev().offset().top - 100)
|
||
}, 1500);
|
||
}
|
||
}, 'json');
|
||
}
|
||
|
||
return false;
|
||
});
|
||
|
||
$body.on("click", ".btn_resend_transfert", function () {
|
||
var $no_transfert = $(this).data('no_transfert');
|
||
var $list = $(this).closest('div.xfer_list');
|
||
|
||
if (confirm("<?php if ($strLangue == 'fr') { ?>Êtes-vous certain de vouloir envoyer de nouveau cette demande de transfert ?<?php } else { ?>Are you sure you want to resend this transfer request?<?php } ?>")) {
|
||
$.post('<?php echo $vDomaine; ?>/ajax_transfert.php', 'a=<?php echo urlencode(base64_encode('resend')); ?>&id=' + $no_transfert + '&lang=<?php echo $strLangue; ?>&ajax=1', function ($result) {
|
||
if ($result.state == 'success') {
|
||
$list.prev().slideUp(750, function () {
|
||
$list.prev().hide();
|
||
$list.prev().html($result.message);
|
||
$list.prev().slideDown('slow');
|
||
});
|
||
$body.stop().animate({
|
||
scrollTop: ($list.prev().offset().top - 100)
|
||
}, 1500);
|
||
|
||
$list.slideUp(750, function () {
|
||
$list.hide();
|
||
$list.html($result.liste);
|
||
$list.slideDown('slow');
|
||
});
|
||
} else {
|
||
$list.prev().slideUp(750, function () {
|
||
$list.prev().hide();
|
||
$list.prev().html($result.message);
|
||
$list.prev().slideDown('slow');
|
||
});
|
||
$body.stop().animate({
|
||
scrollTop: ($list.prev().offset().top - 100)
|
||
}, 1500);
|
||
}
|
||
}, 'json');
|
||
}
|
||
|
||
return false;
|
||
});
|
||
<?php
|
||
}
|
||
?>
|
||
$(".btn_cancel_event_promo,.btn_retablir_event_promo,.btn_cancel_event_client,.btn_retablir_event_client").click(function () {
|
||
var intEprId = $(this).data('epr_id');
|
||
var intPecId = $(this).val();
|
||
var code = $(this).data('eve_code');
|
||
var $btn_id = $(this).attr('id').split('_');
|
||
var $btn_annuler = $("#annuler_" + $btn_id[1]);
|
||
var $btn_retablir = $("#retablir_" + $btn_id[1]);
|
||
var $btn_modifier = $("#modifier_" + $btn_id[1]);
|
||
var $inscrFiche = $(this).closest('.inscr-mobile-fiche');
|
||
$preloader_text.html('<?php afficheTexte('preloader_wait', 1, 0, 1); ?>');
|
||
$body.css('cursor', 'wait');
|
||
$preloader.show();
|
||
|
||
$.post('<?php echo $vDomaine; ?>/ajax_compte.php', 'a=annuler-retablir-inscription&lng=<?php echo $strLangue; ?>&code=' + code + '&epr_id=' + intEprId + '&pec_id=' + intPecId, function ($result) {
|
||
if ($result.state == 'success') {
|
||
if ($inscrFiche.length) {
|
||
window.location.reload();
|
||
return;
|
||
}
|
||
if ($result.action == 'annuler') {
|
||
$btn_annuler.toggleClass('d-none');
|
||
$btn_modifier.toggleClass('d-none');
|
||
$btn_retablir.toggleClass('d-none');
|
||
$btn_annuler.closest('tr').toggleClass('table-danger');
|
||
} else if ($result.action == 'retablir') {
|
||
$btn_retablir.toggleClass('d-none');
|
||
$btn_annuler.toggleClass('d-none');
|
||
$btn_modifier.toggleClass('d-none');
|
||
$btn_annuler.closest('tr').toggleClass('table-danger');
|
||
}
|
||
} else {
|
||
// alert('ERREUR');
|
||
}
|
||
}, 'json');
|
||
|
||
$preloader.fadeOut('slow');
|
||
$body.css('cursor', 'default');
|
||
});
|
||
$(".more_link").click(function (e) {
|
||
e.preventDefault();
|
||
var $span_link = $(this).find('span');
|
||
var $block = $('.more_block');
|
||
|
||
$block.slideToggle('slow', function () {
|
||
if ($block.is(':visible')) {
|
||
$span_link.html('<i class="fa fa-minus ml-2" aria-hidden="true"></i>');
|
||
} else {
|
||
$span_link.html('<i class="fa fa-plus ml-2" aria-hidden="true"></i>');
|
||
}
|
||
});
|
||
});
|
||
$(".xfer_link").click(function (e) {
|
||
e.preventDefault();
|
||
var $pec_id = $(this).data('pec_id');
|
||
var $span_link = $(this).find('span');
|
||
var $xfer_block = $('.xfer_block_' + $pec_id);
|
||
|
||
$xfer_block.slideToggle('slow', function () {
|
||
if ($xfer_block.is(':visible')) {
|
||
$span_link.html('<i class="fa fa-minus ml-2" aria-hidden="true"></i>');
|
||
} else {
|
||
$span_link.html('<i class="fa fa-plus ml-2" aria-hidden="true"></i>');
|
||
}
|
||
});
|
||
});
|
||
$(".donation_link").click(function (e) {
|
||
e.preventDefault();
|
||
var $pec_id = $(this).data('pec_id');
|
||
var $span_link = $(this).find('span');
|
||
var $donation_block = $('.donation_block_' + $pec_id);
|
||
|
||
$donation_block.slideToggle('slow', function () {
|
||
if ($donation_block.is(':visible')) {
|
||
$span_link.html('<i class="fa fa-minus ml-2" aria-hidden="true"></i>');
|
||
} else {
|
||
$span_link.html('<i class="fa fa-plus ml-2" aria-hidden="true"></i>');
|
||
}
|
||
});
|
||
});
|
||
$(".vr_link").click(function (e) {
|
||
e.preventDefault();
|
||
var $pec_id = $(this).data('pec_id');
|
||
var $span_link = $(this).find('span');
|
||
var $donation_block = $('.vr_block_' + $pec_id);
|
||
|
||
$donation_block.slideToggle('slow', function () {
|
||
if ($donation_block.is(':visible')) {
|
||
$span_link.html('<i class="fa fa-minus ml-2" aria-hidden="true"></i>');
|
||
} else {
|
||
$span_link.html('<i class="fa fa-plus ml-2" aria-hidden="true"></i>');
|
||
}
|
||
});
|
||
});
|
||
<?php
|
||
if (isset($arrFormsObjectifsDons)) {
|
||
foreach ($arrFormsObjectifsDons as $array) {
|
||
foreach ($array as $pec_id => $forms) {
|
||
foreach ($forms as $form) {
|
||
?>
|
||
$('#<?php echo $form; ?>')
|
||
.validate({
|
||
rules: {
|
||
montant: {
|
||
number: true
|
||
}
|
||
},
|
||
messages: {
|
||
montant: {
|
||
required: "<?php afficheTexte('objectifs_dons_validation-montant-required'); ?>",
|
||
number: "<?php afficheTexte('objectifs_dons_validation-montant-number'); ?>",
|
||
min: "<?php afficheTexte('objectifs_dons_validation-montant-minlength'); ?>"
|
||
}
|
||
},
|
||
submitHandler: function (form) {
|
||
var $postData = $(form).serialize();
|
||
var $list = $('.donation_list_<?php echo $pec_id; ?>');
|
||
var $msg = $('#msg_<?php echo $pec_id; ?>');
|
||
|
||
$msg.slideUp(750, function () {
|
||
$msg.hide();
|
||
|
||
$.post($(form).attr('action'), $postData + '&ajax=1', function (data) {
|
||
$msg.slideUp(750, function () {
|
||
$msg.hide();
|
||
$msg.html(data.message);
|
||
$msg.slideDown('slow');
|
||
});
|
||
$body.stop().animate({
|
||
scrollTop: ($msg.offset().top - 100)
|
||
}, 1500);
|
||
}, 'json');
|
||
|
||
return false;
|
||
});
|
||
}
|
||
});
|
||
<?php
|
||
}
|
||
}
|
||
}
|
||
}
|
||
// LOGS
|
||
if (isset($arrFormsLogSettings)) {
|
||
foreach ($arrFormsLogSettings as $array) {
|
||
foreach ($array as $pec_id => $forms) {
|
||
foreach ($forms as $form) {
|
||
?>
|
||
$('#<?php echo $form; ?>')
|
||
.validate({
|
||
rules: {
|
||
montant: {
|
||
number: true
|
||
}
|
||
},
|
||
messages: {
|
||
montant: {
|
||
required: "<?php afficheTexte('objectifs_dons_validation-montant-required'); ?>",
|
||
number: "<?php afficheTexte('objectifs_dons_validation-montant-number'); ?>",
|
||
min: "<?php afficheTexte('objectifs_dons_validation-montant-minlength'); ?>"
|
||
}
|
||
},
|
||
submitHandler: function (form) {
|
||
var $postData = $(form).serialize();
|
||
var $list = $('.log_settings_list_<?php echo $pec_id; ?>');
|
||
var $msg = $list.prev();
|
||
|
||
$.post($(form).attr('action'), $postData + '&ajax=1', function (data) {
|
||
$msg.slideUp(750, function () {
|
||
$msg.html(data.message);
|
||
$msg.slideDown('slow');
|
||
});
|
||
$body.stop().animate({
|
||
scrollTop: ($msg.offset().top - 100)
|
||
}, 1500);
|
||
}, 'json');
|
||
|
||
return false;
|
||
}
|
||
});
|
||
<?php
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
if (isset($arrFormsAddLogs)) {
|
||
foreach ($arrFormsAddLogs as $array) {
|
||
foreach ($array as $pec_id => $forms) {
|
||
foreach ($forms as $form) {
|
||
?>
|
||
$('#<?php echo $form; ?>')
|
||
.validate({
|
||
rules: {},
|
||
messages: {
|
||
rlq_distance: {
|
||
required: "<?php afficheTexte('rlq_distance_validation-montant-required'); ?>",
|
||
number: "<?php afficheTexte('rlq_distance_validation-montant-required'); ?>"
|
||
},
|
||
rlq_date: {
|
||
required: "<?php afficheTexte('objectifs_dons_validation-montant-required'); ?>"
|
||
}
|
||
},
|
||
submitHandler: function (form) {
|
||
var $postData = $(form).serialize();
|
||
var $list = $('.log_list_<?php echo $pec_id; ?>');
|
||
var $msg = $('#msg_<?php echo $pec_id; ?>');
|
||
|
||
$.post($(form).attr('action'), $postData + '&ajax=1', function ($result) {
|
||
if ($result.state == 'success') {
|
||
$(form).trigger("reset");
|
||
$list.prev().slideUp(750, function () {
|
||
$list.prev().hide();
|
||
$list.prev().html($result.message);
|
||
$list.prev().slideDown('slow');
|
||
});
|
||
$body.stop().animate({
|
||
scrollTop: ($list.prev().offset().top - 100)
|
||
}, 1500);
|
||
|
||
$list.slideUp(750, function () {
|
||
$list.hide();
|
||
$list.html($result.liste);
|
||
$list.slideDown('slow');
|
||
});
|
||
} else {
|
||
$list.prev().slideUp(750, function () {
|
||
$list.prev().hide();
|
||
$list.prev().html($result.message);
|
||
$list.prev().slideDown('slow');
|
||
});
|
||
$body.stop().animate({
|
||
scrollTop: ($list.prev().offset().top - 100)
|
||
}, 1500);
|
||
}
|
||
}, 'json');
|
||
return false;
|
||
}
|
||
});
|
||
<?php
|
||
}
|
||
}
|
||
}
|
||
}
|
||
?>
|
||
$body.on("click", ".btn_delete_log_course", function () {
|
||
var $id = $(this).data('rlq_id');
|
||
var $list = $(this).closest('div.log_list');
|
||
|
||
bootbox.confirm({
|
||
title: "Confirmation",
|
||
message: "<?php if ($strLangue == 'fr') { ?>Êtes-vous certain de vouloir effacer cette entrée ?<?php } else { ?>Are you sure you want to delete this entry?<?php } ?>",
|
||
buttons: {
|
||
confirm: {
|
||
label: '<?php if ($strLangue == 'fr') { ?>Oui<?php } else { ?>Yes<?php } ?>',
|
||
className: 'btn btn-success rounded-0'
|
||
},
|
||
cancel: {
|
||
label: '<?php if ($strLangue == 'fr') { ?>Non<?php } else { ?>No<?php } ?>',
|
||
className: 'btn btn-danger rounded-0'
|
||
}
|
||
},
|
||
callback: function (result) {
|
||
if (result === true) {
|
||
$.post('<?php echo $vDomaine; ?>/ajax_logs_course.php', 'a=<?php echo urlencode(base64_encode('del')); ?>&id=' + $id + '&lang=<?php echo $strLangue; ?>&ajax=1', function ($result) {
|
||
if ($result.state == 'success') {
|
||
$list.prev().slideUp(750, function () {
|
||
$list.prev().hide();
|
||
$list.prev().html($result.message);
|
||
$list.prev().slideDown('slow');
|
||
});
|
||
$body.stop().animate({
|
||
scrollTop: ($list.prev().offset().top - 100)
|
||
}, 1500);
|
||
|
||
$lis.slideUp(750, function () {
|
||
$list.hide();
|
||
$list.html($result.liste);
|
||
$list.slideDown('slow');
|
||
});
|
||
} else {
|
||
$list.prev().slideUp(750, function () {
|
||
$list.prev().hide();
|
||
$list.prev().html($result.message);
|
||
$list.prev().slideDown('slow');
|
||
});
|
||
$body.stop().animate({
|
||
scrollTop: ($list.prev().offset().top - 100)
|
||
}, 1500);
|
||
}
|
||
}, 'json');
|
||
}
|
||
}
|
||
});
|
||
});
|
||
<?php
|
||
/*************
|
||
* ADHÉSIONS *
|
||
**************/
|
||
if (isset($arrFormsMembership) && count($arrFormsMembership) > 0) {
|
||
foreach ($arrFormsMembership as $strNumeroMembership) {
|
||
?>
|
||
const form_<?php echo $strNumeroMembership; ?> = $('#frm_membership_<?php echo $strNumeroMembership; ?>');
|
||
const validator_<?php echo $strNumeroMembership; ?> = form_<?php echo $strNumeroMembership; ?>.validate({
|
||
rules: {},
|
||
messages: {},
|
||
errorPlacement: function (error, element) {
|
||
error.appendTo(element.parent("div"));
|
||
},
|
||
submitHandler: function (form) {
|
||
var postData = new FormData(form);
|
||
var msg = $('.msg_<?php echo $strNumeroMembership; ?>');
|
||
//window.location.href = $(form).attr('action') + '?' + $postData;
|
||
$.ajax({
|
||
url: $(form).attr('action'),
|
||
type: "POST",
|
||
data: postData,
|
||
dataType: 'json',
|
||
contentType: false,
|
||
cache: false,
|
||
processData: false,
|
||
beforeSend: function () {
|
||
msg.fadeOut();
|
||
$preloader.show();
|
||
},
|
||
success: function (result) {
|
||
if (result.state == 'success') {
|
||
window.location.href = '<?php echo $vDomaine . '/' . afficheTexte('adhesions_link_retour_url', 0) . '?no=' . $strNumeroMembership; ?>';
|
||
} else {
|
||
msg.html(result.message).fadeIn();
|
||
scrollToTop();
|
||
$preloader.hide();
|
||
}
|
||
},
|
||
error: function (e) {
|
||
msg.html(e.responseText).fadeIn();
|
||
scrollToTop();
|
||
$preloader.hide();
|
||
}
|
||
});
|
||
return false;
|
||
}
|
||
});
|
||
<?php
|
||
}
|
||
}
|
||
|
||
if (isset($arrCalMembership) && count($arrCalMembership) > 0) {
|
||
foreach ($arrCalMembership as $array) {
|
||
?>
|
||
const <?php echo $array[0]; ?> =
|
||
document.querySelector('#<?php echo $array[0]; ?>');
|
||
flatpickr(<?php echo $array[0]; ?>, {
|
||
<?php
|
||
if (isset($array[1]) && count($array[1]) > 0) {
|
||
$tabParam = $array[1];
|
||
|
||
foreach ($tabParam as $strParam => $strValue) {
|
||
echo $strParam . ': ' . $strValue . ',';
|
||
}
|
||
}
|
||
?>
|
||
allowInput: true,
|
||
clickOpens: false,
|
||
locale: '<?php echo $strLangue; ?>',
|
||
position: 'auto right',
|
||
positionElement: <?php echo $array[0]; ?>,
|
||
wrap: true
|
||
});
|
||
<?php
|
||
}
|
||
}
|
||
if (isset($arrTelMembership) && count($arrTelMembership) > 0) {
|
||
foreach ($arrTelMembership as $strInput) {
|
||
?>
|
||
$('#<?php echo $strInput; ?>').mask('000-000-0000');
|
||
<?php
|
||
}
|
||
}
|
||
|
||
if (isset($strValidationMembership))
|
||
echo $strValidationMembership;
|
||
?>
|
||
$body.on("click", ".btn_delete_file_membership", function () {
|
||
var no = $(this).data('no');
|
||
var mq = $(this).data('mq');
|
||
var mr = $(this).data('mr');
|
||
|
||
bootbox.confirm({
|
||
title: "<?php afficheTexte('confirm-title', 1, 1, 1); ?>",
|
||
message: "<?php echo afficheTexte('confirm-adhesions-delete', 0) ?>",
|
||
buttons: {
|
||
confirm: {
|
||
label: '<?php afficheTexte('confirm-btn-confirm', 1, 1, 1); ?>',
|
||
className: 'btn btn-success rounded-0'
|
||
},
|
||
cancel: {
|
||
label: '<?php afficheTexte('confirm-btn-cancel', 1, 1, 1); ?>',
|
||
className: 'btn btn-danger rounded-0'
|
||
}
|
||
},
|
||
callback: function (result) {
|
||
if (result === true) {
|
||
$.post('<?php echo $vDomaine; ?>/ajax_compte.php', 'a=<?php echo urlencode('membership_delete_file'); ?>&no=' + no + '&mq=' + mq + '&mr=' + mr + '&lng=<?php echo $strLangue; ?>&ajax=1', function ($result) {
|
||
if ($result.state == 'success') {
|
||
window.location.href = '<?php echo $vDomaine . '/' . afficheTexte('adhesions_link_retour_url', 0) . '?no='; ?>' + no;
|
||
} else {
|
||
msg.html(result.message).fadeIn();
|
||
scrollToTop();
|
||
}
|
||
}, 'json');
|
||
}
|
||
}
|
||
});
|
||
});
|
||
<?php
|
||
/*********************
|
||
* TALEAU PROMOTEUR *
|
||
*********************/
|
||
?>
|
||
$body.on("click", ".btn_qte", function () {
|
||
var int_epr_id = $(this).data('epr_id');
|
||
var int_qte = $("#qte_restante_" + int_epr_id).val();
|
||
|
||
if (int_qte >= 0) {
|
||
$preloader_text.html('<?php afficheTexte('preloader_wait', 1, 0, 1); ?>');
|
||
$preloader.show();
|
||
// alert('<?php echo $vDomaine; ?>/ajax_promoteur.php?a=qte&epr_id=' + int_epr_id + '&qte=' + int_qte + '&lang=<?php echo $strLangue; ?>');
|
||
|
||
$.post('<?php echo $vDomaine; ?>/ajax_promoteur.php', 'a=qte&epr_id=' + int_epr_id + '&qte=' + int_qte + '&lang=<?php echo $strLangue; ?>', function ($result) {
|
||
|
||
|
||
if ($result.state == 'success') {
|
||
let array = $result.data;
|
||
// console.log(array);
|
||
|
||
for (let epr_id in array) {
|
||
|
||
if (epr_id == 'total') {
|
||
$('#qte_origine_total').text(array[epr_id]['qte_origine_total']);
|
||
$('#qte_restante_total').text(array[epr_id]['qte_restante_total']);
|
||
$('#qte_inscrits_total').text(array[epr_id]['qte_inscrits_total']);
|
||
$('#qte_courante_total').text(array[epr_id]['qte_courante_total']);
|
||
$('#qte_ajustement_total').text(array[epr_id]['qte_ajustement_total']);
|
||
|
||
} else {
|
||
$('#qte_origine_' + epr_id).text(array[epr_id]['qte_origine']);
|
||
$('#qte_restante_' + epr_id).val(array[epr_id]['qte_restante']);
|
||
|
||
|
||
$('#qte_inscrits_' + epr_id).text(array[epr_id]['qte_inscrits']);
|
||
$('#qte_courante_' + epr_id).text(array[epr_id]['qte_courante']);
|
||
$('#qte_ajustement_' + epr_id).text(array[epr_id]['qte_ajustement']);
|
||
$('#qte_checkin_' + epr_id).text(array[epr_id]['qte_checkin']);
|
||
|
||
let dispoBadge = document.querySelector('.epr-row[data-epr-id="' + epr_id + '"] .epr-header-summary--dispo');
|
||
if (dispoBadge && array[epr_id]['qte_restante'] !== undefined) {
|
||
let labelParts = dispoBadge.textContent.split(':');
|
||
let label = labelParts.length > 1 ? labelParts[0].trim() : 'Disponibles';
|
||
dispoBadge.textContent = label + ' : ' + array[epr_id]['qte_restante'];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}, 'json');
|
||
|
||
$preloader.fadeOut('slow');
|
||
} else {
|
||
bootbox.alert({
|
||
title: "<?php afficheTexte('alert-title', 1, 1, 1); ?>",
|
||
message: "<?php afficheTexte('promoteur_bad_qte_update'); ?>",
|
||
buttons: {
|
||
ok: {
|
||
label: '<?php afficheTexte('alert-btn-ok', 1, 1, 1); ?>',
|
||
className: 'btn btn-primary rounded-0'
|
||
}
|
||
},
|
||
callback: function (result) {
|
||
if (result === true) {
|
||
|
||
}
|
||
}
|
||
});
|
||
}
|
||
});
|
||
|
||
$body.on("click", ".btn_bib", function () {
|
||
var str_action = $(this).data('action');
|
||
var int_epr_id = $(this).data('epr_id');
|
||
|
||
switch (str_action) {
|
||
case 'no_equipe':
|
||
case 'no_bib':
|
||
int_par_id = $(this).data('par_id');
|
||
int_pec_id = $(this).data('pec_id');
|
||
int_eve_id = $(this).data('eve_id');
|
||
|
||
if (str_action == 'no_bib') {
|
||
str_new_no_bib = $("#txt_no_bib_p" + int_par_id).val();
|
||
} else if (str_action == 'no_equipe') {
|
||
str_new_no_bib = $("#txt_no_bib_e" + int_par_id).val();
|
||
}
|
||
|
||
/*bootbox.confirm({
|
||
title: "<?php afficheTexte('confirm-title', 1, 1, 1); ?>",
|
||
message: "<?php afficheTexte('promoteur_bib_manual'); ?>",
|
||
buttons: {
|
||
confirm: {
|
||
label: '<?php afficheTexte('confirm-btn-confirm', 1, 1, 1); ?>',
|
||
className: 'btn btn-success rounded-0'
|
||
},
|
||
cancel: {
|
||
label: '<?php afficheTexte('confirm-btn-cancel', 1, 1, 1); ?>',
|
||
className: 'btn btn-danger rounded-0'
|
||
}
|
||
},
|
||
callback: function (result) {
|
||
if (result === true) {*/
|
||
$preloader_text.html('<?php afficheTexte('preloader_wait', 1, 0, 1); ?>');
|
||
$preloader.show();
|
||
|
||
$.post('<?php echo $vDomaine; ?>/ajax_promoteur.php', 'a=' + str_action + '&eve_id=' + int_eve_id + '&new_no_bib=' + str_new_no_bib + '&pec_id=' + int_pec_id + '&epr_id=' + int_epr_id + '&par_id=' + int_par_id + '&lang=<?php echo $strLangue; ?>', function ($result) {
|
||
|
||
if ($result.state == 'success') {
|
||
/*bootbox.alert({
|
||
title: "<?php afficheTexte('alert-title', 1, 1, 1); ?>",
|
||
message: "<?php afficheTexte('promoteur_bib_manuel'); ?>",
|
||
buttons: {
|
||
ok: {
|
||
label: '<?php afficheTexte('alert-btn-ok', 1, 1, 1); ?>',
|
||
className: 'btn btn-primary rounded-0'
|
||
}
|
||
},
|
||
callback: function (result) {
|
||
if (result === true) {
|
||
|
||
}
|
||
}
|
||
});*/
|
||
}
|
||
}, 'json');
|
||
|
||
$preloader.fadeOut('slow');
|
||
/*}
|
||
}
|
||
});*/
|
||
break;
|
||
case 'edit':
|
||
$("#row_action_" + int_epr_id).val('defaut');
|
||
if ($("#num_bib_range_start_" + int_epr_id).prop('disabled')) {
|
||
$(this).html('<i class="fa fa-times" aria-hidden="true"></i>');
|
||
$(this).tooltip('dispose');
|
||
$(this).prop('title', '<?php afficheTexte('promoteur_bib_close'); ?>');
|
||
$(this).tooltip();
|
||
|
||
$("#num_bib_range_start_" + int_epr_id).prop('disabled', false);
|
||
$("#num_bib_range_finish_dispo_" + int_epr_id).prop('disabled', false);
|
||
$("#num_dernier_dossard_" + int_epr_id).prop('disabled', false);
|
||
$("#num_dernier_dossard_" + int_epr_id).prop('readonly', true);
|
||
$("#sel_assignment_type_" + int_epr_id).prop('disabled', false);
|
||
|
||
// afficher le bouton "assigner"
|
||
$("#btn_bib_assign_" + int_epr_id).show();
|
||
$("#btn_bib_delete_" + int_epr_id).show();
|
||
|
||
$("#bib_options_bibandteam_" + int_epr_id).show();
|
||
$("#bib_options_fromlast_" + int_epr_id).show();
|
||
|
||
$("#num_bib_range_start_" + int_epr_id).focus();
|
||
} else {
|
||
$("#bib_options_bibandteam_" + int_epr_id).hide();
|
||
$("#bib_options_fromlast_" + int_epr_id).hide();
|
||
|
||
$(this).html('<i class="fa fa-pencil-square-o" aria-hidden="true"></i>');
|
||
$(this).tooltip('dispose');
|
||
$(this).prop('title', '<?php afficheTexte('promoteur_bib_edit'); ?>');
|
||
$(this).tooltip();
|
||
|
||
$("#num_bib_range_start_" + int_epr_id).prop('disabled', true);
|
||
$("#num_bib_range_finish_dispo_" + int_epr_id).prop('disabled', true);
|
||
$("#num_dernier_dossard_" + int_epr_id).prop('disabled', true);
|
||
$("#num_dernier_dossard_" + int_epr_id).prop('readonly', false);
|
||
$("#sel_assignment_type_" + int_epr_id).prop('disabled', true);
|
||
|
||
// afficher le bouton "assigner"
|
||
$("#btn_bib_assign_" + int_epr_id).hide();
|
||
$("#btn_bib_delete_" + int_epr_id).hide();
|
||
}
|
||
break;
|
||
case 'assign':
|
||
|
||
var range_start = parseInt($("#num_bib_range_start_" + int_epr_id).val());
|
||
var qty_booked = parseInt($("#qty_booked_" + int_epr_id).html());
|
||
|
||
if ($("#num_bib_range_start_" + int_epr_id).val() == '' ||
|
||
$("#num_bib_range_finish_dispo_" + int_epr_id).val() == '') {
|
||
bootbox.alert({
|
||
title: "<?php afficheTexte('alert-title', 1, 1, 1); ?>",
|
||
message: "<?php afficheTexte('promoteur_bib_no_range_start'); ?>",
|
||
buttons: {
|
||
ok: {
|
||
label: '<?php afficheTexte('alert-btn-ok', 1, 1, 1); ?>',
|
||
className: 'btn btn-primary rounded-0'
|
||
}
|
||
},
|
||
callback: function (result) {
|
||
if (result === true) {
|
||
$("#num_bib_range_start_" + int_epr_id).focus();
|
||
}
|
||
}
|
||
});
|
||
} else {
|
||
bootbox.confirm({
|
||
title: "<?php afficheTexte('confirm-title', 1, 1, 1); ?>",
|
||
message: "<?php afficheTexte('promoteur_bib_assign');?>",
|
||
buttons: {
|
||
confirm: {
|
||
label: '<?php afficheTexte('confirm-btn-confirm', 1, 1, 1); ?>',
|
||
className: 'btn btn-success rounded-0'
|
||
},
|
||
cancel: {
|
||
label: '<?php afficheTexte('confirm-btn-cancel', 1, 1, 1); ?>',
|
||
className: 'btn btn-danger rounded-0'
|
||
}
|
||
},
|
||
callback: function (result) {
|
||
if (result === true) {
|
||
$("#frm_bib_" + int_epr_id).submit();
|
||
}
|
||
}
|
||
});
|
||
}
|
||
break;
|
||
case 'delete':
|
||
int_eve_id = $(this).data('eve_id');
|
||
|
||
bootbox.confirm({
|
||
title: "<?php afficheTexte('confirm-title', 1, 1, 1); ?>",
|
||
message: "<?php afficheTexte('promoteur_bib_reset'); ?>",
|
||
buttons: {
|
||
confirm: {
|
||
label: '<?php afficheTexte('confirm-btn-confirm', 1, 1, 1); ?>',
|
||
className: 'btn btn-success rounded-0'
|
||
},
|
||
cancel: {
|
||
label: '<?php afficheTexte('confirm-btn-cancel', 1, 1, 1); ?>',
|
||
className: 'btn btn-danger rounded-0'
|
||
}
|
||
},
|
||
callback: function (result) {
|
||
if (result === true) {
|
||
document.location.href = '<?php echo $vDomaine . $strPage ?>/bib_assignment?a=reset&epr_id=' + int_epr_id + '&promoteur_eve_id=' + int_eve_id;
|
||
}
|
||
}
|
||
});
|
||
break;
|
||
case 'view':
|
||
var int_bib_type = $(this).data('bib_type');
|
||
$("#row_action_" + int_epr_id).val('view');
|
||
// MSIN-4148
|
||
// document.location.href = '<?php echo $vDomaine . $strPage ?>/bib_assignment?a=view&type=' + int_bib_type + '&epr_id=' + int_epr_id;
|
||
document.location.href = '<?php echo $vDomaine . $strPage ?>/bib_assignment?type=' + int_bib_type + '&epr_id=' + int_epr_id;
|
||
break;
|
||
}
|
||
});
|
||
|
||
(function () {
|
||
var pendingStatutXhr = null;
|
||
var lastStatutParId = null;
|
||
|
||
$('.inscr-mobile-statut-select').each(function () {
|
||
$(this).data('prev', $(this).val());
|
||
});
|
||
|
||
$body.on('change', '.inscr-mobile-statut-select', function () {
|
||
var $select = $(this);
|
||
var $block = $select.closest('.inscr-mobile-field-block--statut');
|
||
var intParId = $select.data('par_id');
|
||
var strCode = $select.val();
|
||
var strPrev = $select.data('prev');
|
||
|
||
if (!intParId || !strCode) {
|
||
return;
|
||
}
|
||
|
||
if (pendingStatutXhr && lastStatutParId === intParId) {
|
||
pendingStatutXhr.abort();
|
||
}
|
||
lastStatutParId = intParId;
|
||
$block.removeClass('inscr-mobile-statut--saved inscr-mobile-statut--error');
|
||
|
||
$preloader_text.html('<?php afficheTexte('preloader_wait', 1, 0, 1); ?>');
|
||
$preloader.show();
|
||
|
||
pendingStatutXhr = $.post('<?php echo $vDomaine; ?>/ajax_promoteur.php', {
|
||
a: 'par_statut_course',
|
||
par_id: intParId,
|
||
par_statut_course: strCode,
|
||
lang: '<?php echo $strLangue; ?>'
|
||
}, function (result) {
|
||
pendingStatutXhr = null;
|
||
$preloader.fadeOut('slow');
|
||
if (result && result.state === 'success') {
|
||
$select.data('prev', strCode);
|
||
$block.addClass('inscr-mobile-statut--saved');
|
||
window.setTimeout(function () {
|
||
$block.removeClass('inscr-mobile-statut--saved');
|
||
}, 1200);
|
||
} else {
|
||
$select.val(strPrev);
|
||
$block.addClass('inscr-mobile-statut--error');
|
||
}
|
||
}, 'json').fail(function () {
|
||
pendingStatutXhr = null;
|
||
$preloader.fadeOut('slow');
|
||
$select.val(strPrev);
|
||
$block.addClass('inscr-mobile-statut--error');
|
||
});
|
||
});
|
||
})();
|
||
|
||
$('#modal_teammates').on('show.bs.modal', function (event) {
|
||
var button = $(event.relatedTarget);
|
||
var modal = $(this);
|
||
var int_pec_id = button.data('pec_id');
|
||
var int_epr_id = button.data('epr_id');
|
||
var int_eve_id = button.data('eve_id');
|
||
|
||
$.post('<?php echo $vDomaine; ?>/ajax_promoteur.php', 'a=teammates&eve_id=' + int_eve_id + '&pec_id=' + int_pec_id + '&epr_id=' + int_epr_id + '&lang=<?php echo $strLangue; ?>', function ($result) {
|
||
if ($result.state == 'success') {
|
||
modal.find('.modal-title').text($result.team);
|
||
modal.find('.modal-body').html($result.members);
|
||
} else {
|
||
modal.find('.modal-title').text($result.state);
|
||
modal.find('.modal-body').html('');
|
||
}
|
||
}, 'json');
|
||
});
|
||
<?php
|
||
break;
|
||
case 'reserver.php':
|
||
if (($tabEvenement['general']['eve_epreuve_modifiable'] == 1 || $tabEvenement['general']['eve_epreuve_modifiable_client'] == 1) && $strAction == 'mod' && !isset($_SESSION['no_panier']) && fxCheckAccesEpreuve('mod', $intEpreuve, $tabEvenement['general']['eve_id'], $_GET['pec_id'], $_GET['promoteur'], '')) { // si le promoteur ou le participant peut changer l'épreuve
|
||
?>
|
||
$("#sel_epreuve").change(function () {
|
||
$("#btn_changer_epreuve").show();
|
||
$("#btn_changer_epreuve_cancel").show();
|
||
$("#new_epr_id").val($(this).val());
|
||
});
|
||
$("#btn_changer_epreuve_cancel").click(function () {
|
||
$("#div_btn").hide();
|
||
window.location.reload(true);
|
||
});
|
||
$("#btn_changer_epreuve").click(function () {
|
||
var strPage = '<?php if ($strLangue == 'fr') {
|
||
echo 'reserver';
|
||
} else {
|
||
echo 'book';
|
||
} ?>';
|
||
|
||
var strUrl = $("#eve_label_url").val();
|
||
var strPromoteur = '<?php if (!empty($_GET['promoteur']) && $_GET['promoteur'] == 1) {
|
||
echo '&promoteur=1';
|
||
} else {
|
||
echo '';
|
||
} ?>';
|
||
//sl
|
||
// alert('<?php echo $vDomaine?>/' + strPage + '/' + strUrl + '/' + $("#sel_epreuve").val() + '?action=mod&switch=true' + strPromoteur + '&pec_id=<?php echo $_GET['pec_id']; ?>');
|
||
document.location.href = '<?php echo $vDomaine?>/' + strPage + '/' + strUrl + '/' + $("#sel_epreuve").val() + '?action=mod&switch=true' + strPromoteur + '&pec_id=<?php echo $_GET['pec_id']; ?>';
|
||
});
|
||
$("#frm_participant").valid();
|
||
<?php
|
||
}
|
||
?>
|
||
$(".delete_fichier").click(function () {
|
||
var $no_panier = $(this).data('no_panier');
|
||
var $panier = $(this).data('panier');
|
||
var $file = $(this).data('file');
|
||
var $id = $(this).data('id');
|
||
|
||
bootbox.confirm({
|
||
title: "Confirmation",
|
||
message: "<?php if ($strLangue == 'fr') { ?>Êtes-vous certain de vouloir effacer ce fichier?<?php } else { ?>Are you sure you want to this file?<?php } ?>",
|
||
buttons: {
|
||
confirm: {
|
||
label: '<?php afficheTexte('confirm-btn-confirm', 1, 1, 1); ?>',
|
||
className: 'btn btn-success rounded-0'
|
||
},
|
||
cancel: {
|
||
label: '<?php afficheTexte('confirm-btn-cancel', 1, 1, 1); ?>',
|
||
className: 'btn btn-danger rounded-0'
|
||
}
|
||
},
|
||
callback: function (result) {
|
||
if (result === true) {
|
||
$.post('<?php echo $vDomaine; ?>/ajax_file.php', 'no_panier=' + $no_panier + '&panier=' + $panier + '&file=' + $file + '&id=' + $id, function ($result) {
|
||
if ($result.state != 'error') {
|
||
window.location.reload(true);
|
||
}
|
||
}, 'json');
|
||
}
|
||
}
|
||
});
|
||
});
|
||
<?php
|
||
break;
|
||
case 'panier.php':
|
||
switch ($strStep) {
|
||
case 'somaire':
|
||
?>
|
||
$('#btn_empty').click(function () {
|
||
bootbox.confirm({
|
||
title: "<?php afficheTexte('confirm-empty-cart -title'); ?>",
|
||
message: "<?php afficheTexte('confirm-empty-cart -message'); ?>",
|
||
buttons: {
|
||
confirm: {
|
||
label: '<?php afficheTexte('confirm-empty-cart -btn-confirm'); ?>',
|
||
className: 'btn btn-success rounded-0'
|
||
},
|
||
cancel: {
|
||
label: '<?php afficheTexte('confirm-empty-cart -btn-cancel'); ?>',
|
||
className: 'btn btn-danger rounded-0'
|
||
}
|
||
},
|
||
callback: function (result) {
|
||
if (result === true) {
|
||
document.location.href = '<?php echo $vDomaine; ?>/vider_panier.php';
|
||
}
|
||
}
|
||
});
|
||
});
|
||
<?php
|
||
break;
|
||
case 'checkout':
|
||
?>
|
||
var $frm_panier = $('#frm_panier');
|
||
|
||
$frm_panier.validate({
|
||
rules: {
|
||
ccnumber: {
|
||
required: true,
|
||
digits: true,
|
||
minlength: 16
|
||
},
|
||
ccmonth: "required",
|
||
ccyear: "required",
|
||
cvv: {
|
||
required: true,
|
||
digits: true,
|
||
minlength: 3
|
||
}
|
||
},
|
||
messages: {
|
||
ccnumber: {
|
||
required: "<?php afficheTexte('checkout_validation-ccnumber-required'); ?>",
|
||
digits: "<?php afficheTexte('checkout_validation-ccnumber-digits'); ?>",
|
||
minlength: "<?php afficheTexte('checkout_validation-ccnumber-minlength'); ?>"
|
||
},
|
||
ccmonth: "<?php afficheTexte('checkout_validation-ccmonth-required'); ?>",
|
||
ccyear: "<?php afficheTexte('checkout_validation-ccyear-required'); ?>",
|
||
cvv: {
|
||
required: "<?php afficheTexte('checkout_validation-cvv-required'); ?>",
|
||
digits: "<?php afficheTexte('checkout_validation-cvv-digits'); ?>",
|
||
minlength: "<?php afficheTexte('checkout_validation-cvv-minlength'); ?>"
|
||
}
|
||
},
|
||
errorLabelContainer: $(".form-message")
|
||
});
|
||
|
||
var $card_mc = $('#card_mc');
|
||
var $card_visa = $('#card_visa');
|
||
|
||
/* $('#ccnumber').validateCreditCard(function(result) {
|
||
$card_mc.removeClass();
|
||
$card_visa.removeClass();
|
||
|
||
if (result.card_type != null) {
|
||
if (result.valid) {
|
||
$(this).removeClass();
|
||
|
||
switch (result.card_type.name) {
|
||
case 'visa':
|
||
$card_visa.addClass('active');
|
||
$card_mc.addClass('inactive');
|
||
break;
|
||
case 'mastercard':
|
||
$card_visa.addClass('inactive');
|
||
$card_mc.addClass('active');
|
||
break;
|
||
}
|
||
} else {
|
||
$(this).addClass('error');
|
||
$("#form_message").html('Mauvais type de carte!');
|
||
}
|
||
}
|
||
}, {
|
||
accept: ['visa', 'mastercard']
|
||
}); */
|
||
|
||
$('#btn_prev').click(function () {
|
||
document.location.href = '<?php echo $vDomaine; ?>/<?php echo $strPage; ?>/somaire/<?php echo $tabEvenement['general']['eve_label_url']?>';
|
||
});
|
||
|
||
$('#btn_cancel').click(function () {
|
||
bootbox.confirm({
|
||
title: "<?php afficheTexte('confirm-cancel-order-title'); ?>",
|
||
message: "<?php afficheTexte('confirm-cancel-order-message'); ?>",
|
||
buttons: {
|
||
confirm: {
|
||
label: '<?php afficheTexte('confirm-cancel-order-btn-confirm'); ?>',
|
||
className: 'btn btn-success rounded-0'
|
||
},
|
||
cancel: {
|
||
label: '<?php afficheTexte('confirm-cancel-order-btn-cancel'); ?>',
|
||
className: 'btn btn-danger rounded-0'
|
||
}
|
||
},
|
||
callback: function (result) {
|
||
if (result === true) {
|
||
document.location.href = '<?php echo $vDomaine; ?>/vider_panier.php';
|
||
}
|
||
}
|
||
});
|
||
});
|
||
|
||
$('#btn_checkout').click(function () {
|
||
if ($frm_panier.valid()) {
|
||
var $termes = $('input.chk_termes[type=checkbox]:not(:checked)');
|
||
|
||
if (!$termes.length) {
|
||
var $preloader = $('#preloader');
|
||
var $preloader_text = $('#preloader_text');
|
||
$preloader_text.html('<?php afficheTexte('preloader_wait', 1, 0, 1); ?>');
|
||
$preloader.show();
|
||
grecaptcha.ready(function () {
|
||
grecaptcha.execute('<?php echo RECAPTCHA_SITE_KEY; ?>', {action: 'achat'}).then(function (token) {
|
||
document.getElementById('g-recaptcha-response').value = token;
|
||
$("#frm_panier").submit();
|
||
$('body').css('cursor', 'wait');
|
||
});
|
||
});
|
||
} else {
|
||
var str_alert = "<?php afficheTexte('terme_accepter') ?>";
|
||
|
||
/*if ($termes.data('pop_up') == 'location_policy') {
|
||
str_alert = $("#chk_location_policy").data('msg') + "\n" + str_alert;
|
||
}*/
|
||
|
||
alert(str_alert);
|
||
}
|
||
} else {
|
||
|
||
alert("<?php afficheTexte('form-credit') ?>");
|
||
}
|
||
});
|
||
<?php
|
||
if (isset($arrTermesModalButtons) && count($arrTermesModalButtons) > 0) {
|
||
foreach($arrTermesModalButtons as $index => $bouton) {
|
||
?>
|
||
var $chk<?php echo $index; ?> = $("#<?php echo str_replace('btn_accept', 'chk', $bouton); ?>");
|
||
var $div<?php echo $index; ?> = $("#<?php echo str_replace('btn_accept', 'div', $bouton); ?>");
|
||
|
||
$("#<?php echo $bouton; ?>").click(function (e) {
|
||
$chk<?php echo $index; ?>.show();
|
||
$chk<?php echo $index; ?>.prop("checked", true);
|
||
$div<?php echo $index; ?>.modal("hide");
|
||
});
|
||
$chk<?php echo $index; ?>.click(function (e) {
|
||
e.preventDefault();
|
||
$div<?php echo $index; ?>.modal("show");
|
||
});
|
||
<?php
|
||
}
|
||
}
|
||
?>
|
||
|
||
|
||
|
||
// MSIN-3855 checkout Create the Card Fields Component and define callbacks
|
||
<?php
|
||
require_once('paypaladv_checkout.php');
|
||
?>
|
||
// fin paypal adv
|
||
|
||
var $creditcard = $("#creditcard");
|
||
<?php
|
||
if ($intPaiement == 0 || $intPaiement == 2) {
|
||
?>
|
||
$creditcard.css("display", "inline");
|
||
<?php
|
||
} else {
|
||
?>
|
||
$creditcard.css("display", "none");
|
||
<?php
|
||
}
|
||
?>
|
||
var $paiment_checked = $("input[name='chk_paiement']:checked");
|
||
var $chk_paiement = $("input[name='chk_paiement']");
|
||
|
||
$chk_paiement.change(function () {
|
||
if ($(this).val() == '2') {
|
||
$("#creditcard").css("display", "inline");
|
||
} else {
|
||
$("#creditcard").css("display", "none");
|
||
}
|
||
});
|
||
|
||
$("input[name='acheteur']").change(function () {
|
||
$preloader_text.html('<?php afficheTexte('preloader_wait', 1, 0, 1); ?>');
|
||
$preloader.show();
|
||
|
||
$.post('<?php echo $vDomaine; ?>/ajax_adresse.php', 'no_panier=<?php echo $_SESSION['no_panier']; ?>&acheteur=' + $(this).val() + '&langue=<?php echo $strLangue; ?>', function ($result) {
|
||
if ($result.state == 'success') {
|
||
$('#adresse_acheteur').html($result.adresse);
|
||
}
|
||
}, 'json');
|
||
|
||
$preloader.fadeOut('slow');
|
||
});
|
||
<?php
|
||
break;
|
||
}
|
||
break;
|
||
case 'evenements.php':
|
||
if (isset($blnPopup) && $blnPopup) {
|
||
?>
|
||
var now, lastTimePopupShowed;
|
||
now = +new Date();
|
||
|
||
if (localStorage.getItem('lastTimePopupShowed') !== null) {
|
||
lastTimePopupShowed = localStorage.getItem('lastTimePopupShowed');
|
||
}
|
||
|
||
if (((now - lastTimePopupShowed) >= (5 * 60 * 1000)) || !lastTimePopupShowed) {
|
||
setTimeout(function () {
|
||
$.magnificPopup.open({
|
||
items: {
|
||
src: '#popup-modal',
|
||
type: 'inline'
|
||
},
|
||
closeOnBgClick: false,
|
||
tClose: ''
|
||
});
|
||
}, 1500);
|
||
|
||
localStorage.setItem('lastTimePopupShowed', now);
|
||
}
|
||
<?php
|
||
}
|
||
break;
|
||
case 'dons.php': #dons2017 #MSIN-1987
|
||
if ($strDonation != '' && isset($tabRules) && isset($tabMessages)) {
|
||
?>
|
||
|
||
var $form = $("#frm_dons");
|
||
|
||
var validator = $form.validate({
|
||
ignore: ".ignore,:hidden:not(input[type='hidden'])",
|
||
rules: {
|
||
txt_don: {
|
||
required: true,
|
||
min: 1
|
||
},
|
||
ccnumber: {
|
||
required: true,
|
||
digits: true,
|
||
minlength: 16
|
||
},
|
||
ccmonth: "required",
|
||
ccyear: "required",
|
||
cvv: {
|
||
required: true,
|
||
digits: true,
|
||
minlength: 3
|
||
},
|
||
<?php echo implode(',', $tabRules); ?>
|
||
},
|
||
messages: {
|
||
sel_don: "<?php if ($strLangue == 'fr') { ?>Veuillez entrer une valeur<?php } else { ?>Please enter a value<?php } ?>",
|
||
txt_don: {
|
||
required: "<?php if ($strLangue == 'fr') { ?>Veuillez entrer une valeur<?php } else { ?>Please enter a value<?php } ?>",
|
||
min: "<?php if ($strLangue == 'fr') { ?>Veuillez entrer une valeur plus grande que 0<?php } else { ?>Please enter a value greater than 0<?php } ?>"
|
||
},
|
||
sel_recu: "<?php if ($strLangue == 'fr') { ?>Veuillez entrer une valeur<?php } else { ?>Please enter a value<?php } ?>",
|
||
sel_anonyme: "<?php if ($strLangue == 'fr') { ?>Veuillez entrer une valeur<?php } else { ?>Please enter a value<?php } ?>",
|
||
ccnumber: {
|
||
required: "<?php afficheTexte('checkout_validation-ccnumber-required'); ?>",
|
||
digits: "<?php afficheTexte('checkout_validation-ccnumber-digits'); ?>",
|
||
minlength: "<?php afficheTexte('checkout_validation-ccnumber-minlength'); ?>"
|
||
},
|
||
ccmonth: "<?php afficheTexte('checkout_validation-ccmonth-required'); ?>",
|
||
ccyear: "<?php afficheTexte('checkout_validation-ccyear-required'); ?>",
|
||
cvv: {
|
||
required: "<?php afficheTexte('checkout_validation-cvv-required'); ?>",
|
||
digits: "<?php afficheTexte('checkout_validation-cvv-digits'); ?>",
|
||
minlength: "<?php afficheTexte('checkout_validation-cvv-minlength'); ?>"
|
||
},
|
||
<?php echo implode(',', $tabMessages); ?>
|
||
},
|
||
submitHandler: function (form) {
|
||
var $data = $(form).serialize();
|
||
var $montant = 0;
|
||
|
||
if ($('#sel_don').val() == 'other') {
|
||
$montant = $('#txt_don').val();
|
||
} else {
|
||
$montant = $('#sel_don').val();
|
||
}
|
||
|
||
bootbox.confirm({
|
||
title: "<?php afficheTexte('confirm-title'); ?>",
|
||
message: '<?php afficheTexte('confirm-don-message'); ?><div class="h1 my-3">' + $montant + ' $</div>',
|
||
buttons: {
|
||
confirm: {
|
||
label: '<?php afficheTexte('confirm-don-btn-confirm'); ?>',
|
||
className: 'btn btn-success rounded-0'
|
||
},
|
||
cancel: {
|
||
label: '<?php afficheTexte('confirm-don-btn-cancel'); ?>',
|
||
className: 'btn btn-danger rounded-0'
|
||
}
|
||
},
|
||
callback: function (result) {
|
||
if (result === true) {
|
||
var $preloader = $('#preloader');
|
||
var $preloader_text = $('#preloader_text');
|
||
$preloader_text.html('<?php afficheTexte('preloader_wait', 1, 0, 1); ?>');
|
||
$preloader.show();
|
||
$('body').css('cursor', 'wait');
|
||
|
||
form.submit();
|
||
}
|
||
}
|
||
});
|
||
}
|
||
});
|
||
$('#btn_dons').click(function (e) {
|
||
|
||
e.preventDefault();
|
||
|
||
grecaptcha.ready(function () {
|
||
grecaptcha.execute('<?php echo RECAPTCHA_SITE_KEY; ?>', {action: 'donation'}).then(function (token) {
|
||
document.getElementById('g-recaptcha-response').value = token;
|
||
$('#frm_dons').submit();
|
||
});
|
||
});
|
||
});
|
||
var $chk_paiement = $("input[name='chk_paiement']");
|
||
|
||
$chk_paiement.change(function () {
|
||
if ($(this).val() == '2') {
|
||
$("#creditcard").css("display", "inline");
|
||
} else {
|
||
$("#creditcard").css("display", "none");
|
||
}
|
||
});
|
||
<?php
|
||
$intCtr = 1;
|
||
|
||
foreach ($tabCalendriers as $strCalendrier) {
|
||
?>
|
||
$('#<?php echo $strCalendrier; ?>').datepicker({
|
||
showOn: "both",
|
||
buttonImage: '<?php echo $vDomaine; ?>/images/date.png',
|
||
buttonImageOnly: true,
|
||
constrainInput: true,
|
||
changeMonth: true,
|
||
changeYear: true,
|
||
dateFormat: 'yy-mm-dd',
|
||
showMonthAfterYear: true,
|
||
showAnim: 'slideDown',
|
||
yearRange: "<?php echo date('Y', strtotime($tabDates['min_date'])); ?>:<?php echo date('Y', strtotime($tabDates['max_date'])); ?>",
|
||
minDate: "<?php echo $tabDates['min_date']; ?>",
|
||
maxDate: "<?php echo $tabDates['max_date']; ?>",
|
||
onSelect: function (dateText, inst) {
|
||
var datePieces = dateText.split('-');
|
||
var month = datePieces[1];
|
||
var day = datePieces[2];
|
||
var year = datePieces[0];
|
||
$('select#<?php echo $strCalendrier; ?>-month').val(month);
|
||
$('select#<?php echo $strCalendrier; ?>-day').val(day);
|
||
$('select#<?php echo $strCalendrier; ?>-year').val(year);
|
||
validator.element("#<?php echo $strCalendrier; ?>");
|
||
}
|
||
});
|
||
|
||
function checkDays<?php echo $intCtr; ?>() {
|
||
var daysInMonth = new Date($('#<?php echo $strCalendrier; ?>-year').val(), $('#<?php echo $strCalendrier; ?>-month').val(), 0).getDate();
|
||
|
||
if ($('#<?php echo $strCalendrier; ?>-day').val() > daysInMonth) {
|
||
$('#<?php echo $strCalendrier; ?>-day').val(daysInMonth);
|
||
}
|
||
|
||
$('#<?php echo $strCalendrier; ?>-day option:gt(' + (daysInMonth) + ')').attr('disabled', true);
|
||
}
|
||
|
||
function fxSetDateInput<?php echo $intCtr; ?>() { // mettre la date modifiée dans le input du calendrier
|
||
$('#<?php echo $strCalendrier; ?>').val($('#<?php echo $strCalendrier; ?>-year').val() + '-' + $('#<?php echo $strCalendrier; ?>-month').val() + '-' + $('#<?php echo $strCalendrier; ?>-day').val());
|
||
// $('#<?php echo $strCalendrier; ?>').focus();
|
||
}
|
||
|
||
$('#<?php echo $strCalendrier; ?>-year').change(function () {
|
||
$('#<?php echo $strCalendrier; ?>-month option').removeAttr('disabled'); // Enable all months
|
||
|
||
$('#<?php echo $strCalendrier; ?>-month').change(); // Cascade changes
|
||
|
||
checkDays<?php echo $intCtr; ?>(); // Ensure only valid dates
|
||
fxSetDateInput<?php echo $intCtr; ?>();
|
||
validator.element("#<?php echo $strCalendrier; ?>");
|
||
});
|
||
$('#<?php echo $strCalendrier; ?>-month').change(function () {
|
||
$('#<?php echo $strCalendrier; ?>-day option').removeAttr('disabled'); // Enable all days
|
||
|
||
checkDays<?php echo $intCtr; ?>(); // Ensure only valid dates
|
||
fxSetDateInput<?php echo $intCtr; ?>();
|
||
validator.element("#<?php echo $strCalendrier; ?>");
|
||
});
|
||
$('#<?php echo $strCalendrier; ?>-day').change(function () {
|
||
fxSetDateInput<?php echo $intCtr; ?>();
|
||
validator.element("#<?php echo $strCalendrier; ?>");
|
||
});
|
||
<?php
|
||
$intCtr++;
|
||
}
|
||
|
||
if (isset($_SESSION['com_id'])) {
|
||
?>
|
||
change_value_compte();
|
||
<?php
|
||
}
|
||
?>
|
||
$('select').each(function () {
|
||
$(this).bind('change', function (e) {
|
||
//alert($(this).val());
|
||
//validator.resetForm();
|
||
validator.element($(this));
|
||
//validator.form();
|
||
});
|
||
});
|
||
var $last = $('#sel_don');
|
||
var $hidden = $('#div_txt_don');
|
||
var $field = $('#txt_don');
|
||
|
||
if ($last.val() == 'other') {
|
||
$hidden.show();
|
||
$form.valid();
|
||
}
|
||
|
||
$last.bind('change', function (e) {
|
||
$field.val('');
|
||
|
||
if ($last.val() == 'other') {
|
||
$hidden.show();
|
||
} else {
|
||
$hidden.hide();
|
||
}
|
||
|
||
validator.element($field);
|
||
});
|
||
|
||
// MSIN-3855 dons Create the Card Fields Component and define callbacks
|
||
<?php
|
||
require_once('paypaladv_dons.php');
|
||
?>
|
||
// fin paypal adv
|
||
<?php
|
||
}
|
||
break;
|
||
case 'index.php':
|
||
switch ($strCode) {
|
||
case 'contact':
|
||
?>
|
||
var box_details = $('#box_evenement_contact');
|
||
var sel_evenements = $('#sel_evenement_contact');
|
||
|
||
sel_evenements.change(function () {
|
||
let id = sel_evenements.val();
|
||
box_details.hide();
|
||
|
||
//document.location.href = '<?php echo $vDomaine; ?>/ajax_contact.php?a=<?php echo urlencode(base64_encode('contact')); ?>&id=' + id + '&lang=<?php echo $strLangue; ?>';
|
||
$.post('<?php echo $vDomaine; ?>/ajax_contact.php', 'a=<?php echo urlencode(base64_encode('contact')); ?>&id=' + id + '&lang=<?php echo $strLangue; ?>', function (result) {
|
||
box_details.html(result.details);
|
||
}, 'json');
|
||
|
||
box_details.fadeIn('slow');
|
||
});
|
||
|
||
|
||
|
||
|
||
<?php
|
||
}
|
||
break;
|
||
}
|
||
?>
|
||
$.validator.methods.email = function (value, element) {
|
||
return this.optional(element) || /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+\.[a-z]+/.test(value);
|
||
};
|
||
$(".scroll").click(function (event) {
|
||
event.preventDefault();
|
||
var $href = $(this).attr('href');
|
||
var $anchor = $($href).offset();
|
||
$('html, body').animate({scrollTop: $anchor.top}, 500, 'linear');
|
||
});
|
||
$(document).on('scroll', function () {
|
||
if ($(window).scrollTop() >= 200) {
|
||
$('.scroll-top-wrapper').addClass('show');
|
||
} else {
|
||
$('.scroll-top-wrapper').removeClass('show');
|
||
}
|
||
});
|
||
$('.scroll-top-wrapper').on('click', scrollToTop);
|
||
|
||
$preloader.fadeOut();
|
||
});
|
||
var jiraSubmitInProgress = false;
|
||
$(".send_jira").click(function (event) {
|
||
event.preventDefault();
|
||
if (jiraSubmitInProgress) {
|
||
return;
|
||
}
|
||
if (!frm_contact.checkValidity()) {
|
||
alert('Veuillez remplir tous les champs requis correctement.');
|
||
return; // Stopper si le formulaire n'est pas valide
|
||
}
|
||
jira_fx();
|
||
|
||
});
|
||
function jira_fx() {
|
||
const $btn = $('.send_jira');
|
||
const email = $('#txt_courriel').val();
|
||
const nom = $('#txt_nom').val();
|
||
const description = $('#txt_message').val();
|
||
const summary = $('#txt_sujet').val();
|
||
const typedemande = $('#typedemande').val();
|
||
const categorie_interne = $('#typedemande option:selected').data('categorie') || '';
|
||
|
||
jiraSubmitInProgress = true;
|
||
$btn.prop('disabled', true);
|
||
|
||
const postData = {
|
||
request_type: 'check_email',
|
||
email, nom, summary, description, typedemande, categorie_interne
|
||
};
|
||
|
||
return fetch('/ajax_jira.php', {
|
||
method: "POST",
|
||
headers: {
|
||
'Accept': 'application/json',
|
||
'Content-Type': 'application/json'
|
||
},
|
||
body: JSON.stringify(postData)
|
||
})
|
||
.then(async response => {
|
||
const contentType = response.headers.get('content-type') || '';
|
||
if (!response.ok) {
|
||
const errorText = await response.text();
|
||
throw new Error(`Erreur HTTP ${response.status} :\n${errorText}`);
|
||
}
|
||
if (!contentType.includes("application/json")) {
|
||
const text = await response.text();
|
||
throw new Error("Réponse non-JSON :\n" + text);
|
||
}
|
||
return response.json();
|
||
})
|
||
.then(data => {
|
||
console.log('✅ Réponse JSON:', data);
|
||
if (data.success) {
|
||
document.location.href = '/page/contactsend/<?php echo $strLangue; ?>';
|
||
return;
|
||
}
|
||
jiraSubmitInProgress = false;
|
||
$btn.prop('disabled', false);
|
||
})
|
||
.catch(error => {
|
||
console.error("🔥 Erreur AJAX:", error.message);
|
||
jiraSubmitInProgress = false;
|
||
$btn.prop('disabled', false);
|
||
});
|
||
}
|
||
|
||
|
||
// fin
|
||
function fxSetValidation($intCountry) {
|
||
var $strInput = $('#par_telephone1_1');
|
||
if ($intCountry === '1') {
|
||
$("#par_codepostal_1").rules('add', {
|
||
postalCodeCA: true,
|
||
zipcodeUS: false
|
||
});
|
||
console.log('CA');
|
||
$strInput.unmask();
|
||
$strInput.mask('000-000-0000');
|
||
} else if ($intCountry === '234') {
|
||
$("#par_codepostal_1").rules('add', {
|
||
postalCodeCA: false,
|
||
zipcodeUS: true
|
||
});
|
||
console.log('USA');
|
||
$strInput.unmask();
|
||
$strInput.mask('000-000-0000');
|
||
} else {
|
||
$("#par_codepostal_1").rules('add', {
|
||
postalCodeCA: false,
|
||
zipcodeUS: false
|
||
});
|
||
console.log('Autre');
|
||
$strInput.unmask();
|
||
}
|
||
}
|
||
|
||
function scrollToTop() {
|
||
var verticalOffset = typeof (verticalOffset) != 'undefined' ? verticalOffset : 0;
|
||
var element = $('body');
|
||
var offset = element.offset();
|
||
var offsetTop = offset.top;
|
||
$('html, body').animate({scrollTop: offsetTop}, 500, 'linear');
|
||
}
|
||
|
||
// message paypaladvence
|
||
function translateErrorMessage(errorMessage) {
|
||
|
||
switch (errorMessage) {
|
||
case "OnlyVisaandMastercard":
|
||
return "<?php afficheTexte('OnlyVisaandMastercard', 1, 0, 1);?>";
|
||
|
||
case "INVALID_CVV":
|
||
return "<?php afficheTexte('checkout_validation-cvv-digits', 1, 0, 1);?>";
|
||
case "INVALID_NUMBER":
|
||
case "Invalid card number":
|
||
|
||
return "<?php afficheTexte('checkout_validation-ccnumber-required', 1, 0, 1);?>";
|
||
case "INVALID_EXPIRY":
|
||
return "<?php afficheTexte('checkout_validation-expiry', 1, 0, 1);?>";
|
||
case "checkout_validation-declined":
|
||
return "<?php afficheTexte('checkout_validation-declined', 1, 0, 1);?>";
|
||
default:
|
||
// return "Une erreur est survenue lors du traitement du paiement. Veuillez réessayer.";
|
||
console.log('pas traduit');
|
||
return errorMessage;
|
||
}
|
||
}
|
||
|
||
function detectCardType(number) {
|
||
// Simple card type detection based on the card number prefix
|
||
const visaPrefix = /^4[0-9]{12}(?:[0-9]{3})?$/;
|
||
const mastercardPrefix = /^5[1-5][0-9]{14}$/;
|
||
|
||
if (visaPrefix.test(number)) {
|
||
return 'visa';
|
||
} else if (mastercardPrefix.test(number)) {
|
||
return 'mastercard';
|
||
} else {
|
||
return 'unknown';
|
||
}
|
||
}
|
||
function preprod(value) {
|
||
// Ajoute un paramètre à l'URL (ici ?preprod=1)
|
||
// const url = new URL(window.location.href);
|
||
//url.searchParams.set('preprod', value);
|
||
addParamsAndReload({ preprod: value });
|
||
// Recharge la page avec le paramètre dans l'URL
|
||
// window.location.href = url.toString();
|
||
}
|
||
function addParamsAndReload(newParams) {
|
||
const url = new URL(window.location.href);
|
||
|
||
|
||
for (const [key, value] of Object.entries(newParams)) {
|
||
url.searchParams.set(key, value);
|
||
}
|
||
|
||
// Rediriger vers l'URL mise à jour
|
||
|
||
window.location.href = url.toString();
|
||
}
|
||
|
||
|
||
$(function() {
|
||
|
||
const params = new URLSearchParams(window.location.search);
|
||
const ref = params.get('ref');
|
||
|
||
if (ref) {
|
||
try {
|
||
const pecId = atob(ref);
|
||
const target = $('#pec_' + pecId);
|
||
|
||
if (target.length) {
|
||
$('html, body').animate({
|
||
scrollTop: target.offset().top - 100
|
||
}, 800);
|
||
|
||
target.addClass('table-warning');
|
||
}
|
||
} catch (e) {
|
||
console.log('Ref invalide');
|
||
}
|
||
}
|
||
|
||
});
|
||
|
||
const moduleBib = document.getElementById('module-bib');
|
||
|
||
|
||
if (moduleBib) {
|
||
|
||
function bibAjaxLangSuffix() {
|
||
var lang = moduleBib.dataset.lang || 'fr';
|
||
return '&lang=' + encodeURIComponent(lang)
|
||
+ '&csrf_token=' + encodeURIComponent(bibCsrfToken());
|
||
}
|
||
|
||
function bibJs(attr) {
|
||
return moduleBib.dataset[attr] || '';
|
||
}
|
||
|
||
function bibJsConfirm(attr) {
|
||
return bibJs(attr).replace(/\\n/g, '\n');
|
||
}
|
||
|
||
function bibJsFmt(attr) {
|
||
var tpl = bibJs(attr);
|
||
var args = Array.prototype.slice.call(arguments, 1);
|
||
var i = 0;
|
||
return tpl.replace(/%d/g, function () {
|
||
return String(args[i++] ?? 0);
|
||
});
|
||
}
|
||
|
||
function bibRowPendingBibs(row) {
|
||
if (!row) return 0;
|
||
return parseInt(row.dataset.bibAAssigner || '0', 10) || 0;
|
||
}
|
||
|
||
function bibSyncEprBibStats(row, info) {
|
||
if (!row || !info) return;
|
||
|
||
if (info.total !== undefined) {
|
||
let totalEl = row.querySelector('.bib-total');
|
||
if (totalEl) totalEl.textContent = info.total;
|
||
}
|
||
if (info.avec_bib !== undefined) {
|
||
let avecEl = row.querySelector('.bib-avec');
|
||
if (avecEl) avecEl.textContent = info.avec_bib;
|
||
}
|
||
|
||
let pending = (info.a_assigner !== undefined && info.a_assigner !== null)
|
||
? info.a_assigner
|
||
: (info.sans_bib || 0);
|
||
row.dataset.bibAAssigner = String(parseInt(pending, 10) || 0);
|
||
}
|
||
|
||
function bibAlertAutoPendingBibs(row) {
|
||
alert(bibJsFmt('jsAutoPendingBibs', bibRowPendingBibs(row)).replace(/\\n/g, '\n'));
|
||
}
|
||
|
||
/** Bloque l'entrée en mode auto si des inscriptions n'ont pas encore de dossard. */
|
||
function bibBlockAutoActivation(row) {
|
||
if (!row || row.dataset.autoActive === '1') {
|
||
return false;
|
||
}
|
||
if (bibRowPendingBibs(row) > 0) {
|
||
bibAlertAutoPendingBibs(row);
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
// MSIN-4379 — Réduire / développer les blocs gestion et assignation (en-tête seul visible).
|
||
moduleBib.addEventListener('click', function (e) {
|
||
let btnToggle = e.target.closest('.epr-block-toggle');
|
||
if (!btnToggle || !moduleBib.contains(btnToggle)) {
|
||
return;
|
||
}
|
||
let block = btnToggle.closest('.epr-block');
|
||
if (!block) {
|
||
return;
|
||
}
|
||
let collapsed = block.classList.toggle('is-collapsed');
|
||
btnToggle.setAttribute('aria-expanded', collapsed ? 'false' : 'true');
|
||
let label = collapsed
|
||
? (btnToggle.getAttribute('data-label-expand') || '')
|
||
: (btnToggle.getAttribute('data-label-collapse') || '');
|
||
if (label) {
|
||
btnToggle.setAttribute('aria-label', label);
|
||
btnToggle.setAttribute('title', label);
|
||
}
|
||
let icon = btnToggle.querySelector('.fa');
|
||
if (icon) {
|
||
icon.classList.toggle('fa-chevron-up', !collapsed);
|
||
icon.classList.toggle('fa-chevron-down', collapsed);
|
||
}
|
||
});
|
||
|
||
// ============================================================
|
||
// MSIN-4379 — Tippy.js (module #module-bib uniquement)
|
||
// info_texte → data-tippy-content (tip court)
|
||
// info_aide → data-tippy-content sur .btn-aide-bib (pop-up long)
|
||
// Ré-init après chaque refresh AJAX des séquences.
|
||
// ============================================================
|
||
|
||
function getBibContainer(row) {
|
||
if (!row) return null;
|
||
return row.querySelector('.epr-block-assign .epr-table.bib-container')
|
||
|| row.querySelector('.epr-table.bib-container')
|
||
|| row.querySelector('.epr-block-assign .bib-container')
|
||
|| row.querySelector('.bib-container');
|
||
}
|
||
|
||
function bibTippyEscapeHtml(str) {
|
||
return String(str)
|
||
.replace(/&/g, '&')
|
||
.replace(/</g, '<')
|
||
.replace(/>/g, '>')
|
||
.replace(/"/g, '"');
|
||
}
|
||
|
||
function bibTippyAideContent(reference) {
|
||
let span = reference.querySelector('.bib-aide-text');
|
||
if (!span) {
|
||
return '';
|
||
}
|
||
// Mini-formatage : retours à la ligne → <br> ; double saut → paragraphe.
|
||
let lines = span.textContent.replace(/\r\n/g, '\n').replace(/\r/g, '\n').trim().split('\n');
|
||
let html = '';
|
||
let para = [];
|
||
lines.forEach(function (line) {
|
||
if (line.trim() === '') {
|
||
if (para.length) {
|
||
html += '<p>' + para.join('<br>') + '</p>';
|
||
para = [];
|
||
}
|
||
} else {
|
||
para.push(bibTippyEscapeHtml(line));
|
||
}
|
||
});
|
||
if (para.length) {
|
||
html += '<p>' + para.join('<br>') + '</p>';
|
||
}
|
||
return html;
|
||
}
|
||
|
||
function initModuleBibTippy(root) {
|
||
if (typeof tippy === 'undefined') return;
|
||
let scope = root || moduleBib;
|
||
scope.querySelectorAll('[data-tippy-content], .bib-aide-trigger').forEach(function (el) {
|
||
if (el._tippy) {
|
||
el._tippy.destroy();
|
||
}
|
||
});
|
||
|
||
tippy(scope.querySelectorAll('[data-tippy-content]'), {
|
||
theme: 'ms1-bib',
|
||
animation: 'fade',
|
||
allowHTML: false,
|
||
maxWidth: 280,
|
||
interactive: false
|
||
});
|
||
|
||
tippy(scope.querySelectorAll('.bib-aide-trigger'), {
|
||
theme: 'ms1-bib ms1-bib-aide',
|
||
animation: 'fade',
|
||
allowHTML: true,
|
||
maxWidth: 420,
|
||
interactive: true,
|
||
content: bibTippyAideContent
|
||
});
|
||
}
|
||
|
||
/** Visibilité UI v4 — bib-ui-hidden sur le conteneur (bouton + ? ensemble). */
|
||
function bibQuery(row, selector) {
|
||
return (row || moduleBib).querySelector(selector);
|
||
}
|
||
|
||
function bibSetVisible(target, show, row) {
|
||
let el = target;
|
||
if (typeof target === 'string') {
|
||
el = bibQuery(row, target);
|
||
} else if (el && el.nodeType === 1
|
||
&& !el.classList.contains('epr-action-group')
|
||
&& !el.classList.contains('batch-config-container')
|
||
&& !el.classList.contains('auto-config-container')
|
||
&& !el.classList.contains('epr-add-range-row')) {
|
||
el = el.closest('.epr-action-group') || el;
|
||
}
|
||
if (el) {
|
||
el.classList.toggle('bib-ui-hidden', !show);
|
||
}
|
||
}
|
||
|
||
function bibRowModes(row) {
|
||
return {
|
||
batch: row.classList.contains('batch-mode'),
|
||
auto: row.classList.contains('auto-mode'),
|
||
reset: row.classList.contains('reset-mode'),
|
||
};
|
||
}
|
||
|
||
function bibHasSavedSequences(row) {
|
||
return Array.from(row.querySelectorAll('.bib-range[data-id]')).some(function (line) {
|
||
return parseInt(line.getAttribute('data-id') || '0', 10) > 0;
|
||
});
|
||
}
|
||
|
||
function bibCountSelectedRanges(row) {
|
||
return row.querySelectorAll('.batch-select-range:checked').length;
|
||
}
|
||
|
||
/** MSIN-4379 — Rafraîchit le dashboard anomalies (chien de garde). */
|
||
function refreshBibAnomaliesPanel() {
|
||
let mount = document.getElementById('bib-anomalies-mount');
|
||
if (!mount || !moduleBib) {
|
||
return;
|
||
}
|
||
|
||
let eveId = moduleBib.dataset.eveId || '';
|
||
if (!eveId) {
|
||
return;
|
||
}
|
||
|
||
fetch('/ajax_bib_range.php', {
|
||
method: 'POST',
|
||
headers: {
|
||
'Content-Type': 'application/x-www-form-urlencoded'
|
||
},
|
||
body: 'action=anomalies&eve_id=' + encodeURIComponent(eveId) + bibAjaxLangSuffix()
|
||
})
|
||
.then(function (res) { return res.json(); })
|
||
.then(function (data) {
|
||
if (!data.success || !data.html) {
|
||
return;
|
||
}
|
||
mount.innerHTML = data.html;
|
||
initModuleBibTippy(mount);
|
||
});
|
||
}
|
||
|
||
function setBibContainerHtml(row, html) {
|
||
let container = getBibContainer(row);
|
||
if (!container) return null;
|
||
// renderBibRanges renvoie un bloc .epr-table.bib-container complet.
|
||
if (html.indexOf('bib-container') !== -1) {
|
||
container.outerHTML = html;
|
||
container = getBibContainer(row);
|
||
} else {
|
||
container.innerHTML = html;
|
||
}
|
||
if (container) {
|
||
initModuleBibTippy(row);
|
||
}
|
||
syncBibUiState(row);
|
||
refreshBibAnomaliesPanel();
|
||
return container;
|
||
}
|
||
|
||
function bibCsrfToken() {
|
||
return moduleBib ? (moduleBib.dataset.csrfToken || '') : '';
|
||
}
|
||
|
||
initModuleBibTippy(moduleBib);
|
||
|
||
// ============================================================
|
||
// MSIN-4379 — Étape 2 : assignation automatique (interface JS)
|
||
// Prochain tour : étape 6 (fxAssignAutoBibForParticipant), étape 7 (fxMajCommande).
|
||
// ============================================================
|
||
|
||
/** MSIN-4379 — Compte les séquences cochées et met à jour le texte d'aide. */
|
||
function updateAutoSelectionInfo(row) {
|
||
|
||
if (!row) return;
|
||
|
||
let count = row.querySelectorAll('.batch-select-range:checked').length;
|
||
let info = row.querySelector('.auto-info-text');
|
||
if (!info) return;
|
||
|
||
if (count === 0) {
|
||
info.textContent = bibJs('jsAutoSelectHint');
|
||
} else {
|
||
info.textContent = bibJsFmt('jsAutoSelectCount', count);
|
||
}
|
||
}
|
||
|
||
function syncAutoUiState(row, isActive) {
|
||
if (!row) return;
|
||
|
||
let btnAuto = row.querySelector('.btn-auto');
|
||
row.dataset.autoActive = isActive ? '1' : '0';
|
||
row.classList.toggle('auto-enabled', isActive);
|
||
|
||
if (btnAuto) {
|
||
btnAuto.textContent = isActive ? row.dataset.autoLabelConfig : row.dataset.autoLabel;
|
||
btnAuto.classList.toggle('btn-bib-auto--active', isActive);
|
||
let autoAide = bibQuery(row, '.epr-action-auto-group .epr-btn-aide-segment .bib-aide-trigger');
|
||
if (autoAide) {
|
||
autoAide.classList.add('btn-aide-tone-auto');
|
||
autoAide.classList.remove('btn-aide-tone-success', 'btn-aide-tone-secondary');
|
||
}
|
||
}
|
||
}
|
||
|
||
/** MSIN-4379 — Quitte le mode édition auto sans sauver ; recharge les plages (mode assign). */
|
||
function exitAutoMode(row) {
|
||
|
||
if (!row) return;
|
||
|
||
row.classList.remove('auto-mode');
|
||
|
||
let container = row.querySelector('.bib-container');
|
||
if (container) {
|
||
container.classList.remove('batch-mode');
|
||
}
|
||
|
||
row.querySelectorAll('.bib-start, .bib-end').forEach(input => {
|
||
input.removeAttribute('readonly');
|
||
});
|
||
|
||
fetch('/ajax_bib_range.php', {
|
||
method: 'POST',
|
||
headers: {
|
||
'Content-Type': 'application/x-www-form-urlencoded'
|
||
},
|
||
body:
|
||
'action=refresh_ranges'
|
||
+ '&epr_id=' + encodeURIComponent(row.dataset.eprId)
|
||
+ '&mode=assign'
|
||
+ bibAjaxLangSuffix()
|
||
})
|
||
.then(res => res.json())
|
||
.then(data => {
|
||
|
||
if (!data.success) return;
|
||
|
||
let bibContainer = setBibContainerHtml(row, data.html);
|
||
});
|
||
}
|
||
|
||
/** MSIN-4379 — Ouvre le mode édition : checkboxes, bloc Accepter/Annuler, refresh mode=auto. */
|
||
function enterAutoMode(row) {
|
||
|
||
if (!row) return;
|
||
|
||
if (row.classList.contains('batch-mode') || row.classList.contains('reset-mode')) {
|
||
return;
|
||
}
|
||
|
||
if (bibBlockAutoActivation(row)) {
|
||
return;
|
||
}
|
||
|
||
row.classList.add('auto-mode');
|
||
|
||
let container = row.querySelector('.bib-container');
|
||
if (container) {
|
||
container.classList.add('batch-mode');
|
||
}
|
||
|
||
row.querySelectorAll('.bib-start, .bib-end').forEach(input => {
|
||
input.setAttribute('readonly', true);
|
||
});
|
||
|
||
syncBibUiState(row);
|
||
|
||
fetch('/ajax_bib_range.php', {
|
||
method: 'POST',
|
||
headers: {
|
||
'Content-Type': 'application/x-www-form-urlencoded'
|
||
},
|
||
body:
|
||
'action=refresh_ranges'
|
||
+ '&epr_id=' + encodeURIComponent(row.dataset.eprId)
|
||
+ '&mode=auto'
|
||
+ bibAjaxLangSuffix()
|
||
})
|
||
.then(res => res.json())
|
||
.then(data => {
|
||
|
||
if (!data.success) return;
|
||
|
||
let bibContainer = setBibContainerHtml(row, data.html);
|
||
if (!bibContainer) return;
|
||
|
||
bibContainer.classList.add('batch-mode');
|
||
|
||
row.querySelectorAll('.bib-start, .bib-end').forEach(input => {
|
||
input.setAttribute('readonly', true);
|
||
});
|
||
|
||
updateAutoSelectionInfo(row);
|
||
syncBibUiState(row);
|
||
});
|
||
}
|
||
|
||
function syncBibUiState(row) {
|
||
if (!row) return;
|
||
|
||
let modes = bibRowModes(row);
|
||
let avecBib = parseInt(bibQuery(row, '.bib-avec')?.textContent || '0', 10) || 0;
|
||
let hasSequences = bibHasSavedSequences(row);
|
||
let hasSelection = bibCountSelectedRanges(row) > 0;
|
||
let inBatchFlow = modes.batch || modes.reset;
|
||
let inAutoFlow = modes.auto;
|
||
let inPickFlow = inBatchFlow || inAutoFlow;
|
||
|
||
row.querySelectorAll('.team-mode-box input[type="radio"]').forEach(function (radio) {
|
||
if (!radio.closest('.team-mode-option.disabled')) {
|
||
radio.disabled = avecBib > 0;
|
||
}
|
||
});
|
||
|
||
let showReset = hasSequences && (avecBib > 0 || modes.reset)
|
||
&& !modes.auto
|
||
&& (!modes.batch || modes.reset);
|
||
bibSetVisible('.epr-action-batch-group',
|
||
hasSequences && ((!modes.reset && !modes.auto) || modes.batch), row);
|
||
bibSetVisible('.epr-action-reset-group', showReset, row);
|
||
bibSetVisible('.epr-action-auto-group',
|
||
hasSequences && !modes.reset && !modes.auto && !modes.batch, row);
|
||
|
||
if (hasSequences) {
|
||
syncAutoUiState(row, row.dataset.autoActive === '1');
|
||
}
|
||
|
||
bibSetVisible('.epr-add-range-row', !inPickFlow, row);
|
||
bibSetVisible('.batch-config-container', inBatchFlow, row);
|
||
bibSetVisible('.auto-config-container', inAutoFlow, row);
|
||
|
||
let showPick = inPickFlow && !hasSelection;
|
||
let showBatchReady = inBatchFlow && hasSelection;
|
||
let showAutoReady = inAutoFlow && hasSelection;
|
||
bibSetVisible('.bib-seq-pick-prompt', showPick, row);
|
||
bibSetVisible('.batch-config-ready', showBatchReady, row);
|
||
bibSetVisible('.auto-config-ready', showAutoReady, row);
|
||
|
||
let bibContainer = getBibContainer(row);
|
||
if (bibContainer) {
|
||
bibContainer.classList.toggle('batch-awaiting-selection', showPick);
|
||
}
|
||
|
||
bibSetVisible('.epr-action-desactiver-group',
|
||
hasSequences && row.dataset.autoActive === '1' && inAutoFlow, row);
|
||
bibSetVisible('.epr-action-cancel-auto-group', inAutoFlow, row);
|
||
bibSetVisible('.epr-action-accept-auto-group', showAutoReady, row);
|
||
bibSetVisible('.epr-auto-info-group', showAutoReady, row);
|
||
bibSetVisible('.batch-reset-warning', showBatchReady && modes.reset, row);
|
||
bibSetVisible('.epr-batch-order-wrap', showBatchReady && !modes.reset, row);
|
||
bibSetVisible('.epr-action-sim-group', showBatchReady && !modes.reset, row);
|
||
bibSetVisible('.epr-action-go-group', showBatchReady, row);
|
||
}
|
||
|
||
function updateBatchAnalysis(row) {
|
||
|
||
if (!row) return;
|
||
|
||
let totalDispo = 0;
|
||
let totalReset = 0;
|
||
|
||
// =====================
|
||
// TOTAL DISPO
|
||
// Source officielle = PHP
|
||
// JS ne recalcule PAS les disponibilités.
|
||
// Il additionne seulement les valeurs affichées dans .bib-dispo.
|
||
// =====================
|
||
row.querySelectorAll('.batch-select-range:checked').forEach(cb => {
|
||
|
||
let line = cb.closest('.epr-line');
|
||
if (!line) return;
|
||
|
||
let usedDiv = line.querySelector('.bib-used');
|
||
let dispoDiv = line.querySelector('.bib-dispo');
|
||
|
||
let used = parseInt((usedDiv?.textContent || '0'), 10);
|
||
let dispo = parseInt((dispoDiv?.textContent || '0'), 10);
|
||
|
||
if (isNaN(used)) {
|
||
used = 0;
|
||
}
|
||
|
||
if (isNaN(dispo)) {
|
||
dispo = 0;
|
||
}
|
||
|
||
totalReset += used;
|
||
totalDispo += dispo;
|
||
});
|
||
|
||
fetch('/ajax_bib_range.php', {
|
||
method: 'POST',
|
||
headers: {
|
||
'Content-Type': 'application/x-www-form-urlencoded'
|
||
},
|
||
body: 'action=batch_analysis&epr_id=' + encodeURIComponent(row.dataset.eprId) + bibAjaxLangSuffix()
|
||
})
|
||
.then(res => res.json())
|
||
.then(data => {
|
||
|
||
if (!data.success) return;
|
||
|
||
bibSyncEprBibStats(row, data.info);
|
||
syncBibUiState(row);
|
||
let sansBib = bibRowPendingBibs(row);
|
||
let isResetMode = row.dataset.mode === 'reset';
|
||
let message = '';
|
||
|
||
if (isResetMode) {
|
||
|
||
if (totalReset === 0) {
|
||
message = bibJs('jsBatchNone');
|
||
} else {
|
||
message = bibJsFmt('jsBatchResetCount', totalReset);
|
||
}
|
||
|
||
} else {
|
||
|
||
if (totalDispo === 0) {
|
||
message = bibJs('jsBatchNone');
|
||
} else if (totalDispo < sansBib) {
|
||
message = bibJsFmt('jsBatchSummaryShort', totalDispo, sansBib, sansBib - totalDispo);
|
||
} else {
|
||
message = bibJsFmt('jsBatchSummaryOk', totalDispo, sansBib);
|
||
}
|
||
|
||
}
|
||
|
||
let info = row.querySelector('.epr-actions .batch-info-text');
|
||
if (info && bibCountSelectedRanges(row) > 0) {
|
||
info.textContent = message;
|
||
}
|
||
|
||
syncBibUiState(row);
|
||
});
|
||
}
|
||
|
||
// =====================
|
||
// BATCH CHECKBOX CHANGE (PROPRE)
|
||
// =====================
|
||
moduleBib.addEventListener('change', function (e) {
|
||
|
||
// =====================
|
||
// TEAM MODE
|
||
// =====================
|
||
let teamRadio = e.target.closest('.team-mode-box input[type="radio"]');
|
||
|
||
if (teamRadio) {
|
||
|
||
if (teamRadio.disabled) return;
|
||
|
||
let box = teamRadio.closest('.team-mode-box');
|
||
if (!box) return;
|
||
|
||
fetch('/ajax_bib_range.php', {
|
||
method: 'POST',
|
||
headers: {
|
||
'Content-Type': 'application/x-www-form-urlencoded'
|
||
},
|
||
body:
|
||
'action=save_team_mode'
|
||
+ '&epr_id=' + encodeURIComponent(box.dataset.eprId)
|
||
+ '&team_mode=' + encodeURIComponent(teamRadio.value)
|
||
+ bibAjaxLangSuffix()
|
||
});
|
||
|
||
return;
|
||
}
|
||
|
||
let cb = e.target.closest('.batch-select-range');
|
||
if (!cb) return;
|
||
|
||
let row = cb.closest('.epr-row');
|
||
if (!row) return;
|
||
|
||
// MSIN-4379 — Mode auto : même sélection de séquences que le batch, sans GO/simulation.
|
||
if (row.classList.contains('auto-mode')) {
|
||
updateAutoSelectionInfo(row);
|
||
syncBibUiState(row);
|
||
return;
|
||
}
|
||
|
||
if (row.dataset.loading === '1') return;
|
||
let existing = document.querySelector('.epr-row-view');
|
||
if (existing) existing.remove();
|
||
row.dataset.loading = '1';
|
||
|
||
// 1. garder sélection
|
||
let selected = [];
|
||
row.querySelectorAll('.batch-select-range:checked').forEach(el => {
|
||
selected.push(el.dataset.rangeId);
|
||
});
|
||
|
||
// 2. analyse gauche/droite
|
||
updateBatchAnalysis(row);
|
||
|
||
// 3. sortir du cycle du change
|
||
setTimeout(() => {
|
||
|
||
fetch('/ajax_bib_range.php', {
|
||
method: 'POST',
|
||
headers: {
|
||
'Content-Type': 'application/x-www-form-urlencoded'
|
||
},
|
||
body:
|
||
'action=refresh_ranges'
|
||
+ '&epr_id=' + encodeURIComponent(row.dataset.eprId)
|
||
+ '&mode=' + encodeURIComponent(row.dataset.mode || 'assign')
|
||
+ bibAjaxLangSuffix()
|
||
})
|
||
.then(res => res.json())
|
||
.then(data => {
|
||
|
||
if (!data.success) {
|
||
row.dataset.loading = '0';
|
||
return;
|
||
}
|
||
|
||
setBibContainerHtml(row, data.html);
|
||
let container = getBibContainer(row);
|
||
if (!container) {
|
||
row.dataset.loading = '0';
|
||
return;
|
||
}
|
||
|
||
// 4. refresh complet serveur
|
||
// Re-sync après refresh serveur
|
||
|
||
container.classList.add('batch-mode');
|
||
|
||
// 5. remettre readonly
|
||
container.querySelectorAll('.bib-start, .bib-end').forEach(input => {
|
||
input.setAttribute('readonly', true);
|
||
});
|
||
|
||
// 6. restaurer checkbox
|
||
container.querySelectorAll('.batch-select-range').forEach(el => {
|
||
if (selected.includes(el.dataset.rangeId)) {
|
||
el.checked = true;
|
||
}
|
||
});
|
||
updateBatchAnalysis(row);
|
||
|
||
row.dataset.loading = '0';
|
||
|
||
})
|
||
.catch(() => {
|
||
row.dataset.loading = '0';
|
||
});
|
||
|
||
}, 0);
|
||
});
|
||
|
||
moduleBib.querySelectorAll('.epr-row').forEach(syncBibUiState);
|
||
|
||
moduleBib.addEventListener('click', function (e) {
|
||
|
||
let btnTrad = e.target.closest('.btn-admin-trad, .btn-bib-trad');
|
||
if (btnTrad) {
|
||
e.preventDefault();
|
||
e.stopPropagation();
|
||
let url = btnTrad.getAttribute('data-trad-url');
|
||
if (!url) {
|
||
return;
|
||
}
|
||
let clef = btnTrad.getAttribute('data-info-clef') || 'bib_trad';
|
||
let popup = window.open(
|
||
url,
|
||
'bib_trad_' + clef,
|
||
'width=960,height=640,scrollbars=yes,resizable=yes'
|
||
);
|
||
if (popup) {
|
||
let timer = setInterval(function () {
|
||
if (popup.closed) {
|
||
clearInterval(timer);
|
||
window.location.reload();
|
||
}
|
||
}, 400);
|
||
}
|
||
return;
|
||
}
|
||
|
||
// =====================
|
||
// LOCK / UNLOCK SEQUENCE
|
||
// =====================
|
||
let btnLock = e.target.closest('.btn-bib-lock');
|
||
if (btnLock) {
|
||
e.preventDefault();
|
||
|
||
let row = btnLock.closest('.epr-row');
|
||
if (!row) return;
|
||
|
||
let isLocked = btnLock.dataset.locked === '1';
|
||
let confirmMsg = isLocked
|
||
? bibJsConfirm('jsUnlockConfirm')
|
||
: bibJsConfirm('jsLockConfirm');
|
||
|
||
if (!confirm(confirmMsg)) {
|
||
return;
|
||
}
|
||
|
||
fetch('/ajax_bib_range.php', {
|
||
method: 'POST',
|
||
headers: {
|
||
'Content-Type': 'application/x-www-form-urlencoded'
|
||
},
|
||
body:
|
||
'action=toggle_lock'
|
||
+ '&epr_bib_id=' + encodeURIComponent(btnLock.dataset.rangeId)
|
||
+ '&epr_id=' + encodeURIComponent(btnLock.dataset.eprId || row.dataset.eprId)
|
||
+ '&locked=' + encodeURIComponent(isLocked ? '0' : '1')
|
||
+ bibAjaxLangSuffix()
|
||
})
|
||
.then(res => res.json())
|
||
.then(data => {
|
||
|
||
if (!data.success) {
|
||
alert(data.message || bibJs('jsErrGeneric'));
|
||
return;
|
||
}
|
||
|
||
if (typeof data.auto_active !== 'undefined') {
|
||
row.dataset.autoActive = data.auto_active ? '1' : '0';
|
||
syncAutoUiState(row, data.auto_active);
|
||
syncBibUiState(row);
|
||
}
|
||
|
||
if (data.html) {
|
||
setBibContainerHtml(row, data.html);
|
||
}
|
||
});
|
||
|
||
return;
|
||
}
|
||
|
||
// =====================
|
||
// DELETE
|
||
// =====================
|
||
let btnDelete = e.target.closest('.btn-delete-range');
|
||
if (btnDelete) {
|
||
|
||
|
||
e.preventDefault();
|
||
|
||
let container = btnDelete.closest('.bib-container');
|
||
let errorDiv = container.querySelector('.bib-error-global');
|
||
|
||
// reset erreur
|
||
if (errorDiv) {
|
||
errorDiv.style.display = 'none';
|
||
errorDiv.innerText = '';
|
||
}
|
||
|
||
let id = btnDelete.dataset.id;
|
||
if (!id) return;
|
||
|
||
fetch('/ajax_bib_range.php', {
|
||
method: 'POST',
|
||
headers: {
|
||
'Content-Type': 'application/x-www-form-urlencoded'
|
||
},
|
||
body: 'action=delete&id=' + encodeURIComponent(id) + bibAjaxLangSuffix()
|
||
})
|
||
.then(res => res.text())
|
||
.then(raw => {
|
||
|
||
let data;
|
||
try {
|
||
data = JSON.parse(raw);
|
||
} catch (err) {
|
||
if (errorDiv) {
|
||
errorDiv.innerText = bibJs('jsServerError');
|
||
errorDiv.style.display = 'block';
|
||
}
|
||
return;
|
||
}
|
||
|
||
if (!data.success) {
|
||
if (errorDiv) {
|
||
errorDiv.innerText = data.message || bibJs('jsErrGeneric');
|
||
errorDiv.style.display = 'block';
|
||
}
|
||
return;
|
||
}
|
||
|
||
setBibContainerHtml(btnDelete.closest('.epr-row'), data.html);
|
||
});
|
||
|
||
return;
|
||
}
|
||
|
||
// =====================
|
||
// SAVE
|
||
// =====================
|
||
let btnSave = e.target.closest('.btn-save-range');
|
||
if (btnSave) {
|
||
e.preventDefault();
|
||
|
||
let row = btnSave.closest('.bib-range');
|
||
let errorDiv = row.nextElementSibling;
|
||
let epr_id = btnSave.dataset.eprId;
|
||
|
||
// reset
|
||
if (errorDiv) {
|
||
errorDiv.style.display = 'none';
|
||
errorDiv.innerText = '';
|
||
}
|
||
|
||
let start = row.querySelector('.bib-start').value;
|
||
let end = row.querySelector('.bib-end').value;
|
||
let id = btnSave.dataset.id;
|
||
|
||
// ligne temporaire vide = on la retire
|
||
if (id == 0 && (!start || !end)) {
|
||
row.remove();
|
||
if (errorDiv) errorDiv.remove();
|
||
return;
|
||
}
|
||
|
||
if (!start || !end) {
|
||
errorDiv.innerText = bibJs('jsFieldsRequired');
|
||
errorDiv.style.display = 'block';
|
||
return;
|
||
}
|
||
|
||
fetch('/ajax_bib_range.php', {
|
||
method: 'POST',
|
||
headers: {
|
||
'Content-Type': 'application/x-www-form-urlencoded'
|
||
},
|
||
body:
|
||
'action=save'
|
||
+ '&id=' + encodeURIComponent(id)
|
||
+ '&epr_id=' + encodeURIComponent(epr_id)
|
||
+ '&start=' + encodeURIComponent(start)
|
||
+ '&end=' + encodeURIComponent(end)
|
||
+ bibAjaxLangSuffix()
|
||
})
|
||
.then(res => res.text())
|
||
.then(raw => {
|
||
|
||
let data;
|
||
try {
|
||
data = JSON.parse(raw);
|
||
} catch (err) {
|
||
errorDiv.innerText = bibJs('jsServerError');
|
||
errorDiv.style.display = 'block';
|
||
return;
|
||
}
|
||
|
||
if (!data.success) {
|
||
errorDiv.innerText = data.message || bibJs('jsErrGeneric');
|
||
errorDiv.style.display = 'block';
|
||
return;
|
||
}
|
||
|
||
setBibContainerHtml(btnSave.closest('.epr-row'), data.html);
|
||
});
|
||
|
||
return;
|
||
}
|
||
// =====================
|
||
// VIEW
|
||
// =====================
|
||
let btnView = e.target.closest('.btn-view-range');
|
||
if (btnView) {
|
||
e.preventDefault();
|
||
|
||
let epr_id = btnView.dataset.eprId;
|
||
let range_id = btnView.dataset.rangeId;
|
||
|
||
console.log('epr_id:', epr_id);
|
||
console.log('range_id:', range_id);
|
||
if (!epr_id || typeof range_id === 'undefined') return;
|
||
|
||
let container = btnView.closest('.epr-block');
|
||
|
||
// Vérifier si une vue est déjà ouverte
|
||
let existing = document.querySelector('.epr-row-view');
|
||
|
||
// Toggle : si c'est le même œil qui a ouvert la vue, on la ferme et on s'arrête
|
||
if (existing
|
||
&& existing.dataset.eprId === epr_id
|
||
&& existing.dataset.rangeId === range_id
|
||
) {
|
||
existing.remove();
|
||
return;
|
||
}
|
||
|
||
// Un autre œil a été cliqué : fermer la vue précédente avant d'ouvrir la nouvelle
|
||
if (existing) {
|
||
existing.remove();
|
||
}
|
||
|
||
fetch('/ajax_bib_range.php', {
|
||
method: 'POST',
|
||
headers: {
|
||
'Content-Type': 'application/x-www-form-urlencoded'
|
||
},
|
||
body:
|
||
'action=view'
|
||
+ '&epr_id=' + encodeURIComponent(epr_id)
|
||
+ '&range_id=' + encodeURIComponent(range_id)
|
||
+ bibAjaxLangSuffix()
|
||
})
|
||
.then(res => res.text())
|
||
.then(raw => {
|
||
|
||
let data;
|
||
try {
|
||
data = JSON.parse(raw);
|
||
} catch (err) {
|
||
console.log(bibJs('jsServerError'));
|
||
return;
|
||
}
|
||
|
||
if (!data.success) {
|
||
console.log(data.message || bibJs('jsErrGeneric'));
|
||
return;
|
||
}
|
||
|
||
let row = btnView.closest('.epr-row');
|
||
|
||
// Injecter la nouvelle vue sous la ligne du bouton cliqué,
|
||
// en mémorisant epr_id et range_id pour le toggle suivant
|
||
row.insertAdjacentHTML('afterend', data.html);
|
||
|
||
// Stocker les identifiants sur la vue injectée pour pouvoir détecter
|
||
// le 2e clic sur le même œil
|
||
let newView = row.nextElementSibling;
|
||
if (newView && newView.classList.contains('epr-row-view')) {
|
||
newView.dataset.eprId = epr_id;
|
||
newView.dataset.rangeId = range_id;
|
||
}
|
||
});
|
||
|
||
return;
|
||
}
|
||
|
||
|
||
// =====================
|
||
// CLOSE VIEW
|
||
// =====================
|
||
let btnClose = e.target.closest('.btn-close-view');
|
||
if (btnClose) {
|
||
e.preventDefault();
|
||
|
||
let view = btnClose.closest('.epr-row-view');
|
||
if (view) {
|
||
view.remove();
|
||
}
|
||
|
||
return;
|
||
}
|
||
// =====================
|
||
// ASSIGN BATCH
|
||
// =====================
|
||
// Active/désactive le mode batch pour UNE épreuve.
|
||
// - Affiche les checkbox
|
||
// - Bloque Début/Fin
|
||
// - Affiche le bloc de configuration
|
||
// - Recalcule l’analyse initiale
|
||
// =====================
|
||
let btnBatch = e.target.closest('.btn-assign-batch');
|
||
if (btnBatch) {
|
||
|
||
e.preventDefault();
|
||
|
||
let row = btnBatch.closest('.epr-row');
|
||
if (!row) return;
|
||
|
||
// MSIN-4379 — Batch et auto sont mutuellement exclusifs.
|
||
if (row.classList.contains('auto-mode')) {
|
||
return;
|
||
}
|
||
|
||
let container = row.querySelector('.bib-container');
|
||
if (!container) return;
|
||
|
||
// OFF
|
||
if (row.classList.contains('batch-mode')) {
|
||
|
||
row.classList.remove('batch-mode');
|
||
row.querySelectorAll('.batch-select-range').forEach(cb => {
|
||
cb.disabled = false;
|
||
});
|
||
container.classList.remove('batch-mode');
|
||
|
||
row.querySelectorAll('.bib-start, .bib-end').forEach(input => {
|
||
input.removeAttribute('readonly');
|
||
});
|
||
|
||
btnBatch.textContent = row.dataset.batchLabel || btnBatch.textContent;
|
||
|
||
let goBtn = row.querySelector('.btn-go-batch');
|
||
if (goBtn) {
|
||
goBtn.textContent = row.dataset.goLabel || goBtn.textContent;
|
||
}
|
||
row.querySelectorAll('.batch-select-range').forEach(cb => {
|
||
cb.checked = false;
|
||
});
|
||
let info = row.querySelector('.epr-actions .batch-info-text');
|
||
if (info) info.textContent = '';
|
||
syncBibUiState(row);
|
||
return;
|
||
}
|
||
|
||
// ON
|
||
row.classList.add('batch-mode');
|
||
container.classList.add('batch-mode');
|
||
|
||
row.querySelectorAll('.bib-start, .bib-end').forEach(input => {
|
||
input.setAttribute('readonly', true);
|
||
});
|
||
|
||
btnBatch.textContent = row.dataset.batchLabelCancel || btnBatch.textContent;
|
||
let goBtn = row.querySelector('.btn-go-batch');
|
||
if (goBtn) {
|
||
goBtn.textContent = row.dataset.goLabel || goBtn.textContent;
|
||
}
|
||
if (typeof updateBatchAnalysis === 'function') {
|
||
updateBatchAnalysis(row);
|
||
}
|
||
syncBibUiState(row);
|
||
|
||
return;
|
||
}
|
||
// =====================
|
||
// SIMULER BATCH
|
||
// =====================
|
||
let btnSim = e.target.closest('.btn-simuler-batch');
|
||
if (btnSim) {
|
||
|
||
e.preventDefault();
|
||
|
||
let row = btnSim.closest('.epr-row');
|
||
if (!row) return;
|
||
|
||
let selected = [];
|
||
|
||
row.querySelectorAll('.batch-select-range:checked').forEach(cb => {
|
||
selected.push(cb.dataset.rangeId);
|
||
});
|
||
|
||
if (selected.length === 0) {
|
||
alert(bibJs('jsNoSeqSelected'));
|
||
return;
|
||
}
|
||
let isResetMode = row.dataset.mode === 'reset';
|
||
let ba_id = row.querySelector('.batch-order').value;
|
||
|
||
fetch('/ajax_bib_range.php', {
|
||
method: 'POST',
|
||
headers: {
|
||
'Content-Type': 'application/x-www-form-urlencoded'
|
||
},
|
||
body:
|
||
(isResetMode ? 'action=reset_preview' : 'action=batch_go')
|
||
+ '&epr_id=' + encodeURIComponent(row.dataset.eprId)
|
||
+ '&ranges=' + encodeURIComponent(JSON.stringify(selected))
|
||
+ '&ba_id=' + encodeURIComponent(ba_id)
|
||
+ bibAjaxLangSuffix()
|
||
})
|
||
.then(res => res.json())
|
||
.then(data => {
|
||
|
||
if (!data.success) {
|
||
alert(data.message || bibJs('jsErrGeneric'));
|
||
return;
|
||
}
|
||
|
||
let existing = document.querySelector('.epr-row-view');
|
||
if (existing) {
|
||
existing.remove();
|
||
}
|
||
|
||
row.insertAdjacentHTML('afterend', data.html);
|
||
|
||
|
||
});
|
||
|
||
return;
|
||
}
|
||
|
||
// =====================
|
||
// RESET MODE
|
||
// =====================
|
||
let btnReset = e.target.closest('.btn-reset');
|
||
if (btnReset) {
|
||
|
||
e.preventDefault();
|
||
|
||
let row = btnReset.closest('.epr-row');
|
||
if (!row) return;
|
||
|
||
// MSIN-4379 — Reset et auto sont mutuellement exclusifs.
|
||
if (row.classList.contains('auto-mode')) {
|
||
return;
|
||
}
|
||
|
||
let container = row.querySelector('.bib-container');
|
||
if (!container) return;
|
||
|
||
// =====================
|
||
// OFF
|
||
// =====================
|
||
if (row.classList.contains('reset-mode')) {
|
||
|
||
row.classList.remove('reset-mode');
|
||
btnReset.textContent = row.dataset.resetLabel || btnReset.textContent;
|
||
container.classList.remove('batch-mode');
|
||
|
||
row.querySelectorAll('.bib-start, .bib-end').forEach(input => {
|
||
input.removeAttribute('readonly');
|
||
});
|
||
|
||
row.querySelectorAll('.batch-select-range').forEach(cb => {
|
||
cb.checked = false;
|
||
});
|
||
|
||
let goBtn = row.querySelector('.btn-go-batch');
|
||
if (goBtn) {
|
||
goBtn.textContent = row.dataset.goLabel || goBtn.textContent;
|
||
}
|
||
|
||
let info = row.querySelector('.epr-actions .batch-info-text');
|
||
if (info) {
|
||
info.innerHTML = '';
|
||
}
|
||
row.dataset.mode = '';
|
||
syncBibUiState(row);
|
||
return;
|
||
}
|
||
|
||
// =====================
|
||
// ON
|
||
// =====================
|
||
row.classList.add('reset-mode');
|
||
btnReset.textContent = row.dataset.resetCancelLabel || btnReset.textContent;
|
||
row.dataset.mode = 'reset';
|
||
container.classList.add('batch-mode');
|
||
|
||
row.querySelectorAll('.bib-start, .bib-end').forEach(input => {
|
||
input.setAttribute('readonly', true);
|
||
});
|
||
|
||
syncBibUiState(row);
|
||
|
||
let goBtn = row.querySelector('.btn-go-batch');
|
||
if (goBtn) {
|
||
goBtn.textContent = row.dataset.resetLabel || goBtn.textContent;
|
||
}
|
||
|
||
fetch('/ajax_bib_range.php', {
|
||
method: 'POST',
|
||
headers: {
|
||
'Content-Type': 'application/x-www-form-urlencoded'
|
||
},
|
||
body:
|
||
'action=refresh_ranges'
|
||
+ '&epr_id=' + encodeURIComponent(row.dataset.eprId)
|
||
+ '&mode=reset'
|
||
+ bibAjaxLangSuffix()
|
||
})
|
||
.then(res => res.json())
|
||
.then(data => {
|
||
|
||
if (!data.success) return;
|
||
|
||
let container = setBibContainerHtml(row, data.html);
|
||
if (!container) return;
|
||
|
||
container.classList.add('batch-mode');
|
||
|
||
row.querySelectorAll('.bib-start, .bib-end').forEach(input => {
|
||
input.setAttribute('readonly', true);
|
||
});
|
||
|
||
syncBibUiState(row);
|
||
});
|
||
|
||
return;
|
||
}
|
||
|
||
|
||
|
||
|
||
// =====================
|
||
// GO BATCH
|
||
// =====================
|
||
let btnGo = e.target.closest('.btn-go-batch');
|
||
if (btnGo) {
|
||
|
||
e.preventDefault();
|
||
|
||
let row = btnGo.closest('.epr-row');
|
||
if (!row) return;
|
||
|
||
let selected = [];
|
||
|
||
row.querySelectorAll('.batch-select-range:checked').forEach(cb => {
|
||
selected.push(cb.dataset.rangeId);
|
||
});
|
||
|
||
if (selected.length === 0) {
|
||
alert(bibJs('jsNoSeqSelected'));
|
||
return;
|
||
}
|
||
let isResetMode = row.dataset.mode === 'reset';
|
||
let ba_id = row.querySelector('.batch-order').value;
|
||
|
||
fetch('/ajax_bib_range.php', {
|
||
method: 'POST',
|
||
headers: {
|
||
'Content-Type': 'application/x-www-form-urlencoded'
|
||
},
|
||
body:
|
||
(isResetMode ? 'action=reset_apply' : 'action=batch_apply')
|
||
+ '&epr_id=' + encodeURIComponent(row.dataset.eprId)
|
||
+ '&ranges=' + encodeURIComponent(JSON.stringify(selected))
|
||
+ '&ba_id=' + encodeURIComponent(ba_id)
|
||
+ bibAjaxLangSuffix()
|
||
})
|
||
.then(res => res.json())
|
||
.then(data => {
|
||
|
||
if (!data.success) {
|
||
alert(data.message || bibJs('jsErrGeneric'));
|
||
return;
|
||
}
|
||
|
||
let existing = document.querySelector('.epr-row-view');
|
||
if (existing) {
|
||
existing.remove();
|
||
}
|
||
|
||
// afficher résultat
|
||
row.insertAdjacentHTML('afterend', data.html);
|
||
|
||
// =====================
|
||
// RESET UI BATCH
|
||
// =====================
|
||
if (isResetMode) {
|
||
row.classList.remove('reset-mode');
|
||
row.dataset.mode = '';
|
||
|
||
let btnReset = row.querySelector('.btn-reset');
|
||
if (btnReset) {
|
||
btnReset.textContent = row.dataset.resetLabel || btnReset.textContent;
|
||
}
|
||
}
|
||
row.classList.remove('batch-mode');
|
||
|
||
let container = row.querySelector('.bib-container');
|
||
if (container) {
|
||
container.classList.remove('batch-mode');
|
||
}
|
||
|
||
let btnBatch = row.querySelector('.btn-assign-batch');
|
||
if (btnBatch) {
|
||
btnBatch.textContent = row.dataset.batchLabel || btnBatch.textContent;
|
||
}
|
||
|
||
row.querySelectorAll('.bib-start, .bib-end').forEach(input => {
|
||
input.removeAttribute('readonly');
|
||
});
|
||
|
||
row.querySelectorAll('.batch-select-range').forEach(cb => {
|
||
cb.checked = false;
|
||
cb.disabled = false;
|
||
});
|
||
|
||
syncBibUiState(row);
|
||
|
||
fetch('/ajax_bib_range.php', {
|
||
method: 'POST',
|
||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||
body:
|
||
'action=refresh_ranges'
|
||
+ '&epr_id=' + encodeURIComponent(row.dataset.eprId)
|
||
+ '&mode=assign'
|
||
+ bibAjaxLangSuffix()
|
||
})
|
||
.then(res => res.json())
|
||
.then(refresh => {
|
||
|
||
if (!refresh.success) return;
|
||
|
||
let container = setBibContainerHtml(row, refresh.html);
|
||
if (!container) return;
|
||
fetch('/ajax_bib_range.php', {
|
||
method: 'POST',
|
||
headers: {
|
||
'Content-Type': 'application/x-www-form-urlencoded'
|
||
},
|
||
body:
|
||
'action=batch_analysis'
|
||
+ '&epr_id=' + encodeURIComponent(row.dataset.eprId)
|
||
+ bibAjaxLangSuffix()
|
||
})
|
||
.then(res => res.json())
|
||
.then(stats => {
|
||
|
||
if (!stats.success) return;
|
||
|
||
bibSyncEprBibStats(row, stats.info);
|
||
syncBibUiState(row);
|
||
});
|
||
});
|
||
|
||
});
|
||
|
||
return;
|
||
}
|
||
|
||
// =====================
|
||
// MSIN-4379 — Étape 2 : AUTO DOSSARD (clics Accepter / Annuler / Désactiver / Activer)
|
||
// Prochain tour : étape 6–7 (assignation PHP à l'inscription).
|
||
// =====================
|
||
let btnAccepterAuto = e.target.closest('.btn-accepter-auto');
|
||
if (btnAccepterAuto) {
|
||
|
||
e.preventDefault();
|
||
|
||
let row = btnAccepterAuto.closest('.epr-row');
|
||
if (!row) return;
|
||
|
||
let selected = [];
|
||
|
||
row.querySelectorAll('.batch-select-range:checked').forEach(cb => {
|
||
selected.push(cb.dataset.rangeId);
|
||
});
|
||
|
||
if (selected.length === 0) {
|
||
alert(bibJs('jsNoSeqSelected'));
|
||
return;
|
||
}
|
||
|
||
if (bibRowPendingBibs(row) > 0) {
|
||
bibAlertAutoPendingBibs(row);
|
||
return;
|
||
}
|
||
|
||
// MSIN-4379 — Persiste epr_bib_auto=1 sur les séquences choisies (save_auto_config).
|
||
fetch('/ajax_bib_range.php', {
|
||
method: 'POST',
|
||
headers: {
|
||
'Content-Type': 'application/x-www-form-urlencoded'
|
||
},
|
||
body:
|
||
'action=save_auto_config'
|
||
+ '&epr_id=' + encodeURIComponent(row.dataset.eprId)
|
||
+ '&active=1'
|
||
+ '&ranges=' + encodeURIComponent(JSON.stringify(selected))
|
||
+ bibAjaxLangSuffix()
|
||
})
|
||
.then(res => res.json())
|
||
.then(data => {
|
||
|
||
if (!data.success) {
|
||
alert(data.message || bibJs('jsErrGeneric'));
|
||
return;
|
||
}
|
||
|
||
syncAutoUiState(row, true);
|
||
exitAutoMode(row);
|
||
syncBibUiState(row);
|
||
});
|
||
|
||
return;
|
||
}
|
||
|
||
// MSIN-4379 — Annule l'édition sans appeler save_auto_config.
|
||
let btnAnnulerAuto = e.target.closest('.btn-annuler-auto');
|
||
if (btnAnnulerAuto) {
|
||
|
||
e.preventDefault();
|
||
|
||
let row = btnAnnulerAuto.closest('.epr-row');
|
||
if (!row) return;
|
||
|
||
exitAutoMode(row);
|
||
return;
|
||
}
|
||
|
||
// MSIN-4379 — Désactive l'auto en base (active=0, toutes les séquences à 0).
|
||
let btnDesactiverAuto = e.target.closest('.btn-desactiver-auto');
|
||
if (btnDesactiverAuto) {
|
||
|
||
e.preventDefault();
|
||
|
||
let row = btnDesactiverAuto.closest('.epr-row');
|
||
if (!row) return;
|
||
|
||
if (!confirm(bibJs('jsAutoDisableConfirm'))) {
|
||
return;
|
||
}
|
||
|
||
fetch('/ajax_bib_range.php', {
|
||
method: 'POST',
|
||
headers: {
|
||
'Content-Type': 'application/x-www-form-urlencoded'
|
||
},
|
||
body:
|
||
'action=save_auto_config'
|
||
+ '&epr_id=' + encodeURIComponent(row.dataset.eprId)
|
||
+ '&active=0'
|
||
+ '&ranges=' + encodeURIComponent('[]')
|
||
+ bibAjaxLangSuffix()
|
||
})
|
||
.then(res => res.json())
|
||
.then(data => {
|
||
|
||
if (!data.success) {
|
||
alert(data.message || bibJs('jsErrGeneric'));
|
||
return;
|
||
}
|
||
|
||
syncAutoUiState(row, false);
|
||
exitAutoMode(row);
|
||
syncBibUiState(row);
|
||
});
|
||
|
||
return;
|
||
}
|
||
|
||
// MSIN-4379 — Entrée dans le mode configuration auto.
|
||
let btnAuto = e.target.closest('.btn-auto');
|
||
if (btnAuto) {
|
||
|
||
e.preventDefault();
|
||
|
||
let row = btnAuto.closest('.epr-row');
|
||
if (!row) return;
|
||
|
||
if (row.classList.contains('batch-mode') || row.classList.contains('reset-mode')) {
|
||
return;
|
||
}
|
||
|
||
enterAutoMode(row);
|
||
return;
|
||
}
|
||
|
||
// =====================
|
||
// CREATE
|
||
// =====================
|
||
|
||
let btn = e.target.closest('.btn-add-range');
|
||
if (!btn) return;
|
||
|
||
e.preventDefault();
|
||
|
||
let container = btn.closest('.bib-container');
|
||
let errorDiv = container.querySelector('.bib-error-global');
|
||
|
||
// reset
|
||
if (errorDiv) {
|
||
errorDiv.style.display = 'none';
|
||
errorDiv.innerText = '';
|
||
}
|
||
|
||
let epr_id = btn.dataset.eprId;
|
||
if (!epr_id) return;
|
||
|
||
fetch('/ajax_bib_range.php', {
|
||
method: 'POST',
|
||
headers: {
|
||
'Content-Type': 'application/x-www-form-urlencoded'
|
||
},
|
||
body: 'action=create&epr_id=' + encodeURIComponent(epr_id) + bibAjaxLangSuffix()
|
||
})
|
||
.then(res => res.text())
|
||
.then(raw => {
|
||
|
||
let data;
|
||
try {
|
||
data = JSON.parse(raw);
|
||
} catch (err) {
|
||
if (errorDiv) {
|
||
errorDiv.innerText = bibJs('jsServerError');
|
||
errorDiv.style.display = 'block';
|
||
}
|
||
return;
|
||
}
|
||
|
||
if (!data.success) {
|
||
console.log('CREATE ERROR:', data);
|
||
console.log('container:', container);
|
||
console.log('errorDiv:', errorDiv);
|
||
if (errorDiv) {
|
||
errorDiv.innerText = data.message || bibJs('jsErrGeneric');
|
||
errorDiv.style.display = 'block';
|
||
}
|
||
return;
|
||
}
|
||
|
||
setBibContainerHtml(btn.closest('.epr-row'), data.html);
|
||
});
|
||
});
|
||
}
|
||
|
||
(function () {
|
||
var qrPanel = document.getElementById('inscr-mobile-qr-panel');
|
||
if (!qrPanel) {
|
||
return;
|
||
}
|
||
|
||
var qrReaderEl = document.getElementById('inscr-mobile-qr-reader');
|
||
var qrFeedback = document.getElementById('inscr-mobile-qr-feedback');
|
||
var qrCamera = null;
|
||
var qrStarting = false;
|
||
var lastQrRaw = '';
|
||
var qrResolvePending = false;
|
||
var qrLibPromise = null;
|
||
|
||
function loadHtml5Qrcode() {
|
||
if (window.Html5Qrcode) {
|
||
return Promise.resolve();
|
||
}
|
||
if (qrLibPromise) {
|
||
return qrLibPromise;
|
||
}
|
||
qrLibPromise = new Promise(function (resolve, reject) {
|
||
var script = document.createElement('script');
|
||
script.src = 'https://unpkg.com/html5-qrcode@2.3.8/html5-qrcode.min.js';
|
||
script.onload = function () {
|
||
resolve();
|
||
};
|
||
script.onerror = function () {
|
||
qrLibPromise = null;
|
||
reject(new Error('load'));
|
||
};
|
||
document.head.appendChild(script);
|
||
});
|
||
return qrLibPromise;
|
||
}
|
||
|
||
function showQrFeedback(type, message) {
|
||
if (!qrFeedback) {
|
||
return;
|
||
}
|
||
qrFeedback.className = 'alert mb-2 alert-' + type;
|
||
qrFeedback.textContent = message;
|
||
qrFeedback.classList.remove('d-none');
|
||
}
|
||
|
||
function hideQrFeedback() {
|
||
if (!qrFeedback) {
|
||
return;
|
||
}
|
||
qrFeedback.classList.add('d-none');
|
||
qrFeedback.textContent = '';
|
||
}
|
||
|
||
function stopQrScanner() {
|
||
if (!qrCamera) {
|
||
return Promise.resolve();
|
||
}
|
||
var instance = qrCamera;
|
||
qrCamera = null;
|
||
return instance.stop().catch(function () {
|
||
return null;
|
||
}).then(function () {
|
||
try {
|
||
instance.clear();
|
||
} catch (e) {
|
||
/* ignore */
|
||
}
|
||
});
|
||
}
|
||
|
||
function startQrScanner() {
|
||
if (qrStarting || qrCamera || !qrReaderEl) {
|
||
return;
|
||
}
|
||
qrStarting = true;
|
||
hideQrFeedback();
|
||
lastQrRaw = '';
|
||
|
||
loadHtml5Qrcode().then(function () {
|
||
if (!qrPanel.open) {
|
||
qrStarting = false;
|
||
return;
|
||
}
|
||
qrCamera = new Html5Qrcode('inscr-mobile-qr-reader');
|
||
return qrCamera.start(
|
||
{facingMode: 'environment'},
|
||
{fps: 8, qrbox: {width: 220, height: 220}},
|
||
onQrDecoded
|
||
);
|
||
}).catch(function () {
|
||
showQrFeedback('danger', qrPanel.getAttribute('data-qr-msg-camera') || '');
|
||
}).then(function () {
|
||
qrStarting = false;
|
||
});
|
||
}
|
||
|
||
function onQrDecoded(decodedText) {
|
||
if (!decodedText || decodedText === lastQrRaw || qrResolvePending) {
|
||
return;
|
||
}
|
||
lastQrRaw = decodedText;
|
||
qrResolvePending = true;
|
||
|
||
var resolveUrl = qrPanel.getAttribute('data-qr-resolve-url');
|
||
var eveId = qrPanel.getAttribute('data-qr-eve-id');
|
||
var lang = qrPanel.getAttribute('data-qr-lang') || 'fr';
|
||
|
||
if (!resolveUrl || !eveId) {
|
||
qrResolvePending = false;
|
||
return;
|
||
}
|
||
|
||
var body = new URLSearchParams();
|
||
body.set('qr', decodedText);
|
||
body.set('promoteur_eve_id', eveId);
|
||
body.set('lang', lang);
|
||
|
||
fetch(resolveUrl, {
|
||
method: 'POST',
|
||
headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'},
|
||
body: body.toString(),
|
||
credentials: 'same-origin'
|
||
}).then(function (response) {
|
||
return response.json();
|
||
}).then(function (data) {
|
||
qrResolvePending = false;
|
||
if (!data || !data.state) {
|
||
showQrFeedback('danger', qrPanel.getAttribute('data-qr-msg-invalid') || '');
|
||
window.setTimeout(function () {
|
||
lastQrRaw = '';
|
||
}, 2000);
|
||
return;
|
||
}
|
||
|
||
if (data.state === 'success' && data.pec_id) {
|
||
stopQrScanner().then(function () {
|
||
var url = new URL(window.location.href);
|
||
url.searchParams.set('pec_id', String(data.pec_id));
|
||
window.location.href = url.toString();
|
||
});
|
||
return;
|
||
}
|
||
|
||
if (data.state === 'wrong_event') {
|
||
var wrongTpl = qrPanel.getAttribute('data-qr-msg-wrong') || '';
|
||
var wrongMsg = data.message || wrongTpl.replace('%s', data.eve_nom || '');
|
||
showQrFeedback('warning', wrongMsg);
|
||
window.setTimeout(function () {
|
||
lastQrRaw = '';
|
||
}, 2500);
|
||
return;
|
||
}
|
||
|
||
showQrFeedback('danger', data.message || qrPanel.getAttribute('data-qr-msg-invalid') || '');
|
||
window.setTimeout(function () {
|
||
lastQrRaw = '';
|
||
}, 2000);
|
||
}).catch(function () {
|
||
qrResolvePending = false;
|
||
showQrFeedback('danger', qrPanel.getAttribute('data-qr-msg-invalid') || '');
|
||
window.setTimeout(function () {
|
||
lastQrRaw = '';
|
||
}, 2000);
|
||
});
|
||
}
|
||
|
||
qrPanel.addEventListener('toggle', function () {
|
||
if (qrPanel.open) {
|
||
startQrScanner();
|
||
} else {
|
||
stopQrScanner();
|
||
hideQrFeedback();
|
||
lastQrRaw = '';
|
||
qrResolvePending = false;
|
||
}
|
||
});
|
||
})();
|
||
|
||
(function () {
|
||
var moduleInscr = document.getElementById('module-inscr-mobile');
|
||
if (!moduleInscr) {
|
||
return;
|
||
}
|
||
|
||
var params = new URLSearchParams(window.location.search);
|
||
if (params.get('pec_id')) {
|
||
moduleInscr.scrollIntoView({block: 'start'});
|
||
} else if (params.get('pg') && parseInt(params.get('pg'), 10) > 1) {
|
||
var listAnchor = document.getElementById('inscr-mobile-list');
|
||
if (listAnchor) {
|
||
listAnchor.scrollIntoView({block: 'start'});
|
||
}
|
||
}
|
||
moduleInscr.addEventListener('click', function (e) {
|
||
var btnToggle = e.target.closest('.epr-block-toggle');
|
||
if (!btnToggle || !moduleInscr.contains(btnToggle)) {
|
||
return;
|
||
}
|
||
var block = btnToggle.closest('.epr-block');
|
||
if (!block) {
|
||
return;
|
||
}
|
||
var collapsed = block.classList.toggle('is-collapsed');
|
||
btnToggle.setAttribute('aria-expanded', collapsed ? 'false' : 'true');
|
||
var label = collapsed
|
||
? (btnToggle.getAttribute('data-label-expand') || '')
|
||
: (btnToggle.getAttribute('data-label-collapse') || '');
|
||
if (label) {
|
||
btnToggle.setAttribute('aria-label', label);
|
||
btnToggle.setAttribute('title', label);
|
||
}
|
||
var icon = btnToggle.querySelector('.fa');
|
||
if (icon) {
|
||
icon.classList.toggle('fa-chevron-up', !collapsed);
|
||
icon.classList.toggle('fa-chevron-down', collapsed);
|
||
}
|
||
});
|
||
})();
|
||
|
||
</script>
|
||
|