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 19:37:17 +00:00
parent 57ec6af58c
commit 621fb4f96e
+22 -13
View File
@@ -1,13 +1,16 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html lang="fr">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>EverShelf - Réconciliation</title>
<style> <style>
body { font-family: sans-serif; background: #222; color: #eee; padding: 20px; } body { font-family: sans-serif; background: #222; color: #eee; padding: 20px; }
.card { background: #444; padding: 20px; border-radius: 8px; margin-bottom: 20px; } .card { background: #444; padding: 20px; border-radius: 8px; margin-bottom: 20px; }
table { width: 100%; border-collapse: collapse; background: #333; } select { padding: 8px; border-radius: 4px; border: 1px solid #666; margin-right: 10px; }
th, td { border: 1px solid #555; padding: 8px; text-align: left; } button { padding: 8px 15px; background: #1976d2; color: white; border: none; border-radius: 5px; cursor: pointer; }
.selected { background: #1e3a8a; } /* Couleur pour les lignes sélectionnées */ table { width: 100%; border-collapse: collapse; background: #333; margin-top: 20px; }
th, td { border: 1px solid #555; padding: 10px; text-align: left; }
th { background: #444; }
</style> </style>
</head> </head>
<body> <body>
@@ -20,7 +23,12 @@
<table id="prod-table"> <table id="prod-table">
<thead> <thead>
<tr><th><input type="checkbox" onclick="toggleAll(this)"></th><th>Produit</th><th>Catégorie</th><th>Emplacement</th></tr> <tr>
<th><input type="checkbox" onclick="toggleAll(this)"></th>
<th>Produit</th>
<th>Catégorie</th>
<th>Emplacement</th>
</tr>
</thead> </thead>
<tbody></tbody> <tbody></tbody>
</table> </table>
@@ -29,7 +37,7 @@
let fullProductList = []; let fullProductList = [];
let categories = {}; let categories = {};
// Chargement initial // 1. Initialisation : Chargement des données
Promise.all([ Promise.all([
fetch('translations/fr.json').then(r => r.json()), fetch('translations/fr.json').then(r => r.json()),
fetch('api/index.php?action=products_list').then(r => r.json()) fetch('api/index.php?action=products_list').then(r => r.json())
@@ -46,14 +54,15 @@
renderTable(); renderTable();
}); });
// 2. Affichage du tableau
function renderTable() { function renderTable() {
const tbody = document.querySelector('#prod-table tbody'); const tbody = document.querySelector('#prod-table tbody');
tbody.innerHTML = ""; tbody.innerHTML = "";
fullProductList.forEach((p, index) => { fullProductList.forEach((p, index) => {
let row = document.createElement('tr'); let row = document.createElement('tr');
row.innerHTML = `<td><input type="checkbox" class="prod-check" data-index="${index}"></td> row.innerHTML = `<td><input type="checkbox" class="prod-check" data-index="${index}"></td>
<td>${p.name}</td> <td>${p.name || 'Inconnu'}</td>
<td>${categories[p.category] || p.category}</td> <td>${categories[p.category] || p.category || 'Non classé'}</td>
<td>${p.location || 'N/A'}</td>`; <td>${p.location || 'N/A'}</td>`;
tbody.appendChild(row); tbody.appendChild(row);
}); });
@@ -63,18 +72,18 @@
document.querySelectorAll('.prod-check').forEach(c => c.checked = source.checked); document.querySelectorAll('.prod-check').forEach(c => c.checked = source.checked);
} }
// 3. Sauvegarde en masse
async function applyToSelected() { async function applyToSelected() {
const newCat = document.getElementById('cat-mass').value; 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'); const checkedBoxes = document.querySelectorAll('.prod-check:checked');
if(checkedBoxes.length === 0) return alert("Coche des produits !");
// On traite chaque produit coché
for (const checkbox of checkedBoxes) { for (const checkbox of checkedBoxes) {
let p = fullProductList[checkbox.dataset.index]; 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', { await fetch('api/index.php?action=product_save', {
method: 'POST', method: 'POST',
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json' },
@@ -82,7 +91,7 @@
}); });
} }
alert("Traitement terminé !"); alert("Modification effectuée sur " + checkedBoxes.length + " produit(s).");
renderTable(); renderTable();
} }
</script> </script>