Qual: Uniformize code.

This commit is contained in:
Laurent Destailleur 2008-09-08 13:32:37 +00:00
parent 758a78ef85
commit e461753e43
7 changed files with 331 additions and 229 deletions

View File

@ -80,14 +80,10 @@ class PropaleStats extends Stats
$sql = "SELECT date_format(p.datep,'%m') as dm, count(*)";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX."propal as p";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE date_format(p.datep,'%Y') = $year AND p.fk_statut > 0";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if($user->societe_id)
{
$sql .= " AND p.fk_soc = ".$user->societe_id;
}
$sql .= " WHERE date_format(p.datep,'%Y') = ".$year;
$sql.= " AND ".$this->where;
$sql .= " GROUP BY dm DESC";
return $this->_getNbByMonth($year, $sql);
@ -103,15 +99,10 @@ class PropaleStats extends Stats
$sql = "SELECT date_format(p.datep,'%Y') as dm, count(*)";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX."propal as p";
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE p.fk_statut > 0";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if($user->societe_id)
{
$sql .= " AND p.fk_soc = ".$user->societe_id;
}
$sql .= " GROUP BY dm DESC";
$sql.= " WHERE ".$this->where;
$sql.= " GROUP BY dm DESC";
return $this->_getNbByYear($sql);
}
@ -125,15 +116,11 @@ class PropaleStats extends Stats
$sql = "SELECT date_format(p.datep,'%m') as dm, sum(p.total_ht)";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX."propal as p";
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE date_format(p.datep,'%Y') = $year AND p.fk_statut > 0";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if($user->societe_id)
{
$sql .= " AND p.fk_soc = ".$user->societe_id;
}
$sql .= " GROUP BY dm DESC";
$sql.= " WHERE date_format(p.datep,'%Y') = ".$year;
$sql.= " AND ".$this->where;
$sql.= " GROUP BY dm DESC";
return $this->_getAmountByMonth($year, $sql);
}
@ -146,16 +133,12 @@ class PropaleStats extends Stats
global $user;
$sql = "SELECT date_format(p.datep,'%m') as dm, avg(p.total_ht)";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX."propal as p";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE date_format(p.datep,'%Y') = $year AND p.fk_statut > 0";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if($user->societe_id)
{
$sql .= " AND p.fk_soc = ".$user->societe_id;
}
$sql .= " GROUP BY dm DESC";
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p";
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE date_format(p.datep,'%Y') = ".$year;
$sql.= " AND ".$this->where;
$sql.= " GROUP BY dm DESC";
return $this->_getAverageByMonth($year, $sql);
}
@ -170,9 +153,9 @@ class PropaleStats extends Stats
global $user;
$sql = "SELECT date_format(p.datep,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", sc.fk_soc, sc.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."propal as p";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p";
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE ".$this->where;
$sql.= " GROUP BY year DESC";

View File

