diff --git a/agc_2-X/trunk/UPGRADE b/agc_2-X/trunk/UPGRADE index e31ad8f0..86dde703 100644 --- a/agc_2-X/trunk/UPGRADE +++ b/agc_2-X/trunk/UPGRADE @@ -74,6 +74,9 @@ OTHER CHANGES: 6. Added In-Group option to populate new leads with a DID descriptive value in the province field of the new lead. +7. Added cm_sc_send_url.agi script for Call Menus on calls tied to a lead_id to + send a URL defined in a Settings Container. + diff --git a/agc_2-X/trunk/agi/cm_phonesearch.agi b/agc_2-X/trunk/agi/cm_phonesearch.agi index eb159322..8cccf37f 100644 --- a/agc_2-X/trunk/agi/cm_phonesearch.agi +++ b/agc_2-X/trunk/agi/cm_phonesearch.agi @@ -11,6 +11,7 @@ # If phone number is not found, call will go to the 'D' option in the call menu # If default in-group is not found, call will go to the 'C' option in the call menu # If default in-group is found, call will go to the 'B' option in the call menu +# (NOTE: you MUST set the In-Group to DYNAMIC_INGROUP_VAR for 'B' option) # # Flag Options: # 1- Country code to search the areacode within, default 1 diff --git a/agc_2-X/trunk/bin/AST_send_URL.pl b/agc_2-X/trunk/bin/AST_send_URL.pl index 9879e933..f431e0c1 100644 --- a/agc_2-X/trunk/bin/AST_send_URL.pl +++ b/agc_2-X/trunk/bin/AST_send_URL.pl @@ -1,14 +1,14 @@ #!/usr/bin/perl # -# AST_send_URL.pl version 2.12 +# AST_send_URL.pl version 2.14 # # DESCRIPTION: # This script is spawned for remote agents when the Start Call URL is set in the # campaign or in-group that the call came from when sent to the remote agent. # This script is also used for the Add-Lead-URL feature in In-groups and for -# QM socket-send. +# QM socket-send as well as from call menus using a settings container. # -# Copyright (C) 2015 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2017 Matt Florell LICENSE: AGPLv2 # # CHANGES # 100622-0929 - First Build @@ -23,6 +23,7 @@ # 150609-1931 - Added list_description variable # 150703-1542 - Fixed issue with list_id check # 150711-1501 - Changed to add more logging and better HTTPS support +# 170202-2321 - Added SC_CALL_URL function # $|++; @@ -43,7 +44,7 @@ $now_date = "$year-$mon-$mday $hour:$min:$sec"; ### Initialize run-time variables ### my ($CLOhelp, $SYSLOG,$DB, $DBX); -my ($campaign, $lead_id, $phone_number, $call_type, $user, $uniqueid, $alt_dial, $call_id, $function); +my ($campaign, $lead_id, $phone_number, $call_type, $user, $uniqueid, $alt_dial, $call_id, $function, $container); my $FULL_LOG = 1; $url_function = 'other'; $US='_'; @@ -62,6 +63,7 @@ if (scalar @ARGV) { 'call_id=s' => \$call_id, 'list_id:s' => \$list_id, 'function=s' => \$function, + 'container=s' => \$container, 'debug!' => \$DB, 'debugX!' => \$DBX, 'fulllog!' => \$FULL_LOG, @@ -83,6 +85,7 @@ if (scalar @ARGV) { print " call_id: $call_id\n" if ($call_id); print " list_id: $list_id\n" if ($list_id); print " function: $function\n" if ($function); + print " container: $container\n" if ($container); print " compat_url: $compat_url\n" if ($compat_url); print "\n"; } @@ -102,6 +105,7 @@ if (scalar @ARGV) { print " [--call_id] = call_id or caller_code of the call\n"; print " [--list_id] = list_id of the lead on the call\n"; print " [--compat_url] = full compatible URL to send\n"; + print " [--container] = settings container to use if function is SC_CALL_URL\n"; print " [--function] = which function is to be run, default is REMOTE_AGENT_START_CALL_URL\n"; print " *REMOTE_AGENT_START_CALL_URL - performs a Start Call URL get for Remote Agent Calls\n"; print " *INGROUP_ADD_LEAD_URL - performs an Add Lead URL get for In-Groups when a lead is added\n"; @@ -203,6 +207,24 @@ if (length($lead_id) > 0) } $sthA->finish(); + if ($function =~ /SC_CALL_URL/) + { + $sc_call_url=''; + $stmtH= "SELECT container_entry from vicidial_settings_containers where container_id='$container';"; + $sthA = $dbhA->prepare($stmtH) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($AGILOG) {$agi_string = "$sthArows|$stmtH|"; &agi_output;} + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $sc_call_url = $aryA[0]; + } + else + {$no_container=2;} + $sthA->finish(); + } + if ( ($function =~ /NA_CALL_URL/) && (length($list_id) > 1) ) { $stmtH = "SELECT na_call_url FROM vicidial_lists where list_id='$list_id';"; @@ -369,7 +391,7 @@ if (length($lead_id) > 0) } elsif ($function =~ /NA_CALL_URL/) { - ##### BEGIN Call URL function ##### + ##### BEGIN NA Call URL function ##### $stmtA = "SELECT lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner,phone_code FROM vicidial_list where lead_id='$lead_id';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -550,6 +572,217 @@ if (length($lead_id) > 0) $parse_url = $na_call_url; $url_function = 'na_callurl'; + ##### END NA Call URL function ##### + } + elsif ($function =~ /SC_CALL_URL/) + { + $talk_sec=0; $dead_sec=0; $dispo_epoch=time(); $now_epoch=time(); + ##### BEGIN Settings Container Call URL function ##### + $stmtA = "SELECT user,status,talk_sec,dead_sec,dispo_epoch from vicidial_agent_log where lead_id='$lead_id' order by agent_log_id desc limit 1;"; + $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; + $VAR_user = $aryA[0]; + $VAR_dispo = $aryA[1]; + $talk_sec = $aryA[2]; + $dead_sec = $aryA[3]; + $dispo_epoch = $aryA[4]; + } + $ivr_time = ($now_epoch - $dispo_epoch); + $talk_time = ($talk_sec - $dead_sec); + if ($talk_time < 1) + {$talk_time = 0;} + else + {$talk_time_min = ($talk_time / 60); $talk_time_min = sprintf("%.0f", $talk_time_min);} + + $stmtA = "SELECT lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner,phone_code FROM vicidial_list where lead_id='$lead_id';"; + $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; + $VAR_entry_date = $aryA[1]; + $VAR_modify_date = $aryA[2]; + $VAR_status = $aryA[3]; + $VAR_vendor_lead_code = $aryA[5]; + $VAR_source_id = $aryA[6]; + $VAR_list_id = $aryA[7]; + $VAR_phone_number = $aryA[8]; + $VAR_title = $aryA[9]; + $VAR_first_name = $aryA[10]; + $VAR_middle_initial = $aryA[11]; + $VAR_last_name = $aryA[12]; + $VAR_address1 = $aryA[13]; + $VAR_address2 = $aryA[14]; + $VAR_address3 = $aryA[15]; + $VAR_city = $aryA[16]; + $VAR_state = $aryA[17]; + $VAR_province = $aryA[18]; + $VAR_postal_code = $aryA[19]; + $VAR_country_code = $aryA[20]; + $VAR_gender = $aryA[21]; + $VAR_date_of_birth = $aryA[22]; + $VAR_alt_phone = $aryA[23]; + $VAR_email = $aryA[24]; + $VAR_security_phrase = $aryA[25]; + $VAR_comments = $aryA[26]; + $VAR_called_count = $aryA[27]; + $VAR_last_local_call_time = $aryA[28]; + $VAR_rank = $aryA[29]; + $VAR_owner = $aryA[30]; + $VAR_phone_code = $aryA[31]; + } + $sthA->finish(); + + if ($sc_call_url =~ /--A--user_custom_/) + { + $stmtA = "SELECT custom_one,custom_two,custom_three,custom_four,custom_five,user_group from vicidial_users where user='$user';"; + $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; + $VAR_user_custom_one = $aryA[0]; + $VAR_user_custom_two = $aryA[1]; + $VAR_user_custom_three = $aryA[2]; + $VAR_user_custom_four = $aryA[3]; + $VAR_user_custom_five = $aryA[4]; + $VAR_user_group = $aryA[5]; + } + } + + if ($sc_call_url =~ /--A--did_/) + { + $stmtA = "SELECT did_id,extension FROM vicidial_did_log 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; + $VAR_did_id = $aryA[0]; + $VAR_did_extension = $aryA[1]; + } + $sthA->finish(); + + $stmtA = "SELECT did_pattern,did_description FROM vicidial_inbound_dids where did_id='$VAR_did_id';"; + $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; + $VAR_did_pattern = $aryA[0]; + $VAR_did_description = $aryA[1]; + } + $sthA->finish(); + } + + if ($sc_call_url =~ /--A--closecallid--B--/) + { + $stmtA = "SELECT closecallid FROM vicidial_closer_log where uniqueid='$uniqueid' order by closecallid limit 1;"; + $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; + $VAR_closecallid = $aryA[0]; + } + $sthA->finish(); + } + + if ( (length($VAR_list_id) > 1) && ( ( (length($list_name) < 1) && ($sc_call_url =~ /--A--list_name--B--/) ) || ( (length($list_description) < 1) && ($sc_call_url =~ /--A--list_description--B--/) ) ) ) + { + $stmtH = "SELECT list_name,list_description FROM vicidial_lists where list_id='$VAR_list_id';"; + $sthA = $dbhA->prepare($stmtH) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtH ", $dbhA->errstr; + $list_name_ct=$sthA->rows; + if ($list_name_ct > 0) + { + @aryA = $sthA->fetchrow_array; + if (length($aryA[0])>0) + { + $list_name = $aryA[0]; + } + if (length($aryA[1])>0) + { + $list_description = $aryA[1]; + } + } + $sthA->finish(); + } + + $sc_call_url =~ s/^VAR//gi; + $sc_call_url =~ s/--A--lead_id--B--/$VAR_lead_id/gi; + $sc_call_url =~ s/--A--entry_date--B--/$VAR_entry_date/gi; + $sc_call_url =~ s/--A--modify_date--B--/$VAR_modify_date/gi; + $sc_call_url =~ s/--A--status--B--/$VAR_dispo/gi; + $sc_call_url =~ s/--A--dispo--B--/$VAR_dispo/gi; + $sc_call_url =~ s/--A--user--B--/$VAR_user/gi; + $sc_call_url =~ s/--A--vendor_id--B--/$VAR_vendor_lead_code/gi; + $sc_call_url =~ s/--A--vendor_lead_code--B--/$VAR_vendor_lead_code/gi; + $sc_call_url =~ s/--A--source_id--B--/$VAR_source_id/gi; + $sc_call_url =~ s/--A--list_id--B--/$VAR_list_id/gi; + $sc_call_url =~ s/--A--list_name--B--/$list_name/gi; + $sc_call_url =~ s/--A--list_description--B--/$list_description/gi; + $sc_call_url =~ s/--A--phone_code--B--/$VAR_phone_code/gi; + $sc_call_url =~ s/--A--phone_number--B--/$VAR_phone_number/gi; + $sc_call_url =~ s/--A--title--B--/$VAR_title/gi; + $sc_call_url =~ s/--A--first_name--B--/$VAR_first_name/gi; + $sc_call_url =~ s/--A--middle_initial--B--/$VAR_middle_initial/gi; + $sc_call_url =~ s/--A--last_name--B--/$VAR_last_name/gi; + $sc_call_url =~ s/--A--address1--B--/$VAR_address1/gi; + $sc_call_url =~ s/--A--address2--B--/$VAR_address2/gi; + $sc_call_url =~ s/--A--address3--B--/$VAR_address3/gi; + $sc_call_url =~ s/--A--city--B--/$VAR_city/gi; + $sc_call_url =~ s/--A--state--B--/$VAR_state/gi; + $sc_call_url =~ s/--A--province--B--/$VAR_province/gi; + $sc_call_url =~ s/--A--postal_code--B--/$VAR_postal_code/gi; + $sc_call_url =~ s/--A--country_code--B--/$VAR_country_code/gi; + $sc_call_url =~ s/--A--gender--B--/$VAR_gender/gi; + $sc_call_url =~ s/--A--date_of_birth--B--/$VAR_date_of_birth/gi; + $sc_call_url =~ s/--A--alt_phone--B--/$VAR_alt_phone/gi; + $sc_call_url =~ s/--A--email--B--/$VAR_email/gi; + $sc_call_url =~ s/--A--security_phrase--B--/$VAR_security_phrase/gi; + $sc_call_url =~ s/--A--comments--B--/$VAR_comments/gi; + $sc_call_url =~ s/--A--called_count--B--/$VAR_called_count/gi; + $sc_call_url =~ s/--A--last_local_call_time--B--/$VAR_last_local_call_time/gi; + $sc_call_url =~ s/--A--rank--B--/$VAR_rank/gi; + $sc_call_url =~ s/--A--owner--B--/$VAR_owner/gi; + $sc_call_url =~ s/--A--dialed_number--B--/$VAR_phone_number/gi; + $sc_call_url =~ s/--A--dialed_label--B--/$VAR_alt_dial/gi; + $sc_call_url =~ s/--A--user_custom_one--B--/$VAR_user_custom_one/gi; + $sc_call_url =~ s/--A--user_custom_two--B--/$VAR_user_custom_two/gi; + $sc_call_url =~ s/--A--user_custom_three--B--/$VAR_user_custom_three/gi; + $sc_call_url =~ s/--A--user_custom_four--B--/$VAR_user_custom_four/gi; + $sc_call_url =~ s/--A--user_custom_five--B--/$VAR_user_custom_five/gi; + $sc_call_url =~ s/--A--did_id--B--/$VAR_did_id/gi; + $sc_call_url =~ s/--A--did_extension--B--/$VAR_did_extension/gi; + $sc_call_url =~ s/--A--did_pattern--B--/$VAR_did_pattern/gi; + $sc_call_url =~ s/--A--did_description--B--/$VAR_did_description/gi; + $sc_call_url =~ s/--A--closecallid--B--/$VAR_closecallid/gi; + $sc_call_url =~ s/--A--uniqueid--B--/$VAR_uniqueid/gi; + $sc_call_url =~ s/--A--call_id--B--/$VAR_call_id/gi; + $sc_call_url =~ s/--A--user_group--B--/$VAR_user_group/gi; + $sc_call_url =~ s/--A--campaign--B--/$VAR_campaign_id/gi; + $sc_call_url =~ s/--A--campaign_id--B--/$VAR_campaign_id/gi; + $sc_call_url =~ s/--A--group--B--/$VAR_campaign_id/gi; + $sc_call_url =~ s/--A--function--B--/$function/gi; + $sc_call_url =~ s/--A--ivr_time--B--/$ivr_time/gi; + $sc_call_url =~ s/--A--talk_time--B--/$talk_time/gi; + $sc_call_url =~ s/--A--talk_time_min--B--/$talk_time_min/gi; + $sc_call_url =~ s/ /+/gi; + $sc_call_url =~ s/&/\\&/gi; + $parse_url = $sc_call_url; + + $url_function = 'sc_callurl'; + ##### END Settings Container Call URL function ##### } else { diff --git a/agc_2-X/trunk/docs/NON-AGENT_API.txt b/agc_2-X/trunk/docs/NON-AGENT_API.txt index 6adba0e3..b5040804 100644 --- a/agc_2-X/trunk/docs/NON-AGENT_API.txt +++ b/agc_2-X/trunk/docs/NON-AGENT_API.txt @@ -659,7 +659,7 @@ http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&functio http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&function=add_lead&phone_number=7275551111&campaign_id=TESTCAMP&callback=Y&callback_status=CALLBK&callback_datetime=NOW&callback_type=USERONLY&callback_user=6666&callback_comments=Comments+go+here -Example responses: +Example responses: (The "data" values for a successful add_lead request are: phone_number, list_id, lead_id, gmt_offset_now) SUCCESS: add_lead LEAD HAS BEEN ADDED - 7275551111|6666|999|193715|-4 NOTICE: add_lead ADDED TO HOPPER - 7275551111|6666|193715|1677922 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 08b1e0b8..ee5314e2 100644 --- a/agc_2-X/trunk/www/agc/vdc_db_query.php +++ b/agc_2-X/trunk/www/agc/vdc_db_query.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2017 Matt Florell LICENSE: AGPLv2 # # This script is designed to exchange information between vicidial.php and the database server for various actions # @@ -418,10 +418,11 @@ # 161117-0622 - Fixes for rare vicidial_log and recording_log issues # 161222-0728 - Fixed issue with Scheduled Callbacks with tilde'~' in text fields # 161231-1250 - Fixed issue #985, inbound dispo call url +# 170201-2214 - Fix for receiving call just after a pause # -$version = '2.14-312'; -$build = '161231-1250'; +$version = '2.14-313'; +$build = '170201-2214'; $php_script = 'vdc_db_query.php'; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=658; @@ -695,6 +696,10 @@ if (isset($_GET["customer_server_ip"])) {$customer_server_ip=$_GET["customer_ser elseif (isset($_POST["customer_server_ip"])) {$customer_server_ip=$_POST["customer_server_ip"];} if (isset($_GET["phone_pass"])) {$phone_pass=$_GET["phone_pass"];} elseif (isset($_POST["phone_pass"])) {$phone_pass=$_POST["phone_pass"];} +if (isset($_GET["VDRP_stage"])) {$VDRP_stage=$_GET["VDRP_stage"];} + elseif (isset($_POST["VDRP_stage"])) {$VDRP_stage=$_POST["VDRP_stage"];} +if (isset($_GET["previous_agent_log_id"])) {$previous_agent_log_id=$_GET["previous_agent_log_id"];} + elseif (isset($_POST["previous_agent_log_id"])) {$previous_agent_log_id=$_POST["previous_agent_log_id"];} header ("Content-type: text/html; charset=utf-8"); @@ -7632,7 +7637,6 @@ if ($ACTION == 'VDADcheckINCOMING') echo $LeaD_InfO; - $wait_sec=0; $StarTtime = date("U"); $stmt = "SELECT wait_epoch,wait_sec from vicidial_agent_log where agent_log_id='$agent_log_id';"; @@ -11961,35 +11965,22 @@ if ( ($ACTION == 'VDADpause') or ($ACTION == 'VDADready') or ($pause_trigger == } else { - $vla_autodialSQL=''; - $vla_pausecodeSQL=''; - if (preg_match('/INBOUND_MAN/',$dial_method)) - {$vla_autodialSQL = ",outbound_autodial='N'";} - if ($ACTION == 'VDADready') - {$vla_pausecodeSQL = ",pause_code='',external_pause_code=''";} - $random = (rand(1000000, 9999999) + 10000000); - $stmt="UPDATE vicidial_live_agents set uniqueid=0,callerid='',channel='', random_id='$random',comments='',last_state_change='$NOW_TIME' $vla_autodialSQL $vla_pausecodeSQL where user='$user' and server_ip='$server_ip';"; - if ($format=='debug') {echo "\n";} - $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00165',$user,$server_ip,$session_name,$one_mysql_log);} - $retry_count=0; - while ( ($errno > 0) and ($retry_count < 9) ) - { - $rslt=mysql_to_mysqli($stmt, $link); - $one_mysql_log=1; - $errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9165$retry_count",$user,$server_ip,$session_name,$one_mysql_log); - $one_mysql_log=0; - $retry_count++; - } - if ($comments != 'NO_STATUS_CHANGE') { + $VLAaffected_rows=0; $vla_lead_wipeSQL=''; + $vla_where_SQL=''; if ($ACTION == 'VDADready') - {$vla_lead_wipeSQL = ",lead_id=0";} + { + $vla_lead_wipeSQL = ",lead_id=0"; + $vla_where_SQL = "and status NOT IN('QUEUE','INCALL')"; + } if ( ($ACTION == 'VDADpause') or ($pause_trigger == 'PAUSE') ) - {$vla_ring_resetSQL = ",ring_callerid=''";} - $stmt="UPDATE vicidial_live_agents set status='$vla_status' $vla_lead_wipeSQL $vla_ring_resetSQL where user='$user' and server_ip='$server_ip';"; + { + $vla_ring_resetSQL = ",ring_callerid=''"; + $vla_where_SQL = "and status NOT IN('QUEUE','INCALL')"; + } + $stmt="UPDATE vicidial_live_agents set status='$vla_status' $vla_lead_wipeSQL $vla_ring_resetSQL where user='$user' and server_ip='$server_ip' $vla_where_SQL;"; if ($format=='debug') {echo "\n";} $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00166',$user,$server_ip,$session_name,$one_mysql_log);} @@ -12002,10 +11993,32 @@ if ( ($ACTION == 'VDADpause') or ($ACTION == 'VDADready') or ($pause_trigger == $one_mysql_log=0; $retry_count++; } - $affected_rows = mysqli_affected_rows($link); + $VLAaffected_rows = mysqli_affected_rows($link); } - if ( ($affected_rows > 0) or ($comments == 'NO_STATUS_CHANGE') ) + + if ( ($VLAaffected_rows > 0) or ($comments == 'NO_STATUS_CHANGE') ) { + $vla_autodialSQL=''; + $vla_pausecodeSQL=''; + if (preg_match('/INBOUND_MAN/',$dial_method)) + {$vla_autodialSQL = ",outbound_autodial='N'";} + if ($ACTION == 'VDADready') + {$vla_pausecodeSQL = ",pause_code='',external_pause_code=''";} + $random = (rand(1000000, 9999999) + 10000000); + $stmt="UPDATE vicidial_live_agents set uniqueid=0,callerid='',channel='', random_id='$random',comments='',last_state_change='$NOW_TIME' $vla_autodialSQL $vla_pausecodeSQL where user='$user' and server_ip='$server_ip';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00165',$user,$server_ip,$session_name,$one_mysql_log);} + $retry_count=0; + while ( ($errno > 0) and ($retry_count < 9) ) + { + $rslt=mysql_to_mysqli($stmt, $link); + $one_mysql_log=1; + $errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,"9165$retry_count",$user,$server_ip,$session_name,$one_mysql_log); + $one_mysql_log=0; + $retry_count++; + } + ############################################# ##### START QUEUEMETRICS LOGGING LOOKUP ##### $stmt = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id,queuemetrics_pe_phone_append,queuemetrics_pause_type FROM system_settings;"; @@ -12117,8 +12130,8 @@ if ( ($ACTION == 'VDADpause') or ($ACTION == 'VDADready') or ($pause_trigger == $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00171',$user,$server_ip,$session_name,$one_mysql_log);} } - - $agent_log = 'NEW_ID'; + if ($VLAaffected_rows > 0) + {$agent_log = 'NEW_ID';} } if ($wrapup == 'WRAPUP') diff --git a/agc_2-X/trunk/www/agc/vicidial.php b/agc_2-X/trunk/www/agc/vicidial.php index e38274af..e421518e 100644 --- a/agc_2-X/trunk/www/agc/vicidial.php +++ b/agc_2-X/trunk/www/agc/vicidial.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2017 Matt Florell LICENSE: AGPLv2 # # Other scripts that this application depends on: # - vdc_db_query.php: Updates information in the database @@ -536,10 +536,11 @@ # 161217-0826 - Added debug logging of dead call trigger # 161222-0727 - Fixed issue with Scheduled Callbacks with tilde'~' in text fields # 161222-1111 - Added more debug logging of events +# 170201-2215 - Fixes for pause-while-call-coming-in issues # -$version = '2.14-506c'; -$build = '161222-1111'; +$version = '2.14-507c'; +$build = '170201-2215'; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=87; $one_mysql_log=0; @@ -4473,6 +4474,11 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} var agent_display_fields=''; var customer_sec='0'; var allow_required_fields=''; + var safe_pause_counter=0; + var CFAI_sent=0; + var pause_resume_click_epoch=0; + var previous_agent_log_id=''; + var alert_box_close_counter=0; var DiaLControl_auto_HTML = "\" border=\"0\" alt=\"You are paused\" />"; var DiaLControl_auto_HTML_ready = "\" border=\"0\" alt=\"You are active\" />"; var DiaLControl_auto_HTML_OFF = "\" border=\"0\" alt=\"pause button disabled\" />"; @@ -7114,6 +7120,16 @@ function set_length(SLnumber,SLlength_goal,SLdirection) // closes callback list screen function alert_box(temp_message) { + var ABtop='200px'; + var ABleft='200px'; + if (alert_box_close_counter > 0) + { + var ABtop='50px'; + var ABleft='5px'; + } + document.getElementById("AlertBox").style.top = ABtop; + document.getElementById("AlertBox").style.left = ABleft; + document.getElementById("AlertBoxContent").innerHTML = temp_message; showDiv('AlertBox'); @@ -9457,6 +9473,7 @@ function set_length(SLnumber,SLlength_goal,SLdirection) var MDOnextResponse_array=MDOnextResponse.split("\n"); MDnextCID = MDOnextResponse_array[0]; LastCallCID = MDOnextResponse_array[0]; + if (agent_log_id.length > 0) {previous_agent_log_id = agent_log_id;} agent_log_id = MDOnextResponse_array[1]; if (MDnextCID == " CALL NOT PLACED") { @@ -9575,105 +9592,130 @@ function set_length(SLnumber,SLlength_goal,SLdirection) { if (APRclick=='YES') {button_click_log = button_click_log + "" + SQLdate + "-----AutoDial_ReSume_PauSe---" + taskaction + " " + taskagentlog + " " + taskstatuschange + " " + temp_reason + " " + temp_auto + " " + temp_auto_code + "|";} - var add_pause_code=''; - if (taskaction == 'VDADready') + if (VD_live_customer_call==1) { - VDRP_stage = 'READY'; - VDRP_stage_seconds=0; - if (INgroupCOUNT > 0) - { - if (VICIDiaL_closer_blended == 0) - {VDRP_stage = 'CLOSER';} - else - {VDRP_stage = 'READY';} - } - AutoDialReady = 1; - AutoDialWaiting = 1; - if (dial_method == "INBOUND_MAN") - { - auto_dial_level=starting_dial_level; - - document.getElementById("DiaLControl").innerHTML = "\" border=\"0\" alt=\"You are active\" />
\" border=\"0\" alt=\"Dial Next Number\" />"; - } - else - { - document.getElementById("DiaLControl").innerHTML = DiaLControl_auto_HTML_ready; - } + alert_box("\n" + VD_live_customer_call + "\n" + VDRP_stage); + button_click_log = button_click_log + "" + SQLdate + "-----ON_CALL_pause_resume_stopped---" + VD_live_customer_call + " " + VDRP_stage + "|"; } else { - VDRP_stage = 'PAUSED'; - VDRP_stage_seconds=0; - AutoDialReady = 0; - AutoDialWaiting = 0; - pause_code_counter = 0; - dial_next_failed=0; - if (dial_method == "INBOUND_MAN") + if ( (CFAI_sent > 0) && (APRclick=='YES') ) { - auto_dial_level=starting_dial_level; - - document.getElementById("DiaLControl").innerHTML = "\" border=\"0\" alt=\"You are paused\" />
\" border=\"0\" alt=\"Dial Next Number\" />"; + alert_box_close_counter=10; + alert_box(": " + CFAI_sent); + button_click_log = button_click_log + "" + SQLdate + "-----CFAI_stopped_pause_click---" + CFAI_sent + " " + taskaction + " " + agent_log_id + "|"; } else { - document.getElementById("DiaLControl").innerHTML = DiaLControl_auto_HTML; - } - - if ( (agent_pause_codes_active=='FORCE') && (temp_reason != 'LOGOUT') && (temp_reason != 'REQUEUE') && (temp_reason != 'DIALNEXT') && (temp_auto != '1') ) - { - PauseCodeSelectContent_create(); - } - if (temp_auto == '1') - { - add_pause_code = "&sub_status=" + temp_auto_code; - } - } - - var xmlhttp=false; - /*@cc_on @*/ - /*@if (@_jscript_version >= 5) - // JScript gives us Conditional compilation, we can cope with old IE versions. - // and security blocked creation of the objects. - try { - xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); - } catch (e) { - try { - xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); - } catch (E) { - xmlhttp = false; - } - } - @end @*/ - if (!xmlhttp && typeof XMLHttpRequest!='undefined') - { - xmlhttp = new XMLHttpRequest(); - } - if (xmlhttp) - { - autoDiaLready_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=" + taskaction + "&user=" + user + "&pass=" + pass + "&stage=" + VDRP_stage + "&agent_log_id=" + agent_log_id + "&agent_log=" + taskagentlog + "&wrapup=" + taskwrapup + "&campaign=" + campaign + "&dial_method=" + dial_method + "&comments=" + taskstatuschange + add_pause_code + "&qm_extension=" + qm_extension; - xmlhttp.open('POST', 'vdc_db_query.php'); - xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); - xmlhttp.send(autoDiaLready_query); - xmlhttp.onreadystatechange = function() - { - if (xmlhttp.readyState == 4 && xmlhttp.status == 200) + var add_pause_code=''; + if (taskaction == 'VDADready') { - var check_dispo = null; - check_dispo = xmlhttp.responseText; - var check_DS_array=check_dispo.split("\n"); - // alert(xmlhttp.responseText + "\n|" + check_DS_array[1] + "\n|" + check_DS_array[2] + "|"); - if (check_DS_array[1] == 'Next agent_log_id:') - {agent_log_id = check_DS_array[2];} + VDRP_stage = 'READY'; + VDRP_stage_seconds=0; + safe_pause_counter=0; + if (INgroupCOUNT > 0) + { + if (VICIDiaL_closer_blended == 0) + {VDRP_stage = 'CLOSER';} + else + {VDRP_stage = 'READY';} + } + AutoDialReady = 1; + AutoDialWaiting = 1; + if (dial_method == "INBOUND_MAN") + { + auto_dial_level=starting_dial_level; + + document.getElementById("DiaLControl").innerHTML = "\" border=\"0\" alt=\"You are active\" />
\" border=\"0\" alt=\"Dial Next Number\" />"; + } + else + { + document.getElementById("DiaLControl").innerHTML = DiaLControl_auto_HTML_ready; + } } + else + { + VDRP_stage = 'PAUSED'; + VDRP_stage_seconds=0; + AutoDialReady = 0; + AutoDialWaiting = 0; + pause_code_counter = 0; + dial_next_failed=0; + safe_pause_counter=5; + if (dial_method == "INBOUND_MAN") + { + auto_dial_level=starting_dial_level; + + document.getElementById("DiaLControl").innerHTML = "\" border=\"0\" alt=\"You are paused\" />
\" border=\"0\" alt=\"Dial Next Number\" />"; + } + else + { + document.getElementById("DiaLControl").innerHTML = DiaLControl_auto_HTML; + } + + if ( (agent_pause_codes_active=='FORCE') && (temp_reason != 'LOGOUT') && (temp_reason != 'REQUEUE') && (temp_reason != 'DIALNEXT') && (temp_auto != '1') ) + { + PauseCodeSelectContent_create(); + } + if (temp_auto == '1') + { + add_pause_code = "&sub_status=" + temp_auto_code; + } + } + + var xmlhttp=false; + /*@cc_on @*/ + /*@if (@_jscript_version >= 5) + // JScript gives us Conditional compilation, we can cope with old IE versions. + // and security blocked creation of the objects. + try { + xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); + } catch (e) { + try { + xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); + } catch (E) { + xmlhttp = false; + } + } + @end @*/ + if (!xmlhttp && typeof XMLHttpRequest!='undefined') + { + xmlhttp = new XMLHttpRequest(); + } + if (xmlhttp) + { + autoDiaLready_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=" + taskaction + "&user=" + user + "&pass=" + pass + "&stage=" + VDRP_stage + "&agent_log_id=" + agent_log_id + "&agent_log=" + taskagentlog + "&wrapup=" + taskwrapup + "&campaign=" + campaign + "&dial_method=" + dial_method + "&comments=" + taskstatuschange + add_pause_code + "&qm_extension=" + qm_extension; + xmlhttp.open('POST', 'vdc_db_query.php'); + xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); + xmlhttp.send(autoDiaLready_query); + xmlhttp.onreadystatechange = function() + { + if (xmlhttp.readyState == 4 && xmlhttp.status == 200) + { + var check_dispo = null; + check_dispo = xmlhttp.responseText; + var check_DS_array=check_dispo.split("\n"); + // alert(xmlhttp.responseText + "\n|" + check_DS_array[1] + "\n|" + check_DS_array[2] + "|"); + if (check_DS_array[1] == 'Next agent_log_id:') + { + if (agent_log_id.length > 0) {previous_agent_log_id = agent_log_id;} + var temp_agent_log_id = check_DS_array[2]; + if (temp_agent_log_id === undefined) + {button_click_log = button_click_log + "" + SQLdate + "-----AJAX_pause_resume_undefined---" + temp_agent_log_id + " " + taskaction + " " + agent_log_id + "|";} + else + {agent_log_id = temp_agent_log_id;} + } + } + } + delete xmlhttp; + } + waiting_on_dispo=0; } - delete xmlhttp; } - waiting_on_dispo=0; return agent_log_id; } - // ################################################################################ // Check to see if there is a call being sent from the auto-dialer to agent conf function ReChecKCustoMerChaN() @@ -9835,6 +9877,9 @@ function set_length(SLnumber,SLlength_goal,SLdirection) { if (typeof(xmlhttprequestcheckauto) == "undefined") { + CFAI_sent=1; + if (safe_pause_counter > 0) + {button_click_log = button_click_log + "" + SQLdate + "-----safe_pause_CFAI---" + safe_pause_counter + " " + VDRP_stage + "|";} all_record = 'NO'; all_record_count=0; // document.vicidial_form.lead_id.value = ''; @@ -9857,17 +9902,18 @@ function set_length(SLnumber,SLlength_goal,SLdirection) { xmlhttprequestcheckauto = new XMLHttpRequest(); } - if (xmlhttprequestcheckauto) - { - checkVDAI_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&orig_pass=" + orig_pass + "&campaign=" + campaign + "&ACTION=VDADcheckINCOMING" + "&agent_log_id=" + agent_log_id + "&phone_login=" + phone_login + "&agent_email=" + LOGemail + "&conf_exten=" + session_id + "&camp_script=" + campaign_script + '' + "&in_script=" + CalL_ScripT_id + "&customer_server_ip=" + lastcustserverip + "&exten=" + extension + "&original_phone_login=" + original_phone_login + "&phone_pass=" + phone_pass; - xmlhttprequestcheckauto.open('POST', 'vdc_db_query.php'); + if (xmlhttprequestcheckauto) + { + checkVDAI_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&user=" + user + "&pass=" + pass + "&orig_pass=" + orig_pass + "&campaign=" + campaign + "&ACTION=VDADcheckINCOMING" + "&agent_log_id=" + agent_log_id + "&phone_login=" + phone_login + "&agent_email=" + LOGemail + "&conf_exten=" + session_id + "&camp_script=" + campaign_script + '' + "&in_script=" + CalL_ScripT_id + "&customer_server_ip=" + lastcustserverip + "&exten=" + extension + "&original_phone_login=" + original_phone_login + "&phone_pass=" + phone_pass + "&VDRP_stage=" + VDRP_stage + "&previous_agent_log_id=" + previous_agent_log_id; + xmlhttprequestcheckauto.open('POST', 'vdc_db_query.php'); xmlhttprequestcheckauto.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); - xmlhttprequestcheckauto.send(checkVDAI_query); - xmlhttprequestcheckauto.onreadystatechange = function() + xmlhttprequestcheckauto.send(checkVDAI_query); + xmlhttprequestcheckauto.onreadystatechange = function() { if (xmlhttprequestcheckauto.readyState == 4 && xmlhttprequestcheckauto.status == 200) { var check_incoming = null; + CFAI_sent=0; check_incoming = xmlhttprequestcheckauto.responseText; // alert(checkVDAI_query); // alert(xmlhttprequestcheckauto.responseText); @@ -9878,6 +9924,17 @@ function set_length(SLnumber,SLlength_goal,SLdirection) AutoDialWaiting = 0; QUEUEpadding = 0; UpdatESettingSChecK = 1; + safe_pause_counter=0; + // fix for receiving a call just after a pause + if (VDRP_stage == 'PAUSED') + { + button_click_log = button_click_log + "" + SQLdate + "-----paused_CFAI_caught---" + VDRP_stage + " " + agent_log_id + " " + previous_agent_log_id + "|"; + agent_log_id = previous_agent_log_id; + } + + VD_live_customer_call = 1; + VD_live_call_secondS = 0; + customer_sec = 0; var VDIC_data_VDAC=check_VDIC_array[1].split("|"); VDIC_web_form_address = VICIDiaL_web_form_address; @@ -9992,10 +10049,6 @@ function set_length(SLnumber,SLlength_goal,SLdirection) if (uniqueid_status_display=='ENABLED_PRESERVE') {custom_call_id = " Call ID " + VDIC_data_VDIG[25];} - VD_live_customer_call = 1; - VD_live_call_secondS = 0; - customer_sec = 0; - // INSERT VICIDIAL_LOG ENTRY FOR THIS CALL PROCESS // DialLog("start"); @@ -10556,6 +10609,17 @@ function set_length(SLnumber,SLlength_goal,SLdirection) } xmlhttprequestcheckauto = undefined; delete xmlhttprequestcheckauto; + + if (alert_box_close_counter > 0) + { + if (VDRP_stage != 'PAUSED') + { + agent_log_id = AutoDial_ReSume_PauSe("VDADpause",'','','','','1',''); + } + button_click_log = button_click_log + "" + SQLdate + "-----CFAI_close_pause_alert---" + previous_agent_log_id + " " + agent_log_id + "|"; + alert_box_close_counter=0; + hideDiv('AlertBox'); + } } } } @@ -12680,6 +12744,7 @@ function set_length(SLnumber,SLlength_goal,SLdirection) { if (check_DS_array[1] == 'Next agent_log_id:') { + if (agent_log_id.length > 0) {previous_agent_log_id = agent_log_id;} agent_log_id = check_DS_array[2]; } } @@ -13073,7 +13138,10 @@ function set_length(SLnumber,SLlength_goal,SLdirection) var check_pause_code = xmlhttp.responseText; var check_PC_array=check_pause_code.split("\n"); if (check_PC_array[1] == 'Next agent_log_id:') - {agent_log_id = check_PC_array[2];} + { + if (agent_log_id.length > 0) {previous_agent_log_id = agent_log_id;} + agent_log_id = check_PC_array[2]; + } // alert(VMCpausecode_query); // alert(xmlhttp.responseText + "\n|" + check_PC_array[1] + "\n|" + check_PC_array[2] + "|" + agent_log_id + "|" + pause_code_counter); } @@ -16484,9 +16552,10 @@ function phone_number_format(formatphone) { if (agentonly_callbacks == '1') {CB_count_check++;} - if (AutoDialWaiting == 1) + if ( (AutoDialWaiting == 1) || (safe_pause_counter > 0) ) { check_for_auto_incoming(); + safe_pause_counter=(safe_pause_counter - 1); } // look for a channel name for the manually dialed call if (MD_channel_look==1) @@ -16757,6 +16826,14 @@ function phone_number_format(formatphone) { } } } + else + { + if (safe_pause_counter > 0) + { + check_for_auto_incoming(); + safe_pause_counter=(safe_pause_counter - 1); + } + } if (consult_custom_wait > 0) { if (consult_custom_wait == '1') @@ -16799,6 +16876,12 @@ function phone_number_format(formatphone) { // document.getElementById("debugbottomspan").innerHTML = "waiting on dispo response to resume: " + waiting_on_dispo + "|" + updatedispo_resume_trigger; } } + if (alert_box_close_counter > 0) + { + alert_box_close_counter = (alert_box_close_counter - 1); + if (alert_box_close_counter < 1) + {hideDiv('AlertBox');} + } } setTimeout("all_refresh()", refresh_interval); }