From 76cb61f288d536e793a02e435f18bdbe70933293 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Tue, 21 Feb 2017 15:31:20 +0100 Subject: [PATCH] Changes for the merge --- pandora_console/extensions/insert_data.php | 32 ++++++++++++++----- .../agentes/planned_downtime.export_csv.php | 5 ++- .../reporting/graph_builder.graph_editor.php | 5 ++- pandora_console/include/functions_graph.php | 24 +++++++------- pandora_console/include/functions_ui.php | 6 ++-- .../operation/events/events.build_table.php | 6 ++-- pandora_console/pandoradb.sql | 2 +- 7 files changed, 47 insertions(+), 33 deletions(-) diff --git a/pandora_console/extensions/insert_data.php b/pandora_console/extensions/insert_data.php index 3a100115e6..33659b0c71 100644 --- a/pandora_console/extensions/insert_data.php +++ b/pandora_console/extensions/insert_data.php @@ -37,6 +37,7 @@ function createXMLData($agent, $agentModule, $time, $data) { $xml = sprintf($xmlTemplate, io_safe_output(get_os_name($agent['id_os'])), io_safe_output($agent['os_version']), $agent['intervalo'], io_safe_output($agent['agent_version']), $time, + io_safe_output($agent['nombre']), io_safe_output($agent['alias']), $agent['timezone_offset'], io_safe_output($agentModule['nombre']), io_safe_output($agentModule['descripcion']), modules_get_type_name($agentModule['id_tipo_modulo']), $data); @@ -62,6 +63,14 @@ function mainInsertData() { $save = (bool)get_parameter('save', false); $id_agent = (string)get_parameter('id_agent', ''); + + foreach ($_POST as $key => $value) { + if(strpos($key,"agent_autocomplete_idagent")!== false){ + $id_agente = $value; + } + } + + $id_agent_module = (int)get_parameter('id_agent_module', ''); $data = (string)get_parameter('data'); $date = (string) get_parameter('date', date(DATE_FORMAT)); @@ -84,7 +93,8 @@ function mainInsertData() { ui_print_error_message(__('You haven\'t privileges for insert data in the agent.')); } else { - $agent = db_get_row_filter('tagente', array('alias' => $id_agent)); + + $agent = db_get_row_filter('tagente', array('id_agente' => $id_agente)); $agentModule = db_get_row_filter('tagente_modulo', array('id_agente_modulo' => $id_agent_module)); $done = 0; @@ -117,14 +127,14 @@ function mainInsertData() { } if ($errors > 0) { - $msg = sprintf(__('Can\'t save agent (%s), module (%s) data xml.'), $agent['nombre'], $agentModule['nombre']); + $msg = sprintf(__('Can\'t save agent (%s), module (%s) data xml.'), $agent['alias'], $agentModule['nombre']); if ($errors > 1) { $msg .= " ($errors)"; } ui_print_error_message($msg); } if ($done > 0) { - $msg = sprintf(__('Save agent (%s), module (%s) data xml.'), $agent['nombre'], $agentModule['nombre']); + $msg = sprintf(__('Save agent (%s), module (%s) data xml.'), $agent['alias'], $agentModule['nombre']); if ($done > 1) { $msg .= " ($done)"; } @@ -154,14 +164,19 @@ function mainInsertData() { $params['javascript_is_function_select'] = true; $params['javascript_name_function_select'] = 'custom_select_function'; $params['javascript_code_function_select'] = ''; + $params['use_hidden_input_idagent'] = true; + $params['print_hidden_input_idagent'] = true; + $params['hidden_input_idagent_id'] = 'hidden-autocomplete_id_agent'; + $table->data[0][1] = ui_print_agent_autocomplete_input($params); $table->data[1][0] = __('Module'); $modules = array (); - if ($id_agent) - $modules = agents_get_modules ($id_agent, false, array("delete_pending" => 0)); + if ($id_agente){ + $modules = agents_get_modules ($id_agente, false, array("delete_pending" => 0)); + } $table->data[1][1] = html_print_select ($modules, 'id_agent_module', $id_agent_module, true, - __('Select'), 0, true, false, true, '', ($id_agent === '')); + __('Select'), 0, true, false, true, '', ($id_agente === '')); $table->data[2][0] = __('Data'); $table->data[2][1] = html_print_input_text('data', $data, __('Data'), 40, 60, true); $table->data[3][0] = __('Date'); @@ -207,9 +222,10 @@ function mainInsertData() { function custom_select_function(agent_name) { $('#id_agent_module').empty (); - var inputs = []; - inputs.push ("agent_name=" + agent_name); + var id_agent = $('#hidden-autocomplete_id_agent').val(); + + inputs.push ("id_agent=" + id_agent); inputs.push ("delete_pending=0"); inputs.push ("get_agent_modules_json=1"); inputs.push ("page=operation/agentes/ver_agente"); diff --git a/pandora_console/godmode/agentes/planned_downtime.export_csv.php b/pandora_console/godmode/agentes/planned_downtime.export_csv.php index 21d725b2be..5b9a6a06e7 100644 --- a/pandora_console/godmode/agentes/planned_downtime.export_csv.php +++ b/pandora_console/godmode/agentes/planned_downtime.export_csv.php @@ -150,7 +150,7 @@ if (!empty($downtimes)) { $affected_items = array(); - $sql_agents = "SELECT tpda.id_agent AS agent_id, tpda.all_modules AS all_modules, ta.nombre AS agent_name + $sql_agents = "SELECT tpda.id_agent AS agent_id, tpda.all_modules AS all_modules, ta.nombre AS agent_name, ta.alias FROM tplanned_downtime_agents tpda, tagente ta WHERE tpda.id_downtime = $id AND tpda.id_agent = ta.id_agente"; @@ -159,8 +159,7 @@ if (!empty($downtimes)) { if (!empty($downtime_agents)) { foreach ($downtime_agents as $downtime_agent) { $downtime_items = array(); - $alias = db_get_value("alias","tagente","id_agente",$downtime_agent['agent_id']); - $downtime_items[] = $alias; + $downtime_items[] = $downtime_agent[alias]; if (!$downtime_agent['all_modules']) { $agent_id = $downtime_agent['agent_id']; diff --git a/pandora_console/godmode/reporting/graph_builder.graph_editor.php b/pandora_console/godmode/reporting/graph_builder.graph_editor.php index 886bba0b01..cc20e1cfe7 100644 --- a/pandora_console/godmode/reporting/graph_builder.graph_editor.php +++ b/pandora_console/godmode/reporting/graph_builder.graph_editor.php @@ -41,7 +41,7 @@ if (isset ($_GET["get_agent"])) { if ($editGraph) { $graphRows = db_get_all_rows_sql("SELECT t1.*, - (SELECT t3.nombre + (SELECT t3.alias FROM tagente t3 WHERE t3.id_agente = (SELECT t2.id_agente @@ -98,8 +98,7 @@ if (count($module_array) > 0) { $color = 1; } - $alias = db_get_row ('tagente', 'nombre', $agent_array[$a]); - echo "" . $alias['alias'] . ""; + echo "" . $agent_array[$a] . ""; echo ""; echo modules_get_agentmodule_name ($module_array[$a]).""; diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index a3e92f3c1f..795994f618 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -1222,21 +1222,21 @@ function graphic_combined_module ($module_list, $weight_list, $period, else { $agent_name = io_safe_output( modules_get_agentmodule_agent_name ($agent_module_id)); - $alias = db_get_row ('tagente', 'nombre', $agent_name); + $alias = db_get_value ("alias","tagente","nombre",$agent_name); $module_name = io_safe_output( modules_get_agentmodule_name ($agent_module_id)); if ($flash_charts) - $module_name_list[$i] = '' . $alias['alias'] . " / " . $module_name. ''; + $module_name_list[$i] = '' . $alias . " / " . $module_name. ''; else - $module_name_list[$i] = $alias['alias'] . " / " . $module_name; + $module_name_list[$i] = $alias . " / " . $module_name; } } else { //Get and process agent name $agent_name = io_safe_output( modules_get_agentmodule_agent_name ($agent_module_id)); - $alias = db_get_row ('tagente', 'nombre', $agent_name); + $alias = db_get_value ("alias","tagente","nombre",$agent_name); $agent_name = ui_print_truncate_text($agent_name, 'agent_small', false, true, false, '...', false); $agent_id = agents_get_agent_id ($agent_name); @@ -1255,13 +1255,13 @@ function graphic_combined_module ($module_list, $weight_list, $period, else $module_name_list[$i] = '' . - $alias['alias'] . ' / ' . $module_name . ''; + $alias . ' / ' . $module_name . ''; } else { if ($labels[$agent_module_id] != '') $module_name_list[$i] = $labels[$agent_module_id]; else - $module_name_list[$i] = $alias['alias'] . ' / ' . $module_name; + $module_name_list[$i] = $alias . ' / ' . $module_name; } } @@ -1528,8 +1528,8 @@ function graphic_combined_module ($module_list, $weight_list, $period, if ( !empty($labels) && isset($labels[$module]) ){ $label = io_safe_input($labels[$module]); }else{ - $alias = db_get_row ("tagente","id_agente",$temp[$module]['id_agente']); - $label = $alias['alias'] . ': ' . $temp[$module]['nombre']; + $alias = db_get_value ("alias","tagente","id_agente",$temp[$module]['id_agente']); + $label = $alias . ': ' . $temp[$module]['nombre']; } @@ -1597,8 +1597,8 @@ function graphic_combined_module ($module_list, $weight_list, $period, if (!empty($labels) && isset($labels[$module]) ){ $label = $labels[$module]; }else { - $alias = db_get_row ("tagente","id_agente",$module_data['id_agente']); - $label = $alias['alias'] . " - " .$module_data['nombre']; + $alias = db_get_value ("alias","tagente","id_agente",$module_data['id_agente']); + $label = $alias . " - " .$module_data['nombre']; } $temp[$label]['g'] = round($temp_data,4); @@ -1657,8 +1657,8 @@ function graphic_combined_module ($module_list, $weight_list, $period, if ( !empty($labels) && isset($labels[$module]) ){ $label = io_safe_output($labels[$module]); }else { - $alias = db_get_row ("tagente","id_agente",$data_module['id_agente']); - $label = io_safe_output($alias['alias'] . ": " . $data_module['nombre']); + $alias = db_get_value ("alias","tagente","id_agente",$data_module['id_agente']); + $label = io_safe_output($alias . ": " . $data_module['nombre']); } $temp[$label] = array('value'=>$value, diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index d51ccc1895..47e94dc2c8 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -787,7 +787,7 @@ function ui_format_alert_row ($alert, $agent = true, $url = '', $agent_style = f // Get agent id $id_agent = modules_get_agentmodule_agent ($alert['id_agent_module']); - $alias = db_get_row ('tagente', 'id_agente', $id_agent); + $agente = db_get_row ('tagente', 'id_agente', $id_agent); $template = alerts_get_alert_template ($alert['id_alert_template']); $description = io_safe_output($template['name']); @@ -848,10 +848,10 @@ function ui_format_alert_row ($alert, $agent = true, $url = '', $agent_style = f } else { if ($agent_style !== false) { - $data[$index['agent_name']] .=' '.$alias["alias"].''; + $data[$index['agent_name']] .=' '.$agente["alias"].''; } else { - $data[$index['agent_name']] .= ' '.$alias["alias"].''; + $data[$index['agent_name']] .= ' '.$agente["alias"].''; } } diff --git a/pandora_console/operation/events/events.build_table.php b/pandora_console/operation/events/events.build_table.php index 074afcfcfa..7106aa2d0b 100644 --- a/pandora_console/operation/events/events.build_table.php +++ b/pandora_console/operation/events/events.build_table.php @@ -436,9 +436,9 @@ else { } } else { - $alias = db_get_row ("tagente","id_agente",$event["id_agente"]); - $data[$i] .= ''; - $data[$i] .= '' . $alias['alias'] . ''; + $agent = db_get_row ("tagente","id_agente",$event["id_agente"]); + $data[$i] .= ''; + $data[$i] .= '' . $agent['alias'] . ''; } } else { diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index bd74d4010e..f28adb86ae 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -82,7 +82,7 @@ CREATE TABLE IF NOT EXISTS `tagente` ( `fired_count` bigint(20) NOT NULL default '0', `update_module_count` tinyint(1) NOT NULL default '0', `update_alert_count` tinyint(1) NOT NULL default '0', - `alias` varchar(600) NOT NULL default '', + `alias` varchar(600) BINARY NOT NULL default '', `transactional_agent` tinyint(1) NOT NULL default '0', PRIMARY KEY (`id_agente`), KEY `nombre` (`nombre`(255)),