✏️ 正在编辑: FuncionarioController.php
路径:
/srv/systems_dir/yuppiecred/application/controllers/FuncionarioController.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class FuncionarioController extends Zend_Controller_Action { public function indexAction() { $form = new Form_Filtro_Funcionario(); $request = $this->getRequest(); if( $request->isPost() ){ $form->populate($request->getPost()); $dbtable = new Model_Funcionario(); $this->view->paginator = $dbtable->listar($form->getFilter(), 'nome ASC'); } $this->view->form = $form; } public function saveAction() { $request = $this->getRequest(); $id = (int) $request->getParam('id'); $form = new Form_Funcionario(); if( $request->isPost() ){ if( $form->isValid($request->getPost()) ){ $funcionario = new Model_Funcionario($request->getPost()); try { $id = $funcionario->salvar($funcionario); $this->_helper->flashMessenger(array( 'success' => 'Dados salvos com sucesso.' )); } catch ( Zend_Exception $e ) { $this->_helper->flashMessenger($e->getMessage()); } } } if( $id > 0 ){ $funcionario = new Model_Funcionario(); $dados = $funcionario->exibir($id); $dados['data_nascimento'] = $dados['data_nascimento'] != null && $dados['data_nascimento'] != '0000-00-00' ? date('d/m/Y', strtotime($dados['data_nascimento'])) : ''; $form->populate($dados->toArray()); //Aba Dependentes do Funcionário $formDependente = new Form_Dependente(); $this->view->formDependente = $formDependente; $dependente = new Model_Dependente(); $this->view->pagDependentes = $dependente->getDependentesIdade($id); //Aba Histórico do Funcionário $formHistorico = new Form_Historico(); $this->view->formHistorico = $formHistorico; $historico = new Model_Historico(); $where = array( 'fornecedor_id = ?' => $id ); $this->view->pagHistorico = $historico->listar("fornecedor_id = {$id}"); } $this->view->form = $form; } public function deleteAction() { $request = $this->getRequest(); $id = (int) $request->getParam('id'); if( $id > 0 ){ $funcionario = new Model_Funcionario(); $funcionario->excluir($id); } $this->_redirect('/funcionario'); } /** * Detalhamento de Custos */ public function detalhamentoCustoAction() { $this->getHelper('Layout')->disableLayout(); $request = $this->getRequest(); $funcionarioId = $request->getParam('id'); try{ $model = new Model_Funcionario(); $this->view->dados_funcionario = $model->exibir($funcionarioId); $this->_helper->json([ 'alert' => '', 'body' => true, 'content' => $this->view->render('funcionario/detalhamento-custo.phtml'), ]); }catch (Exception $e){ $this->_helper->flashMessenger([ 'alert' => 'Falha ao carregar o detalhamento.' ]); } } /* * Salvar Dependentes */ public function saveDependentesAction() { $request = $this->getRequest(); $idFunc = (int) $request->getParam('id'); $form = new Form_Dependente(); if( $request->isPost() ){ if( $form->isValid($request->getPost()) ){ $dependente = new Model_Dependente($request->getPost()); $dependente->setFornecedorId($idFunc); try { $id = $dependente->salvar($dependente); $this->_helper->flashMessenger(array( 'success' => 'Dados salvos com sucesso.' )); } catch ( Zend_Exception $e ) { $this->_helper->flashMessenger($e->getMessage()); } } } $this->_helper->redirector('save', null, null, array( 'id' => $idFunc, 'tab' => '1' ) ); } /* * Salvar Histórico Funcionário */ public function saveHistoricoAction() { $request = $this->getRequest(); $idFunc = (int) $request->getParam('id'); $form = new Form_Historico(); if( $request->isPost() ){ if( $form->isValid($request->getPost()) ){ $historico = new Model_Historico($request->getPost()); $historico->setFornecedorId($idFunc); try { $id = $historico->salvar($historico); $this->_helper->flashMessenger(array( 'success' => 'Dados salvos com sucesso.' )); } catch ( Zend_Exception $e ) { $this->_helper->flashMessenger($e->getMessage()); } } } $this->_helper->redirector('save', null, null, array( 'id' => $idFunc, 'tab' => '1' ) ); } /* * Excluir Dependente */ public function deleteDependenteAction() { $request = $this->getRequest(); $id = (int) $request->getParam('id'); $func = (int) $request->getParam('func'); if( $id > 0 ){ $dependente = new Model_Dependente(); $dependente->excluir($id); } $this->_helper->redirector('save', null, null, array( 'id' => $func, 'tab' => '1' ) ); } /* * Excluir Histórico Funcionário */ public function deleteHistoricoAction() { $request = $this->getRequest(); $id = (int) $request->getParam('id'); $func = (int) $request->getParam('func'); if( $id > 0 ){ $dependente = new Model_Historico(); $dependente->excluir($id); } $this->_helper->redirector('save', null, null, array( 'id' => $func, 'tab' => '1' ) ); } /* * Buscar dados para Folha de Pagamento */ public function getDadosFolhaPagamentoAction() { $model = new Model_Funcionario(); $funcionario = $this->getRequest()->getParam('funcionario_id'); $diasTrabalhado = $this->getRequest()->getParam('dias_trabalhados') ?: 0; $diasFalta = $this->getRequest()->getParam('qtde_falta') ?: 0; if (empty($funcionario)) { $this->_helper->json(['alert' => 'Funcionário não informado']); } $values = $model->getDadosFolha($funcionario, $diasTrabalhado, $diasFalta); $this->_helper->json($values); } }
💾 保存文件
← 返回文件管理器