Actualiser api/database.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 08:55:35 +00:00
parent 3a33dc7173
commit 046355d6b0
+34
View File
@@ -428,6 +428,40 @@ if (empty($subcatTables)) {
");
}
// Custom categories table (v2.1) — catégories produit, gérables depuis Config
$catTables = $db->query("SELECT name FROM sqlite_master WHERE type='table' AND name='categories'")->fetchAll();
if (empty($catTables)) {
$db->exec("
CREATE TABLE categories (
id INTEGER PRIMARY KEY AUTOINCREMENT,
key TEXT UNIQUE NOT NULL,
label TEXT NOT NULL,
icon TEXT DEFAULT '📦',
keywords TEXT DEFAULT '',
sort_order INTEGER DEFAULT 0,
is_builtin INTEGER DEFAULT 0
);
");
$db->exec("INSERT INTO categories (key, label, icon, sort_order, is_builtin) VALUES
('latticini', 'Latticini', '🥛', 1, 1),
('carne', 'Carne', '🥩', 2, 1),
('pesce', 'Pesce', '🐟', 3, 1),
('frutta', 'Frutta', '🍎', 4, 1),
('verdura', 'Verdura', '🥬', 5, 1),
('pasta', 'Pasta', '🍝', 6, 1),
('pane', 'Pane', '🍞', 7, 1),
('surgelati', 'Surgelati', '🧊', 8, 1),
('bevande', 'Bevande', '🥤', 9, 1),
('condimenti', 'Condimenti', '🧂', 10, 1),
('snack', 'Snack', '🍪', 11, 1),
('conserve', 'Conserve', '🥫', 12, 1),
('cereali', 'Cereali', '🌾', 13, 1),
('igiene', 'Igiene', '🧴', 14, 1),
('pulizia', 'Pulizia', '🧹', 15, 1),
('altro', 'Altro', '📦', 16, 1)
");
}
// Internal shopping list table (v1.8.0) — used when SHOPPING_MODE=internal
$shopTables = $db->query("SELECT name FROM sqlite_master WHERE type='table' AND name='shopping_list'")->fetchAll();
if (empty($shopTables)) {