Skip to content
Snippets Groups Projects
Commit d97f34c7 authored by clement's avatar clement
Browse files

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

parents c9fbdd00 e9c0b84b
Branches
No related tags found
No related merge requests found
......@@ -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);
......
......@@ -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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment