Working in the refactoring the code of reports (prediction_date).

This commit is contained in:
mdtrooper 2015-04-13 18:15:02 +02:00
parent b3ef779319
commit e5332924b1
2 changed files with 44 additions and 38 deletions

View File

@ -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'];

View File

@ -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).' <br> ' .
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] = '<p style="font: bold '.$sizem.'em Arial, Sans-serif; color: #000000;">'.$value.'</p>';
array_push ($table->data, $data);
break;
case 'simple_baseline_graph':
if (empty($item_title)) {
$item_title = __('Simple baseline graph');