2004-10-19 20:58:50 +02:00
|
|
|
|
<?php
|
2003-11-09 18:32:09 +01:00
|
|
|
|
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2004-10-19 20:58:50 +02:00
|
|
|
|
* Copyright (c) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
2003-11-09 18:32:09 +01:00
|
|
|
|
*
|
|
|
|
|
|
* 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$
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2004-12-04 20:07:24 +01:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
\file htdocs/commande/stats/index.php
|
|
|
|
|
|
\ingroup commande
|
|
|
|
|
|
\brief Page des stats commandes
|
|
|
|
|
|
\version $Revision$
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2003-11-09 18:32:09 +01:00
|
|
|
|
require("./pre.inc.php");
|
2005-08-21 20:57:46 +02:00
|
|
|
|
|
|
|
|
|
|
if (!$user->rights->commande->lire) accessforbidden();
|
|
|
|
|
|
|
2005-08-13 23:23:02 +02:00
|
|
|
|
require(DOL_DOCUMENT_ROOT."/commande/commande.class.php");
|
2003-11-16 17:45:13 +01:00
|
|
|
|
require("./commandestats.class.php");
|
2005-07-16 16:56:25 +02:00
|
|
|
|
|
|
|
|
|
|
$WIDTH=500;
|
|
|
|
|
|
$HEIGHT=250;
|
|
|
|
|
|
|
|
|
|
|
|
// S<>curit<69> acc<63>s client
|
2003-11-24 13:18:02 +01:00
|
|
|
|
if ($user->societe_id > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
$action = '';
|
|
|
|
|
|
$socidp = $user->societe_id;
|
|
|
|
|
|
}
|
2003-11-09 18:32:09 +01:00
|
|
|
|
|
2005-07-16 16:56:25 +02:00
|
|
|
|
|
2003-11-09 18:32:09 +01:00
|
|
|
|
llxHeader();
|
|
|
|
|
|
|
2005-02-06 17:08:01 +01:00
|
|
|
|
print_fiche_titre($langs->trans("OrdersStatistics"), $mesg);
|
2003-11-09 18:32:09 +01:00
|
|
|
|
|
2003-11-24 13:18:02 +01:00
|
|
|
|
$stats = new CommandeStats($db, $socidp);
|
|
|
|
|
|
|
2003-11-16 17:45:13 +01:00
|
|
|
|
$year = strftime("%Y", time());
|
2005-07-16 16:56:25 +02:00
|
|
|
|
$data = $stats->getNbByMonthWithPrevYear($year);
|
2004-12-04 20:07:24 +01:00
|
|
|
|
|
2005-02-06 17:34:11 +01:00
|
|
|
|
if (! is_dir($conf->commande->dir_images))
|
|
|
|
|
|
{
|
|
|
|
|
|
mkdir($conf->commande->dir_output);
|
|
|
|
|
|
mkdir($conf->commande->dir_images);
|
|
|
|
|
|
}
|
2004-12-04 20:07:24 +01:00
|
|
|
|
|
2005-02-06 17:08:01 +01:00
|
|
|
|
$filename = $conf->commande->dir_images."/nbcommande2year-".$year.".png";
|
|
|
|
|
|
$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=nbcommande2year-'.$year.'.png';
|
2003-11-16 17:45:13 +01:00
|
|
|
|
|
2005-07-16 16:03:27 +02:00
|
|
|
|
$px = new BarGraph();
|
2004-06-08 22:26:55 +02:00
|
|
|
|
$mesg = $px->isGraphKo();
|
|
|
|
|
|
if (! $mesg) {
|
2005-07-16 16:03:27 +02:00
|
|
|
|
$px->SetData($data);
|
2004-06-08 22:26:55 +02:00
|
|
|
|
$px->SetMaxValue($px->GetMaxValue());
|
2005-07-16 16:56:25 +02:00
|
|
|
|
$px->SetLegend(array($year - 1, $year));
|
|
|
|
|
|
$px->SetWidth($WIDTH);
|
|
|
|
|
|
$px->SetHeight($HEIGHT);
|
2004-06-08 22:26:55 +02:00
|
|
|
|
$px->SetYLabel("Nombre de commande");
|
2005-07-16 16:03:27 +02:00
|
|
|
|
$px->draw($filename);
|
2004-06-08 22:26:55 +02:00
|
|
|
|
}
|
2003-11-24 13:18:02 +01:00
|
|
|
|
$rows = $stats->getNbByYear();
|
|
|
|
|
|
$num = sizeof($rows);
|
2003-11-16 17:45:13 +01:00
|
|
|
|
|
2005-02-06 17:08:01 +01:00
|
|
|
|
print '<table class="border" width="100%">';
|
|
|
|
|
|
print '<tr><td align="center">'.$langs->trans("Year").'</td><td width="10%" align="center">'.$langs->trans("NbOfOrders").'</td><td align="center">'.$langs->trans("AmountTotal").'</td>';
|
2003-11-24 13:18:02 +01:00
|
|
|
|
print '<td align="center" valign="top" rowspan="'.($num + 1).'">';
|
2004-06-08 22:26:55 +02:00
|
|
|
|
if ($mesg) { print $mesg; }
|
2004-12-04 20:07:24 +01:00
|
|
|
|
else { print '<img src="'.$fileurl.'" alt="Nombre de commande par mois">'; }
|
2003-11-24 13:18:02 +01:00
|
|
|
|
print '</td></tr>';
|
|
|
|
|
|
$i = 0;
|
|
|
|
|
|
while (list($key, $value) = each ($rows))
|
2003-11-16 17:45:13 +01:00
|
|
|
|
{
|
2005-07-16 16:56:25 +02:00
|
|
|
|
$year = $value[0];
|
|
|
|
|
|
$nbproduct = $value[1];
|
|
|
|
|
|
$price = $value[2];
|
2003-11-24 13:18:02 +01:00
|
|
|
|
print "<tr>";
|
|
|
|
|
|
print '<td align="center"><a href="month.php?year='.$year.'">'.$year.'</a></td><td align="center">'.$nbproduct.'</td><td align="center">'.price($price).'</td></tr>';
|
|
|
|
|
|
$i++;
|
2003-11-09 18:32:09 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2003-11-24 13:18:02 +01:00
|
|
|
|
print '</table>';
|
|
|
|
|
|
|
2003-11-09 18:32:09 +01:00
|
|
|
|
|
|
|
|
|
|
$db->close();
|
|
|
|
|
|
|
|
|
|
|
|
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
|
|
|
|
|
?>
|