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.
This commit is contained in:
@ -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 '<div id="module-inscr-gestion" class="inscr-gestion-shell" data-inscr-gestion="1">';
|
||||
echo '<script>window.location.replace(' . json_encode($strFicheUrl, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_UNESCAPED_UNICODE) . ');</script>';
|
||||
echo '<noscript><meta http-equiv="refresh" content="0;url=' . fxInscrGestionEsc($strFicheUrl) . '"></noscript>';
|
||||
echo '</div>';
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user