mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 16:24:54 +02:00
Added search by multiple ips agents. Ticket #3949.
This commit is contained in:
parent
1cfe7d9578
commit
d39123eb0a
@ -338,7 +338,28 @@ switch ($sortField) {
|
|||||||
|
|
||||||
$search_sql = '';
|
$search_sql = '';
|
||||||
if ($search != "") {
|
if ($search != "") {
|
||||||
$search_sql = " AND ( nombre " . $order_collation . " LIKE '%$search%' OR direccion LIKE '%$search%' OR comentarios LIKE '%$search%') ";
|
//$search_sql = " AND ( nombre " . $order_collation . " LIKE '%$search%' OR direccion LIKE '%$search%' OR comentarios 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%') ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show only selected groups
|
// Show only selected groups
|
||||||
|
@ -117,6 +117,29 @@ if ($searchAgents) {
|
|||||||
|
|
||||||
switch ($config["dbtype"]) {
|
switch ($config["dbtype"]) {
|
||||||
case "mysql":
|
case "mysql":
|
||||||
|
$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 '%$stringSearchSQL%'";
|
||||||
|
|
||||||
|
$id = db_get_all_rows_sql($sql);
|
||||||
|
if($id != ''){
|
||||||
|
$aux = $id[0]['id_agent'];
|
||||||
|
$search_sql = " t1.nombre COLLATE utf8_general_ci LIKE '%%" . $stringSearchSQL . "%%' OR
|
||||||
|
t2.nombre COLLATE utf8_general_ci LIKE '%%" . $stringSearchSQL . "%%' OR
|
||||||
|
t1.id_agente = $aux";
|
||||||
|
|
||||||
|
if(count($id)>=2){
|
||||||
|
for ($i = 1; $i < count($id); $i++){
|
||||||
|
$aux = $id[$i]['id_agent'];
|
||||||
|
$search_sql .= " OR t1.id_agente = $aux";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$search_sql = " t1.nombre COLLATE utf8_general_ci LIKE '%%" . $stringSearchSQL . "%%' OR
|
||||||
|
t2.nombre COLLATE utf8_general_ci LIKE '%%" . $stringSearchSQL . "%%' OR
|
||||||
|
t1.direccion COLLATE utf8_general_ci LIKE '%%" . $stringSearchSQL . "%%'";
|
||||||
|
}
|
||||||
$sql = "
|
$sql = "
|
||||||
FROM tagente t1
|
FROM tagente t1
|
||||||
INNER JOIN tgrupo t2
|
INNER JOIN tgrupo t2
|
||||||
@ -140,14 +163,35 @@ if ($searchAgents) {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
AND (
|
AND (
|
||||||
t1.nombre COLLATE utf8_general_ci LIKE '%%" . $stringSearchSQL . "%%' OR
|
".$search_sql."
|
||||||
t2.nombre COLLATE utf8_general_ci LIKE '%%" . $stringSearchSQL . "%%' OR
|
|
||||||
t1.direccion COLLATE utf8_general_ci LIKE '%%" . $stringSearchSQL . "%%'
|
|
||||||
)
|
)
|
||||||
";
|
";
|
||||||
break;
|
break;
|
||||||
case "postgresql":
|
case "postgresql":
|
||||||
case "oracle":
|
case "oracle":
|
||||||
|
$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 '%$stringSearchSQL%'";
|
||||||
|
|
||||||
|
$id = db_get_all_rows_sql($sql);
|
||||||
|
if($id != ''){
|
||||||
|
$aux = $id[0]['id_agent'];
|
||||||
|
$search_sql = " t1.nombre COLLATE utf8_general_ci LIKE '%%" . strtolower($stringSearchSQL) . "%%' OR
|
||||||
|
t2.nombre COLLATE utf8_general_ci LIKE '%%" . strtolower($stringSearchSQL) . "%%' OR
|
||||||
|
t1.id_agente = $aux";
|
||||||
|
|
||||||
|
if(count($id)>=2){
|
||||||
|
for ($i = 1; $i < count($id); $i++){
|
||||||
|
$aux = $id[$i]['id_agent'];
|
||||||
|
$search_sql .= " OR t1.id_agente = $aux";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$search_sql = " lower(t1.nombre) LIKE '%%" . strtolower($stringSearchSQL) . "%%' OR
|
||||||
|
lower(t2.nombre) LIKE '%%" . strtolower($stringSearchSQL) . "%%' OR
|
||||||
|
lower(t1.direccion) LIKE '%%" . strtolower($stringSearchSQL) . "%%'";
|
||||||
|
}
|
||||||
$sql = "
|
$sql = "
|
||||||
FROM tagente t1
|
FROM tagente t1
|
||||||
INNER JOIN tgrupo t2
|
INNER JOIN tgrupo t2
|
||||||
@ -171,9 +215,7 @@ if ($searchAgents) {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
AND (
|
AND (
|
||||||
lower(t1.nombre) LIKE '%%" . strtolower($stringSearchSQL) . "%%' OR
|
".$search_sql."
|
||||||
lower(t2.nombre) LIKE '%%" . strtolower($stringSearchSQL) . "%%' OR
|
|
||||||
lower(t1.direccion) LIKE '%%" . strtolower($stringSearchSQL) . "%%'
|
|
||||||
)
|
)
|
||||||
";
|
";
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user