mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 08:45:12 +02:00
Merge branch 'ent-10851-problemas-con-fechas-en-el-inventario' into 'develop'
Ent 10851 problemas con fechas en el inventario See merge request artica/pandorafms!5729
This commit is contained in:
commit
ea24cc8f1b
@ -707,6 +707,17 @@ 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 = [];
|
||||||
@ -741,15 +752,25 @@ function inventory_get_datatable(
|
|||||||
array_push($where, "tagent_module_inventory.data LIKE '%".$inventory_search_string."%'");
|
array_push($where, "tagent_module_inventory.data LIKE '%".$inventory_search_string."%'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($utimestamp > 0) {
|
||||||
|
array_push($where, 'tagente_datos_inventory.utimestamp = '.$utimestamp.' ');
|
||||||
|
}
|
||||||
|
|
||||||
$sql = sprintf(
|
$sql = sprintf(
|
||||||
'SELECT tmodule_inventory.*,
|
'SELECT tmodule_inventory.*,
|
||||||
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.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
|
||||||
|
|
||||||
WHERE %s
|
WHERE %s
|
||||||
ORDER BY tmodule_inventory.id_module_inventory
|
ORDER BY tmodule_inventory.id_module_inventory
|
||||||
LIMIT %d, %d',
|
LIMIT %d, %d',
|
||||||
@ -763,7 +784,11 @@ function inventory_get_datatable(
|
|||||||
if ($order_by_agent === false) {
|
if ($order_by_agent === false) {
|
||||||
$modules = [];
|
$modules = [];
|
||||||
foreach ($rows as $row) {
|
foreach ($rows as $row) {
|
||||||
$data_rows = explode(PHP_EOL, $row['data']);
|
if ($row['utimestamp'] !== $row['last_update']) {
|
||||||
|
$row['timestamp'] = $row['last_update_timestamp'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$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;
|
||||||
@ -781,33 +806,36 @@ function inventory_get_datatable(
|
|||||||
$agent_data[$row['id_agente']][] = $row;
|
$agent_data[$row['id_agente']][] = $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($agent_data as $id_agent => $rows) {
|
foreach ($agent_data as $id_agent => $data_agent) {
|
||||||
$rows_tmp['agent'] = $row['name_agent'];
|
$rows_tmp['agent'] = $data_agent['name_agent'];
|
||||||
foreach ($rows as $row) {
|
foreach ($data_agent as $key => $agent_row) {
|
||||||
|
$data_agent[$key]['timestamp'] = $agent_row['last_update_timestamp'];
|
||||||
|
$data_agent[$key]['utimestamp'] = $agent_row['last_update'];
|
||||||
|
|
||||||
if ($utimestamp > 0) {
|
if ($utimestamp > 0) {
|
||||||
$data_row = db_get_row_sql(
|
$data_row = db_get_row_sql(
|
||||||
sprintf(
|
sprintf(
|
||||||
'SELECT `data`,
|
'SELECT `data`,
|
||||||
`timestamp`
|
`timestamp`,
|
||||||
|
`utimestamp`
|
||||||
FROM tagente_datos_inventory
|
FROM tagente_datos_inventory
|
||||||
WHERE utimestamp <= "%s"
|
WHERE utimestamp = "%s"
|
||||||
AND id_agent_module_inventory = %d
|
AND id_agent_module_inventory = %d
|
||||||
ORDER BY utimestamp DESC',
|
ORDER BY utimestamp DESC',
|
||||||
$utimestamp,
|
$utimestamp,
|
||||||
$row['id_agent_module_inventory']
|
$agent_row['id_agent_module_inventory']
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($data_row !== false) {
|
if ($data_row !== false) {
|
||||||
$row['data'] = $data_row['data'];
|
$data_agent[$key]['data'] = $data_row['data'];
|
||||||
$row['timestamp'] = $data_row['timestamp'];
|
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$rows_tmp['row'] = $rows;
|
$rows_tmp['row'] = $data_agent;
|
||||||
array_push($agents_rows, $rows_tmp);
|
array_push($agents_rows, $rows_tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -963,16 +991,16 @@ function inventory_get_dates($module_inventory_name, $inventory_agent, $inventor
|
|||||||
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 tagente.id_agente = tagent_module_inventory.id_agente';
|
AND tagente.id_agente = tagent_module_inventory.id_agente';
|
||||||
|
|
||||||
if ($inventory_agent != 0) {
|
if ($inventory_agent !== 0) {
|
||||||
$sql .= ' AND tagent_module_inventory.id_agente IN ('."'".implode(',', (array) $inventory_agent)."'".')';
|
$sql .= ' AND tagent_module_inventory.id_agente IN ('."'".implode(',', (array) $inventory_agent)."'".')';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($inventory_id_group != 0) {
|
if ($inventory_id_group !== 0) {
|
||||||
$sql .= " AND tagente.id_grupo = $inventory_id_group";
|
$sql .= " AND tagente.id_grupo = $inventory_id_group";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_string($module_inventory_name) === true
|
if (is_string($module_inventory_name) === true
|
||||||
&& $module_inventory_name != 'all'
|
&& $module_inventory_name !== '0'
|
||||||
) {
|
) {
|
||||||
$sql .= " AND tmodule_inventory.name IN ('".str_replace(',', "','", $module_inventory_name)."')";
|
$sql .= " AND tmodule_inventory.name IN ('".str_replace(',', "','", $module_inventory_name)."')";
|
||||||
}
|
}
|
||||||
|
@ -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%;'
|
||||||
@ -232,7 +231,14 @@ foreach ($rows as $row) {
|
|||||||
$table->cellspacing = 4;
|
$table->cellspacing = 4;
|
||||||
$table->class = 'info_table';
|
$table->class = 'info_table';
|
||||||
$table->head = [];
|
$table->head = [];
|
||||||
$table->head[0] = $row['name'].' - ('.date($config['date_format'], $row['utimestamp']).')';
|
|
||||||
|
if ($row['utimestamp'] === '0' && $utimestamp === 0) {
|
||||||
|
$table->head[0] = $row['name'];
|
||||||
|
} else if ($utimestamp === 0) {
|
||||||
|
$table->head[0] = $row['name'].' - (Last update '.date($config['date_format'], $row['utimestamp']).')';
|
||||||
|
} else {
|
||||||
|
$table->head[0] = $row['name'].' - ('.date($config['date_format'], $utimestamp).')';
|
||||||
|
}
|
||||||
|
|
||||||
if ((bool) $row['block_mode'] === true) {
|
if ((bool) $row['block_mode'] === true) {
|
||||||
$table->head[0] .= ' <a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&tab=inventory&id_agente='.$id_agente.'&utimestamp='.$utimestamp.'&id_agent_module_inventory='.$row['id_agent_module_inventory'].'&diff_view=1">'.html_print_image(
|
$table->head[0] .= ' <a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&tab=inventory&id_agente='.$id_agente.'&utimestamp='.$utimestamp.'&id_agent_module_inventory='.$row['id_agent_module_inventory'].'&diff_view=1">'.html_print_image(
|
||||||
|
@ -675,10 +675,9 @@ $table->data[1][1] = html_print_label_input_block(
|
|||||||
if (is_metaconsole() === false) {
|
if (is_metaconsole() === false) {
|
||||||
$dates = inventory_get_dates(
|
$dates = inventory_get_dates(
|
||||||
$inventory_module,
|
$inventory_module,
|
||||||
$inventory_agent,
|
$inventory_id_agent,
|
||||||
$inventory_id_group
|
$inventory_id_group
|
||||||
);
|
);
|
||||||
|
|
||||||
$table->data[1][2] = html_print_label_input_block(
|
$table->data[1][2] = html_print_label_input_block(
|
||||||
__('Date'),
|
__('Date'),
|
||||||
html_print_select(
|
html_print_select(
|
||||||
@ -690,7 +689,7 @@ if (is_metaconsole() === false) {
|
|||||||
0,
|
0,
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
true,
|
false,
|
||||||
'',
|
'',
|
||||||
false,
|
false,
|
||||||
'width:100%;'
|
'width:100%;'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user