40 |
{ |
{ |
41 |
$num = 0; |
$num = 0; |
42 |
|
|
43 |
|
if ($commercial > 0) |
44 |
|
{ |
45 |
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."telephonie_stats"; |
46 |
|
$sql .= " WHERE graph='commercial.ca.mensuel.".$commercial."';"; |
47 |
|
$resql = $this->db->query($sql); |
48 |
|
} |
49 |
|
|
50 |
|
|
51 |
$sql = "SELECT date_format(f.date,'%Y%m'), sum(f.cout_vente)"; |
$sql = "SELECT date_format(f.date,'%Y%m'), sum(f.cout_vente)"; |
52 |
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture as f"; |
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture as f"; |
53 |
$sql .= " , ".MAIN_DB_PREFIX."telephonie_societe_ligne as l"; |
$sql .= " , ".MAIN_DB_PREFIX."telephonie_societe_ligne as l"; |
55 |
$sql .= " AND l.fk_commercial_sign = ".$commercial; |
$sql .= " AND l.fk_commercial_sign = ".$commercial; |
56 |
$sql .= " GROUP BY date_format(f.date,'%Y%m') ASC"; |
$sql .= " GROUP BY date_format(f.date,'%Y%m') ASC"; |
57 |
|
|
58 |
$result = $this->db->query($sql); |
$resql = $this->db->query($sql); |
59 |
|
|
60 |
if ($result) |
if ($resql) |
61 |
{ |
{ |
62 |
$num = $this->db->num_rows(); |
$num = $this->db->num_rows($resql); |
63 |
$i = 0; |
$i = 0; |
64 |
$j = -1; |
$j = -1; |
65 |
$datas = array(); |
$datas = array(); |
67 |
|
|
68 |
while ($i < $num) |
while ($i < $num) |
69 |
{ |
{ |
70 |
$row = $this->db->fetch_row(); |
$row = $this->db->fetch_row($resql); |
71 |
|
|
72 |
$datas[$i] = $row[1]; |
$datas[$i] = $row[1]; |
73 |
$labels[$i] = substr($row[0],-2)."/".substr($row[0],2,2); |
$labels[$i] = substr($row[0],-2)."/".substr($row[0],2,2); |
74 |
|
|
75 |
|
if ($commercial > 0) |
76 |
|
{ |
77 |
|
$sqli = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_stats"; |
78 |
|
$sqli .= " (graph,ord,legend,valeur)"; |
79 |
|
$sqli .= " VALUES ('commercial.ca.mensuel.".$commercial."'"; |
80 |
|
$sqli .= ",'$i','".$row[0]."','".$datas[$i]."');"; |
81 |
|
$resqli = $this->db->query($sqli); |
82 |
|
} |
83 |
$i++; |
$i++; |
84 |
} |
} |
85 |
|
|
86 |
$this->db->free(); |
$this->db->free($resql); |
87 |
} |
} |
88 |
else |
else |
89 |
{ |
{ |