diff --git a/class/lignefacture.php b/class/lignefacture.php index e553d8be64a4ccf7a1bd0a55bfd7393dd5d557f2..5f717b51a8f9ab8f6a337a93df7359295532d2fc 100644 --- a/class/lignefacture.php +++ b/class/lignefacture.php @@ -79,4 +79,5 @@ class LigneFacture extends Objet public function setRemise($remise) { $this->remise = $remise; - } \ No newline at end of file + } +} \ No newline at end of file diff --git a/class/listview.php b/class/listview.php index 460908d40ea46e0930cc254d42c4999667defaa1..ad789616f489bb473f5d76ec2830b32f7d3ebcb8 100644 --- a/class/listview.php +++ b/class/listview.php @@ -6,10 +6,10 @@ class ListView protected $objArray; public $class; - public function __construct($class, $title) + public function __construct($class, $title, $id=null) { $this->title = $title; - $this->objArray = $class::getAll(); + $this->objArray = $class::getAll($id); $this->class = $class; } diff --git a/class/objet.php b/class/objet.php index 1ad4d59f5bbfe9be993be4fba18c694f7a3755c8..813367fde551b02cb85666edf7be18e34727d39b 100644 --- a/class/objet.php +++ b/class/objet.php @@ -23,15 +23,19 @@ class Objet return $dbName; } - public static function getAll() + public static function getAll($id = null) { $className = get_called_class(); $dbName = self::dbName(); $bdd = new Db(); $result = Array(); - - $requete_prepare = $bdd->db->prepare("SELECT * FROM ".$dbName); // on prépare notre requête - $requete_prepare->execute(); + if($id == null) { + $requete_prepare = $bdd->db->prepare("SELECT * FROM ".$dbName); // on prépare notre requête + $requete_prepare->execute(); + } else { + $requete_prepare = $bdd->db->prepare("SELECT * FROM ".$dbName." WHERE id = :id"); + $requete_prepare->execute(array("id" => $id)); + } while($ligne = $requete_prepare->fetch(PDO::FETCH_ASSOC)) { $temp = new $className(); @@ -155,7 +159,7 @@ class Objet return self::dbName()." #".$this->{$this->_primaryAttr}; } - public function getList($title) { - return new ListView(get_called_class(), $title); + public function getList($title, $id=null) { + return new ListView(get_called_class(), $title, $id); } } \ No newline at end of file diff --git a/controller/fact.php b/controller/fact.php index 90fc63e5acaf2f3f2c18333f36f881ce751b3159..128db530383a39b028c658521209b15d6204789b 100644 --- a/controller/fact.php +++ b/controller/fact.php @@ -27,6 +27,9 @@ switch($action) { $facture->select($_GET['id']); $formConf = $facture->getForm(); include 'view/formDetail.php'; + + $list = LigneFacture::getList("Détail de la facture", $_GET["id"]); + include 'view/list.php'; break; default: include 'view/404.php'; diff --git a/view/stats.php b/view/stats.php index d352d80a22ca388a9093222c00f0d29822ca9eed..e0b62c75d402a276ae55315b8d6730c79903f74b 100644 --- a/view/stats.php +++ b/view/stats.php @@ -16,4 +16,24 @@ </tr> </tbody> </table> + + <table class="table"> + <caption> <th> Top 3 des plus gros client : </th> </caption> + + <tr> + <th>Nom</th> + <th>Prenom</th> + <th>Total des dépenses</th> + </tr> + <tr> + <td>Carmen</td> + <td>33 ans</td> + <td>Espagne</td> + </tr> + <tr> + <td>Michelle</td> + <td>26 ans</td> + <td>États-Unis</td> + </tr> +</table> </div> \ No newline at end of file