added option for system call trigger on call transfer to agi-VDAD_ALL_inbound.agi

git-svn-id: svn://192.168.202.10@761 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2008-01-10 08:01:08 +00:00
parent ffcb43af71
commit 28c19e29c0
+56 -4
View File
@@ -54,6 +54,7 @@
# 71112-0058 - fixed multi-logging bug on CLOSER calls
# 71116-1045 - added fewest_calls_campaign agent call routing option
# 71128-1758 - added CIDLOOKUPRC method to search all lists within a campaign
# 80109-2348 - added option to trigger a system process when the call is sent to an agent
#
$script = 'agi-VDAD_ALL_inbound.agi';
@@ -77,6 +78,7 @@ $hm = ($hm + 0);
$now_date_epoch = time();
$now_date = "$year-$mon-$mday $hour:$min:$sec";
$CLInow_date = "$year-$mon-$mday\\ $hour:$min:$sec";
$start_time=$now_date;
$CIDdate = "$mon$mday$hour$min$sec";
$tsSQLdate = "$year$mon$mday$hour$min$sec";
@@ -134,6 +136,8 @@ foreach(@conf)
if (!$VARDB_port) {$VARDB_port='3306';}
if (!$AGILOGfile) {$AGILOGfile = "$PATHlogs/agiout.$year-$mon-$mday";}
if (!$PRSLOGfile) {$PRSLOGfile = "$PATHlogs/prsout.$year-$mon-$mday";}
if (!$PRSTESTfile) {$PRSTESTfile = "$PATHlogs/prstest.$year-$mon-$mday";}
use DBI;
use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second
@@ -553,7 +557,18 @@ if ( ($hm < $ct_default_start) || ($hm > $ct_default_stop) )
$stmtA = "INSERT INTO vicidial_closer_log set status='DROP',start_epoch='$now_date_epoch',end_epoch='$now_date_epoch',length_in_sec='1',queue_seconds='0',lead_id = '$insert_lead_id',campaign_id='$channel_group',user='VDCL',list_id='$list_id',call_date='$now_date',phone_code='$phone_code',phone_number='$phone_number',comments='AFTER HOURS DROP';";
$affected_rows = $dbhA->do($stmtA);
if ($AGILOG) {$agi_string = "-- VDCL vcl insert: |$affected_rows|$insert_lead_id|\n|$stmtA|"; &agi_output;}
$stmtB = "select LAST_INSERT_ID() LIMIT 1;";
$sthA = $dbhA->prepare($stmtB) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtB ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$insert_close_id = "$aryA[0]";
$cbc++;
}
$sthA->finish();
if ($AGILOG) {$agi_string = "-- VDCL vcl insert: |$affected_rows|$insert_lead_id|$insert_close_id|\n|$stmtA|"; &agi_output;}
$stmtA = "UPDATE vicidial_list set status='DROP' where lead_id = '$insert_lead_id';";
$affected_rows = $dbhA->do($stmtA);
@@ -657,7 +672,18 @@ $affected_rows = $dbhA->do($stmtA);
$stmtA = "INSERT INTO vicidial_closer_log (lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed,xfercallid) values('$insert_lead_id','$channel_group','$SQLdate','$now_date_epoch','QUEUE','$phone_code','$phone_number','VDCL','N','$insert_xfer_id')";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$affected_rows = $dbhA->do($stmtA);
if ($AGILOG) {$agi_string = "-- VDCL : |$insert_lead_id|$insert_xfer_id|insert to vicidial_closer_log"; &agi_output;}
$stmtB = "select LAST_INSERT_ID() LIMIT 1;";
$sthA = $dbhA->prepare($stmtB) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtB ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$insert_close_id = "$aryA[0]";
$cbc++;
}
$sthA->finish();
if ($AGILOG) {$agi_string = "-- VDCL : |$insert_lead_id|$insert_xfer_id|$insert_close_id|insert to vicidial_closer_log"; &agi_output;}
$drop_timer=0;
$drop_seconds=0;
@@ -801,7 +827,7 @@ if ($agent_search_method =~ /^SO|^LO/)
$stmtA = "UPDATE vicidial_closer_log set user='$VDADuser' where lead_id='$insert_lead_id' order by call_date desc limit 1;";
$affected_rows = $dbhA->do($stmtA);
if ($AGILOG) {$agi_string = "-- closer log : |$affected_rows|$insert_lead_id\n|$stmtA|"; &agi_output;}
if ($AGILOG) {$agi_string = "-- closer log : |$affected_rows|$insert_lead_id|$insert_close_id|\n|$stmtA|"; &agi_output;}
### if agent alert exten is not disabled, then trigger the alert and wait
if ($agent_alert_exten !~ /X/i)
@@ -843,6 +869,8 @@ if ($agent_search_method =~ /^SO|^LO/)
if ($AGILOG) {$agi_string = "-- VDLIA agent calls: |$calls_today|$VDADuser|$channel_group|"; &agi_output;}
}
&trigger_transfer_process;
usleep(1*500*1000);
print "SET CONTEXT $ext_context\n";
@@ -863,7 +891,7 @@ if ($agent_search_method =~ /^SO|^LO/)
$stmtA = "UPDATE vicidial_closer_log set queue_seconds='$drop_timer' where lead_id = '$insert_lead_id' and call_date='$SQLdate';";
$affected_rows = $dbhA->do($stmtA);
if ($AGILOG) {$agi_string = "-- VDCL vcl update: |$affected_rows|$insert_lead_id|\n|$stmtA|"; &agi_output;}
if ($AGILOG) {$agi_string = "-- VDCL vcl update: |$affected_rows|$insert_lead_id|$insert_close_id|\n|$stmtA|"; &agi_output;}
$dbhA->disconnect();
@@ -1062,6 +1090,8 @@ if ($agent_search_method =~ /^LO|^LB/)
if ($AGILOG) {$agi_string = "-- VDLIA agent calls: |$calls_today|$VDADuser|$channel_group|"; &agi_output;}
}
&trigger_transfer_process;
usleep(1*500*1000);
print "SET CONTEXT $ext_context\n";
@@ -1370,3 +1400,25 @@ if ( ($AGILOG == '1') || ($AGILOG == '3') )
{print STDERR "$now_date|$script|$agi_string\n";}
$agi_string='';
}
sub trigger_transfer_process
{
# $DS='--';
# $BEGIN='BEGIN';
#
# $CLI = "/usr/bin/date >> $PRSTESTfile &";
# $CLI = "/root/phone.pl $insert_lead_id$DS$insert_close_id$DS$CLInow_date$DS$VDADextension$DS$phone_number$DS$DS$BEGIN$DS >> $PRSTESTfile &";
#
# `$CLI`;
#
# if ($AGILOG >=2)
# {
# ### open the log file for writing ###
# open(Pout, ">>$PRSLOGfile")
# || die "Can't open $AGILOGfile: $!\n";
# print Pout "$now_date|$VDADconf_exten|$VDADuser|$VDADextension|$insert_lead_id|$phone_number|$insert_close_id|$channel_group|$drop_timer|$CLI|\n";
# close(Pout);
# }
#
}