736 lines
28 KiB
PHP
736 lines
28 KiB
PHP
<?php global $vDomaine;
|
||
$com_id = 0;
|
||
|
||
if (isset($_SESSION['com_info']['com_id'])) {
|
||
$com_id = $_SESSION['com_info']['com_id'];
|
||
} ?>
|
||
<div class="footer container-fluid">
|
||
<p class="text-center">
|
||
Copyright © <? echo date('Y'); ?> <a href="http://www.progiweb.ca/" target="_blank">progiweb.ca</a> (A) |
|
||
Tous
|
||
droits réservés | SuperAdmin v<?php echo $vVersion; ?>
|
||
</p>
|
||
<p class="text-center text-muted">
|
||
<small>
|
||
<?php print_mem(); ?>
|
||
</small>
|
||
</p>
|
||
</div>
|
||
<div class="scroll-top-wrapper">
|
||
<span class="scroll-top-inner">
|
||
<i class="fa fa-chevron-up"></i>
|
||
</span>
|
||
</div>
|
||
|
||
<script type="text/javascript" src="jscripts/tiny_mce/tiny_mce.js"></script>
|
||
<!-- a faire MSIN-3930
|
||
<script>
|
||
var toolbarOptions = [
|
||
[{ 'font': [] }],
|
||
[{ 'header': [1, 2, 3, 4, 5, 6, false] }],
|
||
['bold', 'italic', 'underline', 'strike'], // toggled buttons
|
||
['blockquote', 'code-block'],
|
||
|
||
[{ 'header': 1 }, { 'header': 2 }], // custom button values
|
||
[{ 'list': 'ordered'}, { 'list': 'bullet' }],
|
||
[{ 'script': 'sub'}, { 'script': 'super' }], // superscript/subscript
|
||
[{ 'indent': '-1'}, { 'indent': '+1' }], // outdent/indent
|
||
[{ 'direction': 'rtl' }], // text direction
|
||
|
||
[{ 'color': [] }, { 'background': [] }], // dropdown with defaults from theme
|
||
[{ 'align': [] }],
|
||
|
||
['clean'], // remove formatting button
|
||
['link', 'image', 'video'] // link and image, video
|
||
];
|
||
-->
|
||
|
||
</script>
|
||
<script src="js/autosize.min.js"></script>
|
||
<script type="text/javascript">
|
||
tinyMCE.init({
|
||
mode: "specific_textareas",
|
||
editor_selector: "tinymce",
|
||
theme: "advanced",
|
||
plugins: 'advlink,advimage',
|
||
|
||
theme_advanced_buttons1: "bold,italic,strikethrough,forecolor,|,bullist,numlist,|,sub,sup,|,styleselect,formatselect",
|
||
theme_advanced_buttons2: "link,unlink,image,|,undo,redo,|,removeformat,cleanup,code",
|
||
theme_advanced_buttons3: "",
|
||
theme_advanced_toolbar_location: "top",
|
||
theme_advanced_toolbar_align: "left",
|
||
|
||
|
||
|
||
/* content_css : "css/bbcode.css", */
|
||
extended_valid_elements: "img[!src|border:0|alt|title|width|height|class]",
|
||
document_base_url: '<?php echo $vDomaine; ?>/'
|
||
});
|
||
</script>
|
||
<script type="text/javascript">
|
||
$(function () {
|
||
if (!('ontouchstart' in window)) {
|
||
$('[data-toggle="tooltip"]').tooltip({placement: 'auto'});
|
||
}
|
||
|
||
$("input[type=color]").spectrum({
|
||
showInput: true,
|
||
showInitial: true,
|
||
allowEmpty: true,
|
||
preferredFormat: 'hex'
|
||
});
|
||
$(".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;
|
||
});
|
||
|
||
$('.btn_update_panier').click(function () {
|
||
var $id = $(this).data('id');
|
||
var $table = $(this).data('table');
|
||
var $preloader = $('#preloader');
|
||
|
||
bootbox.confirm({
|
||
title: "PANIER",
|
||
message: "Êtes-vous certain de vouloir mettre à jour les infos du panier ?",
|
||
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_panier.php', 't=' + $table + '&id=' + $id, function ($resultajax) {
|
||
console.log($resultajax.sql);
|
||
$preloader.fadeOut();
|
||
if ($resultajax.statut == 'success') {
|
||
bootbox.alert({
|
||
size: "small",
|
||
title: "Résultat",
|
||
message: $resultajax.statut,
|
||
callback: function () {
|
||
window.location.reload();
|
||
}
|
||
});
|
||
} else {
|
||
bootbox.alert({
|
||
size: "small",
|
||
title: "Résultat",
|
||
message: $resultajax.statut,
|
||
callback: function () { /* your callback code */
|
||
}
|
||
});
|
||
}
|
||
}, 'json');
|
||
}
|
||
}
|
||
});
|
||
});
|
||
|
||
$('.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_import_question').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 copier les questions ?",
|
||
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) {
|
||
$('#frm_question_copy').submit();
|
||
|
||
}
|
||
}
|
||
});
|
||
});
|
||
$('.btn_login_as').click(function () {
|
||
var $id = $(this).data('id');
|
||
|
||
bootbox.confirm({
|
||
title: "CONNEXION",
|
||
message: "Êtes-vous certain de vouloir vous connecter en tant que " + $(this).data('usager') + " ?",
|
||
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) {
|
||
$.post('<?php echo $vDomaine; ?>/ajax_login.php', 'com_id=' + $id + '&lng=fr', function ($resultajax) {
|
||
if ($resultajax.state == 'true') {
|
||
bootbox.alert({
|
||
size: "small",
|
||
title: "Résultat",
|
||
message: '<a class="btn btn-primary rounded-pill" href="<?php echo $vDomaine; ?>" target="_blank">Aller sur le site</a>',
|
||
callback: function () {
|
||
//window.location.href = '';
|
||
}
|
||
});
|
||
} else {
|
||
bootbox.alert({
|
||
size: "small",
|
||
title: "Résultat",
|
||
message: $resultajax.state,
|
||
callback: function () { /* your callback code */
|
||
}
|
||
});
|
||
}
|
||
}, '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') {
|
||
if ($action === 'delete2') {
|
||
location.reload(); // recharge la page avec les mêmes paramètres
|
||
return; // pour éviter d'exécuter la suite inutilement
|
||
}
|
||
|
||
$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_update_statut').click(function () {
|
||
//if (confirm("Êtes-vous certain de vouloir annuler cette commande ?")) {
|
||
var $id = $(this).data('ach_id');
|
||
|
||
$.post('<?php echo $vDomaine; ?>/superadm/ajax_update_statut.php', 'id=' + $id, function ($result) {
|
||
if ($result.state == 'success') {
|
||
$('#statut_' + $id).html($result.statut);
|
||
} else {
|
||
alert($result.state);
|
||
}
|
||
}, 'json');
|
||
//}
|
||
});
|
||
|
||
$('#btn_maintenance').click(function () {
|
||
event.preventDefault();
|
||
var $preloader = $('#preloader');
|
||
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');
|
||
|
||
bootbox.confirm({
|
||
title: "Maintenance",
|
||
message: "Êtes-vous certain de vouloir changer l'état du site ?",
|
||
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();
|
||
//window.location.href = '<?php echo $vDomaine; ?>/superadm/enregistrer.php?action=' + $action + '&table=' + $table + '&field=' + $field + '&key=' + $key + '&valeur=' + $valeur + '&id=' + $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 ($valeur == 1) {
|
||
$link.data('valeur', 0);
|
||
$link.html('<i class="fa fa-times mr-2" aria-hidden="true"></i>En maintenance');
|
||
} else {
|
||
$link.data('valeur', 1);
|
||
$link.html('<i class="fa fa-check mr-2" aria-hidden="true"></i>En ligne');
|
||
}
|
||
} else {
|
||
alert($result.state);
|
||
}
|
||
|
||
$preloader.fadeOut();
|
||
}, 'json');
|
||
}
|
||
}
|
||
});
|
||
});
|
||
|
||
$('#btn_confirm_mail').click(function () {
|
||
event.preventDefault();
|
||
var $preloader = $('#preloader');
|
||
var $link = $(this);
|
||
var $action = $link.data('action');
|
||
var $key = $link.data('key');
|
||
var $valeur = $link.data('valeur');
|
||
|
||
bootbox.confirm({
|
||
title: "Confirmation par courriel",
|
||
message: "Êtes-vous certain de vouloir changer l'état des confirmations par courriel ?",
|
||
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();
|
||
//window.location.href = '<?php echo $vDomaine; ?>/superadm/enregistrer.php?action=' + $action + '&table=' + $table + '&field=' + $field + '&key=' + $key + '&valeur=' + $valeur + '&id=' + $id;
|
||
$.post('<?php echo $vDomaine; ?>/superadm/enregistrer.php', 'action=' + $action + '&key=' + $key + '&valeur=' + $valeur, function ($result) {
|
||
if ($result.state == 'success') {
|
||
$link.toggleClass('btn-danger');
|
||
$link.toggleClass('btn-success');
|
||
|
||
if ($valeur == 1) {
|
||
$link.data('valeur', 0);
|
||
$link.html('<i class="fa fa-envelope mr-2" aria-hidden="true"></i>Envoyer courriel');
|
||
} else {
|
||
$link.data('valeur', 1);
|
||
$link.html('<span class="fa-stack fa-lg"><i class="fa fa-envelope-o fa-stack-1x"></i><i class="fa fa-ban fa-stack-2x"></i> </span>Aucun envoi courriel');
|
||
}
|
||
} else {
|
||
alert($result.state);
|
||
}
|
||
|
||
$preloader.fadeOut();
|
||
}, 'json');
|
||
}
|
||
}
|
||
});
|
||
});
|
||
|
||
autosize($('textarea'));
|
||
|
||
|
||
$(".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);
|
||
$('.check').on('click', check);
|
||
$('.check_ques').on('click', check);
|
||
$('#checkall').on('click', checkall);
|
||
$('#checkalltrie').on('click', checkalltrie);
|
||
$('#groupe').on('click', groupechange);
|
||
$(".checktrie").on( "click", function(event) {
|
||
event.preventDefault();
|
||
|
||
var $link = $(this);
|
||
var $trie = $link.data('trie');
|
||
var $index = $link.data('index');
|
||
// alert('<?php echo $vDomaine; ?>/superadm/enregistrer.php?action=triechange&key= <?php echo $com_id ?>&trie=' + $trie + '&index=' + $index);
|
||
$.post('<?php echo $vDomaine; ?>/superadm/enregistrer.php', 'action=triechange&key= <?php echo $com_id ?>&trie=' + $trie + '&index=' + $index, function ($result) {
|
||
|
||
if ($result.state == 'success') {
|
||
location.reload();
|
||
} else {
|
||
alert($result.state);
|
||
}
|
||
|
||
|
||
}, 'json');
|
||
|
||
|
||
});
|
||
|
||
});
|
||
mem_checkall = 0;
|
||
|
||
|
||
|
||
function checkalltrie() {
|
||
|
||
|
||
$.post('<?php echo $vDomaine; ?>/superadm/enregistrer.php', 'action=triecheckall&key= <?php echo $com_id ?>', function ($result) {
|
||
|
||
if ($result.state == 'success') {
|
||
location.reload();
|
||
} else {
|
||
alert($result.state);
|
||
}
|
||
}, 'json');
|
||
}
|
||
function groupechange() {
|
||
checkbox_to_update = $("input[id='groupe']").is(':checked');;
|
||
|
||
$.post('<?php echo $vDomaine; ?>/superadm/enregistrer.php', 'action=groupechange&key= <?php echo $com_id ?>&groupe='+checkbox_to_update, function ($result) {
|
||
|
||
if ($result.state == 'success') {
|
||
// location.reload();
|
||
} else {
|
||
alert($result.state);
|
||
}
|
||
}, 'json');
|
||
}
|
||
function checkall() {
|
||
|
||
if (mem_checkall == 1) {
|
||
$(".check").each(function () {
|
||
$(this).prop("checked", true);
|
||
})
|
||
$(".check_ques").each(function () {
|
||
$(this).prop("checked", true);
|
||
})
|
||
mem_checkall = 0;
|
||
} else {
|
||
$(".check").each(function () {
|
||
$(this).prop("checked", false);
|
||
});
|
||
$(".check_ques").each(function () {
|
||
$(this).prop("checked", false);
|
||
});
|
||
mem_checkall = 1
|
||
|
||
}
|
||
check();
|
||
|
||
}
|
||
|
||
function check() {
|
||
|
||
var fields = $(".check").serializeArray();
|
||
var chk_col = '';
|
||
jQuery.each(fields, function (i, field) {
|
||
chk_col = chk_col + field.value + ",";
|
||
});
|
||
var chk_ques = '';
|
||
|
||
var fields = $(".check_ques").serializeArray();
|
||
jQuery.each(fields, function (i, field) {
|
||
chk_ques = chk_ques + field.value + ",";
|
||
});
|
||
|
||
|
||
$key = '99999';
|
||
|
||
$.post('<?php echo $vDomaine; ?>/superadm/enregistrer.php', 'action=chksave&key= <?php echo $com_id ?>&chk_col=' + chk_col + '&chk_ques=' + chk_ques, function ($result) {
|
||
|
||
if ($result.state == 'success') {
|
||
|
||
} else {
|
||
alert($result.state);
|
||
}
|
||
|
||
|
||
}, 'json');
|
||
|
||
}
|
||
|
||
|
||
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');
|
||
}
|
||
|
||
$('#preloader').fadeOut();
|
||
(function($){
|
||
// Au clic sur un résultat déjà rendu par TON code
|
||
$('#pp-results').on('click', '.list-group-item', function(e){
|
||
e.preventDefault();
|
||
|
||
// Récupère l'ID du promoteur (prend ce qu’il trouve : data-id, data-com-id ou #pp-com-id)
|
||
var comId = $(this).data('id') || $(this).data('comId') || $('#pp-com-id').val();
|
||
var email = $(this).data('email') || $(this).text().trim();
|
||
|
||
if (!comId) {
|
||
alert("ID du promoteur introuvable.");
|
||
return;
|
||
}
|
||
|
||
if (!confirm("Confirmer l’ajout du promoteur :\n" + email)) return;
|
||
|
||
// Construit l’URL "comme delete" en gardant les params actuels
|
||
var p = new URLSearchParams(window.location.search);
|
||
var url = 'index.php'
|
||
+ '?t=' + encodeURIComponent(p.get('t') || '')
|
||
+ '&a=' + encodeURIComponent(p.get('a') || 'mod')
|
||
+ '&id=' + encodeURIComponent(p.get('id') || '0')
|
||
+ '&eve_id=' + encodeURIComponent(p.get('eve_id') || '0')
|
||
+ '&action=addpromoteur'
|
||
+ '&promoteur_id=' + encodeURIComponent(comId);
|
||
|
||
window.location.href = url; // => même comportement que ton bouton DELETE
|
||
});
|
||
})(jQuery);
|
||
(function($){
|
||
var $wrap = $('#pick-promoteur');
|
||
var $in = $('#pp-email');
|
||
var $list = $('#pp-results');
|
||
var timer = null, xhr = null;
|
||
|
||
function render(items){
|
||
$list.empty();
|
||
if (!items || !items.length) { $list.addClass('d-none'); return; }
|
||
items.forEach(function(it){
|
||
$('<a href="#" class="list-group-item list-group-item-action"></a>')
|
||
.text(it.email)
|
||
.attr('data-id', it.id || it.com_id) // << ESSENTIEL
|
||
.data('item', it)
|
||
.appendTo($list);
|
||
});
|
||
$list.removeClass('d-none');
|
||
}
|
||
|
||
$in.on('input', function(){
|
||
var q = $.trim(this.value);
|
||
$list.addClass('d-none').empty();
|
||
if (q.length < 2) return;
|
||
|
||
clearTimeout(timer);
|
||
timer = setTimeout(function(){
|
||
if (xhr) xhr.abort();
|
||
var eveId = new URLSearchParams(window.location.search).get('id') || 0;
|
||
|
||
xhr = $.getJSON('ajax_newpromoteur.php',
|
||
{ action:'search_email', q:q, eve_id: eveId },
|
||
render
|
||
).fail(function(){ render([]); });
|
||
}, 200);
|
||
});
|
||
|
||
$list.on('click', '.list-group-item', function(e){
|
||
e.preventDefault();
|
||
var item = $(this).data('item'); // { id, email }
|
||
$in.val(item.email);
|
||
$list.addClass('d-none').empty();
|
||
|
||
// 👉 Hook ultra simple : TU gères la suite ici
|
||
// Exemple : déclencher un événement que tu captes ailleurs
|
||
$(document).trigger('email-choisi', [item]);
|
||
|
||
// Ou appelle une fonction globale si tu préfères:
|
||
if (window.onEmailChoisi) window.onEmailChoisi(item);
|
||
});
|
||
|
||
// Ferme la liste si clic à l'extérieur
|
||
$(document).on('click', function(e){
|
||
if (!$(e.target).closest($wrap).length) $list.addClass('d-none');
|
||
});
|
||
})(jQuery);
|
||
|
||
|
||
(function($){
|
||
var $wrapE = $('#pick-evenement');
|
||
var $inE = $('#pp-evenement');
|
||
var $listE = $('#pp-results-eve');
|
||
var timerE = null, xhrE = null;
|
||
|
||
function renderE(items){
|
||
$listE.empty();
|
||
if (!items || !items.length) { $listE.addClass('d-none'); return; }
|
||
|
||
items.forEach(function(it){
|
||
const id = it.eve_id || it.id || it.id_eve || it.eveId;
|
||
const nom = it.eve_nom_fr || it.nom || it.titre || it.name || it.label;
|
||
|
||
$('<a href="#" class="list-group-item list-group-item-action"></a>')
|
||
.text(nom || '(sans nom)')
|
||
.attr('data-eve-id', id) // lisible avec .data('eveId')
|
||
.attr('data-id', id) // fallback lisible avec .data('id')
|
||
.data('item', it) // objet complet (debug/flex)
|
||
.appendTo($listE);
|
||
});
|
||
$listE.removeClass('d-none');
|
||
}
|
||
|
||
$inE.on('input', function(){
|
||
var q = $.trim(this.value);
|
||
$listE.addClass('d-none').empty();
|
||
if (q.length < 2) return;
|
||
|
||
clearTimeout(timerE);
|
||
timerE = setTimeout(function(){
|
||
if (xhrE) xhrE.abort();
|
||
var currentId = new URLSearchParams(window.location.search).get('id') || 0;
|
||
|
||
xhrE = $.getJSON('ajax_newpromoteur.php',
|
||
{ action:'search_evenement', q:q, eve_id: currentId },
|
||
renderE
|
||
).fail(function(){ renderE([]); });
|
||
}, 200);
|
||
});
|
||
|
||
// ⚠️ NE METS PAS ICI un autre on('click'...) pour #pp-results-eve
|
||
})(jQuery);
|
||
|
||
// === CLIC (unique) QUI CONFIRME ET REDIRIGE ===
|
||
$('#pp-results-eve').on('click', '.list-group-item', function(e){
|
||
e.preventDefault();
|
||
|
||
const $a = $(this);
|
||
const item = $a.data('item') || {};
|
||
const eveId =
|
||
item.eve_id || item.id || item.id_eve || item.eveId ||
|
||
$a.data('eveId') || $a.data('eve_id') || $a.data('id');
|
||
const label =
|
||
item.eve_nom_fr || item.nom || item.titre || item.name || $a.text().trim();
|
||
|
||
if (!eveId) {
|
||
alert("ID de l’événement introuvable.");
|
||
console.log('a.outerHTML=', $a.get(0).outerHTML);
|
||
console.log('a.data()=', $a.data());
|
||
console.log('item=', item);
|
||
return;
|
||
}
|
||
|
||
if (!confirm("Confirmer l’ajout de l’événement :\n" + label)) return;
|
||
|
||
const p = new URLSearchParams(window.location.search);
|
||
const url = 'index.php'
|
||
+ '?t=' + encodeURIComponent(p.get('t') || '')
|
||
+ '&a=' + encodeURIComponent(p.get('a') || 'mod')
|
||
+ '&id=' + encodeURIComponent(p.get('id') || '0')
|
||
+ '&eve_id=' + encodeURIComponent(p.get('eve_id') || '0')
|
||
+ '&action=addevenement' // <-- adapte si nécessaire
|
||
+ '&evenement_id=' + encodeURIComponent(eveId); // <-- nom du param attendu en PHP
|
||
|
||
window.location.href = url;
|
||
});
|
||
// Sur Enter
|
||
$(document).on("keydown", ".js-commit-on-enter", function (e) {
|
||
if (e.key === "Enter") {
|
||
e.preventDefault();
|
||
envoyerValeur($(this));
|
||
}
|
||
});
|
||
|
||
// Quand on quitte le champ (blur)
|
||
$(document).on("blur", ".js-commit-on-enter", function () {
|
||
envoyerValeur($(this));
|
||
});
|
||
|
||
// --- fonction utilitaire qui envoie la valeur ---
|
||
function envoyerValeur($input) {
|
||
var $preloader = $('#preloader');
|
||
$preloader.show();
|
||
|
||
$.post('<?php echo $vDomaine; ?>/superadm/enregistrer.php', {
|
||
action: $input.data('action'),
|
||
table: $input.data('table'),
|
||
field: $input.data('field'),
|
||
key: $input.data('key'),
|
||
valeur: $input.val(),
|
||
id: $input.data('id')
|
||
}, function (result) {
|
||
if (result.state !== 'success') {
|
||
alert(result.state);
|
||
}
|
||
$preloader.fadeOut();
|
||
}, 'json');
|
||
}
|
||
|
||
|
||
</script>
|
||
</body>
|
||
</html>
|