Retorna a lista de serviços que o usuário atende na determinada unidade.

@param Usuario $usuario
@param Unidade $unidade

@return ArrayCollection
15458
public function servicos(Usuario $usuario, Unidade $unidade)
    {
        $servicos = $this->storage
            ->getManager()
            ->createQueryBuilder()
            ->select('e')
            ->from(ServicoUsuario::class, 'e')
            ->join('e.servico', 's')
            ->where('e.usuario = :usuario')
            ->andWhere('e.unidade = :unidade')
            ->andWhere('s.ativo = TRUE')
            ->orderBy('s.nome', 'ASC')
            ->setParameters([
                'usuario' => $usuario,
                'unidade' => $unidade
            ])
            ->getQuery()
            ->getResult();
        
        return $servicos;
    }
999061
public function atendimentoAndamento($usuario, $unidade = null)
    {
        $status = [
            self::CHAMADO_PELA_MESA,
            self::ATENDIMENTO_INICIADO,
        ];
        try {
            $qb = $this->storage
                ->getManager()
                ->createQueryBuilder()
                ->select('e')
                ->from(Atendimento::class, 'e')
                ->where('e.usuario = :usuario')
                ->andWhere('e.status IN (:status)');
            
            $params = [
                'usuario' => $usuario,
                'status' => $status,
            ];
            
            if ($unidade) {
                $qb->andWhere('e.unidade = :unidade');
                $params['unidade'] = $unidade;
            }
            
            return $qb
                ->setParameters($params)
                ->getQuery()
                ->getOneOrNullResult();
        } catch (\Doctrine\ORM\NonUniqueResultException $e) {
            /*
             * caso tenha mais de um atendimento preso ao usuario,
             * libera os atendimentos e retorna null para o atendente chamar de novo.
             * BUG #213
             */
            $this->storage
                ->getManager()
                ->createQueryBuilder()
                ->update(Atendimento::class, 'e')
                ->set('e.status', ':status')
                ->set('e.usuario', ':null')
                ->where('e.usuario = :usuario')
                ->andWhere('e.status IN (:status)')
                ->setParameters([
                    'status'  => 1,
                    'null'    => null,
                    'usuario' => $usuario,
                    'status'  => $status
                ])
                ->getQuery()
                ->execute();

            return;
        }
    }
1026774
public function getList()
    {
        /** @var RcmUserService $rcmUserService */
        $rcmUserService = $this->serviceLocator->get(RcmUserService::class);

        //ACCESS CHECK
        if (!$rcmUserService->isAllowed(
            ResourceName::RESOURCE_SITES,
            'admin'
        )
        ) {
            $this->getResponse()->setStatusCode(Response::STATUS_CODE_401);

            return $this->getResponse();
        }

        /** @var \Rcm\Repository\Country $repo */
        $repo = $this->getEntityManager()->getRepository(\Rcm\Entity\Country::class);

        try {
            $results = $repo->findBy([], ['countryName' => 'ASC']);
        } catch (\Exception $e) {
            return new ApiJsonModel(null, 1, 'An error occurred will getting countries.');
        }

        return new ApiJsonModel($results, 0, 'Success');
    }
876382
public function getReferences($uuid)
    {
        $session = $this->sessionManager->getSession();
        $node = $session->getNodeByIdentifier($uuid);

        return iterator_to_array($node->getReferences());
    }
1256383
public function getWishList(int $userId)
    {
        $response = $this->handler->handle('GET', false, 'wishlist/' . $userId);

        return $this->make($response, true);
    }
742851
public function pull(UnitOfWork $uow)
    {
        $events = [];

        $events = array_merge($events, $this->pullFromEntities($uow->getScheduledEntityDeletions()));
        $events = array_merge($events, $this->pullFromEntities($uow->getScheduledEntityInsertions()));
        $events = array_merge($events, $this->pullFromEntities($uow->getScheduledEntityUpdates()));

        // other entities
        foreach ($uow->getIdentityMap() as $entities) {
            $events = array_merge($events, $this->pullFromEntities($entities));
        }

        return $events;
    }
463968
public function listCollections($includeSystemCollections = false)
    {
        $this->time->start();
        $return = parent::listCollections($includeSystemCollections);
        $time = $this->time->stop();

        $this->log(array(
            'type' => 'listCollections',
            'time' => $time,
        ));

        return $return;
    }
431581
public function index(Request $request, ServicoService $servicoService, SecurityService $securityService)
    {
        $em      = $this->getDoctrine()->getManager();
        $usuario = $this->getUser();
        $unidade = $usuario->getLotacao()->getUnidade();
        
        $prioridades = $em->getRepository(Prioridade::class)->findAtivas();
        $servicos    = $servicoService->servicosUnidade($unidade, ['ativo' => true]);
        
        return $this->render('@NovosgaTriage/default/index.html.twig', [
            'usuario'     => $usuario,
            'unidade'     => $unidade,
            'servicos'    => $servicos,
            'prioridades' => $prioridades,
            'wsSecret'    => $securityService->getWebsocketSecret(),
        ]);
    }
