From 370f7ff3730d9c5a177f3121185604c1df2e28e9 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Mon, 3 Oct 2016 12:24:15 +0200 Subject: [PATCH] Changed agent name --- .../extensions/resource_exportation.php | 20 ++++++++++--------- .../agentes/planned_downtime.editor.php | 7 ++++--- .../agentes/planned_downtime.export_csv.php | 3 ++- .../reporting_builder.list_items.php | 14 ++++++++----- .../include/functions_reporting_html.php | 14 +++++++++---- .../operation/agentes/exportdata.csv.php | 3 ++- .../operation/agentes/exportdata.excel.php | 3 ++- .../operation/agentes/exportdata.php | 3 ++- .../operation/reporting/reporting_xml.php | 7 +++++++ 9 files changed, 49 insertions(+), 25 deletions(-) diff --git a/pandora_console/extensions/resource_exportation.php b/pandora_console/extensions/resource_exportation.php index 65ecf79940..53cafd0703 100755 --- a/pandora_console/extensions/resource_exportation.php +++ b/pandora_console/extensions/resource_exportation.php @@ -95,12 +95,12 @@ function output_xml_report($id) { echo "" . io_safe_output($item['description']) . "\n"; echo "" . io_safe_output($item['period']) . "\n"; if ($item['id_agent'] != 0) { - $agent = agents_get_name($item['id_agent']); + $agent = db_get_value ("alias","tagente","id_agente",$item['id_agent']); } if ($item['id_agent_module'] != 0) { $module = db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $item['id_agent_module']); $id_agent = db_get_value('id_agente', 'tagente_modulo', 'id_agente_modulo', $item['id_agent_module']); - $agent = agents_get_name($item['id_agent']); + $agent = db_get_value ("alias","tagente","id_agente",$item['id_agent']); echo "\n"; } @@ -138,7 +138,7 @@ function output_xml_report($id) { foreach ($slas as $sla) { $module = db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $sla['id_agent_module']); $id_agent = db_get_value('id_agente', 'tagente_modulo', 'id_agente_modulo', $sla['id_agent_module']); - $agent = agents_get_name($item['id_agent']); + $agent = db_get_value ("alias","tagente","id_agente",$item['id_agent']); echo ""; echo "\n"; echo "\n"; @@ -243,8 +243,14 @@ function output_xml_visual_console($id) { foreach ($items as $item) { echo "\n"; echo "" . $item['id'] . "\n"; //OLD ID USE FOR parent item + $agent = ''; + if ($item['id_agent'] != 0) { + $agent = db_get_value ("alias","tagente","id_agente",$item['id_agent']); + } if (!empty($item['label'])) { - echo "\n"; + $aux = explode("-",$item['label']); + $label = $agent .' -'. $aux[1]; + echo "\n"; } echo "" . $item['pos_x'] . "\n"; echo "" . $item['pos_y'] . "\n"; @@ -261,15 +267,11 @@ function output_xml_visual_console($id) { if ($item['period'] != 0) { echo "" . $item['period'] . "\n"; } - $agent = ''; - if ($item['id_agent'] != 0) { - $agent = agents_get_name($item['id_agent']); - } if (isset($item['id_agente_modulo'])) { if ($item['id_agente_modulo'] != 0) { $module = db_get_value('nombre', 'tagente_modulo', 'id_agente_modulo', $item['id_agente_modulo']); $id_agent = db_get_value('id_agente', 'tagente_modulo', 'id_agente_modulo', $item['id_agente_modulo']); - $agent = agents_get_name($id_agent); + $agent = db_get_value ("alias","tagente","id_agente",$id_agent); echo "\n"; } diff --git a/pandora_console/godmode/agentes/planned_downtime.editor.php b/pandora_console/godmode/agentes/planned_downtime.editor.php index 5ed25e4e2a..f9d1f8cd05 100644 --- a/pandora_console/godmode/agentes/planned_downtime.editor.php +++ b/pandora_console/godmode/agentes/planned_downtime.editor.php @@ -645,7 +645,7 @@ if ($id_downtime > 0) { $filter_cond = ''; if ($filter_group > 0) $filter_cond = " AND id_grupo = $filter_group "; - $sql = sprintf("SELECT tagente.id_agente, tagente.nombre + $sql = sprintf("SELECT tagente.id_agente, tagente.alias FROM tagente WHERE tagente.id_agente NOT IN ( SELECT tagente.id_agente @@ -660,7 +660,7 @@ if ($id_downtime > 0) { $agents = array(); $agent_ids = extract_column($agents, 'id_agente'); - $agent_names = extract_column($agents, 'nombre'); + $agent_names = extract_column($agents, 'alias'); // item[] = ; $agents = array_combine($agent_ids, $agent_names); if ($agents === false) @@ -736,7 +736,8 @@ if ($id_downtime > 0) { foreach ($downtimes_agents as $downtime_agent) { $data = array (); - $data[0] = $downtime_agent['nombre']; + $alias = db_get_value("alias","tagente","id_agente",$downtime_agent['id_agente']); + $data[0] = $alias; $data[1] = db_get_sql ("SELECT nombre FROM tgrupo diff --git a/pandora_console/godmode/agentes/planned_downtime.export_csv.php b/pandora_console/godmode/agentes/planned_downtime.export_csv.php index ea320fddc6..21d725b2be 100644 --- a/pandora_console/godmode/agentes/planned_downtime.export_csv.php +++ b/pandora_console/godmode/agentes/planned_downtime.export_csv.php @@ -159,7 +159,8 @@ if (!empty($downtimes)) { if (!empty($downtime_agents)) { foreach ($downtime_agents as $downtime_agent) { $downtime_items = array(); - $downtime_items[] = $downtime_agent['agent_name']; + $alias = db_get_value("alias","tagente","id_agente",$downtime_agent['agent_id']); + $downtime_items[] = $alias; if (!$downtime_agent['all_modules']) { $agent_id = $downtime_agent['agent_id']; diff --git a/pandora_console/godmode/reporting/reporting_builder.list_items.php b/pandora_console/godmode/reporting/reporting_builder.list_items.php index 3687bc62c8..6f89eb1044 100755 --- a/pandora_console/godmode/reporting/reporting_builder.list_items.php +++ b/pandora_console/godmode/reporting/reporting_builder.list_items.php @@ -87,7 +87,8 @@ else { $agents = array(); foreach ($rows as $row) { - $agents[$row['id_agente']] = $row['nombre']; + $alias = db_get_value ("alias","tagente","id_agente",$row['id_agente']); + $agents[$row['id_agente']] = $alias; } switch ($config['dbtype']) { @@ -372,15 +373,17 @@ foreach ($items as $item) { $agent_name_db = array(); foreach ($agents as $a) { - $agent_name_db[] = agents_get_name($a); + + $alias = db_get_value ("alias","tagente","id_agente",$a); + $agent_name_db[] = $alias; } $agent_name_db = implode('
',$agent_name_db); $module_name_db = implode('
',$modules); } else { - $agent_name_db = agents_get_name(agents_get_agent_id_by_module_id($item['id_agent_module'])); - $agent_name_db = ui_print_truncate_text($agent_name_db, 'agent_small'); + $alias = db_get_value ("alias","tagente","id_agente",agents_get_agent_id_by_module_id($item['id_agent_module'])); + $agent_name_db = '' .$alias . ''; $module_name_db = db_get_value_filter('nombre', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module'])); $module_name_db = ui_print_truncate_text(io_safe_output($module_name_db), 'module_small'); } @@ -390,7 +393,8 @@ foreach ($items as $item) { } } else { - $row[2] = ui_print_truncate_text(agents_get_name($item['id_agent']), 'agent_small'); + $alias = db_get_value ("alias","tagente","id_agente",$item['id_agent']); + $row[2] = '' .$alias . ''; if ($item['id_agent_module'] == '') { $row [3] = ''; diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index bc2e855cfc..d459600d9b 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -121,6 +121,10 @@ function reporting_html_print_report($report, $mini = false) { } else $label = ''; + + $aux = explode("-",$item['subtitle']); + $item['subtitle'] = db_get_value ("alias","tagente","nombre",$item['agent_name']) .' -'. $aux[1]; + reporting_html_header($table, $mini, $item['title'], $item['subtitle'], @@ -738,8 +742,9 @@ function reporting_html_inventory_changes($table, $item) { $table1->data[2][0] = __('Added'); $table1->colspan[2][0] = 2; - - $table1->data = array_merge($table1->data, $module_item['added']); + if (count ($module_item['added'])) { + $table1->data = array_merge($table1->data, $module_item['added']); + } $table1->cellstyle[3 + count($module_item['added'])][0] = @@ -747,8 +752,9 @@ function reporting_html_inventory_changes($table, $item) { $table1->data[3 + count($module_item['added'])][0] = __('Deleted'); $table1->colspan[3 + count($module_item['added'])][0] = 2; - - $table1->data = array_merge($table1->data, $module_item['deleted']); + if (count ($module_item['deleted'])) { + $table1->data = array_merge($table1->data, $module_item['deleted']); + } $table->colspan[ diff --git a/pandora_console/operation/agentes/exportdata.csv.php b/pandora_console/operation/agentes/exportdata.csv.php index 99b44f7f86..df692040e9 100644 --- a/pandora_console/operation/agentes/exportdata.csv.php +++ b/pandora_console/operation/agentes/exportdata.csv.php @@ -138,7 +138,8 @@ if (!empty ($module)) { foreach ($data as $key => $module) { $output .= $rowstart; - $output .= io_safe_output($module['agent_name']); + $alias = db_get_value ("alias","tagente","id_agente",$module['agent_id']); + $output .= io_safe_output($alias); $output .= $divider; $output .= io_safe_output($module['module_name']); $output .= $divider; diff --git a/pandora_console/operation/agentes/exportdata.excel.php b/pandora_console/operation/agentes/exportdata.excel.php index 7957dae886..f289dc1405 100644 --- a/pandora_console/operation/agentes/exportdata.excel.php +++ b/pandora_console/operation/agentes/exportdata.excel.php @@ -137,7 +137,8 @@ if (!empty ($module)) { foreach ($data as $key => $module) { $output .= $rowstart; - $output .= io_safe_output($module['agent_name']); + $alias = db_get_value ("alias","tagente","id_agente",$module['agent_id']); + $output .= io_safe_output($alias); $output .= $divider; $output .= io_safe_output($module['module_name']); $output .= $divider; diff --git a/pandora_console/operation/agentes/exportdata.php b/pandora_console/operation/agentes/exportdata.php index ea5a3caf3c..0532def5f4 100644 --- a/pandora_console/operation/agentes/exportdata.php +++ b/pandora_console/operation/agentes/exportdata.php @@ -160,7 +160,8 @@ if (!empty ($export_btn) && !empty ($module)) { foreach ($data as $key => $module) { $output .= $rowstart; - $output .= io_safe_output($module['agent_name']); + $alias = db_get_value ("alias","tagente","id_agente",$module['agent_id']); + $output .= io_safe_output($alias); $output .= $divider; $output .= io_safe_output($module['module_name']); $output .= $divider; diff --git a/pandora_console/operation/reporting/reporting_xml.php b/pandora_console/operation/reporting/reporting_xml.php index 970b309b5d..42de928c06 100755 --- a/pandora_console/operation/reporting/reporting_xml.php +++ b/pandora_console/operation/reporting/reporting_xml.php @@ -139,6 +139,13 @@ unset($report['private']); unset($report['custom_logo']); //---------------------------------------------------------------------- +//change agent name +if(count($report['contents']) > 0){ + for($i = 0;$i < count($report['contents']); $i++){ + $aux = explode("-",$report['contents'][$i]['subtitle']); + $report['contents'][$i]['subtitle'] = db_get_value ("alias","tagente","nombre",$report['contents'][$i]['agent_name']) .' -'. $aux[1]; + } +} $xml = null; $xml = array2XML($report, "report", $xml);