zi
This commit is contained in:
5
alumnos/delete_post.php
Normal file
5
alumnos/delete_post.php
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
require_once('../models/alumno.php');
|
||||||
|
Alumno::delete($_POST['id']);
|
||||||
|
header("location: /alumnos/index.php");
|
||||||
|
?>
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
<?php include("../includes/_config.php")?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
require_once('../models/alumno.php');
|
require_once('../models/alumno.php');
|
||||||
$alumnos = Alumno::getAll();
|
$alumnos = Alumno::getAll();
|
||||||
@@ -6,47 +8,27 @@ $alumnos = Alumno::getAll();
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Restaurant</title>
|
<?php include("../includes/_head.php")?>
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
||||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.0/css/bootstrap.min.css" integrity="sha384-SI27wrMjH3ZZ89r4o+fGIJtnzkAnFs3E4qz9DIYioCQ5l9Rd/7UAa8DHcaL8jkWt" crossorigin="anonymous">
|
|
||||||
<link rel="stylesheet" href="/style.css">
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
|
<?php include("../includes/_navbar.php")?>
|
||||||
<a class="navbar-brand" href="/">Alumnos</a>
|
<div class="container main">
|
||||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
<div class="row align-items-center">
|
||||||
<span class="navbar-toggler-icon"></span>
|
<div class="col-10">
|
||||||
</button>
|
|
||||||
<div class="collapse navbar-collapse" id="navbarNav">
|
|
||||||
<ul class="navbar-nav">
|
|
||||||
<li class="nav-item dropdown active">
|
|
||||||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
|
||||||
Alumnos
|
|
||||||
</a>
|
|
||||||
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
|
||||||
<a class="dropdown-item" href="/alumnos/index.php">Lista</a>
|
|
||||||
<a class="dropdown-item" href="/alumnos/registrar.php">Crear</a>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="#">Asignatura</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="#">Notas</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
<div class="container">
|
|
||||||
<p class="display-1">Alumnos</p>
|
<p class="display-1">Alumnos</p>
|
||||||
<table class="table">
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<a class="btn btn-success btn-block" href="/alumnos/registrar.php">Crear</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<table class="table table-bordered">
|
||||||
<thead class="thead-dark">
|
<thead class="thead-dark">
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">#</th>
|
<th scope="col">#</th>
|
||||||
<th scope="col">Rut</th>
|
<th scope="col">Rut</th>
|
||||||
<th scope="col">Nombre</th>
|
<th scope="col">Nombre</th>
|
||||||
<th scope="col">Controles</th>
|
<th scope="col" class="control-cell"></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -55,17 +37,19 @@ $alumnos = Alumno::getAll();
|
|||||||
<th scope="row"><?php echo $alumno->get_id() ?></th>
|
<th scope="row"><?php echo $alumno->get_id() ?></th>
|
||||||
<td><?php echo $alumno->get_rut() ?></td>
|
<td><?php echo $alumno->get_rut() ?></td>
|
||||||
<td><?php echo $alumno->get_nombre() ?></td>
|
<td><?php echo $alumno->get_nombre() ?></td>
|
||||||
<td>
|
<td class="control-cell">
|
||||||
<a class="btn btn-primary" href="#" role="button">Link</a>
|
<form class="form-inline" action="delete_post.php" method="post">
|
||||||
<a class="btn btn-primary" href="#" role="button">Link</a>
|
<a class="btn btn-primary btn-fix-width" href="/alumnos/modificar.php?id=<?php echo $alumno->get_id()?>" role="button">Modificar</a>
|
||||||
|
<input type="hidden" class="form-control" id="id" name="id" value="<?php echo $alumno->get_id()?>">
|
||||||
|
<button type="submit" class="btn btn-danger btn-fix-width">Eliminar</button>
|
||||||
|
</form>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php }?>
|
<?php }?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
|
</div>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
|
<?php include("../includes/_scripts.php")?>
|
||||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.0/js/bootstrap.min.js" integrity="sha384-3qaqj0lc6sV/qpzrc1N5DC6i1VRn/HyX4qdPaiEFbn54VjQBEU341pvjz7Dv3n6P" crossorigin="anonymous"></script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php include("../includes/_config.php")?>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
require_once("../models/alumno.php");
|
||||||
|
$alumno = Alumno::get($_GET["id"]);
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<?php include("../includes/_head.php") ?>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<?php include("../includes/_navbar.php") ?>
|
||||||
|
<div class="container main">
|
||||||
|
<p class="display-1">Modificar Alumno</p>
|
||||||
|
<form action="modificar_post.php" method="post">
|
||||||
|
<input type="hidden" class="form-control" id="id" name="id" value="<?php echo $alumno->get_id() ?>">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="rut">Rut</label>
|
||||||
|
<input type="text" class="form-control" id="rut" name="rut" value="<?php echo $alumno->get_rut() ?>">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="nombre">Nombre</label>
|
||||||
|
<input type="text" class="form-control" id="nombre" name="nombre" value="<?php echo $alumno->get_nombre() ?>">
|
||||||
|
</div>
|
||||||
|
<input type="submit" class="btn btn-primary" value="Modificar">
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<?php include("../includes/_scripts.php")?>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|||||||
28
alumnos/modificar_post.php
Normal file
28
alumnos/modificar_post.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
require_once('../models/alumno.php');
|
||||||
|
require_once('../rut_validacion.php');
|
||||||
|
|
||||||
|
$id = $_POST['id'];
|
||||||
|
$rut = $_POST['rut'];
|
||||||
|
$nombre = $_POST['nombre'];
|
||||||
|
|
||||||
|
if(!validar_rut($rut))
|
||||||
|
{
|
||||||
|
header("location: /alumnos/modificar.php?id=$id");
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$alumno = new Alumno();
|
||||||
|
$alumno->set_id($id);
|
||||||
|
$alumno->set_rut($rut);
|
||||||
|
$alumno->set_nombre($nombre);
|
||||||
|
|
||||||
|
if($alumno->update())
|
||||||
|
{
|
||||||
|
header("location: /alumnos/index.php");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
header("location: /alumnos/modificar.php?id=$id");
|
||||||
|
}
|
||||||
|
?>
|
||||||
@@ -3,10 +3,10 @@ require_once('../models/alumno.php');
|
|||||||
require_once('../rut_validacion.php');
|
require_once('../rut_validacion.php');
|
||||||
|
|
||||||
$rut = $_POST['rut'];
|
$rut = $_POST['rut'];
|
||||||
|
$nombre = $_POST['nombre'];
|
||||||
|
|
||||||
if(!validar_rut($rut)){
|
if(!validar_rut($rut)){
|
||||||
echo "ERROR";
|
|
||||||
header("location: /alumnos/registrar.php");
|
header("location: /alumnos/registrar.php");
|
||||||
var_dump("OH NO");
|
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -14,8 +14,5 @@ $alumno = new Alumno();
|
|||||||
$alumno->set_rut($_POST['rut']);
|
$alumno->set_rut($_POST['rut']);
|
||||||
$alumno->set_nombre($_POST['nombre']);
|
$alumno->set_nombre($_POST['nombre']);
|
||||||
|
|
||||||
if($alumno->save())
|
if($alumno->save()) header("location: /alumnos/index.php");
|
||||||
{
|
|
||||||
header("location: /alumnos/index.php");
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -1,39 +1,13 @@
|
|||||||
|
<?php include("../includes/_config.php")?>
|
||||||
|
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Restaurant</title>
|
<?php include("../includes/_head.php")?>
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
||||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.0/css/bootstrap.min.css" integrity="sha384-SI27wrMjH3ZZ89r4o+fGIJtnzkAnFs3E4qz9DIYioCQ5l9Rd/7UAa8DHcaL8jkWt" crossorigin="anonymous">
|
|
||||||
<link rel="stylesheet" href="/style.css">
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
|
<?php include("../includes/_navbar.php")?>
|
||||||
<a class="navbar-brand" href="/">Universidad</a>
|
<div class="container main">
|
||||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
|
||||||
<span class="navbar-toggler-icon"></span>
|
|
||||||
</button>
|
|
||||||
<div class="collapse navbar-collapse" id="navbarNav">
|
|
||||||
<ul class="navbar-nav">
|
|
||||||
<li class="nav-item dropdown active">
|
|
||||||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
|
||||||
Alumnos
|
|
||||||
</a>
|
|
||||||
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
|
||||||
<a class="dropdown-item" href="/clientes/index.php">Lista</a>
|
|
||||||
<a class="dropdown-item" href="/clientes/registrar.php">Crear</a>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="#">Asignaturas</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="#">Notas</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
<div class="container">
|
|
||||||
<p class="display-1">Registrar Alumno</p>
|
<p class="display-1">Registrar Alumno</p>
|
||||||
<form action="register_post.php" method="post">
|
<form action="register_post.php" method="post">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@@ -47,8 +21,5 @@
|
|||||||
<input type="submit" class="btn btn-primary" value="Enviar">
|
<input type="submit" class="btn btn-primary" value="Enviar">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
|
<?php include("../includes/_scripts.php")?></body>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
|
|
||||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.0/js/bootstrap.min.js" integrity="sha384-3qaqj0lc6sV/qpzrc1N5DC6i1VRn/HyX4qdPaiEFbn54VjQBEU341pvjz7Dv3n6P" crossorigin="anonymous"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
31
includes/_config.php
Normal file
31
includes/_config.php
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
error_log("script_name: " . $_SERVER["SCRIPT_NAME"]);
|
||||||
|
|
||||||
|
switch ($_SERVER["SCRIPT_NAME"]) {
|
||||||
|
case "/index.php":
|
||||||
|
$CURRENT_PAGE = "index";
|
||||||
|
$SECTION = "index";
|
||||||
|
$PAGE_TITLE = "Index";
|
||||||
|
break;
|
||||||
|
case "/alumnos/index.php":
|
||||||
|
$CURRENT_PAGE = "alumno_index";
|
||||||
|
$SECTION = "alumno";
|
||||||
|
$PAGE_TITLE = "Alumos";
|
||||||
|
break;
|
||||||
|
case "/alumnos/registrar.php":
|
||||||
|
$CURRENT_PAGE = "alumnos_registrar";
|
||||||
|
$SECTION = "alumno";
|
||||||
|
$PAGE_TITLE = "Registrar Alumno";
|
||||||
|
break;
|
||||||
|
case "/alumnos/modificar.php":
|
||||||
|
$CURRENT_PAGE = "alumnos_modificar";
|
||||||
|
$SECTION = "alumno";
|
||||||
|
$PAGE_TITLE = "Modificar Alumno";
|
||||||
|
}
|
||||||
|
|
||||||
|
error_log("PAGE_TITLE: ".$PAGE_TITLE);
|
||||||
|
error_log("CURRENT_PAGE: ".$CURRENT_PAGE);
|
||||||
|
error_log("SECTION: ".$SECTION);
|
||||||
|
?>
|
||||||
5
includes/_head.php
Normal file
5
includes/_head.php
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<title>Universidad - <?php echo $PAGE_TITLE ?></title>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.0/css/bootstrap.min.css" integrity="sha384-SI27wrMjH3ZZ89r4o+fGIJtnzkAnFs3E4qz9DIYioCQ5l9Rd/7UAa8DHcaL8jkWt" crossorigin="anonymous">
|
||||||
|
<link rel="stylesheet" href="/style.css">
|
||||||
16
includes/_navbar.php
Normal file
16
includes/_navbar.php
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<nav class="navbar navbar-expand fixed-top navbar-dark bg-primary">
|
||||||
|
<ul class="navbar-nav">
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link <?php if($SECTION === "index") echo "active" ?>" href="/index.php">Universidad</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link <?php if($SECTION === "alumno") echo "active" ?>" href="/alumnos/index.php">Alumnos</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link <?php if($SECTION === "asignatura") echo "active" ?>" href="#">Asignatura</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link <?php if($SECTION === "notas") echo "active" ?>" href="#">Notas</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
3
includes/_scripts.php
Normal file
3
includes/_scripts.php
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
|
||||||
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.0/js/bootstrap.min.js" integrity="sha384-3qaqj0lc6sV/qpzrc1N5DC6i1VRn/HyX4qdPaiEFbn54VjQBEU341pvjz7Dv3n6P" crossorigin="anonymous"></script>
|
||||||
38
index.php
38
index.php
@@ -1,40 +1,12 @@
|
|||||||
|
<?php include("includes/_config.php")?>
|
||||||
|
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Restaurant</title>
|
<?php include("includes/_head.php")?>
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
||||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.0/css/bootstrap.min.css" integrity="sha384-SI27wrMjH3ZZ89r4o+fGIJtnzkAnFs3E4qz9DIYioCQ5l9Rd/7UAa8DHcaL8jkWt" crossorigin="anonymous">
|
|
||||||
<link rel="stylesheet" href="/style.css">
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
|
<?php include("includes/_navbar.php")?>
|
||||||
<a class="navbar-brand active" href="/">Universidad</a>
|
<?php include("includes/_scripts.php")?>
|
||||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
|
||||||
<span class="navbar-toggler-icon"></span>
|
|
||||||
</button>
|
|
||||||
<div class="collapse navbar-collapse" id="navbarNav">
|
|
||||||
<ul class="navbar-nav">
|
|
||||||
<li class="nav-item dropdown">
|
|
||||||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
|
||||||
Alumnos
|
|
||||||
</a>
|
|
||||||
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
|
||||||
<a class="dropdown-item" href="/alumnos/index.php">Lista</a>
|
|
||||||
<a class="dropdown-item" href="/alumnos/registrar.php">Crear</a>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="#">Asignatura</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" href="#">Notas</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
|
|
||||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.0/js/bootstrap.min.js" integrity="sha384-3qaqj0lc6sV/qpzrc1N5DC6i1VRn/HyX4qdPaiEFbn54VjQBEU341pvjz7Dv3n6P" crossorigin="anonymous"></script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -28,6 +28,37 @@ class Alumno
|
|||||||
return $result > 0;
|
return $result > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function update()
|
||||||
|
{
|
||||||
|
$db = new DB();
|
||||||
|
$result = $db->dml(
|
||||||
|
"update alumno set rut = ?, nombre = ? where id = ?",
|
||||||
|
$this->rut, $this->nombre, $this->id
|
||||||
|
);
|
||||||
|
return $result > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function delete($id) {
|
||||||
|
$db = new DB();
|
||||||
|
error_log("id: $id");
|
||||||
|
$result = $db->dml("delete from alumno where id = ?", $id);
|
||||||
|
return $result > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function get($id) {
|
||||||
|
$db = new DB();
|
||||||
|
$results = $db->query("select * from alumno where id = ?", $id);
|
||||||
|
|
||||||
|
foreach($results as $result) {
|
||||||
|
$alumno = new Alumno();
|
||||||
|
$alumno->set_id($result['id']);
|
||||||
|
$alumno->set_rut($result['rut']);
|
||||||
|
$alumno->set_nombre($result['nombre']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $alumno;
|
||||||
|
}
|
||||||
|
|
||||||
public static function getAll() {
|
public static function getAll() {
|
||||||
$db = new DB();
|
$db = new DB();
|
||||||
$results = $db->query("select * from alumno");
|
$results = $db->query("select * from alumno");
|
||||||
|
|||||||
@@ -14,8 +14,9 @@ function validar_rut($rut){
|
|||||||
}
|
}
|
||||||
$digito_verificador_calculado = 11 - ($suma % 11);
|
$digito_verificador_calculado = 11 - ($suma % 11);
|
||||||
|
|
||||||
if($digito_verificador_calculado == 11) $dvr = 0;
|
if($digito_verificador_calculado == 11) $digito_verificador_calculado = 0;
|
||||||
if($digito_verificador_calculado == 10) $digito_verificador_calculado = 'K';
|
if($digito_verificador_calculado == 10) $digito_verificador_calculado = 'K';
|
||||||
|
error_log("Rut: " . $rut . " Deberia tener digito verificador " . $digito_verificador_calculado);
|
||||||
return $digito_verificador_calculado == strtoupper($digito_verificador);
|
return $digito_verificador_calculado == strtoupper($digito_verificador);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user