diff --git a/www/vicidial/AST_CLOSERsummary_hourly.php b/www/vicidial/AST_CLOSERsummary_hourly.php index 6d5798da..4d481c8e 100644 --- a/www/vicidial/AST_CLOSERsummary_hourly.php +++ b/www/vicidial/AST_CLOSERsummary_hourly.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2023 Matt Florell LICENSE: AGPLv2 # # CHANGES # @@ -34,6 +34,7 @@ # 191013-0831 - Fixes for PHP7 # 200605-1100 - user_group bug fix # 220303-0829 - Added allow_web_debug system setting +# 230526-1740 - Patch for user_group bug, related to Issue #1346 # $startMS = microtime(); @@ -325,8 +326,8 @@ if ( (!preg_match('/\-\-ALL\-\-/i',$LOGadmin_viewable_groups)) and (strlen($LOGa { $rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups); $rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL); - $LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; - $whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $LOGadmin_viewable_groupsSQL = "and (user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL') OR user_group is null)"; + $whereLOGadmin_viewable_groupsSQL = "where (user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL') OR user_group is null)"; } $LOGadmin_viewable_call_timesSQL=''; diff --git a/www/vicidial/AST_agentDIDstats.php b/www/vicidial/AST_agentDIDstats.php index 65cf5b1f..727c8d79 100644 --- a/www/vicidial/AST_agentDIDstats.php +++ b/www/vicidial/AST_agentDIDstats.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2023 Matt Florell LICENSE: AGPLv2 # # CHANGES # @@ -10,6 +10,7 @@ # 170829-0040 - Added screen color settings # 191013-0836 - Fixes for PHP7 # 220303-1422 - Added allow_web_debug system setting +# 230526-1740 - Patch for user_group bug, related to Issue #1346 # $startMS = microtime(); @@ -217,6 +218,7 @@ if ( (!preg_match('/\-\-ALL\-\-/i',$LOGadmin_viewable_groups)) and (strlen($LOGa $rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups); $rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL); $LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $LOGadmin_viewable_and_null_groupsSQL = "and ( ".$vicidial_closer_log_table.".user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL') OR (".$vicidial_closer_log_table.".user_group is null AND ".$vicidial_closer_log_table.".user='VDCL') )"; $whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; } @@ -640,7 +642,7 @@ else $rslt=mysql_to_mysqli($stmt, $link); if (mysqli_num_rows($rslt)>0) { while ($row=mysqli_fetch_array($rslt)) { - $agent_stmt="select vicidial_users.user, vicidial_users.full_name from ".$vicidial_closer_log_table.", vicidial_users where uniqueid='$row[uniqueid]' and ".$vicidial_closer_log_table.".user=vicidial_users.user"; + $agent_stmt="select vicidial_users.user, vicidial_users.full_name from ".$vicidial_closer_log_table.", vicidial_users where uniqueid='$row[uniqueid]' and ".$vicidial_closer_log_table.".user=vicidial_users.user $LOGadmin_viewable_and_null_groupsSQL"; if ($DB) {echo "$agent_stmt\n";} $agent_rslt=mysql_to_mysqli($agent_stmt, $link); while($agent_row=mysqli_fetch_array($agent_rslt)) { @@ -648,11 +650,16 @@ else } } - $ASCII_text.=" $current_date\n"; - $ASCII_text.=$ASCII_headerA.$ASCII_headerB.$ASCII_headerA; + # Added 5/23/23, as with new user_group filter we don't want to print a date entry that has no viewable users + if (count($user_array)>0) + { + $ASCII_text.=" $current_date\n"; + $ASCII_text.=$ASCII_headerA.$ASCII_headerB.$ASCII_headerA; + + $CSV_text.="\"$current_date\"\n"; + $CSV_text.=$CSV_header; + } - $CSV_text.="\"$current_date\"\n"; - $CSV_text.=$CSV_header; #while (list($key, $val)=each($user_array)) { foreach($user_array as $key => $val) { $agent_total=0; @@ -671,8 +678,12 @@ else $CSV_text.="\"$agent_total\"\n"; $date_total+=$agent_total; } - $ASCII_text.=$ASCII_headerA."\n\n"; - $CSV_text.="\n\n"; + # Added 5/23/23, as with new user_group filter we don't want to print a date entry that has no viewable users + if (count($user_array)>0) + { + $ASCII_text.=$ASCII_headerA."\n\n"; + $CSV_text.="\n\n"; + } } $q++; @@ -689,7 +700,7 @@ else $rslt=mysql_to_mysqli($stmt, $link); if (mysqli_num_rows($rslt)>0) { while ($row=mysqli_fetch_array($rslt)) { - $agent_stmt="select vicidial_users.user, vicidial_users.full_name from ".$vicidial_closer_log_table.", vicidial_users where uniqueid='$row[uniqueid]' and ".$vicidial_closer_log_table.".user=vicidial_users.user"; + $agent_stmt="select vicidial_users.user, vicidial_users.full_name from ".$vicidial_closer_log_table.", vicidial_users where uniqueid='$row[uniqueid]' and ".$vicidial_closer_log_table.".user=vicidial_users.user $LOGadmin_viewable_and_null_groupsSQL"; if ($DB) {echo "$agent_stmt\n";} $agent_rslt=mysql_to_mysqli($agent_stmt, $link); while($agent_row=mysqli_fetch_array($agent_rslt)) { diff --git a/www/vicidial/AST_agent_days_detail.php b/www/vicidial/AST_agent_days_detail.php index b599c562..db7f596c 100644 --- a/www/vicidial/AST_agent_days_detail.php +++ b/www/vicidial/AST_agent_days_detail.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2023 Matt Florell LICENSE: AGPLv2 # # CHANGES # @@ -35,6 +35,7 @@ # 171204-2300 - Fixed minor reporting bug # 191013-0848 - Fixes for PHP7 # 220221-0946 - Added allow_web_debug system setting +# 230526-1740 - Patch for user_group bug, related to Issue #1346 # $startMS = microtime(); @@ -335,16 +336,34 @@ if ( (!preg_match('/\-\-ALL\-\-/i', $LOGadmin_viewable_call_times)) and (strlen( $whereLOGadmin_viewable_call_timesSQL = "where call_time_id IN('---ALL---','$rawLOGadmin_viewable_call_timesSQL')"; } - +$stmt="select user_group from vicidial_user_groups $whereLOGadmin_viewable_groupsSQL order by user_group;"; +$rslt=mysql_to_mysqli($stmt, $link); +if ($DB) {echo "$stmt\n";} +$user_groups_to_print = mysqli_num_rows($rslt); $i=0; -$group_string='|'; -$group_ct = count($group); -while($i < $group_ct) +$user_groups=array(); +while ($i < $user_groups_to_print) { - $group_string .= "$group[$i]|"; + $row=mysqli_fetch_row($rslt); + $user_groups[$i] =$row[0]; $i++; } + +#if ( (preg_match("/--ALL--/",$group_string) ) or ($group_ct < 1) ) +# { + $user_group_SQL = "and user_group IN('".implode("', '", $user_groups)."')"; + $user_group_SQL_val = "and vicidial_agent_log.user_group IN('".implode("', '", $user_groups)."')"; + $user_group_IN_clause="user_group in ('".implode("', '", $user_groups)."')"; +# } +#else +# { +# $user_group_SQL = preg_replace("/,\$/",'',$user_group_SQL); +# $user_group_SQL_str=$user_group_SQL; +# $user_group_IN_clause="user_group in ($user_group_SQL)"; +# $user_group_SQL = "and user_group IN($user_group_SQL)"; +# } + $stmt="select campaign_id from vicidial_campaigns $whereLOGallowed_campaignsSQL order by campaign_id;"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {echo "$stmt\n";} @@ -516,40 +535,58 @@ else $date_namesARY[0]=''; $k=0; - $stmt="select date_format(event_time, '%Y-%m-%d') as date,count(*) as calls,status from vicidial_users,".$vicidial_agent_log_table." where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and vicidial_users.user=".$vicidial_agent_log_table.".user and ".$vicidial_agent_log_table.".user='$user' $group_SQL $user_group_SQL $vuLOGadmin_viewable_groupsSQL group by date,status order by date,status desc limit 500000;"; - $rslt=mysql_to_mysqli($stmt, $link); - if ($DB) {echo "$stmt\n";} - $rows_to_print = mysqli_num_rows($rslt); - $i=0; - while ($i < $rows_to_print) - { - $row=mysqli_fetch_row($rslt); + $ustmt="select count(*), if($user_group_IN_clause, 1, 0) as accessible_user From vicidial_users where user='$user'"; + if ($DB) {echo "$ustmt\n";} + $urslt=mysql_to_mysqli($ustmt, $link); + $urow=mysqli_fetch_row($urslt); + $rows_to_print=0; - if ( ($row[1] > 0) and (strlen($row[2]) > 0) ) + if ($urow[0]>0 && $urow[1]>0) + { + $stmt="select date_format(event_time, '%Y-%m-%d') as date,count(*) as calls,status from vicidial_users,".$vicidial_agent_log_table." where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and vicidial_users.user=".$vicidial_agent_log_table.".user and ".$vicidial_agent_log_table.".user='$user' $group_SQL $user_group_SQL_val $vuLOGadmin_viewable_groupsSQL group by date,status order by date,status desc limit 500000;"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {echo "$stmt\n";} + $rows_to_print = mysqli_num_rows($rslt); + $i=0; + while ($i < $rows_to_print) { - $date[$i] = $row[0]; - $calls[$i] = $row[1]; - $status[$i] = $row[2]; - if ( (!preg_match("/\-$status[$i]\-/i", $statuses)) and (strlen($status[$i])>0) ) + $row=mysqli_fetch_row($rslt); + + if ( ($row[1] > 0) and (strlen($row[2]) > 0) ) { - $statusesTXT = sprintf("%8s", $status[$i]); - $statusesHEAD .= "----------+"; - $statusesHTML .= " $statusesTXT |"; - $statusesFILE .= "$status[$i],"; - $statuses .= "$status[$i]-"; - $statusesARY[$j] = $status[$i]; - $j++; - } - if (!preg_match("/\-$date[$i]\-/i", $dates)) - { - $dates .= "$date[$i]-"; - $datesARY[$k] = $date[$i]; - $k++; + $date[$i] = $row[0]; + $calls[$i] = $row[1]; + $status[$i] = $row[2]; + if ( (!preg_match("/\-$status[$i]\-/i", $statuses)) and (strlen($status[$i])>0) ) + { + $statusesTXT = sprintf("%8s", $status[$i]); + $statusesHEAD .= "----------+"; + $statusesHTML .= " $statusesTXT |"; + $statusesFILE .= "$status[$i],"; + $statuses .= "$status[$i]-"; + $statusesARY[$j] = $status[$i]; + $j++; + } + if (!preg_match("/\-$date[$i]\-/i", $dates)) + { + $dates .= "$date[$i]-"; + $datesARY[$k] = $date[$i]; + $k++; + } } + $i++; } - $i++; } + + if ($urow[0]==0 || $urow[1]==0 || $rows_to_print==0) + { + $ASCII_text.=($urow[0]==0 ? "*** "._QXZ("USER ID NOT FOUND")." ***" : ($urow[1]==0 ? "*** "._QXZ("YOU DO NOT HAVE PRIVILEGES TO VIEW THIS USER")." ***" : "*** "._QXZ("NO RECORDS FOUND")." ***"))."\n"; + $GRAPH_text.="
".($urow[0]==0 ? "*** "._QXZ("USER ID NOT FOUND")." ***" : ($urow[1]==0 ? "*** "._QXZ("YOU DO NOT HAVE PRIVILEGES TO VIEW THIS USER")." ***" : "*** "._QXZ("NO RECORDS FOUND")." ***")).""; + } + else + { + if ($file_download < 1) { $ASCII_text.=_QXZ("LEAD STATS BREAKDOWN").":\n"; @@ -903,6 +940,8 @@ else } } + } // END USER CHECK + if ($file_download > 0) { @@ -945,6 +984,7 @@ if ($file_download > 0) exit; } + $JS_onload.="}\n"; if ($report_display_type=='HTML') {$JS_text.=$JS_onload;} $JS_text.="\n"; diff --git a/www/vicidial/AST_agent_days_time.php b/www/vicidial/AST_agent_days_time.php index e4d2a46c..65820554 100644 --- a/www/vicidial/AST_agent_days_time.php +++ b/www/vicidial/AST_agent_days_time.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2023 Matt Florell LICENSE: AGPLv2 # # CHANGES # @@ -12,6 +12,7 @@ # 170829-0040 - Added screen color settings # 191013-0812 - Fixes for PHP7 # 220303-1510 - Added allow_web_debug system setting +# 230526-1740 - Patch for user_group bug, related to Issue #1346 # $startMS = microtime(); @@ -493,27 +494,35 @@ else $date_namesARY[0]=''; $k=0; - $stmt="select date_format(event_time, '%Y-%m-%d') as date,count(*) as calls from vicidial_users,".$vicidial_agent_log_table." where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and vicidial_users.user=".$vicidial_agent_log_table.".user and ".$vicidial_agent_log_table.".user='$user' $group_SQL $user_group_SQL $vuLOGadmin_viewable_groupsSQL group by date order by date desc limit 500000;"; - $rslt=mysql_to_mysqli($stmt, $link); - if ($DB) {echo "$stmt\n";} - $rows_to_print = mysqli_num_rows($rslt); - $i=0; - while ($i < $rows_to_print) - { - $row=mysqli_fetch_row($rslt); + $ustmt="select count(*), if(user_group in ('$rawLOGadmin_viewable_groupsSQL'), 1, 0) as accessible_user From vicidial_users where user='$user'"; + $urslt=mysql_to_mysqli($ustmt, $link); + $urow=mysqli_fetch_row($urslt); + $rows_to_print=0; - if ( ($row[1] > 0) and (strlen($row[0]) > 0) ) + if ($urow[0]>0 && $urow[1]>0) + { + $stmt="select date_format(event_time, '%Y-%m-%d') as date,count(*) as calls from vicidial_users,".$vicidial_agent_log_table." where event_time <= '$query_date_END' and event_time >= '$query_date_BEGIN' and vicidial_users.user=".$vicidial_agent_log_table.".user and ".$vicidial_agent_log_table.".user='$user' $group_SQL $user_group_SQL $vuLOGadmin_viewable_groupsSQL group by date order by date desc limit 500000;"; + $rslt=mysql_to_mysqli($stmt, $link); + if ($DB) {echo "$stmt\n";} + $rows_to_print = mysqli_num_rows($rslt); + $i=0; + while ($i < $rows_to_print) { - $date[$i] = $row[0]; - $calls[$i] = $row[1]; - if (!preg_match("/\-$date[$i]\-/i", $dates)) + $row=mysqli_fetch_row($rslt); + + if ( ($row[1] > 0) and (strlen($row[0]) > 0) ) { - $dates .= "$date[$i]-"; - $datesARY[$k] = $date[$i]; - $k++; + $date[$i] = $row[0]; + $calls[$i] = $row[1]; + if (!preg_match("/\-$date[$i]\-/i", $dates)) + { + $dates .= "$date[$i]-"; + $datesARY[$k] = $date[$i]; + $k++; + } } + $i++; } - $i++; } @@ -521,7 +530,8 @@ else $MAIN.="\n"; $MAIN.="\n"; $MAINprintALL .= $MAIN; - + $MAIN=''; + $i=0; while ($i < $rows_to_print) { @@ -653,6 +663,11 @@ else $i++; } + if ($i==0) + { + $MAIN.=""; + } + $MAIN.="
"._QXZ("DATE")." "._QXZ("PAUSE")." "._QXZ("WAIT")." "._QXZ("TALK")." "._QXZ("DISPO")." "._QXZ("DEAD")." "._QXZ("CUSTOMER")." "._QXZ("TOTAL")."
".($urow[0]==0 ? "*** "._QXZ("USER ID NOT FOUND")." ***" : ($urow[1]==0 ? "*** ._QXZ("YOU DO NOT HAVE PRIVILEGES TO VIEW THIS USER")." ***" : "*** ._QXZ("NO RECORDS FOUND")." ***"))."


