rendered paste body<?php class C_Ingredient extends C_Gabarit { private $mIngredient; public function __construct() { parent::__construct(); $this->mIngredient=new m_Ingredient(); } public function lister() { $ingredients=$this->mIngredient->selectTout(); header('Content-Type: text/html; charset=utf-8'); require 'V/entete.html'; require 'V/Ingredient/liste.html'; require 'V/piedPage.html'; } public function formAjoutIngredient() { header('Content-Type: text/html; charset=utf-8'); require 'V/entete.html'; require 'V/Ingredient/formAjoutIngredient.html'; require 'V/piedPage.html'; } /**TODO ajouter vrifs fichier fonction d'autres, notification */ /*** */ public function insererNouveauIngredient() { $erreurs = verifierChampsFormAjoutIngredient(); header('Content-Type: text/html; charset=utf-8'); require 'V/entete.html'; if(count($erreurs)==0) { if($this->mIngredient->ajouterIngredient($_POST['nomIngr'],$_POST['quantite'],$_POST['unite'])) require 'V/Erreur/aucuneErreur.html'; } else { require 'V/Erreur/liste.html'; require 'V/Ingredient/formAjoutIngredient.html'; } require 'V/piedPage.html'; } public function supprimerIngredient() { $idIngr = $_GET['idIngr']; header('Content-Type: text/html; charset=utf-8'); require 'V/entete.html'; if(!empty($idIngr) && is_int($idIngr)) { $this->mIngredient->supprimerIngredient($idIngr); require 'V/Erreur/aucuneErreur.html'; } else { $erreur[] = "Impossible d'effectuer la suppression de l'ingrédient"; require 'V/Erreur/liste.html'; } require 'V/piedPage.html'; } public function formMiseAJourIngredient() { $ingredient=$this->mIngredient->selectIngredientParId(); $ingredient->fetch(PDO::FETCH_OBJ); header('Content-Type: text/html; charset=utf-8'); require 'V/entete.html'; require 'V/Ingredient/formMiseAJourIngredient.html'; require 'V/piedPage.html'; } public function mettreAJourIngredient(){ $erreurs = verifierChampsFormIngredient(); header('Content-Type: text/html; charset=utf-8'); require 'V/entete.html'; if(count($erreurs)==0) { if($this->mIngredient->ajouterIngredient($_POST['nomIngr'],$_POST['quantite'],$_POST['unite'])) //TODO demander nom fonction MAJ Jrme require 'V/Erreur/aucuneErreur.html'; } else { require 'V/Erreur/liste.html'; require 'V/Ingredient/formMiseAJourIngredient.html'; } require 'V/piedPage.html'; } /** *Effectue la vrification des champs du formulaire de d'ajout/modification d'ingrdient *@return : Un tableau contenant les messages d'erreurs concernant les saisies */ private function verifierChampsFormIngredient() { $nomIngr = $_POST['nomIngr']; $quantite = $_POST['quantite']; $unite = $_POST['unite']; $erreurs = array(); if(empty($nomIngr)) $erreurs[]='Le nom d\'ingrdient doit tre renseigné'; if(empty($quantite)) $erreurs[]='La quantité doit tre renseigné'; else if(is_float($quantite) || is_int($quantite)) $erreurs[]='La quantité renseigné est incorrecte'; // la quantit n'a pas besoin d'tre vrifie (liste droulante) return $erreurs; }}?>