Clear Actual Data
Clear EcmCallsPhones
Assigning Calls
Generate New Data
Refresh Old Records With src_old Number
connect(); if($_REQUEST['ecAction'] == 'RefreshORWSON') { echo 'Refresh Old Records With src_old Number
'; $query = "UPDATE `cdr` SET `src_old` = `src`, `src` = `dcontext` WHERE INSTR(`channel`, CONCAT('SIP/', `dcontext`, '-')) = 1;"; echo $query.' - '.$GLOBALS['db']->query($query).'
'; } else if($_REQUEST['ecAction'] == 'ClearActualData') { echo 'Clear Actual Data
'; $query = "TRUNCATE TABLE `cdr`;"; echo $query.' - '.$GLOBALS['db']->query($query).'
'; $query = "TRUNCATE TABLE `ecmcalls_beans`;"; echo $query.' - '.$GLOBALS['db']->query($query).'
'; } else if($_REQUEST['ecAction'] == 'ClearEcmCallsPhones') { echo 'Clear EcmCalls Phones
'; $query = "TRUNCATE TABLE `ecmcallsphones`;"; echo $query.' - '.$GLOBALS['db']->query($query).'
'; } else if($_REQUEST['ecAction'] == 'AssigningCalls') { echo 'Assigning Calls
'; $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
'; $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.'
'; } } ?>