From 1fe4d4d483430848331239f68e15a34624601cc8 Mon Sep 17 00:00:00 2001 From: mattf Date: Wed, 29 Apr 2009 18:24:39 +0000 Subject: [PATCH] added new method for monitoring in realtime screen added 4-call-path option for outbound surveys added text-to-speech ability in outbound survey campaigns git-svn-id: svn://192.168.202.10@1099 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/trunk/UPGRADE | 5 + agc_2-X/trunk/agi/agi-VDAD_ALL_outbound.agi | 683 ++++++++++++------ .../bin/Vtiger_OUT_sync2VICIDIAL_file.pl | 180 ++++- agc_2-X/trunk/docs/NON-AGENT_API.txt | 39 +- .../trunk/extras/MySQL_AST_CREATE_tables.sql | 21 +- agc_2-X/trunk/extras/upgrade_2.2.0.sql | 21 + .../TO_BE_TRANSLATED_2.2.0.txt | 14 + agc_2-X/trunk/www/agc/vdc_db_query.php | 2 +- .../trunk/www/vicidial/AST_timeonVDADall.php | 162 ++++- agc_2-X/trunk/www/vicidial/admin.php | 81 ++- agc_2-X/trunk/www/vicidial/non_agent_api.php | 140 +++- 11 files changed, 1076 insertions(+), 272 deletions(-) diff --git a/agc_2-X/trunk/UPGRADE b/agc_2-X/trunk/UPGRADE index a06c6624..544cb60f 100644 --- a/agc_2-X/trunk/UPGRADE +++ b/agc_2-X/trunk/UPGRADE @@ -20,6 +20,11 @@ NOTE: Upgrading from 1.1.12-3 to 2.0.1 is at the bottom \. /path/from/root/extras/upgrade_2.2.0.sql quit +3. Added new method for monitoring from the Real-time screen using a phone entry + +4. Outbound Survey option for using Cepstral Text-to-speech. Requires some + manual configuration and tweaking of TTS scripts. + 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 99e66273..e9011c15 100644 --- a/agc_2-X/trunk/agi/agi-VDAD_ALL_outbound.agi +++ b/agc_2-X/trunk/agi/agi-VDAD_ALL_outbound.agi @@ -348,30 +348,6 @@ if ($dialplan_duplicate_count > 0) exit; } -### pre-generate Cepstral first and last name as an audio file -if ($call_handle_method =~ /SURVEYCAMPCEP/) - { - $stmtA = "SELECT first_name,last_name FROM vicidial_list where lead_id='$CIDlead_id';"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - $dbhP=$dbhA; $mysql_count='01057'; $MEL_aff_rows=$sthArows; &mysql_error_logging; - if ($sthArows > 0) - { - @aryA = $sthA->fetchrow_array; - # $survey_customer_nameRAW = "Hello, If this is $aryA[0] $aryA[1] Please press one now "; - $survey_customer_nameRAW = "hello, this is a call for $aryA[0] $aryA[1],, if you are $aryA[0] $aryA[1] then press 1 to speak with an agent,, if we have not reached the correct number, please press 2 to have your telephone number removed from our database"; - $survey_customer_name = $survey_customer_nameRAW; - $survey_customer_name =~ s/[^, 0-9a-zA-Z]//gi; - $survey_customer_name =~ s/ /\\ /gi; - $voice = 'Allison-8kHz'; - print STDERR "\nGenerating: $survey_customer_name - $voice\n"; - `$PATHagi/cepstral_generate.pl --debug --voice=$voice --dialog=$survey_customer_name >> $CEPLOGfile`; - } - $sthA->finish(); - } - - ### Grab call parameters from vicidial_auto_calls table $stmtA = "UPDATE vicidial_auto_calls set uniqueid='$unique_id', channel='$channel',status='LIVE',stage='LIVE-0' where callerid='$callerid' order by call_time desc limit 1;"; $affected_rows = $dbhA->do($stmtA); @@ -406,13 +382,12 @@ if ($affected_rows > 0) $sthA->finish(); ### Grab campaign values from the database - $stmtA = "SELECT drop_call_seconds,drop_action,safe_harbor_exten,concurrent_transfers,next_agent_call,voicemail_ext,drop_inbound_group,use_internal_dnc,use_campaign_dnc,cpd_amd_action,am_message_exten,three_way_call_cid,campaign_cid FROM vicidial_campaigns where campaign_id = '$VDADcampaign';"; + $stmtA = "SELECT drop_call_seconds,drop_action,safe_harbor_exten,concurrent_transfers,next_agent_call,voicemail_ext,drop_inbound_group,use_internal_dnc,use_campaign_dnc,cpd_amd_action,am_message_exten,three_way_call_cid,campaign_cid,survey_first_audio_file,survey_opt_in_audio_file,survey_ni_audio_file,survey_third_audio_file,survey_fourth_audio_file FROM vicidial_campaigns where campaign_id = '$VDADcampaign';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; $dbhP=$dbhA; $mysql_count='01007'; $MEL_aff_rows=$sthArows; &mysql_error_logging; - $rec_count=0; - while ($sthArows > $rec_count) + if ($sthArows > 0) { @aryA = $sthA->fetchrow_array; $DBdrop_call_seconds = "$aryA[0]"; @@ -431,10 +406,131 @@ if ($affected_rows > 0) $am_message_exten = "$aryA[10]"; $three_way_call_cid = "$aryA[11]"; $campaign_cid = "$aryA[12]"; - $rec_count++; + $survey_first_audio_file = "$aryA[13]"; + $survey_opt_in_audio_file = "$aryA[14]"; + $survey_ni_audio_file = "$aryA[15]"; + $survey_third_audio_file = "$aryA[16]"; + $survey_fourth_audio_file = "$aryA[17]"; } $sthA->finish(); + ### pre-generate Cepstral first and last name as an audio file + if ($call_handle_method =~ /SURVEYCAMPCEP/) + { + $t=0; + if ($survey_first_audio_file =~ /^TTS/) + { + $TTS_prompt[$t] = 'survey_first_audio_file'; + $TTS_filename[$t] = $survey_first_audio_file; + $TTS_filename[$t]=~s/^TTS//gi; + $t++; + } + if ($survey_opt_in_audio_file =~ /^TTS/) + { + $TTS_prompt[$t] = 'survey_opt_in_audio_file'; + $TTS_filename[$t] = $survey_opt_in_audio_file; + $TTS_filename[$t]=~s/^TTS//gi; + $t++; + } + if ($survey_ni_audio_file =~ /^TTS/) + { + $TTS_prompt[$t] = 'survey_ni_audio_file'; + $TTS_filename[$t] = $survey_ni_audio_file; + $TTS_filename[$t]=~s/^TTS//gi; + $t++; + } + if ($survey_third_audio_file =~ /^TTS/) + { + $TTS_prompt[$t] = 'survey_third_audio_file'; + $TTS_filename[$t] = $survey_third_audio_file; + $TTS_filename[$t]=~s/^TTS//gi; + $t++; + } + if ($survey_fourth_audio_file =~ /^TTS/) + { + $TTS_prompt[$t] = 'survey_fourth_audio_file'; + $TTS_filename[$t] = $survey_fourth_audio_file; + $TTS_filename[$t]=~s/^TTS//gi; + $t++; + } + + ### if there are TTS audio files run this + if ($t > 0) + { + $stmtA = "SELECT first_name,last_name,title FROM vicidial_list where lead_id='$CIDlead_id';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $dbhP=$dbhA; $mysql_count='01057'; $MEL_aff_rows=$sthArows; &mysql_error_logging; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $TTS_first_name = $aryA[0]; + $TTS_last_name = $aryA[1]; + $TTS_title = $aryA[2]; + } + $sthA->finish(); + + $s=0; + while ($s < $t) + { + $stmtA = "SELECT tts_text FROM vicidial_tts_prompts where tts_id='$TTS_filename[$s]';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + $dbhP=$dbhA; $mysql_count='01057'; $MEL_aff_rows=$sthArows; &mysql_error_logging; + if ($s < 1) {$hideCLI = '';} + else {$hideCLI = '&';} + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $TTS_text[$s] = $aryA[0]; + $TTS_text[$s] =~ s/--A--first_name--B--/$TTS_first_name/gi; + $TTS_text[$s] =~ s/--A--last_name--B--/$TTS_last_name/gi; + $TTS_text[$s] =~ s/--A--title--B--/$TTS_title/gi; + $TTS_text[$s] =~ s/[^,\.\<\>\'\/\= 0-9a-zA-Z]//gi; + $TTS_textRAW[$s] = $TTS_text[$s]; + $TTS_text[$s] =~ s/ /\\ /gi; + $TTS_text[$s] =~ s/\./\\./gi; + $TTS_text[$s] =~ s/\=/\\=/gi; + $TTS_text[$s] =~ s/\/\\>/gi; + $TTS_text[$s] =~ s/\//\\\//gi; + $TTS_text[$s] =~ s/\'/\\'/gi; + $voice = 'Allison-8kHz'; + print STDERR "\nGenerating: $TTS_text[$s] - $voice\n"; + `$PATHagi/cepstral_generate.pl --debug --voice=$voice --dialog=$TTS_text[$s] >> $CEPLOGfile $hideCLI`; + + use Digest::MD5 qw(md5_hex); + + $enc = md5_hex("$TTS_textRAW[$s]-$voice"); # the hash + $enc_ftl = substr($enc, 0, 2); # first letter of hash + $TTS_filename_path[$s] = $PATHsounds . "/tts/" . $enc_ftl . "/tts-" . $enc; + print STDERR "\nfilename: $TTS_filename_path[$s]\n"; + } + $sthA->finish(); + + $s++; + } + + $s=0; + while ($s < $t) + { + if ($TTS_prompt[$s] =~ /survey_first_audio_file/) + {$survey_first_audio_file = $TTS_filename_path[$s];} + if ($TTS_prompt[$s] =~ /survey_opt_in_audio_file/) + {$survey_opt_in_audio_file = $TTS_filename_path[$s];} + if ($TTS_prompt[$s] =~ /survey_ni_audio_file/) + {$survey_ni_audio_file = $TTS_filename_path[$s];} + if ($TTS_prompt[$s] =~ /survey_third_audio_file/) + {$survey_third_audio_file = $TTS_filename_path[$s];} + if ($TTS_prompt[$s] =~ /survey_fourth_audio_file/) + {$survey_fourth_audio_file = $TTS_filename_path[$s];} + $s++; + } + } + } + $stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed,alt_dial) values('$uniqueid','$CIDlead_id','$VDADcampaign','$SQLdate','$now_date_epoch','$vdlog_status','$VDADphone_code','$VDADphone','VDAD','N','$VDADalt_dial')"; if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} $affected_rows = $dbhA->do($stmtA); @@ -592,7 +688,7 @@ if ($call_handle_method =~ /SURVEY/) ### check to see if the SURVEY settings should be pulled from the campaign settings in the database if ($call_handle_method =~ /SURVEYCAMP/) { - $stmtA = "SELECT survey_first_audio_file,survey_dtmf_digits,survey_ni_digit,survey_opt_in_audio_file,survey_ni_audio_file,survey_method,survey_no_response_action,survey_ni_status,survey_response_digit_map,survey_xfer_exten,survey_camp_record_dir FROM vicidial_campaigns where campaign_id='$VDADcampaign';"; + $stmtA = "SELECT survey_dtmf_digits,survey_ni_digit,survey_method,survey_no_response_action,survey_ni_status,survey_response_digit_map,survey_xfer_exten,survey_camp_record_dir,survey_third_digit,survey_third_status,survey_third_exten,survey_fourth_digit,survey_fourth_status,survey_fourth_exten FROM vicidial_campaigns where campaign_id='$VDADcampaign';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -601,17 +697,20 @@ if ($call_handle_method =~ /SURVEY/) { @aryA = $sthA->fetchrow_array; - $survey_first_audio_file = "$aryA[0]"; - $survey_dtmf_digits = "$aryA[1]"; - $survey_ni_digit = "$aryA[2]"; - $survey_opt_in_audio_file = "$aryA[3]"; - $survey_ni_audio_file = "$aryA[4]"; - $survey_method = "$aryA[5]"; - $survey_no_response_action = "$aryA[6]"; - $survey_ni_status = "$aryA[7]"; - $survey_response_digit_map = "$aryA[8]"; - $survey_xfer_exten = "$aryA[9]"; - $survey_camp_record_dir = "$aryA[10]"; + $survey_dtmf_digits = "$aryA[0]"; + $survey_ni_digit = "$aryA[1]"; + $survey_method = "$aryA[2]"; + $survey_no_response_action = "$aryA[3]"; + $survey_ni_status = "$aryA[4]"; + $survey_response_digit_map = "$aryA[5]"; + $survey_xfer_exten = "$aryA[6]"; + $survey_camp_record_dir = "$aryA[7]"; + $survey_third_digit = "$aryA[8]"; + $survey_third_status = "$aryA[9]"; + $survey_third_exten = "$aryA[10]"; + $survey_fourth_digit = "$aryA[11]"; + $survey_fourth_status = "$aryA[12]"; + $survey_fourth_exten = "$aryA[13]"; @digit_map = split(/\|/,$survey_response_digit_map); @@ -620,15 +719,6 @@ if ($call_handle_method =~ /SURVEY/) $sthA->finish(); } - if ($call_handle_method =~ /SURVEYCAMPCEP/) - { - use Digest::MD5 qw(md5_hex); - - $enc = md5_hex("$survey_customer_nameRAW-$voice"); # the hash - $enc_ftl = substr($enc, 0, 2); # first letter of hash - $survey_first_audio_file = $PATHsounds . "/tts/" . $enc_ftl . "/tts-" . $enc; - } - # 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); @@ -723,188 +813,276 @@ if ($call_handle_method =~ /SURVEY/) exit; } - else + + ### third digit option + if ($opt_code =~ /$survey_third_digit/) { - # they opted in - if ( ($opt_code =~ /\d/) || ($survey_no_response_action =~ /OPTOUT/) ) - { - $now_date_epoch = time(); - $FDtarget = ($now_date_epoch + 60); - ($Fsec,$Fmin,$Fhour,$Fmday,$Fmon,$Fyear,$Fwday,$Fyday,$Fisdst) = localtime($FDtarget); - $Fyear = ($Fyear + 1900); - $Fmon++; - if ($Fmon < 10) {$Fmon = "0$Fmon";} - if ($Fmday < 10) {$Fmday = "0$Fmday";} - if ($Fhour < 10) {$Fhour = "0$Fhour";} - if ($Fmin < 10) {$Fmin = "0$Fmin";} - if ($Fsec < 10) {$Fsec = "0$Fsec";} - $FDtsSQLdate = "$Fyear$Fmon$Fmday$Fhour$Fmin$Fsec"; + if ( $survey_third_audio_file ne "") + { + $AGI->stream_file($survey_third_audio_file); + } - $stmtA = "UPDATE vicidial_auto_calls set last_update_time='$FDtsSQLdate' where callerid='$callerid' order by call_time desc limit 1;"; + $stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' order by call_time desc limit 1;"; + $affected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='01017'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; + if ($AGILOG) + { + $agi_string = "-- VDAD vac record deleted: |$affected_rows|$VDADcampaign|"; + &agi_output; + } + + $Euniqueid=$uniqueid; + $Euniqueid =~ s/\.\d+//gi; + $now_date_epoch = time(); + $drop_seconds = $now_date_epoch - $start_time_epoch; + $stmtA = "UPDATE vicidial_log FORCE INDEX(lead_id) set status='$survey_third_status', end_epoch='$now_date_epoch', length_in_sec='$drop_seconds', term_reason='CALLER' 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='01018'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; + if ($AGILOG) + { + $agi_string = "-- VDAD vicidial_log update: $survey_third_status|$affected_rows|$uniqueid|$drop_seconds|"; + &agi_output; + } + + $stmtA = "UPDATE vicidial_list set status='$survey_third_status' where lead_id = '$CIDlead_id';"; + if ($AGILOG) { $agi_string = "|$stmtA|"; &agi_output; } + $affected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='01019'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; + if ($AGILOG) + { + $agi_string = "-- VDAD vicidial_list update: $survey_third_status|$affected_rows|$CIDlead_id"; + &agi_output; + } + + if (($use_internal_dnc =~ /Y/) && ($survey_third_status eq "DNC")) + { + $stmtA = "INSERT INTO vicidial_dnc set phone_number='$VDADphone';"; + if ($AGILOG) { $agi_string = "|$stmtA|"; &agi_output; } $affected_rows = $dbhA->do($stmtA); - $dbhP=$dbhA; $mysql_count='01022'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; - if ($AGILOG) {$agi_string = "-- VDAC posttime record: |$affected_rows|$FDtsSQLdate|$callerid|"; &agi_output;} - - if ( $survey_opt_in_audio_file ne "") + $dbhP=$dbhA; $mysql_count='01020'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; + if ($AGILOG) { - $AGI->stream_file($survey_opt_in_audio_file); + $agi_string = "-- VDAD vicidial_dnc insert: $affected_rows|$VDADphone"; + &agi_output; } - - if ($survey_method =~ /VOICEMAIL|EXTENSION|HANGUP/) + } + if (($use_campaign_dnc =~ /Y/) && ($survey_third_status eq "DNC")) + { + $stmtA = "INSERT INTO vicidial_campaign_dnc set phone_number='$VDADphone', campaign_id='$VDADcampaign';"; + if ($AGILOG) { $agi_string = "|$stmtA|"; &agi_output; } + $affected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='01021'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; + if ($AGILOG) { - $DROPexten=''; - if ($survey_method =~ /VOICEMAIL/) + $agi_string = "-- VDAD vicidial_campaign_dnc insert: $affected_rows|$VDADphone|$VDADcampaign"; + &agi_output; + } + } + + if (length($survey_third_exten) > 0) + { + if ($AGILOG) {$agi_string = "exiting the VDAD SURVEY app, transferring call to $survey_third_exten"; &agi_output;} + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $survey_third_exten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + } + else + {$AGI->hangup();} + + exit; + } + + + ### fourth digit option + if ($opt_code =~ /$survey_fourth_digit/) + { + if ( $survey_fourth_audio_file ne "") + { + $AGI->stream_file($survey_fourth_audio_file); + } + + $stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' order by call_time desc limit 1;"; + $affected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='01017'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; + if ($AGILOG) + { + $agi_string = "-- VDAD vac record deleted: |$affected_rows|$VDADcampaign|"; + &agi_output; + } + + $Euniqueid=$uniqueid; + $Euniqueid =~ s/\.\d+//gi; + $now_date_epoch = time(); + $drop_seconds = $now_date_epoch - $start_time_epoch; + $stmtA = "UPDATE vicidial_log FORCE INDEX(lead_id) set status='$survey_fourth_status', end_epoch='$now_date_epoch', length_in_sec='$drop_seconds', term_reason='CALLER' 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='01018'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; + if ($AGILOG) + { + $agi_string = "-- VDAD vicidial_log update: $survey_fourth_status|$affected_rows|$uniqueid|$drop_seconds|"; + &agi_output; + } + + $stmtA = "UPDATE vicidial_list set status='$survey_fourth_status' where lead_id = '$CIDlead_id';"; + if ($AGILOG) { $agi_string = "|$stmtA|"; &agi_output; } + $affected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='01019'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; + if ($AGILOG) + { + $agi_string = "-- VDAD vicidial_list update: $survey_fourth_status|$affected_rows|$CIDlead_id"; + &agi_output; + } + + if (($use_internal_dnc =~ /Y/) && ($survey_fourth_status eq "DNC")) + { + $stmtA = "INSERT INTO vicidial_dnc set phone_number='$VDADphone';"; + if ($AGILOG) { $agi_string = "|$stmtA|"; &agi_output; } + $affected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='01020'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; + if ($AGILOG) + { + $agi_string = "-- VDAD vicidial_dnc insert: $affected_rows|$VDADphone"; + &agi_output; + } + } + if (($use_campaign_dnc =~ /Y/) && ($survey_fourth_status eq "DNC")) + { + $stmtA = "INSERT INTO vicidial_campaign_dnc set phone_number='$VDADphone', campaign_id='$VDADcampaign';"; + if ($AGILOG) { $agi_string = "|$stmtA|"; &agi_output; } + $affected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='01021'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; + if ($AGILOG) + { + $agi_string = "-- VDAD vicidial_campaign_dnc insert: $affected_rows|$VDADphone|$VDADcampaign"; + &agi_output; + } + } + + if (length($survey_fourth_exten) > 0) + { + if ($AGILOG) {$agi_string = "exiting the VDAD SURVEY app, transferring call to $survey_fourth_exten"; &agi_output;} + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $survey_fourth_exten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); + } + else + {$AGI->hangup();} + + exit; + } + + # they opted in + if ( ($opt_code =~ /\d/) || ($survey_no_response_action =~ /OPTOUT/) ) + { + $now_date_epoch = time(); + $FDtarget = ($now_date_epoch + 60); + ($Fsec,$Fmin,$Fhour,$Fmday,$Fmon,$Fyear,$Fwday,$Fyday,$Fisdst) = localtime($FDtarget); + $Fyear = ($Fyear + 1900); + $Fmon++; + if ($Fmon < 10) {$Fmon = "0$Fmon";} + if ($Fmday < 10) {$Fmday = "0$Fmday";} + if ($Fhour < 10) {$Fhour = "0$Fhour";} + if ($Fmin < 10) {$Fmin = "0$Fmin";} + if ($Fsec < 10) {$Fsec = "0$Fsec";} + $FDtsSQLdate = "$Fyear$Fmon$Fmday$Fhour$Fmin$Fsec"; + + $stmtA = "UPDATE vicidial_auto_calls set last_update_time='$FDtsSQLdate' where callerid='$callerid' order by call_time desc limit 1;"; + $affected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='01022'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; + if ($AGILOG) {$agi_string = "-- VDAC posttime record: |$affected_rows|$FDtsSQLdate|$callerid|"; &agi_output;} + + if ( $survey_opt_in_audio_file ne "") + { + $AGI->stream_file($survey_opt_in_audio_file); + } + + if ($survey_method =~ /VOICEMAIL|EXTENSION|HANGUP/) + { + $DROPexten=''; + if ($survey_method =~ /VOICEMAIL/) + { + $survey_status='SVYVM'; + if (length($VDADvoicemail_ext)>0) + {$DROPexten = "$voicemail_dump_exten$VDADvoicemail_ext";} + } + if ($survey_method =~ /EXTENSION/) + { + $survey_status='SVYEXT'; + if (length($survey_xfer_exten)>0) { - $survey_status='SVYVM'; - if (length($VDADvoicemail_ext)>0) - {$DROPexten = "$voicemail_dump_exten$VDADvoicemail_ext";} - } - if ($survey_method =~ /EXTENSION/) - { - $survey_status='SVYEXT'; - if (length($survey_xfer_exten)>0) + $DROPexten = "$survey_xfer_exten"; + + if ($three_way_call_cid !~ /CUSTOMER/) { - $DROPexten = "$survey_xfer_exten"; + $newcallerid = "\"$campaign_cid <$campaign_cid>\""; + $AGI->set_callerid($newcallerid); - if ($three_way_call_cid !~ /CUSTOMER/) - { - $newcallerid = "\"$campaign_cid <$campaign_cid>\""; - $AGI->set_callerid($newcallerid); - - print STDERR "Setting CID \"$newcallerid\"\n"; - checkresult($result); - if ($AGILOG) {$agi_string = "callerID changed: \"$calleridname\" \<$VDADphone\>"; &agi_output;} - } + print STDERR "Setting CID \"$newcallerid\"\n"; + checkresult($result); + if ($AGILOG) {$agi_string = "callerID changed: \"$calleridname\" \<$VDADphone\>"; &agi_output;} } } - if ($survey_method =~ /HANGUP/) - { - $survey_status='SVYHU'; - } - - $Euniqueid=$uniqueid; - $Euniqueid =~ s/\.\d+//gi; - $now_date_epoch = time(); - $drop_seconds = $now_date_epoch - $start_time_epoch; - $stmtA = "UPDATE vicidial_log FORCE INDEX(lead_id) set status='$survey_status', end_epoch='$now_date_epoch', length_in_sec='$drop_seconds', term_reason='CALLER' 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='01023'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; - if ($AGILOG) - { - $agi_string = "-- VDAD vicidial_log update: $survey_status|$affected_rows|$uniqueid|$drop_seconds|"; - &agi_output; - } - - $stmtA = "UPDATE vicidial_list set status='$survey_status' where lead_id = '$CIDlead_id';"; - if ($AGILOG) { $agi_string = "|$stmtA|"; &agi_output; } - $affected_rows = $dbhA->do($stmtA); - $dbhP=$dbhA; $mysql_count='01024'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; - if ($AGILOG) - { - $agi_string = "-- VDAD vicidial_list update: $survey_status|$affected_rows|$CIDlead_id"; - &agi_output; - } - - if (length($DROPexten) > 0) - { - $stmtA = "UPDATE vicidial_auto_calls set status='XFER',stage='XFER-0' where callerid='$callerid' order by call_time desc limit 1;"; - $affected_rows = $dbhA->do($stmtA); - $dbhP=$dbhA; $mysql_count='01025'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; - if ($AGILOG) {$agi_string = "-- VDAC XFER status: |$affected_rows|$FDtsSQLdate|$callerid|"; &agi_output;} - - if ($AGILOG) {$agi_string = "exiting the VDAD SURVEY app, transferring call to $DROPexten"; &agi_output;} - print "SET CONTEXT $ext_context\n"; - checkresult($result); - print "SET EXTENSION $DROPexten\n"; - checkresult($result); - print "SET PRIORITY 1\n"; - checkresult($result); - - exit; - } - - if ($survey_method =~ /HANGUP/) - { - $stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' order by call_time desc limit 1;"; - $affected_rows = $dbhA->do($stmtA); - $dbhP=$dbhA; $mysql_count='01026'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; - if ($AGILOG) - { - $agi_string = "-- VDAD vac record deleted: |$affected_rows|$VDADcampaign|"; - &agi_output; - } - - $AGI->hangup(); - - exit; - } + } + if ($survey_method =~ /HANGUP/) + { + $survey_status='SVYHU'; + } + + $Euniqueid=$uniqueid; + $Euniqueid =~ s/\.\d+//gi; + $now_date_epoch = time(); + $drop_seconds = $now_date_epoch - $start_time_epoch; + $stmtA = "UPDATE vicidial_log FORCE INDEX(lead_id) set status='$survey_status', end_epoch='$now_date_epoch', length_in_sec='$drop_seconds', term_reason='CALLER' 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='01023'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; + if ($AGILOG) + { + $agi_string = "-- VDAD vicidial_log update: $survey_status|$affected_rows|$uniqueid|$drop_seconds|"; + &agi_output; } - if ($survey_method =~ /CAMPREC/) + $stmtA = "UPDATE vicidial_list set status='$survey_status' where lead_id = '$CIDlead_id';"; + if ($AGILOG) { $agi_string = "|$stmtA|"; &agi_output; } + $affected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='01024'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; + if ($AGILOG) { - if ($survey_method =~ /60/) - {$timeout=60000;} - if ($survey_method =~ /WAV/) - {$format='WAV';} - if ($survey_method =~ /GSM/) - {$format='GSM';} + $agi_string = "-- VDAD vicidial_list update: $survey_status|$affected_rows|$CIDlead_id"; + &agi_output; + } - $survey_status='SVYREC'; - - $Euniqueid=$uniqueid; - $Euniqueid =~ s/\.\d+//gi; - $now_date_epoch = time(); - $drop_seconds = $now_date_epoch - $start_time_epoch; - $stmtA = "UPDATE vicidial_log FORCE INDEX(lead_id) set status='$survey_status', end_epoch='$now_date_epoch', length_in_sec='$drop_seconds', term_reason='CALLER' where lead_id = '$CIDlead_id' and uniqueid LIKE \"$Euniqueid%\";"; - if ($AGILOG) { $agi_string = "|$stmtA|"; &agi_output; } + if (length($DROPexten) > 0) + { + $stmtA = "UPDATE vicidial_auto_calls set status='XFER',stage='XFER-0' where callerid='$callerid' order by call_time desc limit 1;"; $affected_rows = $dbhA->do($stmtA); - $dbhP=$dbhA; $mysql_count='01027'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; - if ($AGILOG) - { - $agi_string = "-- VDAD vicidial_log update: $survey_status|$affected_rows|$uniqueid|$drop_seconds|"; - &agi_output; - } + $dbhP=$dbhA; $mysql_count='01025'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; + if ($AGILOG) {$agi_string = "-- VDAC XFER status: |$affected_rows|$FDtsSQLdate|$callerid|"; &agi_output;} - $stmtA = "UPDATE vicidial_list set status='$survey_status' where lead_id = '$CIDlead_id';"; - if ($AGILOG) { $agi_string = "|$stmtA|"; &agi_output; } - $affected_rows = $dbhA->do($stmtA); - $dbhP=$dbhA; $mysql_count='01028'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; - if ($AGILOG) - { - $agi_string = "-- VDAD vicidial_list update: $survey_status|$affected_rows|$CIDlead_id"; - &agi_output; - } + if ($AGILOG) {$agi_string = "exiting the VDAD SURVEY app, transferring call to $DROPexten"; &agi_output;} + print "SET CONTEXT $ext_context\n"; + checkresult($result); + print "SET EXTENSION $DROPexten\n"; + checkresult($result); + print "SET PRIORITY 1\n"; + checkresult($result); - if ( -e ('$survey_camp_record_dir/$VDADcampaign')) - {$do_nothing=1;} - else - {`mkdir -p --mode=0666 $survey_camp_record_dir/$VDADcampaign`;} - - $AGI->stream_file('beep'); - - $interrupt_digit = $AGI->record_file("$survey_camp_record_dir/$VDADcampaign/$VDADphone$filedate", "$format", '123456789*#', "$timeout", '0', 1, '10'); - if ($AGILOG) - { - $agi_string = "RECORDING FINISHED: $interrupt_digit|$survey_camp_record_dir/$VDADcampaign/$VDADphone$filedate|"; - &agi_output; - } - - $now_date_epoch = time(); - $drop_seconds = $now_date_epoch - $start_time_epoch; - $stmtA = "UPDATE vicidial_log FORCE INDEX(lead_id) set status='$survey_status', end_epoch='$now_date_epoch', length_in_sec='$drop_seconds', term_reason='CALLER' 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='01029'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; - if ($AGILOG) - { - $agi_string = "-- VDAD vicidial_log update: $survey_status|$affected_rows|$uniqueid|$drop_seconds|"; - &agi_output; - } + exit; + } + if ($survey_method =~ /HANGUP/) + { $stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' order by call_time desc limit 1;"; $affected_rows = $dbhA->do($stmtA); - $dbhP=$dbhA; $mysql_count='01030'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; + $dbhP=$dbhA; $mysql_count='01026'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; if ($AGILOG) { $agi_string = "-- VDAD vac record deleted: |$affected_rows|$VDADcampaign|"; @@ -916,25 +1094,71 @@ if ($call_handle_method =~ /SURVEY/) exit; } } - else + + if ($survey_method =~ /CAMPREC/) { + if ($survey_method =~ /60/) + {$timeout=60000;} + if ($survey_method =~ /WAV/) + {$format='WAV';} + if ($survey_method =~ /GSM/) + {$format='GSM';} + + $survey_status='SVYREC'; + $Euniqueid=$uniqueid; $Euniqueid =~ s/\.\d+//gi; $now_date_epoch = time(); $drop_seconds = $now_date_epoch - $start_time_epoch; - $stmtA = "UPDATE vicidial_log FORCE INDEX(lead_id) set status='PM', end_epoch='$now_date_epoch', length_in_sec='$drop_seconds', term_reason='CALLER' where lead_id = '$CIDlead_id' and uniqueid LIKE \"$Euniqueid%\";"; + $stmtA = "UPDATE vicidial_log FORCE INDEX(lead_id) set status='$survey_status', end_epoch='$now_date_epoch', length_in_sec='$drop_seconds', term_reason='CALLER' 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='01031'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; + $dbhP=$dbhA; $mysql_count='01027'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; if ($AGILOG) { - $agi_string = "-- VDAD vicidial_log update: PM|$affected_rows|$uniqueid|$drop_seconds|"; + $agi_string = "-- VDAD vicidial_log update: $survey_status|$affected_rows|$uniqueid|$drop_seconds|"; + &agi_output; + } + + $stmtA = "UPDATE vicidial_list set status='$survey_status' where lead_id = '$CIDlead_id';"; + if ($AGILOG) { $agi_string = "|$stmtA|"; &agi_output; } + $affected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='01028'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; + if ($AGILOG) + { + $agi_string = "-- VDAD vicidial_list update: $survey_status|$affected_rows|$CIDlead_id"; + &agi_output; + } + + if ( -e ('$survey_camp_record_dir/$VDADcampaign')) + {$do_nothing=1;} + else + {`mkdir -p --mode=0666 $survey_camp_record_dir/$VDADcampaign`;} + + $AGI->stream_file('beep'); + + $interrupt_digit = $AGI->record_file("$survey_camp_record_dir/$VDADcampaign/$VDADphone$filedate", "$format", '123456789*#', "$timeout", '0', 1, '10'); + if ($AGILOG) + { + $agi_string = "RECORDING FINISHED: $interrupt_digit|$survey_camp_record_dir/$VDADcampaign/$VDADphone$filedate|"; + &agi_output; + } + + $now_date_epoch = time(); + $drop_seconds = $now_date_epoch - $start_time_epoch; + $stmtA = "UPDATE vicidial_log FORCE INDEX(lead_id) set status='$survey_status', end_epoch='$now_date_epoch', length_in_sec='$drop_seconds', term_reason='CALLER' 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='01029'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; + if ($AGILOG) + { + $agi_string = "-- VDAD vicidial_log update: $survey_status|$affected_rows|$uniqueid|$drop_seconds|"; &agi_output; } $stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' order by call_time desc limit 1;"; $affected_rows = $dbhA->do($stmtA); - $dbhP=$dbhA; $mysql_count='01032'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; + $dbhP=$dbhA; $mysql_count='01030'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; if ($AGILOG) { $agi_string = "-- VDAD vac record deleted: |$affected_rows|$VDADcampaign|"; @@ -946,6 +1170,35 @@ if ($call_handle_method =~ /SURVEY/) exit; } } + else + { + $Euniqueid=$uniqueid; + $Euniqueid =~ s/\.\d+//gi; + $now_date_epoch = time(); + $drop_seconds = $now_date_epoch - $start_time_epoch; + $stmtA = "UPDATE vicidial_log FORCE INDEX(lead_id) set status='PM', end_epoch='$now_date_epoch', length_in_sec='$drop_seconds', term_reason='CALLER' 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='01031'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; + if ($AGILOG) + { + $agi_string = "-- VDAD vicidial_log update: PM|$affected_rows|$uniqueid|$drop_seconds|"; + &agi_output; + } + + $stmtA = "DELETE FROM vicidial_auto_calls where callerid='$callerid' order by call_time desc limit 1;"; + $affected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='01032'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; + if ($AGILOG) + { + $agi_string = "-- VDAD vac record deleted: |$affected_rows|$VDADcampaign|"; + &agi_output; + } + + $AGI->hangup(); + + exit; + } } ################################################################################ ##### END DO THE SURVEY ##### diff --git a/agc_2-X/trunk/bin/Vtiger_OUT_sync2VICIDIAL_file.pl b/agc_2-X/trunk/bin/Vtiger_OUT_sync2VICIDIAL_file.pl index 09180329..e48bc5f5 100644 --- a/agc_2-X/trunk/bin/Vtiger_OUT_sync2VICIDIAL_file.pl +++ b/agc_2-X/trunk/bin/Vtiger_OUT_sync2VICIDIAL_file.pl @@ -14,6 +14,7 @@ # 90401-1347 - Fixed quiet flag # 90417-0519 - Added custom field updates for timezone and last/largest sale amounts # 90423-0453 - Added calls file and hours file reports +# 90424-1157 - Added orders file report # $secX = time(); @@ -122,6 +123,7 @@ if (length($ARGV[0])>1) print " [--vt-sales-update] = updates the Vtiger account custom sales fields based upon today sales order data\n"; print " [--vt-sales-update-alldate] = updates the Vtiger account custom sales fields based upon all sales order data\n"; print " [--vt-timezone-update] = updates the Vtiger account custom timezone field based upon ViciDial timezone/state\n"; + print " [--vt-territory-update] = updates the Vtiger account tickersymbol field based upon ViciDial user territory\n"; print " report generation options:\n"; print " [--report-call-file] = generates a spec call file from vicidial records\n"; print " [--report-hours-file] = generates a spec agent hours file from vicidial records\n"; @@ -212,6 +214,11 @@ if (length($ARGV[0])>1) $vt_timezone_update=1; if ($q < 1) {print "\n----- VTIGER TIMEZONE FIELD UPDATE -----\n\n";} } + if ($args =~ /-vt-territory-update/i) + { + $vt_territory_update=1; + if ($q < 1) {print "\n----- VTIGER USER TERRITORY UPDATE -----\n\n";} + } if ($args =~ /--report-call-file/i) { $report_call_file=1; @@ -352,6 +359,7 @@ $g=0; ### number of leads with multi-alt-entries $h=0; ### number of timezone updates $j=0; ### number of saleamount updates $m=0; ### number of exported records to file +$n=0; ### number of territory updates ### open the output file for writing ### @@ -373,6 +381,9 @@ if ($report_orders_file > 0) open(OFout, ">$VTofWEBfile") || die "Can't open $VTofWEBfile: $!\n"; } + + + ##### BEGIN REPORT HOURS FILE ##### if ($report_hours_file > 0) { @@ -439,7 +450,7 @@ if ($report_hours_file > 0) if ($DB) {print "printing $last_user|$Lrep\n";} if ($w > 0) - {print HFout "$Lrep,$TODAY,4,15,$L_ob_talk,$L_ib_talk,$L_acw,$L_onhook,$L_train,$L_break,$L_wait\n";} + {print HFout "$last_user,$TODAY,4,15,$L_ob_talk,$L_ib_talk,$L_acw,$L_onhook,$L_train,$L_break,$L_wait\n";} $last_user = $user[$w]; $Lrep=$rep[$w]; $L_ob_talk=0; @@ -676,6 +687,79 @@ while ($sthBrowsC > $i) + ##### BEGIN USER TERRITORY UPDATE ##### + if ($vt_territory_update > 0) + { + $stmtB="SELECT tickersymbol from vtiger_account where accountid='$crmid[$i]';"; + if($DBX){print STDERR "\n|$stmtB|\n";} + $sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr; + $sthB->execute or die "executing: $stmtB ", $dbhB->errstr; + $sthBrows=$sthB->rows; + if ($sthBrows > 0) + { + @aryB = $sthB->fetchrow_array; + $territory = $aryB[0]; + } + $sthB->finish(); + + if (length($territory)>0) + { + $VL_exists=0; + $stmtA = "SELECT count(*) FROM vicidial_users where user_code='$territory';"; + $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; + $VL_exists = "$aryA[0]"; + } + $sthA->finish(); + + if ($VL_exists > 0) + { + $user=''; + $stmtA = "SELECT user FROM vicidial_users where user_code='$territory';"; + $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; + $user = "$aryA[0]"; + } + $sthA->finish(); + + if (length($territory)>0) + { + $user_id=''; + $stmtB="SELECT id from vtiger_users where user_name='$user';"; + if($DBX){print STDERR "\n|$stmtB|\n";} + $sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr; + $sthB->execute or die "executing: $stmtB ", $dbhB->errstr; + $sthBrows=$sthB->rows; + if ($sthBrows > 0) + { + @aryB = $sthB->fetchrow_array; + $user_id = $aryB[0]; + } + $sthB->finish(); + + if (length($user_id)>0) + { + $stmtB = "UPDATE vtiger_crmentity SET smownerid='$user_id' where accountid='$crmid[$i]';"; + if ($T < 1) {$affected_rowsB = $dbhB->do($stmtB) or die "Couldn't execute query: |$stmtB|\n";} + if($DB){print "|$affected_rowsB|$stmtB|\n";} + $n++; + } + } + } + } + } + ##### END USER TERRITORY UPDATE ##### + + + ##### BEGIN SALE AMOUNT UPDATE ##### if ( ( ($vt_sales_update > 0) || ($vt_sales_update_alldate > 0) ) && ( ($vt_last_saleamount_field_exists > 0) && ($vt_largest_saleamount_field_exists > 0) ) ) { @@ -752,9 +836,9 @@ while ($sthBrowsC > $i) { @aryB = $sthB->fetchrow_array; $website = $aryB[0]; - @webARY = split(/-/,$website); - $account = $webARY[0]; - $sequence = $webARY[1]; + @webARY = split(/-/,$website); + $account = $webARY[0]; + $sequence = $webARY[1]; $territory = $aryB[1]; $business_line = $aryB[2]; } @@ -830,7 +914,7 @@ while ($sthBrowsC > $i) if ($call_type =~ /AUTO/) {$ct='3';} else {$ct='2';} - print CFout "$transaction,15,$rep,$account,$sequence,$territory,$phone,$disposition,$call_length,$call_date,$ct\n"; + print CFout "$transaction,15,$user,$account,$sequence,$territory,$phone,$disposition,$call_length,$call_date,$ct\n"; $m++; $w++; } @@ -856,7 +940,7 @@ while ($sthBrowsC > $i) $call_date = "$aryA[6]"; $call_type = "$aryA[7]"; - print CFout "$transaction,15,$rep,$account,$sequence,$territory,$phone,$disposition,$call_length,$call_date,1\n"; + print CFout "$transaction,15,$user,$account,$sequence,$territory,$phone,$disposition,$call_length,$call_date,1\n"; $m++; $w++; } @@ -872,6 +956,89 @@ while ($sthBrowsC > $i) ##### BEGIN REPORT ORDERS FILE ##### if ($report_orders_file > 0) { + $VS_exists=0; + $stmtB="SELECT count(*) from vtiger_salesorder where accountid='$crmid[$i]' and duedate > \"$TODAY 00:00:00\" order by duedate;"; + if($DBX){print STDERR "\n|$stmtB|\n";} + $sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr; + $sthB->execute or die "executing: $stmtB ", $dbhB->errstr; + $sthBrows=$sthB->rows; + if ($sthBrows > 0) + { + @aryB = $sthB->fetchrow_array; + $VS_exists = $aryB[0]; + } + $sthB->finish(); + + if ($VS_exists > 0) + { + $stmtB="SELECT website,phone,accountname,ownership,siccode from vtiger_account where accountid='$crmid[$i]';"; + if($DBX){print STDERR "\n|$stmtB|\n";} + $sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr; + $sthB->execute or die "executing: $stmtB ", $dbhB->errstr; + $sthBrows=$sthB->rows; + if ($sthBrows > 0) + { + @aryB = $sthB->fetchrow_array; + $website = $aryB[0]; + @webARY = split(/-/,$website); + $account = $webARY[0]; + $sequence = $webARY[1]; + $phone = $aryB[1]; + $company = $aryB[2]; + $ownership = $aryB[3]; + @ownARY = split(/ /,$ownership); + $first_name = $ownARY[0]; + $last_name = $ownARY[1]; + $VCstatus = $aryB[4]; + } + $sthB->finish(); + + $stmtA = "SELECT status FROM vicidial_statuses where status_name='$VCstatus';"; + $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; + $VCstatus = "$aryA[0]"; + $sthA->finish(); + } + else + { + $sthA->finish(); + $stmtA = "SELECT status FROM vicidial_campaign_statuses where status_name='$VCstatus';"; + $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; + $VCstatus = "$aryA[0]"; + $sthA->finish(); + } + } + $sthA->finish(); + + $k=0; + $stmtB="SELECT salesorderid,total,duedate from vtiger_salesorder where accountid='$crmid[$i]' and duedate > \"$TODAY 00:00:00\" order by duedate;"; + if($DBX){print STDERR "\n|$stmtB|\n";} + $sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr; + $sthB->execute or die "executing: $stmtB ", $dbhB->errstr; + $sthBrows=$sthB->rows; + while ($sthBrows > $k) + { + @aryB = $sthB->fetchrow_array; + $salesorderid = $aryB[0]; + $total = $aryB[1]; + chop($total); + $duedate = $aryB[2]; + + print OFout "$salesorderid,$phone,$account,$sequence,$company,$first_name,$last_name,$VCstatus,$duedate,$total\n"; + $m++; + $k++; + } + $sthB->finish(); + } } @@ -1023,6 +1190,7 @@ while ($sthBrowsC > $i) {$Falert .= "PHONE DUPLICATES: $f\n";} $Falert .= "TIMEZONE UPDATES: $h\n"; $Falert .= "SALE AMOUNT UPDATES:$j\n"; + $Falert .= "TERRITORY UPDATES: $n\n"; $Falert .= "REPORT RECORDS: $m\n"; if ($q < 1) {print "$Falert";} diff --git a/agc_2-X/trunk/docs/NON-AGENT_API.txt b/agc_2-X/trunk/docs/NON-AGENT_API.txt index e7f87e25..5d9b8024 100644 --- a/agc_2-X/trunk/docs/NON-AGENT_API.txt +++ b/agc_2-X/trunk/docs/NON-AGENT_API.txt @@ -15,6 +15,10 @@ New scripts: /vicidial/non_agent_api.php - the script that is accessed to execute commands +Changes: +80724-1723 - First build +90428-0208 - Added blind_monitor function + API Functions: ('function' variable) @@ -35,10 +39,43 @@ VERSION: 2.0.5-4|BUILD: 80910-0020|DATE: 2008-09-10 00:26:43|EPOCH: 1221020803 + +-------------------------------------------------------------------------------- +blind_monitor - calls user-defined phone and places them in session as blind monitor + +NOTE: api user for this function must have user_level set to 7 or higher + +REQUIRED FIELDS- +phone_login - alpha-numeric, no spaces or special characters allowed +session_id - must be all numbers, 7 digits +server_ip - must be all numbers and dots, max 15 characters +source - description of what originated the API call (maximum 20 characters) +stage - MONITOR, BARGE or HIJACK, default is MONITOR + (HIJACK option is not currently functional) + + +Example URL strings for API calls: +http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&function=blind_monitor&phone_login=350a&session_id=8600051&server_ip=10.10.10.16&stage=MONITOR + +Example responses: +SUCCESS: blind_monitor HAS BEEN LAUNCHED - 350a|010*010*010*017*350|8600051 + +ERROR: blind_monitor INVALID PHONE LOGIN - 350q + +ERROR: blind_monitor INVALID SESSION ID - 8602051 + +ERROR: blind_monitor USER DOES NOT HAVE PERMISSION TO BLIND MONITOR - 6666|0 + +ERROR: NO FUNCTION SPECIFIED + + + + -------------------------------------------------------------------------------- add_lead - adds a new lead to the vicidial_list table with several fields and options -NOTE: api user for this function must have modify_leads set to 1 +NOTE: api user for this function must have modify_leads set to 1 and user_level + must be set to 8 or higher REQUIRED FIELDS- phone_number - must be all numbers, 6-16 digits 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 d95e5a9a..65e7fa83 100644 --- a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql +++ b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql @@ -634,7 +634,15 @@ cpd_amd_action ENUM('DISABLED','DISPO','MESSAGE') default 'DISABLED', agent_allow_group_alias ENUM('Y','N') default 'N', default_group_alias VARCHAR(30) default '', vtiger_search_dead ENUM('DISABLED','ASK','RESURRECT') default 'ASK', -vtiger_status_call ENUM('Y','N') default 'N' +vtiger_status_call ENUM('Y','N') default 'N', +survey_third_digit VARCHAR(1) default '', +survey_third_audio_file VARCHAR(50) default 'US_thanks_no_contact', +survey_third_status VARCHAR(6) default 'NI', +survey_third_exten VARCHAR(20) default '8300', +survey_fourth_digit VARCHAR(1) default '', +survey_fourth_audio_file VARCHAR(50) default 'US_thanks_no_contact', +survey_fourth_status VARCHAR(6) default 'NI', +survey_fourth_exten VARCHAR(20) default '8300' ); CREATE TABLE vicidial_lists ( @@ -1085,7 +1093,8 @@ vtiger_pass VARCHAR(50), vtiger_url VARCHAR(255), qc_features_active ENUM('1','0') default '0', outbound_autodial_active ENUM('1','0') default '1', -outbound_calls_per_second SMALLINT(3) UNSIGNED default '40' +outbound_calls_per_second SMALLINT(3) UNSIGNED default '40', +enable_tts_integration ENUM('0','1') default '0' ); CREATE TABLE vicidial_campaigns_list_mix ( @@ -1455,6 +1464,12 @@ index (user), index (call_date) ); +CREATE TABLE vicidial_tts_prompts ( +tts_id VARCHAR(50) PRIMARY KEY NOT NULL, +tts_name VARCHAR(100), +active ENUM('Y','N'), +tts_text TEXT +); ALTER TABLE vicidial_campaign_server_stats ENGINE=HEAP; @@ -1551,7 +1566,7 @@ CREATE INDEX phone_number on vicidial_closer_log (phone_number); CREATE INDEX date_user on vicidial_closer_log (call_date,user); CREATE INDEX comment_a on live_inbound_log (comment_a); -UPDATE system_settings SET db_schema_version='1138'; +UPDATE system_settings SET db_schema_version='1139'; GRANT RELOAD ON *.* TO cron@'%'; GRANT RELOAD ON *.* TO cron@localhost; diff --git a/agc_2-X/trunk/extras/upgrade_2.2.0.sql b/agc_2-X/trunk/extras/upgrade_2.2.0.sql index 0c7cea48..269e869f 100644 --- a/agc_2-X/trunk/extras/upgrade_2.2.0.sql +++ b/agc_2-X/trunk/extras/upgrade_2.2.0.sql @@ -30,3 +30,24 @@ ALTER TABLE vicidial_users ADD user_code VARCHAR(100) default ''; ALTER TABLE vicidial_users ADD territory VARCHAR(100) default ''; UPDATE system_settings SET db_schema_version='1138'; + +ALTER TABLE vicidial_campaigns ADD survey_third_digit VARCHAR(1) default ''; +ALTER TABLE vicidial_campaigns ADD survey_third_audio_file VARCHAR(50) default 'US_thanks_no_contact'; +ALTER TABLE vicidial_campaigns ADD survey_third_status VARCHAR(6) default 'NI'; +ALTER TABLE vicidial_campaigns ADD survey_third_exten VARCHAR(20) default '8300'; +ALTER TABLE vicidial_campaigns ADD survey_fourth_digit VARCHAR(1) default ''; +ALTER TABLE vicidial_campaigns ADD survey_fourth_audio_file VARCHAR(50) default 'US_thanks_no_contact'; +ALTER TABLE vicidial_campaigns ADD survey_fourth_status VARCHAR(6) default 'NI'; +ALTER TABLE vicidial_campaigns ADD survey_fourth_exten VARCHAR(20) default '8300'; + +ALTER TABLE system_settings ADD enable_tts_integration ENUM('0','1') default '0'; + +CREATE TABLE vicidial_tts_prompts ( +tts_id VARCHAR(50) PRIMARY KEY NOT NULL, +tts_name VARCHAR(100), +active ENUM('Y','N'), +tts_text TEXT +); + +UPDATE system_settings SET db_schema_version='1139'; + diff --git a/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.2.0.txt b/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.2.0.txt index fc88ece2..843108dc 100644 --- a/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.2.0.txt +++ b/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.2.0.txt @@ -17,6 +17,20 @@ There are also 5 additional settings that will define the kind of status: sale, If the customer is on hold and hears this estimated hold time message, the minimum time that will be played is 15 seconds|| Email, User Code and Territory|| These are optional fields|| +All options except for the Not Interested, Third and Fourth digit options will move on to the Survey Method call path|| +Survey Third Digit|| +This allows for a third call path if the Third digit as defined in this field is pressed by the customer|| +Survey Fourth Digit|| +This allows for a fourth call path if the Fourth digit as defined in this field is pressed by the customer|| +Survey Third Audio File|| +Survey Fourth Audio File|| +This is the third audio file to be played upon the selection by the customer of the Third Digit option|| +Survey Third Status|| +Survey Fourth Status|| +This is the third status used for the call upon the selection by the customer of the Third Digit option|| +Survey Third Extension|| +Survey Fourth Extension|| +This is the third extension used for the call upon the selection by the customer of the Third Digit option. Default is 8300 which immediately hangs up the call after the Audio File message is played|| ############################################################ CLIENT diff --git a/agc_2-X/trunk/www/agc/vdc_db_query.php b/agc_2-X/trunk/www/agc/vdc_db_query.php index a5687f3a..939b75f7 100644 --- a/agc_2-X/trunk/www/agc/vdc_db_query.php +++ b/agc_2-X/trunk/www/agc/vdc_db_query.php @@ -3548,7 +3548,7 @@ if ($ACTION == 'updateDISPO') $status_name = $row[0]; } } - if (strlen($dispo_choice) < 1) {$status_name = $dispo_chioce;} + if (strlen($status_name) < 1) {$status_name = $dispo_chioce;} ### connect to your vtiger database $linkV=mysql_connect("$vtiger_server_ip", "$vtiger_login","$vtiger_pass"); diff --git a/agc_2-X/trunk/www/vicidial/AST_timeonVDADall.php b/agc_2-X/trunk/www/vicidial/AST_timeonVDADall.php index 70e0089b..01a2557e 100644 --- a/agc_2-X/trunk/www/vicidial/AST_timeonVDADall.php +++ b/agc_2-X/trunk/www/vicidial/AST_timeonVDADall.php @@ -45,10 +45,11 @@ # 90105-1153 - Changed monitor links to use 0 prefix instead of 6 # 90202-0108 - Changed options to pop-out frame, added outbound_autodial_active option # 90310-0906 - Added admin header +# 90428-0727 - Changed listen and barge to use the API and manager must enter phone # -$version = '2.0.5-36'; -$build = '90310-0906'; +$version = '2.0.5-37'; +$build = '90428-0727'; header ("Content-type: text/html; charset=utf-8"); @@ -97,6 +98,11 @@ if (isset($_GET["CUSTPHONEdisplay"])) {$CUSTPHONEdisplay=$_GET["CUSTPHONEdispl elseif (isset($_POST["CUSTPHONEdisplay"])) {$CUSTPHONEdisplay=$_POST["CUSTPHONEdisplay"];} if (isset($_GET["with_inbound"])) {$with_inbound=$_GET["with_inbound"];} elseif (isset($_POST["with_inbound"])) {$with_inbound=$_POST["with_inbound"];} +if (isset($_GET["monitor_active"])) {$monitor_active=$_GET["monitor_active"];} + elseif (isset($_POST["monitor_active"])) {$monitor_active=$_POST["monitor_active"];} +if (isset($_GET["monitor_phone"])) {$monitor_phone=$_GET["monitor_phone"];} + elseif (isset($_POST["monitor_phone"])) {$monitor_phone=$_POST["monitor_phone"];} + ############################################# ##### START SYSTEM_SETTINGS LOOKUP ##### @@ -115,6 +121,7 @@ while ($i < $qm_conf_ct) ##### END SETTINGS LOOKUP ##### ########################################### +if (!isset($DB)) {$DB=0;} if (!isset($RR)) {$RR=40;} if (!isset($group)) {$group='';} if (!isset($usergroup)) {$usergroup='';} @@ -177,11 +184,18 @@ return false; $load_ave = get_server_load(true); +$NOW_TIME = date("Y-m-d H:i:s"); +$NOW_DAY = date("Y-m-d"); +$NOW_HOUR = date("H:i:s"); +$STARTtime = date("U"); +$epochSIXhoursAGO = ($STARTtime - 21600); +$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO); + $PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER); $PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW); -$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6 and view_reports='1';"; +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 6 and view_reports='1' and active='Y';"; if ($DB) {echo "|$stmt|\n";} if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");} $rslt=mysql_query($stmt, $link); @@ -195,17 +209,18 @@ $auth=$row[0]; echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; exit; } - -$NOW_TIME = date("Y-m-d H:i:s"); -$NOW_DAY = date("Y-m-d"); -$NOW_HOUR = date("H:i:s"); -$STARTtime = date("U"); -$epochSIXhoursAGO = ($STARTtime - 21600); -$timeSIXhoursAGO = date("Y-m-d H:i:s",$epochSIXhoursAGO); +# and (preg_match("/MONITOR|BARGE|HIJACK/",$monitor_active) ) ) +if ( (!isset($monitor_phone)) or (strlen($monitor_phone)<1) ) + { + $stmt="select phone_login from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and active='Y';"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $row=mysql_fetch_row($rslt); + $monitor_phone = $row[0]; + } $stmt="select campaign_id,campaign_name from vicidial_campaigns where active='Y';"; $rslt=mysql_query($stmt, $link); -if (!isset($DB)) {$DB=0;} if ($DB) {echo "$stmt\n";} $groups_to_print = mysql_num_rows($rslt); $i=0; @@ -306,6 +321,26 @@ $select_list .= "