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

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

parents 70e0d9df 5f2406f9
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
......
......@@ -4,7 +4,7 @@
*/
// Implemented actions
$actions = array("listeFacture", "addFacture", "detailFacture");
$actions = array("listeFacture", "addFacture", "detailFacture", "addPresta", "addProduit", "addOrd");
// Check action is correct
if(!in_array($action, $actions)) {
......@@ -21,6 +21,24 @@ switch($action) {
$formConf = $facture->getForm();
include 'view/form.php';
break;
case "addPresta":
$ligne = new LigneFacturePrestation();
$ligne->setFacture($_GET['factId']);
$formConf = $ligne->getForm();
include 'view/form.php';
break;
case "addProduit":
$ligne = new LigneFactureProduit();
$ligne->setFacture($_GET['factId']);
$formConf = $ligne->getForm();
include 'view/form.php';
break;
case "addOrd":
$ligne = new LigneFactureOrdonnance();
$ligne->setFacture($_GET['factId']);
$formConf = $ligne->getForm();
include 'view/form.php';
break;
case "detailFacture":
// TODO: Ajouter bouton payer
// TODO: Ajouter résumé de la facture (client, prix etc... )
......
......@@ -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"]); 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