From 2ff05eb3b38b0499034d60633ccd764eadeb146d Mon Sep 17 00:00:00 2001 From: darode Date: Fri, 10 Feb 2012 14:39:25 +0000 Subject: [PATCH] 2012-02-10 Dario Rodriguez * include/functions_reporting.php, include/functions_groups.php: Fixed a problem in Group View that hide empty parent groups when their children has agents. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5558 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/include/functions_groups.php | 14 ++++++++++++++ .../include/functions_reporting.php | 19 ++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index 1923a20175..a7e911e4aa 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -671,6 +671,20 @@ function groups_get_group_row($id_group, $group_all, $group, &$printed_groups) { if ($data["total_agents"] > 0) echo ""; + + //Total agent field given by function reporting_get_group_stats return the number of agents + //of this groups and its children. It was done to print empty fathers of children groups. + //We need to recalculate the total agents for this group here to get only the total agents + //for this group. Of course the group All (0) is a special case. + + $data["total_agents"]; + + if($id_group != 0) { + + $data["total_agents"] = db_get_sql ("SELECT COUNT(*) FROM tagente + WHERE id_grupo = $id_group AND disabled = 0"); + } + echo $data["total_agents"]; echo ""; diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 0f612cece7..75a76ec64a 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -868,7 +868,24 @@ function reporting_get_group_stats ($id_group = 0) { foreach ($id_group as $group){ + $children = groups_get_childrens($group); + //Show empty groups only if they have children with agents + $group_array = array(); + + foreach($children as $sub) { + + array_push($group_array, $sub['id_grupo']); + + } + + //Add id of this group to create the clause + array_push($group_array, $group); + + $group_clause = implode(",",$group_array); + + $group_clause = "(".$group_clause.")"; + switch ($config["dbtype"]) { case "mysql": $data["agents_unknown"] += db_get_sql ("SELECT COUNT(*) @@ -888,7 +905,7 @@ function reporting_get_group_stats ($id_group = 0) { } $data["total_agents"] += db_get_sql ("SELECT COUNT(*) - FROM tagente WHERE id_grupo = $group AND disabled = 0"); + FROM tagente WHERE id_grupo IN $group_clause AND disabled = 0"); $data["monitor_checks"] += db_get_sql ("SELECT COUNT(tagente_estado.id_agente_estado) FROM tagente_estado, tagente, tagente_modulo