✏️ 正在编辑: IndicadorController.php
路径:
/srv/systems_dir/yuppiecred/application/controllers/IndicadorController.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php use Modules\SimulacaoAberta\Service\SimulacaoAbertaService; class IndicadorController extends Zend_Controller_Action { private $_bucketFolder = 'indicadores'; public function init() { if (Yuppie_Auth::getIdentity()->grupo == 'Indicador') { $this->_helper->layout->setLayout('layout_corretor'); } } public function indexAction() { $form = new Form_Filtro_Indicador(); $request = $this->getRequest(); $ns = new Zend_Session_Namespace('filtro_indicadores'); if ($request->isPost()) { $ns->unsetAll(); $ns->filtro_indicadores = $request->getPost(); } if (count($ns->filtro_indicadores) > 0) { $form->populate($ns->filtro_indicadores); $dbtable = new Model_DbTable_Corretor(); try { $this->view->paginator = $dbtable->fetchAllDependents($ns->filtro_indicadores, [ "corretores.id", "corretores.nome", "corretores.celular", "corretores.cpf", "corretores.uf", "corretores.cidade", "corretores.email", "corretores.apelido", "corretores.corretor_desativado" ]); } catch (Zend_Db_Statement_Exception $e) { $this->_helper->flashMessenger([ 'error' => 'Erro na consulta! Verifique seus parâmetros de busca.' ]); } catch( Core_Exception $e ){ $this->_helper->flashMessenger([ 'error' => $e->getMessage() ]); } } $this->view->form = $form; $formUpdate = new Form_CorretorUpdate(); $this->view->formUpdateCorretor = $formUpdate; } /** * Salvar Indicador */ public function saveAction() { $request = $this->getRequest(); $id = (int) $request->getParam('id'); $form = new Form_Indicador(); if ($request->isPost()) { if ($form->isValid($request->getPost())) { try { $dadosPost = $request->getPost(); $indicador = new Model_Corretor($dadosPost); $result = $indicador->salvar($indicador); if ($result > 0) { $this->_helper->flashMessenger([ 'success' => 'Dados salvos com sucesso.' ]); } else { $this->_helper->flashMessenger([ 'alert' => 'Atenção! Os dados não foram salvos.' ]); } } catch (Zend_Db_Exception $e) { Yuppie_Log::write("Falha ao salvar indicador =>" . $e->getMessage() . $e->getTraceAsString(), $this); $this->_helper->flashMessenger(['error' => "Falha de comunicação com o banco de dados."]); } catch (Exception $e) { $this->_helper->flashMessenger(['error' => $e->getMessage()]); } } else { $this->_helper->flashMessenger([ 'alert' => 'Atenção! Dados inválidos.' ]); } } if ($id > 0) { $indicador = new Model_Corretor(); $dados = $indicador->exibir($id); $form->populate($dados->toArray()); //exibe o formulário para anexar documentos $formDocumento = new Form_CorretorDocumento(); $this->view->form_corretor_documento = $formDocumento; $documento = new Model_CorretorDocumento(); $documentos = $documento->listar(['corretor_id' => $id]); //exibe o formulário para enviar termos e contratos $formContratosTermos = new Form_CorretorTermosResponsabilidade($dados->empresa_id); $formContratosTermos->populate(['corretor_id' => $id]); $this->view->form_contratos_termos = $formContratosTermos; $modelTermos = new Model_CorretorAssinaturaTermo(); $termosIndicador = $modelTermos->getTermosEnviados($id); $this->view->protocolos = $indicador->getProtocolos($id, 20); $this->view->documentos = $documentos; $this->view->termos = $termosIndicador; } $this->view->form = $form; } public function deleteAction() { $request = $this->getRequest(); $id = (int) $request->getParam('id'); if ($id > 0) { $corretor = new Model_Corretor(); $corretor->excluir($id); $this->_helper->flashMessenger(['success' => 'Registro excluído com sucesso.']); } $this->_redirect('/indicador'); } public function addDocumentoAction() { $request = $this->getRequest(); if ($request->isPost()) { $fields = $request->getPost(); try{ Upload::save((new Zend_File_Transfer_Adapter_Http()), $fields, $this->_bucketFolder); $documento = new Model_CorretorDocumento($fields); $result = $documento->salvar($documento); } catch (Zend_Db_Exception $ex) { $result = null; $this->_helper->flashMessenger(['error' => "Não foi possível gravar o anexo no banco de dados."]); } catch (Exception $e){ $result = null; $this->_helper->flashMessenger(['error' => $e->getMessage()]); } if ($result) { $this->_helper->flashMessenger(['success' => 'Documento adicionado com sucesso.']); } else { $this->_helper->flashMessenger(['alert' => 'Atenção! O documento não foi anexado.']); } } $this->_helper->redirector('save', null, null, ['id' => $request->getParam('corretor_id')]); } public function deleteDocumentoAction() { $request = $this->getRequest(); $id = (int) $request->getParam('id'); if ($id > 0) { $documento = new Model_CorretorDocumento(); $anexo = $documento->exibir($id); try{ Upload::deleteObject($anexo['anexo'], $this->_bucketFolder); $result = $documento->excluir($id); } catch (Exception $ex) { $this->_helper->flashMessenger(['error' => $ex->getMessage()]); } if ($result) { $this->_helper->flashMessenger(['success' => 'Documento removido com sucesso.']); } else { $this->_helper->flashMessenger(['alert' => 'Atenção! O documento não foi removido.']); } } $this->_helper->redirector('save', null, null, ['id' => $request->getParam('corretor_id')]); } public function downloadDocumentoAction() { $anexoUrl = $this->getRequest()->getParam('anexo_url'); Upload::download($anexoUrl, $this->_bucketFolder); } public function getValidarCpfIndicadorAction() { $this->_helper->viewRenderer->setNoRender(); $this->_helper->getHelper('layout')->disableLayout(); $request = $this->getRequest(); $cpf = $request->getParam('cpf'); $exist = []; if ($cpf != null) { $model = new Model_Corretor(); $values = $model->listar("cpf = '$cpf' AND grupo_acesso = 5", "nome ASC"); if ($values->toArray() != null ) $exist = ['exist_cpf' => true]; echo Zend_Json::encode($exist); } } }
💾 保存文件
← 返回文件管理器