Fixed historical data reports when monitor is type string. Ticket #4125

This commit is contained in:
Arturo Gonzalez 2016-10-21 13:19:47 +02:00
parent 18cfb9d6e2
commit 63da2f60ab
2 changed files with 32 additions and 5 deletions

View File

@ -2236,21 +2236,41 @@ function reporting_historical_data($report, $content) {
$return['keys'] = array(__('Date'), __('Data'));
$result = db_get_all_rows_sql (
$module_type = db_get_value_filter('id_tipo_modulo', 'tagente_modulo',
array('id_agente_modulo' => $content['id_agent_module']));
$result = array();
switch ($module_type) {
case 3:
case 17:
case 23:
case 33:
$result = db_get_all_rows_sql (
'SELECT *
FROM tagente_datos_string
WHERE id_agente_modulo =' . $content['id_agent_module'] . '
AND utimestamp >' . $date_limit . '
AND utimestamp <=' . time()
);
break;
default:
$result = db_get_all_rows_sql (
'SELECT *
FROM tagente_datos
WHERE id_agente_modulo =' . $content['id_agent_module'] . '
AND utimestamp >' . $date_limit . '
AND utimestamp <=' . time()
);
break;
}
$data = array();
foreach ($result as $row) {
$data[] = array(
__('Date') => date ($config["date_format"], $row['utimestamp']),
__('Data') => $row['datos']);
}
$return["data"] = $data;
return reporting_check_structure_content($return);

View File

@ -1238,12 +1238,19 @@ function reporting_html_event_report_agent($table, $item) {
}
function reporting_html_historical_data($table, $item) {
global $config;
$table1->width = '100%';
$table1->head = array (__('Date'), __('Data'));
$table1->data = array ();
foreach ($item['data'] as $data) {
$row = array($data[__('Date')], $data[__('Data')]);
if (!is_numeric($data[__('Data')])) {
$row = array($data[__('Date')], $data[__('Data')]);
}
else {
$row = array($data[__('Date')], remove_right_zeros(number_format($data[__('Data')], $config['graph_precision'])));
}
$table1->data[] = $row;
}