Merge branch 'ent-8277-12706-Lista-de-alertas-no-filtra-correctamente' into 'develop'

Ent 8277 12706 lista de alertas no filtra correctamente

See merge request artica/pandorafms!4539
This commit is contained in:
Daniel Rodriguez 2021-11-26 07:58:38 +00:00
commit 8fac24a469
2 changed files with 16 additions and 35 deletions

View File

@ -34,6 +34,7 @@ require_once $config['homedir'].'/include/functions_modules.php';
require_once $config['homedir'].'/include/functions_users.php';
$pure = get_parameter('pure', 0);
$agent_id = get_parameter('agent_id', 0);
if (defined('METACONSOLE')) {
$sec = 'advanced';
@ -74,6 +75,11 @@ $params['input_name'] = 'agent_name';
$params['value'] = $agentName;
$params['size'] = 24;
$params['metaconsole_enabled'] = false;
$params['use_hidden_input_idagent'] = true;
$params['print_hidden_input_idagent'] = true;
$params['hidden_input_idagent_id'] = 'hidden-autocomplete_id_agent';
$params['hidden_input_idagent_name'] = 'agent_id';
$params['hidden_input_idagent_value'] = $agent_id;
$form_filter .= ui_print_agent_autocomplete_input($params);
@ -234,7 +240,7 @@ if ($searchFlag) {
$id_agents = array_keys($agents);
$total = agents_get_alerts_simple(
$id_agents,
(empty($agent_id) === false) ? ['0' => $agent_id] : $id_agents,
false,
false,
$where,
@ -412,7 +418,7 @@ if ($id_agente) {
$offset = (int) get_parameter('offset');
$simple_alerts = agents_get_alerts_simple(
$id_agents,
(empty($agent_id) === false) ? ['0' => $agent_id] : $id_agents,
false,
[
'offset' => $offset,

View File

@ -421,12 +421,13 @@ function agents_get_alerts_simple($id_agent=false, $filter='', $options=false, $
INNER JOIN tagente_modulo t2
ON talert_template_modules.id_agent_module = t2.id_agente_modulo
INNER JOIN tagente t3
ON t2.id_agente = t3.id_agente
ON t2.id_agente = t3.id_agente %s
%s
INNER JOIN talert_templates t4
ON talert_template_modules.id_alert_template = t4.id
WHERE id_agent_module in (%s) %s %s %s',
$selectText,
($id_agent !== false && is_array($id_agent)) ? 'AND t3.id_agente IN ('.implode(',', $id_agent).')' : '',
$secondary_join,
$subQuery,
$where,
@ -434,40 +435,14 @@ function agents_get_alerts_simple($id_agent=false, $filter='', $options=false, $
$orderbyText
);
switch ($config['dbtype']) {
case 'mysql':
$limit_sql = '';
if (isset($offset) && isset($limit)) {
$limit_sql = " LIMIT $offset, $limit ";
}
$sql = sprintf('%s %s', $sql, $limit_sql);
$alerts = db_get_all_rows_sql($sql);
break;
case 'postgresql':
$limit_sql = '';
if (isset($offset) && isset($limit)) {
$limit_sql = " OFFSET $offset LIMIT $limit ";
}
$sql = sprintf('%s %s', $sql, $limit_sql);
$alerts = db_get_all_rows_sql($sql);
break;
case 'oracle':
$set = [];
if (isset($offset) && isset($limit)) {
$set['limit'] = $limit;
$set['offset'] = $offset;
}
$alerts = oracle_recode_query($sql, $set, 'AND', false);
break;
$limit_sql = '';
if (isset($offset) && isset($limit)) {
$limit_sql = " LIMIT $offset, $limit ";
}
$sql = sprintf('%s %s', $sql, $limit_sql);
$alerts = db_get_all_rows_sql($sql);
if ($alerts === false) {
return [];
}