Fixed the exportation data with some dates. Ticket #1455

This commit is contained in:
mdtrooper 2014-10-16 16:10:53 +02:00
parent 0f2908c8ea
commit 668a091838
1 changed files with 23 additions and 3 deletions

View File

@ -118,7 +118,7 @@ if (!empty ($export_btn) && !empty ($module)) {
foreach ($module as $selected) { foreach ($module as $selected) {
$output = ""; $output = "";
$work_period = 120000; $work_period = SECONDS_1DAY;
if ($work_period > $period) { if ($work_period > $period) {
$work_period = $period; $work_period = $period;
} }
@ -126,13 +126,16 @@ if (!empty ($export_btn) && !empty ($module)) {
$work_end = $end - $period + $work_period; $work_end = $end - $period + $work_period;
//Buffer to get data, anyway this will report a memory exhaustin //Buffer to get data, anyway this will report a memory exhaustin
$flag_last_time_slice = false;
while ($work_end <= $end) { while ($work_end <= $end) {
$data = array (); // Reinitialize array for each module chunk $data = array (); // Reinitialize array for each module chunk
if ($export_type == "avg") { if ($export_type == "avg") {
$arr = array (); $arr = array ();
$arr["data"] = reporting_get_agentmodule_data_average ($selected, $work_period, $work_end); $arr["data"] =
reporting_get_agentmodule_data_average(
$selected, $work_period, $work_end);
if ($arr["data"] === false) { if ($arr["data"] === false) {
continue; continue;
} }
@ -151,6 +154,8 @@ if (!empty ($export_btn) && !empty ($module)) {
} }
} }
foreach ($data as $key => $module) { foreach ($data as $key => $module) {
$output .= $rowstart; $output .= $rowstart;
$output .= io_safe_output($module['agent_name']); $output .= io_safe_output($module['agent_name']);
@ -174,11 +179,26 @@ if (!empty ($export_btn) && !empty ($module)) {
$output = ""; $output = "";
unset($data); unset($data);
unset($data_single); unset($data_single);
// The last time slice is executed now exit of
// while loop
if ($flag_last_time_slice)
breaK;
if (($work_end + $work_period) > $end) {
// Get the last timelapse
$work_period = $end - $work_end;
$work_end = $end;
$flag_last_time_slice = true;
}
else {
$work_end = $work_end + $work_period; $work_end = $work_end + $work_period;
} }
}
unset ($output); unset ($output);
$output = ""; $output = "";
} // main foreach } // main foreach
echo $dataend; echo $dataend;
break; break;
} }