Changed survey method HANGUP to not wait for digits, added LCRERR Local channel logging on the ALL outbound AGI script

git-svn-id: svn://192.168.202.10@1862 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2012-10-09 19:13:40 +00:00
parent f7e225b2c7
commit f130fb8fb7
+93 -17
View File
@@ -95,12 +95,13 @@
# 111219-2256 - Added max stats updating
# 120529-2112 - Added safe_harbor_audio_field campaign option
# 120621-0726 - Changed survey opt-in non-agent qm logging to log connection to VDAD agent
# 121009-1458 - Changed survey method HANGUP to not wait for digits, added LCRERR Local channel logging
#
$script = 'agi-VDAD_ALL_outbound.agi';
$AGILOG = '0';
$mel=1; # Mysql Error Log enabled = 1
$mysql_log_count=99;
$mysql_log_count=105;
$one_mysql_log=0;
@@ -343,7 +344,78 @@ if ($AGILOG) {$agi_string = "+++++ VDAD START : |$CIDlead_id|$now_date|$AST_ver|
if ( ($channel =~ /Local/i) && ($AST_ver !~ /^1\.0\.8|^1\.0\.9/) )
{
if ($AGILOG) {$agi_string = "+++++ VDAD START LOCAL CHANNEL: EXITING- $priority"; &agi_output;}
if ($priority > 2) {sleep(1);}
if ($priority > 2)
{sleep(1);}
if ($priority > 3)
{
### find list of callback statuses
$SCstatuses="'CBHOLD'";
$stmtA = "select status from vicidial_statuses where scheduled_callback='Y' limit 10000000;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArowsSCS=$sthA->rows;
$rec_count=0;
while ($sthArowsSCS > $rec_count)
{
@aryA = $sthA->fetchrow_array;
$SCstatuses .= ",'$aryA[0]'";
$rec_count++;
}
$sthA->finish();
if ($AGILOG) {$agi_string = "LLLLLLLLL LOCAL CHANNEL PRIORITY 4 LOGGING: (this is usually caused by carrier issues) LCRERR $priority"; &agi_output;}
# flag the lead as being Answered or Picked up
$stmtA = "UPDATE vicidial_list set status='LCRERR' where lead_id='$CIDlead_id' and status NOT IN($SCstatuses);";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01100'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- LCRERR vicidial_list LCRERR update: |$affected_rows|$uniqueid|$CIDlead_id|"; &agi_output;}
$xCLlist_id=0;
$stmtA = "SELECT list_id,security_phrase from vicidial_list where lead_id='$CIDlead_id' limit 1;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArowsLI=$sthA->rows;
$dbhP=$dbhA; $mysql_count='01101'; $MEL_aff_rows=$sthArowsLI; &mysql_error_logging;
if ($sthArowsLI > 0)
{
@aryA = $sthA->fetchrow_array;
$xCLlist_id = $aryA[0];
$security_phrase = $aryA[1];
}
$sthA->finish();
$stmtA = "SELECT campaign_id,phone_number,phone_code,lead_id,call_time,alt_dial,queue_priority FROM vicidial_auto_calls where callerid='$callerid' order by call_time desc limit 1;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='01102'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$VDADcampaign = $aryA[0];
$VDADphone = $aryA[1];
$VDADphone_code = $aryA[2];
$VDADlead_id = $aryA[3];
$VDADcall_time = $aryA[4];
$VDADalt_dial = $aryA[5];
$VDADqueue_priority = $aryA[6];
}
$sthA->finish();
$stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed,alt_dial,list_id) values('$uniqueid','$CIDlead_id','$VDADcampaign','$SQLdate','$now_date_epoch','LCRERR','$VDADphone_code','$VDADphone','VDAD','N','$VDADalt_dial','$xCLlist_id')";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01103'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- LCRERR : |$VDADlead_id|$CIDlead_id|insert to vicidial_log: $uniqueid"; &agi_output;}
$stmtA = "INSERT INTO vicidial_log_extended set uniqueid='$uniqueid',server_ip='$VARserver_ip',call_date='$SQLdate',lead_id = '$CIDlead_id',caller_code='$callerid',custom_call_id='';";
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01104'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- LCRERR VLE insert: |$affected_rows|\n|$stmtA|"; &agi_output;}
}
exit;
}
@@ -876,7 +948,7 @@ if ($VDACaffected_rows > 0)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArowsLI=$sthA->rows;
$dbhP=$dbhA; $mysql_count='010XX'; $MEL_aff_rows=$sthArowsLI; &mysql_error_logging;
$dbhP=$dbhA; $mysql_count='01105'; $MEL_aff_rows=$sthArowsLI; &mysql_error_logging;
if ($sthArowsLI > 0)
{
@aryA = $sthA->fetchrow_array;
@@ -1099,7 +1171,7 @@ if ($call_handle_method =~ /SURVEY/)
# play the message and let them press a number
$digits_to_collect = '1';
$opt_code = enter_pin_number($survey_first_audio_file,$survey_dtmf_digits);
$opt_code = enter_pin_number($survey_first_audio_file,$survey_dtmf_digits,$survey_method);
if (length($opt_code) < 1) {$opt_code = 'X';}
$opt_description = $opt_code;
@@ -3073,6 +3145,7 @@ sub enter_pin_number
{
$sound = $_[0];
$survey_dtmf_digits = $_[1];
$survey_method_TEMP = $_[2];
$digits_to_collect =~ s/DIGITID//gi;
@@ -3099,22 +3172,25 @@ sub enter_pin_number
$digit_loop_counter = length($totalDTMF);
while ( ($digit_loop_counter < $digits_to_collect) )
if ($survey_method_TEMP !~ /HANGUP/)
{
$digit = chr($AGI->wait_for_digit('10000')); # wait 10 seconds for input or until the pound key is pressed
if ( ($digit =~ /\d/) && ($survey_dtmf_digits =~ /$digit/) )
while ( ($digit_loop_counter < $digits_to_collect) )
{
$totalDTMF = "$totalDTMF$digit";
if ($AGILOG) {$agi_string = "digit |$digit| TotalDTMF |$totalDTMF|"; &agi_output;}
# $AGI->say_digits("$digit");
undef $digit;
$digit = chr($AGI->wait_for_digit('10000')); # wait 10 seconds for input or until the pound key is pressed
if ( ($digit =~ /\d/) && ($survey_dtmf_digits =~ /$digit/) )
{
$totalDTMF = "$totalDTMF$digit";
if ($AGILOG) {$agi_string = "digit |$digit| TotalDTMF |$totalDTMF|"; &agi_output;}
# $AGI->say_digits("$digit");
undef $digit;
}
else
{
$digit_loop_counter=$digits_to_collect;
}
$digit_loop_counter++;
}
else
{
$digit_loop_counter=$digits_to_collect;
}
$digit_loop_counter++;
}
$totalDTMF =~ s/\D//gi;