From b5daa5a4ba602a83e801f94d07ea2ad3ee8fb024 Mon Sep 17 00:00:00 2001 From: stephan Date: Mon, 29 Jun 2026 11:12:14 -0400 Subject: [PATCH] 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. --- inc_footer_scripts.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/inc_footer_scripts.php b/inc_footer_scripts.php index cf63d99..8e042e1 100644 --- a/inc_footer_scripts.php +++ b/inc_footer_scripts.php @@ -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(''); $preloader.show(); $.post('/ajax_promoteur.php', 'a=' + action + '&eve_id=' + eveId + '&new_no_bib=' + newBib + '&pec_id=' + pecId + '&epr_id=' + eprId + '&par_id=' + parId + '&lang=', 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: "Dossard déjà utiliséBib already used", message: "Ce dossard est déjà assigné à :This bib is already assigned to:Les doublons sont interdits pour cet événement.Duplicates are not allowed for this event.", @@ -1117,7 +1130,14 @@ if ($strLangue == 'fr') { confirm: { label: 'Assigner quand mêmeAssign anyway', className: 'btn btn-warning rounded-0' }, cancel: { label: '', 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).