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
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:
+6
-4
@@ -2831,6 +2831,7 @@ function saveProduct(PDO $db): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$nutriJson = isset($input['nutriments']) ? json_encode($input['nutriments']) : null;
|
$nutriJson = isset($input['nutriments']) ? json_encode($input['nutriments']) : null;
|
||||||
|
$tagsJson = isset($input['tags']) && is_array($input['tags']) ? json_encode($input['tags']) : null;
|
||||||
$params = [
|
$params = [
|
||||||
$input['name'], $input['brand'] ?? '', $category, $subcategory,
|
$input['name'], $input['brand'] ?? '', $category, $subcategory,
|
||||||
$input['image_url'] ?? '', $input['unit'] ?? 'pz',
|
$input['image_url'] ?? '', $input['unit'] ?? 'pz',
|
||||||
@@ -2838,6 +2839,7 @@ function saveProduct(PDO $db): void {
|
|||||||
$barcode, $input['package_unit'] ?? '',
|
$barcode, $input['package_unit'] ?? '',
|
||||||
$shoppingName, $nutriJson,
|
$shoppingName, $nutriJson,
|
||||||
$input['display_unit_key'] ?? null,
|
$input['display_unit_key'] ?? null,
|
||||||
|
$tagsJson,
|
||||||
];
|
];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -2845,7 +2847,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=?, display_unit_key=?,
|
nutriments_json=?, display_unit_key=?, tags=?,
|
||||||
updated_at=CURRENT_TIMESTAMP WHERE id=?
|
updated_at=CURRENT_TIMESTAMP WHERE id=?
|
||||||
");
|
");
|
||||||
$stmt->execute([...$params, $id]);
|
$stmt->execute([...$params, $id]);
|
||||||
@@ -2853,8 +2855,8 @@ function saveProduct(PDO $db): void {
|
|||||||
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, display_unit_key)
|
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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
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 +2867,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=?, display_unit_key=?,
|
nutriments_json=?, display_unit_key=?, tags=?,
|
||||||
updated_at=CURRENT_TIMESTAMP WHERE id=?
|
updated_at=CURRENT_TIMESTAMP WHERE id=?
|
||||||
");
|
");
|
||||||
$stmt->execute([...$params, $owner]);
|
$stmt->execute([...$params, $owner]);
|
||||||
|
|||||||
Reference in New Issue
Block a user