/**
  * Método que obtém os dados para grid
  * @param \Core_Dto_Search $dtoSearch
  * @return array
  */
 public function getResultList(\Core_Dto_Search $dtoSearch)
 {
     $this->view->perfil = Core_Integration_Sica_User::getUserProfile();
     $dtoSearch->sqPessoa = Core_Integration_Sica_User::getPersonId();
     $dtoSearch->sqUnidadeOrg = Core_Integration_Sica_User::getUserUnit();
     $dtoSearch->sqTipoArtefato = $this->getRequest()->getParam('tipoArtefato') ? $this->getRequest()->getParam('tipoArtefato') : 1;
     $dtoSearch->search = $this->getRequest()->getParam('search') ? $this->getRequest()->getParam('search') : NULL;
     $this->view->isUserSgi = $this->_isUserSgi();
     $this->view->isUnidadePro = $this->getService('AutuarDocumento')->isUnidadeProtocolizadora(false);
     $this->view->isUserPro = $this->view->perfil == \Core_Configuration::getSgdocePerfilProtocolo();
     $this->view->isAllowedAlter = in_array(\Core_Integration_Sica_User::getUserProfile(), $this->getService()->getUsersAllowedAlterArtefact());
     $dtoUnidadeOrg = Core_Dto::factoryFromData(array('sqUnidadeOrg' => $dtoSearch->sqUnidadeOrg), 'search');
     $dtoSearch->currentUnitHasNUP = $this->getService('VwUnidadeOrg')->hasNUP($dtoUnidadeOrg);
     $caixa = null;
     switch (true) {
         case $this->_getParam('unit_box'):
             $caixa = $this->_getParam('unit_box');
             break;
         case $this->_getParam('my_box'):
             $caixa = $this->_getParam('my_box');
             break;
         case $this->_getParam('archive_box'):
             $caixa = $this->_getParam('archive_box');
             break;
         default:
             $caixa = $this->_getParam('external_box');
             break;
     }
     $dtoSearch->caixa = $caixa;
     $res = $this->getService()->getGrid($dtoSearch);
     return $res;
 }
Esempio n. 2
0
 /**
  * @param Core_Dto_Entity
  * @throws Exception
  * */
 public function register(\Core_Dto_Entity $dto)
 {
     # @todo implementar regra de negocio que verifica se o comentario pode ser alterado
     # falta a definicao da estrutura tabela
     # recupera referencia da pessoa que está realizando operacao
     $pessoa = $this->_getRepository('app:VwPessoa')->find(\Core_Integration_Sica_User::getPersonId());
     # verifica o autor existe (usuario da sessao existe na base)
     # isso poderá ocorrer quando a sessao cair perando a realizacao
     # da operacao
     if (!count($pessoa)) {
         throw new \Exception(self::T_COMENTARIO_AUTHOR_NOT_FOUND);
     }
     $dto->setSqPessoa($pessoa);
     # recupera a unidade organizacional da pessoa que esta manipulando o comentario
     $dto->setSqUnidadeOrg($this->_getRepository('app:VwUnidadeOrg')->find(\Core_Integration_Sica_User::getUserUnit()));
     # verifica se o registro já existe
     $this->_alreadyExists($dto);
     # se o sq_comentario_artefato existir indica uma alteracao.
     # Devido a propriedade de tempo nunca será possível repedir um registro
     # se levar esta propriedade em consideracao
     if ($dto->getSqComentarioArtefato()) {
         $this->_update($dto);
         $this->getMessaging()->addSuccessMessage('MD002', 'User');
     } else {
         # define a hora de registro/alteracao
         $dto->setDtComentario(\Zend_Date::now());
         # delega a operação de salvar os dados para superclasse
         $this->_save($dto);
         $this->getMessaging()->addSuccessMessage('MD001', 'User');
     }
     $this->finish();
     $this->getMessaging()->dispatchPackets();
 }
 /**
  *
  * @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);
 }
Esempio n. 4
0
 /**
  *
  * @param $entity
  * @param \Core_Dto $dto
  */
 public function preInsert($entity, $dto = NULL)
 {
     $dtoDuplicado = \Core_Dto::factoryFromData(array('sqArtefato' => $dto->getSqArtefato(), 'sqTipoAssuntoSolicitacao' => $dto->getSqTipoAssuntoSolicitacao(), 'sqPessoa' => \Core_Integration_Sica_User::getPersonId(), 'sqUnidadeOrg' => \Core_Integration_Sica_User::getUserUnit()), 'search');
     $listResult = $this->_getRepository()->getSolicitacaoDuplicado($dtoDuplicado);
     if (count($listResult)) {
         throw new \Core_Exception_ServiceLayer(\Core_Registry::getMessage()->translate('MN206'));
     }
     # artefatos inconsistêntes não podem abrir solicitação de alguns tipos de solicitação
     $isInconsistent = $this->getServiceLocator()->getService('Artefato')->isInconsistent($dtoDuplicado);
     if ($isInconsistent && in_array($dto->getSqTipoAssuntoSolicitacao(), $this->getTipoAssuntoSolcOnlyConsistent())) {
         throw new \Core_Exception_ServiceLayer(\Core_Registry::getMessage()->translate('MN205'));
     }
     # se for exclusão de volume e só houver um volume cadastrado, não permite a criação
     if ($dto->getSqTipoAssuntoSolicitacao() == \Core_Configuration::getSgdoceTipoAssuntoSolicitacaoVolumeDeProcesso() && !$this->_getRepository('app:ProcessoVolume')->notTheOnlyVolume($dto->getSqArtefato())) {
         throw new \Core_Exception_ServiceLayer(\Core_Registry::getMessage()->translate('MN207'));
     }
     //Tira os Espaços do 'enter' para salvar com 500 caracteres
     $dsSolicitacao = $this->getServiceLocator()->getService('MinutaEletronica')->fixNewlines($entity->getDsSolicitacao());
     $entity->setDsSolicitacao(!$dsSolicitacao ? NULL : $dsSolicitacao);
     $this->getEntityManager()->getConnection()->beginTransaction();
     try {
         $entSqPessoa = $this->getEntityManager()->getPartialReference('app:VwPessoa', \Core_Integration_Sica_User::getPersonId());
         $entSqUnidadeOrg = $this->getEntityManager()->getPartialReference('app:VwUnidadeOrg', \Core_Integration_Sica_User::getUserUnit());
         $entTipoAssuntoSolicitacao = $this->_getRepository('app:TipoAssuntoSolicitacao')->find($dto->getSqTipoAssuntoSolicitacao());
         $entity->setDtSolicitacao(\Zend_Date::now());
         $entity->setSqPessoa($entSqPessoa);
         $entity->setSqUnidadeOrg($entSqUnidadeOrg);
         $entity->setSqTipoAssuntoSolicitacao($entTipoAssuntoSolicitacao);
     } catch (\Exception $e) {
         $this->getEntityManager()->getConnection()->rollback();
         throw $e;
     }
 }
