diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 264ee5be0f..21923f89d2 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -5803,10 +5803,13 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) { $filter_module_group = (!empty($filter) && !empty($filter['module_group'])) ? $filter['module_group'] : false; if ($filter['group'] != 0) { - $groups = db_get_row_sql ("SELECT * FROM tgrupo where id_grupo = " . $filter['group']); - - $groups_ax = array($groups['id_grupo'] => $groups); + $groups = db_get_all_rows_sql ("SELECT * FROM tgrupo where id_grupo = " . $filter['group'] . " || parent = " . $filter['group']); + $groups_ax = array(); + foreach ($groups as $g) { + $groups_ax[$g['id_grupo']] = $g; + } + $groups = $groups_ax; } else { @@ -5817,7 +5820,13 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) { if (!empty($groups)) { $groups_aux = $groups; - $data_groups = groups_get_tree($groups); + //$data_groups = groups_get_tree($groups); + + $childrens = array(); + $data_groups = groups_get_tree_good($groups, false, $childrens); + foreach ($childrens as $id_c) { + unset($data_groups[$id_c]); + } $data_groups_keys = array(); groups_get_tree_keys($data_groups, $data_groups_keys); diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index 869050ac45..db046c09be 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -2265,6 +2265,45 @@ function groups_get_tree(&$groups, $parent = false) { return $return; } +function groups_get_tree_good (&$groups, $parent = false, &$childs) { + $return = array(); + + foreach ($groups as $id => $group) { + if ($group['parent'] != 0) { + $childs[$id] = $id; + } + if ($parent === false && (!isset($group['parent']) || $group['parent'] == 0 || !in_array($group['parent'], $groups))) { + $return[$id] = $group; + //unset($groups[$id]); + $children = groups_get_tree_good($groups, $id); + + if (!empty($children)) { + $return[$id]['children'] = $children; + } + else { + $return[$id]['children'] = array(); + } + } + else if ($parent && isset($group['parent']) && $group['parent'] == $parent) { + $return[$id] = $group; + //unset($groups[$id]); + $children = groups_get_tree_good($groups, $id); + + if (!empty($children)) { + $return[$id]['children'] = $children; + } + else { + $return[$id]['children'] = array(); + } + } + else { + continue; + } + } + + return $return; +} + function groups_get_tree_keys ($groups, &$group_keys) { foreach ($groups as $id => $group) { $group_keys[$id] = $id;