✏️ 正在编辑: CargoController.php
路径:
/srv/systems_dir/yuppiecred/application/controllers/CargoController.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class CargoController extends Zend_Controller_Action { public function indexAction() { $form = new Form_Filtro_Cargo(); $ns = new Zend_Session_Namespace('filtro_cargos'); if( $this->getRequest()->isPost() ){ $ns->unsetAll(); $ns->filtro_cargos = $this->getRequest()->getPost(); } if( isset($ns->filtro_cargos) ){ $form->populate($ns->filtro_cargos); $cargo = new Model_Cargo(); $this->view->cargos = $cargo->listar($ns->filtro_cargos, 'cargos.nome ASC'); } $this->view->form = $form; } public function saveAction() { $request = $this->getRequest(); $id = (int) $request->getParam('id'); $form = new Form_Cargo(); if( $request->isPost() ){ if( $form->isValid($request->getPost()) ){ $cargo = new Model_Cargo($request->getPost()); try { $id = $cargo->salvar($cargo); $this->_helper->flashMessenger(array( 'success' => 'Dados salvos com sucesso.' )); } catch ( Zend_Exception $e ) { $this->_helper->flashMessenger($e->getMessage()); } } } if( $id > 0 ){ $cargo = new Model_Cargo(); $dados = $cargo->exibir($id); $form->populate($dados->toArray()); } $this->view->form = $form; } public function deleteAction() { $request = $this->getRequest(); $id = (int) $request->getParam('id'); if( $id > 0 ){ $cargo = new Model_Cargo(); $cargo->excluir($id); } $this->_redirect('/cargo'); } public function getFuncionariosAction() { $request = $this->getRequest(); $cargoId = (int) $request->getParam('id'); $values = array(); if( $cargoId > 0 ){ $model = new Model_Funcionario(); $values = $model->listar(array( 'cargo_id' => $cargoId ), "nome ASC"); if( is_object($values) ) $values = $values->toArray(); } $this->_helper->json($values); } }
💾 保存文件
← 返回文件管理器