From df78c9bd9a0edf28b398074894fda8579d33422a Mon Sep 17 00:00:00 2001 From: goujonpa <goujonpa@gmail.com> Date: Wed, 18 Jun 2014 23:07:53 +0200 Subject: [PATCH] list --- class/list.php | 25 +++++++++++++++++++++++++ controller/animal.php | 16 +++------------- controller/fact.php | 5 +---- controller/ord.php | 10 ++-------- controller/rdv.php | 10 ++-------- 5 files changed, 33 insertions(+), 33 deletions(-) create mode 100644 class/list.php diff --git a/class/list.php b/class/list.php new file mode 100644 index 0000000..716cb0b --- /dev/null +++ b/class/list.php @@ -0,0 +1,25 @@ +<?php + +class List +{ + protected $title; + protected $objArray; + public $class; + + + public function __construct($class, $title) + { + $this->title = $title; + $this->class = $class; + $this->$objArray = $class::getAll(); + } + + public function getTitle() { + return $this->title; + } + + public function getLines() { + return $this->objArray; + } + +} \ No newline at end of file diff --git a/controller/animal.php b/controller/animal.php index 79bb236..8db3540 100644 --- a/controller/animal.php +++ b/controller/animal.php @@ -13,10 +13,7 @@ if(!in_array($action, $actions)) { switch($action) { case "listeAnimal": - $listArray = Animal::getAll(); - $listParams = array("title" => "Liste des animaux de la clinique", - "keys" => array("id", "nom", "client", "race", "poids", "genre", "sterile", "date_naissance", "date_deces", "taille", "code")); - $editLink = "editAnimal"; + $list = Animal::getList("Liste des Animaux"); include 'view/list.php'; break; case "addAnimal": @@ -31,11 +28,7 @@ switch($action) { include 'view/form.php'; break; case "listeEspece": - $listArray = Espece::getAll(); - $listParams = array("title" => "Liste des espèces d'animaux", - "keys" => array("id", "nom", "prix_consultation")); - $editLink = "editEspece"; - include 'view/list.php'; + $list = Espece::getList("Liste des Especes"); break; case "addEspece": $espece = new Espece(); @@ -49,10 +42,7 @@ switch($action) { include 'view/form.php'; break; case "listeRace": - $listArray = Race::getAll(); - $listParams = array("title" => "Liste des races", - "keys" => array("id", "nom", "espece", "prix_intervention")); - $editLink = "editRace"; + $list = Race::getList("Liste des Races"); include 'view/list.php'; break; case "addRace": diff --git a/controller/fact.php b/controller/fact.php index f8cd554..53b5514 100644 --- a/controller/fact.php +++ b/controller/fact.php @@ -13,10 +13,7 @@ if(!in_array($action, $actions)) { switch($action) { case "liste": - $listArray = Facture::getAll(); - $listParams = array("title" => "Liste des factures", - "keys" => array("id", "employe", "animal", "date_edition", "date_paiement", "moyen_paiement", "prix_total")); - $editLink = "edit"; + $list = Facture::getList("Liste des Factures"); include 'view/list.php'; break; case "add": diff --git a/controller/ord.php b/controller/ord.php index e77dcdd..f539f3d 100644 --- a/controller/ord.php +++ b/controller/ord.php @@ -13,10 +13,7 @@ if(!in_array($action, $actions)) { switch($action) { case "liste": - $listArray = Ordonnance::getAll(); - $listParams = array("title" => "Liste des ordonnances", - "keys" => array("id", "animal", "employe", "date", "prix")); - $editLink = "edit"; + $list = Ordonnance::getList("Liste des Ordonnances"); include 'view/list.php'; break; case "add": @@ -31,10 +28,7 @@ switch($action) { include 'view/form.php'; break; case "listeProduit": - $listArray = Produit::getAll(); - $listParams = array("title" => "Liste des ordonnances", - "keys" => array("id", "nom", "prix", "is_medicament")); - $editLink = "editProduit"; + $list = Produit::getList("Liste des Produits"); include 'view/list.php'; break; case "addProduit": diff --git a/controller/rdv.php b/controller/rdv.php index 63e761e..72565ee 100644 --- a/controller/rdv.php +++ b/controller/rdv.php @@ -13,10 +13,7 @@ if(!in_array($action, $actions)) { switch($action) { case "liste": - $listArray = Rdv::getAll(); - $listParams = array("title" => "Liste des rendez-vous", - "keys" => array("id", "animal", "employe", "date", "duree")); - $editLink = "edit"; + $list = Rdv::getList("Liste des Rendez Vous"); include 'view/list.php'; break; case "add": @@ -31,10 +28,7 @@ switch($action) { include 'view/form.php'; break; case "listePrestation": - $listArray = Prestation::getAll(); - $listParams = array("title" => "Liste des prestations", - "keys" => array("id", "description", "type", "prix")); - $editLink = "editPrestation"; + $list = Prestation::getList("Liste des Prestations"); include 'view/list.php'; break; case "addPrestation": -- GitLab