diff --git a/class/list.php b/class/list.php new file mode 100644 index 0000000000000000000000000000000000000000..716cb0b41ae7939cfefa6de70c5497b5602b18da --- /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 79bb2362da1ce31975ddc2d7c159ec358cfc26cb..8db35406e43cf884d0c1f6aa24a156801ac4ba47 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 f8cd55482267c135793444f15b8058dfdd6e72a6..53b5514799466c8be09904004ac696a5c144692e 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 e77dcdd225944317042a214c6125741cd1264b18..f539f3d71311719b01c3ab2e9000a0bc157dcb12 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 63e761e81e3a900524cd5d33498d04faf0d68bc7..72565eeebc69fc29698af1b55940e13b016c5166 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":