Skip to content
Snippets Groups Projects
Commit febad2f4 authored by cortylal's avatar cortylal
Browse files

stats

parent 4081fb5a
No related branches found
No related tags found
No related merge requests found
......@@ -15,6 +15,72 @@ class Stats
return $ligne;
}
public function nbClient()
{
$bdd = new Db();
$requete_prepare = $bdd->db->prepare(" SELECT COUNT(*) AS nb
FROM client" ); // on prépare notre requête
$requete_prepare->execute();
$ligne = $requete_prepare->fetch(PDO::FETCH_ASSOC);
return $ligne;
}
public function nbAnimaux()
{
$bdd = new Db();
$requete_prepare = $bdd->db->prepare(" SELECT COUNT(*) AS nb
FROM animaux" ); // on prépare notre requête
$requete_prepare->execute();
$ligne = $requete_prepare->fetch(PDO::FETCH_ASSOC);
return $ligne;
}
public function totalCA()
{
$bdd = new Db();
$requete_prepare = $bdd->db->prepare(" SELECT SUM(prix_total) AS ca
FROM facture" ); // on prépare notre requête
$requete_prepare->execute();
$ligne = $requete_prepare->fetch(PDO::FETCH_ASSOC);
return $ligne;
}
public function nbEmploye()
{
$bdd = new Db();
$requete_prepare = $bdd->db->prepare(" SELECT COUNT(*) AS nb
FROM employe" ); // on prépare notre requête
$requete_prepare->execute();
$ligne = $requete_prepare->fetch(PDO::FETCH_ASSOC);
return $ligne;
}
public function nbVeterinaire()
{
$bdd = new Db();
$requete_prepare = $bdd->db->prepare(" SELECT COUNT(*) AS nb
FROM employe e
WHERE e.is_veterinaire = '1'" ); // on prépare notre requête
$requete_prepare->execute();
$ligne = $requete_prepare->fetch(PDO::FETCH_ASSOC);
return $ligne;
}
public function nbAnimalMoyClient()
{
$bdd = new Db();
......@@ -36,7 +102,7 @@ class Stats
{
$bdd = new Db();
$requete_prepare = $bdd->db->prepare(" SELECT c.nom, c.prenom, COUNT(a.client)
$requete_prepare = $bdd->db->prepare(" SELECT c.nom, c.prenom, COUNT(a.client) as count
FROM animal a, client c
WHERE a.client = c.id
GROUP BY c.nom, c.prenom, c.id" ); // on prépare notre requête
......
......@@ -7,14 +7,33 @@
<h4>Statistiques générales : </h4>
<table class="table">
<thead>
<th>Facture moyenne : </th>
<th><?php $tmp = $stats->factureMoy(); $nb_formated = number_format($tmp["value"], 2, ',', ' '); echo $nb_formated; ?></th>
<th>Nombre de client : </th>
<th><?php $tmp = $stats->nbClient(); $nb_formated = number_format($tmp["nb"], 2, ',', ' '); echo $nb_formated; ?></th>
</thead>
<thead>
<th>Nombre d'employé' : </th>
<th><?php $tmp = $stats->nbEmploye(); $nb_formated = number_format($tmp["nb"], 2, ',', ' '); echo $nb_formated; ?></th>
</thead>
<thead>
<th>Nombre de vétérinaire' : </th>
<th><?php $tmp = $stats->nbVeterinaire(); $nb_formated = number_format($tmp["nb"], 2, ',', ' '); echo $nb_formated; ?></th>
</thead>
<thead>
<th>Nombre d'animaux : </th>
<th><?php $tmp = $stats->nbAnimaux(); $nb_formated = number_format($tmp["nb"], 2, ',', ' '); echo $nb_formated; ?></th>
</thead>
<thead>
<th>Nombre moyen d'animal par client : </th>
<th><?php $tmp = $stats->nbAnimalMoyClient(); $nb_formated = number_format($tmp["value"], 2, ',', ' '); echo $nb_formated; ?></th>
</thead>
<thead>
<th>Facture moyenne : </th>
<th><?php $tmp = $stats->factureMoy(); $nb_formated = number_format($tmp["value"], 2, ',', ' '); echo $nb_formated; ?></th>
</thead>
<thead>
<th>Total du chiffre d'affaire : </th>
<th><?php $tmp = $stats->totalCA(); $nb_formated = number_format($tmp["ca"], 2, ',', ' '); echo $nb_formated; ?></th>
</thead>
</table>
<br/>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment