From 4d78b28d1750e5393aa28c81e19638fa7e5e0a31 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 27 Mar 2018 17:53:11 +0200 Subject: [PATCH] [Secondary Groups] Fixed grouped agents events in node --- pandora_console/include/functions_events.php | 49 +++++-------------- .../operation/events/events_list.php | 4 +- 2 files changed, 15 insertions(+), 38 deletions(-) diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 311f705c60..be266be519 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -3306,42 +3306,15 @@ function events_get_events_grouped_by_agent($sql_post, $offset = 0, $groupby_extra = ''; $fields_extra = ''; } - - switch ($config["dbtype"]) { - case "mysql": - if ($total) { - $sql = "SELECT COUNT(*) FROM (select id_agente from $table WHERE 1=1 - $sql_post GROUP BY id_agente, event_type$groupby_extra ORDER BY id_agente ) AS t"; - } - else { - $sql = "select id_agente, count(*) as total$fields_extra from $table te LEFT JOIN tagent_secondary_group tasg - ON te.id_grupo = tasg.id_group - WHERE id_agente > 0 $sql_post GROUP BY id_agente$groupby_extra ORDER BY id_agente LIMIT $offset,$pagination"; - } - break; - case 'postgresql': - if ($total) { - - } - else { - $sql = "select id_agente, count(*) as total$fields_extra from $table - WHERE id_agente > 0 $sql_post GROUP BY id_agente$groupby_extra ORDER BY id_agente LIMIT $offset,$pagination"; - } - break; - case 'oracle': - if ($total) { - - } - else { - $set = array(); - $set['limit'] = $pagination; - $set['offset'] = $offset; - - $sql = "select id_agente, count(*) as total$fields_extra from $table - WHERE id_agente > 0 $sql_post GROUP BY id_agente, event_type$groupby_extra ORDER BY id_agente "; - $sql = oracle_recode_query ($sql, $set); - } - break; + + if ($total) { + $sql = "SELECT COUNT(*) FROM (select id_agente from $table WHERE 1=1 + $sql_post GROUP BY id_agente, event_type$groupby_extra ORDER BY id_agente ) AS t"; + } + else { + $sql = "select id_agente, count(*) as total$fields_extra from $table te LEFT JOIN tagent_secondary_group tasg + ON te.id_grupo = tasg.id_group + WHERE id_agente > 0 $sql_post GROUP BY id_agente$groupby_extra ORDER BY id_agente LIMIT $offset,$pagination"; } $result = array(); @@ -3365,7 +3338,9 @@ function events_get_events_grouped_by_agent($sql_post, $offset = 0, 'event_type' => $resultado['event_type']); } else { - $sql = "select event_type from $table + $sql = "SELECT event_type FROM $table te + LEFT JOIN tagent_secondary_group tasg + ON te.id_agente = tasg.id_agent WHERE id_agente = ".$event['id_agente']." $sql_post ORDER BY utimestamp DESC "; $resultado = db_get_row_sql($sql); diff --git a/pandora_console/operation/events/events_list.php b/pandora_console/operation/events/events_list.php index 5d1bd86f4f..d22ee389ed 100644 --- a/pandora_console/operation/events/events_list.php +++ b/pandora_console/operation/events/events_list.php @@ -829,7 +829,9 @@ if (($config['dbtype'] == 'oracle') && ($result !== false)) { if ($group_rep == 0) { $sql = "SELECT COUNT(id_evento) - FROM $event_table + FROM $event_table te + LEFT JOIN tagent_secondary_group tasg + ON te.id_grupo = tasg.id_group WHERE 1=1 $sql_post"; $total_events = (int) db_get_sql ($sql); }