From b8306bbf00fd58ae8d73c63d91ccc73408c7458c Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Wed, 31 Aug 2016 15:34:05 +0200 Subject: [PATCH] Added search by multiple ips agents. Ticket #3949. --- .../godmode/agentes/modificar_agente.php | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index cd2a85ee62..4096ce1185 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -247,8 +247,27 @@ switch ($sortField) { $search_sql = ''; if ($search != "") { - $search_sql = " AND ( nombre " . $order_collation . " - LIKE '%$search%' OR direccion LIKE '%$search%') "; + $sql = "SELECT DISTINCT taddress_agent.id_agent FROM taddress + INNER JOIN taddress_agent ON + taddress.id_a = taddress_agent.id_a + WHERE taddress.ip LIKE '%$search%'"; + + $id = db_get_all_rows_sql($sql); + if($id != ''){ + $aux = $id[0]['id_agent']; + $search_sql = " AND ( nombre " . $order_collation . " + LIKE '%$search%' OR tagente.id_agente = $aux"; + if(count($id)>=2){ + for ($i = 1; $i < count($id); $i++){ + $aux = $id[$i]['id_agent']; + $search_sql .= " OR tagente.id_agente = $aux"; + } + } + $search_sql .= ")"; + }else{ + $search_sql = " AND ( nombre " . $order_collation . " + LIKE '%$search%') "; + } } if ($disabled == 1)