Added changes to get all hierachy to the chart

This commit is contained in:
Arturo Gonzalez 2017-11-24 12:08:15 +01:00
parent 06f83825dc
commit 2883e45849
2 changed files with 52 additions and 4 deletions

View File

@ -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);

View File

@ -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;