Filtre sur l'anne

This commit is contained in:
Rodolphe Quiedeville 2005-12-01 14:58:36 +00:00
parent 95654ef8a7
commit 87bc054be3
3 changed files with 34 additions and 12 deletions

View File

@ -86,17 +86,17 @@ if ($resql)
/* Chiffre d'affaire mensuel */
$file = $img_root . "commercials/".$row[0]."/ca.mensuel.png";
$file = $img_root . "commercials/".$row[0]."/ca.mensuel.$year.png";
if ($verbose) print "Graph : Lignes commandes$file\n";
$graph = new GraphCommercialChiffreAffaire($db, $file);
$graph = new GraphCommercialChiffreAffaire($db, $file, $year);
$graph->width = 400;
$graph->GraphMakeGraph($row[0]);
/* Gain */
$file = $img_root . "commercials/".$row[0]."/gain.mensuel.png";
$file = $img_root . "commercials/".$row[0]."/gain.mensuel.$year.png";
if ($verbose) print "Graph : Lignes commandes$file\n";
$graph = new GraphCommercialGain($db, $file);
$graph = new GraphCommercialGain($db, $file, $year);
$graph->width = 400;
$graph->GraphMakeGraph($row[0]);

View File

@ -24,14 +24,17 @@ require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/bar.class.php");
class GraphCommercialChiffreAffaire extends GraphBar {
Function GraphCommercialChiffreAffaire($DB, $file)
Function GraphCommercialChiffreAffaire($DB, $file, $year=0)
{
$this->db = $DB;
$this->file = $file;
$this->year = $year;
$this->client = 0;
$this->titre = "Chiffre d'affaire";
if ($this->year > 0)
{
$this->titre .= " ".$year;
}
$this->barcolor = "blue";
$this->showframe = true;
}
@ -44,6 +47,10 @@ class GraphCommercialChiffreAffaire extends GraphBar {
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."telephonie_stats";
$sql .= " WHERE graph='commercial.ca.mensuel.".$commercial."';";
if ($this->year > 0)
{
$sql .= " AND legend like '".$this->year."%'";
}
$resql = $this->db->query($sql);
}
@ -53,6 +60,10 @@ class GraphCommercialChiffreAffaire extends GraphBar {
$sql .= " , ".MAIN_DB_PREFIX."telephonie_societe_ligne as l";
$sql .= " WHERE l.rowid = f.fk_ligne";
$sql .= " AND l.fk_commercial_sign = ".$commercial;
if ($this->year > 0)
{
$sql .= " AND date_format(f.date,'%Y')='".$this->year."'";
}
$sql .= " GROUP BY date_format(f.date,'%Y%m') ASC";
$resql = $this->db->query($sql);
@ -70,7 +81,7 @@ class GraphCommercialChiffreAffaire extends GraphBar {
$row = $this->db->fetch_row($resql);
$datas[$i] = $row[1];
$labels[$i] = substr($row[0],-2)."/".substr($row[0],2,2);
$labels[$i] = substr($row[0],-2);
if ($commercial > 0)
{

View File

@ -24,14 +24,17 @@ require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/bar.class.php");
class GraphCommercialGain extends GraphBar {
Function GraphCommercialGain($DB, $file)
Function GraphCommercialGain($DB, $file, $year=0)
{
$this->db = $DB;
$this->file = $file;
$this->year = $year;
$this->client = 0;
$this->titre = "Gain mensuel";
if ($this->year > 0)
{
$this->titre = "Gain mensuel ".$this->year;
}
$this->barcolor = "pink";
$this->showframe = true;
}
@ -43,7 +46,11 @@ class GraphCommercialGain extends GraphBar {
if ($commercial > 0)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."telephonie_stats";
$sql .= " WHERE graph='commercial.gain.mensuel.".$commercial."';";
$sql .= " WHERE graph='commercial.gain.mensuel.".$commercial."'";
if ($this->year > 0)
{
$sql .= " AND legend like '".$this->year."%'";
}
$resql = $this->db->query($sql);
}
@ -52,6 +59,10 @@ class GraphCommercialGain extends GraphBar {
$sql .= " , ".MAIN_DB_PREFIX."telephonie_societe_ligne as l";
$sql .= " WHERE l.rowid = f.fk_ligne";
$sql .= " AND l.fk_commercial_sign = ".$commercial;
if ($this->year > 0)
{
$sql .= " AND date_format(f.date,'%Y')='".$this->year."'";
}
$sql .= " GROUP BY date_format(f.date,'%Y%m') ASC";
$resql = $this->db->query($sql);