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-17 21:22:21 +00:00
parent e534ea2e96
commit 68484b8323
+10 -1
View File
@@ -2702,7 +2702,16 @@ function saveProduct(PDO $db): void {
$shoppingName = array_key_exists('shopping_name', $input) && $input['shopping_name'] !== null && $input['shopping_name'] !== ''
? $input['shopping_name']
: computeShoppingName($input['name'], $input['category'] ?? '', $input['brand'] ?? '');
// Sous-catégorie : toujours optionnelle, sauf obligatoire pour les boissons
$category = $input['category'] ?? '';
$subcategory = trim($input['subcategory'] ?? '');
$validSubcategories = ['vin', 'biere', 'spiritueux', 'soda', 'jus', 'eau', 'autre'];
if ($category === 'bevande' && ($subcategory === '' || !in_array($subcategory, $validSubcategories, true))) {
http_response_code(400);
echo json_encode(['error' => 'subcategory_required', 'message' => 'Sous-catégorie requise pour les boissons']);
return;
}
if ($subcategory === '') $subcategory = null;
// Sous-catégorie obligatoire uniquement pour les boissons
$category = $input['category'] ?? '';
$subcategory = trim($input['subcategory'] ?? '');