Actualiser test.html
CI / PHP Syntax Check (push) Has been cancelled
CI / JavaScript Lint (push) Has been cancelled
CI / Docker Build Test (push) Has been cancelled
CI / Validate Translation Files (push) Has been cancelled
CI / Auto-merge develop → main (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled

This commit is contained in:
2026-06-17 20:28:29 +00:00
parent 94eeba280a
commit a97907dbe1
+13 -17
View File
@@ -90,35 +90,30 @@
let successCount = 0; let successCount = 0;
let errorCount = 0; let errorCount = 0;
// --- TENTATIVE DE RÉCUPÉRATION DU JETON ---
// Regarde le nom du champ "name" dans le Payload de ta requête qui marche
// Ici on essaie les plus courants
let token = document.querySelector('input[name="csrf_token"]')?.value ||
document.querySelector('input[name="_token"]')?.value || "";
for (const checkbox of checkedBoxes) { for (const checkbox of checkedBoxes) {
let p = { ...fullProductList[checkbox.dataset.index] }; let p = fullProductList[checkbox.dataset.index];
let formData = new FormData(); let formData = new FormData();
for (let key in p) { formData.append(key, p[key]); } for (let key in p) {
formData.append(key, p[key]);
}
formData.set('category', newCat); formData.set('category', newCat);
if (token) formData.append('csrf_token', token); // Ajuste 'csrf_token' si besoin
try { try {
let res = await fetch('api/index.php?action=product_save', { let res = await fetch('api/index.php?action=product_save', {
method: 'POST', method: 'POST',
body: formData, body: formData
headers: { 'X-Requested-With': 'XMLHttpRequest' }
}); });
if (res.ok) successCount++; if (res.ok) {
else { successCount++;
let text = await res.text(); } else {
console.error("Échec:", text); console.error("Erreur serveur sur " + p.name);
errorCount++; errorCount++;
} }
await new Promise(r => setTimeout(r, 300)); await new Promise(r => setTimeout(r, 250));
} catch (e) { } catch (e) {
console.error("Erreur réseau sur " + p.name, e);
errorCount++; errorCount++;
} }
} }
@@ -126,7 +121,8 @@
await loadData(); await loadData();
btn.disabled = false; btn.disabled = false;
btn.textContent = "APPLIQUER AUX COCHÉS"; btn.textContent = "APPLIQUER AUX COCHÉS";
alert(`Terminé :\n- Succès : ${successCount}\n- Erreurs : ${errorCount}`);
alert(`Traitement terminé :\n- Succès : ${successCount}\n- Erreurs : ${errorCount}`);
} }
</script> </script>
</body> </body>