✏️ 正在编辑: StatusPropostaController.php
路径:
/srv/systems_dir/yuppiecred-bkp/application/controllers/StatusPropostaController.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class StatusPropostaController extends Zend_Controller_Action { public function init() { /* Initialize action controller here */ } public function indexAction() { $request = $this->getRequest(); $form = new Form_Filtro_StatusProposta(); $ns = new Zend_Session_Namespace("filtro_status"); if( $request->isPost() ){ $ns->unsetAll(); $ns->filtro_status = $request->getPost(); } if( !empty($ns->filtro_status) ){ $form->populate($ns->filtro_status); $where = []; if( !empty($ns->filtro_status['status_id']) ){ $where["id = ?"] = $ns->filtro_status['status_id']; } if( !empty($ns->filtro_status['descricao']) ){ $where["descricao LIKE ?"] = "%{$ns->filtro_status['descricao']}%"; } if( !empty($ns->filtro_status['parent_id']) ){ if( $ns->filtro_status['parent_id'] == 'null' ){ $where['parent_id IS NULL OR parent_id = ?'] = '0'; } else { $where['parent_id = ?'] = $ns->filtro_status['parent_id']; } } $model = new Model_StatusProposta(); $listaStatus = $model->listar($where, 'descricao ASC'); $paginator = Zend_Paginator::factory($listaStatus); $paginator->setCurrentPageNumber($this->_getParam('page', 1)); $paginator->setItemCountPerPage(50); $this->view->paginator = $paginator; } $this->view->form = $form; } public function saveAction() { $request = $this->getRequest(); $id = (int) $request->getParam('id'); $form = new Form_StatusProposta(); if( $request->isPost() ){ if( $form->isValid($request->getPost()) ){ $status = new Model_StatusProposta($request->getPost()); try { $id = $status->salvar($status); if( $id ){ $this->_helper->flashMessenger(array( 'success' => 'Dados salvos com sucesso.' )); } else { $this->_helper->flashMessenger(array( 'alert' => 'Nenhum registro alterado.' )); } } catch ( Exception $e ) { $this->_helper->flashMessenger($e->getMessage()); } } } if( $id > 0 ){ $status = new Model_StatusProposta(); $dados = $status->exibir($id); $form->populate($dados->toArray()); } $this->view->form = $form; } public function deleteAction() { $request = $this->getRequest(); $id = (int) $request->getParam('id'); $statusProposta = $request->getParam('status_proposta'); $status = new Model_StatusProposta(); if( $id > 0 ){ try { $status->excluir($id); $this->_helper->flashMessenger(array( 'success' => 'Registro excluido com sucesso.' )); } catch ( Exception $e ) { $this->_helper->flashMessenger(array( 'error' => $e->getMessage() )); } } if( !empty($statusProposta) && is_array($statusProposta) ){ $cont = 0; foreach ( $statusProposta as $statusPropostaId ) { try{ $status->excluir($statusPropostaId); $cont++; } catch ( Exception $e ) { $this->_helper->flashMessenger(array( 'error' => $e->getMessage() )); continue; } } if($cont > 0){ $this->_helper->flashMessenger(array('success' => "{$cont} Registro(s) excluido(s) com sucesso.")); } } $this->_redirect('/status-proposta'); } public function setarStatusPaiAction() { $request = $this->getRequest(); $statusId = $request->getParam('status_proposta'); if( !$statusId ){ $this->_helper->flashMessenger(array( 'error' => "Nenhum status localizado." )); $this->_redirect('/status-proposta'); return; } if( !$request->getParam("parent_id") ){ $this->_helper->flashMessenger(array( 'error' => "Nenhum status pai informado." )); $this->_redirect('/status-proposta'); return; } $cont = 0; foreach( $statusId as $status ){ $model = new Model_StatusProposta(); $dados = $model->exibir($status); if( $dados->parent_id > 0 ){ continue; } $model->setOptions($dados->toArray()); $model->setParentId($request->getParam("parent_id")); try { if( $model->salvar($model) ){ $cont++; } } catch (Core_Exception $e) { $this->_helper->flashMessenger([ 'error' => $e->getMessage() ]); } } if( $cont > 0 ){ $this->_helper->flashMessenger(array( 'success' => "Status atualizados com sucesso. ({$cont})" )); } $this->_redirect('/status-proposta'); } public function selecionarAcaoAction() { $acao = $this->getRequest()->getPost('acao'); $acoes = array( 'delete', 'setar-status-pai' ); if( in_array($acao, $acoes) ){ $this->_forward($acao, null, null, $this->getRequest()->getParams()); } else { $this->_helper->flashMessenger(array( 'error' => "A ação selecionada não está disponível!" )); $this->_helper->redirector('index'); } } }
💾 保存文件
← 返回文件管理器