Esempio n. 5
0
 /**
  * SALVA HISTORICO.
  *
  * @param Sgdoce\Model\Entity\HistoricoArtefato $entHistoricoArtefato
  *
  * @return Sgdoce\Model\Entity\HistoricoArtefato
  */
 public function save(\Core_Dto_Entity $entHistoricoArtefato)
 {
     $arrDto = array('sqPessoa' => \Core_Integration_Sica_User::getPersonId(), 'sqUnidade' => \Core_Integration_Sica_User::getUserUnit());
     $objCDto = \Core_Dto::factoryFromData($arrDto, 'search');
     $entVwPessoa = $this->getServiceLocator()->getService('Pessoa')->findbyPessoaCorporativo($objCDto);
     $entVwUnidOrg = $this->getServiceLocator()->getService('VwUnidadeOrg')->getDadosUnidade($objCDto);
     return $this->_save($entHistoricoArtefato->getSqArtefato(), $entVwUnidOrg, $entVwPessoa, $entHistoricoArtefato->getSqOcorrencia(), $entHistoricoArtefato->getTxDescricaoOperacao());
 }
 /**
  * PAINEL DE DEMANDAS DE INFORMAÇÃO.
  *
  * @return void
  */
 public function indexAction()
 {
     $sqPessoaDestino = $this->getRequest()->getParam('idMeu', null);
     $this->view->sqUnidadeOrgPessoaDestino = \Core_Integration_Sica_User::getUserUnit();
     $this->view->sqUnidadeOrgPessoaPrazo = $this->view->sqUnidadeOrgPessoaDestino;
     $this->view->sqPessoaDestino = $sqPessoaDestino;
     $this->view->sqPessoaPrazo = $this->view->sqPessoaDestino;
 }
Esempio n. 7
0
 /**
  * Método que popula os objetos para serem salvos no banco
  * @return void
  */
 public function setOperationalEntity($entityName = NULL)
 {
     $userUnit = \Core_Integration_Sica_User::getUserUnit();
     $personId = \Core_Integration_Sica_User::getPersonId();
     $this->_data['sqUnidadeUsuario'] = $this->_getRepository('app:VwUnidadeOrg')->find($userUnit);
     $this->_data['sqPessoaCadastro'] = $this->_getRepository('app:VwPessoa')->find($personId);
     $this->_data['sqClassificacao'] = $this->_getRepository('app:Classificacao')->find($this->_data['sqClassificacao']);
     $this->_data['sqUnidadeOrg'] = $this->_getRepository('app:VwUnidadeOrg')->find($this->_data['sqUnidadeOrg']);
     $this->_data['stFechamento'] = false;
     $this->_data['dtCadastro'] = \Zend_Date::now();
     $this->_data['stAtivo'] = true;
 }
 /**
  * Método que obtém os dados para grid
  * @param \Core_Dto_Search $dtoSearch
  * @return array
  */
 public function getResultList(\Core_Dto_Search $dtoSearch)
 {
     $this->view->perfil = Core_Integration_Sica_User::getUserProfile();
     $dtoSearch->sqPessoa = Core_Integration_Sica_User::getPersonId();
     $dtoSearch->sqUnidadeOrg = Core_Integration_Sica_User::getUserUnit();
     $dtoSearch->sqTipoArtefato = $this->getRequest()->getParam('tipoArtefato') ? $this->getRequest()->getParam('tipoArtefato') : 1;
     $dtoSearch->search = $this->getRequest()->getParam('search') ? $this->getRequest()->getParam('search') : null;
     $this->view->isUserSgi = $this->_isUserSgi();
     $this->view->isUserPro = $this->view->perfil == \Core_Configuration::getSgdocePerfilProtocolo();
     $dtoUnidadeOrg = Core_Dto::factoryFromData(array('sqUnidadeOrg' => $dtoSearch->sqUnidadeOrg), 'search');
     $dtoSearch->currentUnitHasNUP = $this->getService('VwUnidadeOrg')->hasNUP($dtoUnidadeOrg);
     $caixa = $this->_getParam('migration_box');
     $dtoSearch->caixa = $caixa;
     $res = $this->getService()->getGrid($dtoSearch);
     return $res;
 }
Esempio n. 9
0
 /**
  * @param $entity
  * @param $dto
  */
 public function preSave($entity, $dto = NULL, $entPrazo = NULL)
 {
     $sqPessoaDestino = $entity->getSqPessoaDestino();
     if ($sqPessoaDestino && is_numeric($sqPessoaDestino)) {
         $entSqPessoaDestino = $this->getEntityManager()->getPartialReference('app:VwPessoa', $entity->getSqPessoaDestino());
         $entity->setSqPessoaDestino($entSqPessoaDestino);
     } else {
         if ($sqPessoaDestino instanceof \Sgdoce\Model\Entity\VwPessoa) {
             if ($entity->getSqPessoaDestino() && is_null($entity->getSqPessoaDestino()->getSqPessoa())) {
                 $entity->setSqPessoaDestino(NULL);
             }
         } else {
             $entity->setSqPessoaDestino(NULL);
         }
     }
     if (is_null($entity->getDtCadastro())) {
         $entity->setDtCadastro(\Zend_Date::now());
     }
     $sqPrazoPai = $entity->getSqPrazoPai();
     if (!empty($sqPrazoPai) && is_numeric($sqPrazoPai)) {
         $entPrazoPai = $this->getEntityManager()->getPartialReference('app:Prazo', $sqPrazoPai);
         $entity->setSqPrazoPai($entPrazoPai);
     }
     $entSqUnidadeOrgPessoa = $this->getEntityManager()->getPartialReference('app:VwUnidadeOrg', \Core_Integration_Sica_User::getUserUnit());
     $entSqPessoa = $this->getEntityManager()->getPartialReference('app:VwPessoa', \Core_Integration_Sica_User::getPersonId());
     if ($dto->getIsResposta()) {
         $entity->setDtResposta(\Zend_Date::now());
         $entity->setSqUnidadeOrgPessoaResposta($entSqUnidadeOrgPessoa);
         $entity->setSqPessoaResposta($entSqPessoa);
         $entity->setDtPrazo($entPrazo->getDtPrazo());
         $entity->setTxSolicitacao($entPrazo->getTxSolicitacao());
         if ($dto->getSqArtefatoResposta()) {
             $entArtefatoResposta = $this->getEntityManager()->getPartialReference('app:Artefato', (int) $dto->getSqArtefatoResposta());
             $entity->setSqArtefatoResposta($entArtefatoResposta);
         } else {
             $entity->setSqArtefatoResposta(NULL);
         }
         $entSqUnidadeOrgPessoaPrazo = $this->getEntityManager()->getPartialReference('app:VwUnidadeOrg', $entPrazo->getSqUnidadeOrgPessoaPrazo()->getSqUnidadeOrg());
         $entSqPessoaPrazo = $this->getEntityManager()->getPartialReference('app:VwPessoa', $entPrazo->getSqPessoaPrazo()->getSqPessoa());
         $entity->setSqUnidadeOrgPessoaPrazo($entSqUnidadeOrgPessoaPrazo);
         $entity->setSqPessoaPrazo($entSqPessoaPrazo);
     } else {
         $entity->setSqUnidadeOrgPessoaPrazo($entSqUnidadeOrgPessoa);
         $entity->setSqPessoaPrazo($entSqPessoa);
     }
 }
