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(); }
/** * 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; } }