From 716f4be32fed719ddfc30bea8cb17efefaeefe86 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Mon, 24 Nov 2003 12:18:02 +0000 Subject: [PATCH] Modif lecture des stats --- htdocs/commande/stats/index.php | 57 +++++++++++++++++---------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index 0e2c76a0f62..41076245c28 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -21,8 +21,15 @@ */ require("./pre.inc.php"); require("../commande.class.php"); -require("../../graph.class.php"); require("./commandestats.class.php"); +/* + * Sécurité accés client + */ +if ($user->societe_id > 0) +{ + $action = ''; + $socidp = $user->societe_id; +} llxHeader(); /* @@ -32,47 +39,41 @@ llxHeader(); print_fiche_titre('Statistiques commandes', $mesg); -$stats = new CommandeStats($db); +$stats = new CommandeStats($db, $socidp); + $year = strftime("%Y", time()); $data = $stats->getNbCommandeByMonthWithPrevYear($year); $filev = "/document/images/nbcommande2year.png"; -$px = new Graph($data); +$px = new BarGraph($data); $px->SetMaxValue($px->GetMaxValue()); $px->SetWidth(450); $px->SetHeight(280); $px->SetYLabel("Nombre de commande"); $px->draw(DOL_DOCUMENT_ROOT.$filev, $data, $year); -$sql = "SELECT count(*), date_format(date_commande,'%Y') as dm, sum(total_ht) FROM llx_commande WHERE fk_statut > 0 GROUP BY dm DESC "; -if ($db->query($sql)) -{ - $num = $db->num_rows(); +$rows = $stats->getNbByYear(); +$num = sizeof($rows); - print ''; - print ''; - print ''; - $i = 0; - while ($i < $num) - { - $row = $db->fetch_row($i); - $nbproduct = $row[0]; - $year = $row[1]; - print ""; - print ''; - $i++; - } - - print '
AnnéeNb de commandeSomme des commandes'; - print 'Nombre de commande par mois
Graphique nombre de commande'; - print '
'.$year.''.$nbproduct.''.price($row[2]).'
'; - $db->free(); -} -else +print ''; +print ''; +print ''; +$i = 0; +while (list($key, $value) = each ($rows)) { - print "Erreur"; + $nbproduct = $value[0]; + $price = $value[1]; + $year = $key; + print ""; + print ''; + $i++; } +print '
AnnéeNb de commandeSomme des commandes'; +print 'Nombre de commande par mois
Graphique nombre de commande'; +print '
'.$year.''.$nbproduct.''.price($price).'
'; +$db->free(); + $db->close();