/** * método para persistencia - Grau de Acesso * @param \Core_Dto_Search $dto */ public function alterarArtefato($dto) { $sqTipoDocumento = $this->_getRepository('app:TipoDocumento')->find($dto->getSqTipoDocumento()); $criteria = array('sqAssunto' => $dto->getSqAssunto(), 'sqTipoArtefato' => \Core_Configuration::getSgdoceTipoArtefatoDossie()); $sqTipoArtefatoAssunto = $this->_getRepository('app:TipoArtefatoAssunto')->findBy($criteria); $entity = $this->_getRepository('app:Artefato')->find($dto->getSqArtefato()); $entity->setNuArtefato($dto->getNuArtefato()); $entity->setSqTipoDocumento($sqTipoDocumento); $entity->setTxAssuntoComplementar($dto->getTxAssuntoComplementar()); $entity->setSqTipoArtefatoAssunto($this->_getRepository('app:TipoArtefatoAssunto')->find($sqTipoArtefatoAssunto[0]->getSqTipoArtefatoAssunto())); $entityArtefatoDossie = $this->_getRepository('app:ArtefatoDossie')->find($dto->getSqArtefato()); if (!$entityArtefatoDossie) { $entityArtefatoDossie = new \Sgdoce\Model\Entity\ArtefatoDossie(); } $entityArtefatoDossie->setNoTitulo($dto->getNoTitulo()); $entityArtefatoDossie->setTxObservacao($dto->getTxObservacao()); $entityArtefatoDossie->setSqArtefato($entity); $this->getEntityManager()->persist($entityArtefatoDossie); $this->getEntityManager()->flush($entityArtefatoDossie); //Persistir PessoaAssinanteArtefato $this->persistPessoaAssinanteArtefato($entity, $dto); self::_salvaOrigem($entity, $dto); // RN - Caso não exista Grau de Acesso ao Artefato sera por default publico(1) if (!$dto->getSqGrauAcesso()) { $data = array('sqGrauAcesso' => \Core_Configuration::getSgdoceGrauAcessoPublico()); $dto = new \Core_Dto_Mapping($data, array_keys($data)); $sqGrauAcesso = $this->_getRepository('app:GrauAcesso')->find($dto->getSqGrauAcesso()); } else { $sqGrauAcesso = $this->_getRepository('app:GrauAcesso')->find($dto->getSqGrauAcesso()); } // realizando a persistencia do Grau de Acesso $test = $this->persistGrauAcessoArtefato($entity, $sqGrauAcesso); $this->getEntityManager()->persist($entity); $this->getEntityManager()->flush($entity); }
/** * Obtém modelo documento assunto * @param \Core_Dto_Search $dtoSearch * @return array */ public function getModeloDocAssunto(\Core_Dto_Search $dtoSearch) { $queryBuilder = $this->_em->createQueryBuilder(); $queryBuilder->select('pmd.noPadraoModeloDocumento', 'c.noCampo', 'c.noColunaTabela', 'gp.sqGrupoCampo', 'pmdc.inObrigatorio')->from('app:ModeloDocumentoCampo', 'mdc')->innerJoin('mdc.sqPadraoModeloDocumentoCam', 'pmdc')->innerJoin('pmdc.sqPadraoModeloDocumento', 'pmd')->innerJoin('pmdc.sqCampo', 'c')->innerJoin('c.sqGrupoCampo', 'gp')->innerJoin('mdc.sqModeloDocumento', 'md'); $queryBuilder->andWhere('md.sqTipoDocumento = :sqTipoDocumento')->setParameter('sqTipoDocumento', $dtoSearch->getSqTipoDocumento()); $queryBuilder->andWhere('md.inAtivo = :inAtivo')->setParameter('inAtivo', "TRUE"); return $queryBuilder->getQuery()->execute(); }
/** * Verifica a existencia do cadastro de um modelo * @param \Core_Dto_Search $dtoSearch,$result * @return array */ public function hasModeloDocumentoCadastrado(\Core_Dto_Search $dtoSearch, $result = FALSE) { $queryBuilder = $this->_em->createQueryBuilder()->select('md.sqModeloDocumento')->from('app:ModeloDocumento', 'md')->andWhere('md.sqTipoDocumento = :sqTipoDocumento')->andWhere('md.inAtivo = TRUE')->setParameter('sqTipoDocumento', $dtoSearch->getSqTipoDocumento())->andWhere('md.sqAssunto = :sqAssunto')->setParameter('sqAssunto', $dtoSearch->getSqAssunto()); $out = $queryBuilder->getQuery()->execute(); if ($result) { return count($out) > 0 ? $out[0] : $this->getModeloDocAssunto($dtoSearch); } else { return count($out) > 0 ? count($out[0]) : count($this->getModeloDocAssunto($dtoSearch)); } }
/** * Metódo que realiza o save do Artefato */ public function saveArtefato(\Core_Dto_Search $dtoSearch) { $entityArtefato = $this->_newEntity('app:Artefato'); $entityArtefato->setDtPrazo(NULL); $date = new \Zend_Date(); $entityArtefato->setDtArtefato($date); $entityTipoArtefatoAssunto = $this->_getRepository('app:TipoArtefatoAssunto')->findBy(array('sqAssunto' => $dtoSearch->getSqAssunto(), 'sqTipoArtefato' => 5)); $entityTipoDoc = $this->_getRepository('app:TipoDocumento')->find($dtoSearch->getSqTipoDocumento()); $entityArtefato->setSqTipoArtefatoAssunto($entityTipoArtefatoAssunto[0]); $entityArtefato->setSqTipoDocumento($entityTipoDoc); $this->getEntityManager()->persist($entityArtefato); $this->getEntityManager()->flush($entityArtefato); $idModelo = $this->hasModeloDocumentoCadastrado($dtoSearch, TRUE); $entityModelo = $this->_getRepository('app:ModeloDocumento')->find($idModelo); $entityArtefatoMinuta = $this->_newEntity('app:ArtefatoMinuta'); $entityArtefatoMinuta->setSqModeloDocumento($entityModelo); $entityArtefatoMinuta->setSqArtefato($entityArtefato); $this->getEntityManager()->persist($entityArtefatoMinuta); $this->getEntityManager()->flush($entityArtefatoMinuta); return $entityArtefato; }
private function appendQuery(\Doctrine\ORM\QueryBuilder $queryBuilder, \Core_Dto_Search $dto) { //Filtro por Interessado if ($dto->getSqPessoaSgdoce()) { $queryBuilder->andWhere('vwca.sqPessoaInteressada like :sqPessoaSgdoce')->setParameter('sqPessoaSgdoce', '%' . $dto->getSqPessoaSgdoce() . '%'); } //Filtro por Cpf, Cnpj e Passaport if ($dto->getNuCpfCnpjPassaporte()) { $filter = new \Zend_Filter_Digits(); $queryBuilder->andWhere('vwca.nuCpfCnpjPassaporteOrigem = :nuCpfCnpjPassaporte')->setParameter('nuCpfCnpjPassaporte', $filter->filter($dto->getNuCpfCnpjPassaporte())); } //Filtro pelo tipo de documento if ($dto->getSqTipoDocumento()) { $queryBuilder->andWhere('vwca.sqTipoDocumento = :sqTipoDocumento')->setParameter('sqTipoDocumento', $dto->getSqTipoDocumento()); } if ($dto->getSqPessoaFuncao()) { $queryBuilder->andWhere('vwca.sqPessoaSgdoceOrigem = :sqPessoaSgdoceOrigem ')->setParameter('sqPessoaSgdoceOrigem', $dto->getSqPessoaFuncao()); } $this->appendQuery2($queryBuilder, $dto); }