Nouvelle version qui fork
This commit is contained in:
parent
cefdd99ed1
commit
7cee478508
@ -1,4 +1,4 @@
|
|||||||
<?PHP
|
<?php
|
||||||
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -22,7 +22,6 @@
|
|||||||
* Generation des graphiques clients
|
* Generation des graphiques clients
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
require ("../../master.inc.php");
|
require ("../../master.inc.php");
|
||||||
|
|
||||||
@ -39,98 +38,150 @@ require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/camoyen.class.php");
|
|||||||
require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/appelsdureemoyenne.class.php");
|
require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/appelsdureemoyenne.class.php");
|
||||||
require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/comm.nbmensuel.class.php");
|
require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/comm.nbmensuel.class.php");
|
||||||
|
|
||||||
//require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/montant.class.php");
|
|
||||||
require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/camenbert.class.php");
|
require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/graph/camenbert.class.php");
|
||||||
|
|
||||||
$error = 0;
|
$childrenTotal = 10;
|
||||||
|
$childrenNow = 0;
|
||||||
|
$clientPerChild = 0;
|
||||||
|
|
||||||
$img_root = DOL_DATA_ROOT."/graph/telephonie/";
|
$sql = "SELECT max(s.idp)";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||||
/***********************************************************************/
|
|
||||||
/*
|
|
||||||
/* Chiffre d'affaire mensuel par client
|
|
||||||
/*
|
|
||||||
/***********************************************************************/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Lecture des clients
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
$sql = "SELECT s.idp as socidp, s.nom, count(l.ligne) as ligne";
|
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."telephonie_societe_ligne as l";
|
|
||||||
$sql .= " WHERE l.fk_client_comm = s.idp ";
|
|
||||||
$sql .= " GROUP BY s.idp";
|
|
||||||
|
|
||||||
if ($db->query($sql))
|
if ($db->query($sql))
|
||||||
{
|
{
|
||||||
|
$row = $db->fetch_row();
|
||||||
|
$clientPerChild = ceil($row[0] / $childrenTotal);
|
||||||
|
$db->free();
|
||||||
|
}
|
||||||
|
|
||||||
$clients = array();
|
while ( $childrenNow < $childrenTotal )
|
||||||
|
{
|
||||||
|
|
||||||
$num = $db->num_rows();
|
$pid = pcntl_fork();
|
||||||
print "$num client a traiter\n";
|
|
||||||
$i = 0;
|
|
||||||
|
|
||||||
while ($i < $num)
|
if ( $pid == -1 )
|
||||||
{
|
{
|
||||||
$obj = $db->fetch_object();
|
die( "error\n" );
|
||||||
|
}
|
||||||
$dir = $img_root . "client/".substr($obj->socidp,0,1)."/".$obj->socidp."/";
|
elseif ( $pid == 0 )
|
||||||
|
{
|
||||||
$clients[$i] = $obj->socidp;
|
$childrenNow++;
|
||||||
|
}
|
||||||
$i++;
|
else
|
||||||
|
{
|
||||||
|
$process = new Process( $childrenNow, $clientPerChild );
|
||||||
|
$process->go();
|
||||||
|
die();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."telephonie_client_stats";
|
/*
|
||||||
$db->query($sql);
|
* Process
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
foreach ($clients as $client)
|
class Process
|
||||||
{
|
{
|
||||||
print ".";
|
var $ident;
|
||||||
|
|
||||||
|
function Process( $ident , $cpc)
|
||||||
|
{
|
||||||
|
$this->ident = $ident;
|
||||||
|
$this->cpc = $cpc;
|
||||||
|
$this->db = new DoliDb('','','','','',1);
|
||||||
|
}
|
||||||
|
|
||||||
$file = $img_root . "client/".substr($client,0,1)."/".$client."/graphca.png";
|
function go()
|
||||||
$graphca = new GraphCa($db, $file);
|
{
|
||||||
$graphca->client = $client;
|
dolibarr_syslog("Debut client ".$this->ident);
|
||||||
$graphca->GraphDraw();
|
$error = 0;
|
||||||
|
|
||||||
|
$img_root = DOL_DATA_ROOT."/graph/telephonie/";
|
||||||
|
|
||||||
|
$min = $this->ident * $this->cpc;
|
||||||
|
$max = ($this->ident + 1 ) * $this->cpc;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Lecture des clients
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
$sql = "SELECT s.idp as socidp, s.nom, count(l.ligne) as ligne";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
||||||
|
$sql .= ",".MAIN_DB_PREFIX."telephonie_societe_ligne as l";
|
||||||
|
$sql .= " WHERE l.fk_client_comm = s.idp ";
|
||||||
|
$sql .= " AND s.idp >= ".$min;
|
||||||
|
$sql .= " AND s.idp < ".$max;
|
||||||
|
$sql .= " GROUP BY s.idp";
|
||||||
|
|
||||||
|
if ($this->db->query($sql))
|
||||||
|
{
|
||||||
|
$clients = array();
|
||||||
|
|
||||||
|
$num = $this->db->num_rows();
|
||||||
|
print "$this->ident : $num client a traiter ($min - $max)\n";
|
||||||
|
$i = 0;
|
||||||
|
|
||||||
|
while ($i < $num)
|
||||||
|
{
|
||||||
|
$obj = $this->db->fetch_object();
|
||||||
|
|
||||||
|
$dir = $img_root . "client/".substr($obj->socidp,0,1)."/".$obj->socidp."/";
|
||||||
|
|
||||||
|
$clients[$i] = $obj->socidp;
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sizeof($clients))
|
||||||
|
{
|
||||||
|
foreach ($clients as $client)
|
||||||
|
{
|
||||||
|
//print ".";
|
||||||
|
|
||||||
|
$file = $img_root . "client/".substr($client,0,1)."/".$client."/graphca.png";
|
||||||
|
$graphca = new GraphCa($this->db, $file);
|
||||||
|
$graphca->client = $client;
|
||||||
|
$graphca->GraphDraw();
|
||||||
|
|
||||||
$file = $img_root . "client/".substr($client,0,1)."/".$client."/graphgain.png";
|
$file = $img_root . "client/".substr($client,0,1)."/".$client."/graphgain.png";
|
||||||
$file = "/dev/null";
|
|
||||||
$graphgain = new GraphGain ($db, $file);
|
|
||||||
$graphgain->client = $client;
|
|
||||||
$graphgain->show_console = 0 ;
|
|
||||||
$graphgain->GraphDraw();
|
|
||||||
|
|
||||||
if ($graphgain->total_cout > 0)
|
$graphgain = new GraphGain ($this->db, $file);
|
||||||
{
|
$graphgain->client = $client;
|
||||||
$marge = ( $graphgain->total_gain / $graphgain->total_cout * 100);
|
$graphgain->show_console = 0 ;
|
||||||
}
|
$graphgain->GraphDraw();
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_client_stats (fk_client_comm, gain, ca, cout, marge)";
|
if ($graphgain->total_cout > 0)
|
||||||
$sql .= " VALUES (".$client.",'".ereg_replace(",",".",$graphgain->total_gain)."'";
|
{
|
||||||
$sql .= ",'".ereg_replace(",",".",$graphgain->total_ca)."'";
|
$marge = ( $graphgain->total_gain / $graphgain->total_cout * 100);
|
||||||
$sql .= ",'".ereg_replace(",",".",$graphgain->total_cout)."'";
|
}
|
||||||
$sql .= ",'".ereg_replace(",",".",$marge)."')";
|
|
||||||
$db->query($sql);
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_client_stats (fk_client_comm, gain, ca, cout, marge)";
|
||||||
|
$sql .= " VALUES (".$client.",'".ereg_replace(",",".",$graphgain->total_gain)."'";
|
||||||
|
$sql .= ",'".ereg_replace(",",".",$graphgain->total_ca)."'";
|
||||||
|
$sql .= ",'".ereg_replace(",",".",$graphgain->total_cout)."'";
|
||||||
|
$sql .= ",'".ereg_replace(",",".",$marge)."')";
|
||||||
|
$this->db->query($sql);
|
||||||
|
|
||||||
|
|
||||||
$file = $img_root . "client/".substr($client,0,1)."/".$client."/graphappelsdureemoyenne.png";
|
$file = $img_root . "client/".substr($client,0,1)."/".$client."/graphappelsdureemoyenne.png";
|
||||||
|
|
||||||
$graphgain = new GraphAppelsDureeMoyenne ($db, $file);
|
$graphgain = new GraphAppelsDureeMoyenne ($this->db, $file);
|
||||||
$graphgain->client = $client;
|
$graphgain->client = $client;
|
||||||
$graphgain->show_console = 0 ;
|
$graphgain->show_console = 0 ;
|
||||||
$graphgain->GraphDraw();
|
$graphgain->GraphDraw();
|
||||||
|
|
||||||
$file = $img_root . "client/".substr($client,0,1)."/".$client."/nb-comm-mensuel.png";
|
$file = $img_root . "client/".substr($client,0,1)."/".$client."/nb-comm-mensuel.png";
|
||||||
|
|
||||||
$graphx = new GraphCommNbMensuel ($db, $file);
|
$graphx = new GraphCommNbMensuel ($this->db, $file);
|
||||||
$graphx->client = $client;
|
$graphx->client = $client;
|
||||||
$graphx->show_console = 0 ;
|
$graphx->show_console = 0 ;
|
||||||
$graphx->Graph();
|
$graphx->Graph();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dolibarr_syslog("Fin client ".$this->ident);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
print "\n";
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user