From e5332924b1195697bc304ab10ce184cb219d8160 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Mon, 13 Apr 2015 18:15:02 +0200 Subject: [PATCH] Working in the refactoring the code of reports (prediction_date). --- .../include/functions_reporting.php | 38 +++++++++++++++- .../include/functions_reporting_html.php | 44 +++---------------- 2 files changed, 44 insertions(+), 38 deletions(-) diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index b0c6667d2f..35af131c09 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -248,12 +248,48 @@ function reporting_make_reporting_data($id_report, $date, $time, $force_width_chart, $force_height_chart); break; + case 'prediction_date': + $report['contents'][] = reporting_prediction_date( + $report, + $content); + break; } } return reporting_check_structure_report($report); } +function reporting_prediction_date($report, $content) { + + global $config; + + $return['type'] = 'prediction_date'; + + if (empty($content['name'])) { + $content['name'] = __('Prediction Date'); + } + + $return['title'] = $content['name']; + $return["description"] = $content["description"]; + $return["date"] = reporting_get_date_text($report, $content); + + set_time_limit(500); + + $intervals_text = $content['text']; + $max_interval = substr($intervals_text, 0, strpos($intervals_text, ';')); + $min_interval = substr($intervals_text, strpos($intervals_text, ';') + 1); + $value = forecast_prediction_date ($content['id_agent_module'], $content['period'], $max_interval, $min_interval); + + if ($value === false) { + $return["data"]['value'] = __('Unknown'); + } + else { + $return["data"]['value'] = date ('d M Y H:i:s', $value); + } + + return reporting_check_structure_content($return); +} + function reporting_projection_graph($report, $content, $type = 'dinamic', $force_width_chart = null, $force_height_chart = null) { @@ -263,7 +299,7 @@ function reporting_projection_graph($report, $content, $return['type'] = 'projection_graph'; if (empty($content['name'])) { - $content['name'] = __('Agent configuration'); + $content['name'] = __('Projection Graph'); } $return['title'] = $content['name']; diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index cb238ba715..102ee38e33 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -176,6 +176,9 @@ function reporting_html_print_report($report, $mini = false) { case 'projection_graph': reporting_html_projection_graph($table, $item); break; + case 'prediction_date': + reporting_html_prediction_date($table, $item, $mini); + break; } if ($item['type'] == 'agent_module') @@ -188,6 +191,10 @@ function reporting_html_print_report($report, $mini = false) { } } +function reporting_html_prediction_date($table, $item, $mini) { + reporting_html_value($table, $item, $mini, true); +} + function reporting_html_projection_graph(&$table, $item) { $table->colspan['chart']['cell'] = 3; $table->cellstyle['chart']['cell'] = 'text-align: center;'; @@ -3363,43 +3370,6 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $item_title = $content['name']; switch ($content["type"]) { - case 'prediction_date': - if (empty($item_title)) { - $item_title = __('Prediction date'); - } - 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 - $table->colspan[1][0] = 4; - - set_time_limit(500); - - // Put description at the end of the module (if exists) - $table->colspan[2][0] = 4; - if ($content["description"] != ""){ - $data_desc = array(); - $data_desc[0] = $content["description"]; - array_push ($table->data, $data_desc); - } - - $data = array (); - $table->colspan[2][0] = 3; - $intervals_text = $content['text']; - $max_interval = substr($intervals_text, 0, strpos($intervals_text, ';')); - $min_interval = substr($intervals_text, strpos($intervals_text, ';') + 1); - $value = forecast_prediction_date ($content['id_agent_module'], $content['period'], $max_interval, $min_interval); - - if ($value === false) { - $value = __('Unknown'); - } - else { - $value = date ('d M Y H:i:s', $value); - } - $data[0] = '

'.$value.'

'; - array_push ($table->data, $data); - break; case 'simple_baseline_graph': if (empty($item_title)) { $item_title = __('Simple baseline graph');