2893 lines
114 KiB
PHP
2893 lines
114 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':
|
||
if ($footer_script == true) {
|
||
?>
|
||
|
||
$('.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]);
|
||
$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 ($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']);
|
||
}
|
||
}
|
||
}
|
||
}, '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;
|
||
}
|
||
});
|
||
$('#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();
|
||
});
|
||
$(".send_jira").click(function (event) {
|
||
event.preventDefault();
|
||
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 email = $('#txt_courriel').val();
|
||
const nom = $('#txt_nom').val();
|
||
const description = $('#txt_message').val();
|
||
const summary = $('#txt_sujet').val();
|
||
const typedemande = $('#typedemande').val();
|
||
|
||
const postData = {
|
||
request_type: 'check_email',
|
||
email, nom, summary, description, typedemande
|
||
};
|
||
|
||
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; ?>';
|
||
} else {
|
||
// alert("Une erreur est survenue dans Jira : " + JSON.stringify(data));
|
||
}
|
||
})
|
||
.catch(error => {
|
||
console.error("🔥 Erreur AJAX:", error.message);
|
||
// alert("Erreur : " + error.message);
|
||
});
|
||
}
|
||
|
||
|
||
// 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 syncBibUiState(row) {
|
||
|
||
let avecEl = row.querySelector('.bib-avec');
|
||
if (!avecEl) return;
|
||
|
||
let avecBib = parseInt(avecEl.textContent || '0', 10);
|
||
let hasBib = avecBib > 0;
|
||
|
||
// =====================
|
||
// RADIO TEAM MODE
|
||
// =====================
|
||
row.querySelectorAll('.team-mode-box input[type="radio"]').forEach(radio => {
|
||
|
||
if (!radio.closest('.team-mode-option.disabled')) {
|
||
radio.disabled = hasBib;
|
||
}
|
||
|
||
});
|
||
|
||
// =====================
|
||
// RESET BUTTON
|
||
// =====================
|
||
let btnReset = row.querySelector('.btn-reset');
|
||
|
||
if (btnReset) {
|
||
btnReset.style.display = hasBib ? '' : 'none';
|
||
}
|
||
|
||
// =====================
|
||
// ASSIGN BUTTON
|
||
// =====================
|
||
let btnBatch = row.querySelector('.btn-assign-batch');
|
||
|
||
if (btnBatch && !row.classList.contains('reset-mode')) {
|
||
btnBatch.style.display = hasBib ? '' : '';
|
||
}
|
||
}
|
||
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.children[5];
|
||
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)
|
||
})
|
||
.then(res => res.json())
|
||
.then(data => {
|
||
|
||
if (!data.success) return;
|
||
|
||
let totalEl = row.querySelector('.bib-total');
|
||
let avecEl = row.querySelector('.bib-avec');
|
||
|
||
if (totalEl) totalEl.textContent = data.info.total;
|
||
if (avecEl) avecEl.textContent = data.info.avec_bib;
|
||
syncBibUiState(row);
|
||
let sansBib = parseInt(data.info.sans_bib || 0, 10);
|
||
if (isNaN(sansBib)) sansBib = 0;
|
||
let isResetMode = row.dataset.mode === 'reset';
|
||
let message = '';
|
||
|
||
if (isResetMode) {
|
||
|
||
if (totalReset === 0) {
|
||
message = 'Aucun dossard sélectionné';
|
||
} else {
|
||
message = totalReset + ' dossards seront retirés';
|
||
}
|
||
|
||
} else {
|
||
|
||
if (totalDispo === 0) {
|
||
message = 'Aucun dossard sélectionné';
|
||
} else if (totalDispo < sansBib) {
|
||
message = totalDispo + ' disponibles / ' + sansBib + ' à assigner → manque ' + (sansBib - totalDispo);
|
||
} else {
|
||
message = totalDispo + ' disponibles / ' + sansBib + ' à assigner → OK';
|
||
}
|
||
|
||
}
|
||
|
||
let info = row.querySelector('.epr-actions .batch-info');
|
||
if (info) {
|
||
info.textContent = message;
|
||
}
|
||
});
|
||
}
|
||
|
||
// =====================
|
||
// 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)
|
||
});
|
||
|
||
return;
|
||
}
|
||
|
||
let cb = e.target.closest('.batch-select-range');
|
||
if (!cb) return;
|
||
|
||
let row = cb.closest('.epr-row');
|
||
if (!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')
|
||
})
|
||
.then(res => res.json())
|
||
.then(data => {
|
||
|
||
if (!data.success) {
|
||
row.dataset.loading = '0';
|
||
return;
|
||
}
|
||
|
||
let container = row.querySelector('.epr-block:nth-child(2) .bib-container');
|
||
if (!container) {
|
||
row.dataset.loading = '0';
|
||
return;
|
||
}
|
||
|
||
// 4. refresh complet serveur
|
||
container.innerHTML = data.html;
|
||
// 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);
|
||
// 7. afficher bouton GO
|
||
let goBtn = row.querySelector('.btn-go-batch');
|
||
let simBtn = row.querySelector('.btn-simuler-batch');
|
||
|
||
let hasSelection = selected.length > 0;
|
||
|
||
if (goBtn) goBtn.style.display = hasSelection ? 'inline-block' : 'none';
|
||
if (simBtn) simBtn.style.display = hasSelection ? 'inline-block' : 'none';
|
||
|
||
|
||
row.dataset.loading = '0';
|
||
|
||
})
|
||
.catch(() => {
|
||
row.dataset.loading = '0';
|
||
});
|
||
|
||
}, 0);
|
||
});
|
||
|
||
moduleBib.addEventListener('click', function (e) {
|
||
|
||
// =====================
|
||
// 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)
|
||
})
|
||
.then(res => res.text())
|
||
.then(raw => {
|
||
|
||
let data;
|
||
try {
|
||
data = JSON.parse(raw);
|
||
} catch (err) {
|
||
if (errorDiv) {
|
||
errorDiv.innerText = 'Erreur serveur';
|
||
errorDiv.style.display = 'block';
|
||
}
|
||
return;
|
||
}
|
||
|
||
if (!data.success) {
|
||
if (errorDiv) {
|
||
errorDiv.innerText = data.message || 'Erreur delete';
|
||
errorDiv.style.display = 'block';
|
||
}
|
||
return;
|
||
}
|
||
|
||
container.innerHTML = 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 = 'Champs requis';
|
||
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)
|
||
})
|
||
.then(res => res.text())
|
||
.then(raw => {
|
||
|
||
let data;
|
||
try {
|
||
data = JSON.parse(raw);
|
||
} catch (err) {
|
||
errorDiv.innerText = 'Erreur serveur';
|
||
errorDiv.style.display = 'block';
|
||
return;
|
||
}
|
||
|
||
if (!data.success) {
|
||
errorDiv.innerText = data.message || 'Erreur save';
|
||
errorDiv.style.display = 'block';
|
||
return;
|
||
}
|
||
|
||
let container = btnSave.closest('.bib-container');
|
||
container.innerHTML = 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');
|
||
|
||
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)
|
||
})
|
||
.then(res => res.text())
|
||
.then(raw => {
|
||
|
||
let data;
|
||
try {
|
||
data = JSON.parse(raw);
|
||
} catch (err) {
|
||
console.log('Erreur serveur');
|
||
return;
|
||
}
|
||
|
||
if (!data.success) {
|
||
console.log(data.message || 'Erreur view');
|
||
return;
|
||
}
|
||
|
||
let row = btnView.closest('.epr-row');
|
||
|
||
// 1. Supprimer toute vue existante
|
||
let existing = document.querySelector('.epr-row-view');
|
||
if (existing) {
|
||
existing.remove();
|
||
}
|
||
|
||
// 2. Injecter sous la bonne ligne
|
||
row.insertAdjacentHTML('afterend', data.html);
|
||
});
|
||
|
||
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;
|
||
|
||
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');
|
||
});
|
||
|
||
let config = row.querySelector('.batch-config-container');
|
||
if (config) config.style.display = 'none';
|
||
|
||
btnBatch.textContent = 'Assigner batch';
|
||
|
||
let goBtn = row.querySelector('.btn-go-batch');
|
||
if (goBtn) {
|
||
goBtn.style.display = 'none';
|
||
goBtn.textContent = 'GO';
|
||
}
|
||
// Reset des checkbox
|
||
row.querySelectorAll('.batch-select-range').forEach(cb => {
|
||
cb.checked = false;
|
||
});
|
||
let info = row.querySelector('.epr-actions .batch-info');
|
||
if (info) info.textContent = '';
|
||
return;
|
||
}
|
||
|
||
// ON
|
||
row.classList.add('batch-mode');
|
||
container.classList.add('batch-mode');
|
||
|
||
row.querySelectorAll('.bib-start, .bib-end').forEach(input => {
|
||
input.setAttribute('readonly', true);
|
||
});
|
||
|
||
let config = row.querySelector('.batch-config-container');
|
||
if (config) config.style.display = 'block';
|
||
|
||
btnBatch.textContent = 'Annuler batch';
|
||
let goBtn = row.querySelector('.btn-go-batch');
|
||
if (goBtn) {
|
||
goBtn.textContent = 'GO';
|
||
}
|
||
if (typeof updateBatchAnalysis === 'function') {
|
||
updateBatchAnalysis(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('Aucun segment sélectionné');
|
||
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)
|
||
})
|
||
.then(res => res.json())
|
||
.then(data => {
|
||
|
||
if (!data.success) {
|
||
alert(data.message || 'Erreur batch');
|
||
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;
|
||
|
||
let container = row.querySelector('.bib-container');
|
||
if (!container) return;
|
||
|
||
// =====================
|
||
// OFF
|
||
// =====================
|
||
if (row.classList.contains('reset-mode')) {
|
||
|
||
row.classList.remove('reset-mode');
|
||
btnReset.textContent = 'Réinitialiser';
|
||
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 config = row.querySelector('.batch-config-container');
|
||
if (config) config.style.display = 'none';
|
||
|
||
let goBtn = row.querySelector('.btn-go-batch');
|
||
if (goBtn) {
|
||
goBtn.style.display = 'none';
|
||
goBtn.textContent = 'GO';
|
||
}
|
||
|
||
let simBtn = row.querySelector('.btn-simuler-batch');
|
||
if (simBtn) {
|
||
simBtn.style.display = 'none';
|
||
}
|
||
|
||
let orderBlock = row.querySelector('.batch-order');
|
||
if (orderBlock) {
|
||
orderBlock.closest('.mb-2').style.display = '';
|
||
}
|
||
let btnBatch = row.querySelector('.btn-assign-batch');
|
||
if (btnBatch) {
|
||
btnBatch.style.display = '';
|
||
}
|
||
|
||
let btnAuto = row.querySelector('.btn-auto');
|
||
if (btnAuto) {
|
||
btnAuto.style.display = '';
|
||
}
|
||
let info = row.querySelector('.epr-actions .batch-info');
|
||
if (info) {
|
||
info.innerHTML = '';
|
||
}
|
||
row.dataset.mode = '';
|
||
return;
|
||
}
|
||
|
||
// =====================
|
||
// ON
|
||
// =====================
|
||
row.classList.add('reset-mode');
|
||
btnReset.textContent = 'Annuler réinitialisation';
|
||
row.dataset.mode = 'reset';
|
||
container.classList.add('batch-mode');
|
||
|
||
row.querySelectorAll('.bib-start, .bib-end').forEach(input => {
|
||
input.setAttribute('readonly', true);
|
||
});
|
||
|
||
let config = row.querySelector('.batch-config-container');
|
||
if (config) config.style.display = 'block';
|
||
let btnBatch = row.querySelector('.btn-assign-batch');
|
||
if (btnBatch) {
|
||
btnBatch.style.display = 'none';
|
||
}
|
||
|
||
let btnAuto = row.querySelector('.btn-auto');
|
||
if (btnAuto) {
|
||
btnAuto.style.display = 'none';
|
||
}
|
||
|
||
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'
|
||
})
|
||
.then(res => res.json())
|
||
.then(data => {
|
||
|
||
if (!data.success) return;
|
||
|
||
let container = row.querySelector('.epr-block:nth-child(2) .bib-container');
|
||
if (!container) return;
|
||
|
||
container.innerHTML = data.html;
|
||
|
||
container.classList.add('batch-mode');
|
||
|
||
row.querySelectorAll('.bib-start, .bib-end').forEach(input => {
|
||
input.setAttribute('readonly', true);
|
||
});
|
||
|
||
});
|
||
|
||
|
||
// cacher ordre
|
||
let orderBlock = row.querySelector('.batch-order');
|
||
if (orderBlock) {
|
||
orderBlock.closest('.mb-2').style.display = 'none';
|
||
}
|
||
|
||
// cacher simuler
|
||
let simBtn = row.querySelector('.btn-simuler-batch');
|
||
if (simBtn) {
|
||
simBtn.style.display = 'none';
|
||
}
|
||
|
||
// bouton GO
|
||
let goBtn = row.querySelector('.btn-go-batch');
|
||
if (goBtn) {
|
||
goBtn.style.display = 'none';
|
||
goBtn.textContent = 'Réinitialiser';
|
||
}
|
||
|
||
// warning
|
||
let info = row.querySelector('.epr-actions .batch-info');
|
||
if (info) {
|
||
info.innerHTML = '<span style="color:red;">Attention : tous les dossards assignés dans les séquences sélectionnées seront retirés.</span>';
|
||
}
|
||
|
||
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('Aucun segment sélectionné');
|
||
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)
|
||
})
|
||
.then(res => res.json())
|
||
.then(data => {
|
||
|
||
if (!data.success) {
|
||
alert(data.message || 'Erreur batch');
|
||
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 = 'Réinitialiser';
|
||
}
|
||
|
||
let btnBatch = row.querySelector('.btn-assign-batch');
|
||
if (btnBatch) {
|
||
btnBatch.style.display = '';
|
||
}
|
||
|
||
let btnAuto = row.querySelector('.btn-auto');
|
||
if (btnAuto) {
|
||
btnAuto.style.display = '';
|
||
}
|
||
|
||
let orderBlock = row.querySelector('.batch-order');
|
||
if (orderBlock) {
|
||
orderBlock.closest('.mb-2').style.display = '';
|
||
}
|
||
}
|
||
row.classList.remove('batch-mode');
|
||
|
||
let container = row.querySelector('.bib-container');
|
||
if (container) {
|
||
container.classList.remove('batch-mode');
|
||
}
|
||
|
||
// reset bouton
|
||
let btnBatch = row.querySelector('.btn-assign-batch');
|
||
if (btnBatch) {
|
||
btnBatch.textContent = 'Assigner batch';
|
||
}
|
||
|
||
// réactiver champs
|
||
row.querySelectorAll('.bib-start, .bib-end').forEach(input => {
|
||
input.removeAttribute('readonly');
|
||
});
|
||
|
||
// reset checkbox
|
||
row.querySelectorAll('.batch-select-range').forEach(cb => {
|
||
cb.checked = false;
|
||
cb.disabled = false;
|
||
});
|
||
|
||
// cacher boutons batch
|
||
let goBtn = row.querySelector('.btn-go-batch');
|
||
let simBtn = row.querySelector('.btn-simuler-batch');
|
||
|
||
if (goBtn) goBtn.style.display = 'none';
|
||
if (simBtn) simBtn.style.display = 'none';
|
||
|
||
// cacher config
|
||
let config = row.querySelector('.batch-config-container');
|
||
if (config) config.style.display = 'none';
|
||
|
||
// =====================
|
||
// REFRESH RANGES
|
||
// =====================
|
||
|
||
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'
|
||
})
|
||
.then(res => res.json())
|
||
.then(refresh => {
|
||
|
||
if (!refresh.success) return;
|
||
|
||
let container = row.querySelector('.epr-block:nth-child(2) .bib-container');
|
||
if (!container) return;
|
||
|
||
container.innerHTML = refresh.html;
|
||
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)
|
||
})
|
||
.then(res => res.json())
|
||
.then(stats => {
|
||
|
||
if (!stats.success) return;
|
||
|
||
let totalEl = row.querySelector('.bib-total');
|
||
let avecEl = row.querySelector('.bib-avec');
|
||
|
||
if (totalEl) totalEl.textContent = stats.info.total;
|
||
if (avecEl) avecEl.textContent = stats.info.avec_bib;
|
||
syncBibUiState(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)
|
||
})
|
||
.then(res => res.text())
|
||
.then(raw => {
|
||
|
||
let data;
|
||
try {
|
||
data = JSON.parse(raw);
|
||
} catch (err) {
|
||
if (errorDiv) {
|
||
errorDiv.innerText = 'Erreur serveur';
|
||
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 || 'Erreur';
|
||
errorDiv.style.display = 'block';
|
||
}
|
||
return;
|
||
}
|
||
|
||
container.innerHTML = data.html;
|
||
});
|
||
});
|
||
}
|
||
|
||
</script>
|
||
|