✏️ 正在编辑: ReceitaController.php
路径:
/srv/systems_dir/yuppiecred-bkp/application/controllers/ReceitaController.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class ReceitaController extends Zend_Controller_Action { public function init() { /* Initialize action controller here */ } public function indexAction() { $request = $this->getRequest(); $form = new Form_Filtro_Receita(); $ns = new Zend_Session_Namespace('filtro_receitas'); if( $request->isPost() ){ $ns->unsetAll(); $ns->filtro_receitas = $request->getPost(); } if( count($ns->filtro_receitas) > 0 ){ $form->populate($ns->filtro_receitas); $receita = new Model_Receita(); $receitas = $receita->getLancamentos( $ns->filtro_receitas, 'data_vencimento ASC' ); $dados = $request->getPost(); if( array_key_exists('btn_export', $dados) && !empty($dados['btn_export']) ){ $this->_helper->viewRenderer->setNoRender(); $this->_helper->getHelper('layout')->disableLayout(); $fileName = $receita->exportarReceitas($receitas); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: pre-check=0, post-check=0, max-age=0'); header("Pragma: no-cache"); header("Expires: 0"); header('Content-Transfer-Encoding: none'); header('Content-Type: application/vnd.ms-excel;'); // This should work for IE && Opera header("Content-type: application/x-msexcel"); header('Content-disposition: attachment; filename=' . basename($fileName)); header('Content-type: application/pdf'); readfile($fileName); unlink($fileName); die; } $this->view->receitas = $receitas; } $this->view->form = $form; $formUpdate = new Form_ReceitaUpdate(); $formUpdate->setAction($this->view->url(array('action' => 'update-itens'))); $this->view->formUpdate = $formUpdate; } public function addAction() { $request = $this->getRequest(); $form = new Form_Receita(); if( $request->isPost() ){ if( $form->isValid($request->getPost()) ){ $receita = new Model_Receita($request->getPost()); $lancamentoPago = $form->getValue('lancamento_pago'); if( $lancamentoPago ){ $receita->setDataPagamento($form->getValue('data_vencimento')); $receita->setValorPago($form->getValue('valor')); } try { $id = $receita->salvar($receita); $this->_helper->flashMessenger(array('success' => 'Dados salvos com sucesso.')); } catch ( Zend_Exception $e ) { $this->_helper->flashMessenger($e->getMessage()); } } } $this->view->form = $form; } public function updateAction() { $request = $this->getRequest(); $id = (int) $request->getParam('id'); $form = new Form_ReceitaUpdate(); if( $request->isPost() ){ if( $form->isValid($request->getPost()) ){ $receita = new Model_Receita($request->getPost()); try { $id = $receita->salvar($receita); $this->_helper->flashMessenger(array('success' => 'Dados salvos com sucesso.')); } catch ( Zend_Exception $e ) { $this->_helper->flashMessenger($e->getMessage()); } } } if( $id > 0 ){ $receita = new Model_Receita(); $dados = $receita->exibir($id); $dados['data_vencimento'] = $dados['data_vencimento'] != null ? date('d/m/Y', strtotime($dados['data_vencimento'])) : ""; $dados['data_pagamento'] = $dados['data_pagamento'] != null ? date('d/m/Y', strtotime($dados['data_pagamento'])) : ""; $dados['valor'] = number_format($dados['valor'], 2, ',', '.'); $dados['valor_pago'] = number_format($dados['valor_pago'], 2, ',', '.'); $form->populate($dados->toArray()); } $this->view->form = $form; } public function deleteAction() { $request = $this->getRequest(); $id = (int) $request->getParam('id'); if( $id > 0 ){ $receita = new Model_Receita(); $receita->excluir($id); } $this->_redirect('/receita'); } public function imprimirAction() { $this->_helper->layout->setLayout('layout_impressao'); $request = $this->getRequest(); $id = (int)$request->getParam('id'); if( $id > 0 ){ $receita = new Model_Receita(); $dadosReceita = $receita->exibir($id); $this->view->receita = $dadosReceita; } } public function deleteItensAction() { $request = $this->getRequest(); $receitas = $request->getParam('receitas'); if( count($receitas) > 0 ){ $receita = new Model_Receita(); foreach( $receitas as $d ){ $receita->excluir($d); } } $this->_redirect('/receita'); } public function imprimirItensAction() { $this->_helper->layout->setLayout('layout_impressao'); $request = $this->getRequest(); $ids = $request->getParam('receitas'); if(count($ids) > 0){ $receita = new Model_Receita(); $receitas = $receita->listar("id IN (". implode(', ', $ids) .")"); $this->view->receitas = $receitas; } } public function imprimirPromissoriaAction() { $this->_helper->layout->setLayout('layout_impressao'); $request = $this->getRequest(); $id = $request->getParam('id'); $modelReceita = new Model_Receita(); $promissorias = $modelReceita->listar("id = {$id} OR id_pai = {$id}"); $this->view->promissorias = $promissorias; } public function updateItensAction() { $request = $this->getRequest(); if( $request->isPost() ){ $dados = $request->getPost(); $lancamentos = explode('&receitas%5B%5D=', ltrim($dados['lancamentos'], 'receitas%5B%5D=')); if (!$dados['lancamentos'] || count($lancamentos) == 0) { $this->_helper->flashMessenger(array('error' => 'Selecione os lançamentos que deseja alterar')); } else { try { unset($dados['lancamentos'], $dados['btn_save']); $receita = new Model_Receita(); foreach($lancamentos as $lancamentoId) { $receita->alterarItem($lancamentoId, $dados); } $this->_helper->flashMessenger(array( 'success' => 'Dados salvos com sucesso.' )); } catch ( Zend_Exception $e ) { $this->_helper->flashMessenger($e->getMessage()); } } } $this->_helper->redirector('index'); } }
💾 保存文件
← 返回文件管理器