2011-12-15 Juan Manuel Ramon <juanmanuel.ramon@artica.es>

* include/functions_forecast.php
	include/functions_reporting.php: Added CSV functionality for 
	projection and prediction reports.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5267 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
juanmanuelr 2011-12-15 15:27:32 +00:00
parent 3c36dfe98d
commit 56cab1cb60
3 changed files with 18 additions and 3 deletions

View File

@ -1,3 +1,9 @@
2011-12-15 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* include/functions_forecast.php
include/functions_reporting.php: Added CSV functionality for
projection and prediction reports.
2011-12-15 Tomas Palacios <tomas.palacios@artica.es>
* include/languages: Updated template, .po and .mo files.

View File

@ -27,10 +27,11 @@
* @param int Period of the prediction or false to use it in prediction_date function (see below).
* @param int Maximun value using this function for prediction_date.
* @param int Minimun value using this function for prediction_date.
* @param bool Result data for CSV file exportation.
*
* @return array Void array or prediction of the module data.
*/
function forecast_projection_graph($module_id, $period = 5184000, $prediction_period, $max_value = false, $min_value = false){
function forecast_projection_graph($module_id, $period = 5184000, $prediction_period, $max_value = false, $min_value = false, $csv = false){
global $config;
$module_data=grafico_modulo_sparse ($module_id, $period, 0,
@ -169,10 +170,17 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe
// Aplying linear regression to module data in order to do the prediction
$output_data = array();
$idx = 0;
// Create data in graph format like
while ($in_range){
$timestamp_f = date($time_format, $current_ts);
$output_data[$timestamp_f] = ($a + ($b * $current_ts));
if ($csv){
$output_data[$idx]['date'] = $current_ts;
$output_data[$idx]['data'] = ($a + ($b * $current_ts));
}
else{
$output_data[$timestamp_f] = ($a + ($b * $current_ts));
}
// Using this function for prediction_date
if ($prediction_period == false){
// This statements stop the prediction when interval is greater than 4 years
@ -188,6 +196,7 @@ function forecast_projection_graph($module_id, $period = 5184000, $prediction_pe
$in_range = false;
}
$current_ts = $current_ts + $agent_interval;
$idx++;
}
return $output_data;

View File

@ -2166,7 +2166,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
$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);
$value = forecast_prediction_date ($content['id_agent_module'], $content['period'], $max_interval, $min_interval);
if ($value === false) {
$value = __('Unknown');