diff --git a/class/stats.php b/class/stats.php index 811011178708ef5d17fa002bfc121f8c421718e8..4a5a8a28552ab288ae2a505eea0180ff1cf781d3 100644 --- a/class/stats.php +++ b/class/stats.php @@ -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 diff --git a/view/stats.php b/view/stats.php index df2d3da84d25953d97a9db5ea1a16159cb1bbf45..a021d484a7b85f74c7b1d514b634586c05d74b28 100644 --- a/view/stats.php +++ b/view/stats.php @@ -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/>