/** * @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); }
/** * Get registry * * @return Core_Registry */ public static function getInstance() { if (null === self::$_singleton) { self::$_singleton = new self(); } return self::$_singleton; }
public function sistemas($sistemas) { if (!$sistemas) { $msg = \Core_Registry::getMessage()->_('MN170'); return '<div class="alert alert-error campos-obrigatorios"><button class="close" data-dismiss="alert">×</button>' . $msg . '</div>'; } $htmlize = function ($text) { return nl2br(htmlentities($text, ENT_QUOTES, 'UTF-8')); }; $html = ''; $i = 0; foreach ($sistemas as $k => $sistema) { $firstOfRowClass = $i++ % 4 === 0 ? ' welcome-system-first' : ''; $html .= '<div class="span3 thumbnail welcome-system' . $firstOfRowClass . '"'; $html .= ' rel="popover" data-placement="top" data-trigger="hover"'; $html .= ' data-content="' . $htmlize($sistema['txDescricao']) . '"'; $html .= ' title="' . $htmlize($sistema['sgSistema']) . '"'; $html .= ' data-text-find-me="' . $htmlize($sistema['sgSistema'] . $sistema['noSistema'] . $sistema['txDescricao']) . '">'; $html .= ' <div class="caption">'; $html .= ' <h2>' . $htmlize($sistema['sgSistema']) . '</h2>'; $html .= ' <p>' . $htmlize($sistema['noSistema']) . '</p>'; $html .= ' <button type="button" class="btn btn-primary" data-loading-text="Abrindo…" data-sistema="' . $sistema['sqSistema'] . '">Acessar <i class="icon icon-white icon-share-alt"></i></button>'; $html .= ' </div>'; $html .= '</div>'; } $html .= '<script type="text/javascript" src="' . $this->view->assetUrl('sica/sistema/home.js') . '"></script>'; return $html; }
private function _doAction($actionName, $msgCode) { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(TRUE); $mixSqArtefato = $this->getRequest()->getParam('sqArtefato'); if (!is_array($mixSqArtefato)) { $mixSqArtefato = array((int) $mixSqArtefato); } $type = 'Sucesso'; $error = false; foreach ($mixSqArtefato as $sqArtefato) { try { $this->getService()->{$actionName}($sqArtefato); $msg = \Core_Registry::getMessage()->translate($msgCode); } catch (\Core_Exception $e) { $error = true; $type = 'Alerta'; $msg = $e->getMessage(); } catch (\Exception $e) { $error = true; $type = 'Alerta'; $msg = 'Ocorreu um erro na execução da operação. ' . $e->getMessage(); } } $this->_helper->json(array('error' => $error, 'type' => $type, 'msg' => $msg)); }
public function findRequestsToProcess($limit = 100) { $config = \Core_Registry::get('configs'); $queryBuilder = $this->_em->createQueryBuilder(); $queryBuilder->select('smi')->from('app:SolicitacaoMigracaoImagem', 'smi')->innerJoin('smi.sqArtefato', 'a')->innerJoin('smi.sqUnidadeOrg', 'un')->innerJoin('smi.sqPessoa', 'p')->andWhere('smi.stProcessado = FALSE')->andWhere($queryBuilder->expr()->lt('smi.inTentativa', $config['migration']['qtdeTentativa']))->orderBy('smi.dtSolicitacao')->setMaxResults($limit); return $queryBuilder->getQuery()->execute(); }
/** * método que implementa as regras de negócio */ public function preSave($service) { $hasErrors = FALSE; $repository = $this->getEntityManager()->getRepository($this->_entityName); if ($repository->hasTipoDocumento($this->_data['noTipoDocumento'], $this->_data['sqTipoDocumento'])) { $hasErrors = TRUE; $msg = \Core_Registry::getMessage()->translate('MN046'); $this->getMessaging()->addErrorMessage($msg); } if (empty($this->_data['noTipoDocumento'])) { $hasErrors = TRUE; $msg = \Core_Registry::getMessage()->translate('MN003'); $msg = str_replace('<campo>', 'Tipo de Documento', $msg); $this->getMessaging()->addErrorMessage($msg); } if (!$this->_data['inAbreProcesso'] && $this->_data['inAbreProcesso'] !== '0') { $hasErrors = TRUE; $msg = \Core_Registry::getMessage()->translate('MN003'); $msg = str_replace('<campo>', 'Abre Processo', $msg); $this->getMessaging()->addErrorMessage($msg); } if ($hasErrors) { $this->getMessaging()->dispatchPackets(); throw new \Core_Exception_ServiceLayer_Verification(); } }
/** * * @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; } }
public function __construct($message = '', $code = 0, Exception $previous = null) { if (Core_Registry::getMessage()->isTranslated($message)) { $message = Core_Registry::getMessage()->translate($message); } parent::__construct($message, (int) $code, $previous); }
protected function _initAcl() { $session = new Core_Session_Namespace('USER', FALSE, TRUE); if (isset($session->acl)) { Core_Registry::setAcl($session->acl); return $session->acl; } }
/** * Retorna os assuntos cadastrados em formato json * @return string Assuntos no formato json */ public function searchassuntoAction() { $res = $this->getAssunto(); if (0 === count($res)) { $res = array('__NO_CLICK__' => \Core_Registry::getMessage()->_('MN025') . ' Apenas assuntos homologados são apresentados'); } $this->getHelper('json')->sendJson($res); }
public function logoSystem() { $infoSystem = Core_Integration_Sica_User::getInfoSystem(); $configs = Core_Registry::get('configs'); $systemId = isset($infoSystem['sqSistema']) ? $infoSystem['sqSistema'] : null; $systemAlias = isset($infoSystem['sgSistema']) ? $infoSystem['sgSistema'] : null; $urlImagem = rtrim($configs['urlSica']) . '/sistema/render-logo/id/' . $systemId; return "<img src=\"{$urlImagem}\" alt=\"{$systemAlias}\" width=\"120\" height=\"70\">"; }
/** * Return Doctrine EntityManager * * @param string $emName * @return \Doctrine\ORM\EntityManager */ protected function getEntityManager($emName = null) { $containers = Core_Registry::getContainers(); $emName = strtolower($emName); if (array_key_exists($emName, $containers)) { return $containers[$emName]; } $dContainer = $this->locator->getDoctrineContainer(); return $dContainer->getEntityManager($emName); }
/** * Procura se já existe uma mensagem cadastrada com o mesmo tipo de documento e assunto * @param array $params Parâmetros da requisição * @return array Retorna um array com as mensagens encontradas */ public function findMessage($params) { $qry = $this->pesquisaMensagem($params); $res = $qry->getQuery()->execute(); $out = array(); foreach ($res as $item) { $out['Mensagem'] = \Core_Registry::getMessage()->translate('MN071'); $out['idMensagem'] = $item->getSqMensagem(); } return $out; }
public function parseJson($code, array $tokens = array(), $data = NULL, $success = TRUE) { $body = Core_Registry::getMessage()->translate($code, NULL, $tokens); $type = Core_Registry::getMessage()->getType($code); $subject = NULL; if (NULL === $type) { $type = static::TYPE_ERROR; } $subject = $this->_getSubjectType($type); return $this->_makeJsonPacket($success, $type, $subject, $body, $data); }
protected function _initMailer() { $this->bootstrap('mail'); $this->bootstrap('view'); $options = $this->getPluginResource('mail')->getOptions(); $view = $this->getResource('view'); Core_Mailer::setDefaultLayoutOptions($options); Core_Mailer::setDefaultView($view); $mailer = new Core_Mailer(new Zend_Mail('utf-8')); Core_Registry::setMailer($mailer); return $mailer; }
public function desarquivarAction() { try { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(TRUE); $dto = Core_Dto::factoryFromData($this->_getAllParams(), 'search'); $this->getService()->desarquivar($dto); $this->_helper->json(array('error' => false, 'msg' => Core_Registry::getMessage()->translate('MN013'), 'type' => 'Sucesso')); } catch (\Exception $e) { $this->_helper->json(array('error' => true, 'msg' => $e->getMessage(), 'type' => 'Erro')); } }
public function devolverAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(TRUE); try { $dto = Core_Dto::factoryFromData($this->_getAllParams(), 'search'); $this->getService()->saveDevolucao($dto); $this->_helper->json(array("error" => false, "msg" => \Core_Registry::getMessage()->translate('MN013'), "type" => "Sucesso")); } catch (Exception $e) { $this->_helper->json(array("error" => true, "msg" => $e->getMessage(), "type" => "Erro")); } }
public function preSave($service) { //só pode ser classificado se não tiver solicitação aberta ou o usuiario logado for SGI try { $sqArtefato = $service->getEntity()->getSqArtefato()->getSqArtefato(); if (!$this->checkPermisionArtefato($sqArtefato)) { throw new \Core_Exception_ServiceLayer_Verification(\Core_Registry::getMessage()->translate('MN156')); } } catch (\Exception $e) { $this->getMessaging()->addErrorMessage($e->getMessage(), 'User'); throw $e; } }
/** * Metódo que recupera a pessoa * @return json */ public function searchPessoaAction() { $this->_helper->layout->disableLayout(); $params = $this->_getAllParams(); $dtoSearch = \Core_Dto::factoryFromData($params, 'search'); $result = $this->getService('VwPessoa')->autocomplete($dtoSearch, 30); #30 é o limit if (0 === count($result) && isset($params['save'])) { $msg = ''; switch ($params['extraParam']) { case \Core_Configuration::getCorpTipoPessoaFisica(): $msg = 'MN132F'; break; case \Core_Configuration::getCorpTipoPessoaJuridica(): $msg = 'MN132J'; break; } if ($msg) { $result = array('__NO_CLICK__' => Core_Registry::getMessage()->_($msg)); } } $this->_helper->json($result); }
/** * @param \Core_Dto_Search $dto */ public function searchArtefato($dto) { $sqTipoArtefato = $dto->getSqTipoArtefato(); $nuArtefato = "sgdoce.formata_numero_digital(art.nu_digital) ILIKE '%{$dto->getQuery()}%'"; if ($sqTipoArtefato == \Core_Configuration::getSgdoceTipoArtefatoProcesso()) { $value = preg_replace('/[^0-9]/', '', $dto->getQuery()); $withOR = "OR TRANSLATE(art.nu_artefato, './-', '') ILIKE '%{$value}%'"; $nuArtefato = "sgdoce.formata_numero_artefato(art.nu_artefato, ap.co_ambito_processo) ILIKE '%{$value}%' {$withOR}"; } $rsm = new \Doctrine\ORM\Query\ResultSetMapping($this->_em); $rsm->addScalarResult('sq_artefato', 'sqArtefato', 'integer'); $rsm->addScalarResult('nu_artefato', 'nuArtefato', 'string'); $rsm->addScalarResult('nu_digital', 'nuDigital', 'string'); $sql = sprintf(' SELECT art.sq_artefato ,formata_numero_artefato(art.nu_artefato, ap.co_ambito_processo) AS nu_artefato ,formata_numero_digital(art.nu_digital) as nu_digital FROM artefato art JOIN artefato art_pai ON obter_vinculo_pai(art.sq_artefato) = art_pai.sq_artefato JOIN sgdoce.tramite_artefato uta ON art_pai.sq_artefato = uta.sq_artefato AND uta.st_ultimo_tramite JOIN tipo_artefato_assunto taa ON taa.sq_tipo_artefato_assunto = art.sq_tipo_artefato_assunto LEFT JOIN artefato_processo ap ON art.sq_artefato = ap.sq_artefato LEFT JOIN artefato_vinculo av ON av.sq_artefato_filho = art.sq_artefato and av.sq_tipo_vinculo_artefato NOT IN(%5$d,%6$d,%7$d) LEFT JOIN artefato_arquivo_setorial aas ON art.sq_artefato = aas.sq_artefato and aas.dt_desarquivamento is null WHERE aas.sq_artefato IS NULL AND uta.sq_pessoa_recebimento = %1$s AND uta.sq_status_tramite <> %2$s AND (%3$s) AND taa.sq_tipo_artefato = %4$s', $dto->getSqPessoa(), \Core_Configuration::getSgdoceStatusTramiteTramitado(), $nuArtefato, $dto->getSqTipoArtefato(), \Core_Configuration::getSgdoceTipoVinculoArtefatoReferencia(), \Core_Configuration::getSgdoceTipoVinculoArtefatoApoio(), \Core_Configuration::getSgdoceTipoVinculoArtefatoDespacho()); try { return $this->_em->createNativeQuery($sql, $rsm)->useResultCache(false)->getScalarResult(); } catch (\Exception $ex) { $this->getMessaging()->addErrorMessage(\Core_Registry::getMessage()->translate('MN180'), 'User'); $this->getMessaging()->dispatchPackets(); return array(); } }
/** * @return Zend_Controller_Plugin_Abstract */ public function init() { $containers = $this->getOptions(); foreach ($containers as $keyContainer => $container) { if (!isset($container['class'])) { continue; } $configs = isset($container['configs']) ? $container['configs'] : array(); $configs += array('options' => array(), 'class' => 'Core_Model_OWM_Configuration'); $objectConfig = new $configs['class'](); foreach ($configs['options'] as $key => $config) { $methodSet = 'set' . $key; $methodAdd = 'add' . $key; if (method_exists($objectConfig, $methodSet) || method_exists($objectConfig, $methodAdd)) { $objectConfig->{$methodSet}($config); } } unset($configs['class'], $configs['options']); $objectConfig->setConfigs($configs); $container = $container['class']::create($container['options'], $objectConfig); Core_Registry::setContainer($keyContainer, $container); } return Core_Registry::getContainers(); }
/** * Ação para visualização de imagem de documentos migrados */ public function viewMigrationAction() { $this->getHelper('layout')->setLayout('modal'); $sqArtefato = $this->getRequest()->getParam('id'); // Regras para artefatos de migração. $dtoSearchPai = \Core_Dto::factoryFromData(array('sqArtefato' => $sqArtefato), 'search'); $params = $this->_viewSteps(); $entArtefato = $this->getService("Artefato")->find($params['id']); if ($entArtefato->isProcesso() && $this->getService("Artefato")->isMigracao($dtoSearchPai) && $this->getService("Artefato")->isInconsistent($dtoSearchPai)) { $firstItem = current($this->view->treeviewData); $primeiraPeca = current($firstItem['filhos']); $dtoSearch = \Core_Dto::factoryFromData(array('sqArtefato' => $primeiraPeca['sqArtefatoFilho']), 'search'); $hasImagem = $this->getService()->hasArtefatoImagemAtiva($dtoSearch); if (!$hasImagem) { $this->view->entArtefato = $entArtefato; //recupera a 1ª Peça $entPrimeiraPeca = $this->getService('ArtefatoVinculo')->findOneBy(array('sqArtefatoPai' => $entArtefato->getSqArtefato(), 'sqTipoVinculoArtefato' => \Core_Configuration::getSgdoceTipoVinculoArtefatoAutuacao())); //se não tem 1ª Peça não faz nada if (!$entPrimeiraPeca) { $this->render('fail-image-not-first-piece'); } else { $listSolicitacao = $this->getService()->getSolicitacaoMigracaoImagem($dtoSearch); if ($listSolicitacao) { $configs = \Core_Registry::get('configs'); $qtdeTentativa = $configs['migration']['qtdeTentativa']; $entSolicitacao = current($listSolicitacao); if (!$entSolicitacao->getStProcessado() && $entSolicitacao->getInTentativa() == $qtdeTentativa) { $this->render('fail-image-not-process'); } else { $this->render('fail-image-processo'); } } else { $this->render('fail-image-processo'); } } } } $this->view->canOverwrite = false; if (count($this->view->treeviewData) > 0 && !$this->view->hasImage) { $firstItem = current($this->view->treeviewData); $this->view->hasImage = count($firstItem['filhos']) > 0; } if (!$this->view->treeviewData) { $this->view->hasDuplicity = true; } $this->getService('VinculoMigracao')->verificaImagemArvore($this->view->treeviewData); // Verifica se item é de migração e se tem imagem, se não tiver, adicionar uma solicitação de migração de imagem if (isset($params['view']) && $params['view'] == 'migracao') { if ($this->getService("Artefato")->isInconsistent($dtoSearchPai, true)) { $this->view->canOverwrite = true; } $this->view->id = $params['id']; $this->render('view-migracao'); } else { $this->render('view'); } $isAllowedAlter = in_array(\Core_Integration_Sica_User::getUserProfile(), $this->getService()->getUsersAllowedAlterImage()); $inMyDashboard = $this->getService("Artefato")->inMyDashboard($dtoSearchPai->getSqArtefato()); $this->view->canAlterImage = $isAllowedAlter && $inMyDashboard; $this->view->sqTipoArtefato = $entArtefato->getSqTipoArtefatoAssunto()->getSqTipoArtefato()->getSqTipoArtefato(); }
/** * @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(); }
/** * RETORNO TEXTO DE AÇÃO. * * @return string */ public function getMessage($MSGID) { try { $args = func_get_args(); if (count($args) > 1) { array_shift($args); array_unshift($args, \Core_Registry::getMessage()->translate($MSGID)); return call_user_func_array('sprintf', $args); } return \Core_Registry::getMessage()->translate($MSGID); } catch (\Core_Exception $objException) { return $objException->getMessage(); } }
public function preDelete($id) { try { $dto = \Core_Dto::factoryFromData(array('sqCaixa' => $id), 'search'); //Se existir artefato arquivado na caixa, a mesma não pode ser alterada; if (!$this->verificaArtefatoArquivadoCaixa($dto)) { $msg = sprintf(\Core_Registry::getMessage()->translate('MN157'), 'excluida'); throw new \Core_Exception_ServiceLayer_Verification($msg); } } catch (\Exception $e) { throw $e; } }
public function deleteAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(TRUE); $data = $this->_getAllParams(); $sqDespacho = (int) $data['id']; try { # delega a exclusao para superclasse $service = $this->getService(); $service->preDelete($sqDespacho); $service->delete($sqDespacho); $service->finish(); $this->getMessaging()->addSuccessMessage('MD003', 'User'); $this->getMessaging()->dispatchPackets(); $this->_helper->json(array("status" => TRUE, "message" => \Core_Registry::getMessage()->translate('MN045'))); } catch (\Exception $exc) { $this->_helper->json(array("status" => FALSE, "message" => $exc->getMessage())); } }
protected function _getMessageTranslate($code) { if (is_string($code)) { if (!Core_Registry::getMessage()->isTranslated($code)) { return $code; } return Core_Registry::getMessage()->translate($code); } if (is_array($code)) { if (Core_Registry::getMessage()->isTranslated($code[0])) { return Core_Registry::getMessage()->translate($code[0], NULL, isset($code[1]) ? $code[1] : array()); } } return $code; }
/** * Metdo responsavel por persistir os uploads * @param type $destino * @param type $thumb * @param type $validFile * @param type $invalidFile * @return type */ public static function upload($destino = 'anexoArtefato', $thumb = FALSE, $validFile = TRUE, $invalidFile = TRUE, $validImageSize = TRUE) { $configs = \Core_Registry::get('configs'); $upload = new \Zend_File_Transfer_Adapter_Http(); $files = $upload->getFileInfo(); $filesUp = array(); $return = array(); $error = false; $pasta = 'anexo-material'; if ($destino == 'anexoArtefato') { $pasta = 'anexo-artefato'; } $path = current(explode('application', __DIR__)) . 'data' . DIRECTORY_SEPARATOR . 'upload' . DIRECTORY_SEPARATOR . $pasta . DIRECTORY_SEPARATOR; foreach ($files as $file => $info) { $upload = new \Zend_File_Transfer_Adapter_Http(); $upload->setDestination($path); $upload->setValidators(array()); $upload->addValidator('Size', TRUE, array('max' => '100MB', 'messages' => "O tamanho do arquivo é superior ao permitido. O tamanho permitido é 100MB.")); self::_invalidFile($invalidFile, $upload); self::_validFile($validFile, $upload); self::_validImageSize($validImageSize, $upload); self::_getValidator($upload); if ($upload->isValid($file)) { $fileinfo = pathinfo($info['name']); $upload->receive($file); $filesUp[] = $upload->getFileName($file); $return[] = array('name' => $upload->getFileName($file), 'size' => $upload->getFileSize($file)); } else { $error = $upload->getMessages(); break; } } if ($error) { if (count($filesUp)) { foreach ($filesUp as $file) { unlink($file); } } return array('errors' => $error); } if ($thumb) { $pasta = current(explode('application', __DIR__)) . 'data' . DIRECTORY_SEPARATOR . 'upload' . DIRECTORY_SEPARATOR . 'thumbs' . DIRECTORY_SEPARATOR; foreach ($filesUp as $endereco) { $fileinfo = pathinfo($endereco); $image = \WideImage::load($endereco); $image->resize(300, 300, 'outside')->crop('50% - 150', '50% - 150', 300, 300)->saveToFile($pasta . $fileinfo['filename'] . '_300_X_300.' . strtolower($fileinfo['extension'])); $image->resize(133, 89, 'outside')->crop('50% - 67', '50% - 45', 133, 89)->saveToFile($pasta . $fileinfo['filename'] . '_133_X_89.' . strtolower($fileinfo['extension'])); } } return $return; }
/** * método que valida a criação de um novo registro */ public function preSave($service) { if ($this->_data['nuSequencial'] === NULL) { throw new \Core_Exception_ServiceLayer("MN003"); //o campo é de preenchimento obrigatório } $processo = $this->_data['sqTipoArtefato']->getSqTipoArtefato() == \Core_Configuration::getSgdoceTipoArtefatoProcesso(); if ($this->_data['nuSequencial'] != 0 && !$processo) { $sequencial = $this->hasSequencialArtefato($this->_data); if ($sequencial) { $anterior = $sequencial->getNuSequencial(); $msg = \Core_Registry::getMessage()->translate('MN074'); $msg = str_replace('<proximo>', $anterior + 1, $msg); $msg = str_replace('<anterior>', $anterior, $msg); throw new \Core_Exception_ServiceLayer($msg); } else { return FALSE; } } }
public function closeBoxAction() { try { $retorno = array('error' => false, 'msg' => Core_Registry::getMessage()->translate('MN013')); $params = $this->_getAllParams(); $params['sqCaixa'] = $params['id']; $dto = \Core_Dto::factoryFromData($params, 'search'); $this->getService()->closeBox($dto); } catch (\Exception $e) { $retorno['error'] = true; $retorno['msg'] = $e->getMessage(); } echo $this->_helper->json($retorno); }