From 37f62d3836e163df9b99bbbd69079e86efd81aa7 Mon Sep 17 00:00:00 2001 From: mattf Date: Sun, 20 Oct 2019 17:42:33 +0000 Subject: [PATCH] Added User Maximum Inbound Calls Filters features git-svn-id: svn://192.168.202.10@3149 3d104415-ff17-0410-8863-d5cf3c621b8a --- UPGRADE | 5 + agi/VD_amd.agi | 17 +- agi/agi-VDAD_ALL_inbound.agi | 64 ++- bin/ADMIN_keepalive_ALL.pl | 7 +- bin/AST_VDremote_agents.pl | 73 ++- bin/VD_email_inbound.pl | 3 + extras/MySQL_AST_CREATE_tables.sql | 14 +- extras/upgrade_2.14.sql | 17 +- www/agc/vdc_db_query.php | 738 ++++++++++++++++------------ www/agc/vicidial.php | 19 +- www/vicidial/admin.php | 176 ++++++- www/vicidial/help_documentation.txt | 12 +- 12 files changed, 767 insertions(+), 378 deletions(-) diff --git a/UPGRADE b/UPGRADE index b2641d1d..d2f23153 100644 --- a/UPGRADE +++ b/UPGRADE @@ -427,6 +427,11 @@ OTHER CHANGES: 118. Added bench_agent_assign.php script to allow managers to move 'owner-assigned' to another agent. +119. Added User Inbound Max Calls filtering options. Allowing selective counting + of inbound calls excluding calls involving set in-groups, statuses and + with a minimum time threshold. Also, new in-group routing options based + on last non-filtered call times + diff --git a/agi/VD_amd.agi b/agi/VD_amd.agi index cff6ee38..8d580c2d 100644 --- a/agi/VD_amd.agi +++ b/agi/VD_amd.agi @@ -56,6 +56,7 @@ # 190216-0813 - Fix for user-group, in-group and campaign allowed/permissions matching issues # 190320-2331 - Added more logging options # 190720-1007 - Added Call Quota logging +# 191017-1051 - Added option for multiple prompts in DYN messages # $script = 'VD_amd.agi'; @@ -664,10 +665,18 @@ else { $useTTS=0; if ($DB_am_message_exten =~ /^TTS/) - {$useTTS++;} - $TTS_filename = $DB_am_message_exten; - $TTS_filename =~s/^TTS|^DYN//gi; - $TTS_filename =~s/\|.*//gi; + { + $useTTS++; + $TTS_filename = $DB_am_message_exten; + $TTS_filename =~s/^TTS//gi; + $TTS_filename =~s/\|.*//gi; + } + else + { + $TTS_filename = $DB_am_message_exten; + $TTS_filename =~s/^DYN//gi; + $TTS_text = $TTS_filename; + } if ($AGILOG) {$agi_string = "-- TTS : |$useTTS|$TTS_filename|"; &agi_output;} diff --git a/agi/agi-VDAD_ALL_inbound.agi b/agi/agi-VDAD_ALL_inbound.agi index 08d2eea6..201eb165 100644 --- a/agi/agi-VDAD_ALL_inbound.agi +++ b/agi/agi-VDAD_ALL_inbound.agi @@ -2683,6 +2683,8 @@ while ( ($drop_timer <= $DROP_TIME) && ($wait_in_queue > 0) && ($MCdrop_override if ($CAMP_callorder =~ /oldest_call_finish/i) {$agent_call_order = 'order by vicidial_live_agents.last_call_finish';} if ($CAMP_callorder =~ /oldest_inbound_call_start/i) {$agent_call_order = 'order by vicidial_live_agents.last_inbound_call_time';} if ($CAMP_callorder =~ /oldest_inbound_call_finish/i) {$agent_call_order = 'order by vicidial_live_agents.last_inbound_call_finish';} + if ($CAMP_callorder =~ /oldest_inbound_filtered_call_start/i) {$agent_call_order = 'order by vicidial_live_agents.last_inbound_call_time_filtered';} + if ($CAMP_callorder =~ /oldest_inbound_filtered_call_finish/i) {$agent_call_order = 'order by vicidial_live_agents.last_inbound_call_finish_filtered';} if ($CAMP_callorder =~ /random/i) {$agent_call_order = 'order by random_id';} if ($CAMP_callorder =~ /campaign_rank/i) {$agent_call_order = 'order by campaign_weight desc,last_call_finish';} if ($CAMP_callorder =~ /fewest_calls_campaign/i) {$agent_call_order = 'order by vicidial_live_agents.calls_today,vicidial_live_agents.last_call_finish';} @@ -3748,8 +3750,24 @@ while ( ($drop_timer <= $DROP_TIME) && ($wait_in_queue > 0) && ($MCdrop_override $AGI->stream_file('sip-silence'); } + ### gather user details for max calls and filtered settings + $max_inbound_calls=0; + $stmtA = "SELECT max_inbound_calls,max_inbound_filter_enabled,max_inbound_filter_ingroups FROM vicidial_users where user='$VDADuser';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArowsMIC=$sthA->rows; + $dbhP=$dbhA; $mysql_count='02199'; $MEL_aff_rows=$sthArows; &mysql_error_logging; + if ($sthArowsMIC > 0) + { + @aryA = $sthA->fetchrow_array; + $VU_max_inbound_calls = $aryA[0]; + $VU_max_inbound_filter_enabled = $aryA[1]; + $VU_max_inbound_filter_ingroups = $aryA[2]; + } + ### update calls_today for vicidial_live_inbound_agents ### - $stmtA = "SELECT calls_today from vicidial_inbound_group_agents WHERE user='$VDADuser' and group_id='$channel_group';"; + $calls_today_filteredSQL=''; + $stmtA = "SELECT calls_today,calls_today_filtered from vicidial_inbound_group_agents WHERE user='$VDADuser' and group_id='$channel_group';"; if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -3758,34 +3776,38 @@ while ( ($drop_timer <= $DROP_TIME) && ($wait_in_queue > 0) && ($MCdrop_override if ($sthArows > 0) { @aryA = $sthA->fetchrow_array; - $calls_today = $aryA[0]; + $calls_today = $aryA[0]; + $calls_today_filtered = $aryA[1]; $calls_today++; + # if ($VU_max_inbound_filter_enabled > 0) + # { + # $VU_max_inbound_filter_ingroupsTEST = ",$VU_max_inbound_filter_ingroups,"; + # if ($VU_max_inbound_filter_ingroups !~ /,$channel_group,/) + # { + # $calls_today_filtered++; + # $calls_today_filteredSQL = ",calls_today_filtered='$calls_today_filtered'"; + # } + # } + # else + # { + # $calls_today_filtered++; + # $calls_today_filteredSQL = ",calls_today_filtered='$calls_today_filtered'"; + # } } $sthA->finish(); if ($sthArows > 0) { - $stmtA = "UPDATE vicidial_live_inbound_agents set calls_today='$calls_today',last_call_time=NOW() WHERE user='$VDADuser' and group_id='$channel_group';"; + $stmtA = "UPDATE vicidial_live_inbound_agents set calls_today='$calls_today',last_call_time=NOW() $calls_today_filteredSQL WHERE user='$VDADuser' and group_id='$channel_group';"; $affected_rows = $dbhA->do($stmtA); $dbhP=$dbhA; $mysql_count='02070'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; - $stmtA = "UPDATE vicidial_inbound_group_agents set calls_today='$calls_today' WHERE user='$VDADuser' and group_id='$channel_group';"; + $stmtA = "UPDATE vicidial_inbound_group_agents set calls_today='$calls_today' $calls_today_filteredSQL WHERE user='$VDADuser' and group_id='$channel_group';"; $affected_rows = $dbhA->do($stmtA); $dbhP=$dbhA; $mysql_count='02071'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; - if ($AGILOG) {$agi_string = "-- VDLIA agent calls: |$calls_today|$VDADuser|$channel_group|"; &agi_output;} + if ($AGILOG) {$agi_string = "-- VDLIA agent calls: |$calls_today|$calls_today_filtered|$VDADuser|$channel_group|"; &agi_output;} } ##### BEGIN check for user max inbound calls ##### - $max_inbound_calls=0; - $stmtA = "SELECT max_inbound_calls FROM vicidial_users where user='$VDADuser';"; - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArowsMIC=$sthA->rows; - $dbhP=$dbhA; $mysql_count='02199'; $MEL_aff_rows=$sthArows; &mysql_error_logging; - if ($sthArowsMIC > 0) - { - @aryA = $sthA->fetchrow_array; - $VU_max_inbound_calls = $aryA[0]; - } $stmtA = "SELECT max_inbound_calls,max_inbound_calls_outcome FROM vicidial_campaigns where campaign_id='$log_campaign';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -3802,9 +3824,11 @@ while ( ($drop_timer <= $DROP_TIME) && ($wait_in_queue > 0) && ($MCdrop_override { $max_inbound_calls = $CP_max_inbound_calls; if ($VU_max_inbound_calls > 0) - {$max_inbound_calls = $VU_max_inbound_calls;} + { + $max_inbound_calls = $VU_max_inbound_calls; + } $max_inbound_count=0; - $stmtA = "SELECT sum(calls_today) FROM vicidial_inbound_group_agents where user='$VDADuser' and group_type='C';"; + $stmtA = "SELECT sum(calls_today),sum(calls_today_filtered) FROM vicidial_inbound_group_agents where user='$VDADuser' and group_type='C';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArowsVIGA=$sthA->rows; @@ -3813,6 +3837,10 @@ while ( ($drop_timer <= $DROP_TIME) && ($wait_in_queue > 0) && ($MCdrop_override { @aryA = $sthA->fetchrow_array; $max_inbound_count = $aryA[0]; + if ($VU_max_inbound_filter_enabled > 0) + { + $max_inbound_count = $aryA[1]; + } } if ($max_inbound_count >= $max_inbound_calls) { diff --git a/bin/ADMIN_keepalive_ALL.pl b/bin/ADMIN_keepalive_ALL.pl index 1b259830..6a2cf174 100644 --- a/bin/ADMIN_keepalive_ALL.pl +++ b/bin/ADMIN_keepalive_ALL.pl @@ -137,9 +137,10 @@ # 190220-2258 - Added flushing of vicidial_sessions_recent table # 190530-1411 - Added SIP logger code # 190713-0900 - Added vicidial_lead_call_quota_counts log archiving +# 191017-2039 - Added reset of calls_today_filtered fields # -$build = '190713-0900'; +$build = '191017-2039'; $DB=0; # Debug flag $teodDB=0; # flag to log Timeclock End of Day processes to log file @@ -1153,7 +1154,7 @@ if ($timeclock_end_of_day_NOW > 0) if ($DB) {print "|",$aryA[0],"|",$aryA[1],"|",$aryA[2],"|",$aryA[3],"|","\n";} $sthA->finish(); - $stmtA = "update vicidial_inbound_group_agents SET calls_today=0;"; + $stmtA = "update vicidial_inbound_group_agents SET calls_today=0,calls_today_filtered=0;"; if($DBX){print STDERR "\n|$stmtA|\n";} $affected_rows = $dbhA->do($stmtA); if($DB){print STDERR "\n|$affected_rows vicidial_inbound_group_agents call counts reset|\n";} @@ -1258,7 +1259,7 @@ if ($timeclock_end_of_day_NOW > 0) if ($DB) {print "|",$aryA[0],"|",$aryA[1],"|",$aryA[2],"|",$aryA[3],"|","\n";} $sthA->finish(); - $stmtA = "update vicidial_live_inbound_agents SET calls_today=0;"; + $stmtA = "update vicidial_live_inbound_agents SET calls_today=0,calls_today_filtered=0;"; if($DBX){print STDERR "\n|$stmtA|\n";} $affected_rows = $dbhA->do($stmtA); if($DB){print STDERR "\n|$affected_rows vicidial_live_inbound_agents call counts reset|\n";} diff --git a/bin/AST_VDremote_agents.pl b/bin/AST_VDremote_agents.pl index afb45ae5..f17f7bcd 100644 --- a/bin/AST_VDremote_agents.pl +++ b/bin/AST_VDremote_agents.pl @@ -53,6 +53,7 @@ # 161102-1032 - Fixed QM partition problem # 170527-2348 - Fix for rare inbound logging issue #1017 # 190716-1628 - Added code for Call Quotas +# 191017-1909 - Added code for filtered maximum inbound calls # ### begin parsing run-time options ### @@ -367,7 +368,7 @@ while($one_day_interval > 0) if ($QHcall_type[$w] =~ /IN/) {$licf_SQL = ",last_inbound_call_time='$SQLdate'";} - $stmtA = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$SQLdate',comments='REMOTE',calls_today=(calls_today + 1),last_state_change='$SQLdate' $licf_SQL where live_agent_id='$QHlive_agent_id[$w]';"; + $stmtA = "UPDATE vicidial_live_agents set status='INCALL',last_call_time='$SQLdate',last_inbound_call_time_filtered='$SQLdate',last_inbound_call_finish_filtered='$SQLdate',comments='REMOTE',calls_today=(calls_today + 1),last_state_change='$SQLdate' $licf_SQL where live_agent_id='$QHlive_agent_id[$w]';"; $Aaffected_rows = $dbhA->do($stmtA); $stmtB = "UPDATE vicidial_list set status='XFER',user='$QHuser[$w]' where lead_id='$QHlead_id[$w]';"; @@ -375,27 +376,54 @@ while($one_day_interval > 0) if ($QHcall_type[$w] =~ /IN/) { - $stmtC = "UPDATE vicidial_closer_log set status='XFER',user='$QHuser[$w]',comments='REMOTE' where lead_id='$QHlead_id[$w]' and uniqueid='$QHuniqueid[$w]' and campaign_id='$QHcampaign_id[$w]' order by closecallid desc limit 1;"; - $Caffected_rows = $dbhA->do($stmtC); - - $stmtD = "INSERT IGNORE INTO vicidial_live_inbound_agents SET calls_today='1',last_call_time='$SQLdate',user='$QHuser[$w]', group_id='$QHcampaign_id[$w]' ON DUPLICATE KEY UPDATE calls_today=(calls_today + 1),last_call_time='$SQLdate';"; - $Daffected_rows = $dbhA->do($stmtD); - - # $stmtE = "INSERT IGNORE INTO vicidial_inbound_group_agents set calls_today=1,user='$QHuser[$w]',group_id='$QHcampaign_id[$w]' ON DUPLICATE KEY UPDATE calls_today=(calls_today + 1);"; - $stmtE = "INSERT IGNORE INTO vicidial_inbound_group_agents set calls_today=1,user='$QHuser[$w]',group_id='$QHcampaign_id[$w]';"; - $Eaffected_rows = $dbhA->do($stmtE); - - ##### BEGIN check for user max inbound calls ##### + ### Gather user details for max inbound calls $max_inbound_calls=0; - $stmtJ = "SELECT max_inbound_calls FROM vicidial_users where user='$QHuser[$w]';"; + $stmtJ = "SELECT max_inbound_calls,max_inbound_filter_enabled,max_inbound_filter_ingroups FROM vicidial_users where user='$QHuser[$w]';"; $sthA = $dbhA->prepare($stmtJ) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtJ ", $dbhA->errstr; $sthArowsMIC=$sthA->rows; if ($sthArowsMIC > 0) { @aryA = $sthA->fetchrow_array; - $VU_max_inbound_calls = $aryA[0]; + $VU_max_inbound_calls = $aryA[0]; + $VU_max_inbound_filter_enabled = $aryA[1]; + $VU_max_inbound_filter_ingroups = $aryA[2]; } + $channel_group = $QHcampaign_id[$w]; + $calls_today_filteredSQL = ",calls_today_filtered=(calls_today_filtered + 1),last_call_time_filtered='$SQLdate'"; + $calls_today_filteredSQLnew = ",calls_today_filtered='1',last_call_time_filtered='$SQLdate'"; + $calls_today_filteredSQLnewIGA = ",calls_today_filtered='1' ON DUPLICATE KEY UPDATE calls_today_filtered=(calls_today_filtered + 1)"; + if ($VU_max_inbound_filter_enabled > 0) + { + $calls_today_filteredSQL = ''; + $calls_today_filteredSQLnew = ''; + $calls_today_filteredSQLnewIGA = ''; + $VU_max_inbound_filter_ingroupsTEST = ",$VU_max_inbound_filter_ingroups,"; + if ($VU_max_inbound_filter_ingroupsTEST !~ /,$channel_group,/) + { + $calls_today_filteredSQL = ",calls_today_filtered=(calls_today_filtered + 1),last_call_time_filtered='$SQLdate'"; + $calls_today_filteredSQLnew = ",calls_today_filtered='1',last_call_time_filtered='$SQLdate'"; + $calls_today_filteredSQLnewIGA = ",calls_today_filtered='1' ON DUPLICATE KEY UPDATE calls_today_filtered=(calls_today_filtered + 1)"; + } + } + + $stmtC = "UPDATE vicidial_closer_log set status='XFER',user='$QHuser[$w]',comments='REMOTE' where lead_id='$QHlead_id[$w]' and uniqueid='$QHuniqueid[$w]' and campaign_id='$QHcampaign_id[$w]' order by closecallid desc limit 1;"; + $Caffected_rows = $dbhA->do($stmtC); + + $stmtD = "INSERT IGNORE INTO vicidial_live_inbound_agents SET calls_today='1',last_call_time='$SQLdate',user='$QHuser[$w]', group_id='$QHcampaign_id[$w]' $calls_today_filteredSQLnew ON DUPLICATE KEY UPDATE calls_today=(calls_today + 1) $calls_today_filteredSQL;"; + $Daffected_rows = $dbhA->do($stmtD); + + # $stmtE = "INSERT IGNORE INTO vicidial_inbound_group_agents set calls_today=1,user='$QHuser[$w]',group_id='$QHcampaign_id[$w]' ON DUPLICATE KEY UPDATE calls_today=(calls_today + 1);"; + $stmtE = "INSERT IGNORE INTO vicidial_inbound_group_agents set calls_today=1,user='$QHuser[$w]',group_id='$QHcampaign_id[$w]' $calls_today_filteredSQLnewIGA;"; + $Eaffected_rows = $dbhA->do($stmtE); + + if (length($calls_today_filteredSQL) > 10) + { + $stmtF = "UPDATE vicidial_live_agents set last_inbound_call_time_filtered='$SQLdate' where live_agent_id='$QHlive_agent_id[$w]';"; + $Faffected_rows = $dbhA->do($stmtF); + } + + ##### BEGIN check for user max inbound calls ##### $stmtJ = "SELECT max_inbound_calls FROM vicidial_campaigns where campaign_id='$QHcampaign_id[$w]';"; $sthA = $dbhA->prepare($stmtJ) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtJ ", $dbhA->errstr; @@ -412,7 +440,7 @@ while($one_day_interval > 0) if ($VU_max_inbound_calls > 0) {$max_inbound_calls = $VU_max_inbound_calls;} $max_inbound_count=0; - $stmtJ = "SELECT sum(calls_today) FROM vicidial_inbound_group_agents where user='$QHuser[$w]' and group_type='C';"; + $stmtJ = "SELECT sum(calls_today),sum(calls_today_filtered) FROM vicidial_inbound_group_agents where user='$QHuser[$w]' and group_type='C';"; $sthA = $dbhA->prepare($stmtJ) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtJ ", $dbhA->errstr; $sthArowsVIGA=$sthA->rows; @@ -420,6 +448,10 @@ while($one_day_interval > 0) { @aryA = $sthA->fetchrow_array; $max_inbound_count = $aryA[0]; + if ($VU_max_inbound_filter_enabled > 0) + { + $max_inbound_count = $aryA[1]; + } } if ($max_inbound_count >= $max_inbound_calls) { @@ -868,16 +900,17 @@ while($one_day_interval > 0) $TEMPexistsVLIA=0; # grab the group weight and calls today of the agent in each in-group $DBuser_level[$h]='1'; - $stmtA = "SELECT group_weight,calls_today,group_grade FROM vicidial_inbound_group_agents where user='$DBuser_start[$h]' and group_id='$TEMPingroups[$s]';"; + $stmtA = "SELECT group_weight,calls_today,group_grade,calls_today_filtered FROM vicidial_inbound_group_agents where user='$DBuser_start[$h]' and group_id='$TEMPingroups[$s]';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArowsVIGA=$sthA->rows; if ($sthArowsVIGA > 0) { @aryA = $sthA->fetchrow_array; - $TEMPagentWEIGHT = $aryA[0]; - $TEMPagentCALLS = $aryA[1]; - $TEMPagentGRADE = $aryA[2]; + $TEMPagentWEIGHT = $aryA[0]; + $TEMPagentCALLS = $aryA[1]; + $TEMPagentGRADE = $aryA[2]; + $TEMPagentCALLSftl = $aryA[3]; } $sthA->finish(); @@ -898,7 +931,7 @@ while($one_day_interval > 0) if ($TEMPexistsVLIA < 1) { - $stmtA = "INSERT IGNORE INTO vicidial_live_inbound_agents SET user='$DBremote_user[$h]', group_id='$TEMPingroups[$s]', group_weight='$TEMPagentWEIGHT', calls_today='$TEMPagentCALLS', last_call_time='$SQLdate', last_call_finish='$SQLdate', group_grade='$TEMPagentGRADE' ON DUPLICATE KEY UPDATE group_weight='$TEMPagentWEIGHT',group_grade='$TEMPagentGRADE';"; + $stmtA = "INSERT IGNORE INTO vicidial_live_inbound_agents SET user='$DBremote_user[$h]', group_id='$TEMPingroups[$s]', group_weight='$TEMPagentWEIGHT', calls_today='$TEMPagentCALLS', calls_today_filtered='$TEMPagentCALLSftl', last_call_time='$SQLdate', last_call_time_filtered='$SQLdate', last_call_finish='$SQLdate', group_grade='$TEMPagentGRADE' ON DUPLICATE KEY UPDATE group_weight='$TEMPagentWEIGHT',group_grade='$TEMPagentGRADE';"; $affected_rows = $dbhA->do($stmtA); if ( ($DBX) && ($affected_rows > 0) ) {print STDERR "$DBremote_user[$h] VLIA UPDATE: $affected_rows|$TEMPingroups[$s]|$TEMPagentWEIGHT\n";} diff --git a/bin/VD_email_inbound.pl b/bin/VD_email_inbound.pl index 5075b513..4534e8c9 100644 --- a/bin/VD_email_inbound.pl +++ b/bin/VD_email_inbound.pl @@ -25,6 +25,7 @@ $PATHconf = '/etc/astguiclient.conf'; # 121214-2303 - First Build # 180610-1812 - Added code to not allow XFER emails to go to user who transferred # 190216-0810 - Fix for user-group, email-group and campaign allowed/permissions matching issues +# 191017-2043 - Added filtered routing options # if ($ARGV[0]=~/--help/) @@ -259,6 +260,8 @@ sub AssignAgents() if ($CAMP_callorder =~ /oldest_call_finish/i) {$agent_call_order = 'order by vicidial_live_agents.last_call_finish';} if ($CAMP_callorder =~ /oldest_inbound_call_start/i) {$agent_call_order = 'order by vicidial_live_agents.last_inbound_call_time';} # if ($CAMP_callorder =~ /oldest_inbound_call_finish/i) {$agent_call_order = 'order by vicidial_live_agents.last_inbound_call_finish';} # + if ($CAMP_callorder =~ /oldest_inbound_filtered_call_start/i) {$agent_call_order = 'order by vicidial_live_agents.last_inbound_call_time_filtered';} + if ($CAMP_callorder =~ /oldest_inbound_filtered_call_finish/i) {$agent_call_order = 'order by vicidial_live_agents.last_inbound_call_finish_filtered';} if ($CAMP_callorder =~ /random/i) {$agent_call_order = 'order by random_id';} if ($CAMP_callorder =~ /campaign_rank/i) {$agent_call_order = 'order by campaign_weight desc,last_call_finish';} if ($CAMP_callorder =~ /fewest_calls_campaign/i) {$agent_call_order = 'order by vicidial_live_agents.calls_today,vicidial_live_agents.last_call_finish';} diff --git a/extras/MySQL_AST_CREATE_tables.sql b/extras/MySQL_AST_CREATE_tables.sql index 1d3f0a14..2a30f98c 100644 --- a/extras/MySQL_AST_CREATE_tables.sql +++ b/extras/MySQL_AST_CREATE_tables.sql @@ -436,6 +436,8 @@ external_pause_code VARCHAR(6) default '', pause_code VARCHAR(6) default '', preview_lead_id INT(9) UNSIGNED default '0', external_lead_id INT(9) UNSIGNED default '0', +last_inbound_call_time_filtered DATETIME, +last_inbound_call_finish_filtered DATETIME, index (random_id), index (last_call_time), index (last_update_time), @@ -673,7 +675,11 @@ max_hopper_calls_hour SMALLINT(5) UNSIGNED default '0', mute_recordings ENUM('DISABLED','Y','N') default 'DISABLED', hide_call_log_info ENUM('DISABLED','Y','N','SHOW_1','SHOW_2','SHOW_3','SHOW_4','SHOW_5','SHOW_6','SHOW_7','SHOW_8','SHOW_9','SHOW_10') default 'DISABLED', next_dial_my_callbacks ENUM('NOT_ACTIVE','DISABLED','ENABLED') default 'NOT_ACTIVE', -user_admin_redirect_url TEXT +user_admin_redirect_url TEXT, +max_inbound_filter_enabled ENUM('0','1') default '0', +max_inbound_filter_statuses TEXT, +max_inbound_filter_ingroups TEXT, +max_inbound_filter_min_sec SMALLINT(5) default '-1' ) ENGINE=MyISAM; CREATE UNIQUE INDEX user ON vicidial_users (user); @@ -1916,6 +1922,7 @@ calls_today SMALLINT(5) UNSIGNED default '0', group_web_vars VARCHAR(255) default '', group_grade TINYINT(2) UNSIGNED default '1', group_type VARCHAR(1) default 'C', +calls_today_filtered SMALLINT(5) UNSIGNED default '0', index (group_id), index (user), unique index viga_user_group_id (user, group_id) @@ -1929,6 +1936,9 @@ calls_today SMALLINT(5) UNSIGNED default '0', last_call_time DATETIME, last_call_finish DATETIME, group_grade TINYINT(2) UNSIGNED default '1', +calls_today_filtered SMALLINT(5) UNSIGNED default '0', +last_call_time_filtered DATETIME, +last_call_finish_filtered DATETIME, index (group_id), index (group_weight), unique index vlia_user_group_id (user, group_id) @@ -4523,4 +4533,4 @@ INSERT INTO vicidial_settings_containers(container_id,container_notes,container_ UPDATE system_settings set vdc_agent_api_active='1'; -UPDATE system_settings SET db_schema_version='1576',db_schema_update_date=NOW(),reload_timestamp=NOW(); +UPDATE system_settings SET db_schema_version='1577',db_schema_update_date=NOW(),reload_timestamp=NOW(); diff --git a/extras/upgrade_2.14.sql b/extras/upgrade_2.14.sql index 3697cd89..2868c269 100644 --- a/extras/upgrade_2.14.sql +++ b/extras/upgrade_2.14.sql @@ -1052,5 +1052,20 @@ ALTER TABLE vicidial_log_noanswer MODIFY term_reason ENUM('CALLER','AGENT','QUE ALTER TABLE vicidial_log_archive MODIFY term_reason ENUM('CALLER','AGENT','QUEUETIMEOUT','ABANDON','AFTERHOURS','NONE','SYSTEM') default 'NONE'; ALTER TABLE vicidial_log_noanswer_archive MODIFY term_reason ENUM('CALLER','AGENT','QUEUETIMEOUT','ABANDON','AFTERHOURS','NONE','SYSTEM') default 'NONE'; - UPDATE system_settings SET db_schema_version='1576',db_schema_update_date=NOW() where db_schema_version < 1576; + +ALTER TABLE vicidial_users ADD max_inbound_filter_enabled ENUM('0','1') default '0'; +ALTER TABLE vicidial_users ADD max_inbound_filter_statuses TEXT; +ALTER TABLE vicidial_users ADD max_inbound_filter_ingroups TEXT; +ALTER TABLE vicidial_users ADD max_inbound_filter_min_sec SMALLINT(5) default '-1'; + +ALTER TABLE vicidial_live_inbound_agents ADD calls_today_filtered SMALLINT(5) UNSIGNED default '0'; +ALTER TABLE vicidial_live_inbound_agents ADD last_call_time_filtered DATETIME; +ALTER TABLE vicidial_live_inbound_agents ADD last_call_finish_filtered DATETIME; + +ALTER TABLE vicidial_inbound_group_agents ADD calls_today_filtered SMALLINT(5) UNSIGNED default '0'; + +ALTER TABLE vicidial_live_agents ADD last_inbound_call_time_filtered DATETIME; +ALTER TABLE vicidial_live_agents ADD last_inbound_call_finish_filtered DATETIME; + +UPDATE system_settings SET db_schema_version='1577',db_schema_update_date=NOW() where db_schema_version < 1577; diff --git a/www/agc/vdc_db_query.php b/www/agc/vdc_db_query.php index 04eb6115..21917fb2 100644 --- a/www/agc/vdc_db_query.php +++ b/www/agc/vdc_db_query.php @@ -480,13 +480,14 @@ # 190730-0926 - Added campaign SIP Actions processing # 190925-1347 - Added logtable SIP Action # 191013-0934 - Fixes for PHP7 issues +# 191017-2205 - Added code for filtered inbound max calls # $version = '2.14-374'; $build = '191013-0934'; $php_script = 'vdc_db_query.php'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=809; +$mysql_log_count=817; $one_mysql_log=0; $DB=0; $VD_login=0; @@ -786,6 +787,8 @@ if (isset($_GET["start_date"])) {$start_date=$_GET["start_date"];} elseif (isset($_POST["start_date"])){$start_date=$_POST["start_date"];} if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];} elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];} +if (isset($_GET["customer_sec"])) {$customer_sec=$_GET["customer_sec"];} + elseif (isset($_POST["customer_sec"])) {$customer_sec=$_POST["customer_sec"];} header ("Content-type: text/html; charset=utf-8"); @@ -1123,7 +1126,7 @@ $callback_timezone = preg_replace('/[^-, _0-9a-zA-Z]/','',$callback_timezone); $manual_dial_validation = preg_replace('/[^-_0-9a-zA-Z]/','',$manual_dial_validation); $start_date = preg_replace('/[^-_0-9]/','',$start_date); $end_date = preg_replace('/[^-_0-9]/','',$end_date); - +$customer_sec = preg_replace('/[^-_0-9]/','',$customer_sec); # default optional vars if not set if (!isset($format)) {$format="text";} @@ -1488,7 +1491,7 @@ if ($ACTION == 'regCLOSER') else { $orig_closer_choice = $closer_choice; - $stmt = "SELECT max_inbound_calls FROM vicidial_users where user='$user';"; + $stmt = "SELECT max_inbound_calls,max_inbound_filter_enabled,max_inbound_filter_ingroups FROM vicidial_users where user='$user';"; $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00587',$user,$server_ip,$session_name,$one_mysql_log);} if ($format=='debug') {echo "\n";} @@ -1496,7 +1499,9 @@ if ($ACTION == 'regCLOSER') if ($vumic_ct > 0) { $row=mysqli_fetch_row($rslt); - $VU_max_inbound_calls = $row[0]; + $VU_max_inbound_calls = $row[0]; + $VU_max_inbound_filter_enabled = $row[1]; + $VU_max_inbound_filter_ingroups = $row[2]; } $stmt = "SELECT max_inbound_calls,max_inbound_calls_outcome FROM vicidial_campaigns where campaign_id='$campaign';"; $rslt=mysql_to_mysqli($stmt, $link); @@ -1516,7 +1521,7 @@ if ($ACTION == 'regCLOSER') if ($VU_max_inbound_calls > 0) {$max_inbound_calls = $VU_max_inbound_calls;} - $stmt = "SELECT sum(calls_today) FROM vicidial_inbound_group_agents where user='$user' and group_type='C';"; + $stmt = "SELECT sum(calls_today),sum(calls_today_filtered) FROM vicidial_inbound_group_agents where user='$user' and group_type='C';"; $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00588',$user,$server_ip,$session_name,$one_mysql_log);} if ($format=='debug') {echo "\n";} @@ -1525,6 +1530,8 @@ if ($ACTION == 'regCLOSER') { $row=mysqli_fetch_row($rslt); $max_inbound_count = $row[0]; + if ($VU_max_inbound_filter_enabled > 0) + {$max_inbound_count = $row[1];} if ($max_inbound_count >= $max_inbound_calls) {$closer_choice = "MAXLOCK-";} @@ -1674,7 +1681,7 @@ if ($ACTION == 'regCLOSER') { if (strlen($in_groups[$k])>1) { - $stmt="SELECT group_weight,calls_today,group_grade FROM vicidial_inbound_group_agents where user='$user' and group_id='$in_groups[$k]';"; + $stmt="SELECT group_weight,calls_today,group_grade,calls_today_filtered FROM vicidial_inbound_group_agents where user='$user' and group_id='$in_groups[$k]';"; $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00013',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} @@ -1682,9 +1689,10 @@ if ($ACTION == 'regCLOSER') if ($viga_ct > 0) { $row=mysqli_fetch_row($rslt); - $group_weight = $row[0]; - $calls_today = $row[1]; - $group_grade = $row[2]; + $group_weight = $row[0]; + $calls_today = $row[1]; + $group_grade = $row[2]; + $calls_today_filtered = $row[3]; } else { @@ -1692,7 +1700,7 @@ if ($ACTION == 'regCLOSER') $calls_today = 0; $group_grade = 1; } - $stmt="INSERT INTO vicidial_live_inbound_agents set user='$user',group_id='$in_groups[$k]',group_weight='$group_weight',calls_today='$calls_today',last_call_time='$NOW_TIME',last_call_finish='$NOW_TIME',group_grade='$group_grade';"; + $stmt="INSERT INTO vicidial_live_inbound_agents set user='$user',group_id='$in_groups[$k]',group_weight='$group_weight',calls_today='$calls_today',last_call_time='$NOW_TIME',last_call_finish='$NOW_TIME',last_call_time_filtered='$NOW_TIME',last_call_finish_filtered='$NOW_TIME',group_grade='$group_grade',calls_today_filtered='$calls_today_filtered';"; if ($format=='debug') {echo "\n";} $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00014',$user,$server_ip,$session_name,$one_mysql_log);} @@ -11805,330 +11813,463 @@ if ($ACTION == 'updateDISPO') if ($SSagent_debug_logging > 0) {vicidial_ajax_log($NOW_TIME,$startMS,$link,$ACTION,$php_script,$user,$stage,$lead_id,$session_name,$stmt);} exit; } - else + + $user_group=''; + $stmt="SELECT user_group,max_inbound_filter_enabled,max_inbound_filter_ingroups,max_inbound_filter_statuses,max_inbound_filter_min_sec,max_inbound_calls FROM vicidial_users where user='$user' LIMIT 1;"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00152',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $ug_record_ct = mysqli_num_rows($rslt); + if ($ug_record_ct > 0) { - $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);} + $row=mysqli_fetch_row($rslt); + $user_group = trim("$row[0]"); + $max_inbound_filter_enabled = $row[1]; + $max_inbound_filter_ingroups = $row[2]; + $max_inbound_filter_statuses = $row[3]; + $max_inbound_filter_min_sec = $row[4]; + $VU_max_inbound_calls = $row[5]; + } + + $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); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00284',$user,$server_ip,$session_name,$one_mysql_log);} + $VC_dcu_ct = mysqli_num_rows($rslt); + if ($VC_dcu_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $dispo_call_url = $row[0]; + $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 + $stmt = "UPDATE vicidial_live_agents set lead_id=0,external_hangup=0,external_status='',external_update_fields='0',external_update_fields_data='',external_timer_action_seconds='-1',external_dtmf='',external_transferconf='',external_park='',external_recording='',last_state_change='$NOW_TIME',preview_lead_id='0' where user='$user' and server_ip='$server_ip';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00141',$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,"9141$retry_count",$user,$server_ip,$session_name,$one_mysql_log); + $one_mysql_log=0; + $retry_count++; + } + + if ($auto_dial_level < 1) + { + $stmt = "UPDATE vicidial_live_agents set status='PAUSED',callerid='' where user='$user';"; if ($DB) {echo "$stmt\n";} $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00284',$user,$server_ip,$session_name,$one_mysql_log);} - $VC_dcu_ct = mysqli_num_rows($rslt); - if ($VC_dcu_ct > 0) - { - $row=mysqli_fetch_row($rslt); - $dispo_call_url = $row[0]; - $queuemetrics_callstatus_override = $row[1]; - $comments_dispo_screen = $row[2]; - $comments_callback_screen = $row[3]; - $DUcampaign_id = $row[4]; - $DUentry_type = 'campaign'; - } + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00285',$user,$server_ip,$session_name,$one_mysql_log);} + } + $commentsSQL=''; + if ( (strlen($dispo_comments)>0) and ( ($comments_dispo_screen == 'ENABLED') or ($comments_dispo_screen == 'REPLACE_CALL_NOTES') ) ) + {$commentsSQL = ",comments='" . mysqli_real_escape_string($link, $dispo_comments) . "'";} + if ( (strlen($cbcomment_comments)>0) and ( ($comments_callback_screen == 'ENABLED') or ($comments_callback_screen == 'REPLACE_CB_NOTES') ) ) + {$commentsSQL = ",comments='" . mysqli_real_escape_string($link, $cbcomment_comments) . "'";} + $stmt="UPDATE vicidial_list set status='$dispo_choice', user='$user' $commentsSQL where lead_id='$lead_id';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142',$user,$server_ip,$session_name,$one_mysql_log);} - ### reset the API fields in vicidial_live_agents record - $stmt = "UPDATE vicidial_live_agents set lead_id=0,external_hangup=0,external_status='',external_update_fields='0',external_update_fields_data='',external_timer_action_seconds='-1',external_dtmf='',external_transferconf='',external_park='',external_recording='',last_state_change='$NOW_TIME',preview_lead_id='0' where user='$user' and server_ip='$server_ip';"; - if ($DB) {echo "$stmt\n";} - $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {$errno = mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00141',$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,"9141$retry_count",$user,$server_ip,$session_name,$one_mysql_log); - $one_mysql_log=0; - $retry_count++; - } + //Added by Poundteam Incorporated for Audit Comments Package + require_once('audit_comments.php'); + audit_comments($lead_id,$list_id,$format,$user,$mel,$NOW_TIME,$link,$server_ip,$session_name,$one_mysql_log,$campaign); - if ($auto_dial_level < 1) - { - $stmt = "UPDATE vicidial_live_agents set status='PAUSED',callerid='' where user='$user';"; - if ($DB) {echo "$stmt\n";} - $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00285',$user,$server_ip,$session_name,$one_mysql_log);} - } - $commentsSQL=''; - if ( (strlen($dispo_comments)>0) and ( ($comments_dispo_screen == 'ENABLED') or ($comments_dispo_screen == 'REPLACE_CALL_NOTES') ) ) - {$commentsSQL = ",comments='" . mysqli_real_escape_string($link, $dispo_comments) . "'";} - if ( (strlen($cbcomment_comments)>0) and ( ($comments_callback_screen == 'ENABLED') or ($comments_callback_screen == 'REPLACE_CB_NOTES') ) ) - {$commentsSQL = ",comments='" . mysqli_real_escape_string($link, $cbcomment_comments) . "'";} - $stmt="UPDATE vicidial_list set status='$dispo_choice', user='$user' $commentsSQL where lead_id='$lead_id';"; + // JOEJ - Email feature - may not be necessary if vicidial_email_list doesn't need a status column. + if ($email_enabled>0) + { + $stmt="UPDATE vicidial_email_list set status='$dispo_choice', user='$user' where lead_id='$lead_id' and uniqueid='$uniqueid';"; if ($format=='debug') {echo "\n";} $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00142',$user,$server_ip,$session_name,$one_mysql_log);} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00552',$user,$server_ip,$session_name,$one_mysql_log);} + } - //Added by Poundteam Incorporated for Audit Comments Package - require_once('audit_comments.php'); - audit_comments($lead_id,$list_id,$format,$user,$mel,$NOW_TIME,$link,$server_ip,$session_name,$one_mysql_log,$campaign); +# $fp = fopen ("./vicidial_debug.txt", "a"); +# fwrite ($fp, "$NOW_TIME|DISPO_CALL |$MDnextCID|$stage|$campaign|$lead_id|$dispo_choice|$user|$uniqueid|$auto_dial_level|$agent_log_id|\n"); +# fclose($fp); + $log_dispo_choice = $dispo_choice; + if (strlen($CallBackLeadStatus) > 0) {$log_dispo_choice = $CallBackLeadStatus;} - // JOEJ - Email feature - may not be necessary if vicidial_email_list doesn't need a status column. - if ($email_enabled>0) + $term_reasonSQL = ''; + if ($parked_hangup=='1') + {$term_reasonSQL = ",term_reason='CALLER'";} + + $stmt = "SELECT count(*) from vicidial_inbound_groups where group_id='$stage';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00143',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysqli_fetch_row($rslt); + if ($row[0] > 0) + { + $call_type='IN'; + + $stmt = "SELECT dispo_call_url from vicidial_inbound_groups where group_id='$stage';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_to_mysqli($stmt, $link); + 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); + if ($row[0] != 'CAMP') { - $stmt="UPDATE vicidial_email_list set status='$dispo_choice', user='$user' where lead_id='$lead_id' and uniqueid='$uniqueid';"; - if ($format=='debug') {echo "\n";} - $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00552',$user,$server_ip,$session_name,$one_mysql_log);} + $dispo_call_url = $row[0]; + $DUcampaign_id = $stage; + $DUentry_type = 'ingroup'; } + $stmt = "UPDATE vicidial_closer_log set status='$log_dispo_choice' $term_reasonSQL where lead_id='$lead_id' and user='$user' order by closecallid desc limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00144',$user,$server_ip,$session_name,$one_mysql_log);} + $VCLaffected_rows = mysqli_affected_rows($link); + # $fp = fopen ("./vicidial_debug.txt", "a"); - # fwrite ($fp, "$NOW_TIME|DISPO_CALL |$MDnextCID|$stage|$campaign|$lead_id|$dispo_choice|$user|$uniqueid|$auto_dial_level|$agent_log_id|\n"); + # fwrite ($fp, "$NOW_TIME|DISPO_CALL2|$user|$customer_sec <> $max_inbound_filter_min_sec|$stage <> $max_inbound_filter_ingroups|$dispo_choice <> $max_inbound_filter_statuses|\n"); # fclose($fp); - $log_dispo_choice = $dispo_choice; - if (strlen($CallBackLeadStatus) > 0) {$log_dispo_choice = $CallBackLeadStatus;} - $term_reasonSQL = ''; - if ($parked_hangup=='1') - {$term_reasonSQL = ",term_reason='CALLER'";} - - $stmt = "SELECT count(*) from vicidial_inbound_groups where group_id='$stage';"; - if ($format=='debug') {echo "\n";} - $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00143',$user,$server_ip,$session_name,$one_mysql_log);} - $row=mysqli_fetch_row($rslt); - if ($row[0] > 0) + $calls_today_filteredSQL = ",calls_today_filtered=(calls_today_filtered + 1),last_call_finish_filtered=NOW(),last_call_time_filtered=last_call_time"; + if ($max_inbound_filter_enabled > 0) { - $call_type='IN'; - $stmt = "UPDATE vicidial_closer_log set status='$log_dispo_choice' $term_reasonSQL where lead_id='$lead_id' and user='$user' order by closecallid desc limit 1;"; - if ($DB) {echo "$stmt\n";} - $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00144',$user,$server_ip,$session_name,$one_mysql_log);} - $VCLaffected_rows = mysqli_affected_rows($link); - - # $fp = fopen ("./vicidial_debug.txt", "a"); - # fwrite ($fp, "$NOW_TIME|DISPO_CALL2|$VCLaffected_rows|$stmt|\n"); - # fclose($fp); - - $stmt = "UPDATE vicidial_live_inbound_agents set last_call_finish=NOW() where group_id='$stage' and user='$user' limit 1;"; - if ($DB) {echo "$stmt\n";} - $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00553',$user,$server_ip,$session_name,$one_mysql_log);} - - $stmt = "SELECT dispo_call_url from vicidial_inbound_groups where group_id='$stage';"; - if ($format=='debug') {echo "\n";} - $rslt=mysql_to_mysqli($stmt, $link); - 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); - if ($row[0] != 'CAMP') + $calls_today_filteredSQL = ''; + $max_inbound_filter_ingroupsTEST = ",$max_inbound_filter_ingroups,"; + $max_inbound_filter_statusesTEST = ",$max_inbound_filter_statuses,"; + if ( (!preg_match("/,$stage,/",$max_inbound_filter_ingroupsTEST)) and (!preg_match("/,$dispo_choice,/",$max_inbound_filter_statusesTEST)) and ($customer_sec >= $max_inbound_filter_min_sec) ) { - $dispo_call_url = $row[0]; - $DUcampaign_id = $stage; - $DUentry_type = 'ingroup'; + $calls_today_filteredSQL = ",calls_today_filtered=(calls_today_filtered + 1),last_call_finish_filtered=NOW(),last_call_time_filtered=last_call_time"; } } - else + + $stmt = "UPDATE vicidial_live_inbound_agents set last_call_finish=NOW() $calls_today_filteredSQL where group_id='$stage' and user='$user' limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00553',$user,$server_ip,$session_name,$one_mysql_log);} + + ##### BEGIN process filtered calls today, if set ##### + if (strlen($calls_today_filteredSQL) > 10) { - $call_type='OUT'; - $four_hours_ago = date("Y-m-d H:i:s", mktime(date("H")-4,date("i"),date("s"),date("m"),date("d"),date("Y"))); + $stmt = "UPDATE vicidial_inbound_group_agents set calls_today_filtered=(calls_today_filtered + 1) where group_id='$stage' and user='$user' limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00810',$user,$server_ip,$session_name,$one_mysql_log);} - if ( ($auto_dial_level < 1) or (preg_match('/^M/',$MDnextCID)) ) + $stmt = "UPDATE vicidial_live_agents set last_inbound_call_time_filtered=last_inbound_call_time,last_inbound_call_finish_filtered=NOW() where user='$user';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00811',$user,$server_ip,$session_name,$one_mysql_log);} + + $stmt="SELECT max_inbound_calls,max_inbound_calls_outcome FROM vicidial_campaigns where campaign_id='$campaign';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00812',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $camp_record_ct = mysqli_num_rows($rslt); + if ($camp_record_ct > 0) { - $stmt = "SELECT count(*) from vicidial_log where lead_id='$lead_id' and call_date > \"$four_hours_ago\" and called_count='$called_count';"; - if ($format=='debug') {echo "\n";} - $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00213',$user,$server_ip,$session_name,$one_mysql_log);} $row=mysqli_fetch_row($rslt); - if ($row[0] > 0) - { - $stmt="UPDATE vicidial_log set status='$log_dispo_choice',user='$user' $term_reasonSQL where lead_id='$lead_id' and call_date > \"$four_hours_ago\" and called_count='$called_count' order by uniqueid desc limit 1;"; - if ($format=='debug') {echo "\n";} - $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00145',$user,$server_ip,$session_name,$one_mysql_log);} - } - else - { - $VLlist_id = ''; $VLphone_number = ''; $VLphone_code = ''; $user_group=''; - $stmt = "SELECT user_group FROM vicidial_users where user='$user';"; - $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00217',$user,$server_ip,$session_name,$one_mysql_log);} - if ($DB) {echo "$stmt\n";} - $VUinfo_ct = mysqli_num_rows($rslt); - if ($VUinfo_ct > 0) - { - $row=mysqli_fetch_row($rslt); - $user_group = "$row[0]"; - } - - $stmt = "SELECT list_id,phone_number,phone_code,alt_phone,address3 FROM vicidial_list where lead_id='$lead_id';"; - $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00216',$user,$server_ip,$session_name,$one_mysql_log);} - if ($DB) {echo "$stmt\n";} - $VLinfo_ct = mysqli_num_rows($rslt); - if ($VLinfo_ct > 0) - { - $row=mysqli_fetch_row($rslt); - $VLlist_id = $row[0]; - if (strlen($phone_number)<6) - { - $VLphone_number = $row[1]; - $VLalt = 'MAIN'; - $VLalt_phone = $row[3]; - $VLaddress3 = $row[4]; - } - else - { - $VLphone_number = "$phone_number"; - if ($phone_number == "$row[1]") - {$VLalt = 'MAIN';} - else - { - if ($phone_number != $VLalt_phone) - { - if ($phone_number != $VLaddress3) - { - $VLalt = 'X1'; - $stmt = "SELECT alt_phone_count from vicidial_list_alt_phones where lead_id='$lead_id' and phone_number = '$dialed_number' order by alt_phone_count limit 1;"; - if ($DB) {echo "$stmt\n";} - $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00250',$user,$server_ip,$session_name,$one_mysql_log);} - $VDAP_cid_ct = mysqli_num_rows($rslt); - if ($VDAP_cid_ct > 0) - { - $row=mysqli_fetch_row($rslt); - $Xalt_phone_count =$row[0]; - - $stmt = "SELECT count(*) from vicidial_list_alt_phones where lead_id='$lead_id';"; - if ($DB) {echo "$stmt\n";} - $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00251',$user,$server_ip,$session_name,$one_mysql_log);} - $VDAPct_cid_ct = mysqli_num_rows($rslt); - if ($VDAPct_cid_ct > 0) - { - $row=mysqli_fetch_row($rslt); - $COUNTalt_phone_count =$row[0]; - - if ($COUNTalt_phone_count <= $Xalt_phone_count) - {$VLalt = 'XLAST';} - else - {$VLalt = "X$Xalt_phone_count";} - } - - } - } - else - {$VLalt = 'ADDR3';} - } - else - {$VLalt = 'ALT';} - } - } - if (strlen($phone_code)<1) - {$VLphone_code = "$row[2]";} - else - {$VLphone_code = "$phone_code";} - } - - $PADlead_id = sprintf("%010s", $lead_id); - while (strlen($PADlead_id) > 9) {$PADlead_id = substr("$PADlead_id", 1);} - $FAKEcall_id = "$StarTtime.$PADlead_id"; - $stmt = "INSERT INTO vicidial_log set uniqueid='$FAKEcall_id',lead_id='$lead_id',list_id='$VLlist_id',campaign_id='$campaign',call_date='$NOW_TIME',start_epoch='$StarTtime',end_epoch='$StarTtime',length_in_sec='0',status='$log_dispo_choice',phone_code='$VLphone_code',phone_number='$VLphone_number',user='$user',comments='MANUAL',processed='N',user_group='$user_group',term_reason='AGENT',alt_dial='$VLalt',called_count='$called_count';"; - if ($DB) {echo "$stmt\n";} - $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00215',$user,$server_ip,$session_name,$one_mysql_log);} - - ##### insert log into vicidial_log_extended for manual VICIDiaL call - $stmt="INSERT IGNORE INTO vicidial_log_extended SET uniqueid='$FAKEcall_id',server_ip='$server_ip',call_date='$NOW_TIME',lead_id='$lead_id',caller_code='$MDnextCID',custom_call_id='' ON DUPLICATE KEY UPDATE server_ip='$server_ip',call_date='$NOW_TIME',lead_id='$lead_id',caller_code='$MDnextCID';"; - if ($DB) {echo "$stmt\n";} - $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00402',$user,$server_ip,$session_name,$one_mysql_log);} - $affected_rowsX = mysqli_affected_rows($link); - - $MAN_vl_insert++; - } - - $stmt="DELETE FROM vicidial_auto_calls where callerid='$MDnextCID';"; - if ($format=='debug') {echo "\n";} - $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00219',$user,$server_ip,$session_name,$one_mysql_log);} - - $stmt="UPDATE vicidial_live_agents set ring_callerid='' where ring_callerid='$MDnextCID';"; - if ($format=='debug') {echo "\n";} - $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00403',$user,$server_ip,$session_name,$one_mysql_log);} + $CP_max_inbound_calls = $row[0]; + $max_inbound_calls_outcome = $row[1]; } - else + + if ( ($VU_max_inbound_calls > 0) || ($CP_max_inbound_calls > 0) ) { - $stmt="UPDATE vicidial_log set status='$log_dispo_choice' $term_reasonSQL where lead_id='$lead_id' and user='$user' and call_date > \"$four_hours_ago\" order by uniqueid desc limit 1;"; + $max_inbound_calls = $CP_max_inbound_calls; + if ($VU_max_inbound_calls > 0) + { + $max_inbound_calls = $VU_max_inbound_calls; + } + $max_inbound_count=0; + $stmt="SELECT sum(calls_today),sum(calls_today_filtered) FROM vicidial_inbound_group_agents where user='$user' and group_type='C';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00813',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $viga_record_ct = mysqli_num_rows($rslt); + if ($viga_record_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $max_inbound_count = $row[0]; + if ($max_inbound_filter_enabled > 0) + { + $max_inbound_count = $row[1]; + } + } + + # $fp = fopen ("./vicidial_debug.txt", "a"); + # fwrite ($fp, "$NOW_TIME|DISPO_CALL3|$user|$max_inbound_count - $row[0] - $row[1]|\n"); + # fclose($fp); + + if ($max_inbound_count >= $max_inbound_calls) + { + $outbound_autodial='0'; + $stmt="SELECT outbound_autodial,closer_campaigns FROM vicidial_live_agents where user='$user';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00814',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $vla_record_ct = mysqli_num_rows($rslt); + if ($vla_record_ct > 0) + { + $row=mysqli_fetch_row($rslt); + if (preg_match("/Y/",$row[0])) + {$outbound_autodial = '1';} + $closer_campaigns = $row[1]; + } + + $stmtA = "UPDATE vicidial_live_agents set external_ingroups=' -',external_blended='$outbound_autodial',external_igb_set_user='VDIC',manager_ingroup_set='SET' where user='$user'"; + $stmtB = "DELETE FROM vicidial_live_inbound_agents where user='$user';"; + + if (preg_match("/ALLOW_AGENTDIRECT/",$max_inbound_calls_outcome) ) + { + $closer_campaigns = preg_replace("/^ | -$//gi",'',$closer_campaigns); + $ADcloser_campaignsARY = explode(" ",$closer_campaigns); + $ADcloser_campaignsARYct = count($ADcloser_campaignsARY); + $ADc=0; + $ADcloser_campaigns=''; + while ($ADc < $ADcloser_campaignsARYct) + { + if (preg_match("/AGENTDIRECT/i",$ADcloser_campaignsARY[$ADc])) + {$ADcloser_campaigns .= "$ADcloser_campaignsARY[$ADc] ";} + $ADc++; + } + if (strlen($ADcloser_campaigns) > 3) + {$ADcloser_campaigns = " ".$ADcloser_campaigns."-";} + else + {$ADcloser_campaigns = " -";} + + $stmtA = "UPDATE vicidial_live_agents set external_ingroups='$ADcloser_campaigns',external_blended='$outbound_autodial',external_igb_set_user='VDIC',manager_ingroup_set='SET' where user='$user'"; + $stmtB = "DELETE FROM vicidial_live_inbound_agents where user='$user' and group_id NOT LIKE\"%AGENTDIRECT%\";"; + } + + if ($DB) {echo "$stmtA\n";} + $rslt=mysql_to_mysqli($stmtA, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtA,'00815',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rowsA = mysqli_affected_rows($link); + + if ($DB) {echo "$stmtB\n";} + $rslt=mysql_to_mysqli($stmtB, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtB,'00816',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rowsB = mysqli_affected_rows($link); + + $SQL_log = "$stmtA|$stmtB"; + $SQL_log = preg_replace("/'|%//",'',$SQL_log); + $stmtC = "INSERT INTO vicidial_admin_log set event_date=NOW(), user='$user', ip_address='$VARserver_ip', event_section='USERS', event_type='MODIFY', record_id='$user', event_code='MAX IN CALLS MODIFY USER', event_sql='$SQL_log', event_notes='|$dispo_choice|$customer_sec|$max_inbound_count|$max_inbound_calls|$user|IC|$max_inbound_calls_outcome|$closer_campaigns|$affected_rowsA|$affected_rowsB|';"; + $rslt=mysql_to_mysqli($stmtC, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtC,'00817',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rowsC = mysqli_affected_rows($link); + if ($DB) {echo "-- MAX INBOUND AGENT CALLS TRIGGER: |$affected_rowsC|$dispo_choice|$customer_sec|$max_inbound_count|$max_inbound_calls|$user|$max_inbound_calls_outcome|$closer_campaigns|";} + } + } + } + ##### END process filtered calls today, if set ##### + } + else + { + $call_type='OUT'; + $four_hours_ago = date("Y-m-d H:i:s", mktime(date("H")-4,date("i"),date("s"),date("m"),date("d"),date("Y"))); + + if ( ($auto_dial_level < 1) or (preg_match('/^M/',$MDnextCID)) ) + { + $stmt = "SELECT count(*) from vicidial_log where lead_id='$lead_id' and call_date > \"$four_hours_ago\" and called_count='$called_count';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00213',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysqli_fetch_row($rslt); + if ($row[0] > 0) + { + $stmt="UPDATE vicidial_log set status='$log_dispo_choice',user='$user' $term_reasonSQL where lead_id='$lead_id' and call_date > \"$four_hours_ago\" and called_count='$called_count' order by uniqueid desc limit 1;"; if ($format=='debug') {echo "\n";} $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00145',$user,$server_ip,$session_name,$one_mysql_log);} } - } - - ### find all DNC-type statuses in the system - if ( ($use_internal_dnc=='Y') or ($use_campaign_dnc=='Y') or ($use_internal_dnc=='AREACODE') or ($use_campaign_dnc=='AREACODE') ) - { - $DNC_string_check = '|'; - $stmt = "SELECT status FROM vicidial_statuses where dnc='Y';"; - $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00195',$user,$server_ip,$session_name,$one_mysql_log);} - if ($DB) {echo "$stmt\n";} - $dncvs_ct = mysqli_num_rows($rslt); - $i=0; - while ($i < $dncvs_ct) + else { - $row=mysqli_fetch_row($rslt); - $DNC_string_check .= "$row[0]|"; - $i++; + $VLlist_id = ''; $VLphone_number = ''; $VLphone_code = ''; + + $stmt = "SELECT list_id,phone_number,phone_code,alt_phone,address3 FROM vicidial_list where lead_id='$lead_id';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00216',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $VLinfo_ct = mysqli_num_rows($rslt); + if ($VLinfo_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $VLlist_id = $row[0]; + if (strlen($phone_number)<6) + { + $VLphone_number = $row[1]; + $VLalt = 'MAIN'; + $VLalt_phone = $row[3]; + $VLaddress3 = $row[4]; + } + else + { + $VLphone_number = "$phone_number"; + if ($phone_number == "$row[1]") + {$VLalt = 'MAIN';} + else + { + if ($phone_number != $VLalt_phone) + { + if ($phone_number != $VLaddress3) + { + $VLalt = 'X1'; + $stmt = "SELECT alt_phone_count from vicidial_list_alt_phones where lead_id='$lead_id' and phone_number = '$dialed_number' order by alt_phone_count limit 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00250',$user,$server_ip,$session_name,$one_mysql_log);} + $VDAP_cid_ct = mysqli_num_rows($rslt); + if ($VDAP_cid_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $Xalt_phone_count =$row[0]; + + $stmt = "SELECT count(*) from vicidial_list_alt_phones where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00251',$user,$server_ip,$session_name,$one_mysql_log);} + $VDAPct_cid_ct = mysqli_num_rows($rslt); + if ($VDAPct_cid_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $COUNTalt_phone_count =$row[0]; + + if ($COUNTalt_phone_count <= $Xalt_phone_count) + {$VLalt = 'XLAST';} + else + {$VLalt = "X$Xalt_phone_count";} + } + + } + } + else + {$VLalt = 'ADDR3';} + } + else + {$VLalt = 'ALT';} + } + } + if (strlen($phone_code)<1) + {$VLphone_code = "$row[2]";} + else + {$VLphone_code = "$phone_code";} + } + + $PADlead_id = sprintf("%010s", $lead_id); + while (strlen($PADlead_id) > 9) {$PADlead_id = substr("$PADlead_id", 1);} + $FAKEcall_id = "$StarTtime.$PADlead_id"; + $stmt = "INSERT INTO vicidial_log set uniqueid='$FAKEcall_id',lead_id='$lead_id',list_id='$VLlist_id',campaign_id='$campaign',call_date='$NOW_TIME',start_epoch='$StarTtime',end_epoch='$StarTtime',length_in_sec='0',status='$log_dispo_choice',phone_code='$VLphone_code',phone_number='$VLphone_number',user='$user',comments='MANUAL',processed='N',user_group='$user_group',term_reason='AGENT',alt_dial='$VLalt',called_count='$called_count';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00215',$user,$server_ip,$session_name,$one_mysql_log);} + + ##### insert log into vicidial_log_extended for manual VICIDiaL call + $stmt="INSERT IGNORE INTO vicidial_log_extended SET uniqueid='$FAKEcall_id',server_ip='$server_ip',call_date='$NOW_TIME',lead_id='$lead_id',caller_code='$MDnextCID',custom_call_id='' ON DUPLICATE KEY UPDATE server_ip='$server_ip',call_date='$NOW_TIME',lead_id='$lead_id',caller_code='$MDnextCID';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00402',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rowsX = mysqli_affected_rows($link); + + $MAN_vl_insert++; } - $stmt = "SELECT status FROM vicidial_campaign_statuses where dnc='Y' and campaign_id='$campaign';"; + $stmt="DELETE FROM vicidial_auto_calls where callerid='$MDnextCID';"; + if ($format=='debug') {echo "\n";} $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00196',$user,$server_ip,$session_name,$one_mysql_log);} - if ($DB) {echo "$stmt\n";} - $dncvcs_ct = mysqli_num_rows($rslt); - $i=0; - while ($i < $dncvcs_ct) - { - $row=mysqli_fetch_row($rslt); - $DNC_string_check .= "$row[0]|"; - $i++; - } + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00219',$user,$server_ip,$session_name,$one_mysql_log);} - # echo "$DNC_string_check"; + $stmt="UPDATE vicidial_live_agents set ring_callerid='' where ring_callerid='$MDnextCID';"; + if ($format=='debug') {echo "\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00403',$user,$server_ip,$session_name,$one_mysql_log);} } - - $insert_into_dnc=0; - if ( ( ($use_internal_dnc=='Y') or ($use_internal_dnc=='AREACODE') ) and (preg_match("/\|$log_dispo_choice\|/i", $DNC_string_check) ) ) + else { - $stmt = "SELECT phone_number from vicidial_list where lead_id='$lead_id';"; - if ($DB) {echo "$stmt\n";} + $stmt="UPDATE vicidial_log set status='$log_dispo_choice' $term_reasonSQL where lead_id='$lead_id' and user='$user' and call_date > \"$four_hours_ago\" order by uniqueid desc limit 1;"; + if ($format=='debug') {echo "\n";} $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00146',$user,$server_ip,$session_name,$one_mysql_log);} - $row=mysqli_fetch_row($rslt); - $stmt="INSERT IGNORE INTO vicidial_dnc (phone_number) values('$row[0]');"; - $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00147',$user,$server_ip,$session_name,$one_mysql_log);} - if ($DB) {echo "$stmt\n";} - $insert_into_dnc++; - $stmt="INSERT INTO vicidial_dnc_log SET phone_number='$row[0]', campaign_id='-SYSINT-', action='add', action_date=NOW(), user='$user';"; - $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00632',$user,$server_ip,$session_name,$one_mysql_log);} - if ($DB) {echo "$stmt\n";} + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00145',$user,$server_ip,$session_name,$one_mysql_log);} } - if ( ( ($use_campaign_dnc=='Y') or ($use_campaign_dnc=='AREACODE') ) and (preg_match("/\|$log_dispo_choice\|/i", $DNC_string_check) ) ) - { - $stmt="SELECT use_other_campaign_dnc from vicidial_campaigns where campaign_id='$campaign';"; - $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00446',$user,$server_ip,$session_name,$one_mysql_log);} - $row=mysqli_fetch_row($rslt); - $use_other_campaign_dnc = $row[0]; - $temp_campaign_id = $campaign; - if (strlen($use_other_campaign_dnc) > 0) {$temp_campaign_id = $use_other_campaign_dnc;} + } - $stmt = "SELECT phone_number from vicidial_list where lead_id='$lead_id';"; - if ($DB) {echo "$stmt\n";} - $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00148',$user,$server_ip,$session_name,$one_mysql_log);} + ### find all DNC-type statuses in the system + if ( ($use_internal_dnc=='Y') or ($use_campaign_dnc=='Y') or ($use_internal_dnc=='AREACODE') or ($use_campaign_dnc=='AREACODE') ) + { + $DNC_string_check = '|'; + $stmt = "SELECT status FROM vicidial_statuses where dnc='Y';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00195',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $dncvs_ct = mysqli_num_rows($rslt); + $i=0; + while ($i < $dncvs_ct) + { $row=mysqli_fetch_row($rslt); - $stmt="INSERT IGNORE INTO vicidial_campaign_dnc (phone_number,campaign_id) values('$row[0]','$temp_campaign_id');"; - $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00149',$user,$server_ip,$session_name,$one_mysql_log);} - if ($DB) {echo "$stmt\n";} - $insert_into_dnc++; - $stmt="INSERT INTO vicidial_dnc_log SET phone_number='$row[0]', campaign_id='$temp_campaign_id', action='add', action_date=NOW(), user='$user';"; - $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00633',$user,$server_ip,$session_name,$one_mysql_log);} - if ($DB) {echo "$stmt\n";} + $DNC_string_check .= "$row[0]|"; + $i++; } + + $stmt = "SELECT status FROM vicidial_campaign_statuses where dnc='Y' and campaign_id='$campaign';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00196',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $dncvcs_ct = mysqli_num_rows($rslt); + $i=0; + while ($i < $dncvcs_ct) + { + $row=mysqli_fetch_row($rslt); + $DNC_string_check .= "$row[0]|"; + $i++; + } + + # echo "$DNC_string_check"; + } + + $insert_into_dnc=0; + if ( ( ($use_internal_dnc=='Y') or ($use_internal_dnc=='AREACODE') ) and (preg_match("/\|$log_dispo_choice\|/i", $DNC_string_check) ) ) + { + $stmt = "SELECT phone_number from vicidial_list where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00146',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysqli_fetch_row($rslt); + $stmt="INSERT IGNORE INTO vicidial_dnc (phone_number) values('$row[0]');"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00147',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $insert_into_dnc++; + $stmt="INSERT INTO vicidial_dnc_log SET phone_number='$row[0]', campaign_id='-SYSINT-', action='add', action_date=NOW(), user='$user';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00632',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + } + if ( ( ($use_campaign_dnc=='Y') or ($use_campaign_dnc=='AREACODE') ) and (preg_match("/\|$log_dispo_choice\|/i", $DNC_string_check) ) ) + { + $stmt="SELECT use_other_campaign_dnc from vicidial_campaigns where campaign_id='$campaign';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00446',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysqli_fetch_row($rslt); + $use_other_campaign_dnc = $row[0]; + $temp_campaign_id = $campaign; + if (strlen($use_other_campaign_dnc) > 0) {$temp_campaign_id = $use_other_campaign_dnc;} + + $stmt = "SELECT phone_number from vicidial_list where lead_id='$lead_id';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00148',$user,$server_ip,$session_name,$one_mysql_log);} + $row=mysqli_fetch_row($rslt); + $stmt="INSERT IGNORE INTO vicidial_campaign_dnc (phone_number,campaign_id) values('$row[0]','$temp_campaign_id');"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00149',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} + $insert_into_dnc++; + $stmt="INSERT INTO vicidial_dnc_log SET phone_number='$row[0]', campaign_id='$temp_campaign_id', action='add', action_date=NOW(), user='$user';"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00633',$user,$server_ip,$session_name,$one_mysql_log);} + if ($DB) {echo "$stmt\n";} } $dispo_sec=0; @@ -12178,17 +12319,6 @@ if ($ACTION == 'updateDISPO') $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00272',$user,$server_ip,$session_name,$one_mysql_log);} - $user_group=''; - $stmt="SELECT user_group FROM vicidial_users where user='$user' LIMIT 1;"; - $rslt=mysql_to_mysqli($stmt, $link); - if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00152',$user,$server_ip,$session_name,$one_mysql_log);} - if ($DB) {echo "$stmt\n";} - $ug_record_ct = mysqli_num_rows($rslt); - if ($ug_record_ct > 0) - { - $row=mysqli_fetch_row($rslt); - $user_group = trim("$row[0]"); - } $CALL_agent_log_id = $agent_log_id; if ($auto_dial_level < 1) diff --git a/www/agc/vicidial.php b/www/agc/vicidial.php index c39f6bb5..7f72a0cf 100644 --- a/www/agc/vicidial.php +++ b/www/agc/vicidial.php @@ -619,10 +619,11 @@ # 190901-0956 - Added cid_choice option to API transfer_conference function # 190902-0914 - Fix for PHP 7.2 # 190925-1346 - Changes for more SIP Event Action features +# 191018-0904 - Added User Inbound Filtered features # -$version = '2.14-588c'; -$build = '190925-1346'; +$version = '2.14-589c'; +$build = '191018-0904'; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=87; $one_mysql_log=0; @@ -1420,7 +1421,7 @@ else if($auth>0) { ##### grab the full name and other settings of the agent - $stmt="SELECT full_name,user_level,hotkeys_active,agent_choose_ingroups,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,closer_default_blended,user_group,vicidial_recording_override,alter_custphone_override,alert_enabled,agent_shift_enforcement_override,shift_override_flag,allow_alerts,closer_campaigns,agent_choose_territories,custom_one,custom_two,custom_three,custom_four,custom_five,agent_call_log_view_override,agent_choose_blended,agent_lead_search_override,preset_contact_search,max_inbound_calls,wrapup_seconds_override,email,user_choose_language,ready_max_logout,mute_recordings from vicidial_users where user='$VD_login' and active='Y' and api_only_user != '1';"; + $stmt="SELECT full_name,user_level,hotkeys_active,agent_choose_ingroups,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,closer_default_blended,user_group,vicidial_recording_override,alter_custphone_override,alert_enabled,agent_shift_enforcement_override,shift_override_flag,allow_alerts,closer_campaigns,agent_choose_territories,custom_one,custom_two,custom_three,custom_four,custom_five,agent_call_log_view_override,agent_choose_blended,agent_lead_search_override,preset_contact_search,max_inbound_calls,wrapup_seconds_override,email,user_choose_language,ready_max_logout,mute_recordings,max_inbound_filter_enabled from vicidial_users where user='$VD_login' and active='Y' and api_only_user != '1';"; $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01007',$VD_login,$server_ip,$session_name,$one_mysql_log);} $row=mysqli_fetch_row($rslt); @@ -1458,6 +1459,7 @@ else $VU_user_choose_language = $row[31]; $VU_ready_max_logout = $row[32]; $VU_mute_recordings = $row[33]; + $VU_max_inbound_filter_enabled = $row[34]; if ( ($VU_alert_enabled > 0) and ($VU_allow_alerts > 0) ) {$VU_alert_enabled = 'ON';} else {$VU_alert_enabled = 'OFF';} @@ -2449,7 +2451,7 @@ else if ($VU_max_inbound_calls > 0) {$max_inbound_calls = $VU_max_inbound_calls;} - $stmt = "SELECT sum(calls_today) FROM vicidial_inbound_group_agents where user='$VD_login' and group_type='C';"; + $stmt = "SELECT sum(calls_today),sum(calls_today_filtered) FROM vicidial_inbound_group_agents where user='$VD_login' and group_type='C';"; $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01080',$VD_login,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "\n";} @@ -2458,6 +2460,8 @@ else { $row=mysqli_fetch_row($rslt); $max_inbound_count = $row[0]; + if ($VU_max_inbound_filter_enabled > 0) + {$max_inbound_count = $row[1];} if ($max_inbound_count >= $max_inbound_calls) { @@ -3531,7 +3535,7 @@ else echo "\n"; $closer_chooser_string=''; - $stmt="INSERT INTO vicidial_live_agents (user,server_ip,conf_exten,extension,status,lead_id,campaign_id,uniqueid,callerid,channel,random_id,last_call_time,last_update_time,last_call_finish,closer_campaigns,user_level,campaign_weight,calls_today,last_state_change,outbound_autodial,manager_ingroup_set,on_hook_ring_time,on_hook_agent,last_inbound_call_time,last_inbound_call_finish,campaign_grade,pause_code) values('$VD_login','$server_ip','$session_id','$SIP_user','PAUSED','','$VD_campaign','','','','$random','$NOW_TIME','$tsNOW_TIME','$NOW_TIME','$closer_chooser_string','$user_level','$campaign_weight','$calls_today','$NOW_TIME','Y','N','$phone_ring_timeout','$on_hook_agent','$NOW_TIME','$NOW_TIME','$campaign_grade','LOGIN');"; + $stmt="INSERT INTO vicidial_live_agents (user,server_ip,conf_exten,extension,status,lead_id,campaign_id,uniqueid,callerid,channel,random_id,last_call_time,last_update_time,last_call_finish,closer_campaigns,user_level,campaign_weight,calls_today,last_state_change,outbound_autodial,manager_ingroup_set,on_hook_ring_time,on_hook_agent,last_inbound_call_time,last_inbound_call_finish,campaign_grade,pause_code,last_inbound_call_time_filtered,last_inbound_call_finish_filtered) values('$VD_login','$server_ip','$session_id','$SIP_user','PAUSED','','$VD_campaign','','','','$random','$NOW_TIME','$tsNOW_TIME','$NOW_TIME','$closer_chooser_string','$user_level','$campaign_weight','$calls_today','$NOW_TIME','Y','N','$phone_ring_timeout','$on_hook_agent','$NOW_TIME','$NOW_TIME','$campaign_grade','LOGIN','$NOW_TIME','$NOW_TIME');"; if ($DB) {echo "$stmt\n";} $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01044',$VD_login,$server_ip,$session_name,$one_mysql_log);} @@ -3598,7 +3602,7 @@ else { print "\n"; - $stmt="INSERT INTO vicidial_live_agents (user,server_ip,conf_exten,extension,status,lead_id,campaign_id,uniqueid,callerid,channel,random_id,last_call_time,last_update_time,last_call_finish,user_level,campaign_weight,calls_today,last_state_change,outbound_autodial,manager_ingroup_set,on_hook_ring_time,on_hook_agent,campaign_grade) values('$VD_login','$server_ip','$session_id','$SIP_user','PAUSED','','$VD_campaign','','','','$random','$NOW_TIME','$tsNOW_TIME','$NOW_TIME','$user_level', '$campaign_weight', '$calls_today','$NOW_TIME','N','N','$phone_ring_timeout','$on_hook_agent','$campaign_grade');"; + $stmt="INSERT INTO vicidial_live_agents (user,server_ip,conf_exten,extension,status,lead_id,campaign_id,uniqueid,callerid,channel,random_id,last_call_time,last_update_time,last_call_finish,user_level,campaign_weight,calls_today,last_state_change,outbound_autodial,manager_ingroup_set,on_hook_ring_time,on_hook_agent,campaign_grade,last_inbound_call_time_filtered,last_inbound_call_finish_filtered) values('$VD_login','$server_ip','$session_id','$SIP_user','PAUSED','','$VD_campaign','','','','$random','$NOW_TIME','$tsNOW_TIME','$NOW_TIME','$user_level', '$campaign_weight', '$calls_today','$NOW_TIME','N','N','$phone_ring_timeout','$on_hook_agent','$campaign_grade','$NOW_TIME','$NOW_TIME');"; if ($DB) {echo "$stmt\n";} $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01047',$VD_login,$server_ip,$session_name,$one_mysql_log);} @@ -13804,6 +13808,7 @@ function set_length(SLnumber,SLlength_goal,SLdirection) CheckDEADcallON=0; CheckDEADcallCOUNT=0; dead_trigger_count=0; + var last_customer_sec = customer_sec; customer_sec=0; currently_in_email_or_chat=0; customer_3way_hangup_counter=0; @@ -13949,7 +13954,7 @@ function set_length(SLnumber,SLlength_goal,SLdirection) } if (xmlhttp) { - DSupdate_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=updateDISPO&format=text&user=" + user + "&pass=" + pass + "&orig_pass=" + orig_pass + "&dispo_choice=" + DispoChoice + "&lead_id=" + document.vicidial_form.lead_id.value + "&campaign=" + campaign + "&auto_dial_level=" + auto_dial_level + "&agent_log_id=" + agent_log_id + "&CallBackDatETimE=" + CallBackDatETimE + "&list_id=" + document.vicidial_form.list_id.value + "&recipient=" + CallBackrecipient + "&use_internal_dnc=" + use_internal_dnc + "&use_campaign_dnc=" + use_campaign_dnc + "&MDnextCID=" + LasTCID + "&stage=" + group + "&vtiger_callback_id=" + vtiger_callback_id + "&phone_number=" + document.vicidial_form.phone_number.value + "&phone_code=" + document.vicidial_form.phone_code.value + "&dial_method=" + dial_method + "&uniqueid=" + document.vicidial_form.uniqueid.value + "&CallBackLeadStatus=" + CallBackLeadStatus + "&comments=" + encodeURIComponent(CallBackCommenTs) + "&custom_field_names=" + custom_field_names + "&call_notes=" + encodeURIComponent(document.vicidial_form.call_notes_dispo.value) + "&dispo_comments=" + encodeURIComponent(document.vicidial_form.dispo_comments.value) + "&cbcomment_comments=" + encodeURIComponent(document.vicidial_form.cbcomment_comments.value) + "&qm_dispo_code=" + DispoQMcsCODE + "&email_enabled=" + email_enabled + "&recording_id=" + VDDCU_recording_id + "&recording_filename=" + VDDCU_recording_filename + "&called_count=" + document.vicidial_form.called_count.value + "&parked_hangup=" + parked_hangup + "&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 + "&callback_gmt_offset=" + callback_gmt_offset + "&callback_timezone=" + callback_timezone; + DSupdate_query = "server_ip=" + server_ip + "&session_name=" + session_name + "&ACTION=updateDISPO&format=text&user=" + user + "&pass=" + pass + "&orig_pass=" + orig_pass + "&dispo_choice=" + DispoChoice + "&lead_id=" + document.vicidial_form.lead_id.value + "&campaign=" + campaign + "&auto_dial_level=" + auto_dial_level + "&agent_log_id=" + agent_log_id + "&CallBackDatETimE=" + CallBackDatETimE + "&list_id=" + document.vicidial_form.list_id.value + "&recipient=" + CallBackrecipient + "&use_internal_dnc=" + use_internal_dnc + "&use_campaign_dnc=" + use_campaign_dnc + "&MDnextCID=" + LasTCID + "&stage=" + group + "&vtiger_callback_id=" + vtiger_callback_id + "&phone_number=" + document.vicidial_form.phone_number.value + "&phone_code=" + document.vicidial_form.phone_code.value + "&dial_method=" + dial_method + "&uniqueid=" + document.vicidial_form.uniqueid.value + "&CallBackLeadStatus=" + CallBackLeadStatus + "&comments=" + encodeURIComponent(CallBackCommenTs) + "&custom_field_names=" + custom_field_names + "&call_notes=" + encodeURIComponent(document.vicidial_form.call_notes_dispo.value) + "&dispo_comments=" + encodeURIComponent(document.vicidial_form.dispo_comments.value) + "&cbcomment_comments=" + encodeURIComponent(document.vicidial_form.cbcomment_comments.value) + "&qm_dispo_code=" + DispoQMcsCODE + "&email_enabled=" + email_enabled + "&recording_id=" + VDDCU_recording_id + "&recording_filename=" + VDDCU_recording_filename + "&called_count=" + document.vicidial_form.called_count.value + "&parked_hangup=" + parked_hangup + "&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 + "&callback_gmt_offset=" + callback_gmt_offset + "&callback_timezone=" + callback_timezone + "&customer_sec=" + last_customer_sec; xmlhttp.open('POST', 'vdc_db_query.php'); xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8'); xmlhttp.send(DSupdate_query); diff --git a/www/vicidial/admin.php b/www/vicidial/admin.php index 2af6c4f9..57c0f8a1 100644 --- a/www/vicidial/admin.php +++ b/www/vicidial/admin.php @@ -2437,7 +2437,14 @@ if (isset($_GET["auto_active_list_new"])) {$auto_active_list_new=$_GET["auto_a elseif (isset($_POST["auto_active_list_new"])) {$auto_active_list_new=$_POST["auto_active_list_new"];} if (isset($_GET["auto_active_list_rank"])) {$auto_active_list_rank=$_GET["auto_active_list_rank"];} elseif (isset($_POST["auto_active_list_rank"])) {$auto_active_list_rank=$_POST["auto_active_list_rank"];} - +if (isset($_GET["max_inbound_filter_enabled"])) {$max_inbound_filter_enabled=$_GET["max_inbound_filter_enabled"];} + elseif (isset($_POST["max_inbound_filter_enabled"])) {$max_inbound_filter_enabled=$_POST["max_inbound_filter_enabled"];} +if (isset($_GET["max_inbound_filter_statuses"])) {$max_inbound_filter_statuses=$_GET["max_inbound_filter_statuses"];} + elseif (isset($_POST["max_inbound_filter_statuses"])) {$max_inbound_filter_statuses=$_POST["max_inbound_filter_statuses"];} +if (isset($_GET["max_inbound_filter_ingroups"])) {$max_inbound_filter_ingroups=$_GET["max_inbound_filter_ingroups"];} + elseif (isset($_POST["max_inbound_filter_ingroups"])) {$max_inbound_filter_ingroups=$_POST["max_inbound_filter_ingroups"];} +if (isset($_GET["max_inbound_filter_min_sec"])) {$max_inbound_filter_min_sec=$_GET["max_inbound_filter_min_sec"];} + elseif (isset($_POST["max_inbound_filter_min_sec"])) {$max_inbound_filter_min_sec=$_POST["max_inbound_filter_min_sec"];} if (isset($script_id)) {$script_id= strtoupper($script_id);} if (isset($lead_filter_id)) {$lead_filter_id = strtoupper($lead_filter_id);} @@ -2871,6 +2878,7 @@ if ($non_latin < 1) $agent_logout_link = preg_replace('/[^0-9]/','',$agent_logout_link); $user_admin_redirect = preg_replace('/[^0-9]/','',$user_admin_redirect); $list_status_modification_confirmation = preg_replace('/[^0-9]/','',$list_status_modification_confirmation); + $max_inbound_filter_enabled = preg_replace('/[^0-9]/','',$max_inbound_filter_enabled); $user_new_lead_limit = preg_replace('/[^-0-9]/','',$user_new_lead_limit); $drop_call_seconds = preg_replace('/[^-0-9]/','',$drop_call_seconds); @@ -2883,6 +2891,7 @@ if ($non_latin < 1) $cid_cb_valid_length = preg_replace('/[^-0-9]/','',$cid_cb_valid_length); $daily_reset_limit = preg_replace('/[^-0-9]/','',$daily_reset_limit); $auto_active_list_rank = preg_replace('/[^-0-9]/','',$auto_active_list_rank); + $max_inbound_filter_min_sec = preg_replace('/[^-0-9]/','',$max_inbound_filter_min_sec); ### DIGITS and COLONS $shift_length = preg_replace('/[^\:0-9]/','',$shift_length); @@ -4525,12 +4534,13 @@ else # 190902-0839 - Fixes for PHP 7.2 # 190930-2110 - More PHP7 fixes # 191014-1816 - Additional PHP7 fixes +# 191015-1620 - Added user inbound call count filters # # 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.14-720a'; -$build = '191014-1816'; +$admin_version = '2.14-721a'; +$build = '191015-1620'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -5860,6 +5870,7 @@ if ( ( (strlen($ADD)>4) and ($ADD < 99998) ) or ($ADD==3) or (($ADD>20) and ($AD $o=0; $USER_inbound_calls_today=0; + $USER_inbound_calls_today_filtered=0; $ingroup_js_rank=''; $ingroup_js_grade=''; $ingroup_js_rank_ct=0; @@ -5869,7 +5880,7 @@ if ( ( (strlen($ADD)>4) and ($ADD < 99998) ) or ($ADD==3) or (($ADD>20) and ($AD { $group_web_vars=''; $group_web=''; - $stmt="SELECT group_rank,calls_today,group_web_vars,group_grade from vicidial_inbound_group_agents where user='$user' and group_id='$group_id_values[$o]';"; + $stmt="SELECT group_rank,calls_today,group_web_vars,group_grade,calls_today_filtered from vicidial_inbound_group_agents where user='$user' and group_id='$group_id_values[$o]';"; $rslt=mysql_to_mysqli($stmt, $link); $ranks_to_print = mysqli_num_rows($rslt); if ($ranks_to_print > 0) @@ -5879,9 +5890,10 @@ if ( ( (strlen($ADD)>4) and ($ADD < 99998) ) or ($ADD==3) or (($ADD>20) and ($AD $calls_today = $row[1]; $group_web_vars = $row[2]; $SELECT_group_grade = $row[3]; + $calls_today_filtered = $row[4]; } else - {$calls_today=0; $SELECT_group_rank=0; $SELECT_group_grade=1;} + {$calls_today=0; $SELECT_group_rank=0; $SELECT_group_grade=1; $calls_today_filtered=0;} if ( ($ADD=="4A") or ($ADD=="4B") ) { if (isset($_GET["RANK_$group_id_values[$o]"])) {$group_rank=$_GET["RANK_$group_id_values[$o]"];} @@ -6000,6 +6012,7 @@ if ( ( (strlen($ADD)>4) and ($ADD < 99998) ) or ($ADD==3) or (($ADD>20) and ($AD $RANKgroups_list .= "     \n"; $o++; $USER_inbound_calls_today = ($USER_inbound_calls_today + $calls_today); + $USER_inbound_calls_today_filtered = ($USER_inbound_calls_today_filtered + $calls_today_filtered); } if (strlen($groups_value)>2) {$groups_value .= " -";} if (strlen($XFERgroups_value)>2) {$XFERgroups_value .= " -";} @@ -7525,7 +7538,7 @@ if ($ADD==1111) echo "$NWB#inbound_groups-user_group$NWE\n"; echo ""._QXZ("Web Form").": $NWB#inbound_groups-web_form_address$NWE\n"; echo ""._QXZ("Voicemail").": $NWB#inbound_groups-voicemail_ext$NWE\n"; - echo ""._QXZ("Next Agent Call").": $NWB#inbound_groups-next_agent_call$NWE\n"; + echo ""._QXZ("Next Agent Call").": $NWB#inbound_groups-next_agent_call$NWE\n"; echo ""._QXZ("Fronter Display").": $NWB#inbound_groups-fronter_display$NWE\n"; echo ""._QXZ("Script").": $NWB#inbound_groups-user_group$NWE\n"; echo ""._QXZ("Web Form").": $NWB#inbound_groups-web_form_address$NWE\n"; # echo "Voicemail: $NWB#inbound_groups-voicemail_ext$NWE\n"; - echo ""._QXZ("Next Agent Email").": $NWB#inbound_groups-next_agent_email$NWE\n"; + echo ""._QXZ("Next Agent Email").": $NWB#inbound_groups-next_agent_email$NWE\n"; echo ""._QXZ("Fronter Display").": $NWB#inbound_groups-fronter_display$NWE\n"; echo ""._QXZ("Script").": $NWB#inbound_groups-user_group$NWE\n"; echo ""._QXZ("Web Form").": $NWB#inbound_groups-web_form_address$NWE\n"; # echo "Voicemail: $NWB#inbound_groups-voicemail_ext$NWE\n"; - echo ""._QXZ("Next Agent Chat").": $NWB#inbound_groups-next_agent_chat$NWE\n"; + echo ""._QXZ("Next Agent Chat").": $NWB#inbound_groups-next_agent_chat$NWE\n"; echo ""._QXZ("Fronter Display").": $NWB#inbound_groups-fronter_display$NWE\n"; echo ""._QXZ("Script").": $NWB#users-max_inbound_calls$NWE     "._QXZ("inbound calls today").": $USER_inbound_calls_today\n"; + echo ""._QXZ("Max Inbound Calls Filtering Enabled").": $NWB#users-max_inbound_filter_enabled$NWE     "._QXZ("inbound filtered calls today").": $USER_inbound_calls_today_filtered\n"; + + echo ""._QXZ("Max Inbound Calls Filtering Options").": \n"; + echo ""; + + echo "\n"; + + echo "\n"; + + echo "
"._QXZ("Filter Statuses").":$NWB#users-max_inbound_filter_statuses$NWE  
"; + echo "
"._QXZ("Filter In-Groups").":$NWB#users-max_inbound_filter_ingroups$NWE  
"; + echo "
"._QXZ("Filter Minimum Seconds").":$NWB#users-max_inbound_filter_min_sec$NWE  
"; + echo "
\n"; + echo ""._QXZ("Max Manual Dial Hopper Calls").": $NWB#users-max_hopper_calls$NWE     "._QXZ("hopper calls today").": $USER_hopper_calls_today\n"; echo ""._QXZ("Max Manual Dial Hopper Calls Per Hour").": $NWB#users-max_hopper_calls_hour$NWE     "._QXZ("hopper calls this hour").": $USER_hopper_calls_hour\n"; @@ -28469,7 +28615,7 @@ if ($ADD==3111) { echo ""._QXZ("Web Form Three").": $NWB#inbound_groups-web_form_address$NWE\n"; } - echo ""._QXZ("Next Agent Call").": $NWB#inbound_groups-next_agent_call$NWE\n"; + echo ""._QXZ("Next Agent Call").": $NWB#inbound_groups-next_agent_call$NWE\n"; echo ""._QXZ("Queue Priority").": $NWB#inbound_groups-web_form_address$NWE\n"; } - echo ""._QXZ("Next Agent Email").": $NWB#inbound_groups-next_agent_email$NWE\n"; + echo ""._QXZ("Next Agent Email").": $NWB#inbound_groups-next_agent_email$NWE\n"; echo ""._QXZ("Queue Priority").":