$query = sprintf("select count(*) from pbx_grupo_usuario where gp_id = (select gp_id from pbx_grupo where gp_nome = 'ADMINISTRADOR') and user_id = '%s'", GetIdUser());
$org_id = GetOrganizacao();
$query = sprintf("SELECT count(*) FROM pbx_grupo_usuario
WHERE gp_id = (SELECT gp_id FROM pbx_grupo WHERE gp_nome = 'ADMINISTRADOR' AND org_id = {$org_id})
AND user_id = '%s'", GetIdUser());
$result = pg_query($query);
$result = pg_query($query);
$row = @pg_fetch_row($result);
$row = @pg_fetch_row($result);
return $row[0] ? true : false;
return $row[0] ? true : false;
@ -601,7 +605,7 @@ function AgenteON($idUser = null)
return pg_num_rows(pg_query($query));
return pg_num_rows(pg_query($query));
} else {
} else {
$query = sprintf("select '' from pbx_supervisor_agentes where matricula = '%s' and ramal = '%s' ", GetMatricula(), GetRamalMonitorar(RAMAL_MONITOR_AGENTE));
$query = sprintf("SELECT '' FROM pbx_supervisor_agentes WHERE matricula = '%s' AND ramal = '%s' ", GetMatricula(), GetRamalMonitorar(RAMAL_MONITOR_AGENTE));