56 |
Function GetDatas() |
Function GetDatas() |
57 |
{ |
{ |
58 |
|
|
59 |
$sql = "SELECT date_format(td.date,'%Y%m'), sum(duree)"; |
$sql = "SELECT ym, sum(duree)"; |
60 |
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details as td"; |
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details as td"; |
61 |
|
|
62 |
if ($this->client == 0 && $this->contrat == 0 && $this->ligne == 0) |
if ($this->client == 0 && $this->contrat == 0 && $this->ligne == 0) |
63 |
{ |
{ |
64 |
$sql .= " GROUP BY date_format(td.date, '%Y%m') ASC"; |
$sql .= " GROUP BY ym ASC"; |
65 |
} |
} |
66 |
elseif ($this->client > 0 && $this->contrat == 0 && $this->ligne == 0) |
elseif ($this->client > 0 && $this->contrat == 0 && $this->ligne == 0) |
67 |
{ |
{ |
70 |
$sql .= " WHERE td.ligne = s.ligne"; |
$sql .= " WHERE td.ligne = s.ligne"; |
71 |
$sql .= " AND s.fk_client_comm = ".$this->client; |
$sql .= " AND s.fk_client_comm = ".$this->client; |
72 |
|
|
73 |
$sql .= " GROUP BY date_format(td.date,'%Y%m') ASC "; |
$sql .= " GROUP BY ym ASC "; |
74 |
} |
} |
75 |
elseif ($this->client == 0 && $this->contrat > 0 && $this->ligne == 0) |
elseif ($this->client == 0 && $this->contrat > 0 && $this->ligne == 0) |
76 |
{ |
{ |
79 |
$sql .= " WHERE td.ligne = s.ligne"; |
$sql .= " WHERE td.ligne = s.ligne"; |
80 |
$sql .= " AND s.fk_contrat = ".$this->contrat; |
$sql .= " AND s.fk_contrat = ".$this->contrat; |
81 |
|
|
82 |
$sql .= " GROUP BY date_format(td.date,'%Y%m') ASC "; |
$sql .= " GROUP BY ym ASC "; |
83 |
} |
} |
84 |
elseif ($this->client == 0 && $this->contrat == 0 && $this->ligne > 0) |
elseif ($this->client == 0 && $this->contrat == 0 && $this->ligne > 0) |
85 |
{ |
{ |
86 |
$sql .= " WHERE td.fk_ligne = ".$this->ligne; |
$sql .= " WHERE td.fk_ligne = ".$this->ligne; |
87 |
|
|
88 |
$sql .= " GROUP BY date_format(td.date,'%Y%m') ASC "; |
$sql .= " GROUP BY ym ASC "; |
89 |
} |
} |
90 |
|
|
91 |
if ($this->db->query($sql)) |
$resql = $this->db->query($sql); |
92 |
|
|
93 |
|
if ($resql) |
94 |
{ |
{ |
95 |
$num = $this->db->num_rows(); |
$num = $this->db->num_rows($resql); |
96 |
$i = 0; |
$i = 0; |
97 |
|
|
98 |
while ($i < $num) |
while ($i < $num) |
99 |
{ |
{ |
100 |
$row = $this->db->fetch_row(); |
$row = $this->db->fetch_row($resql); |
101 |
|
|
102 |
$this->labels[$i] = substr($row[0],4,2); |
$this->labels[$i] = substr($row[0],2,2); |
103 |
$this->datas[$i] = ceil($row[1] / 60); |
$this->datas[$i] = ceil($row[1] / 60); |
104 |
|
|
105 |
$i++; |
$i++; |
106 |
} |
} |
107 |
$this->db->free(); |
$this->db->free($resql); |
108 |
} |
} |
109 |
else |
else |
110 |
{ |
{ |