diff --git a/pandora_console/include/ajax/alert_list.ajax.php b/pandora_console/include/ajax/alert_list.ajax.php index 4f5b120a6d..89f374a573 100644 --- a/pandora_console/include/ajax/alert_list.ajax.php +++ b/pandora_console/include/ajax/alert_list.ajax.php @@ -228,12 +228,25 @@ if ($get_agent_alerts_agent_view) { } else { $whereAlertSimple .= sprintf( ' AND id_agent_module IN ( - SELECT tam.id_agente_modulo - FROM tagente_modulo tam - WHERE tam.id_agente IN (SELECT ta.id_agente - FROM tagente ta LEFT JOIN tagent_secondary_group tasg ON - ta.id_agente = tasg.id_agent - WHERE (ta.id_grupo IN (%s) OR tasg.id_group IN (%s)))) ', + SELECT tam.id_agente_modulo + FROM tagente_modulo tam + WHERE tam.id_agente IN ( + SELECT + ta.id_agente + FROM + tagente ta + WHERE + ta.id_grupo IN (%s) + ) + OR tam.id_agente IN ( + SELECT + DISTINCT(tasg.id_agent) + FROM + tagent_secondary_group tasg + WHERE + tasg.id_group IN (%s) + ) + ) ', implode(',', $id_groups), implode(',', $id_groups) ); @@ -833,12 +846,20 @@ if ($get_agent_alerts_datatable === true) { } else { $whereAlertSimple .= sprintf( ' AND id_agent_module IN ( - SELECT tam.id_agente_modulo - FROM tagente_modulo tam - WHERE tam.id_agente IN (SELECT ta.id_agente - FROM tagente ta LEFT JOIN tagent_secondary_group tasg ON - ta.id_agente = tasg.id_agent - WHERE (ta.id_grupo IN (%s) OR tasg.id_group IN (%s)))) ', + SELECT tam.id_agente_modulo + FROM tagente_modulo tam + WHERE + tam.id_agente IN ( + SELECT ta.id_agente + FROM tagente ta + WHERE ta.id_grupo IN (%s) + ) + OR tam.id_agente IN ( + SELECT DISTINCT(tasg.id_agent) + FROM tagent_secondary_group tasg + WHERE tasg.id_group IN (%s) + ) + ) ', implode(',', $id_groups), implode(',', $id_groups) ); diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php index 2252ceed07..c9ab918624 100644 --- a/pandora_console/include/functions_alerts.php +++ b/pandora_console/include/functions_alerts.php @@ -2191,15 +2191,19 @@ function get_group_alerts( } else { $subQuery = 'SELECT id_agente_modulo FROM tagente_modulo tam - WHERE delete_pending = 0 AND tam.disabled = 0 - AND id_agente IN (SELECT id_agente - FROM tagente ta - LEFT JOIN tagent_secondary_group tasg - ON ta.id_agente = tasg.id_agent - WHERE ta.disabled = 0 - AND - id_grupo IN ('.implode(',', $id_group).') - OR id_group IN ('.implode(',', $id_group).'))'; + WHERE delete_pending = 0 + AND tam.disabled = 0 + AND id_agente IN ( + SELECT ta.id_agente + FROM tagente ta + WHERE ta.disabled = 0 + AND ta.id_grupo IN ('.implode(',', $id_group).') + ) + OR tam.id_agente IN ( + SELECT DISTINCT(tasg.id_agent) + FROM tagent_secondary_group tasg + WHERE tasg.id_group IN ('.implode(',', $id_group).') + )'; } } else { $subQuery = 'SELECT id_agente_modulo