Added search by secondary group name

This commit is contained in:
Daniel Maya 2020-11-16 12:30:58 +01:00
parent 810db1eec4
commit 4023327091

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
@ -207,6 +209,11 @@ if ($searchAgents) {
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 = "
FROM tagente t1 LEFT JOIN tagent_secondary_group tasg
ON t1.id_agente = tasg.id_agent