Esempio n. 10
0
 /**
  * ATUALIZA SEQUENCIAL DO ORGÃO.
  * 
  * @return integer
  */
 public function setSequencialProcesso()
 {
     $sqUnidadeOrg = \Core_Integration_Sica_User::getUserUnit();
     return $this->_getRepository('app:SequencialArtefato')->setSequencialProcesso($sqUnidadeOrg);
 }
Esempio n. 11
0
 /**
  *
  * @return integer
  */
 private function _checkDigitalEletronica()
 {
     $tipoDigital = $this->_getParam('tipoDigital');
     $params = array();
     $params['nuAno'] = date('Y');
     $params['sqTipoEtiqueta'] = (int) $tipoDigital;
     $params['sqUnidadeOrg'] = \Core_Integration_Sica_User::getUserUnit();
     $dtoSearch = Core_Dto::factoryFromData($params, 'search');
     Zend_Wildfire_Plugin_FirePhp::send($dtoSearch, 'dtoSearch');
     if (!$this->getService()->verificaLiberacaoDigitalEletronica($dtoSearch)) {
         return 1;
     }
     return 0;
 }
Esempio n. 12
0
 /**
  * @return string
  */
 public function getNovoNumeroProcesso()
 {
     $sqUnidadeOrg = \Core_Integration_Sica_User::getUserUnit();
     $nowZd = \Zend_Date::now();
     $vwUnidadeOrg = $this->getServiceLocator()->getService('VwUnidadeOrg')->find($sqUnidadeOrg);
     if ($vwUnidadeOrg->getNuNup() == '') {
         throw new \Exception("Unidade não protocolorizadora.");
     }
     $nuSequencial = $this->getServiceLocator()->getService('SequencialArtefato')->getNextSequencialProcesso();
     $nuArtefato = str_pad($vwUnidadeOrg->getNuNup(), 5, '0', STR_PAD_LEFT);
     $nuArtefato .= str_pad($nuSequencial->getNuSequencial(), 6, '0', STR_PAD_LEFT);
     $nuArtefato .= $nowZd->get(\Zend_Date::YEAR);
     return $this->calcularDigitoVerificador($nuArtefato);
 }
 public function createAction()
 {
     $this->getHelper('layout')->disableLayout();
     $allParams = $this->_getAllParams();
     if (!isset($allParams['id'])) {
         $this->_redirect('/artefato/area-trabalho');
     }
     if (false === $this->_checkPermissaoArtefato($allParams['id'])) {
         $this->_forward('index', null, null, array('id' => $allParams['id']));
     }
     $helper = new Sgdoce_View_Helper_NuArtefato();
     $entArtefato = $this->getService('Artefato')->find($allParams['id']);
     parent::createAction();
     $this->view->arrCargo = $this->getService('Cargo')->comboCargo();
     $this->view->arrFuncao = $this->getService('Funcao')->comboFuncao();
     $this->view->sqArtefato = $allParams['id'];
     $this->view->nuArtefato = $helper->nuArtefato($entArtefato);
     $this->view->sqUnidadeAssinatura = \Core_Integration_Sica_User::getUserUnit();
 }
