121 lines
4.4 KiB
PHP
Executable File
121 lines
4.4 KiB
PHP
Executable File
<a href="index.php?module=EcmCalls&action=GenerateExampleData&ecAction=ClearActualData">Clear Actual Data</a><br />
|
|
<a href="index.php?module=EcmCalls&action=GenerateExampleData&ecAction=ClearEcmCallsPhones">Clear EcmCallsPhones</a><br />
|
|
<a href="index.php?module=EcmCalls&action=GenerateExampleData&ecAction=AssigningCalls">Assigning Calls</a><br />
|
|
<a href="index.php?module=EcmCalls&action=GenerateExampleData&ecAction=GenerateNewData">Generate New Data</a><br />
|
|
<a href="index.php?module=EcmCalls&action=GenerateExampleData&ecAction=RefreshORWSON">Refresh Old Records With src_old Number</a><br />
|
|
<?php
|
|
|
|
$GLOBALS['db'] = new MysqlManager();
|
|
$GLOBALS['db']->connect();
|
|
|
|
|
|
if($_REQUEST['ecAction'] == 'RefreshORWSON') {
|
|
echo 'Refresh Old Records With src_old Number<br>';
|
|
$query = "UPDATE `cdr` SET `src_old` = `src`, `src` = `dcontext` WHERE INSTR(`channel`, CONCAT('SIP/', `dcontext`, '-')) = 1;";
|
|
echo $query.' - '.$GLOBALS['db']->query($query).'<br/>';
|
|
} else
|
|
if($_REQUEST['ecAction'] == 'ClearActualData') {
|
|
echo 'Clear Actual Data<br>';
|
|
$query = "TRUNCATE TABLE `cdr`;";
|
|
echo $query.' - '.$GLOBALS['db']->query($query).'<br/>';
|
|
$query = "TRUNCATE TABLE `ecmcalls_beans`;";
|
|
echo $query.' - '.$GLOBALS['db']->query($query).'<br/>';
|
|
} else
|
|
if($_REQUEST['ecAction'] == 'ClearEcmCallsPhones') {
|
|
echo 'Clear EcmCalls Phones<br />';
|
|
$query = "TRUNCATE TABLE `ecmcallsphones`;";
|
|
echo $query.' - '.$GLOBALS['db']->query($query).'<br/>';
|
|
} else
|
|
if($_REQUEST['ecAction'] == 'AssigningCalls') {
|
|
echo 'Assigning Calls<br />';
|
|
$file = "modules/EcmCalls/EcmCall.php";
|
|
require_once($file);
|
|
if(EcmCall::autoAssigning())
|
|
echo "Assigning successfull!";
|
|
else
|
|
echo "Assigning fail!";
|
|
} else
|
|
if($_REQUEST['ecAction'] == 'GenerateNewData') {
|
|
echo 'Generate New Data<br>';
|
|
$query = "SELECT DISTINCT `phone` FROM `ecmcallsphones` as `ecp`
|
|
LEFT JOIN `users` as `u` ON `ecp`.`bean_id` = `u`.`id`
|
|
LEFT JOIN `accounts` as `a` ON `ecp`.`bean_id` = `a`.`id`
|
|
LEFT JOIN `contacts` as `c` ON `ecp`.`bean_id` = `c`.`id`
|
|
LEFT JOIN `leads` as `l` ON `ecp`.`bean_id` = `l`.`id`
|
|
WHERE `u`.`deleted` = 0
|
|
OR `a`.`deleted` = 0
|
|
OR `c`.`deleted` = 0
|
|
OR `l`.`deleted` = 0
|
|
;";
|
|
$results = $GLOBALS['db']->query($query);
|
|
if(is_resource($results)) {
|
|
$phones = array();
|
|
while($row = $GLOBALS['db']->fetchByAssoc($results)) {
|
|
$phones[] = $row['phone'];
|
|
}
|
|
}
|
|
|
|
$count = count($phones);
|
|
|
|
$types = array( "in", "out", "inside" );
|
|
$statuses = array( "NO ANSWER", "ANSWERED", "FAILED" );
|
|
|
|
for( $i = 0; $i < 1000; $i ++ ) {
|
|
|
|
$type = $types[rand()%count($types)];
|
|
$status = $statuses[rand()%count($statuses)];
|
|
|
|
if($type == "in") {
|
|
$rand = rand() % $count;
|
|
$from = $phones[$rand];
|
|
do {
|
|
$rand = rand() % $count;
|
|
$to = $phones[$rand];
|
|
} while(strlen($to) > 4 && $to != $from);
|
|
} else if($type == "out") {
|
|
$rand = rand() % $count;
|
|
$to = $phones[$rand];
|
|
do {
|
|
$rand = rand() % $count;
|
|
$from = $phones[$rand];
|
|
} while(strlen($from) > 4 && $from != $to);
|
|
} else if($type == "inside") {
|
|
do {
|
|
$rand = rand() % $count;
|
|
$from = $phones[$rand];
|
|
} while(strlen($from) > 4);
|
|
do {
|
|
$rand = rand() % $count;
|
|
$to = $phones[$rand];
|
|
} while(strlen($to) > 4 && $to != $from);
|
|
}
|
|
|
|
$rand_date = date("Y-m-d H:i:s", time()-rand(0,600000));
|
|
|
|
$rand_billsec = rand(0, 120);
|
|
$rand_duration = $rand_duration + rand(0,30);
|
|
|
|
|
|
|
|
$query = "INSERT INTO `cdr` (`calldate`, `clid`, `src`, `dst`, `dcontext`, `channel`, `dstchannel`, `lastapp`, `lastdata`, `duration`, `billsec`, `disposition`, `amaflags`, `accountcode`, `userfield`) VALUES ";
|
|
|
|
$values = array(
|
|
|
|
"('$rand_date', '$from', '$from', '$to', '$from', 'SIP/$to-082dca58', 'mISDN/1-u120', 'Dial', 'misdn/1/0048665981372|60|TW', $rand_duration, $rand_billsec, '$status', 3, '', '')",
|
|
|
|
"('$rand_date', '$from', '$from', '$to', '$from', 'SIP/$to-082ea848', 'mISDN/1-u122', 'Dial', 'misdn/1/0048672652269|60|TW', $rand_duration, $rand_billsec, '$status', 3, '', '')",
|
|
|
|
"('$rand_date', '$from', '$from', '$to', 'default', 'Local/$to@default-e524,2', '', 'Busy', '', $rand_duration, $rand_billsec, '$status', 3, '', '')",
|
|
|
|
);
|
|
|
|
$query .= $values[rand() % count($values)].';';
|
|
$GLOBALS['db']->query($query);
|
|
//echo $query.'<br />';
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
?>
|