Merge branch '1622-filtro-por-grupo-en-mapa-radial-dinamico-dev' into 'develop'

1622 filtro por grupo en mapa radial dinamico dev

See merge request artica/pandorafms!1117
This commit is contained in:
vgilc 2017-11-29 13:24:33 +01:00
commit cf3c9c6ed7
3 changed files with 92 additions and 10 deletions

View File

@ -5802,17 +5802,40 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) {
$filter_module_group = (!empty($filter) && !empty($filter['module_group'])) ? $filter['module_group'] : false; $filter_module_group = (!empty($filter) && !empty($filter['module_group'])) ? $filter['module_group'] : false;
$groups = users_get_groups(false, "AR", false, true, (!empty($filter) && isset($filter['group']) ? $filter['group'] : null)); if ($filter['group'] != 0) {
$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 {
$groups = users_get_groups(false, "AR", false, true, (!empty($filter) && isset($filter['group']) ? $filter['group'] : null));
}
$data_groups = array(); $data_groups = array();
if (!empty($groups)) { if (!empty($groups)) {
$groups_aux = $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);
$groups_aux = null; $groups_aux = null;
} }
if (!empty($data_groups)) { if (!empty($data_groups)) {
$filter = array('id_grupo' => array_keys($data_groups)); $filter = array('id_grupo' => array_keys($data_groups_keys));
$fields = array('id_agente', 'id_parent', 'id_grupo', 'alias'); $fields = array('id_agente', 'id_parent', 'id_grupo', 'alias');
$agents = agents_get_agents($filter, $fields); $agents = agents_get_agents($filter, $fields);
@ -6029,7 +6052,6 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) {
} }
function iterate_group_array ($groups, &$data_agents) { function iterate_group_array ($groups, &$data_agents) {
$data = array(); $data = array();
foreach ($groups as $id => $group) { foreach ($groups as $id => $group) {
@ -6066,8 +6088,8 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) {
$tooltip_content = html_print_image("images/groups_small/" . $group['icon'] . ".png", true) . "&nbsp;" . __('Group') . ": <b>" . $group_aux['name'] . "</b>"; $tooltip_content = html_print_image("images/groups_small/" . $group['icon'] . ".png", true) . "&nbsp;" . __('Group') . ": <b>" . $group_aux['name'] . "</b>";
$group_aux['tooltip_content'] = $tooltip_content; $group_aux['tooltip_content'] = $tooltip_content;
if (!isset($group['children'])) $group_aux['children'] = array();
$group_aux['children'] = array();
if (!empty($group['children'])) if (!empty($group['children']))
$group_aux['children'] = iterate_group_array($group['children'], $data_agents); $group_aux['children'] = iterate_group_array($group['children'], $data_agents);
@ -6075,7 +6097,7 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) {
if (!empty($agents)) if (!empty($agents))
$group_aux['children'] = array_merge($group_aux['children'], $agents); $group_aux['children'] = array_merge($group_aux['children'], $agents);
$data[] = $group_aux; $data[] = $group_aux;
} }
@ -6090,6 +6112,7 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) {
unset($agents[$id]); unset($agents[$id]);
} }
} }
if (!empty($valid_agents)) if (!empty($valid_agents))
return $valid_agents; return $valid_agents;
else else
@ -6097,7 +6120,7 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) {
} }
$graph_data = array('name' => __('Main node'), 'children' => iterate_group_array($data_groups, $data_agents), 'color' => '#3F3F3F'); $graph_data = array('name' => __('Main node'), 'children' => iterate_group_array($data_groups, $data_agents), 'color' => '#3F3F3F');
if (empty($graph_data['children'])) if (empty($graph_data['children']))
return fs_error_image(); return fs_error_image();

View File

@ -2241,6 +2241,9 @@ function groups_get_tree(&$groups, $parent = false) {
if (!empty($children)) { if (!empty($children)) {
$return[$id]['children'] = $children; $return[$id]['children'] = $children;
} }
else {
$return[$id]['children'] = array();
}
} }
else if ($parent && isset($group['parent']) && $group['parent'] == $parent) { else if ($parent && isset($group['parent']) && $group['parent'] == $parent) {
$return[$id] = $group; $return[$id] = $group;
@ -2250,6 +2253,9 @@ function groups_get_tree(&$groups, $parent = false) {
if (!empty($children)) { if (!empty($children)) {
$return[$id]['children'] = $children; $return[$id]['children'] = $children;
} }
else {
$return[$id]['children'] = array();
}
} }
else { else {
continue; continue;
@ -2258,6 +2264,55 @@ function groups_get_tree(&$groups, $parent = false) {
return $return; 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;
if (isset($group['children'])) {
groups_get_tree_keys($groups[$id]['children'], $group_keys);
}
}
}
function groups_get_all_hierarchy_group ($id_group, $hierarchy = array()) { function groups_get_all_hierarchy_group ($id_group, $hierarchy = array()) {
global $config; global $config;
@ -2289,6 +2344,8 @@ function groups_get_all_hierarchy_group ($id_group, $hierarchy = array()) {
return $hierarchy; return $hierarchy;
} }
function group_get_data ($id_user = false, $user_strict = false, $acltags, $returnAllGroup = false, $mode = 'group', $agent_filter = array(), $module_filter = array()) { function group_get_data ($id_user = false, $user_strict = false, $acltags, $returnAllGroup = false, $mode = 'group', $agent_filter = array(), $module_filter = array()) {
global $config; global $config;
if ($id_user == false) { if ($id_user == false) {
@ -3036,4 +3093,5 @@ function groups_get_group_deep ($id_group) {
return $deep; return $deep;
} }
?> ?>

View File

@ -136,8 +136,9 @@ if ($activeTab == "radial_dynamic") {
echo "<div style='width: auto; text-align: center;'>"; echo "<div style='width: auto; text-align: center;'>";
$filter = array(); $filter = array();
if (!empty($group)) if ($networkmap['source'] == 0) {
$filter['group'] = $group; $filter['group'] = $networkmap['source_data'];
}
if (!empty($module_group)) if (!empty($module_group))
$filter['module_group'] = $module_group; $filter['module_group'] = $module_group;