Ejemplo n.º 1
0
 public function listGrid(\Core_Dto_Search $dto)
 {
     $query = $this->_em->createQueryBuilder();
     $query->select('s.sqSistema, s.sgSistema, s.noSistema, s.stRegistroAtivo, a.noArquitetura, r.noPessoa')->from($this->_entityName, 's')->leftJoin('s.sqArquitetura', 'a')->innerJoin('s.sqPessoaResponsavel', 'r')->leftJoin('r.sqPessoaFisica', 'pf');
     if ($dto->hasNoSistema()) {
         $expre = $query->expr()->lower($query->expr()->trim('s.noSistema'));
         $value = "%" . mb_strtolower(trim($dto->getNoSistema()), 'UTF-8') . "%";
         $query->andWhere('(' . $query->expr()->like($expre, ':sistema') . ' OR ' . $query->expr()->like($expre, ':orSistema') . ' OR ' . $query->expr()->like('clear_accentuation(' . $expre . ')', $query->expr()->literal($this->translate($value))) . ')')->setParameter('sistema', $value)->setParameter('orSistema', $this->translate($value));
     }
     if ($dto->hasSistema()) {
         $query->andWhere($query->expr()->eq('s.sqSistema', ':sqSistema'))->setParameter('sqSistema', $dto->getSistema(), 'integer');
     }
     if ($dto->getNoPessoa()) {
         $expre = $query->expr()->lower($query->expr()->trim('r.noPessoa'));
         $value = "%" . mb_strtolower(trim($dto->getNoPessoa()), 'UTF-8') . "%";
         $query->andWhere('(' . $query->expr()->like($expre, ':responsavel') . ' OR ' . $query->expr()->like($expre, ':orResposavel') . ' OR ' . $query->expr()->like('clear_accentuation(' . $expre . ')', $query->expr()->literal($this->translate($value))) . ')')->setParameter('responsavel', $value)->setParameter('orResposavel', $this->translate($value));
     }
     if ($dto->hasSqArquitetura()) {
         $query->andWhere($query->expr()->eq('a.sqArquitetura', ':arquitetura'))->setParameter('arquitetura', $dto->getSqArquitetura(), 'integer');
     }
     if ($dto->hasNuCpf()) {
         $query->andWhere($query->expr()->eq('pf.nuCpf', ':cpf'))->setParameter('cpf', \Zend_Filter::filterStatic($dto->getNuCpf(), 'Digits'), 'integer');
     }
     if ($dto->hasStRegistroAtivo()) {
         $query->andWhere($query->expr()->eq('s.stRegistroAtivo', ':registro'))->setParameter('registro', $dto->getStRegistroAtivo());
     }
     return $query;
 }