From dd9c2029e20b3c2517a9915b78da983892e9e6cb Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Wed, 5 Aug 2015 14:05:53 +0200 Subject: [PATCH] Added new report item 'historical data' for to get a raw data of module' --- .../reporting_builder.item_editor.php | 15 ++++++ .../include/functions_reporting.php | 50 ++++++++++++++++++- pandora_console/include/functions_reports.php | 4 ++ .../operation/reporting/reporting_viewer.php | 2 + 4 files changed, 69 insertions(+), 2 deletions(-) mode change 100755 => 100644 pandora_console/godmode/reporting/reporting_builder.item_editor.php diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php old mode 100755 new mode 100644 index eb96ff5286..258ede2f16 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -313,6 +313,13 @@ switch ($action) { $idAgentModule = $item['id_agent_module']; $period = $item['period']; break; + case 'historical_data': + $description = $item['description']; + $idAgentModule = $item['id_agent_module']; + $idAgent = db_get_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $idAgentModule)); + $idAgentModule = $item['id_agent_module']; + $period = $item['period']; + break; case 'text': $description = $item['description']; $text = $item['text']; @@ -2302,6 +2309,14 @@ function chooseType() { $("#row_show_in_two_columns").show(); break; + case 'historical_data': + $("#row_description").show(); + $("#row_agent").show(); + $("#row_module").show(); + $("#row_period").show(); + $("#row_show_in_two_columns").show(); + break; + case 'agent_detailed': $("#row_description").show(); $("#row_agent").show(); diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 73555f8f47..48666d04d8 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -3716,6 +3716,8 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $item_title = $content['name']; + + switch ($content["type"]) { case 1: case 'simple_graph': @@ -4013,7 +4015,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $table->colspan[1][0] = 3; $data = array(); - + require_once ($config["homedir"] . '/include/functions_graph.php'); $data[0] = graphic_combined_module( $modules, @@ -4736,6 +4738,50 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $data[0] = '

'.$value.'

'; array_push ($table->data, $data); + break; + case 'historical_data': + if (empty($item_title)) { + $item_title = __('Historical data'); + } + reporting_header_content($mini, $content, $report, $table, $item_title, + ui_print_truncate_text($agent_name, 'agent_medium', false) . + '
' . ui_print_truncate_text($module_name, 'module_medium', false)); + + //RUNNING + + $next_row = 1; + + // Put description at the end of the module (if exists) + if ($content["description"] != "") { + $data_desc = array(); + $data_desc[0] = $content["description"]; + array_push ($table->data, $data_desc); + $table->colspan[$next_row][0] = 3; + $next_row++; + } + + $table->colspan[$next_row][0] = 3; + + $table2->class = 'databox alternate'; + $table2->width = '100%'; + + $table2->head = array(__('Date'), __('Data')); + + $table2->data = array(); + + $datelimit = $report["datetime"] - $content['period']; + + $result = modules_get_raw_data($content['id_agent_module'], + $datelimit, $report["datetime"]); + + foreach ($result as $row) { + $table2->data[] = array( + date ($config["date_format"], $row['utimestamp']), + $row['datos']); + } + + $cellContent = html_print_table($table2, true); + array_push($table->data, array($cellContent)); break; case 10: case 'sumatory': @@ -4760,7 +4806,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f } $table->colspan[$next_row][0] = 3; - + $data = array (); $unit = db_get_value('unit', 'tagente_modulo', 'id_agente_modulo', $content['id_agent_module']); diff --git a/pandora_console/include/functions_reports.php b/pandora_console/include/functions_reports.php index f150599f8e..754c7b0660 100755 --- a/pandora_console/include/functions_reports.php +++ b/pandora_console/include/functions_reports.php @@ -557,6 +557,8 @@ function reports_get_report_types ($template = false, $not_editor = false) { 'name' => __('Serialize data')); $types['sumatory'] = array('optgroup' => __('Modules'), 'name' => __('Summatory')); + $types['historical_data'] = array('optgroup' => __('Modules'), + 'name' => __('Historical Data')); @@ -616,6 +618,8 @@ function reports_get_report_types ($template = false, $not_editor = false) { } } + + if (!$template) { $types['agent_configuration'] = array('optgroup' => __('Configuration'), 'name' => __('Agent configuration')); diff --git a/pandora_console/operation/reporting/reporting_viewer.php b/pandora_console/operation/reporting/reporting_viewer.php index 2079e60401..3c4a0076c3 100755 --- a/pandora_console/operation/reporting/reporting_viewer.php +++ b/pandora_console/operation/reporting/reporting_viewer.php @@ -304,6 +304,8 @@ if ($contents === false) { return; } + + foreach ($contents as $content) { $table->data = array (); $table->head = array ();