✏️ 正在编辑: TermoResponsabilidadeController.php
路径:
/srv/systems_dir/yuppiecred/application/controllers/TermoResponsabilidadeController.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php use Mpdf\Mpdf; class TermoResponsabilidadeController extends Zend_Controller_Action { /** @var Service_Corretor_TermoResponsabilidade */ private $service; /** @var string */ public const VIEW_TERMO = 'termo-responsabilidade/imprimir.phtml', TERMO_ENVIADO = 'O termo foi enviado com sucesso.', TERMO_EXCLUIDO = 'O termo foi removido com sucesso.', ERRO_REENVIO = 'Houve um erro durante o reenvio do termo de responsabilidade.', ERRO_EXCLUSAO = 'Houve um erro durante a exclusão do termo de responsabilidade.' ; public function init() { $this->service = service('termo-responsabilidade'); } /** * Imprimir Termo */ public function imprimirAction() { $this->_helper->layout->setLayout('layout_impressao'); $request = $this->getRequest(); $idCorretor = (int) $request->getParam('corretor'); if( !$idCorretor ){ $this->_helper->flashMessenger(array('alert' => 'ID do corretor inválido.')); $this->_helper->redirector('index', 'corretor'); } $dbtableCorretor = new Model_Corretor(); $dadosCorretorSelecionado = $dbtableCorretor->getCorretorTermo($idCorretor); if( !$dadosCorretorSelecionado ){ $this->_helper->flashMessenger(array('alert' => 'Corretor inválido.')); $this->_helper->redirector('index', 'corretor'); } $dbtableTermo = new Model_TermoResponsabilidade(); $termoId = $dbtableTermo->getPrimeiroCodigo(); if( !$termoId ){ $this->_helper->flashMessenger(array('alert' => 'Termo de responsabilidade não configurado!')); $this->_helper->redirector('index', 'corretor'); } $dadosTermoSelecionado = $dbtableTermo->exibir($termoId); if( !$dadosTermoSelecionado){ $this->_helper->flashMessenger(array('error' => 'Nao existe termo de responsabilidade cadastrado!')); $this->_helper->redirector('index', 'corretor'); } $this->view->corretor = $dadosCorretorSelecionado; $this->view->termo = $dadosTermoSelecionado; } public function indexAction() { $request = $this->getRequest(); $form = new Form_Filtro_TermoResponsabilidade(); $fields = []; if ($request->isPost()) { $form->populate($request->getPost()); $fields = $request->getPost(); } $termoResponsabilidade = new Model_TermoResponsabilidade(); $termosResponsabilidades = $termoResponsabilidade->listar($fields); $this->view->form = $form; $this->view->termo_responsabilidade = $termosResponsabilidades; } public function saveAction() { $termoResponsabilidade = new Model_TermoResponsabilidade(); $request = $this->getRequest(); $form = new Form_TermoResponsabilidade(); $id = $request->getParam('id'); if ($request->isPost() && $form->isValid($request->getPost())) { $dados = $request->getPost(); $termoResponsabilidade = new Model_TermoResponsabilidade($dados); try { $id = $termoResponsabilidade->salvar($termoResponsabilidade); $this->_helper->flashMessenger([ 'success' => 'Dados salvos com sucesso.' ]); } catch ( Zend_Exception $e ) { $this->_helper->flashMessenger($e->getMessage()); } } if ($id) { $termo = new Model_TermoResponsabilidade(); $dados = $termo->exibir($id); $form->populate($dados->toArray()); } $this->view->form = $form; } public function deleteAction() { $request = $this->getRequest(); $id = (int) $request->getParam('id'); $termos = new Model_TermoResponsabilidade(); if ($id > 0) { try{ $termos->excluir($id); $this->_helper->flashMessenger(array( 'success' => 'Registro excluído com sucesso' )); } catch (Core_Exception $ex) { $this->_helper->flashMessenger(array( 'error' => $ex->getMessage() )); } } $this->_redirect('/termo-responsabilidade'); } public function enviarTermoCorretorAction() { $this->_helper->viewRenderer->setNoRender(); $this->_helper->layout->disableLayout(); $request = $this->getRequest(); $corretorId = $request->getParam('corretor'); $tipoAcesso = $request->getParam('tipo_acesso'); $corretor = $this->service->getCorretorTermo($corretorId, $tipoAcesso); $termoId = $request->getParam('termo_id'); try { $path = $this->service->getPathResolve($corretor['id']); $file = $path . $this->service::FILENAME; $this->view->corretor = $corretor; $this->view->termo = $this->service->getTermo($request->getParam('termo_id')); Core_PDF::outputPdfHtml(UPLOAD_PATH . $file, $this->view->render(self::VIEW_TERMO)); $uuid = $this->service->sendAutentiqueDocument($corretor, $file); $this->service->saveSolicitacaoAssinatura($corretor['id'], $corretor['email'], $termoId, $uuid); $this->_helper->json(['success' => self::TERMO_ENVIADO]); } catch (DomainException $domainException) { $this->_helper->json(['alert' => $domainException->getMessage()]); } catch (Throwable $throwable) { $return = json_decode($throwable->getMessage()); $this->_helper->json(['alert' => $return->message ?? $throwable->getMessage()]); } } public function reenviarTermoCorretorAction() { $this->_helper->viewRenderer->setNoRender(); $this->_helper->layout->disableLayout(); $request = $this->getRequest(); $tipoAcesso = $request->getParam('tipo_acesso'); $termoId = $request->getParam('termo_id'); $corretorId = $request->getParam('corretor'); $corretor = $this->service->getCorretorTermo($corretorId, $tipoAcesso); $termoPendente = $this->service->getTermoEnviado($termoId, $corretor['id']); if (!$this->service->removerTermoPendente($termoPendente['uuid'])) { $this->_helper->json(['alert' => self::ERRO_REENVIO]); } try { $path = $this->service->getPathResolve($corretor['id']); $file = $path . $this->service::FILENAME; $this->view->corretor = $corretor; $this->view->termo = $this->service->getTermo($termoId); Core_PDF::outputPdfHtml(UPLOAD_PATH . $file, $this->view->render(self::VIEW_TERMO)); $uuid = $this->service->sendAutentiqueDocument($corretor, $file); $this->service->saveSolicitacaoAssinatura($corretor['id'], $corretor['email'], $termoId, $uuid); $this->_helper->json(['success' => self::TERMO_ENVIADO]); } catch (DomainException $domainException) { $this->_helper->json(['alert' => $domainException->getMessage()]); } catch (Throwable $throwable) { $return = json_decode($throwable->getMessage()); $this->_helper->json(['alert' => $return->message ?? $throwable->getMessage()]); } } public function deleteTermoEnviadoAction() { $this->_helper->viewRenderer->setNoRender(); $this->_helper->layout->disableLayout(); $request = $this->getRequest(); $corretorId = $request->getParam('corretor_id'); $termoId = $request->getParam('termo_id'); $termoEnviado = $this->service->getTermoEnviado($termoId, $corretorId); if (empty($termoEnviado)) { $this->_helper->json(['alert' => self::ERRO_EXCLUSAO]); } if (!$this->service->removerTermoPendente($termoEnviado['uuid'])) { $this->_helper->json(['alert' => self::ERRO_EXCLUSAO]); } $this->_helper->json(['success' => self::TERMO_EXCLUIDO]); } public function downloadTermoAssinadoAction() { try { $termoEvnaidoId = $this->getRequest()->getParam('id'); $termoDownload = model('corretor-assinatura')->getTermoAssinado($termoEvnaidoId); echo service('s3')->download($termoDownload['documento_assinado'], 'Termo Responsabilidade[assinado].pdf'); die(); } catch (Throwable $throwable) { $this->_helper->flashMessenger(['alert' => $throwable->getMessage()]); $this->_redirect('/corretor/update/id/' . $termoDownload['corretor_id']); } } public function incluirDocTermoAction() { $request = $this->getRequest(); $id = (int) $request->getPost('id'); if (empty($id)) { $this->_helper->json(['alert' => 'Nenhum documento informado.']); } $incluir = $request->getPost('incluir_termo') == 'true' ? 1 : 0; $docs = new Model_DbTable_CorretorDocumento(); try{ $result = $docs->update(['incluir_termo' => $incluir], "id = " . $id); if ($result) { $msg = $incluir ? 'incluído' : 'removido'; $this->_helper->json(['success' => "Documento $msg com sucesso"]); } $this->_helper->json(['alert' => 'Falha ao incluir o documento.']); } catch (Core_Exception $ex) { $this->_helper->json(['alert' => $ex->getMessage()]); } } }
💾 保存文件
← 返回文件管理器