From 3132fabef9c98bb7ffb756ca07edfe190eae66d2 Mon Sep 17 00:00:00 2001
From: Daniel Cebrian <daniel.cebrian@pandorafms.com>
Date: Wed, 8 Nov 2023 13:36:43 +0100
Subject: [PATCH] #12376 fixed only enabled alerts in tactical view

---
 pandora_console/include/functions_alerts.php                | 6 +++++-
 .../include/lib/TacticalView/elements/Alerts.php            | 2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/pandora_console/include/functions_alerts.php b/pandora_console/include/functions_alerts.php
index 2c738a6578..94dcb97f6c 100644
--- a/pandora_console/include/functions_alerts.php
+++ b/pandora_console/include/functions_alerts.php
@@ -22,7 +22,7 @@ require_once $config['homedir'].'/include/functions_modules.php';
 require_once $config['homedir'].'/include/functions_users.php';
 
 
-function alerts_get_alerts($id_group=0, $free_search='', $status='all', $standby=-1, $acl=false, $total=false, $id_agent=0)
+function alerts_get_alerts($id_group=0, $free_search='', $status='all', $standby=-1, $acl=false, $total=false, $id_agent=0, $only_enabled=false)
 {
     $sql = '';
     $alerts = [];
@@ -121,6 +121,10 @@ function alerts_get_alerts($id_group=0, $free_search='', $status='all', $standby
     // Only enabled agent.
     $sql .= ' AND t3.disabled = 0';
 
+    if ($only_enabled === true) {
+        $sql .= ' AND t0.disabled = 0';
+    }
+
     $row_alerts = db_get_all_rows_sql($sql);
 
     if ($total) {
diff --git a/pandora_console/include/lib/TacticalView/elements/Alerts.php b/pandora_console/include/lib/TacticalView/elements/Alerts.php
index 1c4388e708..44dfb83f4b 100644
--- a/pandora_console/include/lib/TacticalView/elements/Alerts.php
+++ b/pandora_console/include/lib/TacticalView/elements/Alerts.php
@@ -83,7 +83,7 @@ class Alerts extends Element
      */
     public function getActiveAlerts():string
     {
-        $total = alerts_get_alerts(0, '', 'all', -1, 'AR', true);
+        $total = alerts_get_alerts(0, '', 'all', -1, 'AR', true, 0, true);
         return html_print_div(
             [
                 'content' => format_numeric($total, 0),