From 3f8e0f765a7254a0f632570615fb6e7bf1d8b274 Mon Sep 17 00:00:00 2001
From: Calvo <luis.calvo@pandorafms.com>
Date: Tue, 18 Oct 2022 09:52:08 +0200
Subject: [PATCH] Fix adding agnents planned downtime

---
 .../godmode/agentes/planned_downtime.editor.php    | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/pandora_console/godmode/agentes/planned_downtime.editor.php b/pandora_console/godmode/agentes/planned_downtime.editor.php
index cdd5152bd0..fdb8de3b06 100644
--- a/pandora_console/godmode/agentes/planned_downtime.editor.php
+++ b/pandora_console/godmode/agentes/planned_downtime.editor.php
@@ -1423,9 +1423,19 @@ function insert_downtime_agent($id_downtime, $user_groups_ad)
     } else {
         // If is selected 'Any', get all the agents.
         if (count($agents) === 1 && (int) $agents[0] === -2) {
-            $agents = agents_get_agents(
+            $agents = db_get_all_rows_filter(
+                'tagente',
                 ['id_grupo' => $filter_group],
-                'id_agent'
+                'id_agente'
+            );
+
+            $agents = array_reduce(
+                $agents,
+                function ($carry, $item) {
+                    $carry[] = $item['id_agente'];
+
+                    return $carry;
+                }
             );
         }