diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index 956fc121018..06bee4e4466 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -22,6 +22,7 @@ require("./pre.inc.php"); require("../commande.class.php"); require("../../graph.class.php"); +require("./commandestats.class.php"); llxHeader(); /* @@ -30,14 +31,29 @@ llxHeader(); */ print_fiche_titre('Statistiques commandes', $mesg); - -print ''; -print ''; +$stats = new CommandeStats($db); +$year = strftime("%Y", time()); +$data = $stats->getNbCommandeByMonthWithPrevYear($year); +$filev = "/document/images/nbcommande2year.png"; + +$px = new Graph($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(); + + print '
AnnéeNb de commandeSomme des commandes
'; + print ''; + print ''; $i = 0; while ($i < $num) { @@ -45,13 +61,18 @@ if ($db->query($sql)) $nbproduct = $row[0]; $year = $row[1]; print ""; - print ''; + print ''; $i++; } -} -$db->free(); -print '
AnnéeNb de commandeSomme des commandes'; + print 'Graphique nombre de commande'; + print '
'.$year.''.$nbproduct.''.price($row[2]).'
'.$year.''.$nbproduct.''.price($row[2]).'
'; + print ''; + $db->free(); +} +else +{ + print "Erreur"; +} + $db->close();