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); $userGroups = users_get_groups($config['id_user'], 'AR', false);
$id_userGroups = array_keys($userGroups); $id_userGroups = array_keys($userGroups);
$has_secondary = enterprise_hook('agents_is_using_secondary_groups');
$sql = "SELECT DISTINCT taddress_agent.id_agent FROM taddress $sql = "SELECT DISTINCT taddress_agent.id_agent FROM taddress
INNER JOIN taddress_agent ON INNER JOIN taddress_agent ON
taddress.id_a = taddress_agent.id_a taddress.id_a = taddress_agent.id_a
@ -207,6 +209,11 @@ if ($searchAgents) {
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 = " $sql = "
FROM tagente t1 LEFT JOIN tagent_secondary_group tasg FROM tagente t1 LEFT JOIN tagent_secondary_group tasg
ON t1.id_agente = tasg.id_agent ON t1.id_agente = tasg.id_agent