From e9c0b84b8517687e32fc01ea06fe5bd85110e214 Mon Sep 17 00:00:00 2001 From: cortylal <alexcortyl@gmail.com> Date: Thu, 19 Jun 2014 00:54:42 +0200 Subject: [PATCH] stats --- class/stats.php | 10 +++------- view/stats.php | 4 ++-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/class/stats.php b/class/stats.php index 22b0913..592bb1c 100644 --- a/class/stats.php +++ b/class/stats.php @@ -2,16 +2,12 @@ class Stats { - public function factureMoyClient() + public function factureMoy() { $bdd = new Db(); - $requete_prepare = $bdd->db->prepare(" SELECT SUM(t.prix)/COUNT(*) AS value - FROM ( SELECT c.nom, c.prenom, SUM(f.prix_total) AS prix - FROM animal a, client c, facture f - WHERE a.client = c.id - AND f.animal = a.id - GROUP BY c.nom, c.prenom, c.id) t" ); // on prépare notre requête + $requete_prepare = $bdd->db->prepare(" SELECT SUM(f.prix_total)/COUNT(*) + FROM facture f" ); // on prépare notre requête $requete_prepare->execute(); $ligne = $requete_prepare->fetch(PDO::FETCH_ASSOC); diff --git a/view/stats.php b/view/stats.php index 74fd2e6..d352d80 100644 --- a/view/stats.php +++ b/view/stats.php @@ -6,8 +6,8 @@ <table class="table"> <thead> - <th>Facture moyenne par client : </th> - <th><?php $tmp = $stats->factureMoyClient(); $nb_formated = number_format($tmp["value"], 2, ',', ' '); echo $nb_formated; ?></th> + <th>Facture moyenne : </th> + <th><?php $tmp = $stats->factureMoy(); $nb_formated = number_format($tmp["value"], 2, ',', ' '); echo $nb_formated; ?></th> </thead> <tbody> <tr> -- GitLab