From c19f70031c128d098f81140e9c32426c2836d2ac Mon Sep 17 00:00:00 2001 From: stephan Date: Tue, 30 Jun 2026 15:46:48 -0400 Subject: [PATCH] Enhance search functionality in registration management with single result redirection This commit introduces logic to automatically redirect users to a detailed view when a single result is returned from a search query in the registration management interface. It improves user experience by streamlining navigation after search submissions. Additionally, the code structure is refined to ensure that search results are fetched only when necessary, enhancing performance. The version code is updated to reflect these changes. --- php/inc_fx_inscriptions_gestion.php | 36 ++++++++++++++++++----------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/php/inc_fx_inscriptions_gestion.php b/php/inc_fx_inscriptions_gestion.php index 4e0451c..7d89373 100644 --- a/php/inc_fx_inscriptions_gestion.php +++ b/php/inc_fx_inscriptions_gestion.php @@ -1113,6 +1113,25 @@ function fxInscrGestionRenderList($intEveId, $strLangue, $strBaseUrl, $arrReq) { $intFilterCount = fxInscrGestionFilterActiveCount($arrReq); // La page arrive vide : on n'affiche les resultats qu'apres une recherche (meme vide = tout afficher). $blnSearchActive = !empty($arrReq['q']); + $blnFreshSearch = !empty($_GET['btn_recherche']) || !empty($_GET['apply_filters']); + $tabRows = null; + + // Un seul resultat apres soumission : redirection JS (header() impossible ici, la page est deja entamee). + if ($blnSearchActive && $blnFreshSearch) { + $tabRows = fxInscrGestionFetchRows($intEveId, $arrReq); + if ($tabRows !== null && count($tabRows) === 1) { + $strFicheUrl = fxInscrGestionBuildUrl($strBaseUrl, $intEveId, $arrReq, array( + 'pec_id' => (int)$tabRows[1]['pec_id_original'], + 'pg' => 1, + )); + echo '
'; + echo ''; + echo ''; + echo '
'; + return; + } + } + $strBackUrl = fxInscrGestionIsEntry() ? $strBaseUrl : ($vDomaine . ($strLangue === 'fr' ? '/compte/inc_tableau_promoteur' : '/account/inc_tableau_promoteur') @@ -1232,7 +1251,9 @@ function fxInscrGestionRenderList($intEveId, $strLangue, $strBaseUrl, $arrReq) { } // Résultats (la recherche a été lancée — une recherche vide affiche toutes les inscriptions). - $tabRows = fxInscrGestionFetchRows($intEveId, $arrReq); + if ($tabRows === null) { + $tabRows = fxInscrGestionFetchRows($intEveId, $arrReq); + } $intNbItemsParPage = 50; $intNbTotal = ($tabRows !== null) ? count($tabRows) : 0; $intPage = 1; @@ -1558,18 +1579,5 @@ function fxInscrGestionRun($intEveId, $strLangue) { return; } - // Un seul resultat apres une recherche/filtre soumis : ouvrir la fiche directement. - if ($arrReq['q'] && (!empty($_GET['btn_recherche']) || !empty($_GET['apply_filters']))) { - $tabRows = fxInscrGestionFetchRows($intEveId, $arrReq); - if ($tabRows !== null && count($tabRows) === 1) { - $strUrl = fxInscrGestionBuildUrl($strBaseUrl, $intEveId, $arrReq, array( - 'pec_id' => (int)$tabRows[1]['pec_id_original'], - 'pg' => 1, - )); - header('Location: ' . $strUrl); - exit; - } - } - fxInscrGestionRenderList($intEveId, $strLangue, $strBaseUrl, $arrReq); }