Enhance bib management with restore functionality on duplicate check

This commit adds a restore feature for bib numbers in the registration management interface. When a duplicate bib is detected, the previously entered value is restored, improving user experience by preventing accidental data loss. The changes include new functions to manage the restoration process and updates to the existing AJAX handling to ensure the correct bib value is maintained during interactions. This enhancement builds on the previously implemented duplicate check feature, further refining the registration workflow.
This commit is contained in:
2026-06-29 11:12:14 -04:00
parent 811cf02f16
commit b5daa5a4ba

View File

@ -1070,12 +1070,24 @@ if ($strLangue == 'fr') {
}
(function (action, parId, pecId, eveId, eprId, newBib) {
// Champ de saisie du dossard (pour pouvoir restaurer l'ancienne valeur).
var $bibInput = $((action == 'no_equipe' ? '#txt_no_bib_e' : '#txt_no_bib_p') + parId);
// Restaure le dossard precedemment enregistre (valeur de reference du champ).
function restoreBib() {
if ($bibInput.length) { $bibInput.val($bibInput[0].defaultValue); }
}
// Enregistrement reel du dossard (chemin legacy promoteur, inchange).
function saveBib() {
$preloader_text.html('<?php afficheTexte('preloader_wait', 1, 0, 1); ?>');
$preloader.show();
$.post('<?php echo $vDomaine; ?>/ajax_promoteur.php', 'a=' + action + '&eve_id=' + eveId + '&new_no_bib=' + newBib + '&pec_id=' + pecId + '&epr_id=' + eprId + '&par_id=' + parId + '&lang=<?php echo $strLangue; ?>', function ($result) {
// Succes : rien a afficher pour l'instant.
// Memorise la valeur enregistree comme nouvelle reference, pour qu'un
// futur "Annuler" restaure bien CE dossard (et non l'original a l'ouverture).
if ($result && $result.state == 'success' && $bibInput.length) {
$bibInput[0].defaultValue = newBib;
}
}, 'json');
$preloader.fadeOut('slow');
}
@ -1101,6 +1113,7 @@ if ($strLangue == 'fr') {
// Politique bloquante (prevue pour le futur) : interdiction pure.
if (chk.policy === 'block') {
restoreBib();
bootbox.alert({
title: "<?php if ($strLangue == 'fr') { ?>Dossard déjà utilisé<?php } else { ?>Bib already used<?php } ?>",
message: "<?php if ($strLangue == 'fr') { ?>Ce dossard est déjà assigné à :<?php } else { ?>This bib is already assigned to:<?php } ?><ul style=\"margin:8px 0;\">" + lignes + "</ul><?php if ($strLangue == 'fr') { ?>Les doublons sont interdits pour cet événement.<?php } else { ?>Duplicates are not allowed for this event.<?php } ?>",
@ -1117,7 +1130,14 @@ if ($strLangue == 'fr') {
confirm: { label: '<?php if ($strLangue == 'fr') { ?>Assigner quand même<?php } else { ?>Assign anyway<?php } ?>', className: 'btn btn-warning rounded-0' },
cancel: { label: '<?php afficheTexte('confirm-btn-cancel', 1, 1, 1); ?>', className: 'btn btn-secondary rounded-0' }
},
callback: function (result) { if (result === true) { saveBib(); } }
callback: function (result) {
if (result === true) {
saveBib();
} else {
// "Non" : on ne touche pas a la base et on remet l'ancien dossard dans la fiche.
restoreBib();
}
}
});
}, 'json').fail(function () {
// Echec du controle : on n'empeche pas l'enregistrement (mode non bloquant).