From 84905a6579ac56ceec92895f2109db678effd4f4 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Wed, 2 Jun 2021 18:39:33 +0200 Subject: [PATCH] minor fixes in report item --- .../reporting_builder.item_editor.php | 12 +++++----- .../include/functions_reporting.php | 22 +++++++++---------- .../include/functions_reporting_html.php | 11 ++++++++-- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 271b440fdf..3d5b1d91d5 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -3141,11 +3141,13 @@ $class = 'databox filters'; @@ -3193,13 +3195,13 @@ $class = 'databox filters'; html_print_select( $fields, - 'agent_status_filter', + 'agent_status_filter[]', $selected_agent_status_filter, '', false, '', false, - false, + true, false, '', false, diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 88b55367bf..ffbd08eec3 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -2298,11 +2298,7 @@ function reporting_agents_inventory($report, $content) } if ($es_os_filter != '') { - $search_sql .= ' AND id_os = '.$es_os_filter; - } - - if ($es_agent_status_filter != '') { - $search_sql .= ' AND tae.estado = '.$es_agent_status_filter; + $search_sql .= ' AND id_os IN ('.implode(',', $es_os_filter).')'; } if ($es_agent_version_filter != '') { @@ -2327,7 +2323,6 @@ function reporting_agents_inventory($report, $content) 'SELECT DISTINCT(tagente.id_agente) AS id_agente, tagente.id_os, tagente.direccion, - tae.estado, tagente.agent_version, tagente.alias, tagente.id_grupo, @@ -2338,12 +2333,6 @@ function reporting_agents_inventory($report, $content) ON tagente.id_agente = tasg.id_agent INNER JOIN tagente_modulo tam ON tam.id_agente = tagente.id_agente - INNER JOIN ( - SELECT * - FROM (SELECT id_agente, estado FROM tagente_estado ORDER BY `utimestamp` DESC) tagente_estado - GROUP BY `id_agente` - ) tae - ON tae.id_agente = tagente.id_agente WHERE (tagente.id_grupo IN (%s) OR tasg.id_group IN (%s)) %s', $user_groups_to_sql, @@ -2403,6 +2392,15 @@ function reporting_agents_inventory($report, $content) $agents[$key]['custom_fields'] = $agent_custom_fields; } + + if (array_search('estado', $es_agents_inventory_display_options) !== false) { + if (in_array(agents_get_status($value['id_agente']), $es_agent_status_filter)) { + $agents[$key]['estado'] = agents_get_status($value['id_agente']); + } else { + // Agent does not match status filter. + unset($agents[$key]); + } + } } foreach ($agents as $key => $value) { diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index d0272447c3..dfdf56825a 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -1535,12 +1535,19 @@ function reporting_html_agents_inventory($table, $item, $pdf=0) foreach ($data as $data_field_key => $data_field_value) { $column_value = $data_field_value; + $show_link = $pdf === 0 ? true : false; + + // Necessary transformations of data prior to represent it. if ($data_field_key === 'id_os') { $column_value = get_os_name((int) $data_field_value); + } else if ($data_field_key === 'remote' && $pdf === 0) { + $column_value = ((int) $data_field_value === 1) ? __('Yes') : __('No'); + } else if ($data_field_key === 'url_address' && $pdf === 0) { + $column_value = ui_print_truncate_text($data_field_value, 10); } else if ($data_field_key === 'estado') { $column_value = ($pdf === 0) ? ui_print_module_status((int) $data_field_value, true) : modules_get_modules_status((int) $data_field_value); } else if ($data_field_key === 'id_grupo') { - $column_value = ui_print_group_icon((int) $data_field_value, true); + $column_value = ui_print_group_icon((int) $data_field_value, true, 'groups_small', '', $show_link); } else if ($data_field_key === 'custom_fields') { $custom_fields_value = []; @@ -1556,7 +1563,7 @@ function reporting_html_agents_inventory($table, $item, $pdf=0) if (is_array($data_field_value)) { foreach ($data_field_value as $value) { - $custom_fields_value[] = ui_print_group_icon((int) $value['id_group'], true); + $custom_fields_value[] = ui_print_group_icon((int) $value['id_group'], true, 'groups_small', '', $show_link); } }