Merge branch 'ent-5489-Filtrar-desde-SEARCH-GENERAL-grupos-secundarios' into 'develop'

Ent 5489 filtrar desde search general grupos secundarios

See merge request artica/pandorafms!3614
This commit is contained in:
Daniel Rodriguez 2021-01-14 14:46:03 +01:00
commit 18cba9ad84
1 changed files with 14 additions and 7 deletions

View File

@ -179,6 +179,8 @@ if ($searchAgents) {
$userGroups = users_get_groups($config['id_user'], 'AR', false);
$id_userGroups = array_keys($userGroups);
$has_secondary = enterprise_hook('agents_is_using_secondary_groups');
$sql = "SELECT DISTINCT taddress_agent.id_agent FROM taddress
INNER JOIN taddress_agent ON
taddress.id_a = taddress_agent.id_a
@ -188,10 +190,10 @@ if ($searchAgents) {
if ($id != '') {
$aux = $id[0]['id_agent'];
$search_sql = " t1.nombre COLLATE utf8_general_ci LIKE '%%cd ".$stringSearchSQL."%%' OR
t2.nombre COLLATE utf8_general_ci LIKE '%%".$stringSearchSQL."%%' OR
t1.alias COLLATE utf8_general_ci LIKE '%%".$stringSearchSQL."%%' OR
t1.comentarios COLLATE utf8_general_ci LIKE '%%".$stringSearchSQL."%%' OR
t1.id_agente = $aux";
t2.nombre COLLATE utf8_general_ci LIKE '%%".$stringSearchSQL."%%' OR
t1.alias COLLATE utf8_general_ci LIKE '%%".$stringSearchSQL."%%' OR
t1.comentarios COLLATE utf8_general_ci LIKE '%%".$stringSearchSQL."%%' OR
t1.id_agente = $aux";
if (count($id) >= 2) {
for ($i = 1; $i < count($id); $i++) {
@ -201,10 +203,15 @@ if ($searchAgents) {
}
} else {
$search_sql = " t1.nombre COLLATE utf8_general_ci LIKE '%%".$stringSearchSQL."%%' OR
t2.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."%%' OR
t1.comentarios COLLATE utf8_general_ci LIKE '%%".$stringSearchSQL."%%' OR
t1.alias COLLATE utf8_general_ci LIKE '%%".$stringSearchSQL."%%'";
t1.alias COLLATE utf8_general_ci LIKE '%%".$stringSearchSQL."%%'";
}
if ($has_secondary === true) {
$search_sql .= " OR (tasg.id_group IS NOT NULL AND
tasg.id_group IN (SELECT id_grupo FROM tgrupo WHERE nombre COLLATE utf8_general_ci LIKE '%%".$stringSearchSQL."%%'))";
}
$sql = "
@ -235,7 +242,7 @@ if ($searchAgents) {
AND (
".$search_sql.'
)
';
';
$select = 'SELECT DISTINCT(t1.id_agente), t1.ultimo_contacto, t1.nombre, t1.comentarios, t1.id_os, t1.intervalo, t1.id_grupo, t1.disabled, t1.alias, t1.quiet';
if ($only_count) {