#10851 change date order to asc and fix sql query

This commit is contained in:
miguel angel rasteu 2023-05-25 10:30:34 +02:00
parent 9da8e83633
commit cccb03010c
2 changed files with 10 additions and 7 deletions

View File

@ -750,14 +750,16 @@ function inventory_get_datatable(
tagent_module_inventory.*, tagent_module_inventory.*,
tagente.alias as name_agent, tagente.alias as name_agent,
tagente_datos_inventory.utimestamp as last_update, tagente_datos_inventory.utimestamp as last_update,
tagente_datos_inventory.timestamp as last_update_timestamp tagente_datos_inventory.timestamp as last_update_timestamp,
tagente_datos_inventory.data as data_inventory
FROM tmodule_inventory FROM tmodule_inventory
INNER JOIN tagent_module_inventory INNER JOIN tagent_module_inventory
ON tmodule_inventory.id_module_inventory = tagent_module_inventory.id_module_inventory ON tmodule_inventory.id_module_inventory = tagent_module_inventory.id_module_inventory
INNER JOIN tagente_datos_inventory
ON tagent_module_inventory.id_agent_module_inventory = tagente_datos_inventory.id_agent_module_inventory
LEFT JOIN tagente LEFT JOIN tagente
ON tagente.id_agente = tagent_module_inventory.id_agente ON tagente.id_agente = tagent_module_inventory.id_agente
LEFT JOIN tagente_datos_inventory
ON tagent_module_inventory.id_agent_module_inventory = tagente_datos_inventory.id_agent_module_inventory
WHERE %s WHERE %s
ORDER BY tmodule_inventory.id_module_inventory ORDER BY tmodule_inventory.id_module_inventory
LIMIT %d, %d', LIMIT %d, %d',
@ -766,6 +768,8 @@ function inventory_get_datatable(
$config['block_size'] $config['block_size']
); );
hd($sql, true);
$rows = db_get_all_rows_sql($sql); $rows = db_get_all_rows_sql($sql);
if ($order_by_agent === false) { if ($order_by_agent === false) {
@ -775,7 +779,7 @@ function inventory_get_datatable(
$row['timestamp'] = $row['last_update_timestamp']; $row['timestamp'] = $row['last_update_timestamp'];
} }
$data_rows = explode(PHP_EOL, $row['data']); $data_rows = explode(PHP_EOL, $row['data_inventory']);
foreach ($data_rows as $data_key => $data_value) { foreach ($data_rows as $data_key => $data_value) {
if (empty($data_value) === false) { if (empty($data_value) === false) {
$row['data'] = $data_value; $row['data'] = $data_value;

View File

@ -90,13 +90,12 @@ $utimestamps = db_get_all_rows_sql(
FROM tmodule_inventory, tagent_module_inventory, tagente_datos_inventory FROM tmodule_inventory, tagent_module_inventory, tagente_datos_inventory
WHERE tmodule_inventory.id_module_inventory = tagent_module_inventory.id_module_inventory WHERE tmodule_inventory.id_module_inventory = tagent_module_inventory.id_module_inventory
AND tagente_datos_inventory.id_agent_module_inventory = tagent_module_inventory.id_agent_module_inventory AND tagente_datos_inventory.id_agent_module_inventory = tagent_module_inventory.id_agent_module_inventory
AND tagent_module_inventory.%s', AND tagent_module_inventory.%s ORDER BY tagente_datos_inventory.utimestamp DESC',
($module !== 0) ? 'id_module_inventory = '.$module : 'id_agente = '.$id_agente ($module !== 0) ? 'id_module_inventory = '.$module : 'id_agente = '.$id_agente
) )
); );
$utimestamps = (empty($utimestamps) === true) ? [] : extract_column($utimestamps, 'utimestamp'); $utimestamps = (empty($utimestamps) === true) ? [] : extract_column($utimestamps, 'utimestamp');
$utimestampSelectValues = array_reduce( $utimestampSelectValues = array_reduce(
$utimestamps, $utimestamps,
function ($acc, $utimestamp) use ($config) { function ($acc, $utimestamp) use ($config) {
@ -143,7 +142,7 @@ $table->data[0][1] = html_print_label_input_block(
0, 0,
true, true,
false, false,
true, false,
'', '',
false, false,
'width:100%;' 'width:100%;'