\n"; } @@ -749,6 +764,7 @@ echo $MAINprintALL; echo "\n"; +/* if ($report_display_type=="TEXT" || !$report_display_type) { echo "\n"; @@ -781,6 +797,7 @@ if ($report_display_type=="TEXT" || !$report_display_type) echo "\n"; } +*/ if ($db_source == 'S') { diff --git a/www/vicidial/AST_agent_inbound_status.php b/www/vicidial/AST_agent_inbound_status.php index 8816072d..cf9fe2dc 100644 --- a/www/vicidial/AST_agent_inbound_status.php +++ b/www/vicidial/AST_agent_inbound_status.php @@ -1,13 +1,14 @@ LICENSE: AGPLv2 +# Copyright (C) 2023 Matt Florell LICENSE: AGPLv2 # # CHANGES # # 170913-0853 - First build based upon AST_agent_status_detail.php # 191013-0841 - Fixes for PHP7 # 220303-1503 - Added allow_web_debug system setting +# 230526-1740 - Patch for user_group bug, related to Issue #1346 # $startMS = microtime(); @@ -268,6 +269,7 @@ if ( (!preg_match('/\-\-ALL\-\-/i',$LOGadmin_viewable_groups)) and (strlen($LOGa $rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL); $LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; $whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $LOGadminVCL_viewable_groupsSQL = "and (".$closer_log_table.".user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL') OR (".$closer_log_table.".user_group IS NULL and ".$closer_log_table.".user='VDCL'))"; } $LOGadmin_viewable_call_timesSQL=''; @@ -355,11 +357,11 @@ while($i < $user_group_ct) $i++; } if ( (preg_match('/\-\-ALL\-\-/',$user_group_string) ) or ($user_group_ct < 1) ) - {$user_group_SQL = "";} + {$user_group_SQL = "$LOGadminVCL_viewable_groupsSQL";} else { $user_group_SQL = preg_replace('/,$/i', '',$user_group_SQL); - $user_group_SQL = "and ".$closer_log_table.".user_group IN($user_group_SQL)"; + $user_group_SQL = "$LOGadminVCL_viewable_groupsSQL and ".$closer_log_table.".user_group IN($user_group_SQL)"; } if ($DB) {echo "$user_group_string|$user_group_ct|$user_groupQS|$i
";} diff --git a/www/vicidial/AST_agent_time_detail.php b/www/vicidial/AST_agent_time_detail.php index d046ecc9..8e271add 100644 --- a/www/vicidial/AST_agent_time_detail.php +++ b/www/vicidial/AST_agent_time_detail.php @@ -4,7 +4,7 @@ # Pulls time stats per agent selectable by campaign or user group # should be most accurate agent stats of all of the reports # -# Copyright (C) 2022 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2023 Matt Florell LICENSE: AGPLv2 # # CHANGES # 90522-0723 - First build @@ -59,6 +59,7 @@ # 210324-2010 - Added agent visibility stats to HTML graphs # 211115-1513 - Fix for case-mismatch on pause code statuses for multi-campaign selects # 220303-1427 - Added allow_web_debug system setting +# 230526-1740 - Patch for user_group bug, related to Issue #1346 # $startMS = microtime(); @@ -481,7 +482,11 @@ while($i < $user_group_ct) $i++; } if ( (preg_match('/\-\-ALL\-\-/',$user_group_string) ) or ($user_group_ct < 1) ) - {$user_group_SQL = "";} + { + # $user_group_SQL = ""; + $user_group_SQL = " $LOGadmin_viewable_groupsSQL"; + $TCuser_group_SQL = " $LOGadmin_viewable_groupsSQL"; + } else { $user_group_SQL = preg_replace('/,$/i', '',$user_group_SQL); @@ -622,7 +627,8 @@ else ############################################################################ ### BEGIN gather user IDs and names for matching up later - $stmt="select full_name,$userSQL from vicidial_users $whereLOGadmin_viewable_groupsSQL order by user limit 100000;"; + # user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL') + $stmt="select full_name,$userSQL,if(user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL'), 1, 0) from vicidial_users $whereLOGadmin_viewable_groupsSQL order by user limit 100000;"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {echo "|$stmt\n";} $users_to_print = mysqli_num_rows($rslt); diff --git a/www/vicidial/AST_inbound_daily_report.php b/www/vicidial/AST_inbound_daily_report.php index 56b15735..8cb5aec2 100644 --- a/www/vicidial/AST_inbound_daily_report.php +++ b/www/vicidial/AST_inbound_daily_report.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2023 Matt Florell LICENSE: AGPLv2 # # CHANGES # @@ -35,6 +35,7 @@ # 191013-0902 - Fixes for PHP7 # 200701-1500 - Added option to exclude after-hours from abandons, list ID filtering # 220302-1803 - Added allow_web_debug system setting +# 230526-1740 - Patch for user_group bug, related to Issue #1346 # $startMS = microtime(); diff --git a/www/vicidial/AST_inbound_forecasting.php b/www/vicidial/AST_inbound_forecasting.php index b0a56ffc..40e36f57 100644 --- a/www/vicidial/AST_inbound_forecasting.php +++ b/www/vicidial/AST_inbound_forecasting.php @@ -1,7 +1,7 @@ , Joe Johnson LICENSE: AGPLv2 +# Copyright (C) 2023 Matt Florell , Joe Johnson LICENSE: AGPLv2 # # CHANGES # @@ -14,6 +14,7 @@ # 191013-0856 - Fixes for PHP7 # 210823-0948 - Fix for security issue, added NONE option for campaigns # 220301-2219 - Added allow_web_debug system setting +# 230526-1740 - Patch for user_group bug, related to Issue #1346 # $startMS = microtime(); @@ -299,6 +300,7 @@ if ( (!preg_match('/\-\-ALL\-\-/i',$LOGadmin_viewable_groups)) and (strlen($LOGa $rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups); $rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL); $LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $LOGadmin_viewable_and_null_groupsSQL = "and ( user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL') OR (user_group is null AND user='VDCL')) )"; $whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; } @@ -725,17 +727,17 @@ else } if ($erlang_type=="B") { - $hour_stmt="select closecallid, substr(call_date, 1, 13) as start_hour, length_in_sec, substr(call_date+INTERVAL length_in_sec second, 1, 13) as end_hour, if(DATE_FORMAT(call_date, '%Y-%m-%d %H:00:00')!=DATE_FORMAT(call_date+INTERVAL length_in_sec second, '%Y-%m-%d %H:00:00'), UNIX_TIMESTAMP(DATE_FORMAT(call_date+INTERVAL length_in_sec second, '%Y-%m-%d %H:00:00'))-UNIX_TIMESTAMP(call_date), length_in_sec) as length_up_to_next_hour, if(DATE_FORMAT(call_date, '%Y-%m-%d %H:00:00')!=DATE_FORMAT(call_date+INTERVAL length_in_sec second, '%Y-%m-%d %H:00:00'), UNIX_TIMESTAMP(call_date+INTERVAL length_in_sec second)-UNIX_TIMESTAMP(DATE_FORMAT(call_date+INTERVAL length_in_sec second, '%Y-%m-%d %H:00:00')), 0) as length_running_into_next_hour, status, uniqueid from vicidial_closer_log where length_in_sec is not null and campaign_id in ($campaign_group_SQL) and call_date>='$query_date 00:00:00' and call_date<='$end_date 23:59:59' and status!='AFTHRS'"; # * + $hour_stmt="select closecallid, substr(call_date, 1, 13) as start_hour, length_in_sec, substr(call_date+INTERVAL length_in_sec second, 1, 13) as end_hour, if(DATE_FORMAT(call_date, '%Y-%m-%d %H:00:00')!=DATE_FORMAT(call_date+INTERVAL length_in_sec second, '%Y-%m-%d %H:00:00'), UNIX_TIMESTAMP(DATE_FORMAT(call_date+INTERVAL length_in_sec second, '%Y-%m-%d %H:00:00'))-UNIX_TIMESTAMP(call_date), length_in_sec) as length_up_to_next_hour, if(DATE_FORMAT(call_date, '%Y-%m-%d %H:00:00')!=DATE_FORMAT(call_date+INTERVAL length_in_sec second, '%Y-%m-%d %H:00:00'), UNIX_TIMESTAMP(call_date+INTERVAL length_in_sec second)-UNIX_TIMESTAMP(DATE_FORMAT(call_date+INTERVAL length_in_sec second, '%Y-%m-%d %H:00:00')), 0) as length_running_into_next_hour, status, uniqueid from vicidial_closer_log where length_in_sec is not null and campaign_id in ($campaign_group_SQL) and call_date>='$query_date 00:00:00' and call_date<='$end_date 23:59:59' and status!='AFTHRS' $LOGadmin_viewable_and_null_groupsSQL"; # * - $avg_stmt="select avg(length_in_sec) as avg_length from vicidial_closer_log where length_in_sec is not null and campaign_id in ($campaign_group_SQL) and call_date>='$query_date 00:00:00' and call_date<='$end_date 23:59:59'"; # ** + $avg_stmt="select avg(length_in_sec) as avg_length from vicidial_closer_log where length_in_sec is not null and campaign_id in ($campaign_group_SQL) and call_date>='$query_date 00:00:00' and call_date<='$end_date 23:59:59' $LOGadmin_viewable_and_null_groupsSQL"; # ** - $wrapup_stmt="select uniqueid from vicidial_closer_log where length_in_sec is not null and user!='VDCL' and campaign_id in ($campaign_group_SQL) and call_date>='$query_date 00:00:00' and call_date<='$end_date 23:59:59'"; # *** + $wrapup_stmt="select uniqueid from vicidial_closer_log where length_in_sec is not null and user!='VDCL' and campaign_id in ($campaign_group_SQL) and call_date>='$query_date 00:00:00' and call_date<='$end_date 23:59:59' $LOGadmin_viewable_groupsSQL"; # *** } else { - $hour_stmt="select uniqueid, substr(call_date, 1, 13) as start_hour, length_in_sec, substr(call_date+INTERVAL length_in_sec second, 1, 13) as end_hour, if(DATE_FORMAT(call_date, '%Y-%m-%d %H:00:00')!=DATE_FORMAT(call_date+INTERVAL length_in_sec second, '%Y-%m-%d %H:00:00'), UNIX_TIMESTAMP(DATE_FORMAT(call_date+INTERVAL length_in_sec second, '%Y-%m-%d %H:00:00'))-UNIX_TIMESTAMP(call_date), length_in_sec) as length_up_to_next_hour, if(DATE_FORMAT(call_date, '%Y-%m-%d %H:00:00')!=DATE_FORMAT(call_date+INTERVAL length_in_sec second, '%Y-%m-%d %H:00:00'), UNIX_TIMESTAMP(call_date+INTERVAL length_in_sec second)-UNIX_TIMESTAMP(DATE_FORMAT(call_date+INTERVAL length_in_sec second, '%Y-%m-%d %H:00:00')), 0) as length_running_into_next_hour, status, uniqueid from vicidial_log where length_in_sec is not null and campaign_id in ($campaign_SQL) and call_date>='$query_date 00:00:00' and call_date<='$end_date 23:59:59' and status!='AFTHRS'"; # * + $hour_stmt="select uniqueid, substr(call_date, 1, 13) as start_hour, length_in_sec, substr(call_date+INTERVAL length_in_sec second, 1, 13) as end_hour, if(DATE_FORMAT(call_date, '%Y-%m-%d %H:00:00')!=DATE_FORMAT(call_date+INTERVAL length_in_sec second, '%Y-%m-%d %H:00:00'), UNIX_TIMESTAMP(DATE_FORMAT(call_date+INTERVAL length_in_sec second, '%Y-%m-%d %H:00:00'))-UNIX_TIMESTAMP(call_date), length_in_sec) as length_up_to_next_hour, if(DATE_FORMAT(call_date, '%Y-%m-%d %H:00:00')!=DATE_FORMAT(call_date+INTERVAL length_in_sec second, '%Y-%m-%d %H:00:00'), UNIX_TIMESTAMP(call_date+INTERVAL length_in_sec second)-UNIX_TIMESTAMP(DATE_FORMAT(call_date+INTERVAL length_in_sec second, '%Y-%m-%d %H:00:00')), 0) as length_running_into_next_hour, status, uniqueid from vicidial_log where length_in_sec is not null and campaign_id in ($campaign_SQL) and call_date>='$query_date 00:00:00' and call_date<='$end_date 23:59:59' and status!='AFTHRS' $LOGadmin_viewable_and_null_groupsSQL"; # * $avg_stmt="select avg(length_in_sec) as avg_length from vicidial_log where length_in_sec is not null and campaign_id in ($campaign_SQL) and call_date>='$query_date 00:00:00' and call_date<='$end_date 23:59:59'"; # ** - $wrapup_stmt="select uniqueid from vicidial_log where length_in_sec is not null and user!='VDCL' and campaign_id in ($campaign_SQL) and call_date>='$query_date 00:00:00' and call_date<='$end_date 23:59:59'"; # *** + $wrapup_stmt="select uniqueid from vicidial_log where length_in_sec is not null and user!='VDAD' and campaign_id in ($campaign_SQL) and call_date>='$query_date 00:00:00' and call_date<='$end_date 23:59:59'"; # *** } if ($DB) {echo "|$hour_stmt|\n";} if ($DB) {echo "|$avg_stmt|\n";} diff --git a/www/vicidial/AST_performance_comparison_report.php b/www/vicidial/AST_performance_comparison_report.php index aa653eb9..ccb0e8a4 100644 --- a/www/vicidial/AST_performance_comparison_report.php +++ b/www/vicidial/AST_performance_comparison_report.php @@ -1,7 +1,7 @@ , Joe Johnson , Joe Johnson LICENSE: AGPLv2 +# Copyright (C) 2023 Joseph Johnson LICENSE: AGPLv2 # # Gives hourly count of distinct agents per user group, with totals. # For single days only @@ -14,6 +14,7 @@ # 180507-2315 - Added new help display # 191013-0855 - Fixes for PHP7 # 220221-0932 - Added allow_web_debug system setting +# 230526-1740 - Patch for user_group bug, related to Issue #1346 # $startMS = microtime(); @@ -327,7 +328,7 @@ if ( (!preg_match('/\-\-ALL\-\-/i', $LOGadmin_viewable_call_times)) and (strlen( $stmt="select user_group from vicidial_user_groups $whereLOGadmin_viewable_groupsSQL order by user_group;"; $rslt=mysql_to_mysqli($stmt, $link); -if ($DB) {$HTML_text.="$stmt\n";} +if ($DB) {echo "$stmt\n";} $user_groups_to_print = mysqli_num_rows($rslt); $i=0; $user_groups=array(); @@ -349,7 +350,7 @@ while($i < $user_group_ct) $i++; } if ( (preg_match("/--ALL--/",$user_group_string) ) or ($user_group_ct < 1) ) - {$user_group_SQL = "";} + {$user_group_SQL = "and user_group IN('".implode("', '", $user_groups)."')";} else { $user_group_SQL = preg_replace("/,\$/",'',$user_group_SQL); @@ -361,14 +362,23 @@ else $stmt="SELECT campaign_id from vicidial_campaigns $whereLOGallowed_campaignsSQL order by campaign_id;"; $rslt=mysql_to_mysqli($stmt, $link); -if ($DB) {$HTML_text.="$stmt\n";} +if ($DB) {echo "$stmt\n";} $campaigns_to_print = mysqli_num_rows($rslt); $i=0; $groups=array(); +if (in_array("--ALL--", $group)) + { + $ALL_campaigns_selected=1; + $group=array(); + } while ($i < $campaigns_to_print) { $row=mysqli_fetch_row($rslt); $groups[$i] =$row[0]; + if ($ALL_campaigns_selected) + { + $group[$i]=$row[0]; + } $i++; } diff --git a/www/vicidial/AST_user_group_hourly_detail_v2.php b/www/vicidial/AST_user_group_hourly_detail_v2.php index 986c12b8..f751471a 100644 --- a/www/vicidial/AST_user_group_hourly_detail_v2.php +++ b/www/vicidial/AST_user_group_hourly_detail_v2.php @@ -1,7 +1,7 @@ +# Copyright (C) 2023 Liz Tejada # Joseph Johnson # Matt Florell # @@ -19,6 +19,7 @@ # 180507-2315 - Added new help display # 191013-0816 - Fixes for PHP7 # 220301-1940 - Added allow_web_debug system setting +# 230526-1740 - Patch for user_group bug, related to Issue #1346 # $startMS = microtime(); @@ -204,6 +205,13 @@ else echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n"; exit; } + if ($auth_message == 'IPBLOCK') + { + $VDdisplayMESSAGE = _QXZ("Your IP Address is not allowed") . ": $ip"; + Header ("Content-type: text/html; charset=utf-8"); + echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n"; + exit; + } Header("WWW-Authenticate: Basic realm=\"CONTACT-CENTER-ADMIN\""); Header("HTTP/1.0 401 Unauthorized"); echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$PHP_AUTH_PW|$auth_message|\n"; @@ -218,6 +226,9 @@ $LOGserver_name = getenv("SERVER_NAME"); $LOGserver_port = getenv("SERVER_PORT"); $LOGrequest_uri = getenv("REQUEST_URI"); $LOGhttp_referer = getenv("HTTP_REFERER"); +$LOGbrowser=preg_replace("/\'|\"|\\\\/","",$LOGbrowser); +$LOGrequest_uri=preg_replace("/\'|\"|\\\\/","",$LOGrequest_uri); +$LOGhttp_referer=preg_replace("/\'|\"|\\\\/","",$LOGhttp_referer); if (preg_match("/443/i",$LOGserver_port)) {$HTTPprotocol = 'https://';} else {$HTTPprotocol = 'http://';} if (($LOGserver_port == '80') or ($LOGserver_port == '443') ) {$LOGserver_port='';} @@ -321,7 +332,7 @@ if ( (!preg_match('/\-\-ALL\-\-/i', $LOGadmin_viewable_call_times)) and (strlen( $stmt="select user_group from vicidial_user_groups $whereLOGadmin_viewable_groupsSQL order by user_group;"; $rslt=mysql_to_mysqli($stmt, $link); -if ($DB) {$HTML_text.="$stmt\n";} +if ($DB) {echo "$stmt\n";} $user_groups_to_print = mysqli_num_rows($rslt); $i=0; $user_groups=array(); @@ -344,7 +355,7 @@ while($i < $user_group_ct) $i++; } if ( (preg_match("/--ALL--/",$user_group_string) ) or ($user_group_ct < 1) ) - {$user_group_SQL = "";} + {$user_group_SQL = "and log.user_group IN('".implode("', '", $user_groups)."')";} else { $user_group_SQL = preg_replace("/,\$/",'',$user_group_SQL); @@ -360,10 +371,19 @@ if ($DB) {$HTML_text.="$stmt\n";} $campaigns_to_print = mysqli_num_rows($rslt); $i=0; $groups=array(); +if (in_array("--ALL--", $group)) + { + $ALL_campaigns_selected=1; + $group=array(); + } while ($i < $campaigns_to_print) { $row=mysqli_fetch_row($rslt); $groups[$i] =$row[0]; + if ($ALL_campaigns_selected) + { + $group[$i]=$row[0]; + } $i++; } diff --git a/www/vicidial/AST_usergroup_login_report.php b/www/vicidial/AST_usergroup_login_report.php index c961dd9b..470a3990 100644 --- a/www/vicidial/AST_usergroup_login_report.php +++ b/www/vicidial/AST_usergroup_login_report.php @@ -4,7 +4,7 @@ # This User-Group based report runs some very intensive SQL queries, so it is # not recommended to run this on long time periods. # -# Copyright (C) 2022 Joe Johnson, Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2023 Joe Johnson, Matt Florell LICENSE: AGPLv2 # # CHANGES # @@ -25,6 +25,7 @@ # 180507-2315 - Added new help display # 191013-0822 - Fixes for PHP7 # 220301-1656 - Added allow_web_debug system setting +# 230526-1740 - Patch for user_group bug, related to Issue #1346 # $startMS = microtime(); @@ -314,11 +315,11 @@ while($i < $user_group_ct) } if ( (preg_match('/\-\-ALL\-\-/',$user_group_string) ) or ($user_group_ct < 1) ) - {$user_group_SQL = "";} + {$user_group_SQL = "where USER_group in ('".implode("', '", $user_groups)."')";} else { $user_group_SQL = preg_replace('/,$/i', '',$user_group_SQL); - $user_group_SQL = "where user_group in ($user_group_SQL)"; + $user_group_SQL = "where user_GROUP in ($user_group_SQL)"; #$user_group_SQL = "and vicidial_agent_log.user_group IN($user_group_SQL)"; } diff --git a/www/vicidial/Erlang_report.php b/www/vicidial/Erlang_report.php index 57dba1e3..f04a4943 100644 --- a/www/vicidial/Erlang_report.php +++ b/www/vicidial/Erlang_report.php @@ -1,7 +1,7 @@ , Joe Johnson LICENSE: AGPLv2 +# Copyright (C) 2023 Matt Florell , Joe Johnson LICENSE: AGPLv2 # # CHANGES # @@ -14,6 +14,7 @@ # 180712-1508 - Fix for rare allowed reports issue # 191013-0820 - Fixes for PHP7 # 220301-0937 - Added allow_web_debug system setting +# 230526-1740 - Patch for user_group bug, related to Issue #1346 # $startMS = microtime(); @@ -290,6 +291,7 @@ if ( (!preg_match('/\-\-ALL\-\-/i',$LOGadmin_viewable_groups)) and (strlen($LOGa $rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups); $rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL); $LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $LOGadmin_viewable_and_null_groupsSQL = "and ( user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL') OR (user_group is null AND user='VDCL') )"; $whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; } @@ -707,12 +709,13 @@ else } if ($erlang_type=="B") { - $hour_stmt="select closecallid, substr(call_date, 1, 13) as start_hour, length_in_sec, substr(call_date+INTERVAL length_in_sec second, 1, 13) as end_hour, if(DATE_FORMAT(call_date, '%Y-%m-%d %H:00:00')!=DATE_FORMAT(call_date+INTERVAL length_in_sec second, '%Y-%m-%d %H:00:00'), UNIX_TIMESTAMP(DATE_FORMAT(call_date+INTERVAL length_in_sec second, '%Y-%m-%d %H:00:00'))-UNIX_TIMESTAMP(call_date), length_in_sec) as length_up_to_next_hour, if(DATE_FORMAT(call_date, '%Y-%m-%d %H:00:00')!=DATE_FORMAT(call_date+INTERVAL length_in_sec second, '%Y-%m-%d %H:00:00'), UNIX_TIMESTAMP(call_date+INTERVAL length_in_sec second)-UNIX_TIMESTAMP(DATE_FORMAT(call_date+INTERVAL length_in_sec second, '%Y-%m-%d %H:00:00')), 0) as length_running_into_next_hour, status, uniqueid from vicidial_closer_log where length_in_sec is not null and campaign_id in ($campaign_group_SQL) and call_date>='$query_date 00:00:00' and call_date<='$end_date 23:59:59' and status!='AFTHRS'"; # * + $hour_stmt="select closecallid, substr(call_date, 1, 13) as start_hour, length_in_sec, substr(call_date+INTERVAL length_in_sec second, 1, 13) as end_hour, if(DATE_FORMAT(call_date, '%Y-%m-%d %H:00:00')!=DATE_FORMAT(call_date+INTERVAL length_in_sec second, '%Y-%m-%d %H:00:00'), UNIX_TIMESTAMP(DATE_FORMAT(call_date+INTERVAL length_in_sec second, '%Y-%m-%d %H:00:00'))-UNIX_TIMESTAMP(call_date), length_in_sec) as length_up_to_next_hour, if(DATE_FORMAT(call_date, '%Y-%m-%d %H:00:00')!=DATE_FORMAT(call_date+INTERVAL length_in_sec second, '%Y-%m-%d %H:00:00'), UNIX_TIMESTAMP(call_date+INTERVAL length_in_sec second)-UNIX_TIMESTAMP(DATE_FORMAT(call_date+INTERVAL length_in_sec second, '%Y-%m-%d %H:00:00')), 0) as length_running_into_next_hour, status, uniqueid from vicidial_closer_log where length_in_sec is not null and campaign_id in ($campaign_group_SQL) and call_date>='$query_date 00:00:00' and call_date<='$end_date 23:59:59' and status!='AFTHRS' $LOGadmin_viewable_and_null_groupsSQL"; # * - $avg_stmt="select avg(length_in_sec) as avg_length from vicidial_closer_log where length_in_sec is not null and campaign_id in ($campaign_group_SQL) and call_date>='$query_date 00:00:00' and call_date<='$end_date 23:59:59'"; # ** + $avg_stmt="select avg(length_in_sec) as avg_length from vicidial_closer_log where length_in_sec is not null and campaign_id in ($campaign_group_SQL) and call_date>='$query_date 00:00:00' and call_date<='$end_date 23:59:59' $LOGadmin_viewable_and_null_groupsSQL"; # ** - $wrapup_stmt="select uniqueid from vicidial_closer_log where length_in_sec is not null and user!='VDCL' and campaign_id in ($campaign_group_SQL) and call_date>='$query_date 00:00:00' and call_date<='$end_date 23:59:59'"; # *** + $wrapup_stmt="select uniqueid from vicidial_closer_log where length_in_sec is not null and user!='VDCL' and campaign_id in ($campaign_group_SQL) and call_date>='$query_date 00:00:00' and call_date<='$end_date 23:59:59' $LOGadmin_viewable_groupsSQL"; # *** } else { + # There are no filters for user groups in "C" reports because outbound calls don't reliably log user groups. $hour_stmt="select uniqueid, substr(call_date, 1, 13) as start_hour, length_in_sec, substr(call_date+INTERVAL length_in_sec second, 1, 13) as end_hour, if(DATE_FORMAT(call_date, '%Y-%m-%d %H:00:00')!=DATE_FORMAT(call_date+INTERVAL length_in_sec second, '%Y-%m-%d %H:00:00'), UNIX_TIMESTAMP(DATE_FORMAT(call_date+INTERVAL length_in_sec second, '%Y-%m-%d %H:00:00'))-UNIX_TIMESTAMP(call_date), length_in_sec) as length_up_to_next_hour, if(DATE_FORMAT(call_date, '%Y-%m-%d %H:00:00')!=DATE_FORMAT(call_date+INTERVAL length_in_sec second, '%Y-%m-%d %H:00:00'), UNIX_TIMESTAMP(call_date+INTERVAL length_in_sec second)-UNIX_TIMESTAMP(DATE_FORMAT(call_date+INTERVAL length_in_sec second, '%Y-%m-%d %H:00:00')), 0) as length_running_into_next_hour, status, uniqueid from vicidial_log where length_in_sec is not null and campaign_id in ($campaign_SQL) and call_date>='$query_date 00:00:00' and call_date<='$end_date 23:59:59' and status!='AFTHRS'"; # * $avg_stmt="select avg(length_in_sec) as avg_length from vicidial_log where length_in_sec is not null and campaign_id in ($campaign_SQL) and call_date>='$query_date 00:00:00' and call_date<='$end_date 23:59:59'"; # **