From 621fb4f96e3670a5d86601e1f813d14187007167 Mon Sep 17 00:00:00 2001 From: morgane Date: Wed, 17 Jun 2026 19:37:17 +0000 Subject: [PATCH] Actualiser test.html --- test.html | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/test.html b/test.html index 112b60b..65cf0ed 100644 --- a/test.html +++ b/test.html @@ -1,13 +1,16 @@ - + + EverShelf - Réconciliation @@ -20,7 +23,12 @@ - + + + + + +
ProduitCatégorieEmplacement
ProduitCatégorieEmplacement
@@ -29,7 +37,7 @@ let fullProductList = []; let categories = {}; - // Chargement initial + // 1. Initialisation : Chargement des données Promise.all([ fetch('translations/fr.json').then(r => r.json()), fetch('api/index.php?action=products_list').then(r => r.json()) @@ -46,14 +54,15 @@ renderTable(); }); + // 2. Affichage du tableau function renderTable() { const tbody = document.querySelector('#prod-table tbody'); tbody.innerHTML = ""; fullProductList.forEach((p, index) => { let row = document.createElement('tr'); row.innerHTML = ` - ${p.name} - ${categories[p.category] || p.category} + ${p.name || 'Inconnu'} + ${categories[p.category] || p.category || 'Non classé'} ${p.location || 'N/A'}`; tbody.appendChild(row); }); @@ -63,18 +72,18 @@ document.querySelectorAll('.prod-check').forEach(c => c.checked = source.checked); } + // 3. Sauvegarde en masse async function applyToSelected() { const newCat = document.getElementById('cat-mass').value; - if(!newCat) return alert("Sélectionne une catégorie !"); + if(!newCat) return alert("Sélectionne une catégorie d'abord !"); const checkedBoxes = document.querySelectorAll('.prod-check:checked'); - - // On traite chaque produit coché + if(checkedBoxes.length === 0) return alert("Coche des produits !"); + for (const checkbox of checkedBoxes) { let p = fullProductList[checkbox.dataset.index]; - p.category = newCat; + p.category = newCat; // Mise à jour de la catégorie - // Envoi à l'API await fetch('api/index.php?action=product_save', { method: 'POST', headers: { 'Content-Type': 'application/json' }, @@ -82,7 +91,7 @@ }); } - alert("Traitement terminé !"); + alert("Modification effectuée sur " + checkedBoxes.length + " produit(s)."); renderTable(); }