mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-04-08 18:55:09 +02:00
Merge branch 'ent-13331-vista-de-inventario-basico-de-agentes-muestra-deshabilitados' into 'develop'
Ent 13331 Vista de inventario básico de Agentes muestra deshabilitados See merge request artica/pandorafms!7140
This commit is contained in:
commit
d637e7734f
pandora_console
@ -710,7 +710,9 @@ function inventory_get_datatable(
|
||||
$inventory_search_string='',
|
||||
$export_csv=false,
|
||||
$return_mode=false,
|
||||
$order_by_agent=false
|
||||
$order_by_agent=false,
|
||||
$date_init=false,
|
||||
$status_agent=-1,
|
||||
) {
|
||||
global $config;
|
||||
|
||||
@ -737,6 +739,10 @@ function inventory_get_datatable(
|
||||
array_push($where, 'tagent_module_inventory.id_agente IN ('.implode(',', $agents_ids).')');
|
||||
}
|
||||
|
||||
if ($status_agent > -1) {
|
||||
array_push($where, 'tagente.disabled ='.$status_agent);
|
||||
}
|
||||
|
||||
if ($inventory_module_name[0] !== '0'
|
||||
&& $inventory_module_name !== ''
|
||||
&& $inventory_module_name !== 'all'
|
||||
@ -750,21 +756,23 @@ function inventory_get_datatable(
|
||||
}
|
||||
|
||||
if ($utimestamp > 0) {
|
||||
array_push($where, 'tagente_datos_inventory.utimestamp <= '.$utimestamp.' ');
|
||||
array_push($where, 'tagent_module_inventory.utimestamp <= '.$utimestamp.' ');
|
||||
}
|
||||
|
||||
if ($date_init !== false) {
|
||||
array_push($where, 'tagent_module_inventory.utimestamp >= '.$date_init.' ');
|
||||
}
|
||||
|
||||
$sql = sprintf(
|
||||
'SELECT tmodule_inventory.*,
|
||||
tagent_module_inventory.*,
|
||||
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
|
||||
tagent_module_inventory.utimestamp as last_update,
|
||||
tagent_module_inventory.timestamp as last_update_timestamp,
|
||||
tagent_module_inventory.data as data_inventory
|
||||
FROM tmodule_inventory
|
||||
INNER JOIN tagent_module_inventory
|
||||
LEFT JOIN tagent_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
|
||||
ON tagente.id_agente = tagent_module_inventory.id_agente
|
||||
|
||||
@ -884,12 +892,14 @@ function get_data_basic_info_sql($params, $count=false)
|
||||
}
|
||||
|
||||
$where = 'WHERE 1=1 ';
|
||||
if ($params['id_agent'] > 0 && $count === true) {
|
||||
$where .= sprintf(' AND id_agente = %d', $params['id_agent']);
|
||||
} else if ($params['id_agent'] > 0 && $count === false) {
|
||||
if ($params['id_agent'] > 0) {
|
||||
$where .= sprintf(' AND %s.id_agente = %d', $table, $params['id_agent']);
|
||||
}
|
||||
|
||||
if ($params['status'] >= 0) {
|
||||
$where .= sprintf(' AND %s.disabled = %d', $table, $params['status']);
|
||||
}
|
||||
|
||||
if ($params['id_group'] > 0) {
|
||||
$where .= sprintf(' AND id_grupo = %d', $params['id_group']);
|
||||
} else {
|
||||
@ -910,7 +920,7 @@ function get_data_basic_info_sql($params, $count=false)
|
||||
);
|
||||
}
|
||||
|
||||
if ($params['utimestamp'] > 0 && $count === false) {
|
||||
if ($params['utimestamp'] > 0) {
|
||||
$where .= sprintf(
|
||||
' AND utimestamp BETWEEN %d AND %d',
|
||||
($params['utimestamp'] - $params['period']),
|
||||
@ -977,21 +987,20 @@ function get_data_basic_info_sql($params, $count=false)
|
||||
|
||||
$limit_condition = '';
|
||||
$order_condition = '';
|
||||
$fields = 'count(*)';
|
||||
$innerjoin = '';
|
||||
$groupby = '';
|
||||
|
||||
if ($count !== true) {
|
||||
if (is_metaconsole() === true) {
|
||||
$fields = 'tmetaconsole_agent.*, tagent_secondary_group.*, tagent_custom_data.*';
|
||||
} else {
|
||||
$fields = 'tagente.*, tagent_secondary_group.*, tagent_custom_data.*';
|
||||
}
|
||||
if (is_metaconsole() === true) {
|
||||
$fields = 'tmetaconsole_agent.*, tagent_secondary_group.*, tagent_custom_data.*';
|
||||
} else {
|
||||
$fields = 'tagente.*, tagent_secondary_group.*, tagent_custom_data.*';
|
||||
}
|
||||
|
||||
$innerjoin = 'LEFT JOIN tagente_estado ON '.$table.'.id_agente = tagente_estado.id_agente ';
|
||||
$innerjoin .= 'LEFT JOIN tagent_secondary_group ON '.$table.'.id_agente = tagent_secondary_group.id_agent ';
|
||||
$innerjoin .= 'LEFT JOIN tagent_custom_data ON '.$table.'.id_agente = tagent_custom_data.id_agent ';
|
||||
$groupby = 'GROUP BY '.$table.'.id_agente';
|
||||
$innerjoin = 'LEFT JOIN tagente_estado ON '.$table.'.id_agente = tagente_estado.id_agente ';
|
||||
$innerjoin .= 'LEFT JOIN tagent_secondary_group ON '.$table.'.id_agente = tagent_secondary_group.id_agent ';
|
||||
$innerjoin .= 'LEFT JOIN tagent_custom_data ON '.$table.'.id_agente = tagent_custom_data.id_agent ';
|
||||
|
||||
if ($count !== true) {
|
||||
$limit_condition = sprintf(
|
||||
'LIMIT %d, %d',
|
||||
$params['start'],
|
||||
@ -999,8 +1008,12 @@ function get_data_basic_info_sql($params, $count=false)
|
||||
);
|
||||
|
||||
$order_condition = sprintf('ORDER BY %s', $params['order']);
|
||||
} else {
|
||||
$fields = 'COUNT(*)';
|
||||
}
|
||||
|
||||
$groupby = 'GROUP BY '.$table.'.id_agente';
|
||||
|
||||
$sql = sprintf(
|
||||
'SELECT %s
|
||||
FROM %s
|
||||
@ -1018,13 +1031,19 @@ function get_data_basic_info_sql($params, $count=false)
|
||||
$limit_condition
|
||||
);
|
||||
|
||||
$sql_count = sprintf(
|
||||
'SELECT COUNT(*)
|
||||
FROM (%s) AS sub_sql',
|
||||
$sql
|
||||
);
|
||||
|
||||
if ($count !== true) {
|
||||
$result = db_get_all_rows_sql($sql);
|
||||
if ($result === false) {
|
||||
$result = [];
|
||||
}
|
||||
} else {
|
||||
$result = db_get_sql($sql);
|
||||
$result = db_get_sql($sql_count);
|
||||
if ($result === false) {
|
||||
$result = 0;
|
||||
}
|
||||
|
@ -91,6 +91,7 @@ if ($custom_date === '1') {
|
||||
|
||||
$date_init = strtotime($date_init);
|
||||
$utimestamp = strtotime($date_end);
|
||||
$status_agent = (int) get_parameter('status', -1);
|
||||
|
||||
if (is_ajax() === true) {
|
||||
$get_csv_url = (bool) get_parameter('get_csv_url');
|
||||
@ -192,8 +193,9 @@ if (is_ajax() === true) {
|
||||
'order' => $order,
|
||||
'id_agent' => $id_agent,
|
||||
'id_group' => $id_group,
|
||||
'utimestamp' => strtotime($utimestamp),
|
||||
'utimestamp' => $utimestamp,
|
||||
'period' => $period,
|
||||
'status' => $status_agent,
|
||||
];
|
||||
|
||||
$data = get_data_basic_info_sql($params);
|
||||
@ -449,6 +451,8 @@ if ($is_metaconsole === true) {
|
||||
if ($inventory_id_agent > 0) {
|
||||
$sql .= ' AND id_agente = '.$inventory_id_agent;
|
||||
$agents_node = [$inventory_id_agent => $inventory_id_agent];
|
||||
} else {
|
||||
$agents_node = [-1 => true];
|
||||
}
|
||||
|
||||
$result_module = db_get_all_rows_sql($sql);
|
||||
@ -462,8 +466,8 @@ if ($is_metaconsole === true) {
|
||||
$export,
|
||||
false,
|
||||
$order_by_agent,
|
||||
$server,
|
||||
$pagination_url_parameters
|
||||
$date_init,
|
||||
$status_agent
|
||||
);
|
||||
|
||||
$data_tmp['server_name'] = $connection['server_name'];
|
||||
@ -495,6 +499,8 @@ if ($is_metaconsole === true) {
|
||||
if ($inventory_id_agent > 0) {
|
||||
$sql .= ' AND id_agente = '.$inventory_id_agent;
|
||||
$agents_node = [$inventory_id_agent => $inventory_id_agent];
|
||||
} else {
|
||||
$agents_node = [-1 => true];
|
||||
}
|
||||
|
||||
$result = db_get_all_rows_sql($sql);
|
||||
@ -510,8 +516,8 @@ if ($is_metaconsole === true) {
|
||||
$export,
|
||||
false,
|
||||
$order_by_agent,
|
||||
$server,
|
||||
$pagination_url_parameters
|
||||
$date_init,
|
||||
$status_agent
|
||||
);
|
||||
|
||||
$data_tmp['server_name'] = $server['server_name'];
|
||||
@ -764,6 +770,23 @@ if (is_metaconsole() === false) {
|
||||
);
|
||||
}
|
||||
|
||||
$table->data[2][0] = html_print_label_input_block(
|
||||
__('Status agent'),
|
||||
html_print_select(
|
||||
[
|
||||
-1 => __('All'),
|
||||
0 => __('Enabled'),
|
||||
1 => __('Disabled'),
|
||||
],
|
||||
'status',
|
||||
$status_agent,
|
||||
'',
|
||||
'',
|
||||
0,
|
||||
true
|
||||
)
|
||||
);
|
||||
|
||||
$searchForm .= html_print_table($table, true);
|
||||
$searchForm .= html_print_div(
|
||||
[
|
||||
@ -1054,12 +1077,17 @@ if ($inventory_module !== 'basic') {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Single agent selected.
|
||||
if ($inventory_id_agent > 0 && isset($agents[$inventory_id_agent]) === true) {
|
||||
$agents = [$inventory_id_agent => $agents[$inventory_id_agent]];
|
||||
if ($inventory_id_agent > 0) {
|
||||
// Single agent selected.
|
||||
if ($inventory_id_agent > 0 && isset($agents[$inventory_id_agent]) === true) {
|
||||
$agents = [$inventory_id_agent => $agents[$inventory_id_agent]];
|
||||
}
|
||||
|
||||
$agents_ids = array_keys($agents);
|
||||
} else {
|
||||
$agents_ids = [-1];
|
||||
}
|
||||
|
||||
$agents_ids = array_keys($agents);
|
||||
if (count($agents_ids) > 0) {
|
||||
$rows = inventory_get_datatable(
|
||||
$agents_ids,
|
||||
@ -1068,7 +1096,9 @@ if ($inventory_module !== 'basic') {
|
||||
$inventory_search_string,
|
||||
$export,
|
||||
false,
|
||||
$order_by_agent
|
||||
$order_by_agent,
|
||||
$date_init,
|
||||
$status_agent
|
||||
);
|
||||
}
|
||||
|
||||
@ -1355,6 +1385,7 @@ if ($inventory_module !== 'basic') {
|
||||
'id_agent' => $id_agente,
|
||||
'id_group' => $inventory_id_group,
|
||||
'search' => $search,
|
||||
'status' => $status_agent,
|
||||
],
|
||||
'zeroRecords' => __('Agent info not found'),
|
||||
'emptyTable' => __('Agent info not found'),
|
||||
|
Loading…
x
Reference in New Issue
Block a user