diff --git a/htdocs/telephonie/stats/ProcessGraphLignes.class.php b/htdocs/telephonie/stats/ProcessGraphLignes.class.php index 5c31598525e..4b154f7cb21 100644 --- a/htdocs/telephonie/stats/ProcessGraphLignes.class.php +++ b/htdocs/telephonie/stats/ProcessGraphLignes.class.php @@ -48,105 +48,128 @@ class ProcessGraphLignes { var $ident; - function ProcessGraphLignes( $ident , $cpc) + function ProcessGraphLignes( $db) { global $conf; $this->ident = $ident; $this->cpc = $cpc; - $this->db = new DoliDb($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,1); + + $this->db = $db; + $this->labels = array(); + $this->nbminutes = array(); + $this->nbcomm = array(); + $this->duree_moyenne = array(); + $this->vente = array(); + $this->gain = array(); } - function go() + function go($ligne) { - $min = $this->ident * $this->cpc; - $max = ($this->ident + 1 ) * $this->cpc; + dolibarr_syslog("Deb ligne ".$ligne); + + $this->ligne = $ligne; + $this->GetDatas(); - dolibarr_syslog("Deb ligne ".$this->ident . " ($min - $max)"); $error = 0; - /* - * 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"; + /* Chiffre d'affaire */ + + $img_root = DOL_DATA_ROOT."/graph/".substr($ligne,-1)."/telephonie/ligne/"; + + $file = $img_root . $ligne."/graphca.png"; + + $graphx = new GraphBar ($this->db, $file); + $graphx->ligne = $ligne; + $graphx->width = 360; + $graphx->titre = "Chiffre d'affaire (euros HT)"; + $graphx->barcolor = "blue"; + $graphx->show_console = 0 ; + $graphx->GraphDraw($file, $this->vente, $this->labels); + + + /* Gain */ + + $file = $img_root . $ligne."/graphgain.png"; + + $graphx = new GraphBar ($this->db, $file); + $graphx->ligne = $ligne; + $graphx->width = 360; + $graphx->titre = "Gain (euros HT)"; + $graphx->barcolor = "green"; + $graphx->show_console = 0 ; + $graphx->GraphDraw($file, $this->gain, $this->labels); + + /* Duree moyenne des appels */ + + $file = $img_root . $ligne."/graphappelsdureemoyenne.png"; + + $graphx = new GraphBar ($this->db, $file); + $graphx->ligne = $ligne; + $graphx->width = 360; + $graphx->titre = "Durée moyenne"; + $graphx->barcolor = "orange"; + $graphx->show_console = 0 ; + $graphx->GraphDraw($file, $this->duree_moyenne, $this->labels); + + /* Nb de communication */ + + $file = $img_root . $ligne."/nb-comm-mensuel.png"; + + $graphx = new GraphBar ($this->db, $file); + $graphx->ligne = $ligne; + $graphx->width = 360; + $graphx->titre = "Nombre de communications"; + $graphx->show_console = 0 ; + $graphx->GraphDraw($file, $this->nbcomm, $this->labels); + + /* Nb de minutes */ + + $file = $img_root . $ligne."/nb-minutes-mensuel.png"; + + $graphx = new GraphBar ($this->db, $file); + $graphx->ligne = $ligne; + $graphx->width = 360; + $graphx->show_console = 0 ; + $graphx->titre = "Nombre de minutes"; + $graphx->barcolor = "bisque2"; + $graphx->GraphDraw($file, $this->nbminutes, $this->labels); + } + + + Function GetDatas() + { + $sql = "SELECT date_format(td.date,'%m'), sum(duree), count(*), sum(cout_vente), sum(fourn_montant)"; + $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details as td"; + $sql .= " WHERE td.fk_ligne = ".$this->ligne; + $sql .= " GROUP BY date_format(td.date,'%Y%m') ASC "; if ($this->db->query($sql)) { - $lignes = array(); - $num = $this->db->num_rows(); $i = 0; - + while ($i < $num) { - $obj = $this->db->fetch_object(); + $row = $this->db->fetch_row(); - $lignes[$i] = $obj->rowid; + $this->labels[$i] = $row[0]; + + $this->nbminutes[$i] = ceil($row[1] / 60); + $this->nbcomm[$i] = $row[2]; + $this->duree_moyenne[$i] = ($this->nbminutes[$i] / $this->nbcomm[$i]); + $this->vente[$i] = $row[3]; + $this->gain[$i] = ($row[3] - $row[4]); $i++; - } + } + $this->db->free(); } - - if (sizeof($lignes)) + else { - foreach ($lignes as $ligne) - { - /* Chiffre d'affaire */ - - $img_root = DOL_DATA_ROOT."/graph/".substr($ligne,-1)."/telephonie/ligne/"; - - $file = $img_root . $ligne."/graphca.png"; - $graphca = new GraphCa($this->db, $file); - $graphca->ligne = $ligne; - $graphca->GraphDraw(); - - /* Gain */ - - $file = $img_root . $ligne."/graphgain.png"; - - $graphgain = new GraphGain ($this->db, $file); - $graphgain->ligne = $ligne; - $graphgain->show_console = 0 ; - $graphgain->GraphDraw(); - - /* Duree moyenne des appels */ - - $file = $img_root . $ligne."/graphappelsdureemoyenne.png"; - - $graphduree = new GraphAppelsDureeMoyenne ($this->db, $file); - $graphduree->ligne = $ligne; - $graphduree->width = 360; - $graphduree->show_console = 0 ; - $graphduree->Graph(); - - /* Nb de communication */ - - $file = $img_root . $ligne."/nb-comm-mensuel.png"; - - $graphx = new GraphCommNbMensuel ($this->db, $file); - $graphx->ligne = $ligne; - $graphx->width = 360; - $graphx->show_console = 0 ; - $graphx->Graph(); - - /* Nb de minutes */ - - $file = $img_root . $ligne."/nb-minutes-mensuel.png"; - - $graphx = new GraphCommNbMinutes ($this->db, $file); - $graphx->ligne = $ligne; - $graphx->width = 360; - $graphx->show_console = 0 ; - $graphx->Graph(); - } + dolibarr_syslog("Error"); } - - dolibarr_syslog("Fin ligne ".$this->ident); } + } ?> diff --git a/htdocs/telephonie/stats/clients/index.php b/htdocs/telephonie/stats/clients/index.php index f94d8674440..d9039e94eaf 100644 --- a/htdocs/telephonie/stats/clients/index.php +++ b/htdocs/telephonie/stats/clients/index.php @@ -21,8 +21,8 @@ */ require("./pre.inc.php"); -if (!$user->rights->telephonie->lire) - accessforbidden(); +if (!$user->rights->telephonie->lire) accessforbidden(); +if (!$user->rights->telephonie->stats->lire) accessforbidden(); llxHeader('','Telephonie - Statistiques - Clients'); diff --git a/htdocs/telephonie/stats/commerciaux/index.php b/htdocs/telephonie/stats/commerciaux/index.php index c1ce7ad9037..4f425b6e1f9 100644 --- a/htdocs/telephonie/stats/commerciaux/index.php +++ b/htdocs/telephonie/stats/commerciaux/index.php @@ -22,6 +22,7 @@ require("./pre.inc.php"); if (!$user->rights->telephonie->lire) accessforbidden(); +if (!$user->rights->telephonie->stats->lire) accessforbidden(); llxHeader('','Telephonie - Statistiques - Commerciaux'); diff --git a/htdocs/telephonie/stats/communications/index.php b/htdocs/telephonie/stats/communications/index.php index 1e207cda604..3749cef2d54 100644 --- a/htdocs/telephonie/stats/communications/index.php +++ b/htdocs/telephonie/stats/communications/index.php @@ -21,11 +21,8 @@ */ require("./pre.inc.php"); -$page = $_GET["page"]; -$sortorder = $_GET["sortorder"]; - -if (!$user->rights->telephonie->lire) - accessforbidden(); +if (!$user->rights->telephonie->lire) accessforbidden(); +if (!$user->rights->telephonie->stats->lire) accessforbidden(); llxHeader('','Telephonie - Statistiques'); /* diff --git a/htdocs/telephonie/stats/contrats/index.php b/htdocs/telephonie/stats/contrats/index.php index db2e2235def..31e25802500 100644 --- a/htdocs/telephonie/stats/contrats/index.php +++ b/htdocs/telephonie/stats/contrats/index.php @@ -22,6 +22,7 @@ require("./pre.inc.php"); if (!$user->rights->telephonie->lire) accessforbidden(); +if (!$user->rights->telephonie->stats->lire) accessforbidden(); llxHeader('','Telephonie - Statistiques - Contrats'); diff --git a/htdocs/telephonie/stats/destinations/index.php b/htdocs/telephonie/stats/destinations/index.php index e7c70a5453d..17e5c738728 100644 --- a/htdocs/telephonie/stats/destinations/index.php +++ b/htdocs/telephonie/stats/destinations/index.php @@ -25,6 +25,7 @@ $page = $_GET["page"]; $sortorder = $_GET["sortorder"]; if (!$user->rights->telephonie->lire) accessforbidden(); +if (!$user->rights->telephonie->stats->lire) accessforbidden(); llxHeader('','Telephonie - Statistiques'); diff --git a/htdocs/telephonie/stats/distributeurs/index.php b/htdocs/telephonie/stats/distributeurs/index.php index 8cc12318da8..9814de26dad 100644 --- a/htdocs/telephonie/stats/distributeurs/index.php +++ b/htdocs/telephonie/stats/distributeurs/index.php @@ -22,6 +22,7 @@ require("./pre.inc.php"); if (!$user->rights->telephonie->lire) accessforbidden(); +if (!$user->rights->telephonie->stats->lire) accessforbidden(); llxHeader('','Telephonie - Statistiques - Distributeurs'); diff --git a/htdocs/telephonie/stats/factures/index.php b/htdocs/telephonie/stats/factures/index.php index f099ef758b3..15a31c16a86 100644 --- a/htdocs/telephonie/stats/factures/index.php +++ b/htdocs/telephonie/stats/factures/index.php @@ -21,11 +21,8 @@ */ require("./pre.inc.php"); -$page = $_GET["page"]; -$sortorder = $_GET["sortorder"]; - -if (!$user->rights->telephonie->lire) - accessforbidden(); +if (!$user->rights->telephonie->lire) accessforbidden(); +if (!$user->rights->telephonie->stats->lire) accessforbidden(); llxHeader('','Telephonie - Ligne'); diff --git a/htdocs/telephonie/stats/fournisseurs/index.php b/htdocs/telephonie/stats/fournisseurs/index.php index d9cbc3bfeae..988c3d50fd6 100644 --- a/htdocs/telephonie/stats/fournisseurs/index.php +++ b/htdocs/telephonie/stats/fournisseurs/index.php @@ -21,11 +21,8 @@ */ require("./pre.inc.php"); -$page = $_GET["page"]; -$sortorder = $_GET["sortorder"]; - -if (!$user->rights->telephonie->lire) - accessforbidden(); +if (!$user->rights->telephonie->lire) accessforbidden(); +if (!$user->rights->telephonie->stats->lire) accessforbidden(); llxHeader('','Telephonie - Statistiques'); /* diff --git a/htdocs/telephonie/stats/graph/bar.class.php b/htdocs/telephonie/stats/graph/bar.class.php index 6316ae329ab..b6b24893cd3 100644 --- a/htdocs/telephonie/stats/graph/bar.class.php +++ b/htdocs/telephonie/stats/graph/bar.class.php @@ -71,7 +71,7 @@ class GraphBar extends DolibarrGraph { $graph->xaxis->scale->SetGrace(20); - $LabelAngle = 45; + $LabelAngle = 0; if ($this->LabelAngle <> $LabelAngle && strlen($this->LabelAngle) > 0) $LabelAngle = $this->LabelAngle; @@ -84,7 +84,7 @@ class GraphBar extends DolibarrGraph { $graph->title->Set($this->titre); - $graph->title->SetFont(FF_VERDANA,FS_NORMAL); + //$graph->title->SetFont(FF_VERDANA,FS_NORMAL); $graph->xaxis->SetTickLabels($labels); diff --git a/htdocs/telephonie/stats/graph/baraccumul.class.php b/htdocs/telephonie/stats/graph/baraccumul.class.php index 0b6934eb1db..ce38350d325 100644 --- a/htdocs/telephonie/stats/graph/baraccumul.class.php +++ b/htdocs/telephonie/stats/graph/baraccumul.class.php @@ -114,7 +114,6 @@ class GraphBarAccumul extends DolibarrGraph { { $b1plot = new BarPlot($this->datas[$j][$i]); $b1plot->SetFillColor($this->datas_color[$j][$i]); - $b1plot->SetLegend($this->legend[$j][$i]); diff --git a/htdocs/telephonie/stats/index.php b/htdocs/telephonie/stats/index.php index cf43357e21b..d74376ba069 100644 --- a/htdocs/telephonie/stats/index.php +++ b/htdocs/telephonie/stats/index.php @@ -22,6 +22,7 @@ require("./pre.inc.php"); if (!$user->rights->telephonie->lire) accessforbidden(); +if (!$user->rights->telephonie->stats->lire) accessforbidden(); llxHeader('','Telephonie - Statistiques'); diff --git a/htdocs/telephonie/stats/lignes/index.php b/htdocs/telephonie/stats/lignes/index.php index 67e92b03c2b..42723d71661 100644 --- a/htdocs/telephonie/stats/lignes/index.php +++ b/htdocs/telephonie/stats/lignes/index.php @@ -22,6 +22,7 @@ require("./pre.inc.php"); if (!$user->rights->telephonie->lire) accessforbidden(); +if (!$user->rights->telephonie->stats->lire) accessforbidden(); llxHeader('','Telephonie - Statistiques - Lignes');