diff --git a/db.sql b/db.sql index ba6f3b6..2e1639f 100644 --- a/db.sql +++ b/db.sql @@ -54,3 +54,16 @@ CREATE TABLE clients ( INSERT INTO clients (name, client_code) VALUES ('Example Client', 'ABC'); + +CREATE TABLE ingredients_types ( + id INT AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(50) NOT NULL UNIQUE, + description TEXT, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); + + +INSERT INTO ingredients_types (name, description) VALUES +('Spice', 'Used to add flavor to recipes'), +('Sauce', 'Liquid or semi-liquid substance served with food'), +('Topping', 'Additional items used to enhance dishes'); diff --git a/ingredient_types_management.php b/ingredient_types_management.php new file mode 100644 index 0000000..09a439a --- /dev/null +++ b/ingredient_types_management.php @@ -0,0 +1,97 @@ +prepare("INSERT INTO ingredients_types (name, description) VALUES (:name, :description)"); + $stmt->execute(['name' => $name, 'description' => $description]); +} + +// Modifier un type d'ingrédient +if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['edit_ingredient_type'])) { + $id = $_POST['id']; + $name = $_POST['name']; + $description = $_POST['description']; + $stmt = $pdo->prepare("UPDATE ingredients_types SET name = :name, description = :description WHERE id = :id"); + $stmt->execute(['name' => $name, 'description' => $description, 'id' => $id]); +} + +// Supprimer un type d'ingrédient +if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['delete_ingredient_type'])) { + $id = $_POST['id']; + $stmt = $pdo->prepare("DELETE FROM ingredients_types WHERE id = :id"); + $stmt->execute(['id' => $id]); +} + +// Récupérer tous les types d'ingrédients +$stmt = $pdo->query("SELECT * FROM ingredients_types"); +$ingredient_types = $stmt->fetchAll(); +?> + + + +
+ + +ID | +Name | +Description | +Actions | +
---|---|---|---|
+ | + | + | + + + + + | +