From 05ce600e09735ae9bddcab714be007fdd45b9b4c Mon Sep 17 00:00:00 2001 From: stephan Date: Fri, 24 Jul 2026 17:06:46 -0400 Subject: [PATCH] Refactor fxImportResultatsResetPreview to improve SQL query readability and performance by storing the escaped origin in a variable. Add diagnostic SQL query to count visible participants in the list based on active PEC status. Enhance the event panel UI to display database status with refresh functionality. Increment version code. --- php/inc_fx_import_resultats.php | 117 ++++++++++++++++++++++++++++---- 1 file changed, 105 insertions(+), 12 deletions(-) diff --git a/php/inc_fx_import_resultats.php b/php/inc_fx_import_resultats.php index b60178d..373d8b2 100644 --- a/php/inc_fx_import_resultats.php +++ b/php/inc_fx_import_resultats.php @@ -1335,9 +1335,11 @@ function fxImportResultatsResetPreview($intEveId) { return array('state' => 'error', 'message' => 'eve_id manquant'); } + $strOrig = fxImportResultatsDbEsc(MSIN_IMPORT_RESULTATS_ORIGIN); + $sqlPar = "SELECT COUNT(*) AS n FROM resultats_participants" . " WHERE eve_id = " . $intEveId - . " AND par_origine = '" . fxImportResultatsDbEsc(MSIN_IMPORT_RESULTATS_ORIGIN) . "'"; + . " AND par_origine = '" . $strOrig . "'"; $tabPar = $objDatabase->fxGetResults($sqlPar); $intPar = is_array($tabPar) ? intval($tabPar[1]['n'] ?? 0) : 0; @@ -1346,24 +1348,38 @@ function fxImportResultatsResetPreview($intEveId) { . " INNER JOIN resultats_participants p ON p.eve_id = e.eve_id" . " AND (p.pec_id = e.pec_id OR p.pec_id = e.pec_id_original)" . " WHERE e.eve_id = " . $intEveId - . " AND p.par_origine = '" . fxImportResultatsDbEsc(MSIN_IMPORT_RESULTATS_ORIGIN) . "'"; + . " AND p.par_origine = '" . $strOrig . "'"; $tabPec = $objDatabase->fxGetResults($sqlPec); $intPec = is_array($tabPec) ? intval($tabPec[1]['n'] ?? 0) : 0; $sqlQue = "SELECT COUNT(*) AS n FROM resultats_questions rq" . " INNER JOIN resultats_participants p ON (rq.par_id = p.par_id_original OR rq.par_id = p.par_id)" . " WHERE p.eve_id = " . $intEveId - . " AND p.par_origine = '" . fxImportResultatsDbEsc(MSIN_IMPORT_RESULTATS_ORIGIN) . "'"; + . " AND p.par_origine = '" . $strOrig . "'"; $tabQue = $objDatabase->fxGetResults($sqlQue); $intQue = is_array($tabQue) ? intval($tabQue[1]['n'] ?? 0) : 0; + // Diagnostic : ce que la liste inscriptions verrait (même join + pec_actif) + $sqlList = "SELECT COUNT(*) AS n" + . " FROM resultats_epreuves_commandees e, resultats_participants p" + . " WHERE e.eve_id = " . $intEveId + . " AND p.pec_id = e.pec_id_original" + . " AND p.par_origine = '" . $strOrig . "'" + . " AND p.rol_id NOT IN (3, 4)" + . " AND e.is_cancelled = 0 AND e.pec_actif = 1"; + $tabList = $objDatabase->fxGetResults($sqlList); + $intList = is_array($tabList) ? intval($tabList[1]['n'] ?? 0) : 0; + return array( 'state' => 'ok', 'eve_id' => $intEveId, 'participants' => $intPar, 'pec' => $intPec, 'questions' => $intQue, - 'message' => $intPar . ' participant(s) import, ' . $intPec . ' pec, ' . $intQue . ' réponse(s) questions.', + 'list_visible' => $intList, + 'message' => 'En BD : ' . $intPar . ' participant(s) import, ' + . $intPec . ' pec, ' . $intQue . ' réponse(s) questions' + . ' — dont ' . $intList . ' visible(s) dans la liste (pec_actif=1).', ); } @@ -1537,10 +1553,31 @@ function fxImportResultatsRenderEventPanel($intEveId) {
Reset = efface seulement par_origine=import_fichier sur cet événement (pas les inscriptions payantes).

-
- +
+
+ Déjà en BD (origine import_fichier) +
+ + +
+
+
+
Participants
+
+
PEC (coquilles)
+
+
Réponses questions
+
+
Visibles liste*
+
+
+

+ * Visibles liste ≈ join liste inscriptions avec pec_actif=1 (diagnostic). +

0) ? 'warning' : 'success', res.message || 'Import terminé.'); renderImportBlockedPanel(res); + refreshDbStatus(true); ensurePanelOpen(); }).fail(function (xhr) { $btn.prop('disabled', false); @@ -2224,6 +2316,7 @@ function fxImportResultatsRenderEventPanel($intEveId) { if (res && res.state === 'ok') { showStatus((res.blocked_count > 0) ? 'warning' : 'success', res.message || 'Import terminé.'); renderImportBlockedPanel(res); + refreshDbStatus(true); return; } showStatus('danger', 'Erreur réseau (import). Timeout possible sur très gros fichiers — réessayez ou coupez le fichier.');