diff --git a/htdocs/telephonie/script/graph-statistiques.php b/htdocs/telephonie/script/graph-statistiques.php index 7fc47433488..9e29902cabe 100644 --- a/htdocs/telephonie/script/graph-statistiques.php +++ b/htdocs/telephonie/script/graph-statistiques.php @@ -150,45 +150,15 @@ $graphgain->GraphDraw(); /* /*************************************************************************/ -$sql = "SELECT ".$db->pdate("date")." as date, duree"; -$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details"; - -if ($db->query($sql)) -{ - $heure_appel = array(); - $jour_semaine_nb = array(); - $jour_semaine_duree = array(); - - $num = $db->num_rows(); - if ($verbose) print "$num lignes de comm a traiter\n"; - $i = 0; - - while ($i < $num) - { - $obj = $db->fetch_object(); - - $h = strftime("%H",$obj->date) * 1; // suppression du 0 - - $heure_appel_nb[$h]++; - $heure_appel_duree[$h] += $obj->duree; - - $u = strftime("%u",$obj->date) - 1; // 1 pour Lundi - - $jour_semaine_nb[$u]++; - $jour_semaine_duree[$u] += $obj->duree; - - $i++; - } -} - $file = $img_root . "communications/heure_appel_nb.png"; if ($verbose) print "Heures d'appels\n"; $graphha = new GraphHeureAppel ($db, $file); -$graphha->GraphDraw($heure_appel_nb); +$graphha->GraphDraw(); $file = $img_root . "communications/joursemaine_nb.png"; +if ($verbose) print "Jours de semaines\n"; $graphha = new GraphJourSemaine ($db, $file); -$graphha->GraphDraw($jour_semaine_nb); +$graphha->GraphDraw(); repart_comm($db); diff --git a/htdocs/telephonie/stats/graph/heureappel.class.php b/htdocs/telephonie/stats/graph/heureappel.class.php index ed7db7b5592..b41da384880 100644 --- a/htdocs/telephonie/stats/graph/heureappel.class.php +++ b/htdocs/telephonie/stats/graph/heureappel.class.php @@ -22,9 +22,8 @@ require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/brouzouf.class.php"); -class GraphHeureAppel extends GraphBrouzouf{ - - +class GraphHeureAppel extends GraphBrouzouf +{ Function GraphHeureAppel($DB, $file) { $this->db = $DB; @@ -41,7 +40,33 @@ class GraphHeureAppel extends GraphBrouzouf{ Function GraphDraw($g) { - $this->GraphMakeGraph($g, $labels); + + $sql = "SELECT ".$this->db->pdate("date")." as date, duree"; + $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details"; + + if ($this->db->query($sql)) + { + $heure_appel = array(); + $num = $this->db->num_rows(); + $i = 0; + + while ($i < $num) + { + $obj = $this->db->fetch_object(); + + $h = ceil(strftime("%H",$obj->date)); // suppression du 0 + + $heure_appel_nb[$h]++; + $heure_appel_duree[$h] += $obj->duree; + + $i++; + } + } + + if ($num > 0) + { + $this->GraphMakeGraph($heure_appel_nb, $labels); + } } } diff --git a/htdocs/telephonie/stats/graph/joursemaine.class.php b/htdocs/telephonie/stats/graph/joursemaine.class.php index e375f11990c..27af98eb04b 100644 --- a/htdocs/telephonie/stats/graph/joursemaine.class.php +++ b/htdocs/telephonie/stats/graph/joursemaine.class.php @@ -39,10 +39,8 @@ class GraphJoursemaine extends GraphBrouzouf{ $this->barcolor = "green"; } - Function GraphDraw($g) + Function GraphDraw() { - - $sql = "SELECT ".$this->db->pdate("date")." as date, duree"; $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details"; @@ -68,8 +66,11 @@ class GraphJoursemaine extends GraphBrouzouf{ $i++; } } - - $this->GraphMakeGraph($jour_semaine_nb,array('Lun','Mar','Mer','Jeu','Ven','Sam','Dim')); + + if ($num > 0) + { + $this->GraphMakeGraph($jour_semaine_nb,array('Lun','Mar','Mer','Jeu','Ven','Sam','Dim')); + } } }