diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 36c04b89b8..12370f1368 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,13 @@ +2008-06-20 Esteban Sanchez <estebans@artica.es> + + * functions_db.php: Fixed get_agents_in_group() to handle "All" group + properly and make it capable to get disabled agents or not. Style + correction. Fixed a typo in agent_add_address(). + + * godmode/reporting/reporting_builder.php: Use get_agents_in_group() + to get the agents in the group of the report, specially group "All". + Added agent and module column to report content list when applies. + 2008-06-20 Esteban Sanchez <estebans@artica.es> * include/functions_reporting.php: Deleted reference to localhost. Align diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index bf9fc0b4c5..e0741c7c8c 100644 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -190,6 +190,13 @@ if ($id_report) { $report_id_group = $report['id_group']; } +$all_agents = get_agents_in_group ($report_id_group); +$agents = array (); +foreach ($all_agents as $agent) { + $agents[$agent['id_agente']] = $agent['nombre']; +} +asort ($agents); + if ($edit_sla_report_content) { /* Edit SLA report form */ $add_sla = (bool) get_parameter ('add_sla'); @@ -280,9 +287,8 @@ if ($edit_sla_report_content) { $table->size[0] = '150px'; $table->head = array (); $table->style[0] = 'font-weight: bold'; - $sql = sprintf ('SELECT id_agente, nombre FROM tagente WHERE id_grupo = %d ORDER BY nombre', $report_id_group); $table->data[0][0] = lang_string ('agent'); - $table->data[0][1] = print_select_from_sql ($sql, 'id_agent', 0, '', '--', 0, true); + $table->data[0][1] = print_select ($agents, 'id_agent', 0, '', '--', 0, true); $table->data[1][0] = lang_string ('module'); $table->data[1][1] = print_select (array (), 'id_module', 0, '', '--', 0, true); $table->data[2][0] = lang_string ('sla_min'); @@ -387,8 +393,7 @@ if ($edit_sla_report_content) { $table->data[1][1] = print_select ($periods, 'period', 0, '', '--', 0, true); $table->data[2][0] = lang_string ('source_agent'); - $sql = sprintf ('SELECT id_agente, nombre FROM tagente WHERE id_grupo = %d ORDER BY nombre', $report_id_group); - $table->data[2][1] = print_select_from_sql ($sql, 'id_agent', $id_agent, '', '--', 0, true); + $table->data[2][1] = print_select ($agents, 'id_agent', $id_agent, '', '--', 0, true); $table->data[3][0] = lang_string ('module'); $modules = array (); @@ -421,15 +426,16 @@ if ($edit_sla_report_content) { $table->rowstyle = array (); $table->head[0] = lang_string ('order'); $table->head[1] = lang_string ('type'); - $table->head[2] = lang_string ('module'); - $table->head[3] = lang_string ('period'); - $table->head[4] = lang_string ('Options'); + $table->head[2] = lang_string ('agent'); + $table->head[3] = lang_string ('module'); + $table->head[4] = lang_string ('period'); + $table->head[5] = lang_string ('Options'); $table->align = array (); $table->align[0] = 'center'; - $table->align[4] = 'center'; + $table->align[5] = 'center'; if ($report_id_user == $config['id_user']) { - $table->align[5] = 'center'; - $table->head[5] = lang_string ('delete'); + $table->align[6] = 'center'; + $table->head[6] = lang_string ('delete'); } @@ -454,15 +460,18 @@ if ($edit_sla_report_content) { } $data[1] = get_report_name ($report_content['type']); $data[2] = '--'; - if (get_report_type_data_source ($report_content['type']) == 'module') - $data[2] = get_db_value ('descripcion', 'tagente_modulo', 'id_agente_modulo', $report_content['id_agent_module']); - $data[3] = human_time_description ($report_content['period']); - $data[4] = ''; + $data[3] = '--'; + if (get_report_type_data_source ($report_content['type']) == 'module') { + $data[2] = dame_nombre_agente_agentemodulo ($report_content['id_agent_module']); + $data[3] = get_db_value ('descripcion', 'tagente_modulo', 'id_agente_modulo', $report_content['id_agent_module']); + } + $data[4] = human_time_description ($report_content['period']); + $data[5] = ''; if ($report_content['type'] == 'SLA') { - $data[4] = '<a href="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&id_report='.$id_report.'&edit_sla_report_content=1&id_report_content='.$report_content['id_rc'].'"><img src="images/setup.png"></a>'; + $data[5] = '<a href="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&id_report='.$id_report.'&edit_sla_report_content=1&id_report_content='.$report_content['id_rc'].'"><img src="images/setup.png"></a>'; } if ($report_id_user == $config['id_user']) { - $data[5] = '<a href="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&id_report='.$id_report.'&delete_report_content=1&id_report_content='.$report_content['id_rc'].'"><img src="images/cross.png"></a>'; + $data[6] = '<a href="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&id_report='.$id_report.'&delete_report_content=1&id_report_content='.$report_content['id_rc'].'"><img src="images/cross.png"></a>'; } array_push ($table->data, $data); @@ -534,7 +543,7 @@ function agent_changed () { jQuery.ajax ({ data: inputs.join ("&"), type: 'GET', - url: action="ajax.php", + url: "ajax.php", timeout: 10000, dataType: 'json', success: function (data) { diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index bb23997c59..88716f1d6e 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -214,12 +214,25 @@ function give_disabled_group ($id_group) { /** * Get all the agents in a group. * - * @param $id_group Group id + * @param id_group Group id + * @param disabled Add disabled agents to agents. Default: False. * * @return An array with all agents in the group. */ -function get_agents_in_group ($id_group) { - return get_db_all_rows_field_filter ('tagente', 'id_grupo', (int) $id_group); +function get_agents_in_group ($id_group, $disabled = false) { + echo "GROUP: ".$id_group; + /* 'All' group must return all agents */ + if ($id_group == 1) { + if ($disabled) + return get_db_all_rows_in_table ('tagente'); + return get_db_all_rows_field_filter ('tagente', 'disabled', 0); + } + if ($disabled) + return get_db_all_rows_field_filter ('tagente', 'id_grupo', (int) $id_group); + $sql = sprintf ('SELECT * FROM tagente + WHERE id_grupo = %d AND disabled = 0', + $id_group); + return get_db_all_rows_sqlfree ($sql); } /** @@ -942,22 +955,26 @@ function show_icon_type ($id_type) { * @param int Server type id * @return string Fully formatted IMG HTML tag with icon */ - function show_server_type ($id){ - global $config; - switch ($id) { - case 1: return '<img src="images/data.png" title="Pandora FMS Data server">'; - break; - case 2: return '<img src="images/network.png" title="Pandora FMS Network server">'; - break; - case 4: return '<img src="images/plugin.png" title="Pandora FMS Plugin server">'; - break; - case 5: return '<img src="images/chart_bar.png" title="Pandora FMS Prediction server">'; - break; - case 6: return '<img src="images/wmi.png" title="Pandora FMS WMI server">'; - break; - default: return "--"; - } + global $config; + switch ($id) { + case 1: + return '<img src="images/data.png" title="Pandora FMS Data server">'; + break; + case 2: + return '<img src="images/network.png" title="Pandora FMS Network server">'; + break; + case 4: + return '<img src="images/plugin.png" title="Pandora FMS Plugin server">'; + break; + case 5: + return '<img src="images/chart_bar.png" title="Pandora FMS Prediction server">'; + break; + case 6: + return '<img src="images/wmi.png" title="Pandora FMS WMI server">'; + break; + default: return "--"; + } } /** @@ -1023,7 +1040,7 @@ function agent_add_address ($id_agent, $ip_address) { WHERE taddress_agent.id_a = taddress.id_a AND ip = '$ip_address' AND id_agent = $id_agent"; - $current_address = get_db_sql_row ($sql); + $current_address = get_db_row_sql ($sql); if ($current_address) return;