public function confirmaExclusao() { $id = isset($_POST['codigo']) ? $_POST['codigo'] : false; if ($id) { $du = new DaoAluno(); $u = $du->listar($id); if ($du->excluir($u)) { header("location: " . URL . "pagina-inicial"); } else { echo 'Não foi possivel excluir o registro'; } } else { header("location: " . URL . "pagina-inicial"); } }
public static function getInstance() { if (!isset(self::$instance)) { self::$instance = new DaoAluno(); } return self::$instance; }
public function ObterAlunosNovos() { try { $alunos = new DaoAluno(); $lista = $alunos->ListarAlunosNovos(); $alunosNovos = array(); foreach ($lista as $aluno) { $novo['Id'] = $aluno->getId(); $novo['Nome'] = $aluno->getNome() . " " . $aluno->getSobrenome(); $novo['Cpf'] = $aluno->getCpf(); $alunosNovos[] = $novo; } return $alunosNovos; } catch (Exception $e) { self::SetErro("Ocorreu um erro ao tentar executar esta ação: ( " . $e->getMessage() . " [ " . $e->getCode() . " ])"); return array(); } }
public function Inserir($params) { $nome = $params['alnome']; $sobrenome = $params['alsobrenome']; $email = $params['alemail']; $cpf = $params['alcpf']; $rg = $params['alrg']; //$matricula = $params['almatricula']; $dataNascto = $params['aldtnascto']; //**** TAREFA DO PROXY **** $msgErro = ""; if ($nome == "" || strlen($nome) <= 2) { $msgErro .= '- O campo "nome" deve ser preenchido<br/>'; } if ($sobrenome == "" || strlen($sobrenome) <= 2) { $msgErro .= '- O campo "sobrenome" deve ser preenchido<br/>'; } if ($email == "") { $msgErro .= '- O campo "e-mail" deve ser preenchido<br/>'; } else { if (strpos($email, '@') <= 3 || strlen($email) == 0) { $msgErro .= '- Informe um e-mail válido<br/>'; } } if ($cpf != "" && strlen($cpf) != 11) { $msgErro .= '- Informe um CPF válido<br/>'; } //if($matricula == "" || strlen($matricula) < 8){ // $msgErro .= '- Informe uma matrícula válida<br/>'; //} if ($msgErro != "") { //$msgErro = "Verifique os campos obrigatórios: <br/>".$msgErro; self::SetErro($msgErro); return $this->views . "index.php"; } //Registrar como usuário (enviar e-mail, etc...) $usuario = new UsuarioModel(); $usuario->setEmail($email); $usuario->setIdPermissao(3); $usuario->setLogin($nome); $usuario->setSenha(UtilsHelper::CriarSenhaTemporaria($nome)); $daoUsuario = new DaoUsuario(); if (!$daoUsuario->Inserir($usuario)) { self::SetErro(DaoUsuario::GetErro()); } //Fim registro usuário //**** FIM TAREFA DO PROXY **** //TODO Buscar uma maneira de marcar os campos com erro na view (como se pode fazer usando a ViewStade do .Net no Razor) $cpf = (int) $cpf == 0 ? null : $cpf; $rg = (int) $rg == 0 ? null : $rg; $aluno = new AlunoModel(); $aluno->setEmail($email); $aluno->setNome($nome); $aluno->setSobrenome($sobrenome); $aluno->setCpf($cpf); $aluno->setRg($rg); //$aluno->setMatricula($matricula); $aluno->setDataNascimento($dataNascto); $res = $this->repositorio->Inserir($aluno); if (!$res) { $msg = DaoAluno::getInstance()->GetErro(); self::SetErro($msg); } return $this->views . "index.php"; }