public function run() { $this->loginDao = new LoginDao(); if (SessionHandler::checkSession('usuario')) { $this->session = SessionHandler::selectSession('usuario'); $this->usuarioLogado = $this->session['usuario']; if (isset($this->params['adicionar']) && $this->params['adicionar']) { $this->loadTemplate('funcionario/edit_save_funcionario'); } else { if (isset($this->params['salvar']) && $this->params['salvar']) { $this->salvarFuncionario(); } else { if (isset($this->params['editar']) && $this->params['editar']) { $this->editarFuncionario(); } else { if (isset($this->params['remover']) && $this->params['remover']) { $this->removerFuncionario(); } else { $this->load(); } } } } } else { $this->redirect($this->UrlBuilder()->doAction('login')); } }
public function run() { if (SessionHandler::checkSession('usuario')) { if (isset($this->params['salvar']) && $this->params['salvar']) { $this->salvar(); } } }
public function run() { if (SessionHandler::checkSession('usuario')) { $this->load(); } else { $this->redirect($this->UrlBuilder()->doAction('login', array('admin' => 1))); } }
function efetuarLogout() { if (SessionHandler::checkSession('usuario')) { SessionHandler::deleteSession('usuario'); } elseif (SessionHandler::checkSession('cliente')) { SessionHandler::deleteSession('cliente'); } }
public function run() { if (SessionHandler::checkSession('usuario')) { if (isset($this->params['verificar']) && $this->params['verificar']) { $this->loadTemplate('admpedido/verificar'); } else { $this->loadIndex(); } } else { $this->redirect($this->UrlBuilder()->doAction('login')); } }
public function run() { if (SessionHandler::checkSession('cliente')) { $this->dadosLogin = $this->obterDadosDoLogin(); if (isset($this->params['adicionar']) && $this->params['adicionar']) { $this->adicionarAoCarrinho(); } elseif (isset($this->params['remover']) && $this->params['remover']) { $this->removerDoCarrinho(); } elseif (isset($this->params['fazerPedido']) && $this->params['fazerPedido']) { $this->fazerPedido(); } elseif (isset($this->params['confirmarPedido']) && $this->params['confirmarPedido']) { $this->confirmarPedido(); } elseif (isset($this->params['Ok']) && $this->params['Ok']) { $this->loadTemplate(ROOT_URL); } $this->loadTemplate('pedido/index'); } else { $this->loadTemplate('cliente/login'); } }
public function run() { if (SessionHandler::checkSession('usuario')) { if (isset($this->params['adicionar']) && $this->params['adicionar']) { $this->loadTemplate('ingredientes/edit_save_ingredientes'); } else { if (isset($this->params['salvar']) && $this->params['salvar']) { $this->salvarIngrediente(); } else { if (isset($this->params['editar']) && $this->params['editar']) { $this->editarIngrediente(); } else { if (isset($this->params['remover']) && $this->params['remover']) { $this->removerIngrediente(); } else { $this->loadIndex(); } } } } } else { $this->redirect($this->UrlBuilder()->doAction('login')); } }
function salvarCliente() { $cliente = new Cliente(); $erro = ''; if ($this->getPost('id')) { $cliente->setId($this->getPost('id')); } $cliente->setNome($this->getPost('nome')); $cliente->setIdade($this->getPost('idade')); $sexo = $this->getPost('sexo') == 'Masculino' ? 'M' : 'F'; $cliente->setSexo($sexo); $cliente->setData_nascimento($this->getPost('data_nascimento')); $cliente->setNome_mae($this->getPost('nome_mae')); $cpf = $this->getPost('cpf'); // if (!Utils::validaCPF($cpf)) { // $erro .= "CPF inválido."; // } else { $cliente->setCpf($cpf); // } $cliente->setRg($this->getPost('rg')); $email = $this->getPost('email'); // if (!$this->getPost('id') && $this->emailExist($email)) { // $erro .= "E-mail já esta sendo utilizado."; // } else { $cliente->setEmail($email); // } $cliente->setCelular($this->getPost('celular')); $cliente->setTelefone($this->getPost('telefone')); if ($this->getPost('cidade_id') == "0") { $erro .= "Cidade deve ser informada."; } $cliente->setSenha($this->getPost('senha')); $cliente->setCidade_id($this->getPost('cidade_id')); $cliente->setBairro($this->getPost('bairro')); $cliente->setEndereco($this->getPost('endereco')); $clienteS = serialize($cliente); if (strlen($erro) > 0) { $this->redirect($this->UrlBuilder()->doAction('cliente', array('errorMsg' => $erro, 'adicionar' => true, 'clienteS' => $clienteS))); } $clienteDao = new ClienteDao($cliente); if ($this->getPost('id')) { if ($clienteDao->editar(array('id' => $this->getPost('id')))) { $successMsg = "Cliente atualizada com sucesso!"; if (SessionHandler::checkSession('usuario')) { $this->redirect($this->UrlBuilder()->doAction('cliente', array('admin' => TRUE, 'successMsg' => $successMsg))); } $this->redirect($this->UrlBuilder()->doAction('cliente', array('successMsg' => $successMsg))); } else { $errorMsg = "Cliente não pode ser salvo!"; $this->redirect($this->UrlBuilder()->doAction('cliente', array('adicionar' => true, 'errorMsg' => $clienteDao->getErro(), 'clienteS' => $clienteS))); } } else { if ($idcliente = $clienteDao->salvar()) { if (SessionHandler::checkSession('usuario')) { $successMsg = "Cliente salvo com sucesso!"; $this->redirect($this->UrlBuilder()->doAction('cliente', array('successMsg' => $successMsg))); } $successMsg = "Cliente salvo com sucesso!"; $where = array('id' => $idcliente); $clienteDao = new ClienteDao(); $cliente = $clienteDao->obterCliente($where); if ($cliente instanceof Cliente) { $session = array('senha' => $cliente->getSenha(), 'email' => $cliente->getEmail()); } SessionHandler::createSession('cliente', $session); $this->redirect($this->UrlBuilder()->doAction('index')); } else { if (SessionHandler::checkSession('usuario')) { $errorMsg = "Problemas ao salvar cliente!"; $this->redirect($this->UrlBuilder()->doAction('cliente', array('errorMsg' => $errorMsg))); } $errorMsg = "Cliente não pode ser salvo!"; $this->redirect($this->UrlBuilder()->doAction('index')); } } }