Bugfix
This commit is contained in:
parent
373c2dc3a5
commit
abf1bbf913
@ -26,10 +26,17 @@
|
|||||||
require ("../../master.inc.php");
|
require ("../../master.inc.php");
|
||||||
require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/ProcessGraphClients.class.php");
|
require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/ProcessGraphClients.class.php");
|
||||||
|
|
||||||
$childrenTotal = 10;
|
$childrenTotal = 5;
|
||||||
$childrenNow = 0;
|
$childrenNow = 0;
|
||||||
$clientPerChild = 0;
|
$clientPerChild = 0;
|
||||||
|
|
||||||
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."telephonie_client_stats";
|
||||||
|
|
||||||
|
if ($db->query($sql))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "SELECT max(s.idp)";
|
$sql = "SELECT max(s.idp)";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||||
|
|
||||||
|
|||||||
@ -80,17 +80,19 @@ class ProcessGraphClients
|
|||||||
$sql .= " AND s.idp < ".$max;
|
$sql .= " AND s.idp < ".$max;
|
||||||
$sql .= " GROUP BY s.idp";
|
$sql .= " GROUP BY s.idp";
|
||||||
|
|
||||||
if ($this->db->query($sql))
|
$resql = $this->db->query($sql);
|
||||||
|
|
||||||
|
if ($resql)
|
||||||
{
|
{
|
||||||
$clients = array();
|
$clients = array();
|
||||||
|
|
||||||
$num = $this->db->num_rows();
|
$num = $this->db->num_rows($resql);
|
||||||
print "$this->ident : $num client a traiter ($min - $max)\n";
|
print "$this->ident : $num client a traiter ($min - $max)\n";
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object();
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
$clients[$i] = $obj->socidp;
|
$clients[$i] = $obj->socidp;
|
||||||
|
|
||||||
@ -102,8 +104,6 @@ class ProcessGraphClients
|
|||||||
{
|
{
|
||||||
foreach ($clients as $client)
|
foreach ($clients as $client)
|
||||||
{
|
{
|
||||||
//print ".";
|
|
||||||
|
|
||||||
$img_root = DOL_DATA_ROOT."/graph/".substr($client,-1)."/telephonie/client/";
|
$img_root = DOL_DATA_ROOT."/graph/".substr($client,-1)."/telephonie/client/";
|
||||||
|
|
||||||
$file = $img_root . $client."/graphca.png";
|
$file = $img_root . $client."/graphca.png";
|
||||||
@ -118,6 +118,8 @@ class ProcessGraphClients
|
|||||||
$graphgain->show_console = 0 ;
|
$graphgain->show_console = 0 ;
|
||||||
$graphgain->GraphDraw();
|
$graphgain->GraphDraw();
|
||||||
|
|
||||||
|
$marge = 0;
|
||||||
|
|
||||||
if ($graphgain->total_cout > 0)
|
if ($graphgain->total_cout > 0)
|
||||||
{
|
{
|
||||||
$marge = ( $graphgain->total_gain / $graphgain->total_cout * 100);
|
$marge = ( $graphgain->total_gain / $graphgain->total_cout * 100);
|
||||||
@ -133,10 +135,10 @@ class ProcessGraphClients
|
|||||||
|
|
||||||
$file = $img_root . $client."/graphappelsdureemoyenne.png";
|
$file = $img_root . $client."/graphappelsdureemoyenne.png";
|
||||||
|
|
||||||
$graphgain = new GraphAppelsDureeMoyenne ($this->db, $file);
|
$graphduree = new GraphAppelsDureeMoyenne ($this->db, $file);
|
||||||
$graphgain->client = $client;
|
$graphduree->client = $client;
|
||||||
$graphgain->show_console = 0 ;
|
$graphduree->show_console = 0 ;
|
||||||
$graphgain->Graph();
|
$graphduree->Graph();
|
||||||
|
|
||||||
$file = $img_root . $client."/nb-comm-mensuel.png";
|
$file = $img_root . $client."/nb-comm-mensuel.png";
|
||||||
|
|
||||||
|
|||||||
@ -43,7 +43,7 @@ class GraphGain extends GraphBrouzouf{
|
|||||||
{
|
{
|
||||||
$num = 0;
|
$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";
|
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture as tf";
|
||||||
|
|
||||||
if ($this->client == 0 && $this->contrat == 0 && $this->ligne == 0)
|
if ($this->client == 0 && $this->contrat == 0 && $this->ligne == 0)
|
||||||
@ -76,30 +76,33 @@ class GraphGain extends GraphBrouzouf{
|
|||||||
$sql .= " GROUP BY tf.date ASC";
|
$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;
|
$i = 0;
|
||||||
$labels = array();
|
$labels = array();
|
||||||
|
|
||||||
$this->total_gain = 0;
|
$this->total_gain = 0;
|
||||||
|
$this->total_ca = 0;
|
||||||
|
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$row = $this->db->fetch_row();
|
$row = $this->db->fetch_row($resql);
|
||||||
|
|
||||||
$g[$i] = $row[1];
|
$g[$i] = $row[1];
|
||||||
|
|
||||||
$labels[$i] = substr($row[0],5,2)."/".substr($row[0],2,2);
|
$labels[$i] = substr($row[0],5,2)."/".substr($row[0],2,2);
|
||||||
|
|
||||||
$this->total_gain += $row[1];
|
$this->total_gain += $row[1];
|
||||||
|
$this->total_ca += $row[2];
|
||||||
|
$this->total_cout += $row[3];
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->free();
|
$this->db->free($resql);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -123,14 +126,16 @@ class GraphGain extends GraphBrouzouf{
|
|||||||
$sql .= " AND s.fk_client_comm = ".$this->client;
|
$sql .= " AND s.fk_client_comm = ".$this->client;
|
||||||
$sql .= " GROUP BY tf.fk_facture";
|
$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;
|
$i = 0;
|
||||||
|
|
||||||
while ($i < $numr)
|
while ($i < $numr)
|
||||||
{
|
{
|
||||||
$row = $this->db->fetch_row($i);
|
$row = $this->db->fetch_row($resql);
|
||||||
if ( $row[0] > 0)
|
if ( $row[0] > 0)
|
||||||
{
|
{
|
||||||
$this->total_gain = ($this->total_gain - $row[0]);
|
$this->total_gain = ($this->total_gain - $row[0]);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user