示例#1
0
 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);
 }
 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));
 }
示例#3
0
 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;
 }
示例#4
0
 /**
  * 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();
     }
 }
示例#5
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;
     }
 }
示例#6
0
 /**
  * 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);
 }
示例#7
0
 /**
  * Metódo que realiza o upload do arquivo.
  */
 private function _upload()
 {
     $upload = $this->getCoreUpload();
     if (is_string($upload->getFileName())) {
         $upload->setOptions(array('ignoreNoFile' => true));
         $upload->addValidator('Extension', true, array('extensions' => 'png,jpg', 'messages' => str_replace('<extensão>', 'png,jpg', \Core_Registry::getMessage()->_('MN076'))));
         $this->validatorImageSize($upload);
         return $upload->upload();
     }
 }
示例#8
0
 /**
  * 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;
 }
示例#9
0
 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);
 }
 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 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 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;
     }
 }
示例#13
0
 /**
  * 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);
 }
示例#14
0
 /**
  * @param \Core_Dto_Search $dto
  */
 public function searchArtefato($dto)
 {
     $sqTipoArtefato = $dto->getSqTipoArtefato();
     $nuArtefato = "sgdoce.formata_numero_digital(art.nu_digital) ILIKE '%{$dto->getQuery()}%'";
     if ($sqTipoArtefato == \Core_Configuration::getSgdoceTipoArtefatoProcesso()) {
         $value = preg_replace('/[^0-9]/', '', $dto->getQuery());
         $withOR = "OR TRANSLATE(art.nu_artefato, './-', '') ILIKE '%{$value}%'";
         $nuArtefato = "sgdoce.formata_numero_artefato(art.nu_artefato, ap.co_ambito_processo) ILIKE '%{$value}%' {$withOR}";
     }
     $rsm = new \Doctrine\ORM\Query\ResultSetMapping($this->_em);
     $rsm->addScalarResult('sq_artefato', 'sqArtefato', 'integer');
     $rsm->addScalarResult('nu_artefato', 'nuArtefato', 'string');
     $rsm->addScalarResult('nu_digital', 'nuDigital', 'string');
     $sql = sprintf('
               SELECT art.sq_artefato
                      ,formata_numero_artefato(art.nu_artefato, ap.co_ambito_processo) AS nu_artefato
                      ,formata_numero_digital(art.nu_digital) as nu_digital
                 FROM artefato art
                 JOIN artefato                   art_pai ON obter_vinculo_pai(art.sq_artefato) = art_pai.sq_artefato
                 JOIN sgdoce.tramite_artefato    uta ON art_pai.sq_artefato = uta.sq_artefato AND uta.st_ultimo_tramite
                 JOIN tipo_artefato_assunto      taa ON taa.sq_tipo_artefato_assunto = art.sq_tipo_artefato_assunto
            LEFT JOIN artefato_processo           ap ON art.sq_artefato = ap.sq_artefato
            LEFT JOIN artefato_vinculo            av ON av.sq_artefato_filho = art.sq_artefato and av.sq_tipo_vinculo_artefato NOT IN(%5$d,%6$d,%7$d)
            LEFT JOIN artefato_arquivo_setorial  aas ON art.sq_artefato = aas.sq_artefato and aas.dt_desarquivamento is null
                WHERE aas.sq_artefato IS NULL
                  AND uta.sq_pessoa_recebimento = %1$s
                  AND uta.sq_status_tramite <> %2$s
                  AND (%3$s)
                  AND taa.sq_tipo_artefato = %4$s', $dto->getSqPessoa(), \Core_Configuration::getSgdoceStatusTramiteTramitado(), $nuArtefato, $dto->getSqTipoArtefato(), \Core_Configuration::getSgdoceTipoVinculoArtefatoReferencia(), \Core_Configuration::getSgdoceTipoVinculoArtefatoApoio(), \Core_Configuration::getSgdoceTipoVinculoArtefatoDespacho());
     try {
         return $this->_em->createNativeQuery($sql, $rsm)->useResultCache(false)->getScalarResult();
     } catch (\Exception $ex) {
         $this->getMessaging()->addErrorMessage(\Core_Registry::getMessage()->translate('MN180'), 'User');
         $this->getMessaging()->dispatchPackets();
         return array();
     }
 }
 public function printHistoricAction()
 {
     $this->_helper->layout()->disableLayout();
     $sqArtefato = (int) $this->getRequest()->getParam('sqArtefato');
     if (!$sqArtefato) {
         throw new Exception(\Core_Registry::getMessage()->translate('MN132'));
     }
     $params = array('sqArtefato' => $sqArtefato);
     $dto = Core_Dto::factoryFromData($params, 'search');
     $data = $this->getService('Artefato')->getHistoricoByArtefato($dto);
     $options = array('fname' => sprintf('Historico-' . date('YmdHis') . '-%d.pdf', $sqArtefato), 'path' => APPLICATION_PATH . '/modules/artefato/views/scripts/visualizar-artefato');
     $logo = current(explode('application', __FILE__)) . 'public' . DIRECTORY_SEPARATOR . ltrim(self::T_VISUALIZAR_ARTEFATO_IMG_LOGO_PATH, DIRECTORY_SEPARATOR);
     \Core_Doc_Factory::setFilePath($options['path']);
     \Core_Doc_Factory::download('print-historic', array('data' => $data, 'logo' => $logo, 'entityArtefato' => $this->getService('Artefato')->find($sqArtefato)), $options['fname'], 'Pdf', 'L');
 }
示例#16
0
 /**
  * Metódo que verifica se o modelo está cadastrado
  * @return boolean
  */
 public function checkProcessoCadastrado(\Core_Dto_Search $dtoSearch)
 {
     $nuArtefato = preg_replace('/[^a-zA-Z0-9]/', '', $dtoSearch->getNuArtefato());
     $configs = \Core_Registry::get('configs');
     if (strlen($nuArtefato) > 17 && !$configs['processo']['numberWithNupSiorg']) {
         throw new \Core_Exception_ServiceLayer(\Core_Registry::getMessage()->translate('MN204'));
     }
     $return = $this->_getRepository()->findByNuArtefato($nuArtefato);
     if (count($return) > 0) {
         throw new \Core_Exception_ServiceLayer(\Core_Registry::getMessage()->translate('MN020'));
     } else {
         $nuArtefato = preg_replace('/[^a-zA-Z0-9\\.\\-\\/]/', '', $dtoSearch->getNuArtefato());
         $return = $this->_getRepository()->findByNuArtefato($nuArtefato);
         if (count($return) > 0) {
             throw new \Core_Exception_ServiceLayer(\Core_Registry::getMessage()->translate('MN020'));
         }
     }
     return FALSE;
 }
示例#17
0
 /**
  * @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;
 }
示例#18
0
 public function checkCredencials($dto)
 {
     if ($dto->getTxEmail()) {
         $optionsValidate = array(array('mx' => TRUE));
         if (!\Zend_Validate::is($dto->getTxEmail(), 'EmailAddress', $optionsValidate)) {
             return \Core_Registry::getMessage()->_('MN095');
         }
     }
     return !$this->_getRepository()->checkCredencials($dto);
 }
示例#19
0
 public function checkUserExistsProfileAction()
 {
     $params = $this->_getAllParams();
     $dto = Core_Dto::factoryFromData($params, 'entity', $this->_optionsDtoEntity);
     $result = $this->getService()->checkUserExistsProfile($dto);
     $data = array('message' => $params['stRegistroAtivo'] == '1' ? Core_Registry::getMessage()->translate('MN052') : Core_Registry::getMessage()->translate('MN054'), 'exists' => count($result) ? TRUE : FALSE);
     if ($data['exists'] === TRUE && $params['stRegistroAtivo'] == '1') {
         $msg = Core_Registry::getMessage()->translate('MN015');
         $data['message'] = str_replace('<quantidade>', $result['users'], $msg);
     }
     $this->_helper->json($data);
 }
示例#20
0
 /**
  *
  * @param type $dto
  * @return \Sgdoce\Model\Entity\EtiquetasUso
  * @throws \Core_Exception_ServiceLayer_Verification
  */
 private function _doInsertEtiquetaUso($dto, $docEletronico = false)
 {
     //se for eletronico tem que recuperar o proximo numero de etiqueta
     if ($docEletronico) {
         $sqUnidadeOrg = \Core_Integration_Sica_User::getUserUnit();
         $dtoSearchLote = \Core_Dto::factoryFromData(array('nuAno' => date('Y'), 'sqUnidadeOrg' => $sqUnidadeOrg), 'search');
         $novoNuDigital = $this->getServiceLocator()->getService('Artefato')->getNextElectronicDigitalNumber($dtoSearchLote);
         $entityEtiquetaNupSiorg = $this->_getRepository('app:EtiquetaNupSiorg')->findOneBy(array('sqLoteEtiqueta' => $novoNuDigital['sqLoteEtiqueta'], 'nuEtiqueta' => $novoNuDigital['nuDigital']));
     } else {
         //se a digital informada tiver nup associado e a procedencia for externa não pode.
         //tem q usar digital sem nup para procedencia externa
         $entityEtiquetaNupSiorg = $this->getDigitalNupSiorg($dto);
     }
     $nuNupSiorgVinculado = $entityEtiquetaNupSiorg->getNuNupSiorg(true);
     if ($nuNupSiorgVinculado && $dto->getProcedenciaInterno() == 'externo' && !$dto->getIsSic()) {
         throw new \Core_Exception_ServiceLayer_Verification(sprintf(\Core_Registry::getMessage()->translate('MN167'), $nuNupSiorgVinculado));
     }
     if (!$nuNupSiorgVinculado && $dto->getProcedenciaInterno() == 'interno') {
         throw new \Core_Exception_ServiceLayer_Verification(\Core_Registry::getMessage()->translate('MN168'));
     }
     //se for externo o nup pode ter sido informado no cadastro
     if (!$nuNupSiorgVinculado && $dto->getProcedenciaInterno() == 'externo' && $dto->getNuNup()) {
         $nupValidado = $this->_validaNumeroNUP($dto->getNuNup());
         $entityEtiquetaNupSiorg->setNuNupSiorg($nupValidado);
         $this->getEntityManager()->persist($entityEtiquetaNupSiorg);
         $this->getEntityManager()->flush($entityEtiquetaNupSiorg);
     }
     /** @var \Sgdoce\Model\Entity\EtiquetasUso $entityEtiquetasUso */
     $entityEtiquetasUso = $this->_newEntity('app:EtiquetasUso');
     $entityEtiquetasUso->setNuEtiqueta($entityEtiquetaNupSiorg);
     $entityEtiquetasUso->setSqLoteEtiqueta($entityEtiquetaNupSiorg);
     //persist Etiquetas Uso
     $this->getEntityManager()->persist($entityEtiquetasUso);
     $this->getEntityManager()->flush($entityEtiquetasUso);
     return $entityEtiquetasUso;
 }
示例#21
0
 /**
  * implementa a regra de negócio para remover o volume
  *
  * @param integer
  * @throws Exception
  * @return Volume
  * */
 public function preDelete($id)
 {
     $entity = $this->_getRepository()->find($id);
     # apenas usuário SGI pode excluir
     if (!\Zend_Registry::get('isUserSgi')) {
         throw new \Exception(\Core_Registry::getMessage()->translate('MN203'));
     }
     $arrFromData = array('sqArtefato' => $entity->getSqArtefato()->getSqArtefato(), 'sqTipoAssuntoSolicitacao' => \Core_Configuration::getSgdoceTipoAssuntoSolicitacaoVolumeDeProcesso());
     $hasDemandaExcluirVolume = $this->getServiceLocator()->getService('Solicitacao')->hasDemandaAbertaByAssuntoPessoaResponsavel(\Core_Dto::factoryFromData($arrFromData, 'search'));
     # tem que ter demanda de exclusão
     if (!$hasDemandaExcluirVolume) {
         throw new \Exception(\Core_Registry::getMessage()->translate('MN047'));
     }
     return $this;
 }
示例#22
0
 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;
 }
