From 0de44ae3416eee6ddb7f9829fe2cba219cd0db3d Mon Sep 17 00:00:00 2001 From: morgane Date: Thu, 18 Jun 2026 16:56:24 +0000 Subject: [PATCH] Actualiser api/index.php --- api/index.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/api/index.php b/api/index.php index d757ca7..9a06c69 100644 --- a/api/index.php +++ b/api/index.php @@ -2837,6 +2837,7 @@ function saveProduct(PDO $db): void { $input['default_quantity'] ?? 1, $input['notes'] ?? '', $barcode, $input['package_unit'] ?? '', $shoppingName, $nutriJson, + $input['display_unit_key'] ?? null, ]; try { @@ -2844,17 +2845,16 @@ function saveProduct(PDO $db): void { $stmt = $db->prepare(" UPDATE products SET name=?, brand=?, category=?, subcategory=?, image_url=?, unit=?, default_quantity=?, notes=?, barcode=?, package_unit=?, shopping_name=?, - nutriments_json=?, + nutriments_json=?, display_unit_key=?, updated_at=CURRENT_TIMESTAMP WHERE id=? "); $stmt->execute([...$params, $id]); echo json_encode(['success' => true, 'id' => $id, 'merged' => $merged]); return; } - $stmt = $db->prepare(" - INSERT INTO products (name, brand, category, subcategory, image_url, unit, default_quantity, notes, barcode, package_unit, shopping_name, nutriments_json) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) + INSERT INTO products (name, brand, category, subcategory, image_url, unit, default_quantity, notes, barcode, package_unit, shopping_name, nutriments_json, display_unit_key) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) "); $stmt->execute($params); echo json_encode(['success' => true, 'id' => (int)$db->lastInsertId(), 'merged' => false]); @@ -2865,7 +2865,7 @@ function saveProduct(PDO $db): void { $stmt = $db->prepare(" UPDATE products SET name=?, brand=?, category=?, subcategory=?, image_url=?, unit=?, default_quantity=?, notes=?, barcode=?, package_unit=?, shopping_name=?, - nutriments_json=?, + nutriments_json=?, display_unit_key=?, updated_at=CURRENT_TIMESTAMP WHERE id=? "); $stmt->execute([...$params, $owner]); @@ -3104,7 +3104,7 @@ function listInventory(PDO $db): void { $location = $_GET['location'] ?? ''; $query = " SELECT i.*, p.name, p.brand, p.category, p.subcategory, p.image_url, p.unit, p.barcode, p.default_quantity, p.package_unit, - COALESCE(i.vacuum_sealed, 0) as vacuum_sealed, i.opened_at, p.shopping_name + COALESCE(i.vacuum_sealed, 0) as vacuum_sealed, i.opened_at, p.shopping_name, p.display_unit_key FROM inventory i JOIN products p ON i.product_id = p.id WHERE i.quantity > 0