diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index b9635630a1..165d6fd05f 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -1080,14 +1080,23 @@ function modules_get_agentmodule($id_agentmodule) } -function modules_get_table_data($id_agent_module) +/** + * Gets data table for agent module + * + * @param integer|null $id_agent_module Id agentmodule. + * @param integer|null $id_type Id module type. + * @return void + */ +function modules_get_table_data(?int $id_agent_module, ?int $id_type) { - $id_type = db_get_value( - 'id_tipo_modulo', - 'tagente_modulo', - 'id_agente_modulo', - $id_agent_module - ); + if ($id_type === null) { + $id_type = db_get_value( + 'id_tipo_modulo', + 'tagente_modulo', + 'id_agente_modulo', + $id_agent_module + ); + } $name_type = db_get_value('nombre', 'ttipo_modulo', 'id_tipo', $id_type); diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index a5a13924ba..3879734219 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -4148,16 +4148,17 @@ function reporting_last_value($report, $content, $datetime, $period) $result = $module->getStatus()->toArray(); - if ($result === false) { - $result = []; - $result['utimestamp'] = '-'; + if ($result === false + || $result['estado'] == AGENT_MODULE_STATUS_NO_DATA + || $result['estado'] == AGENT_MODULE_STATUS_NOT_INIT + ) { + $result['utimestamp'] = ''; $result['datos'] = __('No data to display within the selected interval'); } if ($datetime < $result['utimestamp']) { - $table_data = modules_get_table_data($id_agent_module); - - $init_date_condition = ''; + $id_tipo_modulo = $module->id_tipo_modulo(); + $table_data = modules_get_table_data(null, $id_tipo_modulo); if ($period !== null) { $sql = sprintf( 'SELECT datos, utimestamp FROM %s WHERE id_agente_modulo = %d AND utimestamp BETWEEN %d AND %d ORDER BY utimestamp DESC', @@ -4175,7 +4176,8 @@ function reporting_last_value($report, $content, $datetime, $period) ); } - $datos = db_get_row_sql($sql); + $search_in_history_db = db_search_in_history_db($datelimit); + $datos = db_get_row_sql($sql, $search_in_history_db); if ($datos !== false) { $result['datos'] = $datos['datos']; $result['utimestamp'] = $datos['utimestamp'];