✏️ 正在编辑: LayoutComissaoPrevistaController.php
路径:
/srv/systems_dir/yuppiecred/application/controllers/LayoutComissaoPrevistaController.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class LayoutComissaoPrevistaController extends Zend_Controller_Action { public function indexAction() { $form = new Form_Filtro_LayoutComissaoPrevista(); $request = $this->getRequest(); $ns = new Zend_Session_Namespace('filtro_layout_comissao_prevista'); if( $request->isPost() && $form->isValid($request->getPost()) ){ $ns->unsetAll(); $ns->filtro_layout_comissao_prevista = $request->getPost(); } if( isset($ns->filtro_layout_comissao_prevista) ){ $form->populate($ns->filtro_layout_comissao_prevista); $model = new Model_Layouts(); $ns->filtro_layout_comissao_prevista['tipo_layout'] = "COMISSAO_PREVISTA"; $select = $model->listar($ns->filtro_layout_comissao_prevista, 'banco_id ASC'); $this->view->paginator = $select; } $this->view->form = $form; } public function saveAction() { $request = $this->getRequest(); $id = (int) $request->getParam('id'); $form = new Form_LayoutComissaoPrevista(); if ($request->isPost() && $form->isValid($request->getPost())) { $bancoId = $request->getPost('banco_id'); $descricao = $request->getPost('descricao'); $letras = $request->getPost('layout'); unset($letras['btn_save']); $layoutBanco = [ 'banco_id' => $bancoId, 'descricao' => $descricao, 'id' => $id > 0 ? $id : null ]; $model = new Model_Layouts($layoutBanco); try { $model->setTipoLayout("COMISSAO_PREVISTA"); $resultId = $model->salvar($model); $idLayout = $resultId ? $resultId : $id; if ($idLayout) { foreach ($letras as $campo => $letra) { $idLayoutLetra = $request->getParam("id_campo_{$campo}"); $modelLayoutLetras = new Model_LayoutsLetras(array( 'id' => $idLayoutLetra ? $idLayoutLetra : null, 'campo' => $campo, 'letra' => $letra, 'layout_id' => $idLayout )); $result = $modelLayoutLetras->salvar($modelLayoutLetras); } } } catch (Exception $e) { $this->_helper->flashMessenger(array( 'alert' => $e->getMessage() )); } if ($result) { $this->_helper->flashMessenger(array( 'success' => "Layout salvo com sucesso." )); $this->_helper->redirector('save', null, null, array( 'id' => $idLayout )); } else { $this->_helper->flashMessenger(array( 'alert' => "Nenhum registro foi atualizado ou adicionado." )); } } if ($id) { $banco = new Model_Layouts(); $dados = $banco->exibir($id); $modelLetras = new Model_DbTable_LayoutsLetras(); $result = $modelLetras->fetchAll("layout_id = " . $id); $form->populate($dados->toArray()); if ($result) { foreach ($result as $values) { $data = array( $values->campo => $values->letra ); $form->addElement('hidden', "id_campo_{$values->campo}", array( 'value' => $values->id )); $form->populate($data); } } } $this->view->form = $form; } public function deleteAction() { $request = $this->getRequest(); $id = (int) $request->getParam('id'); if( $id > 0 ){ $dbtable = new Model_DbTable_Layouts(); $dados = $dbtable->fetchRow("id = {$id}"); $dbtableLayoutBancoLetras = new Model_DbTable_LayoutsLetras(); $dadosLetras = $dbtableLayoutBancoLetras->fetchAll("layout_id = " . $id); if( $dados ){ $result = $dados->delete(); if( $dadosLetras ){ foreach ( $dadosLetras as $vl ) { $dbtableLayoutBancoLetras->delete("id = " . $vl['id']); } } if( $result ){ $this->_helper->flashMessenger(array( 'success' => 'Registro excluído com sucesso.' )); } else { $this->_helper->flashMessenger(array( 'alert' => 'Nenhum registro foi excluído.' )); } } else { $this->_helper->flashMessenger(array( 'error' => 'Registro não localizado.' )); } } $this->_redirect('/layout-banco'); } public function getLayoutBancoAction() { $this->_helper->viewRenderer->setNoRender(); $this->_helper->getHelper('layout')->disableLayout(); $request = $this->getRequest(); $id = (int) $request->getParam('banco_id'); if( $id > 0 ){ $dbtable = new Model_DbTable_Layouts(); $result = $dbtable->fetchAll("banco_id = " . $id); echo Zend_Json::encode($result->toArray()); } else { echo Zend_Json::encode("empty"); } } }
💾 保存文件
← 返回文件管理器