From a56f936c1bbf1fd8fd2d3e2eef19c738e1b15e20 Mon Sep 17 00:00:00 2001 From: mattf Date: Mon, 20 Oct 2008 08:06:16 +0000 Subject: [PATCH] logging fixes and queue_log fixes AST_VDauto_dial.pl fix for deleting vicidial_auto_calls entries git-svn-id: svn://192.168.202.10@979 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/trunk/agi/VDL_CID_lookup.agi | 171 ++++- agc_2-X/trunk/agi/agi-VDAD_ALL_inbound.agi | 118 +++- agc_2-X/trunk/agi/agi-VDAD_ALL_outbound.agi | 57 +- .../agi/agi-VDAD_inbound_calltime_check.agi | 27 +- agc_2-X/trunk/bin/AST_VDauto_dial.pl | 613 ++++++++++-------- agc_2-X/trunk/bin/AST_VDremote_agents.pl | 13 +- agc_2-X/trunk/bin/FastAGI_log.pl | 4 +- agc_2-X/trunk/docs/Inbound_VDAC_IVR.txt | 3 +- agc_2-X/trunk/docs/QUEUEMETRICS.txt | 5 +- agc_2-X/trunk/docs/REQUIRED_APPS_INSTALL.txt | 8 +- agc_2-X/trunk/docs/SCRATCH_INSTALL.txt | 2 +- agc_2-X/trunk/www/agc/vdc_db_query.php | 18 +- agc_2-X/trunk/www/agc/vicidial.php | 9 +- .../trunk/www/vicidial/AST_CLOSERstats.php | 8 + agc_2-X/trunk/www/vicidial/AST_timeonVDAD.php | 8 + 15 files changed, 683 insertions(+), 381 deletions(-) diff --git a/agc_2-X/trunk/agi/VDL_CID_lookup.agi b/agc_2-X/trunk/agi/VDL_CID_lookup.agi index af753e08..f3c626a6 100644 --- a/agc_2-X/trunk/agi/VDL_CID_lookup.agi +++ b/agc_2-X/trunk/agi/VDL_CID_lookup.agi @@ -23,8 +23,10 @@ # # changes: # 80930-0226 - first build +# 81015-1702 - added filter stats # +$filter_stats = 1; $script = 'VDL_CID_lookup.agi'; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); @@ -38,6 +40,7 @@ if ($sec < 10) {$sec = "0$sec";} $now_date_epoch = time(); $now_date = "$year-$mon-$mday $hour:$min:$sec"; +$SQLdate = "$year-$mon-$mday $hour:$min:$sec"; # default path to astguiclient configuration file: $PATHconf = '/etc/astguiclient.conf'; @@ -199,24 +202,160 @@ $callerid =~ s/\"//gi; -### find out if phone number exists in the vicidial_list table -$stmtA = "SELECT count(*) FROM vicidial_list where phone_number = '$callerid' and list_id NOT IN('99999');"; -$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; - $VDL_count = "$aryA[0]"; - } -$sthA->finish(); -if ($VDL_count < 1) + + + + + + + + + +if ($filter_stats > 0) { - $priority = ($priority + 3); - if ($AGILOG) {$agi_string = "-- cid_lookup finish: |$priority|$callerid"; &agi_output;} - print "SET PRIORITY $priority\n"; - checkresult($result); + ### find out if phone number exists in the vicidial_list table + $stmtA = "SELECT count(*) FROM vicidial_list where phone_number = '$callerid';"; + $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; + $VDL_count = "$aryA[0]"; + } + $sthA->finish(); + + if ($VDL_count < 1) + { + $priority = ($priority + 3); + $stmtA = "INSERT INTO live_inbound_log (uniqueid,channel,server_ip,caller_id,extension,start_time,comment_a,comment_b) values('$uniqueid','$channel','$VARserver_ip','$callerid','$extension','$SQLdate','INBOUND_IVR_FILTER','NOT_FOUND')"; + if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} + $affected_rows = $dbhA->do($stmtA); + if ($AGILOG) {$agi_string = "-- cid_lookup finish: : |$affected_rows|$callerid|$priority|NOT_FOUND|"; &agi_output;} + + print "SET PRIORITY $priority\n"; + checkresult($result); + + $dbhA->disconnect(); + + exit; + } + else ################# LEAD IN SYSTEM, FILTER FURTHER ######################### + { + $stmtA = "SELECT count(*) FROM vicidial_list where phone_number = '$callerid' and status IN('A1','A2','A3','A4','SALE');"; + $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; + $sales_count = "$aryA[0]"; + } + $sthA->finish(); + + if ($sales_count > 0) + { + $priority = ($priority + 3); + $stmtA = "INSERT INTO live_inbound_log (uniqueid,channel,server_ip,caller_id,extension,start_time,comment_a,comment_b,comment_c) values('$uniqueid','$channel','$VARserver_ip','$callerid','$extension','$SQLdate','INBOUND_IVR_FILTER','EXISTING','SALE')"; + if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} + $affected_rows = $dbhA->do($stmtA); + if ($AGILOG) {$agi_string = "-- cid_lookup finish: : |$affected_rows|$callerid|$priority|EXISTING|SALE|"; &agi_output;} + + print "SET PRIORITY $priority\n"; + checkresult($result); + + $dbhA->disconnect(); + + exit; + } + + $stmtA = "SELECT count(*) FROM vicidial_list where phone_number = '$callerid' and status IN('DNC');"; + $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; + $dnc_count = "$aryA[0]"; + } + $sthA->finish(); + + if ($dnc_count > 0) + { + $priority = ($priority + 3); + $stmtA = "INSERT INTO live_inbound_log (uniqueid,channel,server_ip,caller_id,extension,start_time,comment_a,comment_b,comment_c) values('$uniqueid','$channel','$VARserver_ip','$callerid','$extension','$SQLdate','INBOUND_IVR_FILTER','EXISTING','DNC')"; + if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} + $affected_rows = $dbhA->do($stmtA); + if ($AGILOG) {$agi_string = "-- cid_lookup finish: : |$affected_rows|$callerid|$priority|EXISTING|DNC|"; &agi_output;} + + print "SET PRIORITY $priority\n"; + checkresult($result); + + $dbhA->disconnect(); + + exit; + } + + $stmtA = "SELECT count(*) FROM vicidial_list where phone_number = '$callerid' and list_id NOT IN('999999');"; + $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; + $archive_count = "$aryA[0]"; + } + $sthA->finish(); + + if ($archive_count < 1) + { + $priority = ($priority + 3); + $stmtA = "INSERT INTO live_inbound_log (uniqueid,channel,server_ip,caller_id,extension,start_time,comment_a,comment_b,comment_c) values('$uniqueid','$channel','$VARserver_ip','$callerid','$extension','$SQLdate','INBOUND_IVR_FILTER','EXISTING','ARCHIVE')"; + if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} + $affected_rows = $dbhA->do($stmtA); + if ($AGILOG) {$agi_string = "-- cid_lookup finish: : |$affected_rows|$callerid|$priority|EXISTING|ARCHIVE|"; &agi_output;} + + print "SET PRIORITY $priority\n"; + checkresult($result); + + $dbhA->disconnect(); + + exit; + } + + $stmtA = "INSERT INTO live_inbound_log (uniqueid,channel,server_ip,caller_id,extension,start_time,comment_a,comment_b,comment_c) values('$uniqueid','$channel','$VARserver_ip','$callerid','$extension','$SQLdate','INBOUND_IVR_FILTER','CLEAN','TO_AGENT')"; + if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} + $affected_rows = $dbhA->do($stmtA); + if ($AGILOG) {$agi_string = "-- cid_lookup finish: : |$affected_rows|$callerid|$priority|EXISTING|CLEAN|"; &agi_output;} + + exit; + } + + } + +else + { + ### find out if phone number exists in the vicidial_list table + $stmtA = "SELECT count(*) FROM vicidial_list where phone_number = '$callerid' and list_id NOT IN('999999');"; + $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; + $VDL_count = "$aryA[0]"; + } + $sthA->finish(); + + if ($VDL_count < 1) + { + $priority = ($priority + 3); + if ($AGILOG) {$agi_string = "-- cid_lookup finish: |$priority|$callerid"; &agi_output;} + print "SET PRIORITY $priority\n"; + checkresult($result); + } + } $dbhA->disconnect(); diff --git a/agc_2-X/trunk/agi/agi-VDAD_ALL_inbound.agi b/agc_2-X/trunk/agi/agi-VDAD_ALL_inbound.agi index e11bb9b7..04d674d0 100644 --- a/agc_2-X/trunk/agi/agi-VDAD_ALL_inbound.agi +++ b/agc_2-X/trunk/agi/agi-VDAD_ALL_inbound.agi @@ -84,6 +84,7 @@ # 80918-0505 - Added place in line and estimated time on hold # 81002-1120 - Added processing for DID forwarded calls # 81011-1019 - Added option for press 1 to leave voicemail if wait time > hold-time-option-seconds +# 81020-0237 - Added term_reason logging for all possible exits of the script # $script = 'agi-VDAD_ALL_inbound.agi'; @@ -536,7 +537,7 @@ if ($call_handle_method =~ /LOOKUP/) } $cbc=0; - $stmtA= "SELECT lead_id from vicidial_list where phone_number='$phone_number' $listSQL order by last_local_call_time limit 1;"; + $stmtA= "SELECT lead_id from vicidial_list where phone_number='$phone_number' $listSQL order by last_local_call_time desc limit 1;"; if ($AGILOG) {$agi_string = "VDAD vicidial_list search |$phone_number|$stmtA|"; &agi_output;} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -692,6 +693,7 @@ if ( ($hm < $ct_default_start) || ($hm > $ct_default_stop) ) if ($after_hours_action =~ /MESSAGE/) { $AGI->stream_file('sip-silence'); + $AGI->stream_file('sip-silence'); $AGI->stream_file("$after_hours_message_filename"); sleep(1); @@ -1149,13 +1151,6 @@ if ($agent_search_method =~ /^SO|^LO/) if ($no_delay_call_route !~ /Y/i) {usleep(1*500*1000);} - print "SET CONTEXT $ext_context\n"; - checkresult($result); - print "SET EXTENSION $VDADconf_exten\n"; - checkresult($result); - print "SET PRIORITY 1\n"; - checkresult($result); - ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $year = ($year + 1900); $mon++; @@ -1169,6 +1164,13 @@ if ($agent_search_method =~ /^SO|^LO/) $affected_rows = $dbhA->do($stmtA); if ($AGILOG) {$agi_string = "-- VDCL vcl update: |$affected_rows|$insert_lead_id|$insert_close_id|\n|$stmtA|"; &agi_output;} + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $VDADconf_exten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + $dbhA->disconnect(); $now_date_epoch = time(); @@ -1439,13 +1441,6 @@ if ($agent_search_method =~ /^LO|^LB/) if ($no_delay_call_route !~ /Y/i) {usleep(1*500*1000);} - print "SET CONTEXT $ext_context\n"; - checkresult($result); - print "SET EXTENSION $VDADremDIALstr\n"; - checkresult($result); - print "SET PRIORITY 1\n"; - checkresult($result); - ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $year = ($year + 1900); $mon++; @@ -1459,6 +1454,13 @@ if ($agent_search_method =~ /^LO|^LB/) $affected_rows = $dbhA->do($stmtA); if ($AGILOG) {$agi_string = "-- VDCL vcl update: |$affected_rows|$insert_lead_id|\n|$stmtA|"; &agi_output;} + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $VDADremDIALstr\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + $dbhA->disconnect(); $now_date_epoch = time(); @@ -1535,14 +1537,6 @@ if ($hold_recall_xfer_group !~ /NONE/) sleep(1); } - if ($AGILOG) {$agi_string = "exiting the VDAD app, transferring call to $DROPexten"; &agi_output;} - print "SET CONTEXT $ext_context\n"; - checkresult($result); - print "SET EXTENSION $DROPexten\n"; - checkresult($result); - print "SET PRIORITY 1\n"; - checkresult($result); - $stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' and server_ip='$VARserver_ip' order by call_time desc limit 1;"; $affected_rows = $dbhA->do($stmtA); if ($AGILOG) {$agi_string = "-- VDCL vac record deleted: |$affected_rows| $VDADcampaign|"; &agi_output;} @@ -1557,6 +1551,27 @@ if ($hold_recall_xfer_group !~ /NONE/) $affected_rows = $dbhA->do($stmtA); if ($AGILOG) {$agi_string = "-- VDCL vl update: |$affected_rows|$insert_lead_id|\n|$stmtA|"; &agi_output;} + if ($enable_queuemetrics_logging > 0) + { + $dbhB = DBI->connect("DBI:mysql:$queuemetrics_dbname:$queuemetrics_server_ip:3306", "$queuemetrics_login", "$queuemetrics_pass") + or die "Couldn't connect to database: " . DBI->errstr; + + if ($DBX) {print "CONNECTED TO DATABASE: $queuemetrics_server_ip|$queuemetrics_dbname\n";} + + $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='$YqueryCID',queue='$channel_group',agent='NONE',verb='TRANSFER',data1='$DROPexten',data2='$ext_context',data3='1',data4='1',serverid='$queuemetrics_log_id';"; + $Baffected_rows = $dbhB->do($stmtB); + + $dbhB->disconnect(); + } + + if ($AGILOG) {$agi_string = "exiting the VDAD app, transferring call to $DROPexten"; &agi_output;} + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $DROPexten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + $dbhA->disconnect(); exit; @@ -1776,6 +1791,7 @@ if ( ($hold_time_option !~ /NONE/ ) && ( $holdtime_estimate_sec_diff > $hold_tim { $wait_in_queue=0; # exits wait loop $DROPexten = ''; +$exitwithkey=0; if ($hold_time_option =~ /EXTENSION/) { if (length($hold_time_option_exten)>0) @@ -1810,6 +1826,26 @@ if ($hold_time_option =~ /PRESS_VMAIL/) { $DROPexten = "$voicemail_dump_exten$hold_time_option_voicemail"; $HT_status='QVMAIL'; + + if ($enable_queuemetrics_logging > 0) + { + $dbhB = DBI->connect("DBI:mysql:$queuemetrics_dbname:$queuemetrics_server_ip:3306", "$queuemetrics_login", "$queuemetrics_pass") + or die "Couldn't connect to database: " . DBI->errstr; + + if ($DBX) {print "CONNECTED TO DATABASE: $queuemetrics_server_ip|$queuemetrics_dbname\n";} + + $place=0; + if ($rec_countWAIT > 0) {$place = $rec_countWAIT;} + if ($rec_countWAITrem > 0) {$place = $rec_countWAITrem;} + $place++; + + $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='$YqueryCID',queue='$channel_group',agent='NONE',verb='EXITWITHKEY',data1='1',data2='$place',serverid='$queuemetrics_log_id';"; + $Baffected_rows = $dbhB->do($stmtB); + + $exitwithkey++; + + $dbhB->disconnect(); + } } else { @@ -1881,14 +1917,6 @@ if ($wait_in_queue < 1) sleep(1); } - if ($AGILOG) {$agi_string = "exiting the VDAD app, transferring call to $DROPexten"; &agi_output;} - print "SET CONTEXT $ext_context\n"; - checkresult($result); - print "SET EXTENSION $DROPexten\n"; - checkresult($result); - print "SET PRIORITY 1\n"; - checkresult($result); - $stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' and server_ip='$VARserver_ip' order by call_time desc limit 1;"; $affected_rows = $dbhA->do($stmtA); if ($AGILOG) {$agi_string = "-- VDCL vac record deleted: |$affected_rows| $VDADcampaign|"; &agi_output;} @@ -1904,6 +1932,27 @@ if ($wait_in_queue < 1) $affected_rows = $dbhA->do($stmtA); if ($AGILOG) {$agi_string = "-- VDCL vl update: |$affected_rows|$insert_lead_id|\n|$stmtA|"; &agi_output;} + if ( ($enable_queuemetrics_logging > 0) && ($exitwithkey < 1) ) + { + $dbhB = DBI->connect("DBI:mysql:$queuemetrics_dbname:$queuemetrics_server_ip:3306", "$queuemetrics_login", "$queuemetrics_pass") + or die "Couldn't connect to database: " . DBI->errstr; + + if ($DBX) {print "CONNECTED TO DATABASE: $queuemetrics_server_ip|$queuemetrics_dbname\n";} + + $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='$YqueryCID',queue='$channel_group',agent='NONE',verb='TRANSFER',data1='$DROPexten',data2='$ext_context',data3='$drop_seconds',data4='$drop_seconds',serverid='$queuemetrics_log_id';"; + $Baffected_rows = $dbhB->do($stmtB); + + $dbhB->disconnect(); + } + + if ($AGILOG) {$agi_string = "exiting the VDAD app, transferring call to $DROPexten"; &agi_output;} + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $DROPexten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + $dbhA->disconnect(); exit; @@ -1984,7 +2033,12 @@ if ($enable_queuemetrics_logging > 0) if ($DBX) {print "CONNECTED TO DATABASE: $queuemetrics_server_ip|$queuemetrics_dbname\n";} - $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='$YqueryCID',queue='$channel_group',agent='NONE',verb='EXITWITHTIMEOUT',data1='1',serverid='$queuemetrics_log_id';"; + $place=0; + if ($rec_countWAIT > 0) {$place = $rec_countWAIT;} + if ($rec_countWAITrem > 0) {$place = $rec_countWAITrem;} + $place++; + + $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='$YqueryCID',queue='$channel_group',agent='NONE',verb='EXITWITHTIMEOUT',data1='$place',serverid='$queuemetrics_log_id';"; $Baffected_rows = $dbhB->do($stmtB); $dbhB->disconnect(); diff --git a/agc_2-X/trunk/agi/agi-VDAD_ALL_outbound.agi b/agc_2-X/trunk/agi/agi-VDAD_ALL_outbound.agi index 81bb3351..2422a182 100644 --- a/agc_2-X/trunk/agi/agi-VDAD_ALL_outbound.agi +++ b/agc_2-X/trunk/agi/agi-VDAD_ALL_outbound.agi @@ -55,6 +55,7 @@ # 80527-2329 - Added SURVEYCAMP ability to pull settings from database # 80831-0353 - Added logging of alt_dial field # 80909-0603 - Added campaign-specific dnc option for outbound survey +# 81020-0235 - Fixed Drop hangup bug and other small bugs # $script = 'agi-VDAD_ALL_outbound.agi'; @@ -466,9 +467,9 @@ if ($affected_rows > 0) ##### PLAY REMINDER MESSAGE ##### if ($call_handle_method =~ /REMIND/) { - $stmtA = "UPDATE vicidial_auto_calls set last_update_time='$FDtsSQLdate' where callerid='$callerid' order by call_time desc limit 1;"; + $stmtA = "UPDATE vicidial_auto_calls set last_update_time='$FDtsSQLdate',stage='REMIND-0' where callerid='$callerid' order by call_time desc limit 1;"; $affected_rows = $dbhA->do($stmtA); - if ($AGILOG) {$agi_string = "-- VDAC posttime record: |$affected_rows|$FDtsSQLdate|$callerid|"; &agi_output;} + if ($AGILOG) {$agi_string = "-- VDAC posttime record: |$affected_rows|$FDtsSQLdate|$callerid|REMIND|"; &agi_output;} $AGI->stream_file("$survey_first_audio_file"); } @@ -483,9 +484,9 @@ if ($call_handle_method =~ /SURVEY/) { $AGI->stream_file('sip-silence'); - $stmtA = "UPDATE vicidial_auto_calls set last_update_time='$FDtsSQLdate' where callerid='$callerid' order by call_time desc limit 1;"; + $stmtA = "UPDATE vicidial_auto_calls set last_update_time='$FDtsSQLdate',stage='SURVEY-0' where callerid='$callerid' order by call_time desc limit 1;"; $affected_rows = $dbhA->do($stmtA); - if ($AGILOG) {$agi_string = "-- VDAC posttime record: |$affected_rows|$FDtsSQLdate|$callerid|"; &agi_output;} + if ($AGILOG) {$agi_string = "-- VDAC posttime record: |$affected_rows|$FDtsSQLdate|$callerid|SURVEY|"; &agi_output;} ### check to see if the SURVEY settings should be pulled from the campaign settings in the database if ($call_handle_method =~ /SURVEYCAMP/) @@ -675,6 +676,10 @@ if ($call_handle_method =~ /SURVEY/) if (length($DROPexten) > 0) { + $stmtA = "UPDATE vicidial_auto_calls set status='XFER',stage='XFER-0' where callerid='$callerid' order by call_time desc limit 1;"; + $affected_rows = $dbhA->do($stmtA); + if ($AGILOG) {$agi_string = "-- VDAC XFER status: |$affected_rows|$FDtsSQLdate|$callerid|"; &agi_output;} + if ($AGILOG) {$agi_string = "exiting the VDAD SURVEY app, transferring call to $DROPexten"; &agi_output;} print "SET CONTEXT $ext_context\n"; checkresult($result); @@ -756,6 +761,14 @@ if ($call_handle_method =~ /SURVEY/) &agi_output; } + $stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' order by call_time desc limit 1;"; + $affected_rows = $dbhA->do($stmtA); + if ($AGILOG) + { + $agi_string = "-- VDAD vac record deleted: |$affected_rows|$VDADcampaign|"; + &agi_output; + } + $AGI->hangup(); exit; @@ -1241,6 +1254,23 @@ if ($drop_action =~ /IN_GROUP/) } + $Euniqueid=$uniqueid; + $Euniqueid =~ s/\.\d+//gi; + $stmtA = "UPDATE vicidial_log FORCE INDEX(lead_id) set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds',term_reason='QUEUETIMEOUT' where lead_id = '$CIDlead_id' and uniqueid LIKE \"$Euniqueid%\";"; + if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} + $affected_rows = $dbhA->do($stmtA); + if ($AGILOG) {$agi_string = "-- VDAD vicidial_log update: |$affected_rows|$uniqueid"; &agi_output;} + + $stmtA = "UPDATE vicidial_list set status='DROP' where lead_id = '$CIDlead_id';"; + if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} + $affected_rows = $dbhA->do($stmtA); + if ($AGILOG) {$agi_string = "-- VDAD vicidial_list update: |$affected_rows|$CIDlead_id"; &agi_output;} + + $stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' order by call_time desc limit 1;"; + $affected_rows = $dbhA->do($stmtA); + if ($AGILOG) {$agi_string = "-- VDAD vac record deleted: |$affected_rows|$VDADcampaign|"; &agi_output;} + + ### use STDOUT to send call to proper DROP location $VHqueryCID = "VH$CIDdate$VDADconf_exten"; @@ -1264,24 +1294,11 @@ if ($drop_action =~ /IN_GROUP/) ### insert a NEW record to the vicidial_manager table to be processed $stmtA = "INSERT INTO vicidial_manager values('','','$SQLdate','NEW','N','$VARserver_ip','','Hangup','$VHqueryCID','Channel: $channel','','','','','','','','','')"; $affected_rows = $dbhA->do($stmtA); - if ($AGILOG) {$agi_string = "-- VDCL call_hungup timout: |$VHqueryCID|$VDADconf_exten|$channel|insert to vicidial_manager"; &agi_output;} + if ($AGILOG) {$agi_string = "-- VDCL call_hungup timout: |$CIDlead_id|$VHqueryCID|$VDADconf_exten|$channel|insert to vicidial_manager"; &agi_output;} + + $AGI->hangup(); } - $stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' order by call_time desc limit 1;"; - $affected_rows = $dbhA->do($stmtA); - if ($AGILOG) {$agi_string = "-- VDAD vac record deleted: |$affected_rows|$VDADcampaign|"; &agi_output;} - - $Euniqueid=$uniqueid; - $Euniqueid =~ s/\.\d+//gi; - $stmtA = "UPDATE vicidial_log FORCE INDEX(lead_id) set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds',term_reason='QUEUETIMEOUT' where lead_id = '$CIDlead_id' and uniqueid LIKE \"$Euniqueid%\";"; - if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} - $affected_rows = $dbhA->do($stmtA); - if ($AGILOG) {$agi_string = "-- VDAD vicidial_log update: |$affected_rows|$uniqueid"; &agi_output;} - - $stmtA = "UPDATE vicidial_list set status='DROP' where lead_id = '$CIDlead_id';"; - if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} - $affected_rows = $dbhA->do($stmtA); - if ($AGILOG) {$agi_string = "-- VDAD vicidial_list update: |$affected_rows|$CIDlead_id"; &agi_output;} } diff --git a/agc_2-X/trunk/agi/agi-VDAD_inbound_calltime_check.agi b/agc_2-X/trunk/agi/agi-VDAD_inbound_calltime_check.agi index d8d578f9..2200a160 100644 --- a/agc_2-X/trunk/agi/agi-VDAD_inbound_calltime_check.agi +++ b/agc_2-X/trunk/agi/agi-VDAD_inbound_calltime_check.agi @@ -13,10 +13,13 @@ # ; 2. whether to log the call into the vicidial_auto_calls table: # ; - YES - insert the call as status IVR # ; - NO - do not insert call into vac table -# +# ; 3. note to put in the comment_b field when record inserted into the +# ; live_inbound_log table, no spaces in this field, use underscore '_' +# ; default if not populated is NONE +# ; # ;inbound calls check calltime: #exten => 1234,1,Answer ; Answer the line -#exten => 1234,2,AGI(agi-VDAD_inbound_calltime_check.agi,INBOUND-----YES) +#exten => 1234,2,AGI(agi-VDAD_inbound_calltime_check.agi,INBOUND-----YES-----START) #exten => 1234,3,Hangup # # Copyright (C) 2008 Matt Florell LICENSE: AGPLv2 @@ -24,6 +27,8 @@ # changes: # 80525-0144 - First Build # 81015-0305 - Added drop logging +# 81015-2009 - Added more logging and NOTE option +# 81017-0238 - Fixed duplication bug for vac in multi-entry dialplans # $script = 'agi-VDAD_inbound_calltime_check.agi'; @@ -147,6 +152,8 @@ if (length($ARGV[0])>1) $channel_group = $ARGV_vars[0]; $log_to_vac = $ARGV_vars[1]; + $note = $ARGV_vars[2]; + if (length($note)<1) {$note = 'NONE';} } $|=1; @@ -162,6 +169,8 @@ while() } } + if (/^agi_context\:\s+(.*)$/) {$context = $1;} + if (/^agi_priority\:\s+(.*)$/) {$priority = $1;} if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1; $uniqueid = $unique_id;} if (/^agi_channel\:\s+(.*)$/) {$channel = $1;} if (/^agi_extension\:\s+(.*)$/) {$extension = $1;} @@ -302,7 +311,8 @@ if ( ($ct_day_start > 0) || ($ct_day_stop > 0) ) $ct_default_stop = $ct_day_stop; } -$AGI->stream_file('beep'); +$AGI->stream_file('sip-silence'); +$AGI->stream_file('sip-silence'); @@ -330,7 +340,8 @@ if ( ($hm < $ct_default_start) || ($hm > $ct_default_stop) ) if (length($DROPexten)>0) { ### if DROP extension is defined then send the dropped call there instead of hangup - $AGI->stream_file('ding'); # stop music-on-hold process + $AGI->stream_file('sip-silence'); # stop music-on-hold process + $AGI->stream_file('sip-silence'); # stop music-on-hold process sleep(1); @@ -347,7 +358,7 @@ if ( ($hm < $ct_default_start) || ($hm > $ct_default_stop) ) $affected_rows = $dbhA->do($stmtA); if ($AGILOG) {$agi_string = "-- VDCL vac record deleted: |$affected_rows| $uniqueid|$callerid|"; &agi_output;} - $stmtA = "INSERT INTO live_inbound_log (uniqueid,channel,server_ip,caller_id,extension,start_time,comment_a,comment_b,comment_c) values('$uniqueid','$channel','$VARserver_ip','$callerid','$extension','$SQLdate','$channel_group','$phone_number','AFTERHOURSDROP')"; + $stmtA = "INSERT INTO live_inbound_log (uniqueid,channel,server_ip,caller_id,extension,phone_ext,start_time,comment_a,comment_b,comment_c,comment_d,comment_e) values('$uniqueid','$channel','$VARserver_ip','$callerid','$extension','$phone_number','$SQLdate','$channel_group','$note','AFTERHOURSDROP','$context','$priority')"; if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} $affected_rowsL = $dbhA->do($stmtA); if ($AGILOG) {$agi_string = "-- LIL : |$affected_rowsL|$uniqueid|$callerid|$extension|"; &agi_output;} @@ -384,13 +395,17 @@ if ( ($hm < $ct_default_start) || ($hm > $ct_default_stop) ) ### insert an IVR record to the vicidial_auto_calls table if ($log_to_vac == 'YES') { + $stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' and uniqueid='$uniqueid' and server_ip='$VARserver_ip';"; + $affected_rows = $dbhA->do($stmtA); + if ($AGILOG) {$agi_string = "-- VDCL vac record deleted: |$affected_rows| $uniqueid|$callerid|"; &agi_output;} + $stmtA = "INSERT INTO vicidial_auto_calls (server_ip,campaign_id,lead_id,status,uniqueid,callerid,channel,phone_code,phone_number,call_time,call_type,stage,queue_priority,last_update_time) values('$VARserver_ip','$channel_group','0','IVR','$uniqueid','$callerid','$channel','$phone_code','$phone_number','$SQLdate','IN','IVR-0','$queue_priority','$last_update_time')"; if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} $affected_rowsV = $dbhA->do($stmtA); if ($AGILOG) {$agi_string = "-- VAC : |$affected_rowsV|$uniqueid|$callerid|$extension|"; &agi_output;} } -$stmtA = "INSERT INTO live_inbound_log (uniqueid,channel,server_ip,caller_id,extension,start_time,comment_a,comment_b) values('$uniqueid','$channel','$VARserver_ip','$callerid','$extension','$SQLdate','$channel_group','$phone_number')"; +$stmtA = "INSERT INTO live_inbound_log (uniqueid,channel,server_ip,caller_id,extension,phone_ext,start_time,comment_a,comment_b,comment_d,comment_e) values('$uniqueid','$channel','$VARserver_ip','$callerid','$extension','$phone_number','$SQLdate','$channel_group','$note','$context','$priority')"; if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} $affected_rowsL = $dbhA->do($stmtA); if ($AGILOG) {$agi_string = "-- LIL : |$affected_rowsL|$uniqueid|$callerid|$extension|"; &agi_output;} diff --git a/agc_2-X/trunk/bin/AST_VDauto_dial.pl b/agc_2-X/trunk/bin/AST_VDauto_dial.pl index b17250f1..332ec2ff 100644 --- a/agc_2-X/trunk/bin/AST_VDauto_dial.pl +++ b/agc_2-X/trunk/bin/AST_VDauto_dial.pl @@ -70,6 +70,8 @@ # 80713-0624 - Added vicidial_list_last_local_call_time field # 80829-2359 - Added extended alt dial and dnc checkon all alt dial hopper insertions # 80909-0845 - Added support for campaign-specific DNC lists +# 81013-2216 - Fixed improper deletion of auto_calls records +# 81020-0125 - Bug fixes from changes to auto_calls deletion changes # @@ -951,13 +953,13 @@ while($one_day_interval > 0) { if (length($KLserver_ip[$kill_vac]) > 7) { - $end_epoch=0; $CLuniqueid=''; + $end_epoch=0; $CLuniqueid=''; $start_epoch=0; $KLcalleridCHECK[$kill_vac]=$KLcallerid[$kill_vac]; $KLcalleridCHECK[$kill_vac] =~ s/\W//gi; if ( (length($KLcalleridCHECK[$kill_vac]) > 17) && ($KLcalleridCHECK[$kill_vac] =~ /\d\d\d\d\d\d\d\d\d\d\d\d\d\d/) ) { - $stmtA = "SELECT end_epoch,uniqueid FROM call_log where caller_code='$KLcallerid[$kill_vac]' and server_ip='$KLserver_ip[$kill_vac]' order by end_epoch, start_time desc limit 1;"; + $stmtA = "SELECT end_epoch,uniqueid,start_epoch FROM call_log where caller_code='$KLcallerid[$kill_vac]' and server_ip='$KLserver_ip[$kill_vac]' order by end_epoch, 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; @@ -968,6 +970,7 @@ while($one_day_interval > 0) @aryA = $sthA->fetchrow_array; $end_epoch = "$aryA[0]"; $CLuniqueid = "$aryA[1]"; + $start_epoch = "$aryA[2]"; $rec_count++; } $sthA->finish(); @@ -975,7 +978,7 @@ while($one_day_interval > 0) if ( (length($KLuniqueid[$kill_vac]) > 11) && (length($CLuniqueid) < 12) ) { - $stmtA = "SELECT end_epoch,uniqueid FROM call_log where uniqueid='$KLuniqueid[$kill_vac]' and server_ip='$KLserver_ip[$kill_vac]' order by end_epoch, start_time desc limit 1;"; + $stmtA = "SELECT end_epoch,uniqueid,start_epoch FROM call_log where uniqueid='$KLuniqueid[$kill_vac]' and server_ip='$KLserver_ip[$kill_vac]' order by end_epoch, 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; @@ -986,308 +989,173 @@ while($one_day_interval > 0) @aryA = $sthA->fetchrow_array; $end_epoch = "$aryA[0]"; $CLuniqueid = "$aryA[1]"; + $start_epoch = "$aryA[2]"; $rec_count++; } $sthA->finish(); } - if ($end_epoch > 1000) + + $CLlead_id=''; $auto_call_id=''; $CLstatus=''; $CLcampaign_id=''; $CLphone_number=''; $CLphone_code=''; + + $stmtA = "SELECT auto_call_id,lead_id,phone_number,status,campaign_id,phone_code,alt_dial,stage,call_type FROM vicidial_auto_calls where callerid='$KLcallerid[$kill_vac]'"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + $rec_countCUSTDATA=0; + while ($sthArows > $rec_count) { - $CLlead_id=''; $auto_call_id=''; $CLstatus=''; $CLcampaign_id=''; $CLphone_number=''; $CLphone_code=''; + @aryA = $sthA->fetchrow_array; + $auto_call_id = "$aryA[0]"; + $CLlead_id = "$aryA[1]"; + $CLphone_number = "$aryA[2]"; + $CLstatus = "$aryA[3]"; + $CLcampaign_id = "$aryA[4]"; + $CLphone_code = "$aryA[5]"; + $CLalt_dial = "$aryA[6]"; + $CLstage = "$aryA[7]"; + $CLcall_type = "$aryA[8]"; + $rec_count++; + } + $sthA->finish(); - $stmtA = "SELECT auto_call_id,lead_id,phone_number,status,campaign_id,phone_code,alt_dial,stage FROM vicidial_auto_calls where callerid='$KLcallerid[$kill_vac]'"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $rec_count=0; - $rec_countCUSTDATA=0; - while ($sthArows > $rec_count) + if ($CLcall_type =~ /IN/) + { + $stmtA = "SELECT drop_call_seconds FROM vicidial_inbound_groups where group_id='$CLcampaign_id';"; + $timeout_leeway = 30; + } + else + { + $stmtA = "SELECT dial_timeout,drop_call_seconds FROM vicidial_campaigns where campaign_id='$CLcampaign_id';"; + $timeout_leeway = 7; + } + $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; + $CLdial_timeout = "$aryA[0]"; + $CLdrop_call_seconds = "$aryA[1]"; + } + $sthA->finish(); + + $dialtime_log = ($end_epoch - $start_epoch); + $dialtime_catch = ($now_date_epoch - ($start_epoch + $timeout_leeway)); + if ($dialtime_catch > 100000) {$dialtime_catch=0;} + $call_timeout = ($CLdial_timeout + $CLdrop_call_seconds); + if ($CLstage =~ /SURVEY|REMIND/) {$call_timeout = ($call_timeout + 120);} + + if ( ($dialtime_log >= $call_timeout) || ($dialtime_catch >= $call_timeout) || ($CLstatus =~ /BUSY|DISCONNECT|XFER|CLOSER/) ) + { + if ($CLcall_type !~ /IN/) { - @aryA = $sthA->fetchrow_array; - $auto_call_id = "$aryA[0]"; - $CLlead_id = "$aryA[1]"; - $CLphone_number = "$aryA[2]"; - $CLstatus = "$aryA[3]"; - $CLcampaign_id = "$aryA[4]"; - $CLphone_code = "$aryA[5]"; - $CLalt_dial = "$aryA[6]"; - $CLstage = "$aryA[7]"; - $rec_count++; - } - $sthA->finish(); - - $stmtA = "DELETE from vicidial_auto_calls where auto_call_id='$auto_call_id'"; - $affected_rows = $dbhA->do($stmtA); - - $event_string = "| dead call vac deleted|$auto_call_id|$CLlead_id|$KLcallerid[$kill_vac]|$end_epoch|$affected_rows|$KLchannel[$kill_vac]|"; - &event_logger; - - if ($CLstatus !~ /XFER|CLOSER/) - { - $CLstage =~ s/LIVE|-//gi; - if ($CLstage < 0.25) {$CLstage=1;} - - if ($CLstatus =~ /BUSY/) {$CLnew_status = 'B';} - else + if ($CLstatus !~ /XFER|CLOSER/) { - if ($CLstatus =~ /DISCONNECT/) {$CLnew_status = 'DC';} - else {$CLnew_status = 'NA';} - } - if ($CLstatus =~ /LIVE/) {$CLnew_status = 'DROP';} - else - { - $end_epoch = ($now_date_epoch + 1); - $stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed,length_in_sec,end_epoch,alt_dial) values('$CLuniqueid','$CLlead_id','$CLcampaign_id','$SQLdate','$now_date_epoch','$CLnew_status','$CLphone_code','$CLphone_number','VDAD','N','$CLstage','$end_epoch','$CLalt_dial')"; - if($M){print STDERR "\n|$stmtA|\n";} + $stmtA = "DELETE from vicidial_auto_calls where auto_call_id='$auto_call_id'"; $affected_rows = $dbhA->do($stmtA); - $event_string = "| dead NA call added to log $CLuniqueid|$CLlead_id|$CLphone_number|$CLstatus|$CLnew_status|$affected_rows|"; + $event_string = "| dead call vac deleted|$auto_call_id|$CLlead_id|$KLcallerid[$kill_vac]|$end_epoch|$affected_rows|$KLchannel[$kill_vac]|$CLcall_type|$CLdial_timeout|$CLdrop_call_seconds|$call_timeout|$dialtime_log|$dialtime_catch|"; &event_logger; - } + $CLstage =~ s/LIVE|-//gi; + if ($CLstage < 0.25) {$CLstage=1;} - if ($CLlead_id > 0) - { - $stmtA = "UPDATE vicidial_list set status='$CLnew_status' where lead_id='$CLlead_id'"; + if ($CLstatus =~ /BUSY/) {$CLnew_status = 'B';} + else + { + if ($CLstatus =~ /DISCONNECT/) {$CLnew_status = 'DC';} + else {$CLnew_status = 'NA';} + } + if ($CLstatus =~ /LIVE/) {$CLnew_status = 'DROP';} + else + { + $end_epoch = ($now_date_epoch + 1); + $stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed,length_in_sec,end_epoch,alt_dial) values('$CLuniqueid','$CLlead_id','$CLcampaign_id','$SQLdate','$now_date_epoch','$CLnew_status','$CLphone_code','$CLphone_number','VDAD','N','$CLstage','$end_epoch','$CLalt_dial')"; + if($M){print STDERR "\n|$stmtA|\n";} + $affected_rows = $dbhA->do($stmtA); + + $event_string = "| dead NA call added to log $CLuniqueid|$CLlead_id|$CLphone_number|$CLstatus|$CLnew_status|$affected_rows|"; + &event_logger; + + } + + if ($CLlead_id > 0) + { + $stmtA = "UPDATE vicidial_list set status='$CLnew_status' where lead_id='$CLlead_id'"; + $affected_rows = $dbhA->do($stmtA); + + $event_string = "| dead call vac lead marked $CLnew_status|$CLlead_id|$CLphone_number|$CLstatus|"; + &event_logger; + } + + $stmtA = "UPDATE vicidial_live_agents set status='PAUSED',random_id='10' where callerid='$KLcallerid[$kill_vac]';"; $affected_rows = $dbhA->do($stmtA); - $event_string = "| dead call vac lead marked $CLnew_status|$CLlead_id|$CLphone_number|$CLstatus|"; + $event_string = "| dead call vla agent PAUSED $affected_rows|$CLlead_id|$CLphone_number|$CLstatus|"; &event_logger; - } - $stmtA = "UPDATE vicidial_live_agents set status='PAUSED',random_id='10' where callerid='$KLcallerid[$kill_vac]';"; - $affected_rows = $dbhA->do($stmtA); - - $event_string = "| dead call vla agent PAUSED $affected_rows|$CLlead_id|$CLphone_number|$CLstatus|"; - &event_logger; - - if ( ($enable_queuemetrics_logging > 0) && ($CLstatus =~ /LIVE/) ) - { - $dbhB = DBI->connect("DBI:mysql:$queuemetrics_dbname:$queuemetrics_server_ip:3306", "$queuemetrics_login", "$queuemetrics_pass") - or die "Couldn't connect to database: " . DBI->errstr; - - if ($DBX) {print "CONNECTED TO DATABASE: $queuemetrics_server_ip|$queuemetrics_dbname\n";} - - $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$secX',call_id='$KLcallerid[$kill_vac]',queue='$CLcampaign_id',agent='NONE',verb='ABANDON',data1='1',data2='1',data3='$CLstage',serverid='$queuemetrics_log_id';"; - $Baffected_rows = $dbhB->do($stmtB); - - $dbhB->disconnect(); - } - - ##### BEGIN AUTO ALT PHONE DIAL SECTION ##### - ### check to see if campaign has alt_dial enabled - $VD_auto_alt_dial = 'NONE'; - $VD_auto_alt_dial_statuses=''; - $stmtA="SELECT auto_alt_dial,auto_alt_dial_statuses,use_internal_dnc,use_campaign_dnc FROM vicidial_campaigns where campaign_id='$CLcampaign_id';"; - if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $epc_countCAMPDATA=0; - while ($sthArows > $epc_countCAMPDATA) - { - @aryA = $sthA->fetchrow_array; - $VD_auto_alt_dial = "$aryA[0]"; - $VD_auto_alt_dial_statuses = "$aryA[1]"; - $VD_use_internal_dnc = "$aryA[2]"; - $VD_use_campaign_dnc = "$aryA[3]"; - $epc_countCAMPDATA++; - } - $sthA->finish(); - if ( ($VD_auto_alt_dial_statuses =~ / $CLnew_status /) && ($CLlead_id > 0) ) - { - if ( ($VD_auto_alt_dial =~ /ALT_ONLY|ALT_AND_ADDR3|ALT_AND_EXTENDED/) && ($CLalt_dial =~ /NONE|MAIN/) ) + if ( ($enable_queuemetrics_logging > 0) && ($CLstatus =~ /LIVE/) ) { - $alt_dial_skip=0; - $VD_alt_phone=''; - $stmtA="SELECT alt_phone,gmt_offset_now,state,list_id FROM vicidial_list where lead_id='$CLlead_id';"; - if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $epc_countCAMPDATA=0; - while ($sthArows > $epc_countCAMPDATA) - { - @aryA = $sthA->fetchrow_array; - $VD_alt_phone = "$aryA[0]"; - $VD_alt_phone =~ s/\D//gi; - $VD_gmt_offset_now = "$aryA[1]"; - $VD_state = "$aryA[2]"; - $VD_list_id = "$aryA[3]"; - $epc_countCAMPDATA++; - } - $sthA->finish(); - if (length($VD_alt_phone)>5) - { - if ($VD_use_internal_dnc =~ /Y/) - { - $stmtA="SELECT count(*) FROM vicidial_dnc where phone_number='$VD_alt_phone';"; - if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} - $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; - $VD_alt_dnc_count = "$aryA[0]"; - } - $sthA->finish(); - } - else {$VD_alt_dnc_count=0;} - if ($VD_use_campaign_dnc =~ /Y/) - { - $stmtA="SELECT count(*) FROM vicidial_campaign_dnc where phone_number='$VD_alt_phone' and campaign_id='$VD_campaign_id';"; - if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} - $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; - $VD_alt_dnc_count = ($VD_alt_dnc_count + $aryA[0]); - } - $sthA->finish(); - } - if ($VD_alt_dnc_count < 1) - { - $stmtA = "INSERT INTO vicidial_hopper SET lead_id='$CLlead_id',campaign_id='$CLcampaign_id',status='READY',list_id='$VD_list_id',gmt_offset_now='$VD_gmt_offset_now',state='$VD_state',alt_dial='ALT',user='',priority='25';"; - $affected_rows = $dbhA->do($stmtA); - if ($AGILOG) {$agi_string = "-- VDH record inserted: |$affected_rows| |$stmtA|"; &agi_output;} - } - else - {$alt_dial_skip=1;} - } - else - {$alt_dial_skip=1;} - if ($alt_dial_skip > 0) - {$CLalt_dial='ALT';} + $dbhB = DBI->connect("DBI:mysql:$queuemetrics_dbname:$queuemetrics_server_ip:3306", "$queuemetrics_login", "$queuemetrics_pass") + or die "Couldn't connect to database: " . DBI->errstr; + + if ($DBX) {print "CONNECTED TO DATABASE: $queuemetrics_server_ip|$queuemetrics_dbname\n";} + + $stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$secX',call_id='$KLcallerid[$kill_vac]',queue='$CLcampaign_id',agent='NONE',verb='ABANDON',data1='1',data2='1',data3='$CLstage',serverid='$queuemetrics_log_id';"; + $Baffected_rows = $dbhB->do($stmtB); + + $dbhB->disconnect(); } - if ( ( ($VD_auto_alt_dial =~ /ADDR3_ONLY/) && ($CLalt_dial =~ /NONE|MAIN/) ) || ( ($VD_auto_alt_dial =~ /ALT_AND_ADDR3/) && ($CLalt_dial =~ /ALT/) ) ) - { - $addr3_dial_skip=0; - $VD_address3=''; - $stmtA="SELECT address3,gmt_offset_now,state,list_id FROM vicidial_list where lead_id='$CLlead_id';"; - if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $epc_countCAMPDATA=0; - while ($sthArows > $epc_countCAMPDATA) - { - @aryA = $sthA->fetchrow_array; - $VD_address3 = "$aryA[0]"; - $VD_address3 =~ s/\D//gi; - $VD_gmt_offset_now = "$aryA[1]"; - $VD_state = "$aryA[2]"; - $VD_list_id = "$aryA[3]"; - $epc_countCAMPDATA++; - } - $sthA->finish(); - if (length($VD_address3)>5) - { - if ($VD_use_internal_dnc =~ /Y/) - { - $stmtA="SELECT count(*) FROM vicidial_dnc where phone_number='$VD_address3';"; - if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} - $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; - $VD_alt_dnc_count = "$aryA[0]"; - } - $sthA->finish(); - } - else {$VD_alt_dnc_count=0;} - if ($VD_use_campaign_dnc =~ /Y/) - { - $stmtA="SELECT count(*) FROM vicidial_campaign_dnc where phone_number='$VD_address3' and campaign_id='$VD_campaign_id';"; - if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} - $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; - $VD_alt_dnc_count = ($VD_alt_dnc_count + $aryA[0]); - } - $sthA->finish(); - } - if ($VD_alt_dnc_count < 1) - { - $stmtA = "INSERT INTO vicidial_hopper SET lead_id='$CLlead_id',campaign_id='$CLcampaign_id',status='READY',list_id='$VD_list_id',gmt_offset_now='$VD_gmt_offset_now',state='$VD_state',alt_dial='ADDR3',user='',priority='20';"; - $affected_rows = $dbhA->do($stmtA); - if ($AGILOG) {$agi_string = "-- VDH record inserted: |$affected_rows| |$stmtA|"; &agi_output;} - } - else - {$addr3_dial_skip=1;} - } - else - {$addr3_dial_skip=1;} - if ($addr3_dial_skip > 0) - {$CLalt_dial='ADDR3';} - } - if ( ( ($VD_auto_alt_dial =~ /EXTENDED_ONLY/) && ($CLalt_dial =~ /NONE|MAIN/) ) || ( ($VD_auto_alt_dial =~ /ALT_AND_EXTENDED/) && ($CLalt_dial =~ /ALT/) ) || ( ($VD_auto_alt_dial =~ /ADDR3_AND_EXTENDED|ALT_AND_ADDR3_AND_EXTENDED/) && ($CLalt_dial =~ /ADDR3/) ) || ( ($VD_auto_alt_dial =~ /EXTENDED/) && ($CLalt_dial =~ /^X/) && ($CLalt_dial !~ /XLAST/) ) ) - { - if ($CLalt_dial =~ /ADDR3/) {$Xlast=0;} - else - {$Xlast = $CLalt_dial;} - $Xlast =~ s/\D//gi; - if (length($Xlast)<1) - {$Xlast=0;} - $VD_altdialx=''; - $stmtA="SELECT gmt_offset_now,state,list_id FROM vicidial_list where lead_id='$CLlead_id';"; - if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $epc_countCAMPDATA=0; - while ($sthArows > $epc_countCAMPDATA) - { - @aryA = $sthA->fetchrow_array; - $VD_gmt_offset_now = "$aryA[1]"; - $VD_state = "$aryA[2]"; - $VD_list_id = "$aryA[3]"; - $epc_countCAMPDATA++; - } - $sthA->finish(); - $alt_dial_phones_count=0; - $stmtA="SELECT count(*) FROM vicidial_list_alt_phones where lead_id='$CLlead_id';"; - if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} - $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; - $alt_dial_phones_count = "$aryA[0]"; - } - $sthA->finish(); - while ( ($alt_dial_phones_count > 0) && ($alt_dial_phones_count > $Xlast) ) + ##### BEGIN AUTO ALT PHONE DIAL SECTION ##### + ### check to see if campaign has alt_dial enabled + $VD_auto_alt_dial = 'NONE'; + $VD_auto_alt_dial_statuses=''; + $stmtA="SELECT auto_alt_dial,auto_alt_dial_statuses,use_internal_dnc,use_campaign_dnc FROM vicidial_campaigns where campaign_id='$CLcampaign_id';"; + if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $epc_countCAMPDATA=0; + while ($sthArows > $epc_countCAMPDATA) + { + @aryA = $sthA->fetchrow_array; + $VD_auto_alt_dial = "$aryA[0]"; + $VD_auto_alt_dial_statuses = "$aryA[1]"; + $VD_use_internal_dnc = "$aryA[2]"; + $VD_use_campaign_dnc = "$aryA[3]"; + $epc_countCAMPDATA++; + } + $sthA->finish(); + if ( ($VD_auto_alt_dial_statuses =~ / $CLnew_status /) && ($CLlead_id > 0) ) + { + if ( ($VD_auto_alt_dial =~ /ALT_ONLY|ALT_AND_ADDR3|ALT_AND_EXTENDED/) && ($CLalt_dial =~ /NONE|MAIN/) ) { - $Xlast++; - $stmtA="SELECT alt_phone_id,phone_number,active FROM vicidial_list_alt_phones where lead_id='$CLlead_id' and alt_phone_count='$Xlast';"; + $alt_dial_skip=0; + $VD_alt_phone=''; + $stmtA="SELECT alt_phone,gmt_offset_now,state,list_id FROM vicidial_list where lead_id='$CLlead_id';"; if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; - if ($sthArows > 0) + $epc_countCAMPDATA=0; + while ($sthArows > $epc_countCAMPDATA) { @aryA = $sthA->fetchrow_array; - $VD_altdial_id = "$aryA[0]"; - $VD_altdial_phone = "$aryA[1]"; - $VD_altdial_active = "$aryA[2]"; + $VD_alt_phone = "$aryA[0]"; + $VD_alt_phone =~ s/\D//gi; + $VD_gmt_offset_now = "$aryA[1]"; + $VD_state = "$aryA[2]"; + $VD_list_id = "$aryA[3]"; + $epc_countCAMPDATA++; } - else - {$Xlast=9999999999;} $sthA->finish(); - - if ($VD_altdial_active =~ /Y/) + if (length($VD_alt_phone)>5) { if ($VD_use_internal_dnc =~ /Y/) { - $stmtA="SELECT count(*) FROM vicidial_dnc where phone_number='$VD_altdial_phone';"; + $stmtA="SELECT count(*) FROM vicidial_dnc where phone_number='$VD_alt_phone';"; if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -1302,7 +1170,7 @@ while($one_day_interval > 0) else {$VD_alt_dnc_count=0;} if ($VD_use_campaign_dnc =~ /Y/) { - $stmtA="SELECT count(*) FROM vicidial_campaign_dnc where phone_number='$VD_altdial_phone' and campaign_id='$VD_campaign_id';"; + $stmtA="SELECT count(*) FROM vicidial_campaign_dnc where phone_number='$VD_alt_phone' and campaign_id='$VD_campaign_id';"; if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -1316,28 +1184,201 @@ while($one_day_interval > 0) } if ($VD_alt_dnc_count < 1) { - if ($alt_dial_phones_count == $Xlast) - {$Xlast = 'LAST';} - $stmtA = "INSERT INTO vicidial_hopper SET lead_id='$CLlead_id',campaign_id='$CLcampaign_id',status='READY',list_id='$VD_list_id',gmt_offset_now='$VD_gmt_offset_now',state='$VD_state',alt_dial='X$Xlast',user='',priority='15';"; + $stmtA = "INSERT INTO vicidial_hopper SET lead_id='$CLlead_id',campaign_id='$CLcampaign_id',status='READY',list_id='$VD_list_id',gmt_offset_now='$VD_gmt_offset_now',state='$VD_state',alt_dial='ALT',user='',priority='25';"; $affected_rows = $dbhA->do($stmtA); - if ($AGILOG) {$agi_string = "-- VDH record inserted: |$affected_rows| |$stmtA|X$Xlast|$VD_altdial_id|"; &agi_output;} - $Xlast=9999999999; + if ($AGILOG) {$agi_string = "-- VDH record inserted: |$affected_rows| |$stmtA|"; &agi_output;} } else - {if ($AGILOG) {$agi_string = "-- VDH alt dial is DNC|X$Xlast|$VD_altdial_phone|"; &agi_output;}} + {$alt_dial_skip=1;} + } + else + {$alt_dial_skip=1;} + if ($alt_dial_skip > 0) + {$CLalt_dial='ALT';} + } + if ( ( ($VD_auto_alt_dial =~ /ADDR3_ONLY/) && ($CLalt_dial =~ /NONE|MAIN/) ) || ( ($VD_auto_alt_dial =~ /ALT_AND_ADDR3/) && ($CLalt_dial =~ /ALT/) ) ) + { + $addr3_dial_skip=0; + $VD_address3=''; + $stmtA="SELECT address3,gmt_offset_now,state,list_id FROM vicidial_list where lead_id='$CLlead_id';"; + if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $epc_countCAMPDATA=0; + while ($sthArows > $epc_countCAMPDATA) + { + @aryA = $sthA->fetchrow_array; + $VD_address3 = "$aryA[0]"; + $VD_address3 =~ s/\D//gi; + $VD_gmt_offset_now = "$aryA[1]"; + $VD_state = "$aryA[2]"; + $VD_list_id = "$aryA[3]"; + $epc_countCAMPDATA++; + } + $sthA->finish(); + if (length($VD_address3)>5) + { + if ($VD_use_internal_dnc =~ /Y/) + { + $stmtA="SELECT count(*) FROM vicidial_dnc where phone_number='$VD_address3';"; + if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} + $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; + $VD_alt_dnc_count = "$aryA[0]"; + } + $sthA->finish(); + } + else {$VD_alt_dnc_count=0;} + if ($VD_use_campaign_dnc =~ /Y/) + { + $stmtA="SELECT count(*) FROM vicidial_campaign_dnc where phone_number='$VD_address3' and campaign_id='$VD_campaign_id';"; + if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} + $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; + $VD_alt_dnc_count = ($VD_alt_dnc_count + $aryA[0]); + } + $sthA->finish(); + } + if ($VD_alt_dnc_count < 1) + { + $stmtA = "INSERT INTO vicidial_hopper SET lead_id='$CLlead_id',campaign_id='$CLcampaign_id',status='READY',list_id='$VD_list_id',gmt_offset_now='$VD_gmt_offset_now',state='$VD_state',alt_dial='ADDR3',user='',priority='20';"; + $affected_rows = $dbhA->do($stmtA); + if ($AGILOG) {$agi_string = "-- VDH record inserted: |$affected_rows| |$stmtA|"; &agi_output;} + } + else + {$addr3_dial_skip=1;} + } + else + {$addr3_dial_skip=1;} + if ($addr3_dial_skip > 0) + {$CLalt_dial='ADDR3';} + } + if ( ( ($VD_auto_alt_dial =~ /EXTENDED_ONLY/) && ($CLalt_dial =~ /NONE|MAIN/) ) || ( ($VD_auto_alt_dial =~ /ALT_AND_EXTENDED/) && ($CLalt_dial =~ /ALT/) ) || ( ($VD_auto_alt_dial =~ /ADDR3_AND_EXTENDED|ALT_AND_ADDR3_AND_EXTENDED/) && ($CLalt_dial =~ /ADDR3/) ) || ( ($VD_auto_alt_dial =~ /EXTENDED/) && ($CLalt_dial =~ /^X/) && ($CLalt_dial !~ /XLAST/) ) ) + { + if ($CLalt_dial =~ /ADDR3/) {$Xlast=0;} + else + {$Xlast = $CLalt_dial;} + $Xlast =~ s/\D//gi; + if (length($Xlast)<1) + {$Xlast=0;} + $VD_altdialx=''; + $stmtA="SELECT gmt_offset_now,state,list_id FROM vicidial_list where lead_id='$CLlead_id';"; + if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $epc_countCAMPDATA=0; + while ($sthArows > $epc_countCAMPDATA) + { + @aryA = $sthA->fetchrow_array; + $VD_gmt_offset_now = "$aryA[1]"; + $VD_state = "$aryA[2]"; + $VD_list_id = "$aryA[3]"; + $epc_countCAMPDATA++; + } + $sthA->finish(); + $alt_dial_phones_count=0; + $stmtA="SELECT count(*) FROM vicidial_list_alt_phones where lead_id='$CLlead_id';"; + if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} + $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; + $alt_dial_phones_count = "$aryA[0]"; + } + $sthA->finish(); + + while ( ($alt_dial_phones_count > 0) && ($alt_dial_phones_count > $Xlast) ) + { + $Xlast++; + $stmtA="SELECT alt_phone_id,phone_number,active FROM vicidial_list_alt_phones where lead_id='$CLlead_id' and alt_phone_count='$Xlast';"; + if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} + $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; + $VD_altdial_id = "$aryA[0]"; + $VD_altdial_phone = "$aryA[1]"; + $VD_altdial_active = "$aryA[2]"; + } + else + {$Xlast=9999999999;} + $sthA->finish(); + + if ($VD_altdial_active =~ /Y/) + { + if ($VD_use_internal_dnc =~ /Y/) + { + $stmtA="SELECT count(*) FROM vicidial_dnc where phone_number='$VD_altdial_phone';"; + if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} + $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; + $VD_alt_dnc_count = "$aryA[0]"; + } + $sthA->finish(); + } + else {$VD_alt_dnc_count=0;} + if ($VD_use_campaign_dnc =~ /Y/) + { + $stmtA="SELECT count(*) FROM vicidial_campaign_dnc where phone_number='$VD_altdial_phone' and campaign_id='$VD_campaign_id';"; + if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} + $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; + $VD_alt_dnc_count = ($VD_alt_dnc_count + $aryA[0]); + } + $sthA->finish(); + } + if ($VD_alt_dnc_count < 1) + { + if ($alt_dial_phones_count == $Xlast) + {$Xlast = 'LAST';} + $stmtA = "INSERT INTO vicidial_hopper SET lead_id='$CLlead_id',campaign_id='$CLcampaign_id',status='READY',list_id='$VD_list_id',gmt_offset_now='$VD_gmt_offset_now',state='$VD_state',alt_dial='X$Xlast',user='',priority='15';"; + $affected_rows = $dbhA->do($stmtA); + if ($AGILOG) {$agi_string = "-- VDH record inserted: |$affected_rows| |$stmtA|X$Xlast|$VD_altdial_id|"; &agi_output;} + $Xlast=9999999999; + } + else + {if ($AGILOG) {$agi_string = "-- VDH alt dial is DNC|X$Xlast|$VD_altdial_phone|"; &agi_output;}} + } } } } + ##### END AUTO ALT PHONE DIAL SECTION ##### + + + + + } + else + { + $event_string = "| dead call vac XFERd do nothing|$CLlead_id|$CLphone_number|$CLstatus|"; + &event_logger; } - ##### END AUTO ALT PHONE DIAL SECTION ##### - - - - } else { - $event_string = "| dead call vac XFERd do nothing|$CLlead_id|$CLphone_number|$CLstatus|"; + $event_string = "| dead call vac INBOUND do nothing|$CLlead_id|$CLphone_number|$CLstatus|"; &event_logger; } } diff --git a/agc_2-X/trunk/bin/AST_VDremote_agents.pl b/agc_2-X/trunk/bin/AST_VDremote_agents.pl index 7689e552..20a83cd0 100644 --- a/agc_2-X/trunk/bin/AST_VDremote_agents.pl +++ b/agc_2-X/trunk/bin/AST_VDremote_agents.pl @@ -469,7 +469,7 @@ while($one_day_interval > 0) } $sthA->finish(); - $stmtA = "INSERT INTO vicidial_live_agents (user,server_ip,conf_exten,extension,status,campaign_id,random_id,last_call_time,last_update_time,last_call_finish,closer_campaigns,channel,uniqueid,callerid,user_level,comments) values('$DBremote_user[$h]','$server_ip','$DBremote_conf_exten[$h]','R/$DBremote_user[$h]','READY','$DBremote_campaign[$h]','$DBremote_random[$h]','$SQLdate','$tsSQLdate','$SQLdate','$DBremote_closer[$h]','','','','$DBuser_level[$h]','REMOTE');"; + $stmtA = "INSERT INTO vicidial_live_agents (user,server_ip,conf_exten,extension,status,campaign_id,random_id,last_call_time,last_update_time,last_call_finish,closer_campaigns,channel,uniqueid,callerid,user_level,comments) values('$DBremote_user[$h]','$server_ip','$DBremote_conf_exten[$h]','R/$DBremote_user[$h]','READY','$DBremote_campaign[$h]','$DBremote_random[$h]','$SQLdate','$FDtsSQLdate','$SQLdate','$DBremote_closer[$h]','','','','$DBuser_level[$h]','REMOTE');"; $affected_rows = $dbhA->do($stmtA); if ($DBX) {print STDERR "$DBremote_user[$h] NEW INSERT\n";} if ($TESTrun > 0) @@ -769,6 +769,17 @@ $now_date = "$year-$mon-$mday $hour:$min:$sec"; $SQLdate = "$year-$mon-$mday $hour:$min:$sec"; $filedate = "$year-$mon-$mday"; +$FDtarget = ($secX + 10); +($Fsec,$Fmin,$Fhour,$Fmday,$Fmon,$Fyear,$Fwday,$Fyday,$Fisdst) = localtime($FDtarget); +$Fyear = ($Fyear + 1900); +$Fmon++; +if ($Fmon < 10) {$Fmon = "0$Fmon";} +if ($Fmday < 10) {$Fmday = "0$Fmday";} +if ($Fhour < 10) {$Fhour = "0$Fhour";} +if ($Fmin < 10) {$Fmin = "0$Fmin";} +if ($Fsec < 10) {$Fsec = "0$Fsec";} + $FDtsSQLdate = "$Fyear$Fmon$Fmday$Fhour$Fmin$Fsec"; + $BDtarget = ($secX - 10); ($Bsec,$Bmin,$Bhour,$Bmday,$Bmon,$Byear,$Bwday,$Byday,$Bisdst) = localtime($BDtarget); $Byear = ($Byear + 1900); diff --git a/agc_2-X/trunk/bin/FastAGI_log.pl b/agc_2-X/trunk/bin/FastAGI_log.pl index e839b218..fc90b0a6 100644 --- a/agc_2-X/trunk/bin/FastAGI_log.pl +++ b/agc_2-X/trunk/bin/FastAGI_log.pl @@ -820,11 +820,11 @@ sub process_request { {$VDCLSQL_update = "term_reason='CALLER',";} else { - if ( ($VD_term_reason !~ /AGENT|CALLER|QUEUETIMEOUT/) && ( ($VD_user =~ /VDAD|VDCL/) || (length($VD_user) < 1) ) ) + if ( ($VD_term_reason !~ /AGENT|CALLER|QUEUETIMEOUT|AFTERHOURS|HOLDRECALLXFER|HOLDTIME/) && ( ($VD_user =~ /VDAD|VDCL/) || (length($VD_user) < 1) ) ) {$VDCLSQL_term_reason = "term_reason='ABANDON',";} else { - if ($VD_term_reason !~ /AGENT|CALLER|QUEUETIMEOUT/) + if ($VD_term_reason !~ /AGENT|CALLER|QUEUETIMEOUT|AFTERHOURS|HOLDRECALLXFER|HOLDTIME/) {$VDCLSQL_term_reason = "term_reason='CALLER',";} else {$VDCLSQL_term_reason = '';} diff --git a/agc_2-X/trunk/docs/Inbound_VDAC_IVR.txt b/agc_2-X/trunk/docs/Inbound_VDAC_IVR.txt index c01b65eb..9958eb7b 100644 --- a/agc_2-X/trunk/docs/Inbound_VDAC_IVR.txt +++ b/agc_2-X/trunk/docs/Inbound_VDAC_IVR.txt @@ -6,6 +6,7 @@ The agi-VDAD_inbound_calltime_check.agi script does a check for the calltime sch A log of the calls going into this agi-VDAD_inbound_calltime_check.agi script is also inserted into the live_inbound_log table. +The agi-VDAD_inbound_calltime_check.agi script can also be used to log the progression of a call through an IVR if you place it at major points in your IVR dialplan. The third field that you can define allows you to set a note or comment that is placed into the database when the call goes through that step. The example below shows how to do a very simple IVR before sending to a queue asking if the caller wants English, Spanish, French or German language service. @@ -34,7 +35,7 @@ exten => 7275551111,1,Goto(TEST_IN,s,1) [TEST_IN] -exten => s,1,AGI(agi-VDAD_inbound_calltime_check.agi,TEST_IN-----YES) +exten => s,1,AGI(agi-VDAD_inbound_calltime_check.agi,TEST_IN-----YES-----START) exten => s,2,Background(test_in_menu) exten => s,n,WaitExten(10) exten => s,n,Background(test_in_menu) diff --git a/agc_2-X/trunk/docs/QUEUEMETRICS.txt b/agc_2-X/trunk/docs/QUEUEMETRICS.txt index 41fc92ca..2689ca8f 100644 --- a/agc_2-X/trunk/docs/QUEUEMETRICS.txt +++ b/agc_2-X/trunk/docs/QUEUEMETRICS.txt @@ -156,6 +156,8 @@ call actions before going to agent - used by agi-VDAD_ALL_inbound/outbound scrip ENTERQUEUE(url|callerid) CONNECT(holdtime) EXITWITHTIMEOUT(position) + EXITWITHKEY(key|position) + TRANSFER(extension|context|holdtime|calltime) call actions before going to agent - used by AST_VDauto_dial.pl ABANDON(position|origposition|waittime) @@ -167,7 +169,8 @@ call actions after going to agent - used by vicidial.php, vdc_db_query.php and F not used in vicidial - - TRANSFER(extension,context) + EXITEMPTY(position|origposition|waittime) + AGENTDUMP diff --git a/agc_2-X/trunk/docs/REQUIRED_APPS_INSTALL.txt b/agc_2-X/trunk/docs/REQUIRED_APPS_INSTALL.txt index 9f6f62fa..fd52401b 100644 --- a/agc_2-X/trunk/docs/REQUIRED_APPS_INSTALL.txt +++ b/agc_2-X/trunk/docs/REQUIRED_APPS_INSTALL.txt @@ -266,9 +266,9 @@ vi /usr/local/lib/php.ini cd /usr/local -wget http://bart.eaccelerator.net/source/0.9.5/eaccelerator-0.9.5.zip -unzip eaccelerator-0.9.5.zip -cd eaccelerator-0.9.5 +wget http://bart.eaccelerator.net/source/0.9.5.3/eaccelerator-0.9.5.3.zip +unzip eaccelerator-0.9.5.3.zip +cd eaccelerator-0.9.5.3 export PHP_PREFIX="/usr/local" $PHP_PREFIX/bin/phpize ./configure --enable-eaccelerator=shared --with-php-config=$PHP_PREFIX/bin/php-config @@ -279,7 +279,7 @@ vi /usr/local/lib/php.ini Add the following lines to the dynamic extensions section of php.ini: (you may need to change the extension location depending on your install of php) -zend_extension="../../../usr/local/eaccelerator-0.9.5/modules/eaccelerator.so" +zend_extension="../../../usr/local/eaccelerator-0.9.5.3/modules/eaccelerator.so" eaccelerator.shm_size="48" eaccelerator.cache_dir="/tmp/eaccelerator" eaccelerator.enable="1" diff --git a/agc_2-X/trunk/docs/SCRATCH_INSTALL.txt b/agc_2-X/trunk/docs/SCRATCH_INSTALL.txt index 0f24d0ff..5f5f6e50 100644 --- a/agc_2-X/trunk/docs/SCRATCH_INSTALL.txt +++ b/agc_2-X/trunk/docs/SCRATCH_INSTALL.txt @@ -973,7 +973,7 @@ with the following patch: - patch -p1 ./codecs/gsm/Makefile 1.2-gsm-gcc4.2.patch *OPTIONAL*(1.2.14 thru 1.2.30.2) rewrite of waitforsilence - - wget http://www.eflo.net/files/app_waitforsilence.c + - wget http://downloads.vicidial.com/asterisk-patches/app_waitforsilence.c - mv -f app_waitforsilence.c apps/app_waitforsilence.c *OPTIONAL* shorter enter and leave sounds for meetme diff --git a/agc_2-X/trunk/www/agc/vdc_db_query.php b/agc_2-X/trunk/www/agc/vdc_db_query.php index a4886f59..d4d2e634 100644 --- a/agc_2-X/trunk/www/agc/vdc_db_query.php +++ b/agc_2-X/trunk/www/agc/vdc_db_query.php @@ -1333,13 +1333,13 @@ if ($stage == "end") $four_hours_ago = date("Y-m-d H:i:s", mktime(date("H")-4,date("i"),date("s"),date("m"),date("d"),date("Y"))); ##### look for the start epoch in the vicidial_closer_log table - $stmt="SELECT start_epoch,term_reason,closecallid FROM vicidial_closer_log where phone_number='$phone_number' and lead_id='$lead_id' and user='$user' and call_date > \"$four_hours_ago\" order by closecallid desc limit 1;"; + $stmt="SELECT start_epoch,term_reason,closecallid,campaign_id FROM vicidial_closer_log where phone_number='$phone_number' and lead_id='$lead_id' and user='$user' and call_date > \"$four_hours_ago\" order by closecallid desc limit 1;"; $VDIDselect = "VDCL_LID $lead_id $phone_number $user $four_hours_ago"; } else { ##### look for the start epoch in the vicidial_log table - $stmt="SELECT start_epoch,term_reason,uniqueid FROM vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id' order by call_date desc limit 1;"; + $stmt="SELECT start_epoch,term_reason,uniqueid,campaign_id FROM vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id' order by call_date desc limit 1;"; $VDIDselect = "VDL_UIDLID $uniqueid $lead_id"; } $rslt=mysql_query($stmt, $link); @@ -1351,6 +1351,7 @@ if ($stage == "end") $start_epoch = $row[0]; $VDterm_reason = $row[1]; $VDvicidial_id = $row[2]; + $VDcampaign_id = $row[3]; $length_in_sec = ($StarTtime - $start_epoch); } else @@ -1365,7 +1366,7 @@ if ($stage == "end") fclose($fp); ##### start epoch in the vicidial_log table, couldn't find one in vicidial_closer_log - $stmt="SELECT start_epoch,term_reason FROM vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id' order by call_date desc limit 1;"; + $stmt="SELECT start_epoch,term_reason,campaign_id FROM vicidial_log where uniqueid='$uniqueid' and lead_id='$lead_id' order by call_date desc limit 1;"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $VM_mancall_ct = mysql_num_rows($rslt); @@ -1374,6 +1375,7 @@ if ($stage == "end") $row=mysql_fetch_row($rslt); $start_epoch = $row[0]; $VDterm_reason = $row[1]; + $VDcampaign_id = $row[2]; $length_in_sec = ($StarTtime - $start_epoch); } else @@ -1384,6 +1386,8 @@ if ($stage == "end") } else {$length_in_sec = ($StarTtime - $start_epoch);} + if (strlen($VDcampaign_id)<1) {$VDcampaign_id = $campaign;} + $four_hours_ago = date("Y-m-d H:i:s", mktime(date("H")-4,date("i"),date("s"),date("m"),date("d"),date("Y"))); if ($VLA_inOUT == 'INBOUND') @@ -1695,7 +1699,7 @@ if ($stage == "end") if ($caller_complete < 1) { - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MDnextCID',queue='$campaign',agent='Agent/$user',verb='COMPLETEAGENT',data1='$CLstage',data2='$length_in_sec',data3='1',serverid='$queuemetrics_log_id';"; + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MDnextCID',queue='$VDcampaign_id',agent='Agent/$user',verb='COMPLETEAGENT',data1='$CLstage',data2='$length_in_sec',data3='1',serverid='$queuemetrics_log_id';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $linkB); $affected_rows = mysql_affected_rows($linkB); @@ -1710,7 +1714,7 @@ if ($stage == "end") } ### delete call record from vicidial_auto_calls - $stmt = "DELETE from vicidial_auto_calls where lead_id='$lead_id' and campaign_id='$campaign' and uniqueid='$uniqueid';"; + $stmt = "DELETE from vicidial_auto_calls where lead_id='$lead_id' and campaign_id='$VDcampaign_id' and uniqueid='$uniqueid';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); @@ -1756,14 +1760,14 @@ if ($stage == "end") $CLstage = preg_replace("/XFER|-/",'',$CLstage); if ($CLstage < 0.25) {$CLstage=0;} - $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MDnextCID',queue='$campaign',agent='Agent/$user',verb='COMPLETEAGENT',data1='$CLstage',data2='$length_in_sec',data3='1',serverid='$queuemetrics_log_id';"; + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MDnextCID',queue='$VDcampaign_id',agent='Agent/$user',verb='COMPLETEAGENT',data1='$CLstage',data2='$length_in_sec',data3='1',serverid='$queuemetrics_log_id';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $linkB); $affected_rows = mysql_affected_rows($linkB); } # $stmt = "DELETE from vicidial_auto_calls lead_id='$lead_id' and campaign_id='$campaign' and uniqueid='$uniqueid';"; - $stmt = "DELETE from vicidial_auto_calls lead_id='$lead_id' and campaign_id='$campaign' and callerid LIKE \"M%\";"; + $stmt = "DELETE from vicidial_auto_calls lead_id='$lead_id' and campaign_id='$VDcampaign_id' and callerid LIKE \"M%\";"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); diff --git a/agc_2-X/trunk/www/agc/vicidial.php b/agc_2-X/trunk/www/agc/vicidial.php index 10a24182..bb4cd8a2 100644 --- a/agc_2-X/trunk/www/agc/vicidial.php +++ b/agc_2-X/trunk/www/agc/vicidial.php @@ -197,10 +197,11 @@ # 81012-1729 - Added INBOUND_MAN dial method to allow manual list dialing and inbound calls # 81013-1644 - Fixed bug in leave 3way for manual dial fronters # 81015-0405 - Fixed bug related to hangups on 3way calls +# 81016-0703 - Changed leave 3way to allow function at any time transfer-conf is available # -$version = '2.0.5-175'; -$build = '81015-0405'; +$version = '2.0.5-176'; +$build = '81016-0703'; require("dbconnect.php"); @@ -5158,7 +5159,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} document.vicidial_form.xferchannel.value = ""; lastxferchannel=''; - document.getElementById("Leave3WayCall").innerHTML ="\"LEAVE"; + // document.getElementById("Leave3WayCall").innerHTML ="\"LEAVE"; document.getElementById("DialWithCustomer").innerHTML ="\"Dial"; @@ -7354,7 +7355,7 @@ Your Status:
Calls Dialing:   DIAL OVERRIDE   - LEAVE 3-WAY CALL + LEAVE 3-WAY CALL Dial Blind Transfer D1 D2 diff --git a/agc_2-X/trunk/www/vicidial/AST_CLOSERstats.php b/agc_2-X/trunk/www/vicidial/AST_CLOSERstats.php index 18093bc9..b00eee31 100644 --- a/agc_2-X/trunk/www/vicidial/AST_CLOSERstats.php +++ b/agc_2-X/trunk/www/vicidial/AST_CLOSERstats.php @@ -14,6 +14,7 @@ # 80430-1920 - Added Customer hangup cause stats # 80709-0331 - Added time stats to call statuses # 80722-2149 - Added Status Category stats +# 81015-0705 - Added IVR calls count # require("dbconnect.php"); @@ -188,7 +189,13 @@ $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $row=mysql_fetch_row($rslt); +$stmt="select count(*) from live_inbound_log where start_time >= '$query_date_BEGIN' and start_time <= '$query_date_END' and comment_a='" . mysql_real_escape_string($group) . "' and comment_b='START';"; +$rslt=mysql_query($stmt, $link); +if ($DB) {echo "$stmt\n";} +$rowx=mysql_fetch_row($rslt); + $TOTALcalls = sprintf("%10s", $row[0]); +$IVRcalls = sprintf("%10s", $rowx[0]); $TOTALsec = $row[1]; if ( ($row[0] < 1) or ($TOTALsec < 1) ) {$average_call_seconds = ' 0';} @@ -201,6 +208,7 @@ else echo "Total calls taken in to this In-Group: $TOTALcalls\n"; echo "Average Call Length for all Calls: $average_call_seconds seconds\n"; +echo "Calls taken into the IVR for this In-Group: $IVRcalls\n"; echo "\n"; echo "---------- DROPS\n"; diff --git a/agc_2-X/trunk/www/vicidial/AST_timeonVDAD.php b/agc_2-X/trunk/www/vicidial/AST_timeonVDAD.php index f569bfad..2558d4d3 100644 --- a/agc_2-X/trunk/www/vicidial/AST_timeonVDAD.php +++ b/agc_2-X/trunk/www/vicidial/AST_timeonVDAD.php @@ -11,6 +11,7 @@ # - Added required user/pass to gain access to this page # 61114-2004 - Changed to display CLOSER and DEFAULT, added trunk shortage # 80422-0305 - Added phone login to display, lower font size to 2 +# 81013-2227 - Fixed Remote Agent display bug # header ("Content-type: text/html; charset=utf-8"); @@ -176,6 +177,13 @@ $talking_to_print = mysql_num_rows($rslt); while ($i < $talking_to_print) { $phone[$i]=' '; + if (eregi("R/",$Sextension[$i])) + { + $protocol = 'EXTERNAL'; + $dialplan = eregi_replace('R/',"",$Sextension[$i]); + $dialplan = eregi_replace("\@.*",'',$dialplan); + $exten = "dialplan_number='$dialplan'"; + } if (eregi("Local/",$Sextension[$i])) { $protocol = 'EXTERNAL';