|
|
|
@@ -22,8 +22,7 @@
|
|
|
|
|
#
|
|
|
|
|
#
|
|
|
|
|
# ;all hangups:
|
|
|
|
|
# exten => h,1,DeadAGI(agi://127.0.0.1:4577/call_log)
|
|
|
|
|
# exten => h,2,DeadAGI(agi://127.0.0.1:4577/VD_hangup--HVcauses--PRI-----NODEBUG-----${HANGUPCAUSE}-----${DIALSTATUS}-----${DIALEDTIME}-----${ANSWEREDTIME}))
|
|
|
|
|
# exten => h,1,DeadAGI(agi://127.0.0.1:4577/call_log--HVcauses--PRI-----NODEBUG-----${HANGUPCAUSE}-----${DIALSTATUS}-----${DIALEDTIME}-----${ANSWEREDTIME}))
|
|
|
|
|
#
|
|
|
|
|
#
|
|
|
|
|
# Copyright (C) 2007 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
|
|
|
@@ -32,7 +31,8 @@
|
|
|
|
|
# 61010-1007 - First test build
|
|
|
|
|
# 70116-1619 - Added Auto Alt Dial code
|
|
|
|
|
# 70215-1258 - Added queue_log entry when deleting vac record
|
|
|
|
|
#
|
|
|
|
|
# 70808-1425 - Moved VD_hangup section to the call_log end stage to improve efficiency
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# defaults for PreFork
|
|
|
|
@@ -509,9 +509,349 @@ sub process_request {
|
|
|
|
|
}
|
|
|
|
|
##### END Park Log entry check and update #####
|
|
|
|
|
|
|
|
|
|
$dbhA->disconnect();
|
|
|
|
|
# $dbhA->disconnect();
|
|
|
|
|
|
|
|
|
|
if ($AGILOG) {$agi_string = "+++++ CALL LOG HUNGUP: |$unique_id|$channel|$extension|$now_date|min: $length_in_min|"; &agi_output;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
##### BEGIN former VD_hangup section functions #####
|
|
|
|
|
|
|
|
|
|
$VDADcampaign='';
|
|
|
|
|
$VDADphone='';
|
|
|
|
|
$VDADphone_code='';
|
|
|
|
|
|
|
|
|
|
if ($DEBUG =~ /^DEBUG$/)
|
|
|
|
|
{
|
|
|
|
|
### open the hangup cause out file for writing ###
|
|
|
|
|
open(out, ">>$PATHlogs/HANGUP_cause-output.txt")
|
|
|
|
|
|| die "Can't open $PATHlogs/HANGUP_cause-output.txt: $!\n";
|
|
|
|
|
|
|
|
|
|
print out "$now_date|$hangup_cause|$dialstatus|$dial_time|$ring_time|$unique_id|$channel|$extension|$type|$callerid|$calleridname|$priority|\n";
|
|
|
|
|
|
|
|
|
|
close(out);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ($AGILOG) {$agi_string = "DEBUG: $DEBUG"; &agi_output;}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$callerid =~ s/\"//gi;
|
|
|
|
|
$CIDlead_id = $callerid;
|
|
|
|
|
$CIDlead_id = substr($CIDlead_id, 11, 9);
|
|
|
|
|
$CIDlead_id = ($CIDlead_id + 0);
|
|
|
|
|
|
|
|
|
|
if ($AGILOG) {$agi_string = "VD_hangup : $callerid $channel $priority $CIDlead_id"; &agi_output;}
|
|
|
|
|
|
|
|
|
|
if ($channel =~ /^Local/)
|
|
|
|
|
{
|
|
|
|
|
if ( ($PRI =~ /^PRI$/) && ($callerid =~ /\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d/) && ( ($dialstatus =~ /BUSY/) || ( ($dialstatus =~ /CHANUNAVAIL/) && ($hangup_cause =~ /^1$|^28$/) ) ) )
|
|
|
|
|
{
|
|
|
|
|
if ($dialstatus =~ /BUSY/) {$VDL_status = 'B'; $VDAC_status = 'BUSY';}
|
|
|
|
|
if ($dialstatus =~ /CHANUNAVAIL/) {$VDL_status = 'DC'; $VDAC_status = 'DISCONNECT';}
|
|
|
|
|
|
|
|
|
|
$stmtA = "UPDATE vicidial_auto_calls set status='$VDAC_status' where callerid = '$callerid';";
|
|
|
|
|
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
|
|
|
|
$affected_rows = $dbhA->do($stmtA);
|
|
|
|
|
if ($AGILOG) {$agi_string = "-- VDAC update: |$affected_rows|$CIDlead_id"; &agi_output;}
|
|
|
|
|
|
|
|
|
|
$stmtA = "UPDATE vicidial_list set status='$VDL_status' 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 = "UPDATE vicidial_log set status='$VDL_status' where uniqueid = '$uniqueid';";
|
|
|
|
|
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;}
|
|
|
|
|
|
|
|
|
|
$dbhA->disconnect();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ($AGILOG) {$agi_string = "-- VD_hangup Local DEBUG: |$PRI|$callerid|$dialstatus|$hangup_cause|"; &agi_output;}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($AGILOG) {$agi_string = "+++++ VDAD START LOCAL CHANNEL: EXITING- $priority"; &agi_output;}
|
|
|
|
|
if ($priority > 2) {sleep(1);}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
########## FIND AND DELETE vicidial_auto_calls ##########
|
|
|
|
|
$VD_alt_dial = 'NONE';
|
|
|
|
|
$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;
|
|
|
|
|
$sthArows=$sthA->rows;
|
|
|
|
|
$rec_countCUSTDATA=0;
|
|
|
|
|
while ($sthArows > $rec_countCUSTDATA)
|
|
|
|
|
{
|
|
|
|
|
@aryA = $sthA->fetchrow_array;
|
|
|
|
|
$VD_lead_id = "$aryA[0]";
|
|
|
|
|
$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();
|
|
|
|
|
|
|
|
|
|
if (!$rec_countCUSTDATA)
|
|
|
|
|
{
|
|
|
|
|
if ($AGILOG) {$agi_string = "VD hangup: no VDAC record found: $uniqueid $calleridname"; &agi_output;}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$stmtA = "DELETE FROM vicidial_auto_calls where uniqueid='$uniqueid' order by call_time desc limit 1;";
|
|
|
|
|
$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)
|
|
|
|
|
{
|
|
|
|
|
$VD_agent='NONE';
|
|
|
|
|
$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 = "SELECT agent from queue_log where call_id='$VD_callerid' and verb='CONNECT';";
|
|
|
|
|
$sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr;
|
|
|
|
|
$sthB->execute or die "executing: $stmtB ", $dbhB->errstr;
|
|
|
|
|
$sthBrows=$sthB->rows;
|
|
|
|
|
$rec_count=0;
|
|
|
|
|
while ($sthBrows > $rec_count)
|
|
|
|
|
{
|
|
|
|
|
@aryB = $sthB->fetchrow_array;
|
|
|
|
|
$VD_agent = "$aryB[0]";
|
|
|
|
|
$rec_count++;
|
|
|
|
|
}
|
|
|
|
|
$sthB->finish();
|
|
|
|
|
|
|
|
|
|
if ($rec_count < 1)
|
|
|
|
|
{
|
|
|
|
|
$stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$secX',call_id='$VD_callerid',queue='$VD_campaign_id',agent='$VD_agent',verb='ABANDON',data1='1',data2='1',data3='$VD_stage',serverid='$queuemetrics_log_id';";
|
|
|
|
|
$Baffected_rows = $dbhB->do($stmtB);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$secX',call_id='$VD_callerid',queue='$VD_campaign_id',agent='$VD_agent',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;";
|
|
|
|
|
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_countCUSTDATA=0;
|
|
|
|
|
$VD_closecallid='';
|
|
|
|
|
while ($sthArows > $rec_countCUSTDATA)
|
|
|
|
|
{
|
|
|
|
|
@aryA = $sthA->fetchrow_array;
|
|
|
|
|
$VD_start_epoch = "$aryA[0]";
|
|
|
|
|
$VD_status = "$aryA[1]";
|
|
|
|
|
$epc_countCUSTDATA++;
|
|
|
|
|
}
|
|
|
|
|
$sthA->finish();
|
|
|
|
|
|
|
|
|
|
if (!$epc_countCUSTDATA)
|
|
|
|
|
{
|
|
|
|
|
if ($AGILOG) {$agi_string = "no VDL record found: $uniqueid $calleridname $VD_lead_id $uniqueid"; &agi_output;}
|
|
|
|
|
|
|
|
|
|
$secX = time();
|
|
|
|
|
$Rtarget = ($secX - 21600); # look for VDCL entry within last 6 hours
|
|
|
|
|
($Rsec,$Rmin,$Rhour,$Rmday,$Rmon,$Ryear,$Rwday,$Ryday,$Risdst) = localtime($Rtarget);
|
|
|
|
|
$Ryear = ($Ryear + 1900);
|
|
|
|
|
$Rmon++;
|
|
|
|
|
if ($Rmon < 10) {$Rmon = "0$Rmon";}
|
|
|
|
|
if ($Rmday < 10) {$Rmday = "0$Rmday";}
|
|
|
|
|
if ($Rhour < 10) {$Rhour = "0$Rhour";}
|
|
|
|
|
if ($Rmin < 10) {$Rmin = "0$Rmin";}
|
|
|
|
|
if ($Rsec < 10) {$Rsec = "0$Rsec";}
|
|
|
|
|
$RSQLdate = "$Ryear-$Rmon-$Rmday $Rhour:$Rmin:$Rsec";
|
|
|
|
|
|
|
|
|
|
$stmtA = "SELECT start_epoch,status,closecallid FROM vicidial_closer_log where lead_id = '$VD_lead_id' and call_date > \"$RSQLdate\" order by call_date desc 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;
|
|
|
|
|
$sthArows=$sthA->rows;
|
|
|
|
|
$epc_countCUSTDATA=0;
|
|
|
|
|
$VD_closecallid='';
|
|
|
|
|
while ($sthArows > $epc_countCUSTDATA)
|
|
|
|
|
{
|
|
|
|
|
@aryA = $sthA->fetchrow_array;
|
|
|
|
|
$VD_start_epoch = "$aryA[0]";
|
|
|
|
|
$VD_status = "$aryA[1]";
|
|
|
|
|
$VD_closecallid = "$aryA[2]";
|
|
|
|
|
$epc_countCUSTDATA++;
|
|
|
|
|
}
|
|
|
|
|
$sthA->finish();
|
|
|
|
|
}
|
|
|
|
|
if (!$epc_countCUSTDATA)
|
|
|
|
|
{
|
|
|
|
|
if ($AGILOG) {$agi_string = "no VDL or VDCL record found: $uniqueid $calleridname $VD_lead_id $uniqueid"; &agi_output;}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$VD_seconds = ($now_date_epoch - $VD_start_epoch);
|
|
|
|
|
|
|
|
|
|
$SQL_status='';
|
|
|
|
|
if ($VD_status =~ /^NA$|^NEW$|^QUEUE$|^XFER$/)
|
|
|
|
|
{
|
|
|
|
|
$SQL_status = "status='DROP',";
|
|
|
|
|
|
|
|
|
|
########## FIND AND UPDATE vicidial_list ##########
|
|
|
|
|
$stmtA = "UPDATE vicidial_list set status='DROP' where lead_id = '$VD_lead_id';";
|
|
|
|
|
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
|
|
|
|
$affected_rows = $dbhA->do($stmtA);
|
|
|
|
|
if ($AGILOG) {$agi_string = "-- VDAD vicidial_list update: |$affected_rows|$VD_lead_id"; &agi_output;}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$stmtA = "UPDATE vicidial_log set $SQL_status end_epoch='$now_date_epoch',length_in_sec='$VD_seconds' where uniqueid = '$uniqueid';";
|
|
|
|
|
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
|
|
|
|
$affected_rows = $dbhA->do($stmtA);
|
|
|
|
|
if ($AGILOG) {$agi_string = "-- VDAD vicidial_log update: |$affected_rows|$uniqueid|$VD_status|"; &agi_output;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
########## UPDATE vicidial_closer_log ##########
|
|
|
|
|
if (length($VD_closecallid) < 1)
|
|
|
|
|
{
|
|
|
|
|
if ($AGILOG) {$agi_string = "no VDCL record found: $uniqueid $calleridname $VD_lead_id $uniqueid"; &agi_output;}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ($VD_status =~ /^DONE$|^INCALL$|^XFER$/)
|
|
|
|
|
{$VDCLSQL_status = "";}
|
|
|
|
|
else
|
|
|
|
|
{$VDCLSQL_status = "status='DROP',queue_seconds='$VD_seconds',";}
|
|
|
|
|
|
|
|
|
|
$VD_seconds = ($now_date_epoch - $VD_start_epoch);
|
|
|
|
|
$stmtA = "UPDATE vicidial_closer_log set $VDCLSQL_status end_epoch='$now_date_epoch',length_in_sec='$VD_seconds' where closecallid = '$VD_closecallid';";
|
|
|
|
|
if ($AGILOG) {$agi_string = "|$VDCLSQL_status|$VD_status|\n|$stmtA|"; &agi_output;}
|
|
|
|
|
$affected_rows = $dbhA->do($stmtA);
|
|
|
|
|
if ($AGILOG) {$agi_string = "-- VDCL update: |$affected_rows|$uniqueid|$VD_closecallid|"; &agi_output;}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
##### 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';";
|
|
|
|
|
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 #####
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$dbhA->disconnect();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
###################################################################
|
|
|
|
@@ -526,343 +866,9 @@ sub process_request {
|
|
|
|
|
##### START VD_hangup process #####################################
|
|
|
|
|
###################################################################
|
|
|
|
|
if ($process =~ /^VD_hangup/)
|
|
|
|
|
{
|
|
|
|
|
$VDADcampaign='';
|
|
|
|
|
$VDADphone='';
|
|
|
|
|
$VDADphone_code='';
|
|
|
|
|
|
|
|
|
|
if ($DEBUG =~ /^DEBUG$/)
|
|
|
|
|
{
|
|
|
|
|
### open the hangup cause out file for writing ###
|
|
|
|
|
open(out, ">>$PATHlogs/HANGUP_cause-output.txt")
|
|
|
|
|
|| die "Can't open $PATHlogs/HANGUP_cause-output.txt: $!\n";
|
|
|
|
|
|
|
|
|
|
print out "$now_date|$hangup_cause|$dialstatus|$dial_time|$ring_time|$unique_id|$channel|$extension|$type|$callerid|$calleridname|$priority|\n";
|
|
|
|
|
|
|
|
|
|
close(out);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ($AGILOG) {$agi_string = "DEBUG: $DEBUG"; &agi_output;}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$callerid =~ s/\"//gi;
|
|
|
|
|
$CIDlead_id = $callerid;
|
|
|
|
|
$CIDlead_id = substr($CIDlead_id, 11, 9);
|
|
|
|
|
$CIDlead_id = ($CIDlead_id + 0);
|
|
|
|
|
|
|
|
|
|
if ($AGILOG) {$agi_string = "VD_hangup : $callerid $channel $priority $CIDlead_id"; &agi_output;}
|
|
|
|
|
|
|
|
|
|
if ($channel =~ /^Local/)
|
|
|
|
|
{
|
|
|
|
|
if ( ($PRI =~ /^PRI$/) && ($callerid =~ /\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d/) && ( ($dialstatus =~ /BUSY/) || ( ($dialstatus =~ /CHANUNAVAIL/) && ($hangup_cause =~ /^1$|^28$/) ) ) )
|
|
|
|
|
{
|
|
|
|
|
if ($dialstatus =~ /BUSY/) {$VDL_status = 'B'; $VDAC_status = 'BUSY';}
|
|
|
|
|
if ($dialstatus =~ /CHANUNAVAIL/) {$VDL_status = 'DC'; $VDAC_status = 'DISCONNECT';}
|
|
|
|
|
|
|
|
|
|
$stmtA = "UPDATE vicidial_auto_calls set status='$VDAC_status' where callerid = '$callerid';";
|
|
|
|
|
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
|
|
|
|
$affected_rows = $dbhA->do($stmtA);
|
|
|
|
|
if ($AGILOG) {$agi_string = "-- VDAC update: |$affected_rows|$CIDlead_id"; &agi_output;}
|
|
|
|
|
|
|
|
|
|
$stmtA = "UPDATE vicidial_list set status='$VDL_status' 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 = "UPDATE vicidial_log set status='$VDL_status' where uniqueid = '$uniqueid';";
|
|
|
|
|
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;}
|
|
|
|
|
|
|
|
|
|
$dbhA->disconnect();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ($AGILOG) {$agi_string = "-- VD_hangup Local DEBUG: |$PRI|$callerid|$dialstatus|$hangup_cause|"; &agi_output;}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($AGILOG) {$agi_string = "+++++ VDAD START LOCAL CHANNEL: EXITING- $priority"; &agi_output;}
|
|
|
|
|
if ($priority > 2) {sleep(1);}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
########## FIND AND DELETE vicidial_auto_calls ##########
|
|
|
|
|
$VD_alt_dial = 'NONE';
|
|
|
|
|
$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;
|
|
|
|
|
$sthArows=$sthA->rows;
|
|
|
|
|
$rec_countCUSTDATA=0;
|
|
|
|
|
while ($sthArows > $rec_countCUSTDATA)
|
|
|
|
|
{
|
|
|
|
|
@aryA = $sthA->fetchrow_array;
|
|
|
|
|
$VD_lead_id = "$aryA[0]";
|
|
|
|
|
$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();
|
|
|
|
|
|
|
|
|
|
if (!$rec_countCUSTDATA)
|
|
|
|
|
{
|
|
|
|
|
if ($AGILOG) {$agi_string = "VD hangup: no VDAC record found: $uniqueid $calleridname"; &agi_output;}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$stmtA = "DELETE FROM vicidial_auto_calls where uniqueid='$uniqueid' order by call_time desc limit 1;";
|
|
|
|
|
$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)
|
|
|
|
|
{
|
|
|
|
|
$VD_agent='NONE';
|
|
|
|
|
$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 = "SELECT agent from queue_log where call_id='$VD_callerid' and verb='CONNECT';";
|
|
|
|
|
$sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr;
|
|
|
|
|
$sthB->execute or die "executing: $stmtB ", $dbhB->errstr;
|
|
|
|
|
$sthBrows=$sthB->rows;
|
|
|
|
|
$rec_count=0;
|
|
|
|
|
while ($sthBrows > $rec_count)
|
|
|
|
|
{
|
|
|
|
|
@aryB = $sthB->fetchrow_array;
|
|
|
|
|
$VD_agent = "$aryB[0]";
|
|
|
|
|
$rec_count++;
|
|
|
|
|
}
|
|
|
|
|
$sthB->finish();
|
|
|
|
|
|
|
|
|
|
if ($rec_count < 1)
|
|
|
|
|
{
|
|
|
|
|
$stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$secX',call_id='$VD_callerid',queue='$VD_campaign_id',agent='$VD_agent',verb='ABANDON',data1='1',data2='1',data3='$VD_stage',serverid='$queuemetrics_log_id';";
|
|
|
|
|
$Baffected_rows = $dbhB->do($stmtB);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$secX',call_id='$VD_callerid',queue='$VD_campaign_id',agent='$VD_agent',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;";
|
|
|
|
|
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_countCUSTDATA=0;
|
|
|
|
|
$VD_closecallid='';
|
|
|
|
|
while ($sthArows > $rec_countCUSTDATA)
|
|
|
|
|
{
|
|
|
|
|
@aryA = $sthA->fetchrow_array;
|
|
|
|
|
$VD_start_epoch = "$aryA[0]";
|
|
|
|
|
$VD_status = "$aryA[1]";
|
|
|
|
|
$epc_countCUSTDATA++;
|
|
|
|
|
}
|
|
|
|
|
$sthA->finish();
|
|
|
|
|
|
|
|
|
|
if (!$epc_countCUSTDATA)
|
|
|
|
|
{
|
|
|
|
|
if ($AGILOG) {$agi_string = "no VDL record found: $uniqueid $calleridname $VD_lead_id $uniqueid"; &agi_output;}
|
|
|
|
|
|
|
|
|
|
$secX = time();
|
|
|
|
|
$Rtarget = ($secX - 21600); # look for VDCL entry within last 6 hours
|
|
|
|
|
($Rsec,$Rmin,$Rhour,$Rmday,$Rmon,$Ryear,$Rwday,$Ryday,$Risdst) = localtime($Rtarget);
|
|
|
|
|
$Ryear = ($Ryear + 1900);
|
|
|
|
|
$Rmon++;
|
|
|
|
|
if ($Rmon < 10) {$Rmon = "0$Rmon";}
|
|
|
|
|
if ($Rmday < 10) {$Rmday = "0$Rmday";}
|
|
|
|
|
if ($Rhour < 10) {$Rhour = "0$Rhour";}
|
|
|
|
|
if ($Rmin < 10) {$Rmin = "0$Rmin";}
|
|
|
|
|
if ($Rsec < 10) {$Rsec = "0$Rsec";}
|
|
|
|
|
$RSQLdate = "$Ryear-$Rmon-$Rmday $Rhour:$Rmin:$Rsec";
|
|
|
|
|
|
|
|
|
|
$stmtA = "SELECT start_epoch,status,closecallid FROM vicidial_closer_log where lead_id = '$VD_lead_id' and call_date > \"$RSQLdate\" order by call_date desc 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;
|
|
|
|
|
$sthArows=$sthA->rows;
|
|
|
|
|
$epc_countCUSTDATA=0;
|
|
|
|
|
$VD_closecallid='';
|
|
|
|
|
while ($sthArows > $epc_countCUSTDATA)
|
|
|
|
|
{
|
|
|
|
|
@aryA = $sthA->fetchrow_array;
|
|
|
|
|
$VD_start_epoch = "$aryA[0]";
|
|
|
|
|
$VD_status = "$aryA[1]";
|
|
|
|
|
$VD_closecallid = "$aryA[2]";
|
|
|
|
|
$epc_countCUSTDATA++;
|
|
|
|
|
}
|
|
|
|
|
$sthA->finish();
|
|
|
|
|
}
|
|
|
|
|
if (!$epc_countCUSTDATA)
|
|
|
|
|
{
|
|
|
|
|
if ($AGILOG) {$agi_string = "no VDL or VDCL record found: $uniqueid $calleridname $VD_lead_id $uniqueid"; &agi_output;}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$VD_seconds = ($now_date_epoch - $VD_start_epoch);
|
|
|
|
|
|
|
|
|
|
$SQL_status='';
|
|
|
|
|
if ($VD_status =~ /^NA$|^NEW$|^QUEUE$|^XFER$/)
|
|
|
|
|
{
|
|
|
|
|
$SQL_status = "status='DROP',";
|
|
|
|
|
|
|
|
|
|
########## FIND AND UPDATE vicidial_list ##########
|
|
|
|
|
$stmtA = "UPDATE vicidial_list set status='DROP' where lead_id = '$VD_lead_id';";
|
|
|
|
|
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
|
|
|
|
$affected_rows = $dbhA->do($stmtA);
|
|
|
|
|
if ($AGILOG) {$agi_string = "-- VDAD vicidial_list update: |$affected_rows|$VD_lead_id"; &agi_output;}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$stmtA = "UPDATE vicidial_log set $SQL_status end_epoch='$now_date_epoch',length_in_sec='$VD_seconds' where uniqueid = '$uniqueid';";
|
|
|
|
|
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
|
|
|
|
$affected_rows = $dbhA->do($stmtA);
|
|
|
|
|
if ($AGILOG) {$agi_string = "-- VDAD vicidial_log update: |$affected_rows|$uniqueid|$VD_status|"; &agi_output;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
########## UPDATE vicidial_closer_log ##########
|
|
|
|
|
if (length($VD_closecallid) < 1)
|
|
|
|
|
{
|
|
|
|
|
if ($AGILOG) {$agi_string = "no VDCL record found: $uniqueid $calleridname $VD_lead_id $uniqueid"; &agi_output;}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ($VD_status =~ /^DONE$|^INCALL$|^XFER$/)
|
|
|
|
|
{$VDCLSQL_status = "";}
|
|
|
|
|
else
|
|
|
|
|
{$VDCLSQL_status = "status='DROP',queue_seconds='$VD_seconds',";}
|
|
|
|
|
|
|
|
|
|
$VD_seconds = ($now_date_epoch - $VD_start_epoch);
|
|
|
|
|
$stmtA = "UPDATE vicidial_closer_log set $VDCLSQL_status end_epoch='$now_date_epoch',length_in_sec='$VD_seconds' where closecallid = '$VD_closecallid';";
|
|
|
|
|
if ($AGILOG) {$agi_string = "|$VDCLSQL_status|$VD_status|\n|$stmtA|"; &agi_output;}
|
|
|
|
|
$affected_rows = $dbhA->do($stmtA);
|
|
|
|
|
if ($AGILOG) {$agi_string = "-- VDCL update: |$affected_rows|$uniqueid|$VD_closecallid|"; &agi_output;}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
##### 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';";
|
|
|
|
|
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 #####
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$dbhA->disconnect();
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
$nothing=0;
|
|
|
|
|
}
|
|
|
|
|
###################################################################
|
|
|
|
|
##### END VD_hangup process #######################################
|
|
|
|
|
###################################################################
|
|
|
|
|