From 9fa26f9fcbd5094ba60528b58904bb841d01e346 Mon Sep 17 00:00:00 2001 From: danielmaya Date: Tue, 13 Mar 2018 16:40:49 +0100 Subject: [PATCH] Changes in networkmap_links_to_js_links --- .../include/functions_pandora_networkmap.php | 81 ++++++++++++------- 1 file changed, 53 insertions(+), 28 deletions(-) diff --git a/pandora_console/include/functions_pandora_networkmap.php b/pandora_console/include/functions_pandora_networkmap.php index bf05d37bbb..7f01a01090 100644 --- a/pandora_console/include/functions_pandora_networkmap.php +++ b/pandora_console/include/functions_pandora_networkmap.php @@ -731,6 +731,15 @@ function networkmap_links_to_js_links($relations, $nodes_graph) { $agent = agents_get_agent_id_by_module_id($relation['id_parent_source_data']); $agent2 = agents_get_agent_id_by_module_id($relation['id_child_source_data']); + foreach ($nodes_graph as $key2 => $node) { + if(isset($node['id_agent'])) { + if($node['id_agent'] == $agent) { + $agent = $node['id_db']; + } else if ($node['id_agent'] == $agent2) { + $agent2 = $node['id_db']; + } + } + } } else if ($relation['child_type'] == 1) { $mod1_status = db_get_value_filter('estado', 'tagente_estado', array('id_agente_modulo' => $relation['id_child_source_data'])); @@ -742,8 +751,16 @@ function networkmap_links_to_js_links($relations, $nodes_graph) { $item['link_color'] = "#FAD403"; } - $agent = $relation['id_parent_source_data']; $agent2 = agents_get_agent_id_by_module_id($relation['id_child_source_data']); + foreach ($nodes_graph as $key2 => $node) { + if(isset($node['id_agent'])) { + if($node['id_agent'] == $relation['id_parent_source_data']) { + $agent = $node['id_db']; + } else if ($node['id_agent'] == $agent2) { + $agent2 = $node['id_db']; + } + } + } } else if ($relation['parent_type'] == 1) { $mod1_status = db_get_value_filter('estado', 'tagente_estado', array('id_agente_modulo' => $relation['id_parent_source_data'])); @@ -756,59 +773,67 @@ function networkmap_links_to_js_links($relations, $nodes_graph) { } $agent = agents_get_agent_id_by_module_id($relation['id_parent_source_data']); - $agent2 = $relation['id_child_source_data']; + + foreach ($nodes_graph as $key2 => $node) { + if(isset($node['id_agent'])) { + if($node['id_agent'] == $agent) { + $agent = $node['id_db']; + } else if ($node['id_agent'] == $relation['id_child_source_data']) { + $agent2 = $node['id_db']; + } + } + } } else if (($relation['parent_type'] == 3) && ($relation['child_type'] == 3)) { - foreach ($nodes_graph as $key => $node) { + foreach ($nodes_graph as $key2 => $node) { if ($relation['id_parent'] == $node['id_db']) { - $agent = $key; + $agent = $node['id_db']; } } - foreach ($nodes_graph as $key => $node) { + foreach ($nodes_graph as $key2 => $node) { if ($relation['id_child'] == $node['id_db']) { - $agent2 = $key; + $agent2 = $node['id_db']; } } } else if (($relation['parent_type'] == 3) || ($relation['child_type'] == 3)) { if ($relation['parent_type'] == 3) { - foreach ($nodes_graph as $key => $node) { + foreach ($nodes_graph as $key2 => $node) { if ($relation['id_parent'] == $node['id_db']) { - $agent = $key; + $agent = $node['id_db']; + } else if ($node['id_agent'] == $relation['id_child_source_data']) { + $agent2 = $node['id_db']; } } - $agent2 = $relation['id_child_source_data']; } else if ($relation['child_type'] == 3) { - foreach ($nodes_graph as $key => $node) { + foreach ($nodes_graph as $key2 => $node) { if ($relation['id_child'] == $node['id_db']) { - $agent2 = $key; + $agent2 = $node['id_db']; + } else if ($node['id_agent'] == $relation['id_parent_source_data']) { + $agent = $node['id_db']; } } - $agent = $relation['id_parent_source_data']; } } else { - $agent = $relation['id_parent_source_data']; - $agent2 = $relation['id_child_source_data']; + foreach ($nodes_graph as $key2 => $node) { + if(isset($node['id_agent'])) { + if($node['id_agent'] == $relation['id_parent_source_data']) { + $agent = $node['id_db']; + } else if ($node['id_agent'] == $relation['id_child_source_data']) { + $agent2 = $node['id_db']; + } + } + } } foreach ($nodes_graph as $node) { - if (!isset($node['id_agent'])) { - if ($node['id'] == $agent) { - $item['target'] = $node['id']; - } - else if($node['id'] == $agent2) { - $item['source'] = $node['id']; - } + if ($node['id_db'] == $agent) { + $item['target'] = $node['id']; } - else { - if ($node['id_agent'] == $agent) { - $item['target'] = $node['id']; - } - else if ($node['id_agent'] == $agent2) { - $item['source'] = $node['id']; - } + else if($node['id_db'] == $agent2) { + $item['source'] = $node['id']; } } $return[] = $item;