@ -15,128 +15,153 @@
* 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$
*/
/**
\file htdocs/commande/stats/commandestats.class.php
\ingroup commandes
\brief Fichier de la classe de gestion des stats des commandes
\version $Revision$
*/
* \file htdocs/commande/stats/commandestats.class.php
* \ingroup commandes
* \brief Fichier de la classe de gestion des stats des commandes
* \version $Id$
*/
include_once DOL_DOCUMENT_ROOT . "/stats.class.php";
include_once DOL_DOCUMENT_ROOT . "/commande/commande.class.php";
/**
\class CommandeStats
\brief Classe permettant la gestion des stats des commandes
*/
* \class CommandeStats
* \brief Classe permettant la gestion des stats des commandes
*/
class CommandeStats extends Stats
{
var $db ;
var $db ;
function CommandeStats($DB, $socid)
{
$this->db = $DB;
$this->socid = $socid;
}
var $socid;
var $where;
/**
* \brief Renvoie le nombre de commande par mois pour une année donnée
*
*/
function getNbByMonth($year)
{
global $conf;
global $user;
$sql = "SELECT date_format(c.date_commande,'%m') as dm, count(*) nb";
$sql .= " FROM ".MAIN_DB_PREFIX."commande as c";
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE date_format(c.date_commande,'%Y') = $year AND c.fk_statut > 0";
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($this->socid)
{
$sql .= " AND c.fk_soc = ".$this->socid;
}
$sql .= " GROUP BY dm";
$sql .= " ORDER BY dm DESC";
var $table_element;
var $field;
return $this->_getNbByMonth($year, $sql);
}
/**
* Constructor
*
* @param $DB Database handler
* @param $socid Id third party
* @return PropaleStats
*/
function CommandeStats($DB, $socid=0)
{
global $user;
$this->db = $DB;
$object=new Commande($this->db);
$this->table_element=$object->table_element;
$this->field='total_ht';
$this->socid = $socid;
$this->where.= " c.fk_statut > 0";
if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if($this->socid)
{
$this->where .= " AND c.fk_soc = ".$this->socid;
}
}
/**
* Renvoie le nombre de commande par année
*
*/
function getNbByYear()
{
global $conf;
global $user;
$sql = "SELECT date_format(c.date_commande,'%Y') as dm, count(*), sum(c.total_ht)";
$sql .= " FROM ".MAIN_DB_PREFIX."commande as c";
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE c.fk_statut > 0";
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($this->socid)
{
$sql .= " AND c.fk_soc = ".$this->socid;
}
$sql .= " GROUP BY dm DESC";
/**
* \brief Renvoie le nombre de commande par mois pour une année donnée
*
*/
function getNbByMonth($year)
{
global $conf;
global $user;
$sql = "SELECT date_format(c.date_commande,'%m') as dm, count(*) nb";
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as c";
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE date_format(c.date_commande,'%Y') = ".$year;
$sql.= " AND ".$this->where;
$sql.= " GROUP BY dm DESC";
return $this->_getNbByYear($sql);
}
/**
* Renvoie le nombre de commande par mois pour une année donnée
*
*/
function getAmountByMonth($year)
{
global $conf;
global $user;
$sql = "SELECT date_format(c.date_commande,'%m') as dm, sum(c.total_ht)";
$sql .= " FROM ".MAIN_DB_PREFIX."commande as c";
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE date_format(c.date_commande,'%Y') = $year AND c.fk_statut > 0";
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($this->socid)
{
$sql .= " AND c.fk_soc = ".$this->socid;
}
$sql .= " GROUP BY dm DESC";
return $this->_getNbByMonth($year, $sql);
}
return $this->_getAmountByMonth($year, $sql);
}
/**
* Renvoie le nombre de commande par mois pour une année donnée
*
*/
function getAverageByMonth($year)
{
global $conf;
global $user;
$sql = "SELECT date_format(c.date_commande,'%m') as dm, avg(c.total_ht)";
$sql .= " FROM ".MAIN_DB_PREFIX."commande as c";
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE date_format(c.date_commande,'%Y') = $year AND c.fk_statut > 0";
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($this->socid)
{
$sql .= " AND c.fk_soc = ".$this->socid;
}
$sql .= " GROUP BY dm DESC";
/**
* Renvoie le nombre de commande par année
*
*/
function getNbByYear()
{
global $conf;
global $user;
$sql = "SELECT date_format(c.date_commande,'%Y') as dm, count(*), sum(c.".$this->field.")";
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as c";
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE ".$this->where;
$sql.= " GROUP BY dm DESC";
return $this->_getAverageByMonth($year, $sql);
}
return $this->_getNbByYear($sql);
}
/**
* Renvoie le nombre de commande par mois pour une année donnée
*
*/
function getAmountByMonth($year)
{
global $conf;
global $user;
$sql = "SELECT date_format(c.date_commande,'%m') as dm, sum(c.".$this->field.")";
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as c";
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE date_format(c.date_commande,'%Y') = ".$year;
$sql.= " AND ".$this->where;
$sql.= " GROUP BY dm DESC";
return $this->_getAmountByMonth($year, $sql);
}
/**
* Renvoie le nombre de commande par mois pour une année donnée
*
*/
function getAverageByMonth($year)
{
global $conf;
global $user;
$sql = "SELECT date_format(c.date_commande,'%m') as dm, avg(c.".$this->field.")";
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as c";
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE date_format(c.date_commande,'%Y') = ".$year;
$sql.= " AND ".$this->where;
$sql.= " GROUP BY dm DESC";
return $this->_getAverageByMonth($year, $sql);
}
/**
* \brief Return nb, total and average
* \return array Array of values
*/
function getAllByYear()
{
global $user;
$sql = "SELECT date_format(c.date_commande,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg";
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as c";
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE ".$this->where;
$sql.= " GROUP BY year DESC";
return $this->_getAllByYear($sql);
}
}
?>

