diff --git a/htdocs/telephonie/stats/commerciaux/commercial.gain.class.php b/htdocs/telephonie/stats/commerciaux/commercial.gain.class.php index b1c68b0996d..94f8e5fe64b 100644 --- a/htdocs/telephonie/stats/commerciaux/commercial.gain.class.php +++ b/htdocs/telephonie/stats/commerciaux/commercial.gain.class.php @@ -40,6 +40,13 @@ class GraphCommercialGain extends GraphBar { { $num = 0; + if ($commercial > 0) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."telephonie_stats"; + $sql .= " WHERE graph='commercial.gain.mensuel.".$commercial."';"; + $resql = $this->db->query($sql); + } + $sql = "SELECT date_format(f.date,'%Y%m'), sum(f.gain)"; $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture as f"; $sql .= " , ".MAIN_DB_PREFIX."telephonie_societe_ligne as l"; @@ -64,6 +71,15 @@ class GraphCommercialGain extends GraphBar { $datas[$i] = $row[1]; $labels[$i] = substr($row[0],-2)."/".substr($row[0],2,2); + if ($commercial > 0) + { + $sqli = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_stats"; + $sqli .= " (graph,ord,legend,valeur)"; + $sqli .= " VALUES ('commercial.gain.mensuel.".$commercial."'"; + $sqli .= ",'$i','".$row[0]."','".$datas[$i]."');"; + $resqli = $this->db->query($sqli); + } + $i++; }