2006-06-16 snapshot
git-svn-id: svn://192.168.202.10@9 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
+102
-23
@@ -12,14 +12,20 @@
|
||||
#
|
||||
# ;VICIDIAL_auto_dialer transfer script:
|
||||
# exten => h,1,DeadAGI(call_log.agi,${EXTEN})
|
||||
# exten => h,2,DeadAGI(VD_hangup.agi,${EXTEN})
|
||||
# exten => h,2,DeadAGI(VD_hangup.agi,PRI-----DEBUG-----${HANGUPCAUSE}-----${DIALSTATUS}-----${DIALEDTIME}-----${ANSWEREDTIME})
|
||||
#
|
||||
# NOTES:
|
||||
# - To disable Busy and Disconnect detection change the first field from PRI to NONPRI
|
||||
# - To disable Debug output to file change the second field from DEBUG to NODEBUG
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
# changes:
|
||||
# 60203-1218 - fixed calleridname issue with 1.2 tree for custom CID
|
||||
# 60314-1250 - Altered to allow for ignoring of AGI-defined status
|
||||
# 60612-1500 - Added option for text log of hangup codes
|
||||
# - Added option for PRI hangup code dispositions: BUSY, DISCONNECT
|
||||
# 60615-1101 - Fixed log updates for CLOSER transfer from fronter calls
|
||||
#
|
||||
|
||||
$V = 1; # set to 1 for verbose mode
|
||||
@@ -62,6 +68,16 @@ if ($V) {print STDERR "Perl Environment Dump:\n";}
|
||||
$i++;
|
||||
}
|
||||
|
||||
### list of command-line array arguments:
|
||||
@ARGV_vars = split(/-----/, $ARGV[0]);
|
||||
|
||||
$PRI = $ARGV_vars[0];
|
||||
$DEBUG = $ARGV_vars[1];
|
||||
$hangup_cause = $ARGV_vars[2];
|
||||
$dialstatus = $ARGV_vars[3];
|
||||
$dial_time = $ARGV_vars[4];
|
||||
$ring_time = $ARGV_vars[5];
|
||||
|
||||
if ($args =~ /--help/i)
|
||||
{
|
||||
print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n";
|
||||
@@ -156,6 +172,18 @@ $VDADphone_code='';
|
||||
|
||||
if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|$calleridname|$priority|\n";}
|
||||
|
||||
if ($DEBUG =~ /^DEBUG$/)
|
||||
{
|
||||
### open the error out file for writing ###
|
||||
open(out, ">>/home/cron/HANGUP_test-output.txt")
|
||||
|| die "Can't open /home/cron/HANGUP_test-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 {print STDERR "\nDEBUG: $DEBUG\n";}
|
||||
|
||||
|
||||
$callerid =~ s/\"//gi;
|
||||
$CIDlead_id = $callerid;
|
||||
@@ -166,11 +194,43 @@ if ($V) {print STDERR "\nVD_hangup : $callerid $channel $priority\n";}
|
||||
if ($M) {print STDERR "+++++ VD hangup START : |$unique_id|$channel|$extension|$type|$callerid|$CIDlead_id|$now_date|$AST_ver|$priority|$calleridname|\n";}
|
||||
|
||||
|
||||
if ( ($channel =~ /Local/i) && ($AST_ver !~ /^1\.0\.8|^1\.0\.9/) )
|
||||
if ($channel =~ /^Local/)
|
||||
{
|
||||
if ($M) {print STDERR "+++++ VDAD START LOCAL CHANNEL: EXITING- $priority\n";}
|
||||
if ($priority > 2) {sleep(1);}
|
||||
exit;
|
||||
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$/) ) ) )
|
||||
{
|
||||
my $dbhA = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n";
|
||||
|
||||
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($M){print STDERR "\n\n|$stmtA|\n";}
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
if ($M) {print STDERR "-- VDAC update: |$affected_rows|$CIDlead_id\n";}
|
||||
|
||||
$stmtA = "UPDATE vicidial_list set status='$VDL_status' where lead_id = '$CIDlead_id';";
|
||||
if($M){print STDERR "\n\n|$stmtA|\n";}
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
if ($M) {print STDERR "-- VDAD vicidial_list update: |$affected_rows|$CIDlead_id\n";}
|
||||
|
||||
$stmtA = "UPDATE vicidial_log set status='$VDL_status' where uniqueid = '$uniqueid';";
|
||||
if($M){print STDERR "\n\n|$stmtA|\n";}
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
if ($M) {print STDERR "-- VDAD vicidial_log update: |$affected_rows|$uniqueid|\n";}
|
||||
|
||||
$dbhA->close;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($M) {print STDERR "-- VDhangup Local DEBUG: |$PRI|$callerid|$dialstatus|$hangup_cause|\n";}
|
||||
}
|
||||
|
||||
if ($M) {print STDERR "+++++ VDAD START LOCAL CHANNEL: EXITING- $priority\n";}
|
||||
if ($priority > 2) {sleep(1);}
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!$DB_port) {$DB_port='3306';}
|
||||
@@ -211,6 +271,7 @@ $stmtA = "SELECT start_epoch,status FROM vicidial_log where uniqueid='$uniqueid'
|
||||
if($M){print STDERR "\n\n|$stmtA|\n";}
|
||||
$dbhA->query("$stmtA");
|
||||
$epc_countCUSTDATA=0;
|
||||
$VD_closecallid='';
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
@@ -224,6 +285,38 @@ if ($dbhA->has_selected_record)
|
||||
if (!$epc_countCUSTDATA)
|
||||
{
|
||||
if($M){print STDERR "\nVD hangup: no VDL record found: $uniqueid $calleridname $VD_lead_id $uniqueid\n";}
|
||||
|
||||
$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($M){print STDERR "\n\n|$stmtA|\n";}
|
||||
$dbhA->query("$stmtA");
|
||||
$epc_countCUSTDATA=0;
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$VD_start_epoch = "$record->[0]";
|
||||
$VD_status = "$record->[1]";
|
||||
$VD_closecallid = "$record->[2]";
|
||||
$epc_countCUSTDATA++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$epc_countCUSTDATA)
|
||||
{
|
||||
if($M){print STDERR "\nVD hangup: no VDL or VDCL record found: $uniqueid $calleridname $VD_lead_id $uniqueid\n";}
|
||||
exit;
|
||||
}
|
||||
$VD_seconds = ($now_date_epoch - $VD_start_epoch);
|
||||
@@ -250,32 +343,18 @@ if ($M) {print STDERR "-- VDAD vicidial_log update: |$affected_rows|$uniqueid
|
||||
|
||||
|
||||
|
||||
########## FIND AND UPDATE vicidial_closer_log ##########
|
||||
$stmtA = "SELECT closecallid,start_epoch FROM vicidial_closer_log where lead_id='$VD_lead_id' order by closecallid desc limit 1;";
|
||||
if($M){print STDERR "\n\n|$stmtA|\n";}
|
||||
$dbhA->query("$stmtA");
|
||||
$epc_countCUSTDATA=0;
|
||||
if ($dbhA->has_selected_record)
|
||||
{
|
||||
$iter=$dbhA->create_record_iterator;
|
||||
while ( $record = $iter->each)
|
||||
{
|
||||
$closecallid = "$record->[0]";
|
||||
$VD_start_epoch = "$record->[1]";
|
||||
$epc_countCUSTDATA++;
|
||||
}
|
||||
}
|
||||
if (!$epc_countCUSTDATA)
|
||||
########## UPDATE vicidial_closer_log ##########
|
||||
if (length($VD_closecallid) < 1)
|
||||
{
|
||||
if($M){print STDERR "\nVD hangup: no VDCL record found: $uniqueid $calleridname $VD_lead_id $uniqueid\n";}
|
||||
exit;
|
||||
}
|
||||
$VD_seconds = ($now_date_epoch - $VD_start_epoch);
|
||||
$stmtA = "UPDATE vicidial_closer_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$VD_seconds' where closecallid = '$closecallid';";
|
||||
$stmtA = "UPDATE vicidial_closer_log set status='DROP',end_epoch='$now_date_epoch',length_in_sec='$VD_seconds' where closecallid = '$VD_closecallid';";
|
||||
if($M){print STDERR "\n\n|$stmtA|\n";}
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
if ($M) {print STDERR "-- VDCL update: |$affected_rows|$uniqueid|$closecallid|\n";}
|
||||
if ($M) {print STDERR "-- VDCL update: |$affected_rows|$uniqueid|$VD_closecallid|\n";}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user