From 995ce673686b2ac1db98a2e83efd248945128e2a Mon Sep 17 00:00:00 2001
From: Jorge Rincon <jorge.rincon@pandorafms.com>
Date: Thu, 8 Jun 2023 09:16:38 +0200
Subject: [PATCH] #11440 Fixed the way to show the information of the actions
 in the alerts

---
 pandora_console/godmode/alerts/alert_view.php | 47 +++++++++++--------
 1 file changed, 27 insertions(+), 20 deletions(-)

diff --git a/pandora_console/godmode/alerts/alert_view.php b/pandora_console/godmode/alerts/alert_view.php
index e8b906b220..17aec8aef0 100644
--- a/pandora_console/godmode/alerts/alert_view.php
+++ b/pandora_console/godmode/alerts/alert_view.php
@@ -326,32 +326,39 @@ if (count($actions) == 1 && isset($actions[0])) {
         }
 
         foreach ($action['escalation'] as $k => $v) {
-            if ($v > 0) {
-                $table->data[$kaction][$k] = html_print_image(
-                    'images/tick.png',
-                    true,
-                    ['class' => 'invert_filter']
-                );
-            } else {
-                $table->data[$kaction][$k] = html_print_image(
-                    'images/blade.png',
-                    true
-                );
-            }
-
-            if (count($table->head) <= count($action['escalation'])) {
-                if ($k == count($action['escalation'])) {
-                    if ($k == 1) {
-                        $table->head[$k] = __('Every time that the alert is fired');
+            if (count($table->head) >= count($action['escalation'])) {
+                if ($k === count($action['escalation'])) {
+                    if ($k === 1) {
+                        $table->head[$kaction] = __('Every time that the alert is fired');
                     } else {
-                        $table->head[$k] = '>#'.($k - 1);
+                        $table->head[$kaction] = '>#'.($kaction - 1);
                     }
                 } else {
-                    $table->head[$k] = '#'.$k;
+                    $table->head[$kaction] = '#'.($kaction);
+                    if ($v > 0) {
+                        $table->data[$kaction][($kaction + 1)] = html_print_image(
+                            'images/tick.png',
+                            true,
+                            ['class' => 'invert_filter']
+                        );
+                    } else {
+                        $table->data[$kkaction][($kaction + 1)] = html_print_image(
+                            'images/blade.png',
+                            true
+                        );
+                    }
                 }
             }
         }
 
+        $table->head[($kaction + 1)] = '#'.($kaction);
+        if (count($action['escalation']) === 0) {
+            $table->data[$kaction][($kaction + 2)] = html_print_image(
+                'images/blade.png',
+                true
+            );
+        }
+
         $action_threshold = ($action['module_action_threshold'] > 0) ? $action['module_action_threshold'] : $action['action_threshold'];
 
         if ($action_threshold == 0) {
@@ -364,7 +371,7 @@ if (count($actions) == 1 && isset($actions[0])) {
             );
         }
 
-        $table->head[($k + 1)] = __('Threshold');
+        $table->head[($kaction + 1)] = __('Threshold');
     }
 }