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:12:37 +00:00
parent 8b44432244
commit 477139d47c
+27 -1
View File
@@ -82,7 +82,7 @@
document.getElementById('prod-name').value = sel.options[sel.selectedIndex].getAttribute('data-name'); document.getElementById('prod-name').value = sel.options[sel.selectedIndex].getAttribute('data-name');
} }
function saveProduct() { function Product() {
const data = { const data = {
id: document.getElementById('prod-id').value, id: document.getElementById('prod-id').value,
name: document.getElementById('prod-name').value, name: document.getElementById('prod-name').value,
@@ -94,6 +94,32 @@
body: JSON.stringify(data) body: JSON.stringify(data)
}).then(r => r.json()).then(res => alert(JSON.stringify(res))); }).then(r => r.json()).then(res => alert(JSON.stringify(res)));
} }
function saveChanges() {
const data = {
id: document.getElementById('edit-id').value,
name: document.getElementById('edit-name').value,
category: document.getElementById('edit-category').value
};
// On utilise l'action la plus probable pour une mise à jour d'entité
// Si 'product_edit' ne marche pas, essaie 'ha_update_product'
// ou regarde le switch dans api/index.php
fetch('api/index.php?action=product_edit', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify(data)
})
.then(r => r.json())
.then(res => {
if(res.error) {
alert("Erreur API : " + res.error);
} else {
alert("Produit mis à jour avec succès !");
loadInventory(); // Recharge la grille
}
})
.catch(e => console.error("Erreur de connexion:", e));
}
</script> </script>
</body> </body>
</html> </html>