✏️ 正在编辑: AtendimentoCorretorController.php
路径:
/srv/systems_dir/yuppiecred-lidernegocios/application/controllers/AtendimentoCorretorController.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class AtendimentoCorretorController extends Zend_Controller_Action { public function init() { /* Initialize action controller here */ } public function indexAction() { $form = new Form_Filtro_AtendimentoCorretor(); $request = $this->getRequest(); $page = $request->getPost('page', 1); $fields = array_filter($request->getPost()); $ns = new Zend_Session_Namespace('filtro_atendimento_corretor'); $supervisor = Yuppie_Auth::getIdentity()->acesso['tipo_acesso'] == 3; if( $request->isPost() ){ $ns->unsetAll(); $ns->filtro_atendimento_corretor = $request->getPost(); } if( isset($ns->filtro_atendimento_corretor) && count($ns->filtro_atendimento_corretor) > 0 ){ $fields = $ns->filtro_atendimento_corretor; unset($fields['btn_filtrar']); unset($fields['page']); $form->populate($fields); } try { $model = new Model_Contrato(); if ($supervisor) { $order = array( "sinalizar_supervisor DESC", "status_resolucao_id DESC", "corretores.nome ASC" ); $fields['atendimento_supervisor'] = true; $agendados = $model->getAtendimentoCorretorAgendados($fields); } else { $order = "corretores.nome ASC"; } $result = $model->getAtendimentoCorretor($fields, $order, $page, 100); } catch ( Zend_Db_Exception $e ) { } catch ( Exception $e ) { $this->_helper->json(array( 'alert' => $e->getMessage(), 'body' => true )); } $form->populate($fields); $this->view->supervisor = $supervisor; $this->view->paginator = $result; if( $request->isXmlHttpRequest() && isset($result) ){ $json = array( 'page' => $page, 'pages' => $result->count(), 'readCompleted' => ($result->count() == $page) ? true : false, 'content' => $this->view->render('atendimento-corretor/index-body.phtml'), 'body' => true ); if( isset($agendados) && $agendados ) $json['info'] = "Há {$agendados[0]['total']} atendimento(s) agendado(s)"; $this->_helper->json($json); } $this->view->form = $form; } public function exibirCorretorAction() { $request = $this->getRequest(); $corretorId = (int) $request->getParam('corretor_id'); $form = new Form_AtendimentoCorretor(); if( $request->isPost() ){ if( $form->isValid($request->getPost()) ){ $fields = array_filter($request->getPost()); $fields['corretor_id'] = $corretorId; $fields['usuario_atendimento'] = Yuppie_Auth::getIdentity()->id; unset($fields['btn_save']); $atendimentoCorretor = new Model_AtendimentoCorretor($fields); try { $notificar = $atendimentoCorretor->notificarSupervisor(); if( $notificar ){ $this->view->descricao = $atendimentoCorretor->getDescricao(); $this->view->data_ligacao = $atendimentoCorretor->getDataLigacao(); $this->view->corretor = $notificar->corretor; $this->view->supervisor = $notificar->nome; //faz o envio da mensagem try { $email = new Core_Mail(); $email->enviarMensagemHtml($notificar->nome, $notificar->email, "Urgência apoio comercial", $this->view->render('atendimento-corretor/notificacao-supervisor.phtml')); } catch ( Zend_Mail_Exception $e ) { $this->_helper->flashMessenger(array( 'alert' => 'Uma falha pode ter ocorrido. ' . 'Sua mensagem não foi enviada. ' . 'Por favor, tente novamente! <br/>' . $e->getMessage() )); } } $atendimentoCorretor->salvar($atendimentoCorretor); $proxContato = $atendimentoCorretor->getdataProximoContato(); if( $proxContato ){ $dbtipos = new Model_DbTable_Tipos(); $statusResolucaoId = $dbtipos->statusResolucaoPorNome('AGENDAR'); $agendamento = new Model_AtendimentoCorretor(); $agendamento->setStatusResolucaoId($statusResolucaoId); $agendamento->setDataProximoContato($proxContato); $agendamento->setHoraProximoContato($request->getParam('hora_proximo_contato')); $agendamento->setCorretorId($atendimentoCorretor->getCorretorId()); $agendamento->setUsuarioAtendimento($atendimentoCorretor->getUsuarioAtendimento()); $agendamento->salvar($agendamento); } $this->_helper->flashMessenger(array( 'success' => 'Dados salvos com sucesso.' )); $this->_redirect("/atendimento-corretor"); } catch ( Exception $e ) { $this->_helper->flashMessenger($e->getMessage()); } } } $atendimentoCorretor = new Model_AtendimentoCorretor(); if( $corretorId > 0 ){ try { $dados = $atendimentoCorretor->verificarCorretorAtendimento($corretorId); if( $dados ){ //atendimento agendado if( is_null($dados['status_resolucao_id']) ){ $dados['data_ligacao'] = Zend_Date::now()->get('dd/MM/yyyy'); $dados['data_proximo_contato'] = ""; } else { $dados['data_ligacao'] = !empty($dados['data_ligacao']) && $dados['data_ligacao'] != '0000-00-00' ? date('d/m/Y', strtotime($dados['data_ligacao'])) : ""; $dados['data_proximo_contato'] = !empty($dados['data_proximo_contato']) && $dados['data_proximo_contato'] != '0000-00-00' ? date('d/m/Y', strtotime($dados['data_proximo_contato'])) : ""; } $form->populate($dados); } } catch ( Exception $e ) { $this->_helper->flashMessenger(array( 'alert' => $e->getMessage() )); $this->_helper->redirector("index"); } if( $corretorId ){ $this->view->atendimentos = $atendimentoCorretor->getHistoricoAtendimento($corretorId); } } $this->view->form = $form; } public function deleteAction() { $request = $this->getRequest(); $id = (int) $request->getParam('id'); if( $id > 0 ){ $banco = new Model_Banco(); $banco->excluir($id); } $this->_redirect('/atendimento-corretor'); } }
💾 保存文件
← 返回文件管理器