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
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:
@@ -1,13 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>EverShelf - Réconciliation</title>
|
||||
<style>
|
||||
body { font-family: sans-serif; background: #222; color: #eee; padding: 20px; }
|
||||
.card { background: #444; padding: 20px; border-radius: 8px; margin-bottom: 20px; }
|
||||
table { width: 100%; border-collapse: collapse; background: #333; }
|
||||
th, td { border: 1px solid #555; padding: 8px; text-align: left; }
|
||||
.selected { background: #1e3a8a; } /* Couleur pour les lignes sélectionnées */
|
||||
select { padding: 8px; border-radius: 4px; border: 1px solid #666; margin-right: 10px; }
|
||||
button { padding: 8px 15px; background: #1976d2; color: white; border: none; border-radius: 5px; cursor: pointer; }
|
||||
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>
|
||||
</head>
|
||||
<body>
|
||||
@@ -20,7 +23,12 @@
|
||||
|
||||
<table id="prod-table">
|
||||
<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>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
@@ -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 = `<td><input type="checkbox" class="prod-check" data-index="${index}"></td>
|
||||
<td>${p.name}</td>
|
||||
<td>${categories[p.category] || p.category}</td>
|
||||
<td>${p.name || 'Inconnu'}</td>
|
||||
<td>${categories[p.category] || p.category || 'Non classé'}</td>
|
||||
<td>${p.location || 'N/A'}</td>`;
|
||||
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();
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user