✏️ 正在编辑: IndexController.php
路径:
/srv/systems_dir/yuppiecred/application/controllers/IndexController.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class IndexController extends Zend_Controller_Action { public function init() { /* Initialize action controller here */ } public function indexAction() { $ns = new Zend_Session_Namespace(); $acl = $ns->acl; if( $acl->isAllowed(Yuppie_Auth::getIdentity()->grupo, 'folha-ponto', 'index') && Yuppie_Auth::getIdentity()->bater_ponto == 1 ){ //Verificar se usuário bater_ponto já deu entrada $folhaPonto = new Model_FolhaPonto(); $folhaPontoEntradasSaidas = $folhaPonto->findByDate(Zend_Date::now()->get('yyyy-MM-dd'), Yuppie_Auth::getIdentity()->funcionario_id); if($folhaPontoEntradasSaidas['data_ponto'] == ''){ $this->_helper->flashMessenger(array('info' => 'Bata seu ponto!')); $this->_redirect('folha-ponto/'); } } if( $acl->isAllowed(Yuppie_Auth::getIdentity()->grupo, 'mensagem', 'view') ){ $mensagem = new Model_Mensagem(); $this->view->mensagens = $mensagem->fetchRecebidas(); } if( Yuppie_Auth::getIdentity()->grupo == 'Supervisor' && !Yuppie_Auth::getIdentity()->rota_id ){ $this->_helper->flashMessenger(array( 'alert' => 'Atenção! Você não está atrelado a uma rota.' )); } if (Yuppie_Auth::getIdentity()->grupo == 'Supervisor') { $modelCorretor = new Model_Corretor(); $corretoresBloqueados = $modelCorretor->getCorretoresBySupervisor(Yuppie_Auth::getIdentity()->id, true); $this->view->corretores_bloqueados = $corretoresBloqueados; } if (in_array(Yuppie_Auth::getIdentity()->grupo, ['Corretor', 'Afiliado', 'Indicador'])) { $this->_helper->layout->setLayout('layout_corretor'); } if( Yuppie_Auth::getIdentity()->grupo == 'Corretor'){ $corretor = new Model_Corretor(); $dashboardCorretor = $corretor->exibirDashboard(); $this->view->comissao = $dashboardCorretor['comissao_receber']; $this->view->fisicosNaoEntreguesPagos = $dashboardCorretor['fisicos_nao_ent_pag']; $this->view->producaoUltimosMeses = $dashboardCorretor['producao']; $this->view->propostas_recusadas = $dashboardCorretor['propostas_recusadas']; $this->view->fisicos_pendentes = $dashboardCorretor['fisicos_pendentes']; $this->view->esteira_contratos = $dashboardCorretor['esteira_contratos']; $this->view->acoes_judiciais = $dashboardCorretor['acoes_judiciais']; $this->view->contratosCancelados = $dashboardCorretor['contratos_cancelados']; $dadosCorretor = $corretor->exibir(Yuppie_Auth::getIdentity()->id); $this->view->dados_corretor = $dadosCorretor; if( !$corretor->estaAtualizado() ){ $this->_forward('atualizar-dados-corretor'); } if( Yuppie_Auth::getIdentity()->bloquear_pagamento == 1 ){ $this->_helper->flashMessenger(array( 'error' => 'Atenção! Pagamento bloqueado. ' . 'Motivo: ' . (Yuppie_Auth::getIdentity()->motivo ? Yuppie_Auth::getIdentity()->motivo : 'não especificado') )); } if ((new Model_Corretor())->checarIndiceFraude(Yuppie_Auth::getIdentity()->id)) { $this->_helper->flashMessenger(['alert' => 'Atenção! Você está com o índice de fraude maior que o permitido. ']); } $diasVencimentoCertificado = $corretor->getDiasVencimentoCertificado(Yuppie_Auth::getIdentity()->validade_certificado); if( !empty(Yuppie_Auth::getIdentity()->validade_certificado) && Yuppie_Auth::getIdentity()->validade_certificado != '0000-00-00' && $diasVencimentoCertificado <= 45 ){ $this->view->dias_vencimento_certificado = $diasVencimentoCertificado; $this->view->certificado_a_vencer = true; $this->view->form_atualizar_certificado = new Form_CorretorAtualizarCertificado(); } } $aniversariantes = array(); $visualizarAniversariantes = $acl->has('visualizar-aniversariantes-do-dia') ? $acl->isAllowed(Yuppie_Auth::getIdentity()->grupo, 'visualizar-aniversariantes-do-dia') : Yuppie_Auth::getIdentity()->grupo != 'Corretor'; if( $visualizarAniversariantes ){ $tbCorretor = new Model_DbTable_Corretor(); $aniversariantes['corretores'] = $tbCorretor->getAniversariantesDoDia(); $tbFuncionario = new Model_DbTable_Funcionario(); $aniversariantes['funcionarios'] = $tbFuncionario->getAniversariantesDoDia(); $tbCliente = new Model_DbTable_Cliente(); $aniversariantes['clientes'] = $tbCliente->getAniversariantesDoDia(); } if( isset(Yuppie_Auth::getIdentity()->data_nascimento) ){ $auth = Yuppie_Auth::getIdentity(); $dataNasc = new Zend_Date($auth->data_nascimento, 'yyyy-MM-dd'); $hoje = Zend_Date::now(); if( $hoje->get('dd/MM') == $dataNasc->get("dd/MM") ){ $this->_helper->flashMessenger(array( 'success' => 'Feliz aniversário, ' . $auth->nome . '!' )); } } // Contas do dia if( $acl->isAllowed(Yuppie_Auth::getIdentity()->grupo, 'visualizar-contas-dia') ){ $despesa = new Model_Despesa(); $despesas = $despesa->getLancamentosVencidos(Zend_Date::now()->get('yyyy-MM-dd')); $this->view->despesas = $despesas; } if (Yuppie_Auth::getIdentity()->grupo != 'Corretor' && $acl->isAllowed(Yuppie_Auth::getIdentity()->grupo, 'visualizar-corretores-certificado-vencer')) { $dbTableCorretores = new Model_DbTable_Corretor(); $this->view->certificados_a_vencer = $dbTableCorretores->selectCorretorCertificadoAVencer(); } $this->view->inicialize_js = Core_GChart::initializeScript(1); $this->view->aniversariantes = $aniversariantes; $this->view->acl = $acl; } public function manutencaoAction(){} public function paginaManutencaoAction(){} public function semPermissaoAction() { if( $this->getRequest()->isXmlHttpRequest() ){ $this->_helper->json(array( 'alert' => 'Você não tem permissão de acesso a esta área.' )); } } public function novaSenhaCorretorAction() { $request = $this->getRequest(); $dados = Yuppie_Auth::getIdentity(); $form = new Form_TrocarSenha(); if( !$dados ){ $this->_helper->redirector('login'); } $usuario = new Model_DbTable_Corretor(); if( $request->isPost() && $form->isValid($request->getPost()) ){ try { $fDados = $form->getValues(); $where = $dados; $result = $usuario->changePassword($fDados, $where); if( $result > 0 ){ $this->_helper->redirector('logout', 'auth'); } else { $this->_helper->flashMessenger(array( 'alert' => 'Nenhum registro foi alterado.' )); } } catch ( Exception $ex ) { $this->_helper->flashMessenger(array( 'alert' => $ex->getMessage() )); } } $this->view->form = $form; } public function atualizarDadosCorretorAction() { $corretor = new Model_Corretor(); $dadosCorretor = $corretor->exibir(Yuppie_Auth::getIdentity()->id); $form = new Form_CorretorAtualizacao(); $request = $this->getRequest(); $result = null; if( $request->isPost() && $form->isValid($request->getPost()) ){ $data = array_filter($request->getPost()); $corretorId = $dadosCorretor->id; unset($data['btn_save']); unset($data['corretor_id']); $dbtable = new Model_DbTable_Corretor(); //retira as data de atualização $data['att_dados_corretor'] = 0; $data['data_ultima_atualizacao'] = Zend_Date::now()->get('yyyy-MM-dd'); Yuppie_Auth::getIdentity()->data_ultima_atualizacao = $data['data_ultima_atualizacao']; $result = $dbtable->update($data, "id = " . $corretorId); if( $result > 0 ){ $this->_helper->flashMessenger(array( 'success' => 'Dados atualizados com sucesso.' )); $this->_forward('index'); } else { $this->_helper->flashMessenger(array( 'alert' => 'Nenhum registo foi alterado.' )); } } //verifica se esta valido para exibição do formulário. $atualizarDados = $corretor->atualizarDadosCorretor($dadosCorretor); if( $atualizarDados ){ $form->populate($atualizarDados); $this->view->form = $form; } } public function novaSenhaAction() { $request = $this->getRequest(); $dados = Yuppie_Auth::getIdentity(); $form = new Form_TrocarSenha(); if( !$dados ){ $this->_helper->redirector('login'); } $usuario = new Model_DbTable_Usuario(); if( $request->isPost() && $form->isValid($request->getPost()) ){ try { $fDados = $form->getValues(); $where = $dados; $result = $usuario->changePassword($fDados, $where); if( $result > 0 ){ $this->_helper->flashMessenger(array( 'success' => 'Senha alterada com sucesso! A partir de agora você deverá usar a nova senha cadastrada.' )); } else { $this->_helper->flashMessenger(array( 'alert' => 'Nenhum registro foi alterado.' )); } } catch ( Exception $ex ) { $this->_helper->flashMessenger(array( 'alert' => $ex->getMessage() )); } } $this->view->form = $form; } public function desempenhoComercialAction() { $request = $this->getRequest(); if( $request->isPost() ){ try { $ns = new Zend_Session_Namespace(); if( $ns->acl->isAllowed(Yuppie_Auth::getIdentity()->grupo, 'visualizar-desempenho-comercial') ){ $modelGerente = new Model_Gerente(); $desempenhoGerente = $modelGerente->meuDesempenhoComercial(); $modelSupervisor = new Model_GerenteRota(); $desempenhoSupervisor = $modelSupervisor->meuDesempenhoComercial(); } } catch ( Exception $e ) { $this->_helper->flashMessenger(array( 'alert' => $e->getMessage() )); } $this->view->desempenho_comercial_gerente = isset($desempenhoGerente) ? $desempenhoGerente : array(); $this->view->desempenho_comercial_supervisor = isset($desempenhoSupervisor) ? $desempenhoSupervisor : array(); } $this->getHelper('Layout')->disableLayout(); } public function desempenhoComercialCorretorAction() { $this->getHelper('Layout')->disableLayout(); $fields = array(); $modelCorretor = new Model_Corretor(); $desempenhoComercialCorretor = array(); $request = $this->getRequest(); $ns = new Zend_Session_Namespace(); if( $request->isPost() ){ try { if(Yuppie_Auth::getIdentity()->grupo == 'Corretor' && $ns->acl->isAllowed(Yuppie_Auth::getIdentity()->grupo, 'visualizar-desempenho-comercial') ){ $desempenhoComercialCorretor = $modelCorretor->meuDesempenhoComercial($fields); } } catch ( Exception $e ) { $this->_helper->flashMessenger(array( 'alert' => $e->getMessage() )); } $this->view->desempenho_comercial_corretor = $desempenhoComercialCorretor; } } public function metasSupervisorAction() { //Produção Gerente - Metas $request = $this->getRequest(); $fields = array_filter($request->getPost()); if( $request->isPost() && count($fields) > 0){ $fields['gerente_comercial_id'] = $request->getPost('gerente_id'); $fields['corretor_id'] = $request->getPost('corretor_id'); } elseif( Yuppie_Auth::getIdentity()->grupo == "Gerente Regional" ){ $fields['gerente_comercial_id'] = Yuppie_Auth::getIdentity()->id; } elseif( Yuppie_Auth::getIdentity()->grupo == 'Supervisor' ){ $fields['gerente_rota_id'] = Yuppie_Auth::getIdentity()->id; } $model = new Model_GerenteMeta(); $grafico = new Model_Grafico(); $fields['grafico'] = true; if( isset($fields['gerente_comercial_id']) && $fields['gerente_comercial_id'] > 0 ){ $values = $model->getProducao($fields, "bancos.nome ASC"); $json = $grafico->producaoGerenteMetaAjax($values); } elseif( Yuppie_Auth::getIdentity()->grupo == "Supervisor" ){ $values = $model->getProducao(array( 'gerente_rota_id' => Yuppie_Auth::getIdentity()->id ), "bancos.nome ASC"); $json = $grafico->producaoGerenteMetaAjax($values); } $this->_helper->json(isset($json) ? $json : array()); } public function downloadAnexoAction() { $this->_helper->layout->disableLayout(); $request = $this->getRequest(); $id = (int) $request->getParam('id'); if( $id ){ $mensagem = new Model_Mensagem(); $model = $mensagem->exibir($id); if( $model->anexo ){ $config = new Zend_Config_Ini(APPLICATION_PATH . "/configs/application.ini"); $s3Options = $config->toArray(); $s3 = new Yuppie_Amazon_S3($s3Options['production']['amazon']['s3']); $info = pathinfo($model->anexo); $siteKey = Yuppie_Auth::getSiteKey(); $result = $s3->getObject("{$siteKey}/mensagens/" . $info['basename']); header('Content-Disposition: attachment; filename=' . $info['basename']); header('Content-Type: ' . $result['ContentType']); echo $result['Body']; } else { $this->_helper->flashMessenger(array( 'alert' => "Anexo não encontrado!" )); } } else { $this->_helper->flashMessenger(array( 'alert' => "Chamado não identificado." )); } die(); } }
💾 保存文件
← 返回文件管理器