From 1c1e25e71261830a6429b8b33132d65fed0e6e30 Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Fri, 14 May 2021 14:54:09 +0200 Subject: [PATCH] Added new item type in reports --- .../reporting_builder.item_editor.php | 155 ++++++++++++++++++ .../include/functions_reporting.php | 13 ++ .../include/functions_reporting_html.php | 63 ++++++- pandora_console/include/functions_reports.php | 5 + 4 files changed, 235 insertions(+), 1 deletion(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index ed52b23aad..c7dd995dbe 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -3020,6 +3020,144 @@ $class = 'databox filters'; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -5223,6 +5361,12 @@ function chooseType() { $("#row_users").hide(); $("#row_profiles_group").hide(); $("#row_select_by_group").hide(); + $("#row_os").hide(); + $("#row_custom_field").hide(); + $("#row_agent_status").hide(); + $("#row_agent_version").hide(); + $("#row_agent_remote_conf").hide(); + $("#row_module_free_search").hide(); // SLA list default state. @@ -5764,6 +5908,17 @@ function chooseType() { break; + case 'agents_inventory': + $("#row_group").show(); + $("#row_os").show(); + $("#row_custom_field").show(); + $("#row_status").show(); + $("#row_agent_version").show(); + $("#row_agent_remote_conf").show(); + $("#row_module_free_search").show(); + + break; + case 'inventory': $("#row_description").show(); $("#row_group").show(); diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index e82bac98ce..93aa30d878 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -734,6 +734,13 @@ function reporting_make_reporting_data( ); break; + case 'agents_inventory': + $report['contents'][] = reporting_agents_inventory( + $report, + $content + ); + break; + case 'inventory': $report['contents'][] = reporting_inventory( $report, @@ -2256,6 +2263,12 @@ function reporting_event_report_module( } +function reporting_agents_inventory($report, $content) +{ + hd($content); +} + + function reporting_inventory_changes($report, $content, $type) { global $config; diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index de800f09d3..211d8b193d 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -247,7 +247,7 @@ function reporting_html_print_report($report, $mini=false, $report_info=1) } $table->colspan['description_row']['description'] = 3; - + hd($item['type']); switch ($item['type']) { case 'availability': default: @@ -377,6 +377,10 @@ function reporting_html_print_report($report, $mini=false, $report_info=1) reporting_html_agent_module($table, $item); break; + case 'agents_inventory': + reporting_html_agents_inventory($table, $item); + break; + case 'inventory': reporting_html_inventory($table, $item); break; @@ -1425,6 +1429,63 @@ function reporting_html_event_report_module($table, $item, $pdf=0) } +/** + * Print in html agents inventory + * + * @param object $table Head table or false if it comes from pdf. + * @param array $item Items data. + * @param boolean $pdf Print pdf true or false. + * + * @return html + */ +function reporting_html_agents_inventory($table, $item, $pdf=0) +{ + hd('agents inventory'); + hd($item); + + global $config; + + if (empty($item['data']) === false) { + $table_data = new stdClass(); + $table_data->width = '100%'; + $table_data->headstyle = []; + $table_data->headstyle[0] = 'text-align: left;'; + $table_data->style = []; + $table_data->style[0] = 'text-align: left;'; + $table_data->head = [ + __('Name'), + __('Date'), + __('Data'), + __('Status'), + ]; + + $table_data->data = []; + $table_data->data[1][0] = $item['data']['agent_name']; + $table_data->data[1][0] .= ' / '; + $table_data->data[1][0] .= $item['data']['module_name']; + + $table_data->data[1][1] = date( + 'Y-m-d H:i:s', + $item['data']['utimestamp'] + ); + } + + if ($pdf === 0) { + $table->colspan['last_value']['cell'] = 3; + $table->cellstyle['last_value']['cell'] = 'text-align: center;'; + $table->data['last_value']['cell'] = html_print_table( + $table_data, + true + ); + } else { + return html_print_table( + $table_data, + true + ); + } +} + + /** * Print in html inventory changes reports * diff --git a/pandora_console/include/functions_reports.php b/pandora_console/include/functions_reports.php index fbf647d392..71fa925ba5 100755 --- a/pandora_console/include/functions_reports.php +++ b/pandora_console/include/functions_reports.php @@ -848,6 +848,11 @@ function reports_get_report_types($template=false, $not_editor=false) 'name' => __('Group event report'), ]; + $types['agents_inventory'] = [ + 'optgroup' => __('Inventory'), + 'name' => __('Agents inventory'), + ]; + if ($config['enterprise_installed']) { $types['inventory'] = [ 'optgroup' => __('Inventory'),