/** * @param Core_Model_Entity_Abstract $entity * @param type $dto */ public function preInsert($entity, $searchDto = null, $artefatoProcesso = null, $digital = null) { if ($this->isDocumentoAutuado($searchDto->getNuDigitalAutuado())) { throw new \Exception("Documento já autuado."); } $configs = \Core_Registry::get('configs'); $nuArtefato = null; if ($configs['processo']['numberWithNupSiorg']) { // ATRUBUI NU NUP DA DIGITAL $nuNupSiorg = $digital->getNuDigital()->getNuNupSiorg(); if ($nuNupSiorg == '') { throw new \Exception("Número Nup Siorg não definido."); } $nuArtefato = $nuNupSiorg; } else { $nuArtefato = $this->getServiceLocator()->getService('ProcessoEletronico')->getNovoNumeroProcesso(); $this->getServiceLocator()->getService('SequencialArtefato')->setSequencialProcesso(\Core_Integration_Sica_User::getUserUnit()); } $entity->setNuArtefato($nuArtefato); // PESQUISA TIPO ARTEFATO ASSUNTO. $sqTpArtAssunto = $this->_getRepository('app:TipoArtefatoAssunto')->findOneBy(array('sqAssunto' => $searchDto->getSqAssunto(), 'sqTipoArtefato' => \Core_Configuration::getSgdoceTipoArtefatoProcesso())); if (!$sqTpArtAssunto) { $entityAssunto = $this->getEntityManager()->getPartialReference('app:Assunto', $searchDto->getSqAssunto()); $entityTipoArtefato = $this->getEntityManager()->getPartialReference('app:TipoArtefato', \Core_Configuration::getSgdoceTipoArtefatoProcesso()); $sqTpArtAssunto = $this->_newEntity('app:TipoArtefatoAssunto'); $sqTpArtAssunto->setSqAssunto($entityAssunto); $sqTpArtAssunto->setSqTipoArtefato($entityTipoArtefato); // persistindo informacao $this->getEntityManager()->persist($sqTpArtAssunto); $this->getEntityManager()->flush($sqTpArtAssunto); } $entity->setSqTipoArtefatoAssunto($sqTpArtAssunto); $entity->setDtCadastro(\Zend_Date::now()); $entity->setInEletronico(false); // trantando atributos if ($searchDto->getInDiasCorridos() == '1') { //Corridos $entity->setInDiasCorridos(TRUE); } else { if ($searchDto->getInDiasCorridos() == '0') { //Uteis $entity->setInDiasCorridos(FALSE); } else { $entity->setInDiasCorridos(NULL); } } ## Tipo Prioridade ## $entSqTipoPrioridade = $this->getEntityManager()->getPartialReference('app:TipoPrioridade', $entity->getSqTipoPrioridade()); $entity->setSqTipoPrioridade($entSqTipoPrioridade); }
/** * * @param \Core_Dto_Search $dto * @return \Doctrine\DBAL\Query\QueryBuilder */ public function listGrid(\Core_Dto_Search $dto) { $rsm = new \Doctrine\ORM\Query\ResultSetMapping(); $rsm->addScalarResult('total_record', 'totalRecord', 'integer'); $rsm->addScalarResult('sq_artefato', 'sqArtefato', 'integer'); $rsm->addScalarResult('digital_numero', 'digitalNumero', 'string'); $rsm->addScalarResult('dt_arquivamento', 'dtArquivamento', 'zenddate'); $rsm->addScalarResult('no_pessoa_arquivamento', 'noPessoaArquivamento', 'string'); $rsm->addScalarResult('tx_assunto', 'txAssunto', 'string'); $rsm->addScalarResult('no_tipo_documento', 'noTipoDocumento', 'string'); $rsm->addScalarResult('no_pessoa_origem', 'noPessoaOrigem', 'string'); $caseNuDigital = "sgdoce.formata_numero_digital(a.nu_digital)"; $sql = "\n SELECT DISTINCT\n COUNT(a.sq_artefato) OVER() AS total_record\n ,a.sq_artefato\n ,COALESCE({$caseNuDigital}, formata_numero_artefato(a.nu_artefato,ap.co_ambito_processo)) AS digital_numero\n ,dt_arquivamento\n ,p.no_pessoa as no_pessoa_arquivamento\n ,ass.tx_assunto\n ,td.no_tipo_documento\n ,ps.no_pessoa AS no_pessoa_origem\n FROM artefato_arquivo_setorial aas\n JOIN vw_pessoa p ON aas.sq_pessoa_arquivamento = p.sq_pessoa\n JOIN artefato a USING(sq_artefato)\n JOIN sgdoce.tipo_artefato_assunto taa USING(sq_tipo_artefato_assunto)\n JOIN sgdoce.assunto ass ON ass.sq_assunto = taa.sq_assunto\n JOIN sgdoce.pessoa_artefato pa ON pa.sq_artefato = a.sq_artefato and pa.sq_pessoa_funcao = %1\$d\n JOIN sgdoce.pessoa_sgdoce ps ON ps.sq_pessoa_sgdoce = pa.sq_pessoa_sgdoce\n LEFT JOIN artefato_processo ap ON a.sq_artefato = ap.sq_artefato\n LEFT JOIN tipo_documento td USING(sq_tipo_documento)\n WHERE dt_desarquivamento IS NULL\n AND sq_unidade_arquivamento = %2\$d\n AND sq_tipo_artefato = %3\$d\n %4\$s\n ORDER BY dt_arquivamento DESC"; $optionalCondition = ''; $search = mb_strtolower($dto->getSearch(), 'UTF-8'); if ($search) { $queryBuild = $this->_em->createQueryBuilder(); if ($dto->getSqTipoArtefato() == \Core_Configuration::getSgdoceTipoArtefatoProcesso()) { $nuArtefato = $this->_em->createQueryBuilder()->expr()->lower("TRANSLATE(a.nu_artefato, './-', '')")->__toString(); $optionalCondition = " AND (" . $queryBuild->expr()->eq('a.nu_artefato', $queryBuild->expr()->literal($search))->__toString() . " OR " . $queryBuild->expr()->eq($nuArtefato, $queryBuild->expr()->literal(str_replace(array('.', '/', '-'), '', $search)))->__toString() . ")"; } else { $optionalCondition = " AND " . $queryBuild->expr()->eq('a.nu_digital', $search)->__toString(); } } $strSql = sprintf($sql, \Core_Configuration::getSgdocePessoaFuncaoOrigem(), \Core_Integration_Sica_User::getUserUnit(), $dto->getSqTipoArtefato(), $optionalCondition); return $this->_em->createNativeQuery($strSql, $rsm)->useResultCache(false); }
public function listItemsVinculoArtefatoAction(array $tipos = NULL) { $tipoDocumento = \Core_Configuration::getSgdoceTipoArtefatoDocumento(); $tipoProcesso = \Core_Configuration::getSgdoceTipoArtefatoProcesso(); $queryBuilder = $this->_em->createQueryBuilder()->select('ta.sqTipoArtefato,ta.noTipoArtefato')->from('app:TipoArtefato', 'ta')->orderBy('ta.noTipoArtefato', 'ASC'); $queryBuilder->andWhere('ta.sqTipoArtefato in(:tipoDocumento,:tipoProcesso)')->setParameters(array('tipoDocumento' => $tipoDocumento, 'tipoProcesso' => $tipoProcesso)); $out = array(); $res = $queryBuilder->getQuery()->getArrayResult(); foreach ($res as $item) { $out[$item['sqTipoArtefato']] = $item['noTipoArtefato']; } return $out; }
/** * Método padrão */ public function indexAction() { $this->_helper->layout->setLayout('modal'); $data['sqArtefato'] = $this->_getParam("sqArtefato"); $dtoArtefato = Core_Dto::factoryFromData($data, 'search'); $this->view->entityArtefato = $this->getService()->find($data['sqArtefato']); $artefatoInconsistente = $this->getService()->isInconsistent($this->view->entityArtefato, FALSE, TRUE); if ($artefatoInconsistente) { $noTipoArtefato = mb_strtolower($this->view->entityArtefato->getSqTipoArtefatoAssunto()->getSqTipoArtefato()->getNoTipoArtefato(), 'utf-8'); $this->getMessaging()->addAlertMessage("Os dados deste {$noTipoArtefato} estão inconsistentes. A correção deve ser feita pelo usuário que estiver com o {$noTipoArtefato} em sua Área de Trabalho.", 'User'); $this->getMessaging()->dispatchPackets(); } $sqTipoArtefato = $this->view->entityArtefato->getSqTipoArtefatoAssunto()->getSqTipoArtefato()->getSqTipoArtefato(); //monta a arvore de vinculos $this->view->vinculos = $this->getService('ArtefatoVinculo')->mostarArvore((int) $data['sqArtefato']); $this->view->urlBack = str_replace(".", "/", $this->getRequest()->getParam('back', "")); $this->view->dadosOrigem = $this->returnDadosOrigem($dtoArtefato); $this->view->dadosDestino = $this->returnDadosDestino($dtoArtefato); if ($sqTipoArtefato == \Core_Configuration::getSgdoceTipoArtefatoProcesso()) { $criteria = array('sqArtefatoPai' => $dtoArtefato->getSqArtefato(), 'sqTipoVinculoArtefato' => \Core_Configuration::getSgdoceTipoVinculoArtefatoAutuacao()); $this->view->autuacao = $this->getService('ArtefatoVinculo')->findBy($criteria); $this->view->dadosInteressado = $this->getService('PessoaInterassadaArtefato')->getPessoaInteressadaArtefato($dtoArtefato); } $this->view->nacionalidadeDestino = NULL; if ($this->view->dadosDestino) { $sqTipoPessoa = $this->view->dadosDestino[0]->getSqPessoaSgdoce()->getSqTipoPessoa()->getSqTipoPessoa(); if ($sqTipoPessoa == \Core_Configuration::getSgdoceTipoPessoaPessoaFisica()) { $this->view->nacionalidadeDestino = $this->returnNacionalidade($this->view->dadosDestino); } } $this->view->nacionalidadeOrigem = NULL; if ($this->view->dadosOrigem) { $sqTipoPessoa = $this->view->dadosOrigem[0]->getSqPessoaSgdoce()->getSqTipoPessoa()->getSqTipoPessoa(); if ($sqTipoPessoa == \Core_Configuration::getSgdoceTipoPessoaPessoaFisica()) { $this->view->nacionalidadeOrigem = $this->returnNacionalidade($this->view->dadosOrigem); } } if ($this->view->urlBack == "") { $this->view->urlBack = "javascript:window.close();"; } // REGISTRO DE VISUALIZAÇÃO DE ARTEFATO. #HistoricoArtefato::save(); // $strMessage = sprintf($this->getServiceLocator() // ->getService('HistoricoArtefato') // ->getMessage('MH003'), Core_Integration_Sica_User::getUserName()); // // $this->_salvarHistoricoArtefato($dtoArtefato->getSqArtefato(), // \Core_Configuration::getSgdoceSqOcorrenciaVisualizar(), // $strMessage); }
/** * * @param \Core_Dto_Search $dto * @return array */ public function listGrid(\Core_Dto_Search $dto) { $rsm = new \Doctrine\ORM\Query\ResultSetMapping($this->_em); $rsm->addScalarResult('sq_caixa', 'sqCaixa', 'integer'); $rsm->addScalarResult('sq_artefato', 'sqArtefato', 'integer'); $rsm->addScalarResult('sq_tipo_artefato', 'sqTipoArtefato', 'integer'); $rsm->addScalarResult('nu_artefato', 'nuArtefato', 'string'); $rsm->addScalarResult('no_tipo_documento', 'noTipoDocumento', 'string'); $rsm->addScalarResult('tx_classificacao', 'txClassificacao', 'string'); $rsm->addScalarResult('nu_classificacao', 'nuClassificacao', 'string'); $rsm->addScalarResult('no_pessoa_origem', 'noPessoaOrigem', 'string'); $rsm->addScalarResult('tx_assunto', 'txAssunto', 'string'); $strQuery = sprintf("SELECT ca.sq_caixa\n ,art.sq_artefato\n ,CASE WHEN (taa.sq_tipo_artefato = %d) THEN art.nu_artefato ELSE art.nu_digital::TEXT END AS nu_artefato\n ,td.no_tipo_documento\n ,taa.sq_tipo_artefato\n ,cl.nu_classificacao || ' - ' ||cl.tx_classificacao as tx_classificacao\n\n ,ps.no_pessoa AS no_pessoa_origem\n ,ass.tx_assunto\n FROM caixa_artefato ca\n INNER JOIN caixa cx using(sq_caixa)\n INNER JOIN artefato art using(sq_artefato)\n INNER JOIN tipo_documento td using(sq_tipo_documento)\n INNER JOIN tipo_artefato_assunto taa using(sq_tipo_artefato_assunto)\n INNER JOIN assunto ass using(sq_assunto)\n INNER JOIN artefato_classificacao ac using(sq_artefato)\n INNER JOIN classificacao cl ON ac.sq_classificacao = cl.sq_classificacao\n INNER JOIN pessoa_artefato pa using(sq_artefato)\n INNER JOIN pessoa_sgdoce ps using(sq_pessoa_sgdoce)\n WHERE ca.sq_caixa = %d\n AND pa.sq_pessoa_funcao = %d", \Core_Configuration::getSgdoceTipoArtefatoProcesso(), $dto->getSqCaixa(), \Core_Configuration::getSgdocePessoaFuncaoOrigem()); $nativeQuery = $this->_em->createNativeQuery($strQuery, $rsm); return $nativeQuery; }
public function modalClassificacaoAction() { $this->getHelper('layout')->disableLayout(); $params = $this->_getAllParams(); $entityArtefato = $this->getService('Artefato')->find($params['sqArtefato']); $sqTipoArtefato = $entityArtefato->getSqTipoArtefatoAssunto()->getSqTipoArtefato()->getSqTipoArtefato(); if ($sqTipoArtefato == \Core_Configuration::getSgdoceTipoArtefatoProcesso()) { $nuArtefato = $this->getService('Processo')->formataProcessoAmbitoFederal($entityArtefato); } else { $nuArtefato = $entityArtefato->getNuDigital()->getNuEtiqueta(); } $this->view->nuArtefato = $nuArtefato; $this->view->entityArtefato = $entityArtefato; if (isset($params['back'])) { $this->view->backUrl = str_replace('.', '/', $params['back']); } }
public function listItemsVinculoArtefatoAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(TRUE); $data = array(); # filtra o tipo de retorno conforme o tipo do documento base # Atentar para o tipo do documento base # BASE -> Recupera # Regra-1: DOC + DOC # Regra-2: PROC + PROC # Regra-3: PROC + DOC $tipoArtefatoFiltro = array(\Core_Configuration::getSgdoceTipoArtefatoDocumento() => array(\Core_Configuration::getSgdoceTipoArtefatoDocumento()), \Core_Configuration::getSgdoceTipoArtefatoProcesso() => array(\Core_Configuration::getSgdoceTipoArtefatoDocumento(), \Core_Configuration::getSgdoceTipoArtefatoProcesso())); $arrTipoArtefatoAceito = $tipoArtefatoFiltro[$this->getRequest()->getParam('sqTipoArtefatoParent')]; foreach ($this->getService()->listItemsVinculoArtefatoAction() as $key => $value) { if (in_array($key, $arrTipoArtefatoAceito)) { $data[] = array('value' => $key, 'text' => $value); } } $this->_helper->json($data); }
/** * LISTA DE TIPO DE ASSUNTO DE SOLICITAÇÃO. * * @param \Core_Dto_Search $dto * @param string $sort * @param string $order * @return array */ public function listTipoAssuntoSolicitacao($dto, $sort = 'a.noTipoAssuntoSolicitacao', $order = 'ASC') { $queryBuilder = $this->_em->createQueryBuilder()->select('a.sqTipoAssuntoSolicitacao, a.noTipoAssuntoSolicitacao, a.inTipoParaArtefato')->from('app:TipoAssuntoSolicitacao', 'a')->orderBy($sort, $order); if ($dto->getQuery() != "") { $search = mb_strtolower($dto->getQuery(), 'UTF-8'); $noTipoAssuntoSolicitacao = $queryBuilder->expr()->lower($queryBuilder->expr()->trim('a.noTipoAssuntoSolicitacao')); $queryBuilder->where($queryBuilder->expr()->like('clear_accentuation(' . $noTipoAssuntoSolicitacao . ')', $queryBuilder->expr()->literal($this->removeAccent('%' . $search . '%')))); } $inTipoParaArtefato = $dto->getInTipoParaArtefato(); if (!is_null($inTipoParaArtefato)) { $paraArtefato = $dto->getInTipoParaArtefato() > 0 ? '1' : '0'; $queryBuilder->andWhere("a.inTipoParaArtefato = :inTipoParaArtefato")->setParameter(":inTipoParaArtefato", $paraArtefato); if ($paraArtefato) { $arrAssuntoProcesso = array(\Core_Configuration::getSgdoceTipoAssuntoSolicitacaoComentario(), \Core_Configuration::getSgdoceTipoAssuntoSolicitacaoDespacho(), \Core_Configuration::getSgdoceTipoAssuntoSolicitacaoAlterarCadastro(), \Core_Configuration::getSgdoceTipoAssuntoSolicitacaoVolumeDeProcesso(), \Core_Configuration::getSgdoceTipoAssuntoSolicitacaoDesanexaProcesso(), \Core_Configuration::getSgdoceTipoAssuntoSolicitacaoDesmembraPecas(), \Core_Configuration::getSgdoceTipoAssuntoSolicitacaoRemoverPeca()); $arrAssuntoDocumento = array(\Core_Configuration::getSgdoceTipoAssuntoSolicitacaoComentario(), \Core_Configuration::getSgdoceTipoAssuntoSolicitacaoAlterarCadastro(), \Core_Configuration::getSgdoceTipoAssuntoSolicitacaoDespacho(), \Core_Configuration::getSgdoceTipoAssuntoSolicitacaoDesanexaDigital(), \Core_Configuration::getSgdoceTipoAssuntoSolicitacaoExcluirImagem()); $arrAssunto = $inTipoParaArtefato == \Core_Configuration::getSgdoceTipoArtefatoProcesso() ? $arrAssuntoProcesso : $arrAssuntoDocumento; $queryBuilder->andWhere("a.sqTipoAssuntoSolicitacao IN(:sqTipoAssuntoSolicitacaoiIn)")->setParameter(":sqTipoAssuntoSolicitacaoiIn", $arrAssunto); } } $queryBuilder->andWhere("a.stRegistroAtivo = :stRegistroAtivo")->setParameter(":stRegistroAtivo", TRUE); return $queryBuilder->getQuery()->useResultCache(TRUE, NULL, __METHOD__)->execute(); }
/** * @param array $data * @param int $selected * @param array $config * @return string */ public function nuArtefato(Artefato $entArtefato, $sqTipoArtefato = null) { $return = NULL; $coAmbitoProcesso = Processo::T_TIPO_AMBITO_PROCESSO_FEDERAL; if (is_null($sqTipoArtefato)) { $sqTipoArtefato = $entArtefato->getSqTipoArtefatoAssunto()->getSqTipoArtefato()->getSqTipoArtefato(); } // PROCESSO if ($sqTipoArtefato == \Core_Configuration::getSgdoceTipoArtefatoProcesso()) { $nuArtefato = $entArtefato->getNuArtefato(); if (method_exists($entArtefato, 'getSqArtefatoProcesso') && $entArtefato->getSqArtefatoProcesso()) { $coAmbitoProcesso = $entArtefato->getSqArtefatoProcesso()->getCoAmbitoProcesso(); } // SE AMBITO FEDERAL APLICA MÁSCARA if ($coAmbitoProcesso == Processo::T_TIPO_AMBITO_PROCESSO_FEDERAL) { $nuArtefato = $this->mask($nuArtefato); } return $nuArtefato; } else { return $entArtefato->getNuDigital()->getNuEtiqueta(TRUE); } return $return; }
/** * @return void */ public function editAction() { $objRequest = $this->getRequest(); $sqArtefato = $objRequest->getParam('id', false); $url = $this->getRequest()->getParam('back', false); $this->view->urlBack = false; $this->view->withTramite = $this->getRequest()->getParam('tramite', 1); if ($url) { $url = str_replace(".", "/", $url); $this->view->urlBack = $url; $url = substr($url, 1); $params = explode("/", $url); $this->view->controllerBack = next($params); $this->view->caixa = end($params); } $dtoSearch = \Core_Dto::factoryFromData(array('sqArtefato' => $sqArtefato), 'search'); if (!$this->getService("Artefato")->isInconsistent($dtoSearch, false, true)) { $this->getMessaging()->addErrorMessage('Processo já corrigido!', 'User'); $this->_redirect($this->view->urlBack); } $this->view->isAutuacao = $objRequest->getParam('autuado', false); if ($sqArtefato) { $artefato = $this->getService()->find($sqArtefato); if (count($artefato) <= 0) { $this->_redirect("/artefato/area-trabalho/index/tipoArtefato/" . \Core_Configuration::getSgdoceTipoArtefatoProcesso()); } } $this->combos(true); $this->view->tipoPessoa = $this->view->arrOptTipoPessoa; $arrParams = $this->_getAllParams(); $arrParams['dtArtefato'] = \Zend_Date::now(); $objDtoParams = \Core_Dto::factoryFromData($arrParams, 'search'); if (!$sqArtefato) { $this->view->pageTitle = "Cadastrar Processo"; if ($arrParams['coAmbitoProcesso'] == 'F') { $arrParams['nuArtefato'] = preg_replace('/[^a-zA-Z0-9]/', '', $arrParams['nuArtefato']); } else { $arrParams['nuArtefato'] = preg_replace('/[^a-zA-Z0-9\\.\\-\\/]/', '', $arrParams['nuArtefato']); } $objEntArtefato = $this->getService('Artefato')->getEntityDto($arrParams, array('entity' => 'Sgdoce\\Model\\Entity\\Artefato', 'mapping' => array())); $objEntArtefatoProcesso = $this->getService('ArtefatoProcesso')->getEntityDto($arrParams, array('entity' => 'Sgdoce\\Model\\Entity\\ArtefatoProcesso', 'mapping' => array('sqEstado' => 'Sgdoce\\Model\\Entity\\VwEstado', 'sqMunicipio' => 'Sgdoce\\Model\\Entity\\VwMunicipio'))); } else { $this->view->pageTitle = "Corrigir Processo"; $listArtefato = $this->getService('Artefato')->findBy(array('sqArtefato' => $sqArtefato)); $objEntArtefato = current($listArtefato); $listArtefatoProcesso = $this->getService('ArtefatoProcesso')->findBy(array('sqArtefato' => $sqArtefato)); $objEntArtefatoProcesso = current($listArtefatoProcesso); } // COMBO MUNICIPIO if ($objEntArtefatoProcesso->getSqMunicipio()) { $sqEstado = $objEntArtefatoProcesso->getSqEstado()->getSqEstado(); $this->view->arrOptMunicipio = array('' => 'Selecione...') + $this->getService('VwEndereco')->comboMunicipio($sqEstado, TRUE); } $dtoArtefato = Core_Dto::factoryFromData(array('sqArtefato' => $sqArtefato), 'search'); $this->view->dadosOrigem = $this->returnDadosOrigem($dtoArtefato); if (!$this->view->dadosOrigem) { $this->view->dadosOrigem = NULL; } elseif (!$this->view->dadosOrigem[0]->getSqPessoaSgdoce()->getSqPessoaCorporativo()->getSqTipoPessoa()) { $this->view->dadosOrigem[1] = NULL; } $this->view->objEntArtefato = $objEntArtefato; $this->view->data = $objEntArtefato; $this->view->objEntArtefatoProcesso = $objEntArtefatoProcesso; $this->view->sqTipoArtefato = \Core_Configuration::getSgdoceTipoArtefatoProcesso(); $this->view->objDtoParams = $objDtoParams; if ($objEntArtefato->getDtArtefato() != null) { $this->view->isValidProcess = true; } else { $this->_redirectAction('index'); } $this->view->bloqueioDigito = false; if (isset($arrParams['tpNuArtefato']) || $sqArtefato) { $this->view->bloqueioDigito = true; } }
/** * @param integer $sqUnidadeOrg */ public function setSequencialProcesso($sqUnidadeOrg) { $data = new \Zend_Date(\Zend_Date::now()); $criteria = array('sqUnidadeOrg' => $sqUnidadeOrg, 'nuAno' => $data->get('Y'), 'sqTipoArtefato' => \Core_Configuration::getSgdoceTipoArtefatoProcesso()); $sequencialArtefato = $this->findOneBy($criteria); $sequencialArtefato->setNuSequencial($sequencialArtefato->getNuSequencial() + 1); $this->getEntityManager()->persist($sequencialArtefato); $this->getEntityManager()->flush(); }
public function autoCompleteVinculacaoAction() { $params = $this->_getAllParams(); if (isset($params['nuArtefato'])) { $params['nuArtefato'] = str_replace('!', '/', $params['nuArtefato']); } $dto = Core_Dto::factoryFromData($params, 'search'); $entity = $this->getService('Dossie')->findAutoComplete($dto); if (count($entity)) { $dados = $this->getService()->returnAutoCompleteVinculacao($entity); $return = array('sqTipoArtefato' => $dados['tipoArtefato'], 'sqTipoDocumento' => $dados['sqTipoDocumento'], 'noTipoDocumento' => $dados['noTipoDocumento'], 'noPessoa' => $dados['sqPessoa'], 'sqPessoa' => $dados['Pessoa'], 'nuArtefato' => $entity[0]->getNuArtefato(), 'nuDigital' => $dto->getSqTipoArtefatoVinculacao() != \Core_Configuration::getSgdoceTipoArtefatoProcesso() ? $entity[0]->getNuDigital()->getNuEtiqueta() : null); } else { $return = array(); } $this->_helper->json($return); }
/** * @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; }
private function _checkCanReturn(\Sgdoce\Model\Entity\Artefato $entityArtefato) { $sqTipoHistoricoArquivo = $this->_getRepository('app:CaixaHistorico')->getLastHistorico($entityArtefato->getSqArtefato()); if (!is_null($sqTipoHistoricoArquivo)) { if ($sqTipoHistoricoArquivo != \Core_Configuration::getSgdoceTipoHistoricoArquivoEmprestado()) { $entityTipoArtefato = $entityArtefato->getSqTipoArtefatoAssunto()->getSqTipoArtefato(); $noTipoArtefato = $entityTipoArtefato->getNoTipoArtefato(); if ($entityTipoArtefato->getSqTipoArtefato() == \Core_Configuration::getSgdoceTipoArtefatoProcesso()) { $nuArtefato = $this->getServiceLocator()->getService('Processo')->formataProcessoAmbitoFederal($entityArtefato); } else { $nuArtefato = $entityArtefato->getNuDigital()->getNuEtiqueta(); } throw new \Core_Exception_ServiceLayer_Verification("O {$noTipoArtefato} <b>{$nuArtefato}</b> não esta emprestado. Logo, não pode ser devolvido"); } } return $this; }
/** * @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; }
/** * @return void */ public function searchArtefatoDestinoAction() { $sqArtefato = $this->getRequest()->getParam('extraParam'); $objZFAlpha = new \Zend_Filter_Alnum(true); $query = $objZFAlpha->filter($this->getRequest()->getParam('query')); $criteria = array('sqTipoArtefato' => \Core_Configuration::getSgdoceTipoArtefatoProcesso(), 'sqPessoaRecebimento' => \Core_Integration_Sica_User::getPersonId(), 'sqUnidadeRecebimento' => \Core_Integration_Sica_User::getUserUnit(), 'nuArtefato' => $query, 'sqArtefato' => $sqArtefato); $listInMyDashboard = $this->getService('ProcessoEletronico')->searchInMyDashboard($criteria); $this->_helper->json($listInMyDashboard); }
/** * 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; } }
/** * * @param \Core_Dto_Search $dto * @return array */ public function searchDocumentsToFirstPiece(\Core_Dto_Search $dto, $isExterno = false, $isLegado = false) { $sqTipoArtefato = $dto->getSqTipoArtefato(); $field = "at.nu_digital"; if ($sqTipoArtefato == \Core_Configuration::getSgdoceTipoArtefatoProcesso()) { $field = $this->_em->createQueryBuilder()->expr()->lower("translate(at.nu_artefato::text, './-'::text, ''::text)")->__toString(); } $inAbreProcesso = ''; if (!$isExterno) { $inAbreProcesso = ' AND td.in_abre_processo'; } if ($isLegado) { $inAbreProcesso = ''; } $sql = "SELECT at.sq_artefato,\n at.nu_digital,\n at.nu_artefato\n FROM sgdoce.fn_show_area_trabalho(NULL, :sqTipoArtefato, :sqPessoaLogada, :sqUnidadeLogada, :search) at\n JOIN tipo_documento td\n ON td.sq_tipo_documento = at.sq_tipo_documento\n WHERE at.sq_status_tramite > :sqStatusTramite\n\n AND at.has_imagem\n AND NOT at.arquivado\n AND {$field} LIKE '{$dto->getQuery()}%'\n AND NOT at.has_solicitacao_aberta\n {$inAbreProcesso}\n ORDER BY at.nu_digital"; $rsm = new \Doctrine\ORM\Query\ResultSetMapping($this->_em); $rsm->addScalarResult('sq_artefato', 'sqArtefato', 'integer'); $rsm->addScalarResult('nu_digital', 'nuDigital', 'string'); $rsm->addScalarResult('nu_artefato', 'nuArtefato', 'string'); $nq = $this->_em->createNativeQuery($sql, $rsm); $nq->setParameter('sqStatusTramite', \Core_Configuration::getSgdoceStatusTramiteTramitado())->setParameter('sqTipoArtefato', $dto->getSqTipoArtefato())->setParameter('sqUnidadeLogada', \Core_Integration_Sica_User::getUserUnit())->setParameter('sqPessoaLogada', \Core_Integration_Sica_User::getPersonId())->setParameter('search', $dto->getQuery()); $nq->useResultCache(false); return $nq->getArrayResult(); }
/** * @param \Core_Dto_Search $dto * @return Array */ public function findArtefatoResposta(\Core_Dto_Search $dto, $limit = 10) { $retorno = $this->_getRepository('app:Artefato')->findArtefatoResposta($dto, $limit); $out = array(); foreach ($retorno as $item) { if ($item['sqTipoArtefato'] == \Core_Configuration::getSgdoceTipoArtefatoProcesso()) { $out[$item['sqArtefato']] = $item['nuArtefato']; } else { $out[$item['sqArtefato']] = "{$item['nuDigital']}"; } } return $out; }
/** * @return redireciona para createAction */ public function indexAction() { $sqArtefato = $this->_getParam('id'); $url = $this->getRequest()->getParam('back', false); if ($url) { $url = str_replace(".", "/", $url); $this->view->urlBack = $url; $url = substr($url, 1); $params = explode("/", $url); $this->view->controllerBack = next($params); $this->view->caixa = end($params); } $dto = \Core_Dto::factoryFromData(array('sqArtefato' => $sqArtefato), 'search'); $arResult = $this->getService()->getChilds($dto); if ($arResult) { $this->view->listVinculos = $arResult['list']; $isProcesso = $this->getService('ArtefatoProcesso')->isProcesso($sqArtefato, false); $this->view->tipoArtefato = $isProcesso ? \Core_Configuration::getSgdoceTipoArtefatoProcesso() : \Core_Configuration::getSgdoceTipoArtefatoDocumento(); } else { $this->_redirect($this->view->urlBack); } if ($arResult['isOk']) { $sqArtefatoPai = $arResult['sqArtefatoPai']; $this->getService()->setMigracaoConcluida($sqArtefatoPai); $dtox = Core_Dto::factoryFromData(array('sqArtefato' => $sqArtefatoPai), 'search'); $areaTrabalho = $this->getService('AreaTrabalho')->findArtefato($dtox); $msg = 'Migração concluída com sucesso'; $caixa = "minhaCaixa"; if ($areaTrabalho) { $this->getMessaging()->addSuccessMessage($msg, 'User'); $this->getMessaging()->dispatchPackets(); $this->_redirect('artefato/area-trabalho/index/tipoArtefato/' . $this->view->tipoArtefato . '/caixa/' . $caixa); } else { $sucesso = FALSE; if ($this->getService('CaixaArtefato')->isArquivado($dtox)) { $caixa = "caixaArquivo"; $msg .= ", o artefato se encontra arquivado."; $sucesso = TRUE; } if ($this->getService('VwUltimoTramiteArtefato')->isTramiteExterno($dtox)) { $caixa = "caixaExterna"; $sucesso = TRUE; } if ($sucesso) { $this->getMessaging()->addSuccessMessage($msg, 'User'); $this->getMessaging()->dispatchPackets(); $this->_redirect('artefato/area-trabalho/index/tipoArtefato/' . $this->view->tipoArtefato . '/caixa/' . $caixa); } else { $this->getMessaging()->addErrorMessage(\Core_Registry::getMessage()->translate('MN178'), 'User'); $this->getMessaging()->dispatchPackets(); } } //@TODO: procurar por getArquivado e getIsTramiteExterno pois usuando a função essas informações não vem //ANTES ERA FEITO ASSIM quando fazia find na vw_area_trablaho // if ($entArtefato) { // // if( $entArtefato->getArquivado() ) { // $caixa = "caixaArquivo"; // $msg .= ", o artefato se encontra arquivado."; // } // // if( $entArtefato->getIsTramiteExterno() ){ // $caixa = "caixaExterna"; // } // // $this->getMessaging()->addSuccessMessage($msg, 'User'); // $this->getMessaging()->dispatchPackets(); // // $this->_redirect( 'artefato/area-trabalho/index/tipoArtefato/' . $this->view->tipoArtefato . '/caixa/' . $caixa ); // } else { // $this->getMessaging()->addErrorMessage(\Core_Registry::getMessage()->translate('MN178'), 'User'); // $this->getMessaging()->dispatchPackets(); // } } $this->view->urlBack = false; $this->view->controllerBack = null; $this->view->caixa = null; $this->view->id = $sqArtefato; $this->view->maskNumber = new Core_Filter_MaskNumber(); }
/** * @return type * @throws RuntimeException */ public function saveAction() { if (!$this->_request->isPost()) { throw new RuntimeException('A requisição deve ser POST'); } $isValid = true; if ($this->getRequest()->getParam('stProcessoVolume', false)) { $this->getRequest()->setPost('sqPessoaAbertura', \Core_Integration_Sica_User::getPersonId()); $this->getRequest()->setPost('sqUnidadeOrgAbertura', (int) \Core_Integration_Sica_User::getUserUnit()); } else { $sqArtefato = (int) $this->getRequest()->getParam('id'); $volume = $this->getService()->getLastVolumeAberto($sqArtefato); $params = $this->_getAllParams(); $configs = \Core_Registry::get('configs'); if ($params['nuFolhaFinal'] - $params['nuFolhaInicial'] <= (int) $configs['volume']['maxPagePerVolume']) { $sqPessoaAbertura = $volume->getSqPessoaAbertura() ? $volume->getSqPessoaAbertura()->getSqPessoa() : 0; $sqUnidadeOrgAbertura = $volume->getSqUnidadeOrgAbertura() ? $volume->getSqUnidadeOrgAbertura()->getSqUnidadeOrg() : 0; $this->getRequest()->setPost('sqVolume', $volume->getSqVolume()); $this->getRequest()->setPost('sqPessoaAbertura', $sqPessoaAbertura); $this->getRequest()->setPost('sqUnidadeOrgAbertura', $sqUnidadeOrgAbertura); if ($volume->getSqPessoaAssinaturaAbertura() && $volume->getSqCargoAssinaturaAbertura()) { $this->getRequest()->setPost('sqPessoaAssinaturaAbertura', $volume->getSqPessoaAssinaturaAbertura()->getSqPessoa()); $this->getRequest()->setPost('sqCargoAssinaturaAbertura', $volume->getSqCargoAssinaturaAbertura()->getSqCargo()); } if ($volume->getSqPessoaAssinaturaAbertura() && $volume->getSqFuncaoAssinaturaAbertura()) { $this->getRequest()->setPost('sqPessoaAssinaturaAbertura', $volume->getSqPessoaAssinaturaAbertura()->getSqPessoa()); $this->getRequest()->setPost('sqFuncaoAssinaturaAbertura', $volume->getSqFuncaoAssinaturaAbertura()->getSqFuncao()); } $this->getRequest()->setPost('sqPessoaEncerramento', \Core_Integration_Sica_User::getPersonId()); $this->getRequest()->setPost('sqUnidadeOrgEncerramento', (int) \Core_Integration_Sica_User::getUserUnit()); $this->_optionsDtoEntity['mapping'] = array_merge($this->_optionsDtoEntity['mapping'], array('sqPessoaAssinaturaEncerramento' => array('sqPessoa' => 'Sgdoce\\Model\\Entity\\VwPessoa'), 'sqCargoAssinaturaEncerramento' => array('sqCargo' => 'Sgdoce\\Model\\Entity\\VwCargo'), 'sqFuncaoAssinaturaEncerramento' => array('sqFuncao' => 'Sgdoce\\Model\\Entity\\VwFuncao'), 'sqPessoaEncerramento' => array('sqPessoa' => 'Sgdoce\\Model\\Entity\\VwPessoa'), 'sqUnidadeOrgEncerramento' => array('sqUnidadeOrg' => 'Sgdoce\\Model\\Entity\\VwUnidadeOrg'))); } else { $isValid = false; $this->getMessaging()->addErrorMessage('Volume não pode ter mais de 200 páginas.', 'User'); } } if ($isValid) { $entity = $this->_save(); $this->getService()->finish(); $this->_addMessageSave(); return $this->_redirect("/artefato/volume/termo/id/" . $entity->getSqVolume()); } $this->getMessaging()->dispatchPackets(); $sqTipoArtefato = \Core_Configuration::getSgdoceTipoArtefatoProcesso(); return $this->_redirect("/artefato/area-trabalho/index/tipoArtefato/{$sqTipoArtefato}/caixa/minhaCaixa"); }
/** * @return void */ public function saveAction() { parent::saveAction(); if (!$this->_request->isPost()) { throw new RuntimeException('A requisição deve ser POST'); } $data = $this->_request->getPost(); $this->_save(); $this->getService()->finish(); $this->_addMessageSave(); $isResposta = $data['isReposta']; if ($isResposta) { return $this->_redirectActionDefault('index'); } else { $this->_redirect("/artefato/area-trabalho/index/tipoArtefato/" . \Core_Configuration::getSgdoceTipoArtefatoProcesso()); } }
public function saveSequencialProcesso($sequencial) { $criteria = array('sqTipoArtefato' => \Core_Configuration::getSgdoceTipoArtefatoProcesso(), 'sqTipoDocumento' => NULL, 'sqUnidadeOrg' => NULL); $seqProcesso = $this->findBy($criteria); $seqProcesso[0]->setNuSequencial($sequencial); $this->getEntityManager()->persist($seqProcesso[0]); }
/** * @return */ public function listGridHistorico(\Core_Dto_Search $dto) { $listCondition = array('getSqTipoAssuntoSolicitacao' => array("=" => array("AND" => 'tas.sq_tipo_assunto_solicitacao'))); $operationTypeArtefato = 'IS NULL'; if (in_array($dto->getSqTipoArtefato(), array(1, 2))) { $operationTypeArtefato = '='; } $listCondition['getSqTipoArtefato'] = array($operationTypeArtefato => array("AND" => 'taa.sq_tipo_artefato')); if ($dto->getNuArtefato() != '' && $dto->getSqTipoArtefato()) { if ($dto->getSqTipoArtefato() == \Core_Configuration::getSgdoceTipoArtefatoProcesso()) { $listCondition['getNuArtefato'] = array("ilike" => array("OR" => array("formata_numero_artefato(at.nu_artefato, ap.co_ambito_processo)", 'at.nu_artefato'))); } else { $listCondition['getNuArtefato'] = array("ilike" => array("AND" => "formata_numero_digital(at.nu_digital)")); } } $where = $this->getEntityManager()->getRepository('app:Artefato')->getCriteriaText($listCondition, $dto); if ($dto->getDtSolicitacao() != "") { $dateInicial = new \Zend_Date($dto->getDtSolicitacao()); $dateFinal = new \Zend_Date($dto->getDtSolicitacao()); $dateInicial->setHour(00)->setMinute(00)->setSecond(00); $dateFinal->setHour(23)->setMinute(59)->setSecond(59); $where .= $where ? ' AND ' : ' '; $where .= "s.dt_solicitacao between '{$dateInicial->get(\Zend_Date::ISO_8601)}' and '{$dateFinal->get(\Zend_Date::ISO_8601)}'"; } $rsm = new \Doctrine\ORM\Query\ResultSetMapping($this->_em); $rsm->addScalarResult('total_record', 'totalRecord', 'integer'); $rsm->addScalarResult('sq_artefato', 'sqArtefato', 'integer'); $rsm->addScalarResult('sq_solicitacao', 'sqSolicitacao', 'integer'); $rsm->addScalarResult('dt_solicitacao', 'dtSolicitacao', 'string'); $rsm->addScalarResult('no_tipo_status_solicitacao', 'noTipoStatusSolicitacao', 'string'); $rsm->addScalarResult('no_pessoa_abertura', 'noPessoaAbertura', 'string'); $rsm->addScalarResult('no_unidade_abertura', 'noUnidadeAbertura', 'string'); $rsm->addScalarResult('nu_artefato', 'nuArtefato', 'string'); $rsm->addScalarResult('no_tipo_assunto_solicitacao', 'noTipoAssuntoSolicitacao', 'string'); $rsm->addScalarResult('ds_solicitacao', 'dsSolicitacao', 'string'); $rsm->addScalarResult('has_image', 'hasImage', 'boolean'); $sql = "SELECT COUNT(s.sq_solicitacao) OVER() AS total_record,\n s.sq_artefato,\n s.sq_solicitacao,\n s.dt_solicitacao,\n uss.no_tipo_status_solicitacao,\n s.sq_pessoa as sq_pessoa_abertura,\n und_abertura.sg_unidade_org as no_unidade_abertura,\n pes_abertura.no_pessoa || (COALESCE('<br>(' || tel.nu_ddd || ') ' || tel.nu_telefone, '')) as no_pessoa_abertura,\n\n CASE\n WHEN at.nu_digital IS NOT NULL THEN\n sgdoce.formata_numero_digital(at.nu_digital)\n ELSE\n sgdoce.formata_numero_artefato(at.nu_artefato, ap.co_ambito_processo)\n END AS nu_artefato,\n tas.no_tipo_assunto_solicitacao,\n s.ds_solicitacao\n FROM sgdoce.solicitacao s\n JOIN sgdoce.tipo_assunto_solicitacao AS tas USING(sq_tipo_assunto_solicitacao)\n LEFT JOIN (\n sgdoce.artefato AS at\n INNER JOIN sgdoce.tipo_artefato_assunto AS taa ON at.sq_tipo_artefato_assunto = taa.sq_tipo_artefato_assunto\n LEFT JOIN sgdoce.artefato_processo AS ap ON at.sq_artefato = ap.sq_artefato\n ) ON s.sq_artefato = at.sq_artefato\n\n JOIN corporativo.vw_pessoa AS pes_abertura ON s.sq_pessoa = pes_abertura.sq_pessoa\n JOIN corporativo.vw_unidade_org AS und_abertura ON s.sq_unidade_org = und_abertura.sq_pessoa\n JOIN sgdoce.vw_ultimo_status_solicitacao AS uss ON s.sq_solicitacao = uss.sq_solicitacao\n LEFT JOIN corporativo.vw_telefone AS tel ON (tel.sq_pessoa = pes_abertura.sq_pessoa AND tel.sq_tipo_telefone = " . \Core_Configuration::getCorpTipoTelefoneInstitucional() . ")\n %s\n ORDER BY s.dt_solicitacao DESC"; if ($where != "") { $sql = sprintf($sql, "WHERE {$where}"); } else { $sql = sprintf($sql, ""); } return $this->_em->createNativeQuery($sql, $rsm)->useResultCache(false); }
public function setMigracaoConcluida($sqArtefato) { $entArtefato = $this->getEntityManager()->getPartialReference('app:Artefato', $sqArtefato); // Validação para migração do artefato processo ao corrigir todas as inconsistẽncias. if ($entArtefato instanceof \Sgdoce\Model\Entity\Artefato && $entArtefato->getSqTipoArtefatoAssunto()->getSqTipoArtefato() && $entArtefato->getSqTipoArtefatoAssunto()->getSqTipoArtefato()->getSqTipoArtefato() == \Core_Configuration::getSgdoceTipoArtefatoProcesso()) { $dtoInconsistente = \Core_Dto::factoryFromData(array('sqArtefato' => $entArtefato->getSqArtefato()), 'search'); // Valida somente dados if (!$this->getServiceLocator()->getService('Artefato')->isInconsistent($dtoInconsistente, false, true)) { $this->getServiceLocator()->getService('DocumentoMigracao')->setHasImage($entArtefato->getSqArtefato()); foreach ($this->_arSqArtefatosProcesso as $sqArtefato) { $this->getServiceLocator()->getService('DocumentoMigracao')->setHasImage($sqArtefato); } } } // Histórico // #HistoricoArtefato::save(); $strMessage = $this->getServiceLocator()->getService('HistoricoArtefato')->getMessage('MH023'); $this->getServiceLocator()->getService('HistoricoArtefato')->registrar($entArtefato->getSqArtefato(), \Core_Configuration::getSgdoceSqOcorrenciaCorrigirMigracao(), $strMessage); }
/** * @param integer $sqArtefato * @return boolean */ public function hasImage($sqArtefato, $sqTipoArtefato = null) { try { if ($sqTipoArtefato == \Core_Configuration::getSgdoceTipoArtefatoProcesso()) { $entityArtefato = $this->_getRepository($this->_entityArtefato)->find($sqArtefato); $sqTipoArtefato = $entityArtefato->getSqTipoArtefatoAssunto()->getSqTipoArtefato()->getSqTipoArtefato(); /** * se for processo recupera a 1ª peça para verificar se tem imagem */ if ($sqTipoArtefato == \Core_Configuration::getSgdoceTipoArtefatoProcesso()) { $entityArtefatoVinculoPrimeiraPeca = $this->_getRepository($this->_entityArtefatoVinculo)->findOneBy(array('sqArtefatoPai' => $sqArtefato, 'sqTipoVinculoArtefato' => \Core_Configuration::getSgdoceTipoVinculoArtefatoAutuacao())); /** * Não existe vinculo de primeira peça para o processo */ if (null === $entityArtefatoVinculoPrimeiraPeca) { return false; } //pega o sqArtefato do pai $sqArtefato = $entityArtefatoVinculoPrimeiraPeca->getSqArtefatoFilho()->getSqArtefato(); } } $filePath = $this->getImagePath($sqArtefato); if (empty($filePath)) { return false; } $file = sprintf('%1$s%2$s..%2$sdata%2$s%3$s', APPLICATION_PATH, DIRECTORY_SEPARATOR, $filePath); if (!file_exists($file)) { throw new \Core_Exception_ServiceLayer('Imagem cadastrada, porém não foi encontrado o arquivo da mesma'); } $artefatoImagemEntity = $this->_getArtefatoImageEntity($sqArtefato); $hashValidate = new \Zend_Validate_File_Hash(array('hash' => $artefatoImagemEntity->getTxHash(), 'algorithm' => self::HASH_ALGORITHM)); if (!$hashValidate->isValid($file)) { throw new \Core_Exception_ServiceLayer('Autenticidade da imagem violada'); } } catch (\Exception $exp) { $message = sprintf('[SGDoc-e] Exception %s in %s(%d): "%s"', get_class($exp), __METHOD__, $sqArtefato, $exp->getMessage()); error_log($message); throw $exp; } return true; }
/** * @param \Core_Dto_Search $dto * @return array */ public function comboArtefato($dto) { $sqTipoArtefato = $dto->getSqTipoArtefato(); $field = "nuDigital"; if ($sqTipoArtefato == \Core_Configuration::getSgdoceTipoArtefatoProcesso()) { $field = "nuArtefato"; } $list = $this->_getRepository()->searchArtefato($dto); if (!isset($list['__NO_CLICK__'])) { $out = array(); foreach ($list as $item) { $out[$item['sqArtefato']] = "{$item[$field]}"; } return $out; } return $list; }
/** * método que implementa grid * @param array $params * @return array $result */ public function listGrid(\Core_Dto_Search $params) { $repository = $this->getEntityManager()->getRepository($this->_entityName); $result = $repository->searchPageDto('listGrid', $params); // caso a unidade possua numero de NUP então visualiza o sequencia de processo if ($params->getNoPessoa() != '') { $entityPessoa = $this->getServiceLocator()->getService('VwUnidadeOrg')->find($params->getNoPessoa()); if ($entityPessoa && $entityPessoa->getNuNup() != NUll) { $seqProcesso = $repository->findOneBy(array('sqTipoArtefato' => \Core_Configuration::getSgdoceTipoArtefatoProcesso(), 'nuAno' => $params->getNuAno(), 'sqUnidadeOrg' => $entityPessoa->getSqUnidadeOrg())); if (!$seqProcesso) { $sqTipoArtefato = $this->_getRepository('app:TipoArtefato')->find(\Core_Configuration::getSgdoceTipoArtefatoProcesso()); $seqProcesso = new \Sgdoce\Model\Entity\SequencialArtefato(); $seqProcesso->setSqTipoArtefato($sqTipoArtefato); $seqProcesso->setNuAno($params->getNuAno()); $seqProcesso->setSqUnidadeOrg($entityPessoa); $seqProcesso->setNuSequencial(0); $this->getEntityManager()->persist($seqProcesso); $this->getEntityManager()->flush(); } if ($seqProcesso != NULL) { $result['data']->append($seqProcesso->toArray()); } } } return $result; }
/** * Listagem de artefatos de migração inconsistentes. * * @param \Core_Dto_Abstract $dto * @return \Doctrine\ORM\QueryBuilder */ public function listGridArtefatosInconsistentes(\Core_Dto_Search $dto) { $rsm = new \Doctrine\ORM\Query\ResultSetMapping(); $rsm->addScalarResult('total_record', 'totalRecord', 'integer'); $rsm->addScalarResult('sq_artefato', 'sqArtefato', 'integer'); $rsm->addScalarResult('nu_digital', 'nuDigital', 'string'); $rsm->addScalarResult('nu_artefato', 'nuArtefato', 'string'); $rsm->addScalarResult('dt_cadastro', 'dtCadastro', 'zenddate'); $not = "NOT"; $proc = "LEFT"; if ($dto->sqTipoArtefato == \Core_Configuration::getSgdoceTipoArtefatoProcesso()) { $not = ""; $proc = ""; } $sql = 'SELECT COUNT(sq_artefato) OVER() AS total_record, * FROM ( SELECT a.sq_artefato, LPAD(CAST(a.nu_digital AS VARCHAR), 7, \'0\') AS nu_digital, a.dt_cadastro, sgdoce.formata_numero_artefato(a.nu_artefato, ap.co_ambito_processo ) as nu_artefato FROM sgdoce.artefato a LEFT JOIN sgdoce.tramite_artefato ta using(sq_artefato) ' . $proc . ' JOIN sgdoce.artefato_processo ap ON a.sq_artefato = ap.sq_artefato WHERE a.st_migracao AND a.nu_digital IS ' . $not . ' NULL AND a.ar_inconsistencia IS NOT NULL AND FALSE = ANY(a.ar_inconsistencia) AND ta.st_ultimo_tramite AND ta.sq_pessoa_destino IS NULL %1$s ) AS totalizador ORDER BY nu_digital, nu_artefato NULLS LAST'; $optionalCondition = ''; $search = mb_strtolower($dto->getSearch(), 'UTF-8'); if ($search) { $queryBuild = $this->_em->createQueryBuilder(); if ($dto->sqTipoArtefato == \Core_Configuration::getSgdoceTipoArtefatoProcesso()) { $nuArtefato = $this->_em->createQueryBuilder()->expr()->lower("TRANSLATE(a.nu_artefato, './-', '')")->__toString(); $optionalCondition = " AND (" . $queryBuild->expr()->eq('a.nu_artefato', $queryBuild->expr()->literal($search))->__toString() . " OR " . $queryBuild->expr()->eq($nuArtefato, $queryBuild->expr()->literal(str_replace(array('.', '/', '-'), '', $search)))->__toString() . ")"; } else { $optionalCondition = " AND " . $queryBuild->expr()->eq('a.nu_digital', $search)->__toString(); } } $query = $this->_em->createNativeQuery(sprintf($sql, $optionalCondition), $rsm); $query->setParameter('sqUnidadeOrg', \Core_Integration_Sica_User::getUserUnit())->useResultCache(false); return $query; }
/** * @throws RuntimeException */ public function saveAction() { if (!$this->_request->isPost()) { throw new RuntimeException('A requisição deve ser POST'); } $this->_save(); $this->getService()->finish(); $this->_addMessageSave(); $this->_redirect("/artefato/area-trabalho/index/tipoArtefato/" . \Core_Configuration::getSgdoceTipoArtefatoProcesso() . "/caixa/minhaCaixa"); }