834223
public function getSubCatList()
    {
        if ($this->_oSubCatList === null) {
            $this->_oSubCatList = [];
            if ($this->hasVisibleSubCats()) {
                return $this->_oSubCatList;
            }
        }

        return $this->_oSubCatList;
    }
1093834
public function getTransUnitList(array $locales = null, $rows = 20, $page = 1, array $filters = null)
    {
        $sortColumn = isset($filters['sidx']) ? $filters['sidx'] : 'id';
        $order = isset($filters['sord']) ? $filters['sord'] : 'ASC';

        $sortColumn = ucfirst($sortColumn);

        $query = TransUnitQuery::create()
            ->select('Id')
        ;

        $this->addTransUnitFilters($query, $filters);
        $this->addTranslationFilter($query, $locales, $filters);

        $ids = $query
            ->orderBy($sortColumn, $order)
            ->offset($rows * ($page - 1))
            ->limit($rows)
            ->find($this->getConnection())
        ;

        $transUnits = array();

        if (count($ids) > 0) {
            $unitsData = TransUnitQuery::create()
                ->filterById($ids, Criteria::IN)
                ->joinWith('Translation')
                ->useTranslationQuery()
                    ->filterByLocale($locales, Criteria::IN)
                ->endUse()
                ->orderBy($sortColumn, $order)
                ->setFormatter(ModelCriteria::FORMAT_ARRAY)
                ->find($this->getConnection())
            ;

            $transUnits = $this->filterTransUnitData($unitsData);
        }

        return $transUnits;
    }
1225940
public function createCollection()
    {
        $collectClass = $this->collectionClass();
        if ($collectClass === 'array') {
            return [];
        }

        if (!class_exists($collectClass)) {
            throw new RuntimeException(sprintf(
                'Collection class [%s] does not exist.',
                $collectClass
            ));
        }

        if (!is_subclass_of($collectClass, ArrayAccess::class)) {
            throw new RuntimeException(sprintf(
                'Collection class [%s] must implement ArrayAccess.',
                $collectClass
            ));
        }

        $collection = new $collectClass;

        return $collection;
    }
919072
protected function listSubCategoryOptions()
    {
        $arResult = [];
        $obCategoryList = CategoryCollection::make()->tree();
        if ($obCategoryList->isEmpty()) {
            return $arResult;
        }

        $arResult = $this->getCategoryMenuOptions($obCategoryList);

        return $arResult;
    }
388715
protected function getCatalogsFromResources($locale, $domain) {
		$catalogs = [];
		
		foreach ($this->resources as $resource) {
			$catalogs = array_replace_recursive($catalogs, $resource->getCatalogs($locale, $domain));
		}
		
		return $catalogs;
	}
1181658
public function get($fields = [])
    {
        $fields = empty($fields) ? $this->fields : $fields;

        $this->haveFields($fields);

        $query = $this->createQuery($fields);

        return new ServiceCollection($this->getService(), $this->service->query($query)->getEntries());
    }
88741
private function servicosDisponiveisUnidade($unidade)
    {
        $rs = $this
            ->getDoctrine()
            ->getManager()
            ->createQueryBuilder()
            ->select([
                'e',
                's',
                'sub'
            ])
            ->from(ServicoUnidade::class, 'e')
            ->join('e.servico', 's')
            ->leftJoin('s.subServicos', 'sub')
            ->where('s.mestre IS NULL')
            ->andWhere('e.ativo = TRUE')
            ->andWhere('e.unidade = :unidade')
            ->orderBy('s.nome', 'ASC')
            ->setParameter('unidade', $unidade)
            ->getQuery()
            ->getResult();
        
        $dados = [
            'unidade'  => $unidade->getNome(),
            'servicos' => $rs,
        ];

        return $dados;
    }
713704
public function create($categoryIds, $locale)
    {
        if (empty($categoryIds)) {
            return new Collection();
        }

        // Load category with keywords
        $queryBuilder = $this->categoryRepository->createQueryBuilder('category')
            ->select(['category.id', 'category.key', 'translate.translation as name', 'keyword.keyword'])
            ->leftJoin('category.translations', 'translate', Join::WITH, 'translate.locale = :locale')
            ->setParameter('locale', $locale)
            ->leftJoin('translate.keywords', 'keyword');

        $queryBuilder->where($queryBuilder->expr()->in('category.id', $categoryIds));

        $categories = [];

        foreach ($queryBuilder->getQuery()->getResult() as $categoryData) {
            $id = (int) $categoryData['id'];

            if (!isset($categories[$id])) {
                $categories[$id] = new CategoryViewObject();
                $categories[$id]->id = $id;
                $categories[$id]->key = $categoryData['key'];
                $categories[$id]->name = $categoryData['name'];
            }

            $categories[$id]->keywords[] = $categoryData['keyword'];
        }

        return new Collection(array_values($categories));
    }
981215
def create_usuario_grupo(self):
        """"""
        return UsuarioGrupo(
            self.networkapi_url,
            self.user,
            self.password,
            self.user_ldap)