Esempio n. 14
0
 public function excluirImagem($entArtefato, $txObservacao, $stAtivo = FALSE)
 {
     try {
         $entArtefatoImagem = $this->_getRepository("app:ArtefatoImagem")->findBy(array('sqArtefato' => $entArtefato->getSqArtefato(), 'stAtivo' => true));
         $entArtefatoImagem = current($entArtefatoImagem);
         if ($entArtefatoImagem) {
             $arrDto = array('sqPessoa' => \Core_Integration_Sica_User::getPersonId(), 'sqUnidade' => \Core_Integration_Sica_User::getUserUnit());
             $objCDto = \Core_Dto::factoryFromData($arrDto, 'search');
             $entVwPessoa = $this->getServiceLocator()->getService('Pessoa')->findbyPessoaCorporativo($objCDto);
             $entVwUnidOrg = $this->getServiceLocator()->getService('VwUnidadeOrg')->getDadosUnidade($objCDto);
             $entArtefatoImagem->setStAtivo($stAtivo);
             $entArtefatoImagem->setSqPessoaInativacao($entVwPessoa);
             $entArtefatoImagem->setSqUnidadeOrgInativacao($entVwUnidOrg);
             $entArtefatoImagem->setTxObservacao($txObservacao);
             $entArtefatoImagem->setDtInativacao(\Zend_Date::now());
             $this->getEntityManager()->persist($entArtefatoImagem);
             $this->getEntityManager()->flush();
             // REGISTRO DA EXCLUSÃO DA IMAGEM. #HistoricoArtefato::save();
             $haService = $this->getServiceLocator()->getService('HistoricoArtefato');
             $sqOcorrencia = \Core_Configuration::getSgdoceSqOcorrenciaExcluirImagem();
             $strMessage = $haService->getMessage('MH024', \Zend_Date::now()->get(\Zend_Date::DATETIME_MEDIUM), \Core_Integration_Sica_User::getUserName());
             $haService->registrar($entArtefato->getSqArtefato(), $sqOcorrencia, $strMessage);
             $this->getMessaging()->addSuccessMessage('MD003', 'User');
         } else {
             $this->getMessaging()->addErrorMessage('MN174', 'User');
         }
         $this->getMessaging()->dispatchPackets();
         return $entArtefatoImagem;
     } catch (\Core_Exception_ServiceLayer $e) {
         $this->getMessaging()->addErrorMessage($e->getMessage(), 'User');
         $this->getMessaging()->dispatchPackets();
     }
     return false;
 }
 /**
  * @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);
 }
Esempio n. 16
0
 /**
  * Salva o tramite dos artefatos
  *
  * @param array $data
  */
 public function processTramite(array $data)
 {
     $this->getEntityManager()->getConnection()->beginTransaction();
     try {
         $sqUnidadeOrigem = \Core_Integration_Sica_User::getUserUnit();
         $params = array('sqTipoRastreamento' => $data['sqTipoRastreamento'] ?: NULL, 'txCodigoRastreamento' => $data['txCodigoRastreamento'] ? trim(strip_tags(mb_strtoupper($data['txCodigoRastreamento'], 'UTF-8'))) : NULL, 'dtTramite' => \Zend_Date::now(), 'sqPessoaTramite' => \Core_Integration_Sica_User::getPersonId(), 'sqUnidadeOrgTramite' => \Core_Integration_Sica_User::getUserUnit(), 'sqStatusTramite' => \Core_Configuration::getSgdoceStatusTramiteTramitado());
         foreach ($data['sqArtefato'] as $sqArtefato) {
             $dtoSearchArtefato = \Core_Dto::factoryFromData(array('sqArtefato' => $sqArtefato), 'search');
             $params['sqArtefato'] = $sqArtefato;
             $params['nuTramite'] = $this->getNextTramiteNumber($dtoSearchArtefato);
             if ($data['tipo_tramite'] == 1) {
                 //interno
                 $params['sqPessoaDestino'] = (int) $data['sqUnidadeOrg'];
                 $params['sqPessoaDestinoInterno'] = $data['sqPessoaDestinoInterno'] ? (int) $data['sqPessoaDestinoInterno'] : NULL;
                 $this->_ruleTramiteInterno($sqUnidadeOrigem, $params['sqPessoaDestino']);
                 $params['inImpresso'] = TRUE;
                 $hasVinculoSigiloso = $this->_getRepository('app:ArtefatoVinculo')->hasVinculoSigiloso($sqArtefato);
                 if (!$params['sqPessoaDestinoInterno'] && $hasVinculoSigiloso) {
                     $entityArtefato = $this->_getRepository('app:Artefato')->find($sqArtefato);
                     $helper = new \Sgdoce_View_Helper_NuArtefato();
                     $nrArtefato = $helper->nuArtefato($entityArtefato);
                     throw new \Core_Exception_ServiceLayer(sprintf(\Core_Registry::getMessage()->translate('MN189'), $nrArtefato));
                 }
             } else {
                 //externo
                 //                    if ($data['stImprimeGuia'] && !$data['sqEndereco']) {
                 //                        throw new \Core_Exception_ServiceLayer(\Core_Registry::getMessage()->translate('MN172'));
                 //                    }else{
                 $params['sqEndereco'] = $data['sqEndereco'] ? $this->getEntityManager()->getPartialReference('app:vwEndereco', $data['sqEndereco']) : NULL;
                 //                    }
                 //                    $this->_checkArtefatoSigiloso($dtoSearchArtefato);
                 $params['sqPessoaDestino'] = $data['sqPessoaOrigem'];
                 $params['inImpresso'] = isset($data['inImpresso']) ? $data['inImpresso'] : TRUE;
             }
             // verifica se destino foi informado
             if (!isset($params['sqPessoaDestino']) || empty($params['sqPessoaDestino'])) {
                 throw new \Core_Exception_ServiceLayer(\Core_Registry::getMessage()->translate('MN201'));
             }
             $this->_checkHasImage($params);
             if (!is_null($params['sqTipoRastreamento'])) {
                 $params['sqTipoRastreamento'] = $this->getEntityManager()->getPartialReference('app:TipoRastreamentoCorreio', $data['sqTipoRastreamento']);
             } else {
                 $params['sqTipoRastreamento'] = NULL;
             }
             $entityDto = $this->montaEntidateTramite($params);
             $this->save($entityDto);
         }
         $this->getMessaging()->addSuccessMessage(\Core_Registry::getMessage()->translate('MN155'), 'User');
         $this->getMessaging()->dispatchPackets();
         $this->finish();
         $this->getEntityManager()->getConnection()->commit();
     } catch (\Exception $e) {
         $this->getEntityManager()->getConnection()->rollback();
         throw $e;
     }
 }
Esempio n. 17
0
 /**
  *
  * @param integer $sqArtefato
  * @return boolean
  * @throws \InvalidArgumentException
  */
 public function inMyDashboard($sqArtefato)
 {
     if (!$sqArtefato) {
         throw new \InvalidArgumentException('Values must not be empty.');
     }
     $sqPessoa = (int) \Core_Integration_Sica_User::getPersonId();
     $sqPessoaDestino = (int) \Core_Integration_Sica_User::getUserUnit();
     $dtoSearch = \Core_Dto::factoryFromData(array('sqArtefato' => $sqArtefato, 'sqPessoa' => $sqPessoa, 'sqPessoaDestino' => $sqPessoaDestino), 'search');
     return $this->_getRepository('app:VwUltimoTramiteArtefato')->inMyDashboard($dtoSearch);
 }