View File

@ -41,36 +41,39 @@ if ($user->societe_id > 0)
$socid = $user->societe_id;
}
$year = strftime("%Y", time());
$startyear=$year-2;
$endyear=$year;
/*
* View
*/
llxHeader();
print_fiche_titre($langs->trans("OrdersStatistics"), $mesg);
$stats = new CommandeStats($db, $socid);
$year = strftime("%Y", time());
$startyear=$year-2;
$endyear=$year;
$data = $stats->getNbByMonthWithPrevYear($endyear,$startyear);
// Création répertoire pour images générées
$dir=$conf->commande->dir_temp;
if (! file_exists($dir))
{
if (create_exdir($dir) < 0)
{
$mesg = $langs->trans("ErrorCanNotCreateDir",$dir);
}
}
create_exdir($dir);
$stats = new CommandeStats($db, $socid);
// Build graphic number of object
$data = $stats->getNbByMonthWithPrevYear($endyear,$startyear);
//var_dump($data);
// $data = array(array('Lib',val1,val2,val3),...)
if (!$user->rights->societe->client->voir || $user->societe_id)
{
$filename = $conf->commande->dir_temp.'/nbcommande2year-'.$user->id.'-'.$year.'.png';
$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=nbcommande2year-'.$user->id.'-'.$year.'.png';
$filenamenb = $dir.'/ordersnbinyear-'.$user->id.'-'.$year.'.png';
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnbinyear-'.$user->id.'-'.$year.'.png';
}
else
{
$filename = $conf->commande->dir_temp.'/nbcommande2year-'.$year.'.png';
$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=nbcommande2year-'.$year.'.png';
$filenamenb = $dir.'/ordersnbinyear-'.$year.'.png';
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnbinyear-'.$year.'.png';
}
$px = new DolGraph();
@ -87,6 +90,7 @@ if (! $mesg)
}
$px->SetLegend($legend);
$px->SetMaxValue($px->GetCeilMaxValue());
$px->SetMinValue(min(0,$px->GetFloorMinValue()));
$px->SetWidth($WIDTH);
$px->SetHeight($HEIGHT);
$px->SetYLabel($langs->trans("NbOfOrder"));
@ -94,31 +98,109 @@ if (! $mesg)
$px->SetHorizTickIncrement(1);
$px->SetPrecisionY(0);
$px->mode='depth';
$px->draw($filename);
$px->SetTitle($langs->trans("NumberOfOrdersByMonth"));
$px->draw($filenamenb);
}
$rows = $stats->getNbByYear();
$num = sizeof($rows);
// Build graphic amount of object
$data = $stats->getAmountByMonthWithPrevYear($endyear,$startyear);
//var_dump($data);
// $data = array(array('Lib',val1,val2,val3),...)
if (!$user->rights->societe->client->voir || $user->societe_id)
{
$filenameamount = $dir.'/ordersamountinyear-'.$user->id.'-'.$year.'.png';
$fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamountinyear-'.$user->id.'-'.$year.'.png';
}
else
{
$filenameamount = $dir.'/ordersamountinyear-'.$year.'.png';
$fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamountinyear-'.$year.'.png';
}
$px = new DolGraph();
$mesg = $px->isGraphKo();
if (! $mesg)
{
$px->SetData($data);
$px->SetPrecisionY(0);
$i=$startyear;
while ($i <= $endyear)
{
$legend[]=$i;
$i++;
}
$px->SetLegend($legend);
$px->SetMaxValue($px->GetCeilMaxValue());
$px->SetMinValue(min(0,$px->GetFloorMinValue()));
$px->SetWidth($WIDTH);
$px->SetHeight($HEIGHT);
$px->SetYLabel($langs->trans("AmountOfOrders"));
$px->SetShading(3);
$px->SetHorizTickIncrement(1);
$px->SetPrecisionY(0);
$px->mode='depth';
$px->SetTitle($langs->trans("AmountOfOrdersByMonthHT"));
$px->draw($filenameamount);
}
print '<table class="notopnoleftnopadd" width="100%"><tr>';
print '<td align="center" valign="top">';
// Show array
$data = $stats->getAllByYear();
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>';
print '<td align="center" valign="top" rowspan="'.($num + 1).'">';
if ($px->isGraphKo()) { print '<font class="error">'.$px->isGraphKo().'</div>'; }
else { print '<img src="'.$fileurl.'" alt="Nombre de commande par mois">'; }
print '</td></tr>';
$i = 0;
while (list($key, $value) = each ($rows))
print '<tr height="24">';
print '<td align="center">'.$langs->trans("Year").'</td>';
print '<td align="center">'.$langs->trans("NbOfOrders").'</td>';
print '<td align="center">'.$langs->trans("AmountTotal").'</td>';
print '<td align="center">'.$langs->trans("AmountAverage").'</td>';
print '</tr>';
$oldyear=0;
foreach ($data as $val)
{
$year = $value[0];
$nbproduct = $value[1];
$price = $value[2];
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++;
$year = $val['year'];
print $avg;
while ($oldyear > $year+1)
{ // If we have empty year
$oldyear--;
print '<tr height="24">';
print '<td align="center"><a href="month.php?year='.$oldyear.'&amp;mode='.$mode.'">'.$oldyear.'</a></td>';
print '<td align="right">0</td>';
print '<td align="right">0</td>';
print '<td align="right">0</td>';
print '</tr>';
}
print '<tr height="24">';
print '<td align="center"><a href="month.php?year='.$year.'">'.$year.'</a></td>';
print '<td align="right">'.$val['nb'].'</td>';
print '<td align="right">'.price(price2num($val['total'],'MT'),1).'</td>';
print '<td align="right">'.price(price2num($val['avg'],'MT'),1).'</td>';
print '</tr>';
$oldyear=$year;
}
print '</table>';
print '</td>';
print '<td align="center" valign="top">';
// Show graphs
print '<table class="border" width="100%"><tr valign="top"><td align="center">';
if ($mesg) { print $mesg; }
else {
print '<img src="'.$fileurlnb.'" title="'.$langs->trans("NbOfOrders").'" alt="'.$langs->trans("NbOfProposals").'">';
print "<br>\n";
print '<img src="'.$fileurlamount.'" title="'.$langs->trans("AmountTotal").'" alt="'.$langs->trans("AmountTotal").'">';
}
print '</td></tr></table>';
print '</td></tr></table>';
$db->close();
llxFooter('$Date$ - $Revision$');

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (c) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (c) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
@ -18,57 +18,71 @@
*/
/**
\file htdocs/commande/stats/month.php
\ingroup commande
\brief Page des stats commandes par mois
\version $Id$
*/
* \file htdocs/commande/stats/month.php
* \ingroup commande
* \brief Page des stats commandes par mois
* \version $Id$
*/
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php");
require_once(DOL_DOCUMENT_ROOT."/commande/stats/commandestats.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/dolgraph.class.php");
// Sécurité accés client
$GRAPHWIDTH=500;
$GRAPHHEIGHT=200;
// Check security access
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
}
llxHeader();
$year = isset($_GET["year"])?$_GET["year"]:date("Y",time());
$mesg = '<a href="month.php?year='.($year - 1).'">'.img_previous().'</a> ';
$mesg.= $langs->trans("Year")." $year";
$mesg.= ' <a href="month.php?year='.($year + 1).'">'.img_next().'</a>';
$mode='customer';
if (isset($_GET["mode"])) $mode=$_GET["mode"];
$WIDTH=500;
$HEIGHT=200;
/*
*
*
* View
*/
print_fiche_titre($langs->trans("OrdersStatistics"), $mesg);
llxHeader();
if ($mode == 'customer')
{
$title=$langs->trans("OrdersStatistics");
$dir=$conf->commande->dir_temp;
}
if ($mode == 'supplier')
{
$title=$langs->trans("OrdersStatisticsSuppliers");
$dir=$conf->fournisseur->commande->dir_temp;
}
$mesg = '<a href="month.php?year='.($year - 1).'&amp;mode='.$mode.'">'.img_previous().'</a> ';
$mesg.= $langs->trans("Year")." $year";
$mesg.= ' <a href="month.php?year='.($year + 1).'&amp;mode='.$mode.'">'.img_next().'</a>';
print_fiche_titre($title, $mesg);
create_exdir($dir);
$stats = new CommandeStats($db, $socid, $mode);
$stats = new CommandeStats($db, $socid);
$data = $stats->getNbByMonth($year);
create_exdir($conf->commande->dir_temp);
if (!$user->rights->societe->client->voir || $user->societe_id)
{
$filename = $conf->commande->dir_temp.'/commande-'.$user->id.'-'.$year.'.png';
$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=commande-'.$user->id.'-'.$year.'.png';
$filename = $dir.'/ordersnb-'.$user->id.'-'.$year.'.png';
$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnb-'.$user->id.'-'.$year.'.png';
}
else
{
$filename = $conf->commande->dir_temp.'/commande'.$year.'.png';
$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=commande'.$year.'.png';
$filename = $dir.'/ordersnb-'.$year.'.png';
$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersnb-'.$year.'.png';
}
$px = new DolGraph();
@ -77,8 +91,9 @@ if (! $mesg)
{
$px->SetData($data);
$px->SetMaxValue($px->GetCeilMaxValue());
$px->SetWidth($WIDTH);
$px->SetHeight($HEIGHT);
$px->SetMinValue($px->GetFloorMinValue());
$px->SetWidth($GRAPHWIDTH);
$px->SetHeight($GRAPHHEIGHT);
$px->SetYLabel($langs->trans("NbOfOrders"));
$px->SetShading(3);
$px->SetHorizTickIncrement(1);
@ -86,24 +101,18 @@ if (! $mesg)
$px->draw($filename);
}
$res = $stats->getAmountByMonth($year);
$data = array();
for ($i = 1 ; $i < 13 ; $i++)
{
$data[$i-1] = array(ucfirst(substr(strftime("%b",dolibarr_mktime(12,12,12,$i,1,$year)),0,3)), $res[$i]);
}
$data = $stats->getAmountByMonth($year);
if (!$user->rights->societe->client->voir || $user->societe_id)
{
$filename_amount = $conf->commande->dir_temp.'/commandeamount-'.$user->id.'-'.$year.'.png';
$fileurl_amount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=commandeamount-'.$user->id.'-'.$year.'.png';
$filename_amount = $dir.'/ordersamount-'.$user->id.'-'.$year.'.png';
$fileurl_amount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamount-'.$user->id.'-'.$year.'.png';
}
else
{
$filename_amount = $conf->commande->dir_temp.'/commandeamount'.$year.'.png';
$fileurl_amount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=commandeamount'.$year.'.png';
$filename_amount = $dir.'/ordersamount-'.$year.'.png';
$fileurl_amount = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersamount-'.$year.'.png';
}
$px = new DolGraph();
@ -111,11 +120,12 @@ $mesg = $px->isGraphKo();
if (! $mesg)
{
$px->SetData($data);
$px->SetMaxValue($px->GetCeilMaxValue());
$px->SetWidth($WIDTH);
$px->SetHeight($HEIGHT);
$px->SetYLabel($langs->trans("AmountTotal"));
$px->SetShading(5);
$px->SetMaxValue($px->GetCeilMaxValue());
$px->SetMinValue($px->GetFloorMinValue());
$px->SetWidth($GRAPHWIDTH);
$px->SetHeight($GRAPHHEIGHT);
$px->SetShading(3);
$px->SetHorizTickIncrement(1);
$px->SetPrecisionY(0);
$px->draw($filename_amount);
@ -131,13 +141,13 @@ for ($i = 1 ; $i < 13 ; $i++)
if (!$user->rights->societe->client->voir || $user->societe_id)
{
$filename_avg = $conf->commande->dir_temp.'/commandeaverage-'.$user->id.'-'.$year.'.png';
$fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=commandeaverage-'.$user->id.'-'.$year.'.png';
$filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png';
$fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png';
}
else
{
$filename_avg = $conf->commande->dir_temp.'/commandeaverage'.$year.'.png';
$fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=commandeaverage'.$year.'.png';
$filename_avg = $dir.'/ordersaverage-'.$year.'.png';
$fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png';
}
$px = new DolGraph();
@ -145,11 +155,12 @@ $mesg = $px->isGraphKo();
if (! $mesg)
{
$px->SetData($data);
$px->SetMaxValue($px->GetCeilMaxValue());
$px->SetWidth($WIDTH);
$px->SetHeight($HEIGHT);
$px->SetYLabel($langs->trans("AmountAverage"));
$px->SetShading(5);
$px->SetMaxValue($px->GetCeilMaxValue());
$px->SetMinValue($px->GetFloorMinValue());
$px->SetWidth($GRAPHWIDTH);
$px->SetHeight($GRAPHHEIGHT);
$px->SetShading(3);
$px->SetHorizTickIncrement(1);
$px->SetPrecisionY(0);
$px->draw($filename_avg);

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (c) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (c) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
@ -136,7 +136,6 @@ $mesg = $px->isGraphKo();
if (! $mesg)
{
$px->SetData($data);
$px->SetPrecisionY(0);
$px->SetYLabel($langs->trans("AmountAverage"));
$px->SetMaxValue($px->GetCeilMaxValue());
$px->SetMinValue($px->GetFloorMinValue());

View File

@ -69,6 +69,7 @@ AllOrders=All orders
NbOfOrders=Number of orders
OrdersStatistics=Orders' statistics
NumberOfOrdersByMonth=Number of orders by month
AmountOfOrdersByMonthHT=amount of orders by month (net of tax)
ListOfOrders=List of orders
CloseOrder=Close order
ConfirmCloseOrder=Are you sure you want to close this order ? Once an order is closed, it can only be billed.

View File

@ -69,6 +69,7 @@ AllOrders=Toutes les commandes
NbOfOrders=Nombre de commandes
OrdersStatistics=Statistiques des commandes
NumberOfOrdersByMonth=Nombre de commandes par mois
AmountOfOrdersByMonthHT=Montant total de commandes par mois (HT)
ListOfOrders=Liste des commandes
CloseOrder=Cloturer commande
ConfirmCloseOrder=Êtes-vous sur de vouloir cloturer cette commande ? Une fois une commande cloturée, elle doit être facturée.