Actualiser api/index.php
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
Security Scan (Trivy) / Trivy — Docker image scan (push) Has been cancelled
Security Scan (Trivy) / Trivy — Filesystem scan (push) Has been cancelled

This commit is contained in:
2026-06-18 16:56:24 +00:00
parent 5a4e16c30d
commit 0de44ae341
+6 -6
View File
@@ -2837,6 +2837,7 @@ function saveProduct(PDO $db): void {
$input['default_quantity'] ?? 1, $input['notes'] ?? '', $input['default_quantity'] ?? 1, $input['notes'] ?? '',
$barcode, $input['package_unit'] ?? '', $barcode, $input['package_unit'] ?? '',
$shoppingName, $nutriJson, $shoppingName, $nutriJson,
$input['display_unit_key'] ?? null,
]; ];
try { try {
@@ -2844,17 +2845,16 @@ function saveProduct(PDO $db): void {
$stmt = $db->prepare(" $stmt = $db->prepare("
UPDATE products SET name=?, brand=?, category=?, subcategory=?, image_url=?, unit=?, UPDATE products SET name=?, brand=?, category=?, subcategory=?, image_url=?, unit=?,
default_quantity=?, notes=?, barcode=?, package_unit=?, shopping_name=?, default_quantity=?, notes=?, barcode=?, package_unit=?, shopping_name=?,
nutriments_json=?, nutriments_json=?, display_unit_key=?,
updated_at=CURRENT_TIMESTAMP WHERE id=? updated_at=CURRENT_TIMESTAMP WHERE id=?
"); ");
$stmt->execute([...$params, $id]); $stmt->execute([...$params, $id]);
echo json_encode(['success' => true, 'id' => $id, 'merged' => $merged]); echo json_encode(['success' => true, 'id' => $id, 'merged' => $merged]);
return; return;
} }
$stmt = $db->prepare(" $stmt = $db->prepare("
INSERT INTO products (name, brand, category, subcategory, image_url, unit, default_quantity, notes, barcode, package_unit, shopping_name, nutriments_json) INSERT INTO products (name, brand, category, subcategory, image_url, unit, default_quantity, notes, barcode, package_unit, shopping_name, nutriments_json, display_unit_key)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
"); ");
$stmt->execute($params); $stmt->execute($params);
echo json_encode(['success' => true, 'id' => (int)$db->lastInsertId(), 'merged' => false]); echo json_encode(['success' => true, 'id' => (int)$db->lastInsertId(), 'merged' => false]);
@@ -2865,7 +2865,7 @@ function saveProduct(PDO $db): void {
$stmt = $db->prepare(" $stmt = $db->prepare("
UPDATE products SET name=?, brand=?, category=?, subcategory=?, image_url=?, unit=?, UPDATE products SET name=?, brand=?, category=?, subcategory=?, image_url=?, unit=?,
default_quantity=?, notes=?, barcode=?, package_unit=?, shopping_name=?, default_quantity=?, notes=?, barcode=?, package_unit=?, shopping_name=?,
nutriments_json=?, nutriments_json=?, display_unit_key=?,
updated_at=CURRENT_TIMESTAMP WHERE id=? updated_at=CURRENT_TIMESTAMP WHERE id=?
"); ");
$stmt->execute([...$params, $owner]); $stmt->execute([...$params, $owner]);
@@ -3104,7 +3104,7 @@ function listInventory(PDO $db): void {
$location = $_GET['location'] ?? ''; $location = $_GET['location'] ?? '';
$query = " $query = "
SELECT i.*, p.name, p.brand, p.category, p.subcategory, p.image_url, p.unit, p.barcode, p.default_quantity, p.package_unit, 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 FROM inventory i
JOIN products p ON i.product_id = p.id JOIN products p ON i.product_id = p.id
WHERE i.quantity > 0 WHERE i.quantity > 0