Esempio n. 18
0
 /**
  *
  * @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();
 }
Esempio n. 19
0
 public function getNotification()
 {
     $rsm = new \Doctrine\ORM\Query\ResultSetMapping();
     $rsm->addScalarResult('tipo', 'tipo', 'integer');
     $rsm->addScalarResult('intervalo', 'intervalo', 'integer');
     $rsm->addScalarResult('qtde', 'qtde', 'integer');
     $sqlSGI = "";
     $sqUnidadeOrg = (int) \Core_Integration_Sica_User::getUserUnit();
     if (\Zend_Registry::get('isUserSgi')) {
         $sqlSGI = "UNION\n\n                      SELECT 2 AS tipo\n                             ,2 AS intervalo\n                             ,COUNT(*) AS qtde\n                        FROM solicitacao AS s\n                        JOIN vw_ultimo_status_solicitacao AS vuss USING (sq_solicitacao)\n                       WHERE vuss.sq_tipo_status_solicitacao = " . \Core_Configuration::getSgdoceTipoStatusSolicitacaoAberta() . "\n                      HAVING COUNT(*) > 0\n\n                       UNION\n\n                      SELECT 2 AS tipo\n                             ,1 AS intervalo\n                             ,COUNT(*) AS qtde\n                        FROM solicitacao AS s\n                        JOIN vw_ultimo_status_solicitacao as vuss USING (sq_solicitacao)\n                       WHERE vuss.sq_tipo_status_solicitacao = " . \Core_Configuration::getSgdoceTipoStatusSolicitacaoEmAndamento() . "\n                         AND vuss.sq_pessoa_responsavel = :sqPessoa\n                      HAVING COUNT(*) > 0";
     }
     $sql = "WITH dias_prazo_demanda AS (\n                        SELECT 1 AS tipo\n                               ,EXTRACT(day FROM dt_prazo - CURRENT_DATE) AS qtd_dias\n                               ,sq_pessoa_destino\n                               ,sq_unidade_org_pessoa_destino\n                               ,sq_prazo\n                          FROM prazo\n                         WHERE dt_resposta IS NULL\n                )\n\n                SELECT 1 AS tipo\n                       ,5 AS intervalo\n                       ,COUNT(*) AS qtde\n                  FROM prazo\n                 WHERE dt_resposta is null\n                   AND sq_unidade_org_pessoa_destino = {$sqUnidadeOrg}\n                 GROUP BY tipo\n\n                UNION\n\n                SELECT tipo\n                       ,4 AS intervalo\n                       ,COUNT(*) AS qtde\n                  FROM dias_prazo_demanda\n                 WHERE qtd_dias > 5\n                   AND sq_pessoa_destino = :sqPessoa\n                   AND sq_unidade_org_pessoa_destino = {$sqUnidadeOrg}\n                 GROUP BY tipo\n\n                UNION\n\n                SELECT tipo\n                       ,3 AS intervalo\n                       ,COUNT(*) AS qtde\n                  FROM dias_prazo_demanda\n                 WHERE qtd_dias BETWEEN 2 AND 5\n                   AND sq_pessoa_destino = :sqPessoa\n                   AND sq_unidade_org_pessoa_destino = {$sqUnidadeOrg}\n                 GROUP BY tipo\n\n                UNION\n\n                SELECT tipo\n                       ,2 AS intervalo\n                       ,COUNT(*) AS qtde\n                  FROM dias_prazo_demanda\n                 WHERE qtd_dias between 0 AND 1\n                   AND sq_pessoa_destino = :sqPessoa\n                   AND sq_unidade_org_pessoa_destino = {$sqUnidadeOrg}\n                 GROUP BY tipo\n\n                UNION\n\n                SELECT tipo\n                       ,1 AS intervalo\n                       ,COUNT(*) AS qtde\n                  FROM dias_prazo_demanda\n                 WHERE qtd_dias < 0\n                   AND sq_pessoa_destino = :sqPessoa\n                   AND sq_unidade_org_pessoa_destino = {$sqUnidadeOrg}\n                 GROUP BY tipo\n\n                 {$sqlSGI}\n\n                ORDER BY tipo, intervalo";
     $query = $this->_em->createNativeQuery($sql, $rsm);
     $query->setParameter('sqPessoa', \Core_Integration_Sica_User::getPersonId());
     return $query->execute();
 }
Esempio n. 20
0
 /**
  * @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");
 }
 /**
  */
 public function searchArtefatoAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $params = $this->_getAllParams();
     if (isset($params['extraParam']) && $params['extraParam'] != '') {
         $params['sqTipoArtefato'] = $params['extraParam'];
     } else {
         $params['sqTipoArtefato'] = \Core_Configuration::getSgdoceTipoArtefatoDocumento();
     }
     $params['sqUnidadeOrg'] = \Core_Integration_Sica_User::getUserUnit();
     $params['sqPessoa'] = \Core_Integration_Sica_User::getPersonId();
     $dtoSearch = Core_Dto::factoryFromData($params, 'search');
     $this->getHelper('json')->sendJson($this->getService()->comboArtefato($dtoSearch));
 }
Esempio n. 22
0
 /**
  * Metódo que realiza o save do Artefato
  * @param Object $dtoSearch
  * @return \Sgdoce\Model\Entity\Artefato
  */
 public function saveArtefato(\Core_Dto_Search $dtoSearch)
 {
     $date = new \Zend_Date();
     $this->getEntityManager()->getConnection()->beginTransaction();
     try {
         $sqPessoaSgdoce = $this->_getRepository('app:PessoaSgdoce')->findBySqPessoaCorporativo(\Core_Integration_Sica_User::getPersonId());
         if (empty($sqPessoaSgdoce)) {
             $filter = new \Zend_Filter_Digits();
             $sqPessoaCorporativo = \Core_Integration_Sica_User::getPersonId();
             $data['sqPessoaCorporativo'] = $this->_getRepository('app:VwPessoa')->find($sqPessoaCorporativo);
             $dtoPessoaSearch = \Core_Dto::factoryFromData($data, 'search');
             $cpfCnpjPassaportUnfiltered = $this->getServiceLocator()->getService('VwPessoa')->returnCpfCnpjPassaporte($dtoPessoaSearch);
             $cpfCnpjPassaport = $filter->filter($cpfCnpjPassaportUnfiltered);
             $noPessoaCorporativo = $data['sqPessoaCorporativo']->getNoPessoa();
             $this->addPessoaSgdoce($sqPessoaCorporativo, $noPessoaCorporativo, $cpfCnpjPassaport);
             $sqPessoaSgdoce = $this->_getRepository('app:PessoaSgdoce')->findBySqPessoaCorporativo(\Core_Integration_Sica_User::getPersonId());
         }
         /** @var \Sgdoce\Model\Entity\Artefato $entityArtefato */
         $entityArtefato = $this->_newEntity('app:Artefato');
         //só seta o numero da digital se for documento tipo físico
         if (!$dtoSearch->getInEletronico()) {
             $entityLoteEtiqueta = $this->getEntityManager()->getPartialReference('app:LoteEtiqueta', $dtoSearch->getSqLoteEtiqueta());
             /** @var \Sgdoce\Model\Entity\EtiquetasUso $entityEtiquetasUso */
             $entityEtiquetasUso = $this->_newEntity('app:EtiquetasUso');
             $entityEtiquetasUso->setNuEtiqueta($dtoSearch->getNuDigital());
             $entityEtiquetasUso->setSqLoteEtiqueta($entityLoteEtiqueta);
             //persist Etiquetas Uso
             $this->getEntityManager()->persist($entityEtiquetasUso);
             $this->getEntityManager()->flush($entityEtiquetasUso);
             $entityArtefato->setNuDigital($entityEtiquetasUso);
             $entityArtefato->setSqLoteEtiqueta($entityEtiquetasUso);
         }
         $entityArtefato->setDtPrazo(NULL);
         $entityArtefato->setDtArtefato($date);
         $entityArtefato->setInEletronico($dtoSearch->getInEletronico());
         //persist artefato
         $this->getEntityManager()->persist($entityArtefato);
         $this->getEntityManager()->flush($entityArtefato);
         $sqPessoaFuncao = $this->getEntityManager()->getPartialReference('app:PessoaFuncao', \Core_Configuration::getSgdocePessoaFuncaoAutor());
         /** @var \Sgdoce\Model\Entity\PessoaArtefato $entityPessoaArtefato */
         $entityPessoaArtefato = $this->_newEntity('app:PessoaArtefato');
         $entityPessoaArtefato->setSqArtefato($entityArtefato);
         $entityPessoaArtefato->setSqPessoaSgdoce($sqPessoaSgdoce[0]);
         $entityPessoaArtefato->setSqPessoaFuncao($sqPessoaFuncao);
         $this->getEntityManager()->persist($entityPessoaArtefato);
         $this->getEntityManager()->flush($entityPessoaArtefato);
         // salva o historico do artefato
         $arrDto = array('sqPessoa' => \Core_Integration_Sica_User::getPersonId(), 'sqUnidade' => \Core_Integration_Sica_User::getUserUnit());
         // #HistoricoArtefato::save();
         $strMessage = $this->getServiceLocator()->getService('HistoricoArtefato')->getMessage('MH005');
         $this->getServiceLocator()->getService('HistoricoArtefato')->registrar($entityArtefato->getSqArtefato(), \Core_COnfiguration::getSgdoceSqOcorrenciaCadastrar(), $strMessage);
         $this->getEntityManager()->getConnection()->commit();
     } catch (\Exception $e) {
         $this->getEntityManager()->getConnection()->rollback();
         throw $e;
     }
     return $entityArtefato;
 }
 /**
  * Metódo para recuperar o ID do usuário logado
  * @return int
  */
 public function getIdUnidade()
 {
     return Core_Integration_Sica_User::getUserUnit();
 }
 public function qtdItensMinhaCaixaJsonAction()
 {
     $this->_jsonResponse(function () {
         return $this->getService()->getQtdItensMinhaCaixa(\Core_Integration_Sica_User::getPersonId(), \Core_Integration_Sica_User::getUserUnit(), $this->_getParam('artefactType', 0));
     });
 }
