/** * * @param \Core_Dto_Abstract $dto * @return array */ public function listGridAnexos(\Core_Dto_Search $dto) { $queryBuilder = $this->_em->createQueryBuilder(); $queryBuilder->select('af.sqArtefato')->from('app:ArtefatoVinculo', 'av')->innerJoin('av.sqArtefatoFilho', 'af')->andWhere('av.sqTipoVinculoArtefato != :tipoVinculo')->andWhere('av.sqArtefatoPai = :sqArtefatoPai')->andWhere('av.dtRemocaoVinculo is null')->setParameters(array('tipoVinculo' => \Core_Configuration::getSgdoceTipoVinculoArtefatoReferencia(), 'sqArtefatoPai' => $dto->getSqArtefato())); $arrSqArtefatoVinculo = $queryBuilder->getQuery()->execute(); $arrSqArtefato = array((int) $dto->getSqArtefato()); if (!empty($arrSqArtefatoVinculo)) { foreach ($arrSqArtefatoVinculo as $artefatoVinculo) { $arrSqArtefato[] = $artefatoVinculo['sqArtefato']; } } $queryBuilder = $this->_em->createQueryBuilder(); $queryBuilder->select('aa,a')->from('app:AnexoArtefato', 'aa')->innerJoin('aa.sqArtefato', 'a')->andWhere('aa.sqArtefato in(:sqArtefato)')->setParameters(array('sqArtefato' => $arrSqArtefato))->orderBy('aa.nuPagina'); return $queryBuilder->getQuery()->getArrayResult(); }
/** * @param \Core_Dto_Search $dto */ public function searchArtefato($dto) { $sqTipoArtefato = $dto->getSqTipoArtefato(); $nuArtefato = "sgdoce.formata_numero_digital(art.nu_digital) ILIKE '%{$dto->getQuery()}%'"; if ($sqTipoArtefato == \Core_Configuration::getSgdoceTipoArtefatoProcesso()) { $value = preg_replace('/[^0-9]/', '', $dto->getQuery()); $withOR = "OR TRANSLATE(art.nu_artefato, './-', '') ILIKE '%{$value}%'"; $nuArtefato = "sgdoce.formata_numero_artefato(art.nu_artefato, ap.co_ambito_processo) ILIKE '%{$value}%' {$withOR}"; } $rsm = new \Doctrine\ORM\Query\ResultSetMapping($this->_em); $rsm->addScalarResult('sq_artefato', 'sqArtefato', 'integer'); $rsm->addScalarResult('nu_artefato', 'nuArtefato', 'string'); $rsm->addScalarResult('nu_digital', 'nuDigital', 'string'); $sql = sprintf(' SELECT art.sq_artefato ,formata_numero_artefato(art.nu_artefato, ap.co_ambito_processo) AS nu_artefato ,formata_numero_digital(art.nu_digital) as nu_digital FROM artefato art JOIN artefato art_pai ON obter_vinculo_pai(art.sq_artefato) = art_pai.sq_artefato JOIN sgdoce.tramite_artefato uta ON art_pai.sq_artefato = uta.sq_artefato AND uta.st_ultimo_tramite JOIN tipo_artefato_assunto taa ON taa.sq_tipo_artefato_assunto = art.sq_tipo_artefato_assunto LEFT JOIN artefato_processo ap ON art.sq_artefato = ap.sq_artefato LEFT JOIN artefato_vinculo av ON av.sq_artefato_filho = art.sq_artefato and av.sq_tipo_vinculo_artefato NOT IN(%5$d,%6$d,%7$d) LEFT JOIN artefato_arquivo_setorial aas ON art.sq_artefato = aas.sq_artefato and aas.dt_desarquivamento is null WHERE aas.sq_artefato IS NULL AND uta.sq_pessoa_recebimento = %1$s AND uta.sq_status_tramite <> %2$s AND (%3$s) AND taa.sq_tipo_artefato = %4$s', $dto->getSqPessoa(), \Core_Configuration::getSgdoceStatusTramiteTramitado(), $nuArtefato, $dto->getSqTipoArtefato(), \Core_Configuration::getSgdoceTipoVinculoArtefatoReferencia(), \Core_Configuration::getSgdoceTipoVinculoArtefatoApoio(), \Core_Configuration::getSgdoceTipoVinculoArtefatoDespacho()); try { return $this->_em->createNativeQuery($sql, $rsm)->useResultCache(false)->getScalarResult(); } catch (\Exception $ex) { $this->getMessaging()->addErrorMessage(\Core_Registry::getMessage()->translate('MN180'), 'User'); $this->getMessaging()->dispatchPackets(); return array(); } }
public function isCitacao(\Core_Dto_Search $dto, $sqTipoVinculo = null) { $queryBuilder = $this->_em->createQueryBuilder(); if (!is_null($sqTipoVinculo)) { $sqTipoVinculo = (array) $sqTipoVinculo; } else { $sqTipoVinculo = array(\Core_Configuration::getSgdoceTipoVinculoArtefatoDespacho(), \Core_Configuration::getSgdoceTipoVinculoArtefatoApoio(), \Core_Configuration::getSgdoceTipoVinculoArtefatoReferencia()); } $query = $queryBuilder->select('av')->from('app:ArtefatoVinculo', 'av')->andWhere('av.sqArtefatoFilho = :id')->andWhere($queryBuilder->expr()->In('av.sqTipoVinculoArtefato', $sqTipoVinculo))->setParameter('id', $dto->getSqArtefato()); $result = $query->getQuery()->getOneOrNullResult(); return $result ? true : false; }
/** * @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; }
/** * @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; }
/** * Metódo que realiza o post Save. * @param Object $entity * @param Object $dto */ public function postSave($entity, $dto = NULL) { try { // 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); $strMessage = NULL; if ($this->_firstTramite) { $strMessage = $this->getServiceLocator()->getService('HistoricoArtefato')->getMessage('MH005', $entity->getDtCadastro()->get(\Zend_Date::DATETIME_MEDIUM), \Core_Integration_Sica_User::getUserName()); $nuOcorrencia = \Core_Configuration::getSgdoceSqOcorrenciaCadastrar(); } else { $strMessage = $this->getServiceLocator()->getService('HistoricoArtefato')->getMessage('MH006', \Zend_Date::now()->get(\Zend_Date::DATETIME_MEDIUM), \Core_Integration_Sica_User::getUserName()); $nuOcorrencia = \Core_Configuration::getSgdoceSqOcorrenciaAlterar(); } $this->getServiceLocator()->getService('HistoricoArtefato')->registrar($entity->getSqArtefato(), $nuOcorrencia, $strMessage); // verificando atributo // noResponsavelAssinatura vem o sqPessoa selecionado no autocomplete if ($dto->getNoResponsavelAssinatura() != NULL) { /** * em caso de update de documento de origem externa ou com tipo de documento sem assinatura e que não tiver assinante * efetua a exclusão caso ja tenha sido preenchido * anteriormente */ if ($entity->getSqArtefato() && !$dto->getNoResponsavelAssinatura()) { $this->_checkExcluirAssinante($entity, $dto); } else { $sqPessoaResponsavelAssinatura = $dto->getNoResponsavelAssinatura_hidden() ? $dto->getNoResponsavelAssinatura_hidden() : $dto->getNoResponsavelAssinatura(); $noPessoaResponsavelAssinatura = $dto->getNoResponsavelAssinatura_autocomplete() ? $dto->getNoResponsavelAssinatura_autocomplete() : $dto->getNoResponsavelAssinatura(); if (!is_numeric($sqPessoaResponsavelAssinatura)) { throw new \Core_Exception_ServiceLayer_Verification('Ocorreu um erro na identificação do assintante do documento. ' . "Preencha o campo <b>Assinatura</b> novamente."); } $entityPessoa = $this->pessoaCorporativoSgdoce($sqPessoaResponsavelAssinatura, $noPessoaResponsavelAssinatura); $pessoaArtefato = $this->getServiceLocator()->getService('Artefato')->cadastrarPessoaArtefato($entity, $entityPessoa, \Core_Configuration::getSgdocePessoaFuncaoAssinatura()); $this->getEntityManager()->persist($pessoaArtefato); $this->getEntityManager()->flush($pessoaArtefato); // verificando se existe registro em PessoaAssinanteArtefato if ($dto->getProcedenciaInterno() != 'externo') { //só quando é unidade if ($dto->getSqPessoaOrigem() != '') { $sqPessoaOrigem = NULL; } else { $sqPessoaOrigem = $dto->getSqPessoaIcmbio(); } $pessoaUnidadeOrg = $this->hasPessoaUnidadeOrg($entityPessoa, $dto->getNoPessoaFuncaoAssinante(), $sqPessoaOrigem); $criteria = array('sqArtefato' => $entity->getSqArtefato()); $entPessoaAssinante = $this->_getRepository('app:PessoaAssinanteArtefato')->findOneBy($criteria); // verificando se existe registro if (count($entPessoaAssinante)) { // atualizando PessoaAssinanteArtefato $entPessoaAssinante->setSqPessoaUnidadeOrg($pessoaUnidadeOrg); if ($dto->getNoPessoaFuncaoAssinante() != $entPessoaAssinante->getNoCargoAssinante()) { $entPessoaAssinante->setNoCargoAssinante($dto->getNoPessoaFuncaoAssinante()); } } else { // Preparando Entidade para salvar /** @var PessoaAssinanteArtefato $resPessoaAssinante */ $entPessoaAssinante = $this->_newEntity('app:PessoaAssinanteArtefato'); // $entPessoaAssinante->setSqArtefato($this->_getRepository('app:Artefato')->find($entity->getSqArtefato())); $entPessoaAssinante->setSqArtefato($entity); $entPessoaAssinante->setSqPessoaUnidadeOrg($pessoaUnidadeOrg); $entPessoaAssinante->setNoCargoAssinante($dto->getNoPessoaFuncaoAssinante()); } // salvando PessoaAssinanteArtefato $this->getEntityManager()->persist($entPessoaAssinante); $this->getEntityManager()->flush($entPessoaAssinante); } } } else { /** * em caso de update de documento de origem externa e não tiver assinante efetua a exclusão caso ja tenha sido preenchido * anteriormente */ $this->_checkExcluirAssinante($entity, $dto); } //sqPrazo = 1 (data) e sqPrazo = 2 (dias) $entity->setDtPrazo($dto->getSqPrazo() == 2 ? NULL : $dto->getDtPrazo() != '' ? $dto->getDtPrazo() : NULL); $entity->setNuDiasPrazo($dto->getNuDiasPrazo() == '' ? NULL : $dto->getNuDiasPrazo()); //Tira os Espaços do 'enter' para salvar com 250 caracteres $txAssuntoComplementar = $this->getServiceLocator()->getService('MinutaEletronica')->fixNewlines($entity->getTxAssuntoComplementar()); $entity->setTxAssuntoComplementar(!$txAssuntoComplementar ? NULL : $txAssuntoComplementar); // salvando Origem e Destino self::salvaOrigemDestino($entity, $dto); if ($entity->getNuDigital() && !$entity->getNuDigital() instanceof \Sgdoce\Model\Entity\EtiquetaNupSiorg) { $entityEtiquetaNupSiorg = $this->getEntityManager()->getPartialReference('app:EtiquetaNupSiorg', $entity->getNuDigital()); $entity->setNuDigital($entityEtiquetaNupSiorg); } // persistindo informacao $this->getEntityManager()->persist($entity); $this->getEntityManager()->flush($entity); /* * ##### 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->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.'); } } } /* * ##### 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->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 documento"; } throw new \Core_Exception_ServiceLayer($msg); } } } #processar anexos para SIC if (true === (bool) $dto->getIsSic() && (int) $dto->getUploader_count() > 0) { $this->_processaAnexoSIC($entity, $dto); } if ($this->_firstTramite) { $this->getServiceLocator()->getService('TramiteArtefato')->insertFirstTramite($entity->getSqArtefato()); } } catch (\Exception $e) { $this->getEntityManager()->getConnection()->rollback(); throw $e; } }
public function processDownloadFileRequest($sqArtefato) { try { $dto = \Core_Dto::factoryFromData(array('sqArtefato' => $sqArtefato), 'search'); $arrNotVinculo = array(\Core_Configuration::getSgdoceTipoVinculoArtefatoReferencia(), \Core_Configuration::getSgdoceTipoVinculoArtefatoApoio(), \Core_Configuration::getSgdoceTipoVinculoArtefatoDespacho()); $arrVinculo = $this->getServiceLocator()->getService('ArtefatoVinculo')->findVinculoArtefato($dto, $arrNotVinculo); $entArtefato = $this->_getRepository($this->_entityArtefato)->find($sqArtefato); $sqTipoArtefato = $entArtefato->getSqTipoArtefatoAssunto()->getSqTipoArtefato()->getSqTipoArtefato(); if ($sqTipoArtefato == \Core_Configuration::getSgdoceTipoArtefatoDocumento() && count($arrVinculo) == 0) { //Documento sem Vinculo $arrRetorno = $this->_processDownloadUniqueFile($sqArtefato); } else { //Processo com vinculo além da 1ª Peça //Documento com vinculo $sqPessoa = \Core_Integration_Sica_User::getPersonId(); $configs = \Core_Registry::get('configs'); $mergePdfOptions = $configs['merge_pdf']; $robotMode = (bool) $mergePdfOptions['robotMode']; if (!$robotMode) { $arrRetorno = $this->_processMergeFiles($sqArtefato, $sqPessoa); } else { $txEmailCorporativo = $this->_getEmailCorporativo($sqPessoa); if (!$txEmailCorporativo) { throw new \Core_Exception_ServiceLayer('Email corporativo não localizado. Impossível prosseguir.'); } $entSolicitacaoDownloadImagem = $this->_newEntity('app:SolicitacaoDownloadImagem'); $entSolicitacaoDownloadImagem->setSqArtefato($entArtefato)->setSqPessoa($this->getEntityManager()->getPartialReference('app:VwPessoa', $sqPessoa))->setSqUnidadeOrg($this->getEntityManager()->getPartialReference('app:VwUnidadeOrg', \Core_Integration_Sica_User::getUserUnit()))->setDtSolicitacao(\Zend_Date::now())->setStProcessado(FALSE)->setInTentativa(0)->setTxEmail($txEmailCorporativo); $this->getEntityManager()->persist($entSolicitacaoDownloadImagem); $this->getEntityManager()->flush(); $arrRetorno['success'] = true; $arrRetorno['msg'] = sprintf(\Core_Registry::getMessage()->translate('MN169'), $txEmailCorporativo); $arrRetorno['link'] = ''; $arrRetorno['filesize'] = ''; } } // switch ($sqTipoArtefato) { // //Processo apenas com a 1ª Peça // case \Core_Configuration::getSgdoceTipoArtefatoProcesso() && count($arrVinculo) == 1: // $arrRetorno = $this->_processDownloadUniqueFile($arrVinculo[1]['sqArtefato']); // break; // //Documento sem Vinculo // case \Core_Configuration::getSgdoceTipoArtefatoDocumento() && count($arrVinculo) == 0: // $arrRetorno = $this->_processDownloadUniqueFile($sqArtefato); // break; // //Processo com vinculo além da 1ª Peça // //Documento com vinculo // default: // // $sqPessoa = \Core_Integration_Sica_User::getPersonId(); // $configs = \Core_Registry::get('configs'); // $mergePdfOptions = $configs['merge_pdf']; // $robotMode = (boolean) $mergePdfOptions['robotMode']; // // if (!$robotMode) { // $arrRetorno = $this->_processMergeFiles($sqArtefato, $sqPessoa); // break; // } // // $txEmailCorporativo = $this->_getEmailCorporativo($sqPessoa); // // if (!$txEmailCorporativo) { // throw new \Core_Exception_ServiceLayer('Email corporativo não localizado. Impossível prosseguir.'); // } // // $entSolicitacaoDownloadImagem = $this->_newEntity('app:SolicitacaoDownloadImagem'); // $entSolicitacaoDownloadImagem->setSqArtefato($entArtefato) // ->setSqPessoa($this->getEntityManager()->getPartialReference('app:VwPessoa', $sqPessoa)) // ->setSqUnidadeOrg($this->getEntityManager()->getPartialReference('app:VwUnidadeOrg', \Core_Integration_Sica_User::getUserUnit())) // ->setDtSolicitacao(\Zend_Date::now()) // ->setStProcessado(FALSE) // ->setInTentativa(0) // ->setTxEmail($txEmailCorporativo); // // $this->getEntityManager()->persist($entSolicitacaoDownloadImagem); // $this->getEntityManager()->flush(); // // $arrRetorno['success'] = true; // $arrRetorno['msg'] = sprintf(\Core_Registry::getMessage()->translate('MN169'), $txEmailCorporativo); // $arrRetorno['link'] = ''; // $arrRetorno['filesize'] = ''; // // break; // } } catch (\Exception $e) { $arrRetorno['success'] = false; $arrRetorno['msg'] = $e->getMessage(); $arrRetorno['link'] = ''; } return $arrRetorno; }
public function addDocumentoEletronicoAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(TRUE); $params = $this->_getAllParams(); $params['tipoVinculo'] = \Core_Configuration::getSgdoceTipoVinculoArtefatoReferencia(); $dto = Core_Dto::factoryFromData($params, 'search'); if ($dto->getNuArtefatoVinculacao()) { $artefato = $this->getService('Artefato')->findBy(array('nuArtefato' => $dto->getNuArtefatoVinculacao())); } else { $artefato = $this->getService('Artefato')->findBy(array('nuDigital' => $dto->getNuDigital())); } $criteria = array('sqArtefatoPai' => $dto->getSqArtefato(), 'sqArtefatoFilho' => $artefato[0]->getSqArtefato(), 'sqTipoVinculoArtefato' => $params['tipoVinculo'], 'dtRemocaoVinculo' => NULL); $result = $this->getService('ArtefatoVinculo')->findBy($criteria); if (count($result) > 0) { $this->_helper->json(array('sucess' => 'false')); } else { $json = $this->getService('Documento')->addDocumentoEletronico($dto); $this->_helper->json(array('sucess' => 'true')); } }
/** * @return */ public function findArtefatoResposta($dto, $limit = 10) { $sqTipoArtefato = $dto->getSqTipoArtefato(); $nuArtefato = $dto->getNuArtefato(); $sqArtefatoPrazo = $dto->getSqArtefatoPrazo(); $rsm = new \Doctrine\ORM\Query\ResultSetMapping($this->_em); $rsm->addScalarResult('sq_artefato', 'sqArtefato', 'integer'); $rsm->addScalarResult('nu_artefato', 'nuArtefato', 'string'); $rsm->addScalarResult('nu_digital', 'nuDigital', 'string'); $rsm->addScalarResult('sq_tipo_artefato', 'sqTipoArtefato', 'integer'); $likeNuArtefatoNuDigital = ""; if ($sqTipoArtefato == \Core_Configuration::getSgdoceTipoArtefatoProcesso()) { $likeNuArtefatoNuDigital = "art.nu_artefato ILIKE '%{$nuArtefato}%'"; } else { $likeNuArtefatoNuDigital = "formata_numero_digital(art.nu_digital) ILIKE '%{$nuArtefato}%'"; } $sql = "SELECT art.sq_artefato,\n formata_numero_artefato(art.nu_artefato, atp.co_ambito_processo) AS nu_artefato,\n formata_numero_digital(art.nu_digital) AS nu_digital,\n ta.sq_tipo_artefato\n FROM sgdoce.artefato art\n INNER JOIN sgdoce.tipo_artefato_assunto tas ON art.sq_tipo_artefato_assunto = tas.sq_tipo_artefato_assunto\n INNER JOIN sgdoce.tipo_artefato ta ON tas.sq_tipo_artefato = ta.sq_tipo_artefato\n LEFT JOIN sgdoce.artefato_processo atp ON art.sq_artefato = atp.sq_artefato\n LEFT JOIN sgdoce.artefato_vinculo av ON art.sq_artefato = av.sq_artefato_filho\n WHERE ta.sq_tipo_artefato = {$sqTipoArtefato}\n AND ((av.sq_artefato_filho IS NULL OR av.sq_tipo_vinculo_artefato IN (\n " . \Core_Configuration::getSgdoceTipoVinculoArtefatoDespacho() . ",\n " . \Core_Configuration::getSgdoceTipoVinculoArtefatoApoio() . ",\n " . \Core_Configuration::getSgdoceTipoVinculoArtefatoReferencia() . "\n )))\n AND ({$likeNuArtefatoNuDigital})\n AND art.sq_artefato <> {$sqArtefatoPrazo} LIMIT {$limit}"; $nativeQuery = $this->_em->createNativeQuery($sql, $rsm); return $nativeQuery->execute(); }