Nouveau fichier

This commit is contained in:
Rodolphe Quiedeville 2003-11-07 16:48:27 +00:00
parent ad926f3583
commit 265c88b34f
2 changed files with 168 additions and 44 deletions

View File

@ -0,0 +1,152 @@
<?PHP
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
class CommandeStats
{
var $db ;
Function CommandeStats($DB)
{
$this->db = $DB;
}
/**
* Renvoie le nombre de commande par année
*
*/
Function getNbCommandeByYear()
{
$result = array();
$sql = "SELECT date_format(date_commande,'%Y') as dm, count(*) FROM llx_commande GROUP BY dm DESC";
if ($this->db->query($sql))
{
$num = $this->db->num_rows();
$i = 0;
while ($i < $num)
{
$row = $this->db->fetch_row($i);
$result[$i] = $row;
$i++;
}
$this->db->free();
}
return $result;
}
/**
* Renvoie le nombre de commande par mois pour une année donnée
*
*/
Function getNbCommandeByMonth($year)
{
$result = array();
$sql = "SELECT date_format(date_commande,'%m') as dm, count(*) FROM llx_commande";
$sql .= " WHERE date_format(date_commande,'%Y') = $year";
$sql .= " GROUP BY dm DESC";
if ($this->db->query($sql))
{
$num = $this->db->num_rows();
$i = 0;
while ($i < $num)
{
$row = $this->db->fetch_row($i);
$j = $row[0] * 1;
$result[$j] = $row[1];
$i++;
}
$this->db->free();
}
for ($i = 1 ; $i < 13 ; $i++)
{
$res[$i] = $result[$i] + 0;
}
return $res;
}
/**
* Renvoie le nombre de commande par mois pour une année donnée
*
*/
Function getCommandeAmountByMonth($year)
{
$result = array();
$sql = "SELECT date_format(date_commande,'%m') as dm, sum(total_ht) FROM llx_commande";
$sql .= " WHERE date_format(date_commande,'%Y') = $year";
$sql .= " GROUP BY dm DESC";
if ($this->db->query($sql))
{
$num = $this->db->num_rows();
$i = 0;
while ($i < $num)
{
$row = $this->db->fetch_row($i);
$j = $row[0] * 1;
$result[$j] = $row[1];
$i++;
}
$this->db->free();
}
for ($i = 1 ; $i < 13 ; $i++)
{
$res[$i] = $result[$i] + 0;
}
return $res;
}
/**
* Renvoie le nombre de commande par mois pour une année donnée
*
*/
Function getCommandeAverageByMonth($year)
{
$result = array();
$sql = "SELECT date_format(date_commande,'%m') as dm, avg(total_ht) FROM llx_commande";
$sql .= " WHERE date_format(date_commande,'%Y') = $year";
$sql .= " GROUP BY dm DESC";
if ($this->db->query($sql))
{
$num = $this->db->num_rows();
$i = 0;
while ($i < $num)
{
$row = $this->db->fetch_row($i);
$j = $row[0] * 1;
$result[$j] = $row[1];
$i++;
}
$this->db->free();
}
for ($i = 1 ; $i < 13 ; $i++)
{
$res[$i] = $result[$i] + 0;
}
return $res;
}
}
?>

View File

@ -19,65 +19,37 @@
* $Source$
*
*/
require("./pre.inc.php");
require("../../propal.class.php");
require("../commande.class.php");
require("../../graph.class.php");
llxHeader();
$mesg = '';
/*
*
*
*/
$sql = "SELECT count(*) FROM llx_product WHERE fk_product_type = 0";
if ($db->query($sql))
{
$row = $db->fetch_row(0);
$nbproduct = $row[0];
}
$db->free();
$sql = "SELECT count(*) FROM llx_product WHERE envente = 0 AND fk_product_type = 0";
if ($db->query($sql))
{
$row = $db->fetch_row(0);
$nbhv = $row[0];
}
$db->free();
print_fiche_titre('Statistiques produits et services', $mesg);
print_fiche_titre('Statistiques commandes', $mesg);
print '<table class="liste" border="1" width="100%" cellspacing="0" cellpadding="4">';
print "<tr $bc[1]>";
print '<td width="40%">Nb de produit dans le catalogue</td>';
print '<td>'.$nbproduct.'</td></tr>';
print "<tr $bc[1]>";
print '<td width="40%">Nb de produit dans le catalogue qui ne sont pas en vente</td>';
print '<td>'.$nbhv.'</td></tr>';
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td width="40%">Nb de commande</td><td>Année</td></tr>';
$sql = "SELECT count(*) FROM llx_product WHERE fk_product_type = 1";
$sql = "SELECT count(*), date_format(date_commande,'%Y') as dm FROM llx_commande GROUP BY dm DESC";
if ($db->query($sql))
{
$row = $db->fetch_row(0);
$nbproduct = $row[0];
$num = $db->num_rows();
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($i);
$nbproduct = $row[0];
$year = $row[1];
print "<tr>";
print '<td>'.$nbproduct.'</td><td><a href="month.php?year='.$year.'">'.$year.'</a></td></tr>';
$i++;
}
}
$db->free();
$sql = "SELECT count(*) FROM llx_product WHERE envente = 0 AND fk_product_type = 1";
if ($db->query($sql))
{
$row = $db->fetch_row(0);
$nbhv = $row[0];
}
$db->free();
print "<tr $bc[1]>";
print '<td width="40%">Nb de service dans le catalogue</td>';
print '<td>'.$nbproduct.'</td></tr>';
print "<tr $bc[1]>";
print '<td width="40%">Nb de service dans le catalogue qui ne sont pas en vente</td>';
print '<td>'.$nbhv.'</td></tr>';
print '</table>';