Esempio n. 25
0
 public function update(array $postData)
 {
     $configs = \Core_Registry::get('configs');
     if (!$postData['sqPessoaAssinaturaAbertura'] && $postData['sqPessoaAssinaturaAberturaBD_hidden']) {
         $postData['sqPessoaAssinaturaAbertura'] = $postData['sqPessoaAssinaturaAberturaBD_hidden'];
     }
     if (!$postData['sqPessoaAssinaturaEncerramento'] && $postData['sqPessoaAssinaturaEncerramentoBD_hidden']) {
         $postData['sqPessoaAssinaturaEncerramento'] = $postData['sqPessoaAssinaturaEncerramentoBD_hidden'];
     }
     $dtoVolume = \Core_Dto::factoryFromData($postData, 'search');
     if ($dtoVolume->getNuFolhaFinal() && (int) $dtoVolume->getNuFolhaFinal() <= (int) $dtoVolume->getNuFolhaInicial()) {
         throw new \Core_Exception_ServiceLayer('A Folha Final deve ser maior que a Folha Inicial.');
     }
     if ((int) $dtoVolume->getNuFolhaFinal() - (int) $dtoVolume->getNuFolhaInicial() > (int) $configs['volume']['maxPagePerVolume']) {
         throw new \Core_Exception_ServiceLayer('Volume não pode ter mais de 200 páginas.');
     }
     $hasDemandaAlterarVolume = $this->getServiceLocator()->getService('Solicitacao')->hasDemandaAbertaByAssuntoPessoaResponsavel(\Core_Dto::factoryFromData(array('sqArtefato' => $dtoVolume->getSqArtefato(), 'sqTipoAssuntoSolicitacao' => \Core_Configuration::getSgdoceTipoAssuntoSolicitacaoVolumeDeProcesso()), 'search'));
     $entVolume = $this->_getRepository()->find($dtoVolume->getSqVolume());
     if (\Zend_Registry::get('isUserSgi') && !$hasDemandaAlterarVolume && $this->_checkArtefatoLastTramite($entVolume) < 1) {
         throw new \Core_Exception_ServiceLayer(\Core_Registry::getMessage()->translate('MN147'));
     }
     $entArtefato = $this->getEntityManager()->getPartialReference('app:Artefato', $dtoVolume->getSqArtefato());
     $entPessAbertura = $this->getEntityManager()->getPartialReference('app:VwPessoa', $dtoVolume->getSqPessoaAbertura());
     $entUOrgAbertura = $this->getEntityManager()->getPartialReference('app:VwUnidadeOrg', $dtoVolume->getSqUnidadeOrgAbertura());
     $entPessAssAbertura = $this->getEntityManager()->getPartialReference('app:VwPessoa', $dtoVolume->getSqPessoaAssinaturaAbertura());
     $sqPessoaAbertura = \Core_Integration_Sica_User::getPersonId();
     $sqUnidadeOrgAbertura = \Core_Integration_Sica_User::getUserUnit();
     $entVolume->setSqVolume($dtoVolume->getSqVolume())->setSqArtefato($entArtefato)->setNuVolume($dtoVolume->getNuVolume())->setNuFolhaInicial($dtoVolume->getNuFolhaInicial())->setDtAbertura($dtoVolume->getDtAbertura())->setSqPessoaAbertura($entPessAbertura)->setSqUnidadeOrgAbertura($entUOrgAbertura)->setSqPessoaAssinaturaAbertura($entPessAssAbertura);
     if ($dtoVolume->getSqCargoAssinaturaAbertura()) {
         $entCargoAbertura = $this->getEntityManager()->getPartialReference('app:VwCargo', $dtoVolume->getSqCargoAssinaturaAbertura());
         $entVolume->setSqCargoAssinaturaAbertura($entCargoAbertura)->setSqFuncaoAssinaturaAbertura(NULL);
     } else {
         $entFuncaoAbertura = $this->getEntityManager()->getPartialReference('app:VwFuncao', $dtoVolume->getSqFuncaoAssinaturaAbertura());
         $entVolume->setSqFuncaoAssinaturaAbertura($entFuncaoAbertura)->setSqCargoAssinaturaAbertura(NULL);
     }
     if ($dtoVolume->getNuFolhaFinal()) {
         $entPessEncerramento = $this->getEntityManager()->getPartialReference('app:VwPessoa', \Core_Integration_Sica_User::getPersonId());
         $entUOrgEncerramento = $this->getEntityManager()->getPartialReference('app:VwUnidadeOrg', (int) \Core_Integration_Sica_User::getUserUnit());
         $entPessAssEncerramento = $this->getEntityManager()->getPartialReference('app:VwPessoa', $dtoVolume->getSqPessoaAssinaturaEncerramento());
         $entVolume->setNuFolhaFinal($dtoVolume->getNuFolhaFinal())->setDtEncerramento($dtoVolume->getDtEncerramento())->setSqPessoaEncerramento($entPessEncerramento)->setSqUnidadeOrgEncerramento($entUOrgEncerramento)->setSqPessoaAssinaturaEncerramento($entPessAssEncerramento);
         if ($dtoVolume->getSqCargoAssinaturaEncerramento()) {
             $entCargoEncerramento = $this->getEntityManager()->getPartialReference('app:VwCargo', $dtoVolume->getSqCargoAssinaturaEncerramento());
             $entVolume->setSqCargoAssinaturaEncerramento($entCargoEncerramento)->setSqFuncaoAssinaturaEncerramento(NULL);
         } else {
             $entFuncaoEncerramento = $this->getEntityManager()->getPartialReference('app:VwFuncao', $dtoVolume->getSqFuncaoAssinaturaEncerramento());
             $entVolume->setSqFuncaoAssinaturaEncerramento($entFuncaoEncerramento)->setSqCargoAssinaturaEncerramento(NULL);
         }
     } else {
         $entVolume->setNuFolhaFinal(NULL)->setDtEncerramento(NULL)->setSqPessoaEncerramento(NULL)->setSqUnidadeOrgEncerramento(NULL)->setSqPessoaAssinaturaEncerramento(NULL)->setSqCargoAssinaturaEncerramento(NULL)->setSqFuncaoAssinaturaEncerramento(NULL);
     }
     $this->getEntityManager()->persist($entVolume);
     $this->getEntityManager()->flush();
 }
 /**
  * retorna dados da grid
  * @param array $params
  * @return array
  */
 public function getResultList($params)
 {
     //garante quando o usuario não for SGI o filtro somente da unidade da pessoa logada
     if (!$this->_isUserSgi) {
         $params['sqUnidadeOrg'] = Core_Integration_Sica_User::getUserUnit();
     }
     $dtoSearch = \Core_Dto::factoryFromData($params, 'search');
     return $this->getService('LoteEtiqueta')->listGrid($dtoSearch);
 }
