Merge branch 'ent-11579-vista-de-inventario-no-muestra-nada-filtrando-por-un-modulo-p-e-software' into 'develop'
Ent 11579 vista de inventario no muestra nada filtrando por un modulo p e software See merge request artica/pandorafms!6111
This commit is contained in:
commit
dedbd9e109
|
@ -707,17 +707,6 @@ function inventory_get_datatable(
|
||||||
) {
|
) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if ($utimestamp === 0) {
|
|
||||||
$data_last = db_get_row_sql(
|
|
||||||
sprintf(
|
|
||||||
'SELECT `utimestamp`, `timestamp`
|
|
||||||
FROM tagente_datos_inventory
|
|
||||||
ORDER BY utimestamp DESC'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$utimestamp = $data_last['utimestamp'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$offset = (int) get_parameter('offset');
|
$offset = (int) get_parameter('offset');
|
||||||
|
|
||||||
$where = [];
|
$where = [];
|
||||||
|
@ -753,7 +742,7 @@ function inventory_get_datatable(
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($utimestamp > 0) {
|
if ($utimestamp > 0) {
|
||||||
array_push($where, 'tagente_datos_inventory.utimestamp = '.$utimestamp.' ');
|
array_push($where, 'tagente_datos_inventory.utimestamp <= '.$utimestamp.' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = sprintf(
|
$sql = sprintf(
|
||||||
|
@ -772,13 +761,22 @@ function inventory_get_datatable(
|
||||||
ON tagente.id_agente = tagent_module_inventory.id_agente
|
ON tagente.id_agente = tagent_module_inventory.id_agente
|
||||||
|
|
||||||
WHERE %s
|
WHERE %s
|
||||||
ORDER BY tmodule_inventory.id_module_inventory
|
ORDER BY tmodule_inventory.id_module_inventory
|
||||||
LIMIT %d, %d',
|
',
|
||||||
implode(' AND ', $where),
|
implode(' AND ', $where)
|
||||||
$offset,
|
|
||||||
$config['block_size']
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ($inventory_module_name[0] !== '0'
|
||||||
|
&& $inventory_module_name !== ''
|
||||||
|
&& $inventory_module_name !== 'all'
|
||||||
|
) {
|
||||||
|
$sql .= sprintf(
|
||||||
|
'LIMIT %d, %d',
|
||||||
|
$offset,
|
||||||
|
$config['block_size']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$rows = db_get_all_rows_sql($sql);
|
$rows = db_get_all_rows_sql($sql);
|
||||||
|
|
||||||
if ($order_by_agent === false) {
|
if ($order_by_agent === false) {
|
||||||
|
@ -803,12 +801,29 @@ function inventory_get_datatable(
|
||||||
$agent_data = [];
|
$agent_data = [];
|
||||||
$rows_tmp = [];
|
$rows_tmp = [];
|
||||||
foreach ($rows as $row) {
|
foreach ($rows as $row) {
|
||||||
$agent_data[$row['id_agente']][] = $row;
|
$replace_agent_data = false;
|
||||||
|
if (isset($agent_data[$row['id_agente']]) === true) {
|
||||||
|
foreach ($agent_data[$row['id_agente']] as $key => $compare_data) {
|
||||||
|
if ($compare_data['id_module_inventory'] === $row['id_module_inventory']
|
||||||
|
&& $row['last_update'] > $compare_data['last_update']
|
||||||
|
) {
|
||||||
|
$agent_data[$row['id_agente']][$key] = $row;
|
||||||
|
$replace_agent_data = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($replace_agent_data === false) {
|
||||||
|
$agent_data[$row['id_agente']][] = $row;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($agent_data as $id_agent => $data_agent) {
|
foreach ($agent_data as $id_agent => $data_agent) {
|
||||||
$rows_tmp['agent'] = $data_agent['name_agent'];
|
|
||||||
foreach ($data_agent as $key => $agent_row) {
|
foreach ($data_agent as $key => $agent_row) {
|
||||||
|
if (isset($rows_tmp['agent']) === false) {
|
||||||
|
$rows_tmp['agent'] = $agent_row['name_agent'];
|
||||||
|
}
|
||||||
|
|
||||||
$data_agent[$key]['timestamp'] = $agent_row['last_update_timestamp'];
|
$data_agent[$key]['timestamp'] = $agent_row['last_update_timestamp'];
|
||||||
$data_agent[$key]['utimestamp'] = $agent_row['last_update'];
|
$data_agent[$key]['utimestamp'] = $agent_row['last_update'];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue