From 01244bd2be6cb1884486d464de9ecae2c1ddab63 Mon Sep 17 00:00:00 2001 From: mattf Date: Thu, 15 Feb 2007 18:09:13 +0000 Subject: [PATCH] added COMPLETEAGENT/COMPLETECALLER/CALLSTATUS queue_log entries to vicidial.php, vdc_db_query.php and FastAGI_log.pl git-svn-id: svn://192.168.202.10@526 3d104415-ff17-0410-8863-d5cf3c621b8a --- bin/AST_VDauto_dial.pl | 146 +++++++++++++++++++++++++++---- bin/FastAGI_log.pl | 182 +++++++++++++++++++++++---------------- docs/QUEUEMETRICS.txt | 17 +++- www/agc/vdc_db_query.php | 182 +++++++++++++++++++++++++++++---------- www/agc/vicidial.php | 10 ++- 5 files changed, 398 insertions(+), 139 deletions(-) diff --git a/bin/AST_VDauto_dial.pl b/bin/AST_VDauto_dial.pl index bf5c0876..9ff0ab44 100644 --- a/bin/AST_VDauto_dial.pl +++ b/bin/AST_VDauto_dial.pl @@ -25,7 +25,7 @@ # It is good practice to keep this program running by placing the associated # KEEPALIVE script running every minute to ensure this program is always running # -# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# Copyright (C) 2007 Matt Florell LICENSE: GPLv2 # # CHANGELOG: # 50125-1201 - Changed dial timeout to 120 seconds from 180 seconds @@ -60,6 +60,7 @@ # 70131-1550 - Fixed Manual dialing trunk shortage bug # 70205-1414 - Added code for last called date update # 70207-1031 - Fixed Tally-only-available bug with customer hangups +# 70215-1123 - Added queue_log ABANDON logging # @@ -214,6 +215,29 @@ $sthA->finish(); $event_string='LOGGED INTO MYSQL SERVER ON 1 CONNECTION|'; &event_logger; +############################################# +##### START QUEUEMETRICS LOGGING LOOKUP ##### +$stmtA = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; +$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; +$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; +$sthArows=$sthA->rows; +$rec_count=0; +while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $enable_queuemetrics_logging = "$aryA[0]"; + $queuemetrics_server_ip = "$aryA[1]"; + $queuemetrics_dbname = "$aryA[2]"; + $queuemetrics_login= "$aryA[3]"; + $queuemetrics_pass = "$aryA[4]"; + $queuemetrics_log_id = "$aryA[5]"; + $rec_count++; + } +$sthA->finish(); +##### END QUEUEMETRICS LOGGING LOOKUP ##### +########################################### + + $one_day_interval = 12; # 1 month loops for one year while($one_day_interval > 0) { @@ -890,7 +914,7 @@ while($one_day_interval > 0) { $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 FROM vicidial_auto_calls where callerid='$KLcallerid[$kill_vac]'"; + $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; @@ -906,12 +930,12 @@ while($one_day_interval > 0) $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'"; - # $stmtA = "UPDATE vicidial_auto_calls set status='PAUSED' where callerid='$KLcallerid[$kill_vac]'"; $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]|"; @@ -928,14 +952,29 @@ while($one_day_interval > 0) if ($CLstatus =~ /LIVE/) {$CLnew_status = 'DROP';} else { + $CLstage =~ s/LIVE|-//gi; + if ($CLstage < 0.25) {$CLstage=1;} + $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) values('$CLuniqueid','$CLlead_id','$CLcampaign_id','$SQLdate','$now_date_epoch','$CLnew_status','$CLphone_code','$CLphone_number','VDAD','N','1','$end_epoch')"; + $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) values('$CLuniqueid','$CLlead_id','$CLcampaign_id','$SQLdate','$now_date_epoch','$CLnew_status','$CLphone_code','$CLphone_number','VDAD','N','$CLstage','$end_epoch')"; 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 ($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='$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(); + } } $stmtA = "UPDATE vicidial_list set status='$CLnew_status' where lead_id='$CLlead_id'"; @@ -1099,7 +1138,7 @@ while($one_day_interval > 0) } - ### delete call records that are SENT for over 3 minutes + ### delete call records that are SENT for over 2 minutes $stmtA = "DELETE FROM vicidial_auto_calls where server_ip='$server_ip' and call_time < '$XDSQLdate' and status NOT IN('XFER','CLOSER','LIVE')"; $affected_rows = $dbhA->do($stmtA); @@ -1125,18 +1164,73 @@ while($one_day_interval > 0) $sthA->finish(); } - ### delete call records that are LIVE and not updated for over 10 seconds - $stmtA = "DELETE FROM vicidial_auto_calls where server_ip='$server_ip' and last_update_time < '$BDtsSQLdate' and status IN('LIVE');"; - $affected_rows = $dbhA->do($stmtA); - - $event_string = "| lagged call vdac call DELETED $affected_rows|$BDtsSQLdate|"; - &event_logger; - - if ($affected_rows > 0) + ### find call records that are LIVE and not updated for over 10 seconds + $stmtA = "SELECT auto_call_id,lead_id,phone_number,status,campaign_id,phone_code,alt_dial,stage,callerid,uniqueid from vicidial_auto_calls where server_ip='$server_ip' and last_update_time < '$BDtsSQLdate' and status IN('LIVE');"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) { - $jam_string = "| lagged call vdac call DELETED $affected_rows|$BDtsSQLdate|"; - &jam_event_logger; + @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]"; + $CLcallerid = "$aryA[8]"; + $CLuniqueid = "$aryA[9]"; + $rec_count++; } + $sthA->finish(); + + ### delete call records that are LIVE and not updated for over 10 seconds + $rec_count=0; + while ($sthArows > $rec_count) + { + $stmtA = "DELETE from vicidial_auto_calls where auto_call_id='$auto_call_id'"; + $affected_rows = $dbhA->do($stmtA); + + $event_string = "| lagged call vdac call DELETED $affected_rows|$BDtsSQLdate|"; + &event_logger; + + if ($affected_rows > 0) + { + $jam_string = "| lagged call vdac call DELETED $affected_rows|$BDtsSQLdate|"; + &jam_event_logger; + + $CLstage =~ s/LIVE|-//gi; + if ($CLstage < 0.25) {$CLstage=1;} + + $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) values('$CLuniqueid','$CLlead_id','$CLcampaign_id','$SQLdate','$now_date_epoch','DROP','$CLphone_code','$CLphone_number','VDAD','N','$CLstage','$end_epoch')"; + 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|DROP|$affected_rows|"; + &event_logger; + + 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='$secX',call_id='$CLcallerid',queue='$CLcampaign_id',agent='NONE',verb='ABANDON',data1='1',data2='1',data3='$CLstage',serverid='$queuemetrics_log_id';"; + $Baffected_rows = $dbhB->do($stmtB); + + $dbhB->disconnect(); + } + + } + + $rec_count++; + } + $sthA->finish(); if ($LUcount > 0) @@ -1194,6 +1288,28 @@ while($one_day_interval > 0) } $sthA->finish(); + ############################################# + ##### START QUEUEMETRICS LOGGING LOOKUP ##### + $stmtA = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $enable_queuemetrics_logging = "$aryA[0]"; + $queuemetrics_server_ip = "$aryA[1]"; + $queuemetrics_dbname = "$aryA[2]"; + $queuemetrics_login= "$aryA[3]"; + $queuemetrics_pass = "$aryA[4]"; + $queuemetrics_log_id = "$aryA[5]"; + $rec_count++; + } + $sthA->finish(); + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + ### delete call records that are LIVE for over 10 minutes $stmtA = "DELETE FROM vicidial_auto_calls where server_ip='$server_ip' and call_time < '$TDSQLdate' and status NOT IN('XFER','CLOSER')"; $affected_rows = $dbhA->do($stmtA); diff --git a/bin/FastAGI_log.pl b/bin/FastAGI_log.pl index 94074f8f..4f41b2c7 100644 --- a/bin/FastAGI_log.pl +++ b/bin/FastAGI_log.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl # -# FastAGI_log.pl version 0.01 *DBI-version* +# FastAGI_log.pl version 2.0.3 *DBI-version* # # Experimental Deamon using perl Net::Server that runs as FastAGI to reduce load # replaces the following AGI scripts: @@ -26,11 +26,12 @@ # exten => h,2,DeadAGI(agi://127.0.0.1:4577/VD_hangup--HVcauses--PRI-----NODEBUG-----${HANGUPCAUSE}-----${DIALSTATUS}-----${DIALEDTIME}-----${ANSWEREDTIME})) # # -# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# Copyright (C) 2007 Matt Florell LICENSE: GPLv2 # -# CHANGES +# CHANGELOG: # 61010-1007 - First test build # 70116-1619 - Added Auto Alt Dial code +# 70215-1258 - Added queue_log entry when deleting vac record # @@ -568,7 +569,7 @@ sub process_request { ########## FIND AND DELETE vicidial_auto_calls ########## $VD_alt_dial = 'NONE'; - $stmtA = "SELECT lead_id,callerid,campaign_id,alt_dial FROM vicidial_auto_calls where uniqueid = '$uniqueid' limit 1;"; + $stmtA = "SELECT lead_id,callerid,campaign_id,alt_dial,stage,UNIX_TIMESTAMP(call_time) FROM vicidial_auto_calls where uniqueid = '$uniqueid' limit 1;"; if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -581,6 +582,8 @@ sub process_request { $VD_callerid = "$aryA[1]"; $VD_campaign_id = "$aryA[2]"; $VD_alt_dial = "$aryA[3]"; + $VD_stage = "$aryA[4]"; + $VD_start_epoch = "$aryA[5]"; $rec_countCUSTDATA++; } $sthA->finish(); @@ -595,6 +598,45 @@ sub process_request { $affected_rows = $dbhA->do($stmtA); if ($AGILOG) {$agi_string = "-- VDAC record deleted: |$affected_rows| |$VD_lead_id|$uniqueid|$VD_callerid|$VARserver_ip"; &agi_output;} + ############################################# + ##### START QUEUEMETRICS LOGGING LOOKUP ##### + $stmtA = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $enable_queuemetrics_logging = "$aryA[0]"; + $queuemetrics_server_ip = "$aryA[1]"; + $queuemetrics_dbname = "$aryA[2]"; + $queuemetrics_login= "$aryA[3]"; + $queuemetrics_pass = "$aryA[4]"; + $queuemetrics_log_id = "$aryA[5]"; + $rec_count++; + } + $sthA->finish(); + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + if ($enable_queuemetrics_logging > 0) + { + $secX = time(); + $VD_call_length = ($secX - $VD_start_epoch); + $VD_stage =~ s/.*-//gi; + if ($VD_stage < 0.25) {$VD_stage=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='$secX',call_id='$VD_callerid',queue='$VD_campaign_id',agent='NONE',verb='COMPLETECALLER',data1='$VD_stage',data2='$VD_call_length',data3='1',serverid='$queuemetrics_log_id';"; + $Baffected_rows = $dbhB->do($stmtB); + + $dbhB->disconnect(); + } + ########## FIND AND UPDATE vicidial_log ########## $stmtA = "SELECT start_epoch,status FROM vicidial_log where uniqueid='$uniqueid' and lead_id='$VD_lead_id' limit 1;"; @@ -694,34 +736,12 @@ sub process_request { } } - } - } - - ##### 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 FROM vicidial_campaigns where 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; - $epc_countCAMPDATA=0; - while ($sthArows > $epc_countCAMPDATA) - { - @aryA = $sthA->fetchrow_array; - $VD_auto_alt_dial = "$aryA[0]"; - $VD_auto_alt_dial_statuses = "$aryA[1]"; - $epc_countCAMPDATA++; - } - $sthA->finish(); - if ($VD_auto_alt_dial_statuses =~ / $VD_status | $VDL_status /) - { - if ( ($VD_auto_alt_dial =~ /(ALT_ONLY|ALT_AND_ADDR3)/) && ($VD_alt_dial =~ /NONE|MAIN/) ) - { - $VD_alt_phone=''; - $stmtA="SELECT alt_phone,gmt_offset_now,state,list_id FROM vicidial_list where lead_id='$VD_lead_id';"; + ##### 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 FROM vicidial_campaigns where 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; @@ -730,54 +750,72 @@ sub process_request { 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]"; + $VD_auto_alt_dial = "$aryA[0]"; + $VD_auto_alt_dial_statuses = "$aryA[1]"; $epc_countCAMPDATA++; } $sthA->finish(); - if (length($VD_alt_phone)>5) + if ($VD_auto_alt_dial_statuses =~ / $VD_status | $VDL_status /) { - $stmtA = "INSERT INTO vicidial_hopper SET lead_id='$VD_lead_id',campaign_id='$VD_campaign_id',status='READY',list_id='$VD_list_id',gmt_offset_now='$VD_gmt_offset_now',state='$VD_state',alt_dial='ALT',user='';"; - $affected_rows = $dbhA->do($stmtA); - if ($AGILOG) {$agi_string = "-- VDH record inserted: |$affected_rows| |$stmtA|"; &agi_output;} - } - } - if ( ( ($VD_auto_alt_dial =~ /(ADDR3_ONLY)/) && ($VD_alt_dial =~ /NONE|MAIN/) ) || ( ($VD_auto_alt_dial =~ /(ALT_AND_ADDR3)/) && ($VD_alt_dial =~ /ALT/) ) ) - { - $VD_address3=''; - $stmtA="SELECT address3,gmt_offset_now,state,list_id FROM vicidial_list where lead_id='$VD_lead_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) - { - $stmtA = "INSERT INTO vicidial_hopper SET lead_id='$VD_lead_id',campaign_id='$VD_campaign_id',status='READY',list_id='$VD_list_id',gmt_offset_now='$VD_gmt_offset_now',state='$VD_state',alt_dial='ADDR3',user='';"; - $affected_rows = $dbhA->do($stmtA); - if ($AGILOG) {$agi_string = "-- VDH record inserted: |$affected_rows| |$stmtA|"; &agi_output;} + if ( ($VD_auto_alt_dial =~ /(ALT_ONLY|ALT_AND_ADDR3)/) && ($VD_alt_dial =~ /NONE|MAIN/) ) + { + $VD_alt_phone=''; + $stmtA="SELECT alt_phone,gmt_offset_now,state,list_id FROM vicidial_list where lead_id='$VD_lead_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) + { + $stmtA = "INSERT INTO vicidial_hopper SET lead_id='$VD_lead_id',campaign_id='$VD_campaign_id',status='READY',list_id='$VD_list_id',gmt_offset_now='$VD_gmt_offset_now',state='$VD_state',alt_dial='ALT',user='';"; + $affected_rows = $dbhA->do($stmtA); + if ($AGILOG) {$agi_string = "-- VDH record inserted: |$affected_rows| |$stmtA|"; &agi_output;} + } + } + if ( ( ($VD_auto_alt_dial =~ /(ADDR3_ONLY)/) && ($VD_alt_dial =~ /NONE|MAIN/) ) || ( ($VD_auto_alt_dial =~ /(ALT_AND_ADDR3)/) && ($VD_alt_dial =~ /ALT/) ) ) + { + $VD_address3=''; + $stmtA="SELECT address3,gmt_offset_now,state,list_id FROM vicidial_list where lead_id='$VD_lead_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) + { + $stmtA = "INSERT INTO vicidial_hopper SET lead_id='$VD_lead_id',campaign_id='$VD_campaign_id',status='READY',list_id='$VD_list_id',gmt_offset_now='$VD_gmt_offset_now',state='$VD_state',alt_dial='ADDR3',user='';"; + $affected_rows = $dbhA->do($stmtA); + if ($AGILOG) {$agi_string = "-- VDH record inserted: |$affected_rows| |$stmtA|"; &agi_output;} + } + } } + ##### END AUTO ALT PHONE DIAL SECTION ##### } + } - ##### END AUTO ALT PHONE DIAL SECTION ##### - - - - $dbhA->disconnect(); } diff --git a/docs/QUEUEMETRICS.txt b/docs/QUEUEMETRICS.txt index 38182482..a5be7ea1 100644 --- a/docs/QUEUEMETRICS.txt +++ b/docs/QUEUEMETRICS.txt @@ -131,15 +131,24 @@ agent actions - used by vicidial.php, vdc_db_query.php and AST_VDremote_agents.p UNPAUSE PAUSEREASON -call actions - used by +call actions before going to agent - used by agi-VDADtransfer scripts ENTERQUEUE(url|callerid) - ABANDON(position|origposition|waittime) CONNECT(holdtime) + EXITWITHTIMEOUT(position) + +call actions before going to agent - used by AST_VDauto_dial.pl + ABANDON(position|origposition|waittime) + +call actions after going to agent - used by vicidial.php, vdc_db_query.php and FastAGI_log.pl COMPLETEAGENT(holdtime|calltime|origposition) COMPLETECALLER(holdtime|calltime|origposition) - EXITWITHTIMEOUT(position) + CALLSTATUS(status) + + +not used in vicidial - TRANSFER(extension,context) - CALLSTATUS + + data1: call termination codes, TBD diff --git a/www/agc/vdc_db_query.php b/www/agc/vdc_db_query.php index fbe609f7..d488d372 100644 --- a/www/agc/vdc_db_query.php +++ b/www/agc/vdc_db_query.php @@ -121,10 +121,11 @@ # 70212-1253 - Fixed small issue with CXFER # 70213-1431 - Added QueueMetrics PAUSE/UNPAUSE/AGENTLOGIN/AGENTLOGOFF actions # 70214-1231 - Added queuemetrics_log_id field for server_id in queue_log +# 70215-1210 - Added queuemetrics COMPLETEAGENT action # -$version = '2.0.48'; -$build = '70214-1231'; +$version = '2.0.49'; +$build = '70215-1210'; require("dbconnect.php"); @@ -900,6 +901,29 @@ if ($stage == "end") if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); } + + ############################################# + ##### START QUEUEMETRICS LOGGING LOOKUP ##### + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; + if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");} + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $qm_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $qm_conf_ct) + { + $row=mysql_fetch_row($rslt); + $enable_queuemetrics_logging = $row[0]; + $queuemetrics_server_ip = $row[1]; + $queuemetrics_dbname = $row[2]; + $queuemetrics_login = $row[3]; + $queuemetrics_pass = $row[4]; + $queuemetrics_log_id = $row[5]; + $i++; + } + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + if ($auto_dial_level > 0) { ### check to see if campaign has alt_dial enabled @@ -975,38 +999,55 @@ if ($stage == "end") } } + if ($enable_queuemetrics_logging > 0) + { + ### check to see if lead should be alt_dialed + $stmt="SELECT auto_call_id,lead_id,phone_number,status,campaign_id,phone_code,alt_dial,stage,callerid,uniqueid from vicidial_auto_calls where lead_id='$lead_id';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VAC_qm_ct = mysql_num_rows($rslt); + if ($VAC_qm_ct > 0) + { + $row=mysql_fetch_row($rslt); + $auto_call_id = $row[0]; + $CLlead_id = $row[1]; + $CLphone_number = $row[2]; + $CLstatus = $row[3]; + $CLcampaign_id = $row[4]; + $CLphone_code = $row[5]; + $CLalt_dial = $row[6]; + $CLstage = $row[7]; + $CLcallerid = $row[8]; + $CLuniqueid = $row[9]; + } + + $CLstage = preg_replace("/XFER|-/",'',$CLstage); + if ($CLstage < 0.25) {$CLstage=0;} + + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$CLcallerid',queue='$CLcampaign_id',agent='Agent/$user',verb='COMPLETEAGENT',data1='$CLstage',data2='$length_in_sec',data3='1',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");} + $rslt=mysql_query($stmt, $linkB); + $affected_rows = mysql_affected_rows($linkB); + + mysql_close($linkB); + } + ### delete call record from vicidial_auto_calls - $stmt = "DELETE from vicidial_auto_calls where uniqueid='$uniqueid';"; + $stmt = "DELETE from vicidial_auto_calls where lead_id='$lead_id';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); + $stmt = "UPDATE vicidial_live_agents set status='PAUSED',lead_id='',uniqueid=0,callerid='',channel='',call_server_ip='',last_call_finish='$NOW_TIME',comments='' where user='$user' and server_ip='$server_ip';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); $affected_rows = mysql_affected_rows($link); if ($affected_rows > 0) { - ############################################# - ##### START QUEUEMETRICS LOGGING LOOKUP ##### - $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; - if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");} - $rslt=mysql_query($stmt, $link); - if ($DB) {echo "$stmt\n";} - $qm_conf_ct = mysql_num_rows($rslt); - $i=0; - while ($i < $qm_conf_ct) - { - $row=mysql_fetch_row($rslt); - $enable_queuemetrics_logging = $row[0]; - $queuemetrics_server_ip = $row[1]; - $queuemetrics_dbname = $row[2]; - $queuemetrics_login = $row[3]; - $queuemetrics_pass = $row[4]; - $queuemetrics_log_id = $row[5]; - $i++; - } - ##### END QUEUEMETRICS LOGGING LOOKUP ##### - ########################################### if ($enable_queuemetrics_logging > 0) { $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); @@ -1024,6 +1065,43 @@ if ($stage == "end") } else { + if ($enable_queuemetrics_logging > 0) + { + ### check to see if lead should be alt_dialed + $stmt="SELECT auto_call_id,lead_id,phone_number,status,campaign_id,phone_code,alt_dial,stage,callerid,uniqueid from vicidial_auto_calls where lead_id='$lead_id';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $VAC_qm_ct = mysql_num_rows($rslt); + if ($VAC_qm_ct > 0) + { + $row=mysql_fetch_row($rslt); + $auto_call_id = $row[0]; + $CLlead_id = $row[1]; + $CLphone_number = $row[2]; + $CLstatus = $row[3]; + $CLcampaign_id = $row[4]; + $CLphone_code = $row[5]; + $CLalt_dial = $row[6]; + $CLstage = $row[7]; + $CLcallerid = $row[8]; + $CLuniqueid = $row[9]; + } + + $CLstage = preg_replace("/XFER|-/",'',$CLstage); + if ($CLstage < 0.25) {$CLstage=0;} + + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$CLcallerid',queue='$CLcampaign_id',agent='Agent/$user',verb='COMPLETEAGENT',data1='$CLstage',data2='$length_in_sec',data3='1',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");} + $rslt=mysql_query($stmt, $linkB); + $affected_rows = mysql_affected_rows($linkB); + + mysql_close($linkB); + } + $stmt = "DELETE from vicidial_auto_calls lead_id='$lead_id';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); @@ -1034,27 +1112,6 @@ if ($stage == "end") $affected_rows = mysql_affected_rows($link); if ($affected_rows > 0) { - ############################################# - ##### START QUEUEMETRICS LOGGING LOOKUP ##### - $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; - if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");} - $rslt=mysql_query($stmt, $link); - if ($DB) {echo "$stmt\n";} - $qm_conf_ct = mysql_num_rows($rslt); - $i=0; - while ($i < $qm_conf_ct) - { - $row=mysql_fetch_row($rslt); - $enable_queuemetrics_logging = $row[0]; - $queuemetrics_server_ip = $row[1]; - $queuemetrics_dbname = $row[2]; - $queuemetrics_login = $row[3]; - $queuemetrics_pass = $row[4]; - $queuemetrics_log_id = $row[5]; - $i++; - } - ##### END QUEUEMETRICS LOGGING LOOKUP ##### - ########################################### if ($enable_queuemetrics_logging > 0) { $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); @@ -1798,6 +1855,41 @@ if ($ACTION == 'updateDISPO') $rslt=mysql_query($stmt, $link); } + ############################################# + ##### START QUEUEMETRICS LOGGING LOOKUP ##### + $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id FROM system_settings;"; + if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");} + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $qm_conf_ct = mysql_num_rows($rslt); + $i=0; + while ($i < $qm_conf_ct) + { + $row=mysql_fetch_row($rslt); + $enable_queuemetrics_logging = $row[0]; + $queuemetrics_server_ip = $row[1]; + $queuemetrics_dbname = $row[2]; + $queuemetrics_login = $row[3]; + $queuemetrics_pass = $row[4]; + $queuemetrics_log_id = $row[5]; + $i++; + } + ##### END QUEUEMETRICS LOGGING LOOKUP ##### + ########################################### + if ($enable_queuemetrics_logging > 0) + { + $linkB=mysql_connect("$queuemetrics_server_ip", "$queuemetrics_login", "$queuemetrics_pass"); + mysql_select_db("$queuemetrics_dbname", $linkB); + + $stmt = "INSERT INTO queue_log SET partition='P01',time_id='$StarTtime',call_id='$MDnextCID',queue='$campaign',agent='Agent/$user',verb='CALLSTATUS',data1='$dispo_choice',serverid='$queuemetrics_log_id';"; + if ($DB) {echo "$stmt\n";} + if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");} + $rslt=mysql_query($stmt, $linkB); + $affected_rows = mysql_affected_rows($linkB); + + mysql_close($linkB); + } + echo 'Lead ' . $lead_id . ' has been changed to ' . $dispo_choice . " Status\nNext agent_log_id:\n" . $agent_log_id . "\n"; } diff --git a/www/agc/vicidial.php b/www/agc/vicidial.php index d28b4c59..3baba0a3 100644 --- a/www/agc/vicidial.php +++ b/www/agc/vicidial.php @@ -148,10 +148,11 @@ # 70212-1252 - Fixed small issue with CXFER # 70213-1018 - Changed CXFER and AXFER to update customer information before transfer # 70214-1233 - Added queuemetrics_log_id field for server_id in queue_log +# 70215-1240 - Added queuemetrics_log_id field for server_id in queue_log # -$version = '2.0.119'; -$build = '70214-1233'; +$version = '2.0.120'; +$build = '70215-1240'; require("dbconnect.php"); @@ -1437,6 +1438,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} var CalLCID = ''; var MDnextCID = ''; var XDnextCID = ''; + var LasTCID = ''; var lead_dial_number = ''; var MD_channel_look = 0; var XD_channel_look = 0; @@ -2994,6 +2996,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} else { fronter = user; + LasTCID = MDnextResponse_array[0]; document.vicidial_form.lead_id.value = MDnextResponse_array[1]; LeaDPreVDispO = MDnextResponse_array[2]; document.vicidial_form.vendor_lead_code.value = MDnextResponse_array[4]; @@ -3582,6 +3585,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} custchannellive=1; + LasTCID = check_VDIC_array[4]; LeaDPreVDispO = check_VDIC_array[6]; fronter = check_VDIC_array[7]; document.vicidial_form.vendor_lead_code.value = check_VDIC_array[8]; @@ -4400,7 +4404,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} } if (xmlhttp) { - DSupdate_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=updateDISPO&format=text&user=" + user + "&pass=" + pass + "&dispo_choice=" + DispoChoice + "&lead_id=" + document.vicidial_form.lead_id.value + "&campaign=" + campaign + "&auto_dial_level=" + auto_dial_level + "&agent_log_id=" + agent_log_id + "&CallBackDatETimE=" + CallBackDatETimE + "&list_id=" + document.vicidial_form.list_id.value + "&recipient=" + CallBackrecipient + "&use_internal_dnc=" + use_internal_dnc + "&comments=" + CallBackCommenTs; + DSupdate_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=updateDISPO&format=text&user=" + user + "&pass=" + pass + "&dispo_choice=" + DispoChoice + "&lead_id=" + document.vicidial_form.lead_id.value + "&campaign=" + campaign + "&auto_dial_level=" + auto_dial_level + "&agent_log_id=" + agent_log_id + "&CallBackDatETimE=" + CallBackDatETimE + "&list_id=" + document.vicidial_form.list_id.value + "&recipient=" + CallBackrecipient + "&use_internal_dnc=" + use_internal_dnc + "&MDnextCID=" + LasTCID + "&comments=" + CallBackCommenTs; xmlhttp.open('POST', 'vdc_db_query.php'); xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); xmlhttp.send(DSupdate_query);