Esempio n. 27
0
 /**
  * metodo que trata o upload dos artefatos de migração
  */
 public function indexMigrationAction()
 {
     $params = $this->_viewSteps();
     if (isset($params['back'])) {
         $this->view->backUrl = str_replace('.', '/', $params['back']);
     }
     $dtoSearch = \Core_Dto::factoryFromData(array('sqArtefato' => $params['id']), 'search');
     $isImagemInconsistent = $this->getService("Artefato")->isInconsistent($dtoSearch, true);
     if ($this->view->hasImage && !$isImagemInconsistent) {
         $this->_redirect($this->view->backUrl ?: 'artefato/area-trabalho/index');
     }
     $this->view->canUpload = !$this->view->hasImage && $this->getService("Artefato")->inMyDashboard($params['id']) && $this->getService()->canUpload($params['id']);
     if ($isImagemInconsistent) {
         if ($this->getService()->hasArtefatoImagemData($dtoSearch)) {
             if (!$this->view->hasImage) {
                 $this->view->canUpload = true;
                 $this->view->canOverwrite = false;
             } else {
                 if ($isImagemInconsistent) {
                     $this->view->hasImage = false;
                     $this->view->canUpload = true;
                     $this->view->canOverwrite = true;
                 }
             }
         } else {
             $listSolicitacao = $this->getService()->getSolicitacaoMigracaoImagem($dtoSearch);
             if (!count($listSolicitacao)) {
                 $dtoSolicitacao = \Core_Dto::factoryFromData(array('sqPessoa' => \Core_Integration_Sica_User::getPersonId(), 'sqUnidadeOrg' => \Core_Integration_Sica_User::getUserUnit(), 'sqArtefato' => $params['id']), 'search');
                 $this->getService('VinculoMigracao')->addSolicitacaoMigracao($dtoSolicitacao);
                 $this->getMessaging()->addAlertMessage('A(s) imagem(ns) deste artefato ainda não foi(ram) processada(s), aguarde.', 'User');
                 $this->_redirect($this->view->backUrl ?: 'artefato/area-trabalho/index');
             } else {
                 $configs = \Core_Registry::get('configs');
                 $qtdeTentativa = $configs['migration']['qtdeTentativa'];
                 $entSolicitacao = current($listSolicitacao);
                 if ($entSolicitacao->getStProcessado() || !$entSolicitacao->getStProcessado() && $entSolicitacao->getInTentativa() == $qtdeTentativa) {
                     if (!$this->view->hasImage) {
                         $this->view->canUpload = true;
                         $this->view->canOverwrite = false;
                     } else {
                         $this->getMessaging()->addInfoMessage('Imagem deste artefato foi processada com sucesso, clique no visualizar imagem.', 'User');
                         $this->_redirect($this->view->backUrl ?: 'artefato/area-trabalho/index');
                     }
                 } else {
                     $this->getMessaging()->addAlertMessage('A imagem deste artefato ainda não foi processada, aguarde.', 'User');
                     $this->_redirect($this->view->backUrl ?: 'artefato/area-trabalho/index');
                 }
             }
         }
     }
     $this->render('index');
 }
