diff --git a/htdocs/telephonie/script/graph-statistiques-clients.php b/htdocs/telephonie/script/graph-statistiques-clients.php index f085aa81df6..c9b0933321e 100644 --- a/htdocs/telephonie/script/graph-statistiques-clients.php +++ b/htdocs/telephonie/script/graph-statistiques-clients.php @@ -26,10 +26,17 @@ require ("../../master.inc.php"); require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/ProcessGraphClients.class.php"); -$childrenTotal = 10; +$childrenTotal = 5; $childrenNow = 0; $clientPerChild = 0; +$sql = "DELETE FROM ".MAIN_DB_PREFIX."telephonie_client_stats"; + +if ($db->query($sql)) +{ + +} + $sql = "SELECT max(s.idp)"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; diff --git a/htdocs/telephonie/stats/ProcessGraphClients.class.php b/htdocs/telephonie/stats/ProcessGraphClients.class.php index bb8fe39e77a..096085383ff 100644 --- a/htdocs/telephonie/stats/ProcessGraphClients.class.php +++ b/htdocs/telephonie/stats/ProcessGraphClients.class.php @@ -79,18 +79,20 @@ class ProcessGraphClients $sql .= " AND s.idp >= ".$min; $sql .= " AND s.idp < ".$max; $sql .= " GROUP BY s.idp"; + + $resql = $this->db->query($sql); - if ($this->db->query($sql)) + if ($resql) { $clients = array(); - $num = $this->db->num_rows(); + $num = $this->db->num_rows($resql); print "$this->ident : $num client a traiter ($min - $max)\n"; $i = 0; while ($i < $num) { - $obj = $this->db->fetch_object(); + $obj = $this->db->fetch_object($resql); $clients[$i] = $obj->socidp; @@ -102,8 +104,6 @@ class ProcessGraphClients { foreach ($clients as $client) { - //print "."; - $img_root = DOL_DATA_ROOT."/graph/".substr($client,-1)."/telephonie/client/"; $file = $img_root . $client."/graphca.png"; @@ -118,6 +118,8 @@ class ProcessGraphClients $graphgain->show_console = 0 ; $graphgain->GraphDraw(); + $marge = 0; + if ($graphgain->total_cout > 0) { $marge = ( $graphgain->total_gain / $graphgain->total_cout * 100); @@ -133,10 +135,10 @@ class ProcessGraphClients $file = $img_root . $client."/graphappelsdureemoyenne.png"; - $graphgain = new GraphAppelsDureeMoyenne ($this->db, $file); - $graphgain->client = $client; - $graphgain->show_console = 0 ; - $graphgain->Graph(); + $graphduree = new GraphAppelsDureeMoyenne ($this->db, $file); + $graphduree->client = $client; + $graphduree->show_console = 0 ; + $graphduree->Graph(); $file = $img_root . $client."/nb-comm-mensuel.png"; diff --git a/htdocs/telephonie/stats/graph/gain.class.php b/htdocs/telephonie/stats/graph/gain.class.php index df4a50462f1..bed8951d53b 100644 --- a/htdocs/telephonie/stats/graph/gain.class.php +++ b/htdocs/telephonie/stats/graph/gain.class.php @@ -43,7 +43,7 @@ class GraphGain extends GraphBrouzouf{ { $num = 0; - $sql = "SELECT tf.date, sum(tf.gain)"; + $sql = "SELECT tf.date, sum(tf.gain), sum(tf.cout_vente), sum(tf.fourn_montant)"; $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture as tf"; if ($this->client == 0 && $this->contrat == 0 && $this->ligne == 0) @@ -76,30 +76,33 @@ class GraphGain extends GraphBrouzouf{ $sql .= " GROUP BY tf.date ASC"; } - $result = $this->db->query($sql); + $resql = $this->db->query($sql); - if ($result) + if ($resql) { - $num = $this->db->num_rows(); + $num = $this->db->num_rows($resql); $i = 0; $labels = array(); $this->total_gain = 0; + $this->total_ca = 0; while ($i < $num) { - $row = $this->db->fetch_row(); + $row = $this->db->fetch_row($resql); $g[$i] = $row[1]; $labels[$i] = substr($row[0],5,2)."/".substr($row[0],2,2); $this->total_gain += $row[1]; + $this->total_ca += $row[2]; + $this->total_cout += $row[3]; $i++; } - $this->db->free(); + $this->db->free($resql); } else { @@ -123,14 +126,16 @@ class GraphGain extends GraphBrouzouf{ $sql .= " AND s.fk_client_comm = ".$this->client; $sql .= " GROUP BY tf.fk_facture"; - if ($this->db->query($sql)) + $resql = $this->db->query($sql); + + if ($resql) { - $numr = $this->db->num_rows(); + $numr = $this->db->num_rows($resql); $i = 0; while ($i < $numr) { - $row = $this->db->fetch_row($i); + $row = $this->db->fetch_row($resql); if ( $row[0] > 0) { $this->total_gain = ($this->total_gain - $row[0]);