✏️ 正在编辑: FolhaPontoController.php
路径:
/srv/systems_dir/yuppiecred/application/controllers/FolhaPontoController.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class FolhaPontoController extends Zend_Controller_Action { public function init() { } public function indexAction() { $request= $this->getRequest(); $form = new Form_Filtro_FolhaPonto(); $values = $request->getPost(); if($request->isPost() && $form->isValid($values)){ $funcionario = new Model_Funcionario(); $mesAno = $request->getParam('mes_ano'); $funcionarioId = $request->getParam('funcionario_id'); $modelFolhaPonto = new Model_FolhaPonto(); $pontos = []; $folhas = $modelFolhaPonto->listar($funcionarioId, $mesAno); foreach($folhas as $folha){ $time = strtotime($folha['data_ponto']); $data = getDate($time); $pontos[$data['mday']] = $folha->toArray(); } $this->view->pontos = $pontos; $this->view->funcionario = $funcionario->exibir($funcionarioId); $this->view->form = $form->populate($request->getPost()); $this->view->mesAno = $mesAno; $this->view->folgas = (new Model_FolhaPontoFolgas())->getFolgas($mesAno, $funcionarioId); } $this->view->form = $form; } public function saveAction() { $request = $this->getRequest(); $form = new Form_FolhaPonto(); if($request->isPost() && $form->isValid($request->getPost())){ $funcionarioId = Yuppie_Auth::getIdentity()->funcionario_id; //Registra Entrada no trabalho $cpf = String_Refatorar::resetCpf($request->getParam('cpf')); $modelFuncionario = new Model_Funcionario(); $funcionario = $modelFuncionario->findByCpf($cpf); $tipoRegistro = $request->getParam('registro'); $pontos = array('chegada_trabalho', 'saida_intervalo', 'retorno_intervalo', 'saida_intervalo2', 'retorno_intervalo2', 'saida_intervalo3', 'retorno_intervalo3', 'saida_trabalho'); if(!empty($funcionario) && $funcionario['id'] == $funcionarioId && trim($tipoRegistro)) { //realiza as validações para registro repetido if(in_array($tipoRegistro, $pontos)){ $filter = new Zend_Filter_Word_UnderscoreToCamelCase(); $tipoCamelCase = $filter->filter($tipoRegistro); $proximoPonto = null; $folhaPonto = new Model_FolhaPonto(); //buscar data_ponto e entradas e saidas do funcionario $registro = $folhaPonto->findByDate(Zend_Date::now()->get('yyyy-MM-dd'), $funcionario['id']); $dados = $registro['id'] > 0 ? $registro->toArray() : array(); $folhaPonto->setOptions($dados); if ( trim($folhaPonto->getHorarioByTipo('SaidaTrabalho')) ){ $this->_helper->flashMessenger(array('error' => 'O registro de saída de trabalho já foi registrado. Não é possível realizar esta operação.')); } else { if ( !trim($folhaPonto->getHorarioByTipo('ChegadaTrabalho')) && $tipoCamelCase != 'ChegadaTrabalho' ){ $this->_helper->flashMessenger(array('error' => 'O ponto de chegada ainda não foi registrado.')); } else { if ( !trim($folhaPonto->getHorarioByTipo($tipoCamelCase)) ) { $dados['funcionario_id'] = $funcionarioId; $dados['login'] = Yuppie_Auth::getIdentity()->login; $dados['ip'] = $_SERVER['REMOTE_ADDR']; $dados['dataPonto'] = Zend_Date::now()->get("yyyy-MM-dd"); $dados[$tipoRegistro] = Zend_Date::now()->get("HH:mm:ss"); $folhaPonto->setOptions($dados); $result = $folhaPonto->salvar($folhaPonto); if($result){ $this->_helper->flashMessenger(array('success' => 'Dados salvos com sucesso.')); } else { $this->_helper->flashMessenger(array('error' => 'O ponto não foi registrado. Verifique os dados e tente novamente.')); } } else { $this->_helper->flashMessenger(array('error' => 'O ponto já foi registrado. Verifique os dados e tente novamente.')); } } } } else { $this->_helper->flashMessenger(array('error' => 'Tipo de ponto inválido. Verifique os dados e tente novamente.')); } } else { $this->_helper->flashMessenger(array('error' => 'Funcionário não encontrado. Verifique os dados e tente novamente.')); } } $this->view->form = $form; } public function deleteAction() { $request = $this->getRequest(); $id = (int) $request->getParam('id'); if( $id > 0 ){ $registro = new Model_FolhaPonto(); $registro->excluir($id); } $this->_redirect('/folha-ponto'); } public function updateAction() { $request = $this->getRequest(); $form = new Form_EditarFolhaPonto(); $id = (int) $request->getParam('id'); $folhaPonto = new Model_FolhaPonto(); if( $request->isPost() ){ if($form->isValid($request->getPost()) ){ $dados = $folhaPonto->exibir($id); $folhaPonto->setOptions($dados->toArray()); $folhaPonto->setOptions($request->getPost()); $folhaPonto->setLogin(Yuppie_Auth::getIdentity()->login); $folhaPonto->setIp($_SERVER['REMOTE_ADDR']); try { $id = $folhaPonto->salvar($folhaPonto); $this->_helper->flashMessenger( array( 'success' => 'Dados salvos com sucesso.' )); } catch ( Zend_Exception $e ) { $this->_helper->flashMessenger( array( 'error' => $e->getMessage() )); } } } if( $id > 0 ){ $dados = $folhaPonto->exibir($id); $form->populate($dados->toArray()); } $this->view->form = $form; } public function listarFolgasAction() { $request = $this->getRequest(); $form = new Form_Filtro_FolhaPontoFolgas(); $values = $request->getPost(); $filtro = new Zend_Session_Namespace('filtro_folgas'); if ($request->isPost() && $form->isValid($values)) { $dbTableFolgas = new Model_DbTable_FolhaPontoFolgas(); $this->view->listaFolgas = $dbTableFolgas->listarFolgas($request->getParams()); $filtro->unsetAll(); $filtro->filtro_folgas = array_filter($request->getPost()); } if (!empty($filtro->filtro_folgas)) { $form->populate($filtro->filtro_folgas); $dbTableFolgas = new Model_DbTable_FolhaPontoFolgas(); $this->view->listaFolgas = $dbTableFolgas->listarFolgas($filtro->filtro_folgas); } $this->view->form = $form; } public function registrarFolgasAction() { $request = $this->getRequest(); $id = (int) $request->getParam('id'); $form = new Form_FolhaPontoFolgas(); if ($request->isPost() && $form->isValid($request->getPost())) { $folhaPontoFolgas = new Model_FolhaPontoFolgas($request->getPost()); $salvo = $folhaPontoFolgas->salvar($folhaPontoFolgas); $this->_helper->flashMessenger([ $salvo['status'] => $salvo['msg'] ]); $this->_redirect('/folha-ponto/listar-folgas'); } if ($id > 0) { $folhaPontoFolgas = new Model_FolhaPontoFolgas(); $dados = $folhaPontoFolgas->exibir($id); $form->populate($dados->toArray()); } $this->view->form = $form; } public function excluirFolgasAction() { $request = $this->getRequest(); $id = (int) $request->getParam('id'); if ($id > 0) { $registro = new Model_FolhaPontoFolgas(); $registro->excluir($id); } $this->_redirect('/folha-ponto/listar-folgas'); } }
💾 保存文件
← 返回文件管理器