Skip to content
Snippets Groups Projects
Commit 376736b7 authored by goujonpa's avatar goujonpa
Browse files

Merge branch 'master' of gitlab.utc.fr:nf17-camp-p14/clivi

parents 3e75b7d1 570cd5b0
No related branches found
No related tags found
No related merge requests found
File moved
File moved
...@@ -2,16 +2,12 @@ ...@@ -2,16 +2,12 @@
class Stats class Stats
{ {
public function factureMoyClient() public function factureMoy()
{ {
$bdd = new Db(); $bdd = new Db();
$requete_prepare = $bdd->db->prepare(" SELECT SUM(t.prix)/COUNT(*) AS value $requete_prepare = $bdd->db->prepare(" SELECT SUM(f.prix_total)/COUNT(*) AS value
FROM ( SELECT c.nom, c.prenom, SUM(f.prix_total) AS prix FROM facture f" ); // on prépare notre requête
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->execute(); $requete_prepare->execute();
$ligne = $requete_prepare->fetch(PDO::FETCH_ASSOC); $ligne = $requete_prepare->fetch(PDO::FETCH_ASSOC);
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
<table class="table"> <table class="table">
<thead> <thead>
<th>Facture moyenne par client : /th> <th>Facture moyenne : </th>
<th><?php $tmp = $stats->factureMoyClient(); $nb_formated = number_format($tmp["value"], 2, ',', ' '); echo $nb_formated; ?></th> <th><?php $tmp = $stats->factureMoy(); $nb_formated = number_format($tmp["value"], 2, ',', ' '); echo $nb_formated; ?></th>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment