In this case, we will create a script cdrlog to generate CDR(call record details), the script will receive call events, based on these events we can create/update CDRs. The script is written in php and we use MySql database.
The script will process call events, when it receive a “ringing” event, it will create a new CDR, when receive another event, it will update the record
function cdr() {
if($data ['calltype'] == ‘dialout’){
//outbound call event
if($data['source'] == 'CALLEE' && $data['event'] == 'ringing'){
//agent dial out, customer ring, call start
$src = (string)$agentphone; //legA, agent number
$dst = (string)$data['activenum'];//dialed number
$starttime = $data['eventTime'];//ringing time is start time
$disposition = 'NOANSWER';//ringing means no answer yet
$target = 'DialOut';//it's a outbound call
$diallogid = $data['sessionid']; //identity of the call
$agentno;//agent number
$orgidentity;//team identity
If(!(SELECT * FROM `your cdr table` WHERE diallogid=$diallogid limit 1;)){
//check if the record exists, if no, we create a new CDR, just in case we received duplicated events
INSERT INTO `your cdr table` SET `variables above`;//save to database
}
}else if($data['source'] == 'CALLEE' && $data['event'] == 'answer'){
//customer answered, we need to update CDR
$disposition = 'ANSWER';//update call status
$answertime =$data['eventTime'];//update answered time
UPDATE scenario WHERE diallogid=$diallogid limit 1;
}else if($data['source'] == 'CALLEE' && $data['event'] == 'hangup'){
$endtime =$data['eventTime'];//end time
UPDATE scenario WHERE diallogid=$diallogid limit 1;
}
}
}
To receive call events for a team, you need to go to Team → Advanced, “Push event URL:” = your script address, like http://192.168.0.100/cdr.php
restart astercc daemons
/etc/init.d/asterccd restart