From a2152dde66fdc043f7d3925f9e4083d4aac2b5bf Mon Sep 17 00:00:00 2001 From: mattf Date: Tue, 27 Sep 2011 04:28:44 +0000 Subject: [PATCH] small changes to amd post process: VD_amd.agi git-svn-id: svn://192.168.202.10@1728 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/trunk/agi/VD_amd.agi | 105 ++++++++++++++++-- agc_2-X/trunk/agi/agi-VDAD_ALL_outbound.agi | 27 +++-- .../trunk/extras/MySQL_AST_CREATE_tables.sql | 4 +- agc_2-X/trunk/extras/upgrade_2.4.sql | 4 + .../TO_BE_TRANSLATED_2.4.txt | 1 + agc_2-X/trunk/www/vicidial/admin.php | 10 +- 6 files changed, 125 insertions(+), 26 deletions(-) diff --git a/agc_2-X/trunk/agi/VD_amd.agi b/agc_2-X/trunk/agi/VD_amd.agi index 94df3340..ff00ea4e 100644 --- a/agc_2-X/trunk/agi/VD_amd.agi +++ b/agc_2-X/trunk/agi/VD_amd.agi @@ -24,9 +24,9 @@ # Copyright (C) 2011 Matt Florell 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 =~ /\|/) diff --git a/agc_2-X/trunk/agi/agi-VDAD_ALL_outbound.agi b/agc_2-X/trunk/agi/agi-VDAD_ALL_outbound.agi index 1c0a4055..1c320059 100644 --- a/agc_2-X/trunk/agi/agi-VDAD_ALL_outbound.agi +++ b/agc_2-X/trunk/agi/agi-VDAD_ALL_outbound.agi @@ -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"; diff --git a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql index 10b30ab2..3cf4223e 100644 --- a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql +++ b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql @@ -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; diff --git a/agc_2-X/trunk/extras/upgrade_2.4.sql b/agc_2-X/trunk/extras/upgrade_2.4.sql index ab4554f4..efcb0998 100644 --- a/agc_2-X/trunk/extras/upgrade_2.4.sql +++ b/agc_2-X/trunk/extras/upgrade_2.4.sql @@ -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; diff --git a/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.4.txt b/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.4.txt index 72af6a09..92e8b425 100644 --- a/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.4.txt +++ b/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.4.txt @@ -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 - 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 diff --git a/agc_2-X/trunk/www/vicidial/admin.php b/agc_2-X/trunk/www/vicidial/admin.php index 86491705..9a6e71bd 100644 --- a/agc_2-X/trunk/www/vicidial/admin.php +++ b/agc_2-X/trunk/www/vicidial/admin.php @@ -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)

- Survey Recording - 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. + Survey Recording - 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. FORM';} echo "Get Call Launch: $NWB#vicidial_campaigns-get_call_launch$NWE\n"; - echo "Answering Machine Message:
audio chooser $NWB#vicidial_campaigns-am_message_exten$NWE\n"; + echo "Answering Machine Message: audio chooser $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 "Voicemail: voicemail chooser $NWB#vicidial_campaigns-voicemail_ext$NWE\n"; echo "Survey Call Menu: $NWB#vicidial_campaigns-survey_menu_id$NWE\n"; - echo "Survey Recording: $NWB#vicidial_campaigns-survey_recording$NWE\n"; + echo "Survey Recording: $NWB#vicidial_campaigns-survey_recording$NWE\n"; echo "\n"; echo "\n";