23 |
* |
* |
24 |
* |
* |
25 |
*/ |
*/ |
26 |
|
print strftime("%H:%M:%S",time())."\n"; |
27 |
require ("../../master.inc.php"); |
require ("../../master.inc.php"); |
28 |
require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/ProcessGraphLignes.class.php"); |
require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/ProcessGraphLignes.class.php"); |
29 |
|
|
30 |
$childrenTotal = 4; |
$datetime = time(); |
31 |
$childrenNow = 0; |
$month = strftime("%m", $datetime); |
32 |
$clientPerChild = 0; |
$year = strftime("%Y", $datetime); |
33 |
|
|
34 |
$sql = "SELECT max(rowid)"; |
if ($month == 1) |
35 |
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne"; |
{ |
36 |
|
$month = "12"; |
37 |
if ($db->query($sql)) |
$year = $year - 1; |
38 |
|
} |
39 |
|
else |
40 |
{ |
{ |
41 |
$row = $db->fetch_row(); |
$month = substr("00".($month - 1), -2) ; |
|
$clientPerChild = ceil($row[0] / $childrenTotal); |
|
|
$db->free(); |
|
42 |
} |
} |
43 |
|
|
44 |
while ( $childrenNow < $childrenTotal ) |
$sql = "SELECT distinct(fk_ligne)"; |
45 |
|
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details"; |
46 |
|
$sql .= " WHERE date_format(date,'%m%Y') = '".$month.$year."'"; |
47 |
|
|
48 |
|
$resql = $db->query($sql); |
49 |
|
|
50 |
|
if ($resql) |
51 |
{ |
{ |
52 |
$pid = pcntl_fork(); |
$num = $db->num_rows($resql); |
53 |
|
$i = 0; |
54 |
if ( $pid == -1 ) |
|
55 |
{ |
print "$num lignes\n"; |
56 |
die( "error\n" ); |
|
57 |
} |
while ($i < $num) |
|
elseif ( $pid == 0 ) |
|
|
{ |
|
|
$childrenNow++; |
|
|
} |
|
|
else |
|
58 |
{ |
{ |
59 |
$process = new ProcessGraphLignes( $childrenNow, $clientPerChild ); |
print substr("0000".($i+1), -4) . "/".substr("0000".$num, -4)."\n"; |
60 |
$process->go(); |
$row = $db->fetch_row($resql); |
61 |
die(); |
|
62 |
} |
$gr = new ProcessGraphLignes($db); |
63 |
|
$gr->go($row[0]); |
64 |
|
|
65 |
usleep(100000); |
$i++; |
66 |
|
} |
67 |
} |
} |
68 |
?> |
?> |