From 47a2b051bad939209783b60b64d636954df10640 Mon Sep 17 00:00:00 2001 From: stephan Date: Wed, 8 Jul 2026 09:25:44 -0400 Subject: [PATCH] IMSIN-4425mplement quantity management enhancements in bib assignments and increment version code to 4.72.740 This commit introduces new JavaScript functions for managing quantity data in the bib assignments, including `bibApplyQteData` for updating UI elements and `bibSaveQte` for handling quantity submissions via AJAX. Additionally, the PHP file is updated to render a new panel for anomalies, improving the overall functionality and user experience. The version code is incremented to reflect these changes, ensuring proper versioning in the application. --- js/v2/bib-assignments.js | 115 +++++++++++++++++++++++++++++++++++++++ php/inc_fx_promoteur.php | 81 ++++++++++++++++++++++++--- php/inc_settings.php | 2 +- 3 files changed, 189 insertions(+), 9 deletions(-) diff --git a/js/v2/bib-assignments.js b/js/v2/bib-assignments.js index ba8d29b..6488eb6 100644 --- a/js/v2/bib-assignments.js +++ b/js/v2/bib-assignments.js @@ -679,6 +679,114 @@ return false; } + // MSIN-4379 — Mise à jour affichage quantités (panneau gestion + pastille en-tête). + function bibApplyQteData(data) { + if (!data || typeof data !== 'object') { + return; + } + + Object.keys(data).forEach(function (eprId) { + if (eprId === 'total') { + return; + } + + let row = data[eprId]; + if (!row) { + return; + } + + let elOrigine = document.getElementById('qte_origine_' + eprId); + let elAjustement = document.getElementById('qte_ajustement_' + eprId); + let elCourante = document.getElementById('qte_courante_' + eprId); + let elInscrits = document.getElementById('qte_inscrits_' + eprId); + let elCheckin = document.getElementById('qte_checkin_' + eprId); + let elRestante = document.getElementById('qte_restante_' + eprId); + + if (elOrigine) { + elOrigine.textContent = row.qte_origine; + } + if (elAjustement) { + elAjustement.textContent = row.qte_ajustement; + } + if (elCourante) { + elCourante.textContent = row.qte_courante; + } + if (elInscrits) { + elInscrits.textContent = row.qte_inscrits; + } + if (elCheckin) { + elCheckin.textContent = row.qte_checkin; + } + if (elRestante) { + elRestante.value = row.qte_restante; + } + + let dispoBadge = document.querySelector( + '.epr-row[data-epr-id="' + eprId + '"] .epr-header-summary--dispo' + ); + if (dispoBadge && row.qte_restante !== undefined) { + let labelParts = dispoBadge.textContent.split(':'); + let label = labelParts.length > 1 ? labelParts[0].trim() : ''; + dispoBadge.textContent = label + ' : ' + row.qte_restante; + } + + let btnQte = document.querySelector( + '.epr-gestion-panel[data-epr-id="' + eprId + '"] .btn_qte' + ); + if (btnQte) { + btnQte.setAttribute('data-qte_initiale', row.qte_restante); + } + }); + } + + function bibSaveQte(btn) { + let eprId = btn.getAttribute('data-epr_id'); + if (!eprId) { + return; + } + + let input = document.getElementById('qte_restante_' + eprId); + if (!input) { + return; + } + + let intQte = parseInt(input.value, 10); + if (isNaN(intQte) || intQte < 0) { + alert(bibJs('err-generic')); + return; + } + + bibLoaderShow(); + fetch('/ajax_promoteur.php', { + method: 'POST', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + }, + credentials: 'same-origin', + body: + 'a=qte' + + '&epr_id=' + encodeURIComponent(eprId) + + '&qte=' + encodeURIComponent(intQte) + + '&lang=' + encodeURIComponent(moduleBib.dataset.lang || 'fr') + }) + .then(function (res) { + return res.json(); + }) + .then(function (result) { + if (result && result.state === 'success' && result.data) { + bibApplyQteData(result.data); + return; + } + alert(bibJs('err-generic')); + }) + .catch(function () { + alert(bibJs('server-error')); + }) + .finally(function () { + bibLoaderHide(); + }); + } + // MSIN-4379 — Réduire / développer les blocs gestion et assignation (en-tête seul visible). moduleBib.addEventListener('click', function (e) { let btnToggle = e.target.closest('.epr-block-toggle'); @@ -1590,6 +1698,13 @@ moduleBib.addEventListener('click', function (e) { + let btnQte = e.target.closest('.btn_qte'); + if (btnQte && moduleBib.contains(btnQte)) { + e.preventDefault(); + bibSaveQte(btnQte); + return; + } + let btnGotoAssign = e.target.closest('.bib-anomaly-goto-assign'); if (btnGotoAssign) { e.preventDefault(); diff --git a/php/inc_fx_promoteur.php b/php/inc_fx_promoteur.php index 12fc2d1..0c60876 100644 --- a/php/inc_fx_promoteur.php +++ b/php/inc_fx_promoteur.php @@ -4052,7 +4052,7 @@ function fxShowBibTool4($str_code, $int_eve_id, $strLangue){
>
- +
@@ -4264,18 +4264,29 @@ function fxBibSqlIsBibDuplicateAnomaly($strEprIdExpr, $strBibNumExpr) { function fxInfosBibRange($epr_id = 0, $epr_bib_id = 0){ global $objDatabase, $vDomaine; - $where = []; + static $memCache = []; - if ((int)$epr_id > 0) { - $where[] = "b.epr_id = " . intval($epr_id); + $epr_id = (int)$epr_id; + $epr_bib_id = (int)$epr_bib_id; + $strCacheKey = $epr_id . ':' . $epr_bib_id; + + if (array_key_exists($strCacheKey, $memCache)) { + return $memCache[$strCacheKey]; } - if ((int)$epr_bib_id > 0) { - $where[] = "b.epr_bib_id = " . intval($epr_bib_id); + $where = []; + + if ($epr_id > 0) { + $where[] = "b.epr_id = " . $epr_id; + } + + if ($epr_bib_id > 0) { + $where[] = "b.epr_bib_id = " . $epr_bib_id; } if (empty($where)) { - return []; + $memCache[$strCacheKey] = []; + return $memCache[$strCacheKey]; } $where_sql = implode(' AND ', $where); @@ -4394,7 +4405,10 @@ function fxInfosBibRange($epr_id = 0, $epr_bib_id = 0){ ORDER BY b.epr_bib_start "; - return $objDatabase->fxGetResults($sqlBibStats); + $tabResult = $objDatabase->fxGetResults($sqlBibStats); + $memCache[$strCacheKey] = is_array($tabResult) ? $tabResult : []; + + return $memCache[$strCacheKey]; } /** MSIN-4379 — Libellé court épreuve pour le dashboard anomalies. */ @@ -4817,6 +4831,49 @@ function fxBibAnomalyTotalCount(array $tabAnomalies) { return $intTotal; } +/** + * MSIN-4436 — Coquille anomalies au chargement page (détail via AJAX). + * Évite 4 requêtes lourdes avant le premier affichage des épreuves. + */ +function renderBibAnomaliesPanelShell($int_eve_id, $strLangue = 'fr') { + global $vDomaine; + + $int_eve_id = (int)$int_eve_id; + $strWait = fxBibTexte('bib_v4_js_loader_wait', 0); + if ($strWait === '' || $strWait === 'bib_v4_js_loader_wait') { + $strWait = ($strLangue === 'en') ? 'Loading...' : 'Chargement...'; + } + $strRunnerSrc = $vDomaine . '/images/ms1-runner-loader.gif?v=' . _VERSION_CODE; + + ob_start(); + ?> + + fxCountBatchAssignUnits($epr_id) ]; + $memCache[$epr_id] = $info; + return $info; } function renderBibRanges($tabBibRanges, $epr_id = 0, $mode = 'assign') { diff --git a/php/inc_settings.php b/php/inc_settings.php index 87d3960..4111aef 100644 --- a/php/inc_settings.php +++ b/php/inc_settings.php @@ -7,7 +7,7 @@ * Constantes * * **************/ -define('_VERSION_CODE', '4.72.739'); +define('_VERSION_CODE', '4.72.740'); define('_DATE_CODE', '2026-07-08'); //MSIN-4290 define('QR_SECRET_KEY', 'ms1_qr_2026_cle_secrete_longue_et_fixe');