added DID logging of call length to call_log table from start until pre-in-group queue or hangup

git-svn-id: svn://192.168.202.10@1313 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2010-01-19 19:20:31 +00:00
parent 25aed0a17c
commit f70135f421
2 changed files with 42 additions and 10 deletions
+29 -2
View File
@@ -1336,6 +1336,33 @@ else
}
##########################################################
### end logging for call_log logged DID_INBOUND calls ###
$CLchannel_group='';
$stmtA = "SELECT channel_group,start_epoch FROM call_log where uniqueid='$unique_id' order by start_time desc limit 1;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$CLchannel_group = $aryA[0];
$CLstart_epoch = $aryA[1];
}
$sthA->finish();
if ($CLchannel_group =~ /DID_INBOUND/)
{
$CLlength_in_sec = ($now_date_epoch - $CLstart_epoch);
$CLlength_in_min = ($CLlength_in_sec / 60);
$CLlength_in_min = sprintf("%8.2f", $CLlength_in_min);
$stmtA = "UPDATE call_log set end_time='$now_date',end_epoch='$now_date_epoch',length_in_sec=$CLlength_in_sec,length_in_min='$CLlength_in_min',extension='$callerid' where uniqueid='$unique_id'";
$affected_rowsCL = $dbhA->do($stmtA);
if ($AGILOG) {$agi_string = "DID IVR time logged: $start_time|$now_date_epoch|$affected_rowsCL|$stmtA|"; &agi_output;}
}
############################################
### Loop to try to send call to an agent ###
while ( ($drop_timer <= $DROP_TIME) && ($wait_in_queue > 0) )
@@ -1763,8 +1790,8 @@ while ( ($drop_timer <= $DROP_TIME) && ($wait_in_queue > 0) )
$dbhA->disconnect();
$now_date_epoch = time();
$now_date = "$year-$mon-$mday $hour:$min:$sec";
$now_date_epoch = time();
$now_date = "$year-$mon-$mday $hour:$min:$sec";
if ($AGILOG) {$agi_string = "XXXXX VDAD transferred: start|stop $start_time|$now_date"; &agi_output;}
exit;
+13 -8
View File
@@ -601,9 +601,9 @@ sub process_request
### get uniqueid and start_epoch from the call_log table
$CALLunique_id = $unique_id;
$stmtA = "SELECT uniqueid,start_epoch,channel FROM call_log where uniqueid='$unique_id';";
$stmtA = "SELECT uniqueid,start_epoch,channel,end_epoch,channel_group FROM call_log where uniqueid='$unique_id';";
if ($callerid =~ /^M/)
{$stmtA = "SELECT uniqueid,start_epoch,channel FROM call_log where caller_code='$callerid' and channel NOT LIKE \"Local\/%\";";}
{$stmtA = "SELECT uniqueid,start_epoch,channel,end_epoch,channel_group FROM call_log where caller_code='$callerid' and channel NOT LIKE \"Local\/%\";";}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@@ -611,16 +611,21 @@ sub process_request
while ($sthArows > $rec_count)
{
@aryA = $sthA->fetchrow_array;
$unique_id = $aryA[0];
$uniqueid = $aryA[0];
$start_time = $aryA[1];
$channel = $aryA[2];
if ($AGILOG) {$agi_string = "|$aryA[0]|$aryA[1]|"; &agi_output;}
$unique_id = $aryA[0];
$uniqueid = $aryA[0];
$start_time = $aryA[1];
$channel = $aryA[2];
$end_epoch = $aryA[3];
$channel_group = $aryA[4];
if ($AGILOG) {$agi_string = "|$aryA[0]|$aryA[1]|$aryA[2]|$aryA[3]|"; &agi_output;}
$rec_count++;
}
$sthA->finish();
if ($rec_count)
$did_log=0;
if ( ($channel_group =~ /DID_INBOUND/) && ($end_epoch > 1000) )
{$did_log=1;}
if ( ($rec_count) && ($did_log < 1) )
{
$length_in_sec = ($now_date_epoch - $start_time);
$length_in_min = ($length_in_sec / 60);