diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index b1dd45e7c9..57206f9a37 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2011-12-15 Juan Manuel Ramon + + * include/functions_forecast.php + include/functions_reporting.php: Added CSV functionality for + projection and prediction reports. + 2011-12-15 Tomas Palacios * include/languages: Updated template, .po and .mo files. diff --git a/pandora_console/include/functions_forecast.php b/pandora_console/include/functions_forecast.php index 08b629ff25..a66700b8f0 100644 --- a/pandora_console/include/functions_forecast.php +++ b/pandora_console/include/functions_forecast.php @@ -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; diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index d83e2c672c..c003d900c5 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -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');