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.
This commit is contained in:
2026-07-08 09:25:44 -04:00
parent 40625572e6
commit 47a2b051ba
3 changed files with 189 additions and 9 deletions

View File

@ -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();