Esempio n. 28
0
 /**
  * @param type $dto
  * @return type
  */
 protected function _inserirTramite($dto)
 {
     $this->getEntityManager()->getConnection()->beginTransaction();
     try {
         $objUltTramiteArtefato = $this->getServiceLocator()->getService('TramiteArtefato')->findBy(array('sqArtefato' => $dto->getSqArtefato()));
         $objUltTramiteArtefato = current($objUltTramiteArtefato);
         $entArtefato = $this->getEntityManager()->getPartialReference('app:Artefato', $dto->getSqArtefato());
         if ($objUltTramiteArtefato instanceof \Sgdoce\Model\Entity\TramiteArtefato) {
             // RECEBE ARTEFATO.
             $entStatusTramite = $this->getEntityManager()->getPartialReference('app:StatusTramite', \Core_Configuration::getSgdoceStatusTramiteRecebido());
             $entPessoa = $this->getEntityManager()->getPartialReference('app:VwPessoa', \Core_Integration_Sica_User::getPersonId());
             $entPessoaDestino = $this->getEntityManager()->getPartialReference('app:VwPessoa', \Core_Integration_Sica_User::getUserUnit());
             $entUnidadeOrg = $this->getEntityManager()->getPartialReference('app:VwUnidadeOrg', \Core_Integration_Sica_User::getUserUnit());
             $newTramiteArtefato = $this->_newEntity('app:TramiteArtefato');
             $artefatoDto = \Core_Dto::factoryFromData(array('sqArtefato' => $dto->getSqArtefato()), 'search');
             $nextNuTramite = $this->getServiceLocator()->getService('TramiteArtefato')->getNextTramiteNumber($artefatoDto);
             $newTramiteArtefato->setSqArtefato($entArtefato);
             $newTramiteArtefato->setSqPessoaTramite($entPessoa);
             $newTramiteArtefato->setSqUnidadeOrgTramite($entUnidadeOrg);
             $newTramiteArtefato->setSqPessoaDestino($entPessoaDestino);
             $newTramiteArtefato->setSqPessoaDestinoInterno($entPessoa);
             $newTramiteArtefato->setSqPessoaRecebimento($entPessoa);
             $newTramiteArtefato->setSqStatusTramite($entStatusTramite);
             $newTramiteArtefato->setNuTramite($nextNuTramite);
             $newTramiteArtefato->setDtTramite(\Zend_Date::now());
             $newTramiteArtefato->setDtRecebimento(\Zend_Date::now()->addSecond(1));
             $newTramiteArtefato->setInImpresso(true);
             $this->getEntityManager()->persist($newTramiteArtefato);
             $this->getEntityManager()->flush($newTramiteArtefato);
         } else {
             $newTramiteArtefato = $this->getServiceLocator()->getService('TramiteArtefato')->insertFirstTramite($dto->getSqArtefato());
         }
         $this->getEntityManager()->getConnection()->commit();
     } catch (\Exception $e) {
         $this->getEntityManager()->getConnection()->rollback();
         throw $e;
     }
     return $newTramiteArtefato;
 }
Esempio n. 29
0
 /**
  *
  * @param \Sgdoce\Model\Entity\Artefato $entityArtefato
  * @return \Arquivo\Service\ArquivamentoSetorial
  */
 private function _processTramite(\Sgdoce\Model\Entity\Artefato $entityArtefato)
 {
     $sqArtefato = $entityArtefato->getSqArtefato();
     $entityUltimoTramite = $this->_getRepository('app:VwUltimoTramiteArtefato')->find($sqArtefato);
     $sqPessoaLogada = (int) \Core_Integration_Sica_User::getPersonId();
     $sqUnidadeLogada = (int) \Core_Integration_Sica_User::getUserUnit();
     $serviceTramite = $this->getServiceLocator()->getService('TramiteArtefato');
     $dtoSearchArtefato = \Core_Dto::factoryFromData(array('sqArtefato' => $sqArtefato), 'search');
     /**
      * Se não tem ultimo Tramite é porque o artefato ainda não foi corrigido.
      * Verificar, mesmo assim, se tem tramite pois a view de ultimo tramite faz join
      * que pode não retornar registro caso documento não tenha sido corrido
      */
     if (!$entityUltimoTramite) {
         $objZendDate = \Zend_Date::now();
         $dataTramite = array('sqArtefato' => $sqArtefato, 'sqPessoaDestino' => $sqUnidadeLogada, 'sqPessoaDestinoInterno' => $sqPessoaLogada, 'sqUnidadeOrgTramite' => $sqUnidadeLogada, 'sqStatusTramite' => \Core_Configuration::getSgdoceStatusTramiteRecebido(), 'dtTramite' => $objZendDate, 'sqPessoaTramite' => $sqPessoaLogada, 'inImpresso' => TRUE, 'nuTramite' => $serviceTramite->getNextTramiteNumber($dtoSearchArtefato));
         $entityDtoTramite = $serviceTramite->montaEntidateTramite($dataTramite);
         $entityPessoaRecebimento = $this->getEntityManager()->getPartialReference('app:VwPessoa', $sqPessoaLogada);
         $entityDtoTramite->getEntity()->setSqPessoaRecebimento($entityPessoaRecebimento);
         $objZendDateRecebimento = clone $objZendDate;
         $entityDtoTramite->getEntity()->setDtRecebimento($objZendDateRecebimento->addSecond(1));
         $entityTramite = $serviceTramite->save($entityDtoTramite);
     } else {
         $sqPessoaRecebimento = $entityUltimoTramite->getSqPessoaRecebimento()->getSqPessoa();
         $sqPessoaDestino = $entityUltimoTramite->getSqPessoaDestino()->getSqPessoa();
         /**
          * caso o ultimo tramite do artefato não for da pessoa logada
          * deve-se registrar um tramite para pessoa logada (SGI) para que este
          * possa encaminhar para quem solicitou a desanexação
          */
         if ($sqPessoaRecebimento != $sqPessoaLogada || $sqPessoaDestino != $sqUnidadeLogada) {
             $dtoSearchArtefato = \Core_Dto::factoryFromData(array('sqArtefato' => $sqArtefato), 'search');
             $objZendDate = \Zend_Date::now();
             $dataTramite = array('sqArtefato' => $sqArtefato, 'sqPessoaDestino' => $sqUnidadeLogada, 'sqPessoaDestinoInterno' => $sqPessoaLogada, 'sqUnidadeOrgTramite' => $sqUnidadeLogada, 'sqStatusTramite' => \Core_Configuration::getSgdoceStatusTramiteRecebido(), 'dtTramite' => $objZendDate, 'sqPessoaTramite' => $sqPessoaLogada, 'inImpresso' => TRUE, 'nuTramite' => $serviceTramite->getNextTramiteNumber($dtoSearchArtefato));
             $entityDtoTramite = $serviceTramite->montaEntidateTramite($dataTramite);
             $entityPessoaRecebimento = $this->getEntityManager()->getPartialReference('app:VwPessoa', $sqPessoaLogada);
             $entityDtoTramite->getEntity()->setSqPessoaRecebimento($entityPessoaRecebimento);
             $objZendDateRecebimento = clone $objZendDate;
             $entityDtoTramite->getEntity()->setDtRecebimento($objZendDateRecebimento->addSecond(1));
             $entityTramite = $serviceTramite->save($entityDtoTramite);
         }
     }
     return $this;
 }
Esempio n. 30
0
 private static function _injectCredencial(&$data)
 {
     $data['sqPessoa'] = \Core_Integration_Sica_User::getPersonId();
     $data['sqUnidadeOrg'] = \Core_Integration_Sica_User::getUserUnit();
 }