48 |
{ |
{ |
49 |
var $ident; |
var $ident; |
50 |
|
|
51 |
function ProcessGraphLignes( $ident , $cpc) |
function ProcessGraphLignes( $db) |
52 |
{ |
{ |
53 |
global $conf; |
global $conf; |
54 |
|
|
55 |
$this->ident = $ident; |
$this->ident = $ident; |
56 |
$this->cpc = $cpc; |
$this->cpc = $cpc; |
57 |
$this->db = new DoliDb($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,1); |
|
58 |
|
$this->db = $db; |
59 |
|
$this->labels = array(); |
60 |
|
$this->nbminutes = array(); |
61 |
|
$this->nbcomm = array(); |
62 |
|
$this->duree_moyenne = array(); |
63 |
|
$this->vente = array(); |
64 |
|
$this->gain = array(); |
65 |
} |
} |
66 |
|
|
67 |
function go() |
function go($ligne) |
68 |
{ |
{ |
69 |
$min = $this->ident * $this->cpc; |
dolibarr_syslog("Deb ligne ".$ligne); |
70 |
$max = ($this->ident + 1 ) * $this->cpc; |
|
71 |
|
$this->ligne = $ligne; |
72 |
|
$this->GetDatas(); |
73 |
|
|
|
dolibarr_syslog("Deb ligne ".$this->ident . " ($min - $max)"); |
|
74 |
$error = 0; |
$error = 0; |
75 |
|
|
76 |
/* |
/* Chiffre d'affaire */ |
|
* Lecture des lignes |
|
|
* |
|
|
*/ |
|
|
$sql = "SELECT l.rowid"; |
|
|
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne as l"; |
|
|
$sql .= " WHERE l.rowid >= ".$min; |
|
|
$sql .= " AND l.rowid < ".$max; |
|
|
$sql .= " ORDER BY l.rowid ASC"; |
|
77 |
|
|
78 |
if ($this->db->query($sql)) |
$img_root = DOL_DATA_ROOT."/graph/".substr($ligne,-1)."/telephonie/ligne/"; |
|
{ |
|
|
$lignes = array(); |
|
|
|
|
|
$num = $this->db->num_rows(); |
|
|
$i = 0; |
|
|
|
|
|
while ($i < $num) |
|
|
{ |
|
|
$obj = $this->db->fetch_object(); |
|
|
|
|
|
$lignes[$i] = $obj->rowid; |
|
|
|
|
|
$i++; |
|
|
} |
|
|
} |
|
79 |
|
|
80 |
if (sizeof($lignes)) |
$file = $img_root . $ligne."/graphca.png"; |
|
{ |
|
|
foreach ($lignes as $ligne) |
|
|
{ |
|
|
/* Chiffre d'affaire */ |
|
|
|
|
|
$img_root = DOL_DATA_ROOT."/graph/".substr($ligne,-1)."/telephonie/ligne/"; |
|
81 |
|
|
82 |
$file = $img_root . $ligne."/graphca.png"; |
$graphx = new GraphBar ($this->db, $file); |
83 |
$graphca = new GraphCa($this->db, $file); |
$graphx->ligne = $ligne; |
84 |
$graphca->ligne = $ligne; |
$graphx->width = 360; |
85 |
$graphca->GraphDraw(); |
$graphx->titre = "Chiffre d'affaire (euros HT)"; |
86 |
|
$graphx->barcolor = "blue"; |
87 |
|
$graphx->show_console = 0 ; |
88 |
|
$graphx->GraphDraw($file, $this->vente, $this->labels); |
89 |
|
|
|
/* Gain */ |
|
90 |
|
|
91 |
$file = $img_root . $ligne."/graphgain.png"; |
/* Gain */ |
92 |
|
|
93 |
$graphgain = new GraphGain ($this->db, $file); |
$file = $img_root . $ligne."/graphgain.png"; |
94 |
$graphgain->ligne = $ligne; |
|
95 |
$graphgain->show_console = 0 ; |
$graphx = new GraphBar ($this->db, $file); |
96 |
$graphgain->GraphDraw(); |
$graphx->ligne = $ligne; |
97 |
|
$graphx->width = 360; |
98 |
|
$graphx->titre = "Gain (euros HT)"; |
99 |
|
$graphx->barcolor = "green"; |
100 |
|
$graphx->show_console = 0 ; |
101 |
|
$graphx->GraphDraw($file, $this->gain, $this->labels); |
102 |
|
|
103 |
/* Duree moyenne des appels */ |
/* Duree moyenne des appels */ |
104 |
|
|
105 |
|
$file = $img_root . $ligne."/graphappelsdureemoyenne.png"; |
106 |
|
|
107 |
|
$graphx = new GraphBar ($this->db, $file); |
108 |
|
$graphx->ligne = $ligne; |
109 |
|
$graphx->width = 360; |
110 |
|
$graphx->titre = "Durée moyenne"; |
111 |
|
$graphx->barcolor = "orange"; |
112 |
|
$graphx->show_console = 0 ; |
113 |
|
$graphx->GraphDraw($file, $this->duree_moyenne, $this->labels); |
114 |
|
|
115 |
$file = $img_root . $ligne."/graphappelsdureemoyenne.png"; |
/* Nb de communication */ |
116 |
|
|
117 |
$graphduree = new GraphAppelsDureeMoyenne ($this->db, $file); |
$file = $img_root . $ligne."/nb-comm-mensuel.png"; |
|
$graphduree->ligne = $ligne; |
|
|
$graphduree->width = 360; |
|
|
$graphduree->show_console = 0 ; |
|
|
$graphduree->Graph(); |
|
|
|
|
|
/* Nb de communication */ |
|
118 |
|
|
119 |
$file = $img_root . $ligne."/nb-comm-mensuel.png"; |
$graphx = new GraphBar ($this->db, $file); |
120 |
|
$graphx->ligne = $ligne; |
121 |
$graphx = new GraphCommNbMensuel ($this->db, $file); |
$graphx->width = 360; |
122 |
$graphx->ligne = $ligne; |
$graphx->titre = "Nombre de communications"; |
123 |
$graphx->width = 360; |
$graphx->show_console = 0 ; |
124 |
$graphx->show_console = 0 ; |
$graphx->GraphDraw($file, $this->nbcomm, $this->labels); |
125 |
$graphx->Graph(); |
|
126 |
|
/* Nb de minutes */ |
127 |
|
|
128 |
|
$file = $img_root . $ligne."/nb-minutes-mensuel.png"; |
129 |
|
|
130 |
|
$graphx = new GraphBar ($this->db, $file); |
131 |
|
$graphx->ligne = $ligne; |
132 |
|
$graphx->width = 360; |
133 |
|
$graphx->show_console = 0 ; |
134 |
|
$graphx->titre = "Nombre de minutes"; |
135 |
|
$graphx->barcolor = "bisque2"; |
136 |
|
$graphx->GraphDraw($file, $this->nbminutes, $this->labels); |
137 |
|
} |
138 |
|
|
|
/* Nb de minutes */ |
|
139 |
|
|
140 |
$file = $img_root . $ligne."/nb-minutes-mensuel.png"; |
Function GetDatas() |
141 |
|
{ |
142 |
|
$sql = "SELECT date_format(td.date,'%m'), sum(duree), count(*), sum(cout_vente), sum(fourn_montant)"; |
143 |
|
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details as td"; |
144 |
|
$sql .= " WHERE td.fk_ligne = ".$this->ligne; |
145 |
|
$sql .= " GROUP BY date_format(td.date,'%Y%m') ASC "; |
146 |
|
|
147 |
|
if ($this->db->query($sql)) |
148 |
|
{ |
149 |
|
$num = $this->db->num_rows(); |
150 |
|
$i = 0; |
151 |
|
|
152 |
|
while ($i < $num) |
153 |
|
{ |
154 |
|
$row = $this->db->fetch_row(); |
155 |
|
|
156 |
|
$this->labels[$i] = $row[0]; |
157 |
|
|
158 |
|
$this->nbminutes[$i] = ceil($row[1] / 60); |
159 |
|
$this->nbcomm[$i] = $row[2]; |
160 |
|
$this->duree_moyenne[$i] = ($this->nbminutes[$i] / $this->nbcomm[$i]); |
161 |
|
$this->vente[$i] = $row[3]; |
162 |
|
$this->gain[$i] = ($row[3] - $row[4]); |
163 |
|
|
164 |
$graphx = new GraphCommNbMinutes ($this->db, $file); |
$i++; |
165 |
$graphx->ligne = $ligne; |
} |
166 |
$graphx->width = 360; |
$this->db->free(); |
167 |
$graphx->show_console = 0 ; |
} |
168 |
$graphx->Graph(); |
else |
169 |
} |
{ |
170 |
|
dolibarr_syslog("Error"); |
171 |
} |
} |
|
|
|
|
dolibarr_syslog("Fin ligne ".$this->ident); |
|
172 |
} |
} |
173 |
|
|
174 |
} |
} |
175 |
?> |
?> |