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
Security Scan (Trivy) / Trivy — Docker image scan (push) Has been cancelled
Security Scan (Trivy) / Trivy — Filesystem scan (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-20 08:50:31 +00:00
parent b73748346e
commit 78310f9fe9
+7 -5
View File
@@ -2831,6 +2831,7 @@ function saveProduct(PDO $db): void {
}
$nutriJson = isset($input['nutriments']) ? json_encode($input['nutriments']) : null;
$tagsJson = isset($input['tags']) && is_array($input['tags']) ? json_encode($input['tags']) : null;
$params = [
$input['name'], $input['brand'] ?? '', $category, $subcategory,
$input['image_url'] ?? '', $input['unit'] ?? 'pz',
@@ -2838,6 +2839,7 @@ function saveProduct(PDO $db): void {
$barcode, $input['package_unit'] ?? '',
$shoppingName, $nutriJson,
$input['display_unit_key'] ?? null,
$tagsJson,
];
try {
@@ -2845,7 +2847,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=?, display_unit_key=?,
nutriments_json=?, display_unit_key=?, tags=?,
updated_at=CURRENT_TIMESTAMP WHERE id=?
");
$stmt->execute([...$params, $id]);
@@ -2853,8 +2855,8 @@ function saveProduct(PDO $db): void {
return;
}
$stmt = $db->prepare("
INSERT INTO products (name, brand, category, subcategory, image_url, unit, default_quantity, notes, barcode, package_unit, shopping_name, nutriments_json, display_unit_key)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
INSERT INTO products (name, brand, category, subcategory, image_url, unit, default_quantity, notes, barcode, package_unit, shopping_name, nutriments_json, display_unit_key, tags)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
");
$stmt->execute($params);
echo json_encode(['success' => true, 'id' => (int)$db->lastInsertId(), 'merged' => false]);
@@ -2865,9 +2867,9 @@ 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=?, display_unit_key=?,
nutriments_json=?, display_unit_key=?, tags=?,
updated_at=CURRENT_TIMESTAMP WHERE id=?
");
");
$stmt->execute([...$params, $owner]);
echo json_encode(['success' => true, 'id' => $owner, 'merged' => true]);
return;