diff --git a/class/stats.php b/class/stats.php index 70b095c29ecff3166004ab383cf2429481373af6..811011178708ef5d17fa002bfc121f8c421718e8 100644 --- a/class/stats.php +++ b/class/stats.php @@ -42,7 +42,7 @@ class Stats GROUP BY c.nom, c.prenom, c.id" ); // on prépare notre requête $requete_prepare->execute(); - $ligne = $requete_prepare->fetch(PDO::FETCH_ASSOC); + $ligne = $requete_prepare->fetchAll(PDO::FETCH_ASSOC); return $ligne; } @@ -56,6 +56,7 @@ class Stats WHERE a.client = c.id AND f.animal = a.id GROUP BY c.nom, c.prenom, c.id + ORDER BY prix DESC LIMIT 3" ); // on prépare notre requête $requete_prepare->execute(); @@ -76,7 +77,7 @@ class Stats LIMIT 3" ); // on prépare notre requête $requete_prepare->execute(); - $ligne = $requete_prepare->fetch(PDO::FETCH_ASSOC); + $ligne = $requete_prepare->fetchAll(PDO::FETCH_ASSOC); return $ligne; } diff --git a/view/list.php b/view/list.php index 29f77aff2e217285de7525f88e04843177ec755b..5f05ccc0665e64fc21a64f3043cb6b2902c68459 100644 --- a/view/list.php +++ b/view/list.php @@ -3,7 +3,14 @@ <div class="page-header"> <h1><?php echo $list->getTitle(); ?></h1> </div> - <?php try { ?> + <?php + $ok = true; + try { + $test=$list->getLabels(); + } catch (Exception $e) { print($e->getMessage()); + $ok = false; + } ?> + <?php if($ok) { ?> <table class="table"> <thead> <?php foreach($list->getLabels() as $field): ?> @@ -22,7 +29,5 @@ <?php endforeach; ?> </tbody> </table> - <?php } catch(Exception $e) { - echo $e->getMessage(); - } ?> -</div> \ No newline at end of file + <?php } ?> +</div> diff --git a/view/stats.php b/view/stats.php index bc4801f5b2ce7308929b97030151d3d8bdb4288b..df2d3da84d25953d97a9db5ea1a16159cb1bbf45 100644 --- a/view/stats.php +++ b/view/stats.php @@ -36,4 +36,45 @@ <?php endforeach; ?> </tbody> </table> + + <br/> + <hr/> + <h4>Top 3 des plus grosses factures</h4> + <table class="table"> + <thead> + <th>Nom </th> + <th>Prenom </th> + <th>Montant de la facture </th> + </thead> + <tbody> + <?php foreach ($stats->top3Facture() as $ligne): ?> + <tr> + <td><?php echo $ligne["nom"]; ?> </td> + <td><?php echo $ligne["prenom"]; ?> </td> + <td><?php echo $ligne["prix_total"]; ?> </td> + </tr> + <?php endforeach; ?> + </tbody> + </table> + + <br/> + <hr/> + <h4>Nombre d'animaux par client</h4> + <table class="table"> + <thead> + <th>Nom </th> + <th>Prenom </th> + <th>Nombre d'animaux </th> + </thead> + <tbody> + <?php foreach ($stats->nbAnimalClient() as $ligne): ?> + <tr> + <td><?php echo $ligne["nom"]; ?> </td> + <td><?php echo $ligne["prenom"]; ?> </td> + <td><?php echo $ligne["count"]; ?> </td> + </tr> + <?php endforeach; ?> + </tbody> + </table> + </div> \ No newline at end of file