示例#23
0
 /**
  * Faz o upload do arquivo
  * @param  array $params Parâmetros http
  * @return string         Retorna o basename do arquivo enviado
  */
 public function upload($params)
 {
     $registry = \Core_Registry::get('configs');
     $maxSize = $registry['upload']['carimboMaxSize'];
     $adapter = $this->getFileTransferAdapter();
     $adapter->addValidator('Extension', FALSE, 'png')->addValidator('Size', TRUE, array('max' => $maxSize));
     $errorCodes = array();
     $errorCodes['fileExtensionFalse'] = str_replace('<extensão>', '.png', \Core_Registry::getMessage()->translate('MN076'));
     $errorCodes['fileSizeTooBig'] = str_replace('<tamanho>', $maxSize, \Core_Registry::getMessage()->translate('MN077'));
     $uploadErrors = array();
     if (!$adapter->isValid()) {
         $errors = $adapter->getErrors();
         foreach ($errors as $error) {
             if (isset($errorCodes[$error])) {
                 $uploadErrors[] = $errorCodes[$error];
             }
         }
         if (empty($uploadErrors)) {
             $msg = 'Erro na operação';
         } else {
             $msg = implode('<br />', $uploadErrors);
         }
         throw new \Core_Exception_ServiceLayer($msg);
     }
     $info = $adapter->getFileInfo();
     $this->isAlphaPng($info['deCaminhoArquivo']['tmp_name']);
     $this->isValidSize($info['deCaminhoArquivo']['tmp_name']);
     $path = current(explode('application', __DIR__)) . 'data' . DIRECTORY_SEPARATOR . 'upload' . DIRECTORY_SEPARATOR . 'carimbo' . DIRECTORY_SEPARATOR;
     if (!$this->fileExists($path)) {
         throw new \Core_Exception_ServiceLayer("MN111");
     }
     if (!is_writable($path)) {
         throw new \Core_Exception_ServiceLayer("MN110");
     }
     // pegando os dados do documento
     $currentFile = $info['deCaminhoArquivo']['name'];
     $newFile = $this->getUploadedFilename($info['deCaminhoArquivo']['name']);
     $data = array('de_caminho_arquivo' => date('Ymdhis') . "_" . $info['deCaminhoArquivo']['name']);
     $newFile = $path . $data['de_caminho_arquivo'];
     $adapter->addFilter('Rename', array('source' => $info['deCaminhoArquivo']['tmp_name'], 'target' => $newFile, 'overwrite' => TRUE));
     // adicionando no temp
     $this->addTemp($data);
     // colocando o arquivo na pasta
     $adapter->receive($currentFile);
     if (!$this->fileExists($newFile)) {
         throw new \Core_Exception_ServiceLayer("MN109");
     }
     return basename($newFile);
 }
示例#24
0
 /**
  * @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();
 }
示例#25
0
 public function detailAction()
 {
     try {
         $this->getHelper('layout')->disableLayout();
         $data = $this->_getAllParams();
         $sqVolume = (int) $data['id'];
         if (!$sqVolume) {
             throw new Exception(\Core_Registry::getMessage()->translate('MN025'));
         }
         $row = $this->getService()->find($sqVolume);
         $this->view->sqArtefato = $row->getSqArtefato()->getSqArtefato();
         $this->view->nuArtefato = $row->getSqArtefato()->getNuArtefato();
         $this->view->nuVolume = $row->getNuVolume();
         $this->view->nuFolhaInicial = $row->getNuFolhaInicial();
         $this->view->nuFolhaFinal = $row->getNuFolhaFinal();
         $this->view->dtAbertura = $row->getDtAbertura();
         $this->view->dtEncerramento = $row->getDtEncerramento();
     } catch (\Exception $exc) {
         $this->getMessaging()->addErrorMessage($exc->getMessage());
     }
 }
示例#26
0
 /**
  * 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();
     }
 }
示例#27
0
 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()));
     }
 }
示例#29
-1
 /**
  * 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;
         }
     }
 }
示例#30
-2
 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);
 }