From 5d69ca3126d13ee776a1493b6f2b029593a5d6ef Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 21 Oct 2020 17:54:33 +0200 Subject: [PATCH] recursion taken in mind in group report --- .../include/functions_reporting.php | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index c480969f16..f71269f288 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -2972,7 +2972,11 @@ function reporting_group_report($report, $content) $return['data']['count_events'] = count($events); - $return['data']['group_stats'] = reporting_get_group_stats($content['id_group']); + $return['data']['group_stats'] = reporting_get_group_stats( + $content['id_group'], + 'AR', + (bool) $content['recursion'] + ); if ($config['metaconsole']) { metaconsole_restore_db(); @@ -8969,7 +8973,7 @@ function reporting_get_agents_detailed_event( * * @return array Group statistics */ -function reporting_get_group_stats($id_group=0, $access='AR') +function reporting_get_group_stats($id_group=0, $access='AR', $recursion=true) { global $config; @@ -9071,16 +9075,19 @@ function reporting_get_group_stats($id_group=0, $access='AR') // Store the groups where we are quering $covered_groups = []; $group_array = []; - foreach ($id_group as $group) { - $children = groups_get_children($group); - // Show empty groups only if they have children with agents - // $group_array = array(); - foreach ($children as $sub) { - // If the group is quering previously, we ingore it - if (!in_array($sub['id_grupo'], $covered_groups)) { - array_push($covered_groups, $sub['id_grupo']); - array_push($group_array, $sub['id_grupo']); + foreach ($id_group as $group) { + if ($recursion === true) { + $children = groups_get_children($group); + + // Show empty groups only if they have children with agents + // $group_array = array(); + foreach ($children as $sub) { + // If the group is quering previously, we ingore it + if (!in_array($sub['id_grupo'], $covered_groups)) { + array_push($covered_groups, $sub['id_grupo']); + array_push($group_array, $sub['id_grupo']); + } } }