small changes to amd post process: VD_amd.agi

git-svn-id: svn://192.168.202.10@1728 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2011-09-27 04:28:44 +00:00
parent a72bbecf3a
commit a2152dde66
6 changed files with 125 additions and 26 deletions
+98 -7
View File
@@ -24,9 +24,9 @@
# Copyright (C) 2011 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# changes:
# 60206-1434 first build
# 60207-1205 added database records entries/modifications
# 60207-1507 added ability to send AMs to campaign-defined message to leave
# 60206-1434 - first build
# 60207-1205 - added database records entries/modifications
# 60207-1507 - added ability to send AMs to campaign-defined message to leave
# 60731-1407 - changed to use DBI-DBD::mysql
# - changed to use /etc/astguiclient.conf for configs
# 60815-1310 - added output options check from database
@@ -41,6 +41,7 @@
# 101111-1552 - Fixed minor bug in TTS filtering
# 110324-2334 - Logging changes made
# 110812-1515 - Added static tts file parsing and replacement
# 110926-1902 - Added extended logging and additional waitforsilence options
#
$script = 'VD_amd.agi';
@@ -388,9 +389,8 @@ else
if ($AGILOG) {$agi_string = "-- VDAD vicidial_log update: |$affected_rows|$uniqueid|"; &agi_output;}
}
### Grab vmail forward message values from the database
$stmtA = "SELECT am_message_exten,amd_send_to_vmx,waitforsilence_options FROM vicidial_campaigns where campaign_id = '$VD_campaign_id' limit 1;";
$stmtA = "SELECT am_message_exten,amd_send_to_vmx,waitforsilence_options,survey_recording,campaign_rec_filename FROM vicidial_campaigns where campaign_id = '$VD_campaign_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;
@@ -401,13 +401,15 @@ else
$DB_am_message_exten = $aryA[0];
$DB_amd_send_to_vmx = $aryA[1];
$waitforsilence_options = $aryA[2];
$survey_recording = $aryA[3];
$campaign_rec_filename = $aryA[4];
$sthA->finish();
}
else
{
$sthA->finish();
### Grab vmail forward message values from the database
$stmtA = "SELECT am_message_exten,amd_send_to_vmx,waitforsilence_options FROM vicidial_campaigns where closer_campaigns LIKE \"% $VD_campaign_id %\" order by campaign_id limit 1;";
$stmtA = "SELECT am_message_exten,amd_send_to_vmx,waitforsilence_options,survey_recording,campaign_rec_filename FROM vicidial_campaigns where closer_campaigns LIKE \"% $VD_campaign_id %\" order by campaign_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;
@@ -418,12 +420,89 @@ else
$DB_am_message_exten = $aryA[0];
$DB_amd_send_to_vmx = $aryA[1];
$waitforsilence_options = $aryA[2];
$survey_recording = $aryA[3];
$campaign_rec_filename = $aryA[4];
$sthA->finish();
}
else
{$sthA->finish();}
}
### if not a CPD message, log to the extended log and check for amd recording setting
if ($AMDSTATUS !~ /CPD/)
{
$VLEcount=0;
$stmtA = "SELECT count(*) FROM vicidial_log_extended where uniqueid='$uniqueid';";
$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;
$VLEcount = $aryA[0];
$sthA->finish();
}
if ($AGILOG) {$agi_string = "$VLEcount|$stmtA|"; &agi_output;}
if ($VLEcount < 1)
{
$stmtA = "INSERT INTO vicidial_log_extended set uniqueid='$uniqueid',server_ip='$VARserver_ip',call_date='$now_date',lead_id = '$VD_lead_id',caller_code='$callerid',custom_call_id='';";
$affected_rows = $dbhA->do($stmtA);
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
if ($AGILOG) {$agi_string = "-- VDAD vicidial_log_extended insert: |$affected_rows|\n|$stmtA|"; &agi_output;}
}
if ($survey_recording =~ /Y_WITH_AMD/)
{
$stmtA = "SELECT vendor_lead_code FROM vicidial_list where lead_id='$VD_lead_id';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$vendor_lead_code = $aryA[0];
}
$sthA->finish();
# get date/time
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$year = ($year + 1900);
$Tyear = ($year - 2000);
$mon++;
if ($mon < 10) {$mon = "0$mon";}
if ($mday < 10) {$mday = "0$mday";}
if ($hour < 10) {$hour = "0$hour";}
if ($min < 10) {$min = "0$min";}
if ($sec < 10) {$sec = "0$sec";}
$now_date_epoch = time();
$now_date = "$year-$mon-$mday $hour:$min:$sec";
$recdate = "$year$mon$mday-$hour$min$sec";
$tinydate = "$Tyear$mon$mday$hour$min$sec";
$campaign_rec_filename =~ s/CAMPAIGN/$VD_campaign_id/gi;
$campaign_rec_filename =~ s/CUSTPHONE/$VD_phone_number/gi;
$campaign_rec_filename =~ s/FULLDATE/$recdate/gi;
$campaign_rec_filename =~ s/TINYDATE/$tinydate/gi;
$campaign_rec_filename =~ s/EPOCH/$now_date_epoch/gi;
$campaign_rec_filename =~ s/AGENT/VDAD/gi;
$campaign_rec_filename =~ s/VENDORLEADCODE/$vendor_lead_code/gi;
$campaign_rec_filename =~ s/LEADID/$VD_lead_id/gi;
$campaign_rec_filename =~ s/\"|\'//gi;
$campaign_rec_filename =~ s/ //gi;
$AGI->exec("Monitor wav|/var/spool/asterisk/monitor/MIX/$campaign_rec_filename");
### insert record into recording_log table ###
$stmtA = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,length_in_sec,filename,lead_id,user,location,vicidial_id) values('$channel','$VARserver_ip','$VD_phone_number','$now_date','$now_date_epoch','0','$campaign_rec_filename','$VD_lead_id','VDAD','$campaign_rec_filename','$uniqueid');";
$SRaffected_rows = $dbhA->do($stmtA);
if ($AGILOG) {$agi_string = "-- AMD RECORDING STARTED : |$SRaffected_rows|$campaign_rec_filename|$stmtA|"; &agi_output;}
}
}
### check for list_id override
if ( ($DB_amd_send_to_vmx =~ /Y/) || ($AMDSTATUS =~ /CPD/) )
{
@@ -635,10 +714,22 @@ else
### run waitforsilence if enabled
if (length($waitforsilence_options) > 0)
if ( (length($waitforsilence_options) > 0) && ($waitforsilence_options !~ /NONE|X/i) )
{
if ($AGILOG) {$agi_string = "WaitForSilence launched: |$waitforsilence_options|"; &agi_output;}
$AGI->exec("WaitForSilence","$waitforsilence_options");
}
if ($waitforsilence_options =~ /X/i)
{
$waitforsilence_seconds = $waitforsilence_options;
$waitforsilence_seconds =~ s/\D//gi;
if (length($waitforsilence_seconds) < 1)
{$waitforsilence_seconds = '1';}
if ($waitforsilence_seconds > 20)
{$waitforsilence_seconds = '20';}
if ($AGILOG) {$agi_string = "Wait time seconds in WaitForSilence field: |$waitforsilence_seconds|$waitforsilence_options|"; &agi_output;}
sleep($waitforsilence_seconds);
}
### play messages
if ($DB_am_message_exten =~ /\|/)
+15 -12
View File
@@ -90,12 +90,13 @@
# 110723-2330 - Set CID to customer phone number and caller code when transferring to CALLMENU
# 110812-1514 - Added static tts file parsing and replacement
# 110829-2324 - Added survey_recording option
# 110926-1929 - Small fixes
#
$script = 'agi-VDAD_ALL_outbound.agi';
$AGILOG = '0';
$mel=1; # Mysql Error Log enabled = 1
$mysql_log_count=76;
$mysql_log_count=84;
$one_mysql_log=0;
@@ -539,7 +540,7 @@ if ($VDACaffected_rows > 0)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$dbhP=$dbhA; $mysql_count='01XXX'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
$dbhP=$dbhA; $mysql_count='01077'; $MEL_aff_rows=$sthArows; &mysql_error_logging;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
@@ -579,7 +580,7 @@ if ($VDACaffected_rows > 0)
### insert record into recording_log table ###
$stmtA = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,length_in_sec,filename,lead_id,user,location,vicidial_id) values('$channel','$VARserver_ip','$VDADphone','$now_date','$now_date_epoch','0','$campaign_rec_filename','$CIDlead_id','VDAD','$campaign_rec_filename','$uniqueid');";
$SRaffected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01XXX'; $MEL_aff_rows=$SRaffected_rows; &mysql_error_logging;
$dbhP=$dbhA; $mysql_count='01078'; $MEL_aff_rows=$SRaffected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- SURVEY RECORDING STARTED : |$SRaffected_rows|$campaign_rec_filename|$stmtA|"; &agi_output;}
}
@@ -1400,11 +1401,11 @@ if ($call_handle_method =~ /SURVEY/)
$stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='$callerid',queue='$VDADcampaign',agent='NONE',verb='EXITWITHTIMEOUT',data1='1',serverid='$queuemetrics_log_id';";
$Baffected_rows = $dbhB->do($stmtB);
$dbhP=$dbhB; $stmtA=$stmtB; $mysql_count='01XXX'; $MEL_aff_rows=$Baffected_rows; &mysql_error_logging;
$dbhP=$dbhB; $stmtA=$stmtB; $mysql_count='01079'; $MEL_aff_rows=$Baffected_rows; &mysql_error_logging;
$stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='$callerid',queue='$VDADcampaign',agent='NONE',verb='CALLSTATUS',data1='$survey_status',serverid='$queuemetrics_log_id';";
$Baffected_rows = $dbhB->do($stmtB);
$dbhP=$dbhB; $stmtA=$stmtB; $mysql_count='01XXX'; $MEL_aff_rows=$Baffected_rows; &mysql_error_logging;
$dbhP=$dbhB; $stmtA=$stmtB; $mysql_count='01080'; $MEL_aff_rows=$Baffected_rows; &mysql_error_logging;
$dbhB->disconnect();
}
@@ -2667,11 +2668,11 @@ if ($drop_timer > $DROP_TIME)
$stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='$callerid',queue='$VDADcampaign',agent='NONE',verb='EXITWITHTIMEOUT',data1='1',serverid='$queuemetrics_log_id';";
$Baffected_rows = $dbhB->do($stmtB);
$dbhP=$dbhB; $stmtA=$stmtB; $mysql_count='01XXX'; $MEL_aff_rows=$Baffected_rows; &mysql_error_logging;
$dbhP=$dbhB; $stmtA=$stmtB; $mysql_count='01081'; $MEL_aff_rows=$Baffected_rows; &mysql_error_logging;
$stmtB = "INSERT INTO queue_log SET partition='P01',time_id='$now_date_epoch',call_id='$callerid',queue='$VDADcampaign',agent='NONE',verb='CALLSTATUS',data1='IVRXFR',serverid='$queuemetrics_log_id';";
$Baffected_rows = $dbhB->do($stmtB);
$dbhP=$dbhB; $stmtA=$stmtB; $mysql_count='01XXX'; $MEL_aff_rows=$Baffected_rows; &mysql_error_logging;
$dbhP=$dbhB; $stmtA=$stmtB; $mysql_count='01082'; $MEL_aff_rows=$Baffected_rows; &mysql_error_logging;
$dbhB->disconnect();
}
@@ -2679,13 +2680,13 @@ if ($drop_timer > $DROP_TIME)
$stmtA = "UPDATE vicidial_log FORCE INDEX(lead_id) set status='IVRXFR',end_epoch='$now_date_epoch',length_in_sec='$drop_seconds',term_reason='CALLMENUXFER' where lead_id = '$CIDlead_id' and uniqueid LIKE \"$Euniqueid%\";";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01XXX'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
$dbhP=$dbhA; $mysql_count='01083'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDAD vicidial_log update: |$affected_rows|$uniqueid"; &agi_output;}
$stmtA = "UPDATE vicidial_list set status='IVRXFR' where lead_id = '$CIDlead_id';";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$affected_rows = $dbhA->do($stmtA);
$dbhP=$dbhA; $mysql_count='01XXX'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
$dbhP=$dbhA; $mysql_count='01084'; $MEL_aff_rows=$affected_rows; &mysql_error_logging;
if ($AGILOG) {$agi_string = "-- VDAD vicidial_list update: |$affected_rows|$CIDlead_id"; &agi_output;}
}
else
@@ -3038,9 +3039,11 @@ sub cpd_end_call
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
sleep(1);
$AGI->stream_file('sip-silence');
$AGI->stream_file('sip-silence');
$AGI->stream_file('sip-silence');
# $AGI->stream_file('ding'); # stop music-on-hold process
# sleep(1);
if ($AGILOG) {$agi_string = "exiting the VDAD app, CPD transferring call to $DROPexten"; &agi_output;}
print "SET CONTEXT $ext_context\n";
@@ -830,7 +830,7 @@ disable_dispo_status VARCHAR(6) default '',
screen_labels VARCHAR(20) default '--SYSTEM-SETTINGS--',
status_display_fields VARCHAR(30) default 'CALLID',
na_call_url TEXT,
survey_recording ENUM('Y','N') default 'N',
survey_recording ENUM('Y','N','Y_WITH_AMD') default 'N',
pllb_grouping ENUM('DISABLED','ONE_SERVER_ONLY','CASCADING') default 'DISABLED',
pllb_grouping_limit SMALLINT(5) default '50'
);
@@ -2672,7 +2672,7 @@ CREATE TABLE vicidial_log_noanswer_archive LIKE vicidial_log_noanswer;
CREATE TABLE vicidial_did_agent_log_archive LIKE vicidial_did_agent_log;
CREATE UNIQUE INDEX vdala on vicidial_did_agent_log_archive (uniqueid,call_date,did_route);
UPDATE system_settings SET db_schema_version='1299',db_schema_update_date=NOW();
UPDATE system_settings SET db_schema_version='1300',db_schema_update_date=NOW();
GRANT RELOAD ON *.* TO cron@'%';
GRANT RELOAD ON *.* TO cron@localhost;
+4
View File
@@ -1075,3 +1075,7 @@ ALTER TABLE vicidial_inbound_dids ADD custom_four VARCHAR(100) default '';
ALTER TABLE vicidial_inbound_dids ADD custom_five VARCHAR(100) default '';
UPDATE system_settings SET db_schema_version='1299',db_schema_update_date=NOW() where db_schema_version < 1299;
ALTER TABLE vicidial_campaigns MODIFY survey_recording ENUM('Y','N','Y_WITH_AMD') default 'N';
UPDATE system_settings SET db_schema_version='1300',db_schema_update_date=NOW() where db_schema_version < 1300;
@@ -748,6 +748,7 @@ If After Hours Action is set to CALLMENU, the call will be sent to this Call Men
Drop Call Menu||
If Drop Action is set to CALLMENU, the call will be sent to this call menu if it reaches Drop Call Seconds||
Custom DID Fields -</B> These five fields can be used for various purposes, mostly relating to custom programming and reports||
If set to Y_WITH_AMD even answering machine detected message calls will be recorded||
lead_report_export.php
+5 -5
View File
@@ -2012,7 +2012,6 @@ if ($non_latin < 1)
$webphone_auto_answer = ereg_replace("[^NY]","",$webphone_auto_answer);
$noanswer_log = ereg_replace("[^NY]","",$noanswer_log);
$did_agent_log = ereg_replace("[^NY]","",$did_agent_log);
$survey_recording = ereg_replace("[^NY]","",$survey_recording);
$qc_enabled = ereg_replace("[^0-9NY]","",$qc_enabled);
$active = ereg_replace("[^0-9NY]","",$active);
@@ -2300,6 +2299,7 @@ if ($non_latin < 1)
$user_start = ereg_replace("[^-_0-9a-zA-Z]","",$user_start);
$drop_callmenu = ereg_replace("[^-_0-9a-zA-Z]","",$drop_callmenu);
$after_hours_callmenu = ereg_replace("[^-_0-9a-zA-Z]","",$after_hours_callmenu);
$survey_recording = ereg_replace("[^-_0-9a-zA-Z]","",$survey_recording);
### ALPHA-NUMERIC and underscore and dash and slash and dot
$menu_prompt = ereg_replace("[^-\/\|\._0-9a-zA-Z]","",$menu_prompt);
@@ -2475,7 +2475,7 @@ if ($non_latin < 1)
$voicemail_options = ereg_replace("[^ -\=\*\#\.\,\:\/\|\@\_0-9a-zA-Z]","",$voicemail_options);
### NUMERIC and comma and pipe
$waitforsilence_options = ereg_replace("[^\|\,0-9]","",$waitforsilence_options);
$waitforsilence_options = ereg_replace("[^\|\,0-9a-zA-Z]","",$waitforsilence_options);
### value cleaning
$no_agent_action_value = ereg_replace("[^-\/\|\_\#\*\,\.\_0-9a-zA-Z]","",$no_agent_action_value);
@@ -4835,7 +4835,7 @@ if ($ADD==99999)
<BR>
<A NAME="vicidial_campaigns-survey_recording">
<BR>
<B>Survey Recording -</B> If enabled, this will start recording when the call is answered. Only recommended if the method is not set to transfer to an agent. Default is N for disabled.
<B>Survey Recording -</B> If enabled, this will start recording when the call is answered. Only recommended if the method is not set to transfer to an agent. Default is N for disabled. If set to Y_WITH_AMD even answering machine detected message calls will be recorded.
<?php
}
@@ -20345,7 +20345,7 @@ if ($ADD==31)
{$cfwHTML = '<option>FORM</option>';}
echo "<tr bgcolor=#B6D3FC><td align=right>Get Call Launch: </td><td align=left><select size=1 name=get_call_launch><option selected>NONE</option><option>SCRIPT</option><option>WEBFORM</option>$eswHTML$cfwHTML<option selected>$get_call_launch</option></select>$NWB#vicidial_campaigns-get_call_launch$NWE</td></tr>\n";
echo "<tr bgcolor=#8EBCFD><td align=right>Answering Machine Message: </td><td><input type=text size=50 maxlength=100 name=am_message_exten id=am_message_exten value=\"$am_message_exten\"> <a href=\"javascript:launch_chooser('am_message_exten','date',1200);\">audio chooser</a> $NWB#vicidial_campaigns-am_message_exten$NWE\n";
echo "<tr bgcolor=#8EBCFD><td align=right>Answering Machine Message: </td><td><input type=text size=50 maxlength=100 name=am_message_exten id=am_message_exten value=\"$am_message_exten\"> <a href=\"javascript:launch_chooser('am_message_exten','date',2000);\">audio chooser</a> $NWB#vicidial_campaigns-am_message_exten$NWE\n";
$stmt="SELECT count(*) from vicidial_lists where campaign_id='$campaign_id' and am_message_exten_override != '' and active='Y';";
$rslt=mysql_query($stmt, $link);
$rowx=mysql_fetch_row($rslt);
@@ -21396,7 +21396,7 @@ if ($ADD==31)
echo "<tr bgcolor=#B9CBFD><td align=right>Voicemail: </td><td><input type=text size=12 maxlength=10 name=voicemail_ext id=voicemail_ext value=\"$voicemail_ext\"> <a href=\"javascript:launch_vm_chooser('voicemail_ext','vm',300);\">voicemail chooser</a> $NWB#vicidial_campaigns-voicemail_ext$NWE</td></tr>\n";
echo "<tr bgcolor=#B9CBFD><td align=right>Survey Call Menu: </td><td align=left><select size=1 name=survey_menu_id id=survey_menu_id>$call_menu_list<option SELECTED>$survey_menu_id</option></select>$NWB#vicidial_campaigns-survey_menu_id$NWE</td></tr>\n";
echo "<tr bgcolor=#B9CBFD><td align=right>Survey Recording: </td><td align=left><select size=1 name=survey_recording id=survey_recording><option>Y</option><option>N</option><option SELECTED>$survey_recording</option></select>$NWB#vicidial_campaigns-survey_recording$NWE</td></tr>\n";
echo "<tr bgcolor=#B9CBFD><td align=right>Survey Recording: </td><td align=left><select size=1 name=survey_recording id=survey_recording><option>Y</option><option>N</option><option>Y_WITH_AMD</option><option SELECTED>$survey_recording</option></select>$NWB#vicidial_campaigns-survey_recording$NWE</td></tr>\n";
echo "<tr bgcolor=#B9CBFD><td align=center colspan=2><input type=submit name=submit value=SUBMIT></td></tr>\n";
echo "</table>\n";