diff --git a/htdocs/telephonie/script/graph-statistiques-commerciaux.php b/htdocs/telephonie/script/graph-statistiques-commerciaux.php index 609bb67459d..abea118a295 100644 --- a/htdocs/telephonie/script/graph-statistiques-commerciaux.php +++ b/htdocs/telephonie/script/graph-statistiques-commerciaux.php @@ -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]); diff --git a/htdocs/telephonie/stats/commerciaux/commercial.ca.class.php b/htdocs/telephonie/stats/commerciaux/commercial.ca.class.php index 6f86134bb31..a3f7190c54e 100644 --- a/htdocs/telephonie/stats/commerciaux/commercial.ca.class.php +++ b/htdocs/telephonie/stats/commerciaux/commercial.ca.class.php @@ -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) { diff --git a/htdocs/telephonie/stats/commerciaux/commercial.gain.class.php b/htdocs/telephonie/stats/commerciaux/commercial.gain.class.php index 94f8e5fe64b..84e43cd8603 100644 --- a/htdocs/telephonie/stats/commerciaux/commercial.gain.class.php +++ b/htdocs/telephonie/stats/commerciaux/commercial.gain.class.php @@ -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);