diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index f0047e953d..b0c6667d2f 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -240,12 +240,88 @@ function reporting_make_reporting_data($id_report, $date, $time, $report, $content); break; + case 'projection_graph': + $report['contents'][] = reporting_projection_graph( + $report, + $content, + $type, + $force_width_chart, + $force_height_chart); + break; } } return reporting_check_structure_report($report); } +function reporting_projection_graph($report, $content, + $type = 'dinamic', $force_width_chart = null, + $force_height_chart = null) { + + global $config; + + $return['type'] = 'projection_graph'; + + if (empty($content['name'])) { + $content['name'] = __('Agent configuration'); + } + + $return['title'] = $content['name']; + $return["description"] = $content["description"]; + $return["date"] = reporting_get_date_text($report, $content); + + set_time_limit(500); + + $output_projection = forecast_projection_graph( + $content['id_agent_module'], $content['period'], $content['top_n_value']); + + // If projection doesn't have data then don't draw graph + if ($output_projection == NULL) { + $output_projection = false; + } + + // Get chart + reporting_set_conf_charts($width, $height, $only_image, $type, $content); + + if (!empty($force_width_chart)) { + $width = $force_width_chart; + } + + if (!empty($force_height_chart)) { + $height = $force_height_chart; + } + + switch ($type) { + case 'dinamic': + case 'static': + $return['chart'] = graphic_combined_module( + array($content['id_agent_module']), + array(), + $content['period'], + $width, + $height, + 'Projection%20Sample%20Graph', + '', + 0, + 0, + 0, + 0, + $report["datetime"], + true, + ui_get_full_url(false, false, false, false) . '/', + 1, + // Important parameter, this tell to graphic_combined_module function that is a projection graph + $output_projection, + $content['top_n_value'] + ); + break; + case 'data': + break; + } + + return reporting_check_structure_content($return); +} + function reporting_agent_configuration($report, $content) { global $config; diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index c45d7b99f4..cb238ba715 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -173,6 +173,9 @@ function reporting_html_print_report($report, $mini = false) { case 'agent_configuration': reporting_html_agent_configuration($table, $item); break; + case 'projection_graph': + reporting_html_projection_graph($table, $item); + break; } if ($item['type'] == 'agent_module') @@ -185,6 +188,12 @@ function reporting_html_print_report($report, $mini = false) { } } +function reporting_html_projection_graph(&$table, $item) { + $table->colspan['chart']['cell'] = 3; + $table->cellstyle['chart']['cell'] = 'text-align: center;'; + $table->data['chart']['cell'] = $item['chart']; +} + function reporting_html_agent_configuration(&$table, $item) { $table->colspan['agent']['cell'] = 3; $table->cellstyle['agent']['cell'] = 'text-align: left;'; @@ -3354,63 +3363,6 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $item_title = $content['name']; switch ($content["type"]) { - case 'projection_graph': - if (empty($item_title)) { - $item_title = __('Projection graph'); - } - 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); - - $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; - $table->cellstyle[$next_row][0] = 'text-align: center;'; - $data = array (); - - $output_projection = forecast_projection_graph($content['id_agent_module'], $content['period'], $content['top_n_value']); - - // If projection doesn't have data then don't draw graph - if ($output_projection == NULL) { - $output_projection = false; - } - - $modules = array($content['id_agent_module']); - $weights = array(); - $data[0] = graphic_combined_module( - $modules, - $weights, - $content['period'], - $sizgraph_w, $sizgraph_h, - 'Projection%20Sample%20Graph', - '', - 0, - 0, - 0, - 0, - $report["datetime"], - true, - ui_get_full_url(false, false, false, false) . '/', - 1, - // Important parameter, this tell to graphic_combined_module function that is a projection graph - $output_projection, - $content['top_n_value'] - ); - array_push ($table->data, $data); - break; case 'prediction_date': if (empty($item_title)) { $item_title = __('Prediction date');