public function cadastraCliente($nome, $email, $foto, $idPlano, $valor) { $_POST['cliente']['nome'] = $nome; $_POST['cliente']['email'] = $email; $_POST['cliente']['foto'] = $foto; $_POST['cliente']['ativo'] = 's'; $_POST['cliente']['dataCadastro'] = DATAHORAMYSQL; $novaSenha = Cliente::getNovaSenha(); $_POST['cliente']['senha'] = md5($novaSenha); //MOVER FOTO DE PASTA if (file_exists(PATHUPLOAD . 'pre-cliente/' . $foto)) { $origem = PATHUPLOAD . 'pre-cliente/' . $foto; $destino = PATHUPLOAD . 'cliente/' . $foto; copy($origem, $destino); unlink($origem); } //CADASTRA CLIENTE $objCliente = new Cliente($_POST['cliente']); if ($objCliente->inserir()) { //GERAO PEDIDO DA COMPRA DO PLANO ESCOLHIDO Pedido::cadastrarPedido($objCliente->id, $valor, $idPlano, 1); //CADASTRA PLANO ESCOLHIDO Planos::cadastrarClientePlano($objCliente->id, $idPlano, $valor); //ENVIA E-MAIL PARA CLIENTE INFORMANDO LOGIN E SENHA COM LINK DE ACESSO $objPlanos = new Planos(); $objPlanos->id = $idPlano; $objPlanos->carregar(); $_POST['email']['nome'] = $objCliente->nome; $_POST['email']['email'] = $objCliente->email; $_POST['email']['senha'] = $novaSenha; $_POST['email']['plano'] = $objPlanos->titulo; $_POST['email']['valor'] = $valor; $_POST['email']['linkAcesso'] = URLRAIZ . '/painel/login.php'; $_POST['email']['topo'] = Email::topoEmail(); $_POST['email']['rodape'] = Email::rodapeEmail(); Email::enviar($objCliente->email, 'Acesso para finalizar compra', 'cliente-login-acesso.html', $_POST['email']); } }
public function recuperarSenha($email) { $msg = array(); $idCliente = Cliente::buscaPorEmail($email); if (!$idCliente) { $msg[] = "E-mail não cadastrado"; } else { $novaSenha = Cliente::getNovaSenha(); $objCliente = new Cliente(); $objCliente->id = $idCliente; $objCliente->carregar(); $objCliente->senha = md5($novaSenha); if ($objCliente->alterar()) { $_POST['senha']['nome'] = $objCliente->nome; $_POST['senha']['email'] = $objCliente->email; $_POST['senha']['novaSenha'] = $novaSenha; $_POST['senha']['linkAcesso'] = URLRAIZ . '/painel/login.php'; $_POST['senha']['topo'] = Email::topoEmail(); $_POST['senha']['rodape'] = Email::rodapeEmail(); Email::enviar($objCliente->email, 'Recuperação de senha', 'esqueci-senha.html', $_POST['senha']); $msg[] = "Nova senha foi enviada por e-mail"; } } return $msg; }