diff --git a/agc_2-X/trunk/UPGRADE b/agc_2-X/trunk/UPGRADE index 942a4905..ea892924 100644 --- a/agc_2-X/trunk/UPGRADE +++ b/agc_2-X/trunk/UPGRADE @@ -91,6 +91,12 @@ OTHER CHANGES: 14. Added ability to use No Agent Call URL with the dispo_move_list.php script see script comments for instructions. +15. Added DID options to check for a Maximum number of calls in queue in a set + In-Group and route the call to an extension if over the set number. + +16. Added the ability to define multiple Dispo Call URLs as well as define + specific statuses that they will be triggered for. + diff --git a/agc_2-X/trunk/bin/AST_send_URL.pl b/agc_2-X/trunk/bin/AST_send_URL.pl index 67f4758f..9879e933 100644 --- a/agc_2-X/trunk/bin/AST_send_URL.pl +++ b/agc_2-X/trunk/bin/AST_send_URL.pl @@ -22,6 +22,7 @@ # 150429-0910 - Added campaign variables # 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 # $|++; @@ -758,16 +759,58 @@ if (length($lead_id) > 0) } $sthA->finish(); - `$wgetbin -q --output-document=/tmp/ASUtmp$US$uniqueid$US$secX $parse_url `; + $url = $parse_url; + $url =~ s/'/\\'/gi; + $url =~ s/"/\\"/gi; - $event_string="$function|$wgetbin -q --output-document=/tmp/ASUtmp$US$uniqueid$US$secX $parse_url|"; + my $secW = time(); + + `$wgetbin --no-check-certificate --output-document=/tmp/ASUBtmpD$US$url_id$US$secX --output-file=/tmp/ASUBtmpF$US$url_id$US$secX $url `; + + $event_string="$function|$wgetbin --no-check-certificate --output-document=/tmp/ASUBtmpD$US$url_id$US$secX --output-file=/tmp/ASUBtmpF$US$url_id$US$secX $url|"; &event_logger; - ### update url log entry - $stmtA = "UPDATE vicidial_url_log SET url_response='/tmp/ASUtmp$US$uniqueid$US$secX' where url_log_id='$url_id';"; - $affected_rows = $dbhA->do($stmtA); - } + my $secY = time(); + my $response_sec = ($secY - $secW); + open(Wdoc, "/tmp/ASUBtmpD$US$url_id$US$secX") || die "can't open /tmp/ASUBtmpD$US$url_id$US$secX: $!\n"; + @Wdoc = ; + close(Wdoc); + $i=0; + $Wdocline_cat=''; + foreach(@Wdoc) + { + $Wdocline = $Wdoc[$i]; + $Wdocline =~ s/\n|\r/!/gi; + $Wdocline =~ s/ |\t|\'|\`//gi; + $Wdocline_cat .= "$Wdocline"; + $i++; + } + if (length($Wdocline_cat)<1) + {$Wdocline_cat='';} + + open(Wfile, "/tmp/ASUBtmpF$US$url_id$US$secX") || die "can't open /tmp/ASUBtmpF$US$url_id$US$secX: $!\n"; + @Wfile = ; + close(Wfile); + $i=0; + $Wfileline_cat=''; + foreach(@Wfile) + { + $Wfileline = $Wfile[$i]; + $Wfileline =~ s/\n|\r/!/gi; + $Wfileline =~ s/ |\t|\'|\`//gi; + $Wfileline_cat .= "$Wfileline"; + $i++; + } + if (length($Wfileline_cat)<1) + {$Wfileline_cat='
';} + + + ### update url log entry + $stmtA = "UPDATE vicidial_url_log SET url_response='$Wdocline_cat|$Wfileline_cat',response_sec='$response_sec' where url_log_id='$url_id';"; + $affected_rows = $dbhA->do($stmtA); + if ($DB) {print "$affected_rows|$stmtA\n";} + } my $secZ = time(); diff --git a/agc_2-X/trunk/bin/AST_send_URLbasic.pl b/agc_2-X/trunk/bin/AST_send_URLbasic.pl new file mode 100644 index 00000000..6512521c --- /dev/null +++ b/agc_2-X/trunk/bin/AST_send_URLbasic.pl @@ -0,0 +1,273 @@ +#!/usr/bin/perl +# +# AST_send_URLbasic.pl version 2.12 +# +# DESCRIPTION: +# This script is spawned by the agent interface to run for URLs in the background +# +# Copyright (C) 2015 Matt Florell LICENSE: AGPLv2 +# +# CHANGES +# 150711-1227 - First Build +# + +$|++; +use Getopt::Long; + +### Initialize date/time vars ### +my $secX = time(); #Start time + +($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); +$year = ($year + 1900); +$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 = "$year-$mon-$mday $hour:$min:$sec"; + +### Initialize run-time variables ### +my ($CLOhelp, $SYSLOG,$DB, $DBX); +my ($url_id, $lead_id, $phone_number, $call_type, $user, $uniqueid, $alt_dial, $call_id, $function); +my $FULL_LOG = 1; +$url_function = 'other'; +$US='_'; + +### begin parsing run-time options ### +if (scalar @ARGV) { + GetOptions('help!' => \$CLOhelp, + 'SYSLOG!' => \$SYSLOG, + 'url_id=s' => \$url_id, + 'debug!' => \$DB, + 'debugX!' => \$DBX, + 'fulllog!' => \$FULL_LOG, + 'compat_url=s' => \$compat_url); + + $DB = 1 if ($DBX); + if ($DB) + { + print "\n----- DEBUGGING -----\n\n"; + print "\n----- SUPER-DUPER DEBUGGING -----\n\n" if ($DBX); + print " SYSLOG: $SYSLOG\n" if ($SYSLOG); + print " url_id: $url_id\n" if ($url_id); + print " compat_url: $compat_url\n" if ($compat_url); + print "\n"; + } + if ($CLOhelp) + { + print "allowed run time options:\n"; + print " [--help] = this help screen\n"; + print " [--SYSLOG] = whether to log actions or not\n"; + print " [--debug] = debug\n"; + print " [--debugX] = extra debug\n"; + print " [--compat_url] = full compatible URL to send(not implemented)\n"; + print "required flags:\n"; + print " [--url_id] = URL ID to run\n"; + print "\n"; + print "You may prefix an option with 'no' to disable it.\n"; + print " ie. --noSYSLOG or --noFULLLOG\n"; + + exit 0; + } + } + +# default path to astguiclient configuration file: +$PATHconf = '/etc/astguiclient.conf'; + +open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n"; +@conf = ; +close(conf); +$i=0; +foreach(@conf) + { + $line = $conf[$i]; + $line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi; + if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) ) + {$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;} + if ( ($line =~ /^VARserver_ip/) && ($CLIserver_ip < 1) ) + {$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_server/) && ($CLIDB_server < 1) ) + {$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_database/) && ($CLIDB_database < 1) ) + {$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_user/) && ($CLIDB_user < 1) ) + {$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_pass/) && ($CLIDB_pass < 1) ) + {$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;} + if ( ($line =~ /^VARDB_port/) && ($CLIDB_port < 1) ) + {$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;} + $i++; + } + +if (!$VARDB_port) {$VARDB_port='3306';} + + +if (length($url_id) > 0) + { + ### find wget binary + $wgetbin = ''; + if ( -e ('/bin/wget')) {$wgetbin = '/bin/wget';} + else + { + if ( -e ('/usr/bin/wget')) {$wgetbin = '/usr/bin/wget';} + else + { + if ( -e ('/usr/local/bin/wget')) {$wgetbin = '/usr/local/bin/wget';} + else + { + print "Can't find wget binary! Exiting...\n"; + exit; + } + } + } + + use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second + use DBI; + + $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") + or die "Couldn't connect to database: " . DBI->errstr; + + ### Grab Server values from the database + $stmtA = "SELECT vd_server_logs,local_gmt,ext_context FROM servers where server_ip = '$VARserver_ip';"; + $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; + $DBvd_server_logs = $aryA[0]; + $DBSERVER_GMT = $aryA[1]; + $ext_context = $aryA[2]; + if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';} + else {$SYSLOG = '0';} + if (length($DBSERVER_GMT)>0) {$SERVER_GMT = $DBSERVER_GMT;} + } + $sthA->finish(); + + $stmtG = "SELECT url FROM vicidial_url_log where url_log_id='$url_id';"; + $sthA = $dbhA->prepare($stmtG) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtG ", $dbhA->errstr; + $url_ct=$sthA->rows; + if ($url_ct > 0) + { + @aryA = $sthA->fetchrow_array; + $url = $aryA[0]; + } + $sthA->finish(); + + if (length($url) > 5) + { + $url =~ s/ /+/gi; + $url =~ s/&/\\&/gi; + $url =~ s/'/\\'/gi; + $url =~ s/"/\\"/gi; + + my $secW = time(); + + `$wgetbin --no-check-certificate --output-document=/tmp/ASUBtmpD$US$url_id$US$secX --output-file=/tmp/ASUBtmpF$US$url_id$US$secX $url `; + + $event_string="$function|$wgetbin --no-check-certificate --output-document=/tmp/ASUBtmpD$US$url_id$US$secX --output-file=/tmp/ASUBtmpF$US$url_id$US$secX $url|"; + &event_logger; + + my $secY = time(); + my $response_sec = ($secY - $secW); + + open(Wdoc, "/tmp/ASUBtmpD$US$url_id$US$secX") || die "can't open /tmp/ASUBtmpD$US$url_id$US$secX: $!\n"; + @Wdoc = ; + close(Wdoc); + $i=0; + $Wdocline_cat=''; + foreach(@Wdoc) + { + $Wdocline = $Wdoc[$i]; + $Wdocline =~ s/\n|\r/!/gi; + $Wdocline =~ s/ |\t|\'|\`//gi; + $Wdocline_cat .= "$Wdocline"; + $i++; + } + if (length($Wdocline_cat)<1) + {$Wdocline_cat='';} + + open(Wfile, "/tmp/ASUBtmpF$US$url_id$US$secX") || die "can't open /tmp/ASUBtmpF$US$url_id$US$secX: $!\n"; + @Wfile = ; + close(Wfile); + $i=0; + $Wfileline_cat=''; + foreach(@Wfile) + { + $Wfileline = $Wfile[$i]; + $Wfileline =~ s/\n|\r/!/gi; + $Wfileline =~ s/ |\t|\'|\`//gi; + $Wfileline_cat .= "$Wfileline"; + $i++; + } + if (length($Wfileline_cat)<1) + {$Wfileline_cat='
';} + + + ### update url log entry + $stmtA = "UPDATE vicidial_url_log SET url_response='$Wdocline_cat|$Wfileline_cat',response_sec='$response_sec' where url_log_id='$url_id';"; + $affected_rows = $dbhA->do($stmtA); + if ($DB) {print "$affected_rows|$stmtA\n";} + } + else + { + if ($DB) {print "ERROR: no valid URL found: $url_id|$url\n";} + } + } + + +my $secZ = time(); +my $script_time = ($secZ - $secX); +if ($DB) {print "DONE execute time: $script_time seconds\n";} + +exit 0; +# Program ends. + + + +### Start of subroutines + +sub event_logger + { + my ($tms) = @_; + my($sec,$min,$hour,$mday,$mon,$year) = getTime($tms); + $now_date = $year.'-'.$mon.'-'.$mday.' '.$hour.':'.$min.':'.$sec; + $log_date = $year . '-' . $mon . '-' . $mday; + if (!$ASULOGfile) {$ASULOGfile = "$PATHlogs/sendurlbasic.$log_date";} + + if ($DB) {print "$now_date|$event_string|\n";} + if ($SYSLOG) + { + ### open the log file for writing ### + open(Lout, ">>$ASULOGfile") + || die "Can't open $VDRLOGfile: $!\n"; + print Lout "$now_date|$event_string|\n"; + close(Lout); + } + $event_string=''; + } + + +# getTime usage: +# getTime($SecondsSinceEpoch); +# Options: +# $SecondsSinceEpoch : Request time in seconds, defaults to current date/time. +# Returns: +# ($sec, $min, $hour. $day, $mon, $year) +sub getTime + { + my ($tms) = @_; + $tms = time unless ($tms); + my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime($tms); + $year += 1900; + $mon++; + $mon = "0" . $mon if ($mon < 10); + $mday = "0" . $mday if ($mday < 10); + $min = "0" . $min if ($min < 10); + $sec = "0" . $sec if ($sec < 10); + return ($sec,$min,$hour,$mday,$mon,$year); + } + +### End of subs 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 7f638c70..acdddfcc 100644 --- a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql +++ b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql @@ -3253,6 +3253,20 @@ allow_replies ENUM('Y','N') COLLATE utf8_unicode_ci DEFAULT 'N', PRIMARY KEY (manager_chat_id) ) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_unicode_ci; +CREATE TABLE vicidial_url_multi ( +url_id INT(9) UNSIGNED NOT NULL AUTO_INCREMENT, +campaign_id VARCHAR(20) NOT NULL, +entry_type ENUM('campaign','ingroup','list','') default '', +active ENUM('Y','N') default 'N', +url_type ENUM('dispo','start','addlead','noagent','') default '', +url_rank SMALLINT(5) default '1', +url_statuses VARCHAR(1000) default '', +url_description VARCHAR(255) default '', +url_address TEXT, +PRIMARY KEY (url_id), +KEY vicidial_url_multi_campaign_id_key (campaign_id) +) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_unicode_ci; + ALTER TABLE vicidial_email_list MODIFY message text character set utf8; @@ -3502,4 +3516,4 @@ UPDATE vicidial_configuration set value='1766' where name='qc_database_version'; UPDATE system_settings set vdc_agent_api_active='1'; -UPDATE system_settings SET db_schema_version='1418',db_schema_update_date=NOW(),reload_timestamp=NOW(); +UPDATE system_settings SET db_schema_version='1419',db_schema_update_date=NOW(),reload_timestamp=NOW(); diff --git a/agc_2-X/trunk/extras/upgrade_2.12.sql b/agc_2-X/trunk/extras/upgrade_2.12.sql index d08d9e0b..0ab9aae1 100644 --- a/agc_2-X/trunk/extras/upgrade_2.12.sql +++ b/agc_2-X/trunk/extras/upgrade_2.12.sql @@ -186,3 +186,19 @@ ALTER TABLE vicidial_inbound_dids ADD max_queue_ingroup_id VARCHAR(20) default ' ALTER TABLE vicidial_inbound_dids ADD max_queue_ingroup_extension VARCHAR(50) default '9998811112'; UPDATE system_settings SET db_schema_version='1418',db_schema_update_date=NOW() where db_schema_version < 1418; + +CREATE TABLE vicidial_url_multi ( +url_id INT(9) UNSIGNED NOT NULL AUTO_INCREMENT, +campaign_id VARCHAR(20) NOT NULL, +entry_type ENUM('campaign','ingroup','list','') default '', +active ENUM('Y','N') default 'N', +url_type ENUM('dispo','start','addlead','noagent','') default '', +url_rank SMALLINT(5) default '1', +url_statuses VARCHAR(1000) default '', +url_description VARCHAR(255) default '', +url_address TEXT, +PRIMARY KEY (url_id), +KEY vicidial_url_multi_campaign_id_key (campaign_id) +) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_unicode_ci; + +UPDATE system_settings SET db_schema_version='1419',db_schema_update_date=NOW() where db_schema_version < 1419; 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 72c78eed..482b79ff 100644 --- a/agc_2-X/trunk/www/agc/vdc_db_query.php +++ b/agc_2-X/trunk/www/agc/vdc_db_query.php @@ -382,10 +382,11 @@ # 150609-1857 - Added list_description web url variable # 150701-1205 - Modified mysqli_error() to mysqli_connect_error() where appropriate # 150706-0903 - Added user lead filter option for no-hopper dialing +# 150711-0815 - Changed to allow for multiple Dispo Call URLs # -$version = '2.12-277'; -$build = '150706-0903'; +$version = '2.12-278'; +$build = '150711-0815'; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=616; $one_mysql_log=0; @@ -639,6 +640,8 @@ if (isset($_GET["camp_script"])) {$camp_script=$_GET["camp_script"];} elseif (isset($_POST["camp_script"])) {$camp_script=$_POST["camp_script"];} if (isset($_GET["manual_dial_search_filter"])) {$manual_dial_search_filter=$_GET["manual_dial_search_filter"];} elseif (isset($_POST["manual_dial_search_filter"])) {$manual_dial_search_filter=$_POST["manual_dial_search_filter"];} +if (isset($_GET["url_ids"])) {$url_ids=$_GET["url_ids"];} + elseif (isset($_POST["url_ids"])) {$url_ids=$_POST["url_ids"];} header ("Content-type: text/html; charset=utf-8"); @@ -9407,7 +9410,7 @@ if ($ACTION == 'updateDISPO') } else { - $stmt = "SELECT dispo_call_url,queuemetrics_callstatus_override,comments_dispo_screen,comments_callback_screen from vicidial_campaigns vc,vicidial_live_agents vla where vla.campaign_id=vc.campaign_id and vla.user='$user';"; + $stmt = "SELECT dispo_call_url,queuemetrics_callstatus_override,comments_dispo_screen,comments_callback_screen,vc.campaign_id from vicidial_campaigns vc,vicidial_live_agents vla where vla.campaign_id=vc.campaign_id and vla.user='$user';"; if ($non_latin > 0) {$rslt=mysql_to_mysqli("SET NAMES 'UTF8'", $link);} if ($DB) {echo "$stmt\n";} $rslt=mysql_to_mysqli($stmt, $link); @@ -9420,6 +9423,8 @@ if ($ACTION == 'updateDISPO') $queuemetrics_callstatus_override = $row[1]; $comments_dispo_screen = $row[2]; $comments_callback_screen = $row[3]; + $DUcampaign_id = $row[4]; + $DUentry_type = 'campaign'; } ### reset the API fields in vicidial_live_agents record @@ -9506,6 +9511,8 @@ if ($ACTION == 'updateDISPO') if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00286',$user,$server_ip,$session_name,$one_mysql_log);} $row=mysqli_fetch_row($rslt); $dispo_call_url = $row[0]; + $DUcampaign_id = $stage; + $DUentry_type = 'ingroup'; } else { @@ -10515,16 +10522,97 @@ if ($ACTION == 'updateDISPO') mysqli_close($linkB); } - + + ##### check if system is set to generate logfile for dispos + $stmt="SELECT enable_agc_dispo_log FROM system_settings;"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00311',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $enable_agc_dispo_log_ct = mysqli_num_rows($rslt); + if ($enable_agc_dispo_log_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $enable_agc_dispo_log =$row[0]; + } + + if ( ($WeBRooTWritablE > 0) and ($enable_agc_dispo_log > 0) ) + { + $talk_time = 0; + $stmt = "SELECT talk_sec,dead_sec from vicidial_agent_log where lead_id='$lead_id' and agent_log_id='$CALL_agent_log_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00312',$user,$server_ip,$session_name,$one_mysql_log);} + $VAL_talk_ct = mysqli_num_rows($rslt); + if ($VAL_talk_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $talk_sec = $row[0]; + $dead_sec = $row[1]; + $talk_time = ($talk_sec - $dead_sec); + if ($talk_time < 1) + { + $talk_time = 0; + } + } + + # DATETIME|campaign|lead_id|phone_number|user|type|Call_ID||province|talk_sec| + # 2010-02-19 11:11:11|TESTCAMP|65432|3125551212|1234|D|Y09876543210987654||note|123| + $fp = fopen ("./xfer_log.txt", "a"); + fwrite ($fp, "$NOW_TIME|$campaign|$lead_id|$phone_number|$user|D|$MDnextCID||$province|$talk_sec|\n"); + fclose($fp); + } + + # debug testing sleep + # sleep(5); + + echo _QXZ("Lead %1s has been changed to %2s Status",0,'',$lead_id,$dispo_choice)."\nNext agent_log_id:\n" . $agent_log_id . "\n"; + + ############################################ ### BEGIN Issue Dispo Call URL if defined ############################################ - if (strlen($dispo_call_url) > 7) + $dispo_call_url_count=0; + $dispo_call_urlARY[0]=''; + $dispo_urls=''; + if ( (strlen($dispo_call_url) > 7) or ($dispo_call_url == 'ALT') ) + { + if ($dispo_call_url == 'ALT') + { + $stmt="SELECT url_rank,url_statuses,url_address from vicidial_url_multi where campaign_id='$DUcampaign_id' and entry_type='$DUentry_type' and url_type='dispo' and active='Y' order by url_rank limit 1000;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + $VUM_ct = mysqli_num_rows($rslt); + $k=0; + while ($VUM_ct > $k) + { + $row=mysqli_fetch_row($rslt); + $url_rank = $row[0]; + $url_statuses = " $row[1] "; + $url_address = $row[2]; + + if ( (preg_match("/---ALL---/",$url_statuses)) or ( (strlen($url_statuses)>2) and (preg_match("/ $dispo_choice /",$url_statuses)) ) ) + { + $dispo_call_urlARY[$dispo_call_url_count] = $url_address; + $dispo_call_url_count++; + } + $k++; + } + } + else + { + $dispo_call_urlARY[0] = $dispo_call_url; + $dispo_call_url_count=1; + } + } + ### loop through each Dispo URL entry and process ### + $j=0; + while ($dispo_call_url_count > $j) { $talk_time=0; $talk_time_ms=0; $talk_time_min=0; - if ( (preg_match('/--A--user_custom_/i',$dispo_call_url)) or (preg_match('/--A--fullname/i',$dispo_call_url)) or (preg_match('/--A--user_group/i',$dispo_call_url)) ) + if ( (preg_match('/--A--user_custom_/i',$dispo_call_urlARY[$j])) or (preg_match('/--A--fullname/i',$dispo_call_urlARY[$j])) or (preg_match('/--A--user_group/i',$dispo_call_urlARY[$j])) ) { $stmt = "SELECT custom_one,custom_two,custom_three,custom_four,custom_five,full_name,user_group from vicidial_users where user='$user';"; if ($DB) {echo "$stmt\n";} @@ -10544,7 +10632,7 @@ if ($ACTION == 'updateDISPO') } } - if (preg_match('/--A--talk_time/i',$dispo_call_url)) + if (preg_match('/--A--talk_time/i',$dispo_call_urlARY[$j])) { $stmt = "SELECT talk_sec,dead_sec from vicidial_agent_log where lead_id='$lead_id' and agent_log_id='$CALL_agent_log_id';"; if ($DB) {echo "$stmt\n";} @@ -10570,7 +10658,7 @@ if ($ACTION == 'updateDISPO') } } - if (preg_match('/--A--dispo_name--B--/i',$dispo_call_url)) + if (preg_match('/--A--dispo_name--B--/i',$dispo_call_urlARY[$j])) { ### find the full status name for this status $stmt = "SELECT status_name from vicidial_statuses where status='$dispo_choice';"; @@ -10600,7 +10688,7 @@ if ($ACTION == 'updateDISPO') } $dispo_name = urlencode(trim($status_name)); - if (preg_match('/--A--call_notes/i',$dispo_call_url)) + if (preg_match('/--A--call_notes/i',$dispo_call_urlARY[$j])) { if (strlen($call_notes) > 1) {$url_call_notes = urlencode(trim($call_notes));} @@ -10608,7 +10696,7 @@ if ($ACTION == 'updateDISPO') {$url_call_notes = urlencode(" ");} } - if (preg_match('/--A--dialed_/i',$dispo_call_url)) + if (preg_match('/--A--dialed_/i',$dispo_call_urlARY[$j])) { $dialed_number = $phone_number; $dialed_label = 'NONE'; @@ -10630,7 +10718,7 @@ if ($ACTION == 'updateDISPO') } } - if (preg_match('/--A--did_/i',$dispo_call_url)) + if (preg_match('/--A--did_/i',$dispo_call_urlARY[$j])) { $DID_id=''; $DID_extension=''; @@ -10662,7 +10750,7 @@ if ($ACTION == 'updateDISPO') } } - if ((preg_match('/callid--B--/i',$dispo_call_url)) or (preg_match('/group--B--/i',$dispo_call_url))) + if ((preg_match('/callid--B--/i',$dispo_call_urlARY[$j])) or (preg_match('/group--B--/i',$dispo_call_urlARY[$j]))) { $INclosecallid=''; $INxfercallid=''; @@ -10723,7 +10811,7 @@ if ($ACTION == 'updateDISPO') $entry_list_id = urlencode(trim($row[34])); } - if (preg_match('/list_name--B--|list_description--B--/i',$dispo_call_url)) + if (preg_match('/list_name--B--|list_description--B--/i',$dispo_call_urlARY[$j])) { $stmt = "SELECT list_name,list_description from vicidial_lists where list_id='$list_id' limit 1;"; if ($DB) {echo "$stmt\n";} @@ -10738,85 +10826,85 @@ if ($ACTION == 'updateDISPO') } } - $dispo_call_url = preg_replace('/^VAR/','',$dispo_call_url); - $dispo_call_url = preg_replace('/--A--lead_id--B--/i',"$lead_id",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--vendor_id--B--/i',"$vendor_id",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--vendor_lead_code--B--/i',"$vendor_lead_code",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--list_id--B--/i',"$list_id",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--list_name--B--/i',"$list_name",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--list_description--B--/i',"$list_description",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--gmt_offset_now--B--/i',"$gmt_offset_now",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--phone_code--B--/i',"$phone_code",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--phone_number--B--/i',"$phone_number",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--title--B--/i',"$title",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--first_name--B--/i',"$first_name",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--middle_initial--B--/i',"$middle_initial",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--last_name--B--/i',"$last_name",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--address1--B--/i',"$address1",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--address2--B--/i',"$address2",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--address3--B--/i',"$address3",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--city--B--/i',"$city",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--state--B--/i',"$state",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--province--B--/i',"$province",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--postal_code--B--/i',"$postal_code",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--country_code--B--/i',"$country_code",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--gender--B--/i',"$gender",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--date_of_birth--B--/i',"$date_of_birth",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--alt_phone--B--/i',"$alt_phone",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--email--B--/i',"$email",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--security_phrase--B--/i',"$security_phrase",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--comments--B--/i',"$comments",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--user--B--/i',"$user",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--pass--B--/i',"$orig_pass",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--campaign--B--/i',"$campaign",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--phone_login--B--/i',"$phone_login",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--original_phone_login--B--/i',"$original_phone_login",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--phone_pass--B--/i',"$phone_pass",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--fronter--B--/i',"$fronter",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--closer--B--/i',"$user",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--group--B--/i',"$VDADchannel_group",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--channel_group--B--/i',"$VDADchannel_group",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--SQLdate--B--/i',"$SQLdate",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--epoch--B--/i',"$epoch",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--uniqueid--B--/i',"$uniqueid",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--customer_zap_channel--B--/i',"$customer_zap_channel",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--customer_server_ip--B--/i',"$customer_server_ip",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--server_ip--B--/i',"$server_ip",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--SIPexten--B--/i',"$SIPexten",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--session_id--B--/i',"$session_id",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--phone--B--/i',"$phone",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--parked_by--B--/i',"$parked_by",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--dispo--B--/i',"$dispo",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--dispo_name--B--/i',"$dispo_name",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--dialed_number--B--/i',"$dialed_number",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--dialed_label--B--/i',"$dialed_label",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--source_id--B--/i',"$source_id",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--rank--B--/i',"$rank",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--owner--B--/i',"$owner",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--camp_script--B--/i',"$camp_script",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--in_script--B--/i',"$in_script",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--fullname--B--/i',"$fullname",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--user_custom_one--B--/i',"$user_custom_one",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--user_custom_two--B--/i',"$user_custom_two",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--user_custom_three--B--/i',"$user_custom_three",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--user_custom_four--B--/i',"$user_custom_four",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--user_custom_five--B--/i',"$user_custom_five",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--talk_time--B--/i',"$talk_time",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--talk_time_ms--B--/i',"$talk_time_ms",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--talk_time_min--B--/i',"$talk_time_min",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--agent_log_id--B--/i',"$CALL_agent_log_id",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--entry_list_id--B--/i',"$entry_list_id",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--did_id--B--/i',urlencode(trim($DID_id)),$dispo_call_url); - $dispo_call_url = preg_replace('/--A--did_extension--B--/i',urlencode(trim($DID_extension)),$dispo_call_url); - $dispo_call_url = preg_replace('/--A--did_pattern--B--/i',urlencode(trim($DID_pattern)),$dispo_call_url); - $dispo_call_url = preg_replace('/--A--did_description--B--/i',urlencode(trim($DID_description)),$dispo_call_url); - $dispo_call_url = preg_replace('/--A--closecallid--B--/i',urlencode(trim($INclosecallid)),$dispo_call_url); - $dispo_call_url = preg_replace('/--A--xfercallid--B--/i',urlencode(trim($INxfercallid)),$dispo_call_url); - $dispo_call_url = preg_replace('/--A--call_id--B--/i',urlencode(trim($MDnextCID)),$dispo_call_url); - $dispo_call_url = preg_replace('/--A--user_group--B--/i',urlencode(trim($user_group)),$dispo_call_url); - $dispo_call_url = preg_replace('/--A--call_notes--B--/i',"$url_call_notes",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--recording_id--B--/i',"$recording_id",$dispo_call_url); - $dispo_call_url = preg_replace('/--A--recording_filename--B--/i',"$recording_filename",$dispo_call_url); + $dispo_call_urlARY[$j] = preg_replace('/^VAR/','',$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--lead_id--B--/i',"$lead_id",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--vendor_id--B--/i',"$vendor_id",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--vendor_lead_code--B--/i',"$vendor_lead_code",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--list_id--B--/i',"$list_id",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--list_name--B--/i',"$list_name",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--list_description--B--/i',"$list_description",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--gmt_offset_now--B--/i',"$gmt_offset_now",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--phone_code--B--/i',"$phone_code",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--phone_number--B--/i',"$phone_number",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--title--B--/i',"$title",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--first_name--B--/i',"$first_name",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--middle_initial--B--/i',"$middle_initial",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--last_name--B--/i',"$last_name",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--address1--B--/i',"$address1",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--address2--B--/i',"$address2",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--address3--B--/i',"$address3",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--city--B--/i',"$city",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--state--B--/i',"$state",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--province--B--/i',"$province",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--postal_code--B--/i',"$postal_code",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--country_code--B--/i',"$country_code",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--gender--B--/i',"$gender",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--date_of_birth--B--/i',"$date_of_birth",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--alt_phone--B--/i',"$alt_phone",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--email--B--/i',"$email",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--security_phrase--B--/i',"$security_phrase",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--comments--B--/i',"$comments",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--user--B--/i',"$user",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--pass--B--/i',"$orig_pass",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--campaign--B--/i',"$campaign",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--phone_login--B--/i',"$phone_login",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--original_phone_login--B--/i',"$original_phone_login",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--phone_pass--B--/i',"$phone_pass",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--fronter--B--/i',"$fronter",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--closer--B--/i',"$user",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--group--B--/i',"$VDADchannel_group",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--channel_group--B--/i',"$VDADchannel_group",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--SQLdate--B--/i',"$SQLdate",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--epoch--B--/i',"$epoch",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--uniqueid--B--/i',"$uniqueid",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--customer_zap_channel--B--/i',"$customer_zap_channel",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--customer_server_ip--B--/i',"$customer_server_ip",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--server_ip--B--/i',"$server_ip",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--SIPexten--B--/i',"$SIPexten",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--session_id--B--/i',"$session_id",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--phone--B--/i',"$phone",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--parked_by--B--/i',"$parked_by",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--dispo--B--/i',"$dispo",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--dispo_name--B--/i',"$dispo_name",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--dialed_number--B--/i',"$dialed_number",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--dialed_label--B--/i',"$dialed_label",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--source_id--B--/i',"$source_id",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--rank--B--/i',"$rank",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--owner--B--/i',"$owner",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--camp_script--B--/i',"$camp_script",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--in_script--B--/i',"$in_script",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--fullname--B--/i',"$fullname",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--user_custom_one--B--/i',"$user_custom_one",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--user_custom_two--B--/i',"$user_custom_two",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--user_custom_three--B--/i',"$user_custom_three",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--user_custom_four--B--/i',"$user_custom_four",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--user_custom_five--B--/i',"$user_custom_five",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--talk_time--B--/i',"$talk_time",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--talk_time_ms--B--/i',"$talk_time_ms",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--talk_time_min--B--/i',"$talk_time_min",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--agent_log_id--B--/i',"$CALL_agent_log_id",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--entry_list_id--B--/i',"$entry_list_id",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--did_id--B--/i',urlencode(trim($DID_id)),$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--did_extension--B--/i',urlencode(trim($DID_extension)),$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--did_pattern--B--/i',urlencode(trim($DID_pattern)),$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--did_description--B--/i',urlencode(trim($DID_description)),$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--closecallid--B--/i',urlencode(trim($INclosecallid)),$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--xfercallid--B--/i',urlencode(trim($INxfercallid)),$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--call_id--B--/i',urlencode(trim($MDnextCID)),$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--user_group--B--/i',urlencode(trim($user_group)),$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--call_notes--B--/i',"$url_call_notes",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--recording_id--B--/i',"$recording_id",$dispo_call_urlARY[$j]); + $dispo_call_urlARY[$j] = preg_replace('/--A--recording_filename--B--/i',"$recording_filename",$dispo_call_urlARY[$j]); if (strlen($FORMcustom_field_names)>2) { @@ -10841,7 +10929,7 @@ if ($ACTION == 'updateDISPO') $form_field_value = urlencode(trim("$row[$o]")); $field_name_id = $custom_field_names_ARY[$o]; $field_name_tag = "--A--" . $field_name_id . "--B--"; - $dispo_call_url = preg_replace("/$field_name_tag/i","$form_field_value",$dispo_call_url); + $dispo_call_urlARY[$j] = preg_replace("/$field_name_tag/i","$form_field_value",$dispo_call_urlARY[$j]); $o++; } } @@ -10854,10 +10942,7 @@ if ($ACTION == 'updateDISPO') $vle_update = mysqli_affected_rows($link); ### insert a new url log entry - $SQL_log = "$dispo_call_url"; - $SQL_log = preg_replace('/;/','',$SQL_log); - $SQL_log = addslashes($SQL_log); - $stmt = "INSERT INTO vicidial_url_log SET uniqueid='$uniqueid',url_date='$NOW_TIME',url_type='dispo',url='$SQL_log',url_response='';"; + $stmt = "INSERT INTO vicidial_url_log SET uniqueid='$uniqueid',url_date=NOW(),url_type='dispo',url='" . mysqli_real_escape_string($link, $dispo_call_urlARY[$j]) . "',url_response='';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00424',$user,$server_ip,$session_name,$one_mysql_log);} @@ -10867,8 +10952,14 @@ if ($ACTION == 'updateDISPO') $URLstart_sec = date("U"); ### send dispo_call_url ### - if ($DB > 0) {echo "$dispo_call_url
\n";} - $SCUfile = file("$dispo_call_url"); + if ($DB > 0) {echo "$dispo_call_urlARY[$j]
\n";} + + $dispo_urls .= "$url_id|"; + + # exec("./AST_send_URLbasic.pl --url_id=$url_id &"); + + /* + $SCUfile = file("$dispo_call_urlARY[$j]"); if ( !($SCUfile) ) { $error_array = error_get_last(); @@ -10898,7 +10989,7 @@ if ($ACTION == 'updateDISPO') $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00425',$user,$server_ip,$session_name,$one_mysql_log);} $affected_rows = mysqli_affected_rows($link); - + */ $stmt = "SELECT enable_vtiger_integration FROM system_settings;"; $rslt=mysql_to_mysqli($stmt, $link); @@ -10909,18 +11000,18 @@ if ($ACTION == 'updateDISPO') $row=mysqli_fetch_row($rslt); $enable_vtiger_integration = $row[0]; } - if ( ($enable_vtiger_integration > 0) and (preg_match('/mode=callend/',$dispo_call_url)) and (preg_match('/contactwsid/',$dispo_call_url)) ) + if ( ($enable_vtiger_integration > 0) and (preg_match('/mode=callend/',$dispo_call_urlARY[$j])) and (preg_match('/contactwsid/',$dispo_call_urlARY[$j])) ) { $SCUoutput=''; foreach ($SCUfile as $SCUline) {$SCUoutput .= "$SCUline";} $fp = fopen ("./call_url_log.txt", "a"); - fwrite ($fp, "$dispo_call_url\n$SCUoutput\n"); + fwrite ($fp, "$dispo_call_urlARY[$j]\n$SCUoutput\n"); fclose($fp); } ### add this to the Dispo URL for callcard calls to be logged "&callcard=--A--talk_time_min--B--" - if (preg_match("/callcard/",$dispo_call_url)) + if (preg_match("/callcard/",$dispo_call_urlARY[$j])) { $stmt="SELECT balance_minutes_start,card_id FROM callcard_log where uniqueid='$uniqueid' order by call_time desc LIMIT 1;"; $rslt=mysql_to_mysqli($stmt, $link); @@ -10928,7 +11019,7 @@ if ($ACTION == 'updateDISPO') if ($DB) {echo "$stmt\n";} $bms_ct = mysqli_num_rows($rslt); $fp = fopen ("./call_url_log.txt", "a"); - fwrite ($fp, "$dispo_call_url\n$stmt|$bms_ct\n"); + fwrite ($fp, "$dispo_call_urlARY[$j]\n$stmt|$bms_ct\n"); fclose($fp); if ($bms_ct > 0) @@ -10958,57 +11049,89 @@ if ($ACTION == 'updateDISPO') $ccad_update = mysqli_affected_rows($link); } } + $j++; } + echo "Dispo URLs:\n$dispo_urls\n"; ############################################ ### END Issue Dispo Call URL if defined ############################################ - - - ##### check if system is set to generate logfile for dispos - $stmt="SELECT enable_agc_dispo_log FROM system_settings;"; - $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00311',$user,$server_ip,$session_name,$one_mysql_log);} - if ($DB) {echo "$stmt\n";} - $enable_agc_dispo_log_ct = mysqli_num_rows($rslt); - if ($enable_agc_dispo_log_ct > 0) - { - $row=mysqli_fetch_row($rslt); - $enable_agc_dispo_log =$row[0]; - } - - if ( ($WeBRooTWritablE > 0) and ($enable_agc_dispo_log > 0) ) - { - $talk_time = 0; - $stmt = "SELECT talk_sec,dead_sec from vicidial_agent_log where lead_id='$lead_id' and agent_log_id='$CALL_agent_log_id';"; - if ($DB) {echo "$stmt\n";} - $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00312',$user,$server_ip,$session_name,$one_mysql_log);} - $VAL_talk_ct = mysqli_num_rows($rslt); - if ($VAL_talk_ct > 0) - { - $row=mysqli_fetch_row($rslt); - $talk_sec = $row[0]; - $dead_sec = $row[1]; - $talk_time = ($talk_sec - $dead_sec); - if ($talk_time < 1) - { - $talk_time = 0; - } - } - - # DATETIME|campaign|lead_id|phone_number|user|type|Call_ID||province|talk_sec| - # 2010-02-19 11:11:11|TESTCAMP|65432|3125551212|1234|D|Y09876543210987654||note|123| - $fp = fopen ("./xfer_log.txt", "a"); - fwrite ($fp, "$NOW_TIME|$campaign|$lead_id|$phone_number|$user|D|$MDnextCID||$province|$talk_sec|\n"); - fclose($fp); - } - - # debug testing sleep - # sleep(5); - - echo _QXZ("Lead %1s has been changed to %2s Status",0,'',$lead_id,$dispo_choice)."\nNext agent_log_id:\n" . $agent_log_id . "\n"; } + +################################################################################ +### RUNurls - update the vicidial_list table to reflect the values that are +### in the agents screen at time of call hangup +################################################################################ +if ($ACTION == 'RUNurls') + { + $MT[0]=''; + $row=''; $rowx=''; + if (strlen($url_ids) < 2) + { + echo _QXZ("URL IDs are is not valid",0,'',$url_ids)."\n"; + exit; + } + else + { + $urls_split = explode('|',$url_ids); + $urls_split_ct = count($urls_split); + $k=0; + while ($k < $urls_split_ct) + { + if (strlen($urls_split[$k]) > 0) + { + $stmt="SELECT url FROM vicidial_url_log where url_log_id='$urls_split[$k]';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $urlid_ct = mysqli_num_rows($rslt); + if ($urlid_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $url = $row[0]; + + $URLstart_sec = date("U"); + + $SCUfile = file("$url"); + if ( !($SCUfile) ) + { + $error_array = error_get_last(); + $error_type = $error_array["type"]; + $error_message = $error_array["message"]; + $error_line = $error_array["line"]; + $error_file = $error_array["file"]; + } + + if ($DB > 0) {echo "$SCUfile[0]
\n";} + + ### update url log entry + $URLend_sec = date("U"); + $URLdiff_sec = ($URLend_sec - $URLstart_sec); + if ($SCUfile) + { + $SCUfile_contents = implode("", $SCUfile); + $SCUfile_contents = ereg_replace(';','',$SCUfile_contents); + $SCUfile_contents = addslashes($SCUfile_contents); + } + else + { + $SCUfile_contents = "PHP ERROR: Type=$error_type - Message=$error_message - Line=$error_line - File=$error_file"; + } + $stmt = "UPDATE vicidial_url_log SET response_sec='$URLdiff_sec',url_response='" . date("r") . "|$SCUfile_contents' where url_log_id='$urls_split[$k]';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00425',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rows = mysqli_affected_rows($link); + + echo "URL sent: $k|$urls_split[$k]|$affected_rows|$URLdiff_sec\n"; + } + } + $k++; + } + } + } + + ################################################################################ ### updateLEAD - update the vicidial_list table to reflect the values that are ### in the agents screen at time of call hangup diff --git a/agc_2-X/trunk/www/agc/vicidial.php b/agc_2-X/trunk/www/agc/vicidial.php index 2d7b627a..2eaaeea4 100644 --- a/agc_2-X/trunk/www/agc/vicidial.php +++ b/agc_2-X/trunk/www/agc/vicidial.php @@ -491,11 +491,12 @@ # 150609-1917 - Added list_description web url variable # 150610-0940 - Added customer_gone_seconds campaign option # 150701-1211 - Modified mysqli_error() to mysqli_connect_error() where appropriate -# 150704-0005 - Change disposubmit to be blocking before resume, Issue #863 +# 150704-0005 - Changed disposubmit to be blocking before resume, Issue #863 +# 150712-2045 - Changed dispo call url to operate through a separate AJAX process # -$version = '2.12-464c'; -$build = '150704-0005'; +$version = '2.12-465c'; +$build = '150712-2045'; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=85; $one_mysql_log=0; @@ -11234,6 +11235,7 @@ function set_length(SLnumber,SLlength_goal,SLdirection) waiting_on_dispo=1; var VDDCU_recording_id=document.getElementById("RecorDID").innerHTML; var VDDCU_recording_filename=last_recording_filename; + var dispo_urls=''; document.getElementById("callchannel").innerHTML = ''; document.vicidial_form.callserverip.value = ''; document.vicidial_form.xferchannel.value = ''; @@ -11319,17 +11321,23 @@ function set_length(SLnumber,SLlength_goal,SLdirection) if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { - // alert(xmlhttp.responseText); + // alert(xmlhttp.responseText); + var check_dispo = null; + check_dispo = xmlhttp.responseText; + var check_DS_array=check_dispo.split("\n"); if (auto_dial_level < 1) { - var check_dispo = null; - check_dispo = xmlhttp.responseText; - var check_DS_array=check_dispo.split("\n"); if (check_DS_array[1] == 'Next agent_log_id:') { agent_log_id = check_DS_array[2]; } } + if (check_DS_array[3] == 'Dispo URLs:') + { + dispo_urls = check_DS_array[4]; + + SendURLs(dispo_urls,"dispo"); + } waiting_on_dispo=0; } } @@ -11589,6 +11597,50 @@ function set_length(SLnumber,SLlength_goal,SLdirection) } +// ################################################################################ +// Submit the URLs + function SendURLs(newurlids,newurltype) + { + // Send AJAX call to run the defined url_ids for dispo_call_url + 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) + { + DUsend_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=RUNurls&format=text&user=" + user + "&pass=" + pass + "&orig_pass=" + orig_pass + "&url_ids=" + newurlids + "&campaign=" + campaign + "&auto_dial_level=" + auto_dial_level + "&stage=dispo"; + xmlhttp.open('POST', 'vdc_db_query.php'); + xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); + xmlhttp.send(DUsend_query); + xmlhttp.onreadystatechange = function() + { + if (xmlhttp.readyState == 4 && xmlhttp.status == 200) + { + // alert(DUsend_query + "\n" + xmlhttp.responseText); + var dispo_url_send_response = null; + dispo_url_send_response = xmlhttp.responseText; + } + } + delete xmlhttp; + } + } + + // ################################################################################ // Submit the Pause Code function PauseCodeSelect_submit(newpausecode) diff --git a/agc_2-X/trunk/www/vicidial/admin.php b/agc_2-X/trunk/www/vicidial/admin.php index d1d934d5..5f361c71 100644 --- a/agc_2-X/trunk/www/vicidial/admin.php +++ b/agc_2-X/trunk/www/vicidial/admin.php @@ -3526,12 +3526,13 @@ else # 150703-2105 - Fixed field sizes in Issues #867 and #868 # 150706-0811 - Added user setting for lead_filter_id in no-hopper dialing # 150708-2246 - Added max_queue_ingroup_ DID settings options +# 150710-1120 - Added options for alternate Dispo Call URLs # # make sure you have added a user to the vicidial_users MySQL table with at least user_level 9 to access this page the first time -$admin_version = '2.12-495a'; -$build = '150708-2246'; +$admin_version = '2.12-496a'; +$build = '150710-1120'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -19834,7 +19835,23 @@ if ($ADD==31) echo ""._QXZ("Start Call URL").": $NWB#campaigns-start_call_url$NWE\n"; - echo ""._QXZ("Dispo Call URL").": $NWB#campaigns-dispo_call_url$NWE\n"; + if ($dispo_call_url == 'ALT') + { + $stmt="SELECT count(*) from vicidial_url_multi where campaign_id='$campaign_id' and entry_type='campaign' and url_type='dispo';"; + $rslt=mysql_to_mysqli($stmt, $link); + $vum_to_print = mysqli_num_rows($rslt); + if ($vum_to_print > 0) + { + $rowx=mysqli_fetch_row($rslt); + $vum_count = $rowx[0]; + } + + echo ""._QXZ("Dispo Call URL").": $NWB#campaigns-dispo_call_url$NWE "._QXZ("Alternate Dispo URLs Defined").": $vum_count\n"; + } + else + { + echo ""._QXZ("Dispo Call URL").": $NWB#campaigns-dispo_call_url$NWE\n"; + } echo ""._QXZ("No Agent Call URL").": $NWB#campaigns-na_call_url$NWE\n"; @@ -23961,7 +23978,23 @@ if ($ADD==3111) echo ""._QXZ("Start Call URL").": $NWB#inbound_groups-start_call_url$NWE\n"; - echo ""._QXZ("Dispo Call URL").": $NWB#inbound_groups-dispo_call_url$NWE\n"; + if ($dispo_call_url == 'ALT') + { + $stmt="SELECT count(*) from vicidial_url_multi where campaign_id='$group_id' and entry_type='ingroup' and url_type='dispo';"; + $rslt=mysql_to_mysqli($stmt, $link); + $vum_to_print = mysqli_num_rows($rslt); + if ($vum_to_print > 0) + { + $rowx=mysqli_fetch_row($rslt); + $vum_count = $rowx[0]; + } + + echo ""._QXZ("Dispo Call URL").": $NWB#inbound_groups-dispo_call_url$NWE "._QXZ("Alternate Dispo URLs Defined").": $vum_count\n"; + } + else + { + echo ""._QXZ("Dispo Call URL").": $NWB#inbound_groups-dispo_call_url$NWE\n"; + } echo ""._QXZ("Add Lead URL").": $NWB#inbound_groups-add_lead_url$NWE\n"; @@ -24708,7 +24741,23 @@ if ($ADD==3811) echo ""._QXZ("Start Email URL").": $NWB#inbound_groups-start_email_url$NWE\n"; - echo ""._QXZ("Dispo Email URL").": $NWB#inbound_groups-dispo_email_url$NWE\n"; + if ($dispo_call_url == 'ALT') + { + $stmt="SELECT count(*) from vicidial_url_multi where campaign_id='$group_id' and entry_type='ingroup' and url_type='dispo';"; + $rslt=mysql_to_mysqli($stmt, $link); + $vum_to_print = mysqli_num_rows($rslt); + if ($vum_to_print > 0) + { + $rowx=mysqli_fetch_row($rslt); + $vum_count = $rowx[0]; + } + + echo ""._QXZ("Dispo Email URL").": $NWB#inbound_groups-dispo_call_url$NWE "._QXZ("Alternate Dispo URLs Defined").": $vum_count\n"; + } + else + { + echo ""._QXZ("Dispo Email URL").": $NWB#inbound_groups-dispo_email_url$NWE\n"; + } # echo "Add Lead URL: $NWB#inbound_groups-add_lead_url$NWE\n"; @@ -25443,11 +25492,27 @@ if ($ADD==3911) echo ""._QXZ("Start Chat URL").": $NWB#inbound_groups-start_chat_url$NWE\n"; - echo ""._QXZ("Dispo Chat URL").": $NWB#inbound_groups-dispo_chat_url$NWE\n"; + if ($dispo_call_url == 'ALT') + { + $stmt="SELECT count(*) from vicidial_url_multi where campaign_id='$group_id' and entry_type='ingroup' and url_type='dispo';"; + $rslt=mysql_to_mysqli($stmt, $link); + $vum_to_print = mysqli_num_rows($rslt); + if ($vum_to_print > 0) + { + $rowx=mysqli_fetch_row($rslt); + $vum_count = $rowx[0]; + } + + echo ""._QXZ("Dispo Chat URL").": $NWB#inbound_groups-dispo_call_url$NWE "._QXZ("Alternate Dispo URLs Defined").": $vum_count\n"; + } + else + { + echo ""._QXZ("Dispo Chat URL").": $NWB#inbound_groups-dispo_chat_url$NWE\n"; + } echo ""._QXZ("No Agent Chat URL").": $NWB#inbound_groups-na_chat_url$NWE\n"; /* - echo "Extension Append CID: $NWB#inbound_groups-extension_appended_cidname$NWE\n"; + echo "Extension Append CID: $NWB#inbound_groups-extension_appended_cidname$NWE\n"; */ echo ""._QXZ("Uniqueid Status Display").": $NWB#inbound_groups-uniqueid_status_display$NWE\n"; @@ -26080,7 +26145,7 @@ if ($ADD==3311) $i++; } - echo ""._QXZ("No-Agent In-Group Redirect").": $NWB#inbound_dids-no_agent_ingroup_redirect$NWE\n"; + echo ""._QXZ("No-Agent In-Group Redirect").": $NWB#inbound_dids-no_agent_ingroup_redirect$NWE\n"; echo ""._QXZ("No-Agent In-Group ID").":