/**
  * Obtén dados da pessoa de autoria de uma minuta
  * @param $dto
  * @return array
  */
 public function getPessoaArtefatoAutor($dto)
 {
     $query = $this->_em->createQueryBuilder()->select('pf.sqPessoaFuncao, pf.noPessoaFuncao, p.sqPessoa, p.noPessoa, p.noProfissao,
                             t.noTratamento, tv.deEnderecamento, v.noVocativo, cid.noMunicipio, est.noEstado,
                             p.coCep, a.txEmenta')->from($this->_enName, 'p')->innerJoin('p.sqPessoaFuncao', 'pf')->leftJoin('p.sqTratamentoVocativo', 'tv')->leftJoin('tv.sqTratamento', 't')->leftJoin('tv.sqVocativo', 'v')->leftJoin('p.sqMunicipioEndereco', 'cid')->leftJoin('cid.sqEstado', 'est')->innerJoin('p.sqArtefato', 'a')->andWhere('p.sqArtefato = :sqArtefato')->setParameter('sqArtefato', $dto->getSqArtefato())->andWhere('p.sqPessoaFuncao = :sqPessoaFuncao')->setParameter('sqPessoaFuncao', \Core_Configuration::getSgdocePessoaFuncaoAutor())->getQuery()->execute();
     if (empty($query)) {
         return NULL;
     }
     return $query[0];
 }
 /**
  * @param type $entity
  * @param type $dto
  * @param type $objArtProDto
  */
 public function postSave($entity, $dto = null, $objArtProDto = null)
 {
     $retorno = false;
     $this->getEntityManager()->beginTransaction();
     $sqPessoaCorporativo = \Core_Integration_Sica_User::getPersonId();
     try {
         // salva o artefato_processo
         $objArtProDto->setSqArtefato($entity);
         $this->saveArtefatoProcesso($objArtProDto);
         $arrPesArtDto = array('entity' => 'Sgdoce\\Model\\Entity\\PessoaArtefato', 'mapping' => array('sqPessoaFuncao' => 'Sgdoce\\Model\\Entity\\PessoaFuncao', 'sqPessoaSgdoce' => 'Sgdoce\\Model\\Entity\\PessoaSgdoce', 'sqArtefato' => 'Sgdoce\\Model\\Entity\\Artefato'));
         $sqPessoaSgdoce = $this->_getRepository('app:PessoaSgdoce')->findBySqPessoaCorporativo($sqPessoaCorporativo);
         if (empty($sqPessoaSgdoce)) {
             $filter = new \Zend_Filter_Digits();
             $data['sqPessoaCorporativo'] = $this->_getRepository('app:VwPessoa')->find($sqPessoaCorporativo);
             $dtoPessoaSearch = \Core_Dto::factoryFromData($data, 'search');
             $cpfCnpjPassaportUnfiltered = $this->getServiceLocator()->getService('VwPessoa')->returnCpfCnpjPassaporte($dtoPessoaSearch);
             $cpfCnpjPassaport = $filter->filter($cpfCnpjPassaportUnfiltered);
             $noPessoaCorporativo = $data['sqPessoaCorporativo']->getNoPessoa();
             $this->addPessoaSgdoce($sqPessoaCorporativo, $noPessoaCorporativo, $cpfCnpjPassaport);
             $sqPessoaSgdoce = $this->_getRepository('app:PessoaSgdoce')->findBySqPessoaCorporativo($sqPessoaCorporativo);
         }
         $arrParams = array();
         $arrParams['sqArtefato'] = $entity->getSqArtefato();
         $arrParams['sqPessoaFuncao'] = \Core_Configuration::getSgdocePessoaFuncaoAutor();
         $arrParams['sqPessoaSgdoce'] = $sqPessoaSgdoce[0]->getSqPessoaSgdoce();
         $objPessoArtefato = $this->getServiceLocator()->getService('PessoaArtefato')->findBy($arrParams);
         if (!count($objPessoArtefato)) {
             $objPessoaArtefatoDto = \Core_Dto::factoryFromData($arrParams, 'entity', $arrPesArtDto);
             $this->getServiceLocator()->getService('PessoaArtefato')->savePessoaArtefato($objPessoaArtefatoDto);
         }
         $this->_salvaOrigem($entity, $dto);
         // SALVA GRAU DE ACESSO.
         if ($dto->getSqGrauAcesso()) {
             $grauAcesso = $this->getEntityManager()->getPartialReference('app:GrauAcesso', $dto->getSqGrauAcesso());
             $this->getServiceLocator()->getService('GrauAcessoArtefato')->saveGrauAcessoArtefato($entity, $grauAcesso);
         }
         /*
          * ##### VOLUME #####
          *
          * só é postado no create
          *
          */
         if ($dto->getDataVolume()) {
             $dataIntessado = $dto->getDataVolume();
             $sqPessoaAbertura = \Core_Integration_Sica_User::getPersonId();
             $sqUnidadeOrgAbertura = \Core_Integration_Sica_User::getUserUnit();
             foreach ($dataIntessado->getApi() as $method) {
                 $line = $dataIntessado->{$method}();
                 if (!(int) $line->getNuVolume()) {
                     throw new \Core_Exception_ServiceLayer('Volume não informado.');
                 }
                 $nuFolhaFinal = (int) $line->getNuFolhaFinal();
                 $dtEncerramento = null;
                 if (!empty($nuFolhaFinal)) {
                     $dtEncerramento = \Zend_Date::now();
                 } else {
                     $nuFolhaFinal = null;
                 }
                 $add = $this->getServiceLocator()->getService('ProcessoVolume')->addVolume(array('nuVolume' => (int) $line->getNuVolume(), 'nuFolhaInicial' => (int) $line->getNuFolhaInicial(), 'nuFolhaFinal' => $nuFolhaFinal, 'sqArtefato' => $entity->getSqArtefato(), 'sqPessoa' => $sqPessoaAbertura, 'sqUnidadeOrg' => $sqUnidadeOrgAbertura, 'dtAbertura' => \Zend_Date::now(), 'dtEncerramento' => $dtEncerramento));
                 if (!$add) {
                     throw new \Core_Exception_ServiceLayer('Erro ao adicionar volume.');
                 }
             }
         }
         /*
          * ##### INTERESSADO #####
          *
          * só é postado no create, em caso de edit os interessados são
          * manutenidos no proprio formulario
          *
          */
         if ($dto->getDataInteressado()) {
             $dataIntessado = $dto->getDataInteressado();
             foreach ($dataIntessado->getApi() as $method) {
                 $line = $dataIntessado->{$method}();
                 //metodo foi copiado e adaptado de Artefato_PessoaController::addInteressadoAction()
                 $add = $this->getServiceLocator()->getService('Documento')->addInteressado(array('noPessoa' => $line->getNoPessoa(), 'unidFuncionario' => $line->getUnidFuncionario(), 'sqPessoaCorporativo' => $line->getSqPessoaCorporativo(), 'sqTipoPessoa' => $line->getSqTipoPessoa(), 'sqPessoaFuncao' => $line->getSqPessoaFuncao(), 'sqArtefato' => $entity->getSqArtefato()));
                 if (!$add) {
                     throw new \Core_Exception_ServiceLayer($line->getNoPessoa() . ' já é um interessado deste processo.');
                 }
             }
         }
         /*
          * ##### REFERÊNCIA (VINCULO) #####
          *
          * só é postado no create, em caso de edit os vinculos são
          * manutenidos no proprio formulario
          *
          */
         if ($dto->getDataVinculo()) {
             //só é postado no create
             $dataVinculo = $dto->getDataVinculo();
             foreach ($dataVinculo->getApi() as $method) {
                 $gridLine = $dataVinculo->{$method}();
                 //metodo foi copiado e adaptado de Artefato_DocumentoController::addDocumentoEletronicoAction()
                 $add = $this->getServiceLocator()->getService('Documento')->addVinculo(array('nuDigital' => $gridLine->getNuDigital(), 'nuArtefatoVinculacao' => $gridLine->getNuArtefatoVinculacao(), 'sqTipoArtefato' => $gridLine->getSqTipoArtefato(), 'sqArtefato' => $entity->getSqArtefato(), 'tipoVinculo' => \Core_Configuration::getSgdoceTipoVinculoArtefatoReferencia(), 'inOriginal' => $gridLine->getInOriginal()));
                 if (!$add) {
                     $msg = "A digital <b>{$gridLine->getNuDigital()}</b> já esta vinculada a este documento";
                     if ($gridLine->getSqTipoArtefato() == \Core_Configuration::getSgdoceTipoArtefatoProcesso()) {
                         $msg = "O processo <b>{$gridLine->getNuArtefatoVinculacao()}</b> já esta vinculado a este processo.";
                     }
                     throw new \Core_Exception_ServiceLayer($msg);
                 }
             }
         }
         // #HistoricoArtefato::save();
         $dtAcao = new \Zend_Date(\Zend_Date::now());
         $sqOcorrencia = 0;
         if ($this->_firstTramite) {
             $sqOcorrencia = \Core_Configuration::getSgdoceSqOcorrenciaCadastrar();
             $message = "Processo cadastrado com sucesso";
             $strHMessage = sprintf(\Core_Registry::getMessage()->translate('MH007'), \Core_Integration_Sica_User::getUserName(), $dtAcao->get(\Zend_Date::DATETIME_MEDIUM));
         } else {
             $sqOcorrencia = \Core_Configuration::getSgdoceSqOcorrenciaAlterar();
             $message = "Processo alterado com sucesso";
             if ($dto->getIsAutuacao()) {
                 $message = "Processo autuado com sucesso!";
             }
             $strHMessage = sprintf(\Core_Registry::getMessage()->translate('MH008'), \Core_Integration_Sica_User::getUserName(), $dtAcao->get(\Zend_Date::DATETIME_MEDIUM));
         }
         $this->getServiceLocator()->getService('HistoricoArtefato')->registrar($entity->getSqArtefato(), $sqOcorrencia, $strHMessage);
         if ($this->_firstTramite) {
             $this->getServiceLocator()->getService('TramiteArtefato')->insertFirstTramite($entity->getSqArtefato());
         }
         $this->getMessaging()->addSuccessMessage($message, "User");
         $retorno = $this->getEntityManager()->commit();
     } catch (\Exception $objException) {
         $this->getEntityManager()->rollback();
         $this->getMessaging()->addErrorMessage("[" . $objException->getCode() . "] " . $objException->getMessage(), "User");
         $retorno = $objException;
     }
     $this->getMessaging()->dispatchPackets();
     return $retorno;
 }
示例#3
0
 /**
  * @param type $entity
  * @param type $dto
  * @param type $objArtProDto
  */
 public function postSave($entity, $dto = null, $objArtProDto = null)
 {
     $retorno = false;
     $this->getEntityManager()->beginTransaction();
     $sqPessoaCorporativo = \Core_Integration_Sica_User::getPersonId();
     try {
         // salva o artefato_processo
         $objArtProDto->setSqArtefato($entity);
         $this->saveArtefatoProcesso($objArtProDto);
         $arrPesArtDto = array('entity' => 'Sgdoce\\Model\\Entity\\PessoaArtefato', 'mapping' => array('sqPessoaFuncao' => 'Sgdoce\\Model\\Entity\\PessoaFuncao', 'sqPessoaSgdoce' => 'Sgdoce\\Model\\Entity\\PessoaSgdoce', 'sqArtefato' => 'Sgdoce\\Model\\Entity\\Artefato'));
         $sqPessoaSgdoce = $this->_getRepository('app:PessoaSgdoce')->findBySqPessoaCorporativo($sqPessoaCorporativo);
         if (empty($sqPessoaSgdoce)) {
             $filter = new \Zend_Filter_Digits();
             $data['sqPessoaCorporativo'] = $this->_getRepository('app:VwPessoa')->find($sqPessoaCorporativo);
             $dtoPessoaSearch = \Core_Dto::factoryFromData($data, 'search');
             $cpfCnpjPassaportUnfiltered = $this->getServiceLocator()->getService('VwPessoa')->returnCpfCnpjPassaporte($dtoPessoaSearch);
             $cpfCnpjPassaport = $filter->filter($cpfCnpjPassaportUnfiltered);
             $noPessoaCorporativo = $data['sqPessoaCorporativo']->getNoPessoa();
             $this->addPessoaSgdoce($sqPessoaCorporativo, $noPessoaCorporativo, $cpfCnpjPassaport);
             $sqPessoaSgdoce = $this->_getRepository('app:PessoaSgdoce')->findBySqPessoaCorporativo($sqPessoaCorporativo);
         }
         $arrParams = array();
         $arrParams['sqArtefato'] = $entity->getSqArtefato();
         $arrParams['sqPessoaFuncao'] = \Core_Configuration::getSgdocePessoaFuncaoAutor();
         $arrParams['sqPessoaSgdoce'] = $sqPessoaSgdoce[0]->getSqPessoaSgdoce();
         $objPessoArtefato = $this->getServiceLocator()->getService('PessoaArtefato')->findBy($arrParams);
         if (!count($objPessoArtefato)) {
             $objPessoaArtefatoDto = \Core_Dto::factoryFromData($arrParams, 'entity', $arrPesArtDto);
             $this->getServiceLocator()->getService('PessoaArtefato')->savePessoaArtefato($objPessoaArtefatoDto);
         }
         // Autor
         $this->_arInconsistencia[3] = 't';
         $this->_salvaOrigem($entity, $dto);
         $this->_arInconsistencia[0] = 't';
         // SALVA GRAU DE ACESSO.
         if ($dto->getSqGrauAcesso()) {
             $grauAcesso = $this->getEntityManager()->getPartialReference('app:GrauAcesso', $dto->getSqGrauAcesso());
             $this->getServiceLocator()->getService('GrauAcessoArtefato')->saveGrauAcessoArtefato($entity, $grauAcesso);
         }
         /*
          * ##### VOLUME #####
          *
          * só é postado no create
          *
          */
         if ($dto->getDataVolume()) {
             $dataIntessado = $dto->getDataVolume();
             $sqPessoaAbertura = \Core_Integration_Sica_User::getPersonId();
             $sqUnidadeOrgAbertura = \Core_Integration_Sica_User::getUserUnit();
             foreach ($dataIntessado->getApi() as $method) {
                 $line = $dataIntessado->{$method}();
                 if (!(int) $line->getNuVolume()) {
                     throw new \Core_Exception_ServiceLayer('Volume não informado.');
                 }
                 $nuFolhaFinal = (int) $line->getNuFolhaFinal();
                 $dtEncerramento = null;
                 if (!empty($nuFolhaFinal)) {
                     $dtEncerramento = \Zend_Date::now();
                 } else {
                     $nuFolhaFinal = null;
                 }
                 $add = $this->getServiceLocator()->getService('ProcessoVolume')->addVolume(array('nuVolume' => (int) $line->getNuVolume(), 'nuFolhaInicial' => (int) $line->getNuFolhaInicial(), 'nuFolhaFinal' => $nuFolhaFinal, 'sqArtefato' => $entity->getSqArtefato(), 'sqPessoa' => $sqPessoaAbertura, 'sqUnidadeOrg' => $sqUnidadeOrgAbertura, 'dtAbertura' => \Zend_Date::now(), 'dtEncerramento' => $dtEncerramento));
                 if (!$add) {
                     throw new \Core_Exception_ServiceLayer('Erro ao adicionar volume.');
                 }
             }
         }
         /*
          * ##### INTERESSADO #####
          *
          * só é postado no create, em caso de edit os interessados são
          * manutenidos no proprio formulario
          *
          */
         if ($dto->getDataInteressado()) {
             $dataIntessado = $dto->getDataInteressado();
             foreach ($dataIntessado->getApi() as $method) {
                 $line = $dataIntessado->{$method}();
                 //metodo foi copiado e adaptado de Artefato_PessoaController::addInteressadoAction()
                 $add = $this->getServiceLocator()->getService('Documento')->addInteressado(array('noPessoa' => $line->getNoPessoa(), 'unidFuncionario' => $line->getUnidFuncionario(), 'sqPessoaCorporativo' => $line->getSqPessoaCorporativo(), 'sqTipoPessoa' => $line->getSqTipoPessoa(), 'sqPessoaFuncao' => $line->getSqPessoaFuncao(), 'sqArtefato' => $entity->getSqArtefato()));
                 if (!$add) {
                     throw new \Core_Exception_ServiceLayer($line->getNoPessoa() . ' já é um interessado deste processo.');
                 }
                 $this->_arInconsistencia[2] = 't';
             }
         } else {
             $dtoInteressado = \Core_Dto::factoryFromData(array('sqArtefato' => $entity->getSqArtefato()), 'search');
             $nuInteressados = $this->getServiceLocator()->getService('PessoaInterassadaArtefato')->countInteressadosArtefato($dtoInteressado);
             if ($nuInteressados['nu_interessados'] > 0) {
                 $this->_arInconsistencia[2] = 't';
             } else {
                 throw new \Core_Exception_ServiceLayer(\Core_Registry::getMessage()->translate('MN176'));
             }
         }
         /*
          * ##### REFERÊNCIA (VINCULO) #####
          *
          * só é postado no create, em caso de edit os vinculos são
          * manutenidos no proprio formulario
          *
          */
         if ($dto->getDataVinculo()) {
             //só é postado no create
             $dataVinculo = $dto->getDataVinculo();
             foreach ($dataVinculo->getApi() as $method) {
                 $gridLine = $dataVinculo->{$method}();
                 //metodo foi copiado e adaptado de Artefato_DocumentoController::addDocumentoEletronicoAction()
                 $add = $this->getServiceLocator()->getService('Documento')->addVinculo(array('nuDigital' => $gridLine->getNuDigital(), 'nuArtefatoVinculacao' => $gridLine->getNuArtefatoVinculacao(), 'sqTipoArtefato' => $gridLine->getSqTipoArtefato(), 'sqArtefato' => $entity->getSqArtefato(), 'tipoVinculo' => \Core_Configuration::getSgdoceTipoVinculoArtefatoReferencia(), 'inOriginal' => $gridLine->getInOriginal()));
                 if (!$add) {
                     $msg = "A digital <b>{$gridLine->getNuDigital()}</b> já esta vinculada a este documento";
                     if ($gridLine->getSqTipoArtefato() == \Core_Configuration::getSgdoceTipoArtefatoProcesso()) {
                         $msg = "O processo <b>{$gridLine->getNuArtefatoVinculacao()}</b> já esta vinculado a este processo.";
                     }
                     throw new \Core_Exception_ServiceLayer($msg);
                 }
             }
         }
         // #HistoricoArtefato::save();
         $dtAcao = new \Zend_Date(\Zend_Date::now());
         #Datas default
         $this->_arInconsistencia[5] = 't';
         # Se estiver tudo corrigido, insere tramite se tiver que inserir.
         # existe um parametro no form que indica se o tramite deve ser inserido
         # pois o documento já poderá estar na area de trabalho da pessoa (neste caso nao insere)
         if (!in_array('f', $this->_arInconsistencia) && $dto->getPersistTramite()) {
             $this->getServiceLocator()->getService('VinculoMigracao')->setArtefatoCorrigido($entity->getSqArtefato());
         } else {
             $this->_arInconsistencia[6] = 't';
         }
         $arInconsistencia = implode(",", $this->_arInconsistencia);
         $arInconsistencia = "{" . $arInconsistencia . "}";
         $entity->setArInconsistencia($arInconsistencia);
         // persistindo informacao
         $this->getEntityManager()->persist($entity);
         $this->getEntityManager()->flush($entity);
         // #HistoricoArtefato::save();
         $strMessage = $this->getServiceLocator()->getService('HistoricoArtefato')->getMessage('MH022');
         $this->getServiceLocator()->getService('HistoricoArtefato')->registrar($entity->getSqArtefato(), \Core_Configuration::getSgdoceSqOcorrenciaCorrigirMigracao(), $strMessage);
         $retorno = $this->getEntityManager()->commit();
     } catch (\Exception $objException) {
         $this->getEntityManager()->rollback();
         $this->getMessaging()->addErrorMessage("[" . $objException->getCode() . "] " . $objException->getMessage(), "User");
         $retorno = $objException;
     }
     $this->getMessaging()->dispatchPackets();
     return $retorno;
 }
示例#4
0
 /**
  * Metódo que realiza o save da Origem e Autor da Minuta
  */
 public function saveOrigemAutor($entity, $unidadeEntity, $pessoaEntity)
 {
     $criteria = array('sqPessoaCorporativo' => $pessoaEntity->getSqPessoa());
     $entityAux1 = $this->_getRepository('app:PessoaSgdoce')->findOneBy($criteria);
     if (!$entityAux1) {
         $entityAux1 = $this->_newEntity('app:PessoaSgdoce');
     }
     $entityAux1->setSqPessoaCorporativo($pessoaEntity);
     $entityTipoPessoa = $this->getEntityManager()->getPartialReference('app:VwTipoPessoa', \Core_Configuration::getSgdoceTipoPessoaPessoaFisica());
     $entityAux1->setNoPessoa($pessoaEntity->getNoPessoa());
     $entityAux1->setSqTipoPessoa($entityTipoPessoa);
     $this->getEntityManager()->persist($entityAux1);
     $this->getEntityManager()->flush($entityAux1);
     $entityPessoaArtefato = $this->_newEntity('app:PessoaArtefato');
     $entityArtefato = $this->getEntityManager()->getPartialReference('app:Artefato', $entity->getSqArtefato()->getSqArtefato());
     $entityPessoaFuncao = $this->getEntityManager()->getPartialReference('app:PessoaFuncao', \Core_Configuration::getSgdocePessoaFuncaoAutor());
     $entityPessoaArtefato->setSqArtefato($entityArtefato);
     $entityPessoaArtefato->setSqPessoaSgdoce($entityAux1);
     $entityPessoaArtefato->setSqPessoaFuncao($entityPessoaFuncao);
     //grava demais dados,endereco,email,telefone
     $this->saveComplementoPessoa($entityPessoaArtefato, $pessoaEntity, $entityAux1);
     $this->getEntityManager()->persist($entityPessoaArtefato);
     $this->getEntityManager()->flush($entityPessoaArtefato);
     $vwPessoa = $this->getServiceLocator()->getService('VwPessoa')->find($unidadeEntity->getSqUnidadeOrg());
     $criteria = array('sqPessoaCorporativo' => $vwPessoa->getSqPessoa());
     $entityAux2 = $this->_getRepository('app:PessoaSgdoce')->findOneBy($criteria);
     if (!$entityAux2) {
         $entityAux2 = $this->_newEntity('app:PessoaSgdoce');
     }
     $entityAux2->setSqPessoaCorporativo($vwPessoa);
     $entityTipoPessoa = $this->getEntityManager()->getPartialReference('app:VwTipoPessoa', \Core_Configuration::getSgdoceTipoPessoaMinisterioPublico());
     $entityPessoaFuncao = $this->getEntityManager()->getPartialReference('app:PessoaFuncao', \Core_Configuration::getSgdocePessoaFuncaoOrigem());
     $entityAux2->setNoPessoa($unidadeEntity->getNoUnidadeOrg());
     $entityAux2->setSqTipoPessoa($entityTipoPessoa);
     $this->getEntityManager()->persist($entityAux2);
     $this->getEntityManager()->flush($entityPessoaArtefato);
     $entityPessoaArtefato = $this->_newEntity('app:PessoaArtefato');
     $entityPessoaArtefato->setSqArtefato($entityArtefato);
     $entityPessoaArtefato->setSqPessoaFuncao($entityPessoaFuncao);
     $entityPessoaArtefato->setSqPessoaSgdoce($entityAux2);
     $this->saveComplementoPessoa($entityPessoaArtefato, $pessoaEntity, $entityAux2);
     $this->getEntityManager()->persist($entityPessoaArtefato);
     $this->getEntityManager()->flush($entityPessoaArtefato);
 }
示例#5
0
 /**
  * Metódo que realiza o save do Artefato
  * @param Object $dtoSearch
  * @return \Sgdoce\Model\Entity\Artefato
  */
 public function saveArtefato(\Core_Dto_Search $dtoSearch)
 {
     $date = new \Zend_Date();
     $this->getEntityManager()->getConnection()->beginTransaction();
     try {
         $sqPessoaSgdoce = $this->_getRepository('app:PessoaSgdoce')->findBySqPessoaCorporativo(\Core_Integration_Sica_User::getPersonId());
         if (empty($sqPessoaSgdoce)) {
             $filter = new \Zend_Filter_Digits();
             $sqPessoaCorporativo = \Core_Integration_Sica_User::getPersonId();
             $data['sqPessoaCorporativo'] = $this->_getRepository('app:VwPessoa')->find($sqPessoaCorporativo);
             $dtoPessoaSearch = \Core_Dto::factoryFromData($data, 'search');
             $cpfCnpjPassaportUnfiltered = $this->getServiceLocator()->getService('VwPessoa')->returnCpfCnpjPassaporte($dtoPessoaSearch);
             $cpfCnpjPassaport = $filter->filter($cpfCnpjPassaportUnfiltered);
             $noPessoaCorporativo = $data['sqPessoaCorporativo']->getNoPessoa();
             $this->addPessoaSgdoce($sqPessoaCorporativo, $noPessoaCorporativo, $cpfCnpjPassaport);
             $sqPessoaSgdoce = $this->_getRepository('app:PessoaSgdoce')->findBySqPessoaCorporativo(\Core_Integration_Sica_User::getPersonId());
         }
         /** @var \Sgdoce\Model\Entity\Artefato $entityArtefato */
         $entityArtefato = $this->_newEntity('app:Artefato');
         //só seta o numero da digital se for documento tipo físico
         if (!$dtoSearch->getInEletronico()) {
             $entityLoteEtiqueta = $this->getEntityManager()->getPartialReference('app:LoteEtiqueta', $dtoSearch->getSqLoteEtiqueta());
             /** @var \Sgdoce\Model\Entity\EtiquetasUso $entityEtiquetasUso */
             $entityEtiquetasUso = $this->_newEntity('app:EtiquetasUso');
             $entityEtiquetasUso->setNuEtiqueta($dtoSearch->getNuDigital());
             $entityEtiquetasUso->setSqLoteEtiqueta($entityLoteEtiqueta);
             //persist Etiquetas Uso
             $this->getEntityManager()->persist($entityEtiquetasUso);
             $this->getEntityManager()->flush($entityEtiquetasUso);
             $entityArtefato->setNuDigital($entityEtiquetasUso);
             $entityArtefato->setSqLoteEtiqueta($entityEtiquetasUso);
         }
         $entityArtefato->setDtPrazo(NULL);
         $entityArtefato->setDtArtefato($date);
         $entityArtefato->setInEletronico($dtoSearch->getInEletronico());
         //persist artefato
         $this->getEntityManager()->persist($entityArtefato);
         $this->getEntityManager()->flush($entityArtefato);
         $sqPessoaFuncao = $this->getEntityManager()->getPartialReference('app:PessoaFuncao', \Core_Configuration::getSgdocePessoaFuncaoAutor());
         /** @var \Sgdoce\Model\Entity\PessoaArtefato $entityPessoaArtefato */
         $entityPessoaArtefato = $this->_newEntity('app:PessoaArtefato');
         $entityPessoaArtefato->setSqArtefato($entityArtefato);
         $entityPessoaArtefato->setSqPessoaSgdoce($sqPessoaSgdoce[0]);
         $entityPessoaArtefato->setSqPessoaFuncao($sqPessoaFuncao);
         $this->getEntityManager()->persist($entityPessoaArtefato);
         $this->getEntityManager()->flush($entityPessoaArtefato);
         // salva o historico do artefato
         $arrDto = array('sqPessoa' => \Core_Integration_Sica_User::getPersonId(), 'sqUnidade' => \Core_Integration_Sica_User::getUserUnit());
         // #HistoricoArtefato::save();
         $strMessage = $this->getServiceLocator()->getService('HistoricoArtefato')->getMessage('MH005');
         $this->getServiceLocator()->getService('HistoricoArtefato')->registrar($entityArtefato->getSqArtefato(), \Core_COnfiguration::getSgdoceSqOcorrenciaCadastrar(), $strMessage);
         $this->getEntityManager()->getConnection()->commit();
     } catch (\Exception $e) {
         $this->getEntityManager()->getConnection()->rollback();
         throw $e;
     }
     return $entityArtefato;
 }
示例#6
0
 /**
  * Metódo que realiza o save da pessoa interessa e assinante.
  */
 public function saveExtraPessoa($entity, $entityArtefatoClone, $entityArtefato)
 {
     //grava pessoa interessada artefato
     $entityInteressadaArtefato = $this->_getRepository('app:PessoaInteressadaArtefato')->findBy(array('sqArtefato' => $entity->getSqArtefato()->getSqArtefato()));
     if (is_array($entityInteressadaArtefato)) {
         foreach ($entityInteressadaArtefato as $entityInteressada) {
             $entityInteressadaClone = clone $entityInteressada;
             $entityInteressadaClone->setSqArtefato($entityArtefatoClone);
             $this->getEntityManager()->persist($entityInteressadaClone);
             $this->getEntityManager()->flush($entityInteressadaClone);
         }
     }
     //grava pessoa interessada artefato
     $entityAssinanteArtefato = $this->_getRepository('app:PessoaAssinanteArtefato')->findBy(array('sqArtefato' => $entity->getSqArtefato()->getSqArtefato()));
     if (is_array($entityAssinanteArtefato)) {
         foreach ($entityAssinanteArtefato as $entityAssinante) {
             $entityAssinanteClone = clone $entityAssinante;
             $entityAssinanteClone->setSqArtefato($entityArtefatoClone);
             $this->getEntityManager()->persist($entityAssinanteClone);
             $this->getEntityManager()->flush($entityAssinanteClone);
         }
     }
     //grava pessoa motivacao artefato
     $entityMotivacaoArtefato = $this->_getRepository('app:Motivacao')->findBy(array('sqArtefato' => $entity->getSqArtefato()->getSqArtefato()));
     if (is_array($entityMotivacaoArtefato)) {
         foreach ($entityMotivacaoArtefato as $entityMotivacao) {
             $entityMotivacaoClone = clone $entityMotivacao;
             $entityMotivacaoClone->setSqArtefato($entityArtefatoClone);
             $this->getEntityManager()->persist($entityMotivacaoClone);
             $this->getEntityManager()->flush($entityMotivacaoClone);
         }
     }
     //grava rodape
     $criteria = array('sqArtefato' => $entityArtefato->getSqArtefato(), 'sqPessoaFuncao' => \Core_Configuration::getSgdocePessoaFuncaoDadosRodape());
     $entityRodapeArtefato = $this->_getRepository('app:PessoaArtefato')->findOneBy($criteria);
     if ($entityRodapeArtefato) {
         $entityRodapeArtefatoClone = clone $entityRodapeArtefato;
         $entityRodapeArtefatoClone->setSqArtefato($entityArtefatoClone);
         $this->getEntityManager()->persist($entityRodapeArtefatoClone);
         $this->getEntityManager()->flush($entityRodapeArtefatoClone);
     }
     //grava o artefato minuta
     $entityArtefatoMinuta = $this->_getRepository()->find($entity->getSqArtefato()->getSqArtefato());
     $entityArtefatoMinutaClone = clone $entityArtefatoMinuta;
     $entityArtefatoMinutaClone->setSqArtefato($entityArtefatoClone);
     $this->getEntityManager()->persist($entityArtefatoMinutaClone);
     $this->getEntityManager()->flush($entityArtefatoMinutaClone);
     //save historico
     $criteria = array('sqArtefato' => $entity->getSqArtefato()->getSqArtefato());
     $entityHistorico = $this->_getRepository('app:HistoricoArtefato')->findBy($criteria);
     $entityHistoricoClone = clone $entityHistorico[0];
     $entityHistoricoClone->setSqArtefato($entityArtefatoClone);
     $this->getEntityManager()->persist($entityHistoricoClone);
     $this->getEntityManager()->flush($entityHistoricoClone);
     //save origem
     $entityOrigemSgdoce = $this->getPessoaSgdoce($entity, \Core_Configuration::getSgdocePessoaFuncaoOrigem());
     $entityOrigemSgdoceClone = clone $entityOrigemSgdoce[0];
     $entityOrigemSgdoceClone->setSqArtefato($entityArtefatoClone);
     $this->getEntityManager()->persist($entityOrigemSgdoceClone);
     $this->getEntityManager()->flush($entityOrigemSgdoceClone);
     //save autor
     $entityAutorSgdoce = $this->getPessoaSgdoce($entity, \Core_Configuration::getSgdocePessoaFuncaoAutor());
     $entityAutorSgdoceClone = clone $entityAutorSgdoce[0];
     $entityAutorSgdoceClone->setSqArtefato($entityArtefatoClone);
     $this->getEntityManager()->persist($entityAutorSgdoceClone);
     $this->getEntityManager()->flush($entityAutorSgdoceClone);
 }
示例#7
0
 /**
  *
  * @param array $data
  * @param integer $sqArtefato
  */
 private function _getProcessChildrenProcess(array &$data, $sqArtefato)
 {
     $dto = \Core_Dto::factoryFromData(array('sqArtefato' => $sqArtefato, 'sqTipoArtefato' => \Core_Configuration::getSgdoceTipoArtefatoProcesso(), 'sqPessoaFuncao' => \Core_Configuration::getSgdocePessoaFuncaoAutor()), 'search');
     $children = $this->getEntityManager()->getRepository('app:ArtefatoVinculo')->findProcessGuiaProcess($dto);
     $data = array_merge($data, $children);
 }
示例#8
0
 /**
  * @param Core_Model_Entity_Abstract $entity
  * @param type $dto
  */
 public function postInsert($entity, $dto = null, $artefatoProcesso = null, $digital = null)
 {
     $retorno = false;
     $this->getEntityManager()->beginTransaction();
     try {
         // salva o artefato_processo
         $artefatoProcesso->setSqArtefato($entity);
         // Ao autuar um documento sempre vai abrir um volume, iniciando pela página um.
         // Adicionando um volume na linha 148 deste arquivo.
         $artefatoProcesso->setNuVolume(1);
         $artefatoProcesso->setNuPaginaProcesso(1);
         $this->getServiceLocator()->getService('ProcessoEletronico')->saveArtefatoProcesso($artefatoProcesso);
         $arrPesArtDto = array('entity' => 'Sgdoce\\Model\\Entity\\PessoaArtefato', 'mapping' => array('sqPessoaFuncao' => 'Sgdoce\\Model\\Entity\\PessoaFuncao', 'sqPessoaSgdoce' => 'Sgdoce\\Model\\Entity\\PessoaSgdoce', 'sqArtefato' => 'Sgdoce\\Model\\Entity\\Artefato'));
         $arrParams = array();
         $arrParams['sqArtefato'] = $entity->getSqArtefato();
         $arrParams['sqPessoaFuncao'] = \Core_Configuration::getSgdocePessoaFuncaoAutor();
         $arrParams['sqPessoaSgdoce'] = current($this->getServiceLocator()->getService('PessoaSgdoce')->findBy(array('sqPessoaCorporativo' => \Core_Integration_Sica_User::getPersonId())))->getSqPessoaSgdoce();
         $objPessoaArtefatoDto = \Core_Dto::factoryFromData($arrParams, 'entity', $arrPesArtDto);
         $this->getServiceLocator()->getService('PessoaArtefato')->savePessoaArtefato($objPessoaArtefatoDto);
         $this->_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());
             $dtoAcesso = new \Core_Dto_Mapping($data, array_keys($data));
             $sqGrauAcesso = $this->_getRepository('app:GrauAcesso')->find($dtoAcesso->getSqGrauAcesso());
         } else {
             $sqGrauAcesso = $this->_getRepository('app:GrauAcesso')->find($dto->getSqGrauAcesso());
         }
         // realizando a persistencia do Grau de Acesso
         $this->getServiceLocator()->getService('Dossie')->persistGrauAcessoArtefato($entity, $sqGrauAcesso);
         /*
          * ##### INTERESSADO #####
          *
          * só é postado no create, em caso de edit os interessados são
          * manutenidos no proprio formulario
          *
          */
         if ($dto->getDataInteressado()) {
             $dataIntessado = $dto->getDataInteressado();
             foreach ($dataIntessado->getApi() as $method) {
                 $line = $dataIntessado->{$method}();
                 //metodo foi copiado e adaptado de Artefato_PessoaController::addInteressadoAction()
                 $add = $this->getServiceLocator()->getService('Documento')->addInteressado(array('noPessoa' => $line->getNoPessoa(), 'unidFuncionario' => $line->getUnidFuncionario(), 'sqPessoaCorporativo' => $line->getSqPessoaCorporativo(), 'sqTipoPessoa' => $line->getSqTipoPessoa(), 'sqPessoaFuncao' => $line->getSqPessoaFuncao(), 'sqArtefato' => $entity->getSqArtefato()));
                 if (!$add) {
                     throw new \Core_Exception_ServiceLayer($line->getNoPessoa() . ' já é um interessado deste documento.');
                 }
             }
         }
         /**
          * #### VOLUME ####
          */
         $sqPessoaAbertura = \Core_Integration_Sica_User::getPersonId();
         $sqUnidadeOrgAbertura = \Core_Integration_Sica_User::getUserUnit();
         $entPessoaAbertura = $this->getEntityManager()->getPartialReference('app:VwPessoa', $sqPessoaAbertura);
         $entUnidadeOrgAbertura = $this->getEntityManager()->getPartialReference('app:VwUnidadeOrg', $sqUnidadeOrgAbertura);
         $entVolume = $this->_newEntity('app:ProcessoVolume');
         $entVolume->setSqArtefato($entity);
         $entVolume->setNuVolume(1);
         $entVolume->setNuFolhaInicial(1);
         $entVolume->setDtAbertura(\Zend_Date::now());
         $entVolume->setSqPessoaAbertura($entPessoaAbertura);
         $entVolume->setSqUnidadeOrgAbertura($entUnidadeOrgAbertura);
         $this->getEntityManager()->persist($entVolume);
         /*
          * ##### (PEÇA) #####
          */
         $this->getServiceLocator()->getService('ArtefatoVinculo')->inserirPeca(array('parent' => $entity, 'child' => $digital), \Core_Configuration::getSgdoceTipoVinculoArtefatoAutuacao());
         // #HistoricoArtefato::save();
         $nuDigital = $digital->getNuDigital()->getNuEtiqueta();
         $dataAtual = new \Zend_Date(\Zend_Date::now());
         $nuProcesso = $this->getServiceLocator()->getService("Processo")->formataProcessoAmbitoFederal($entity);
         $strMessage = $this->getServiceLocator()->getService('HistoricoArtefato')->getMessage('MH012', $dataAtual->get("dd/MM/yyyy HH:mm:ss"), $nuProcesso);
         $this->getServiceLocator()->getService('HistoricoArtefato')->registrar($entity->getSqArtefato(), \Core_Configuration::getSgdoceSqOcorrenciaCadastrar(), $strMessage);
         // insere tramite
         $this->getServiceLocator()->getService('TramiteArtefato')->insertFirstTramite($entity->getSqArtefato());
         $this->getMessaging()->addSuccessMessage("Documento autuado gerando o processo " . $nuProcesso, "User");
         $retorno = $this->getEntityManager()->commit();
     } catch (\Exception $objException) {
         $this->getEntityManager()->rollback();
         $this->getMessaging()->addErrorMessage("[" . $objException->getCode() . "] " . $objException->getMessage(), "User");
         $retorno = $objException;
     }
     $this->getMessaging()->dispatchPackets();
     return $retorno;
 }