commit f480b2942fc0e04da8c5a1a974c21ecdf4def3c2 Author: Daniel Cortés Date: Thu Dec 12 16:05:20 2019 -0300 initial commit diff --git a/alumnos/index.php b/alumnos/index.php new file mode 100644 index 0000000..b04b1b8 --- /dev/null +++ b/alumnos/index.php @@ -0,0 +1,71 @@ + + + + + + Restaurant + + + + + + + +
+

Alumnos

+ + + + + + + + + + + + + + + + + + + +
#RutNombreControles
get_id() ?>get_rut() ?>get_nombre() ?> + Link + Link +
+
+ + + + + diff --git a/alumnos/modificar.php b/alumnos/modificar.php new file mode 100644 index 0000000..e69de29 diff --git a/alumnos/register_post.php b/alumnos/register_post.php new file mode 100644 index 0000000..a7d36ad --- /dev/null +++ b/alumnos/register_post.php @@ -0,0 +1,21 @@ +set_rut($_POST['rut']); +$alumno->set_nombre($_POST['nombre']); + +if($alumno->save()) +{ + header("location: /alumnos/index.php"); +} +?> diff --git a/alumnos/registrar.php b/alumnos/registrar.php new file mode 100644 index 0000000..30a6c2b --- /dev/null +++ b/alumnos/registrar.php @@ -0,0 +1,54 @@ + + + + Restaurant + + + + + + + +
+

Registrar Alumno

+
+
+ + +
+
+ + +
+ +
+
+ + + + + diff --git a/db.php b/db.php new file mode 100644 index 0000000..b161283 --- /dev/null +++ b/db.php @@ -0,0 +1,51 @@ + PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, + PDO::ATTR_EMULATE_PREPARES => false, + ]; + + private $dsn; + + public function __construct() + { + $this->dsn = "mysql:host=".$this->server.";dbname=".$this->db; + } + + public function query($query, ...$params) + { + try + { + $pdo = new PDO($this->dsn, $this->user, $this->pass, $this->options); + $stmt = $pdo->prepare($query); + $stmt->execute($params); + return $stmt->fetchAll(PDO::FETCH_ASSOC); + } + catch(PDOException $e) + { + throw new \PDOException($e->getMessage(), (int)$e->getCode()); + } + } + + public function dml($dml, ...$params) + { + try + { + $pdo = new PDO($this->dsn, $this->user, $this->pass, $this->options); + $stmt = $pdo->prepare($dml); + $stmt->execute($params); + return $stmt->rowCount(); + } + catch(PDOException $e) + { + throw new \PDOException($e->getMessage(), (int)$e->getCode()); + } + } +} +?> diff --git a/index.php b/index.php new file mode 100644 index 0000000..f83ad54 --- /dev/null +++ b/index.php @@ -0,0 +1,40 @@ + + + + Restaurant + + + + + + + + + + + + diff --git a/models/alumno.php b/models/alumno.php new file mode 100644 index 0000000..9750a12 --- /dev/null +++ b/models/alumno.php @@ -0,0 +1,46 @@ +id = $id; } + public function get_id() { return $this->id; } + public function set_rut($rut) { $this->rut = $rut; } + public function get_rut() { return $this->rut; } + public function set_nombre($nombre) { $this->nombre = $nombre; } + public function get_nombre() { return $this->nombre; } + + public function save() + { + + $db = new DB(); + $result = $db->dml + ( + "insert into alumno (rut, nombre) values (?, ?)", + $this->rut, $this->nombre + ); + return $result > 0; + } + + public static function getAll() { + $db = new DB(); + $results = $db->query("select * from alumno"); + + $alumnos = []; + foreach($results as $result) { + $alumno = new Alumno(); + $alumno->set_id($result['id']); + $alumno->set_rut($result['rut']); + $alumno->set_nombre($result['nombre']); + array_push($alumnos, $alumno); + } + return $alumnos; + } + } + ?> diff --git a/models/pedido.php b/models/pedido.php new file mode 100644 index 0000000..e4998c1 --- /dev/null +++ b/models/pedido.php @@ -0,0 +1,38 @@ +id; } + public function get_fecha() { return $this->fecha; } + public function get_estado() { return $this->estado; } + public function get_plato_id() { return $this->plato_id; } + public function get_cliente_id() { return $this->cliente_id; } + public function set_id($id) { $this->id = $id} + public function set_fecha($fecha) { $this->fecha = $fecha; } + public function set_estado($estado) { $this->estado = $estado; } + public function set_plato_id($plato_id) { $this->plato_id = $plato_id; } + public function set_cliente_id($cliente_id) { $this->cliente_id = $cliente_id; } + + public function save() + { + $db = new DB(); + $result = $db->dml + ( + "insert into plato (id, fecha, estado, plato, cliente) values (?, ?, ?, ?, ?)", + $this->id, $this->fecha, $this->estado, $this->plato_id, $this->cliente_id + ); + return $result > 0; + } +} +?> diff --git a/models/plato.php b/models/plato.php new file mode 100644 index 0000000..337ae03 --- /dev/null +++ b/models/plato.php @@ -0,0 +1,35 @@ +id; } + public function set_id($id) { $this->id = $id; } + public function get_nombre() { return $this->nombre; } + public function set_nombre($nombre) { $this->nombre = $nombre; } + public function get_descripcion() { return $this->descripcion; } + public function set_descripcion($descripcion) { $this->descripcion = $descripcion; } + public function get_imagen() { return $this->imagen; } + public function set_imagen($imagen) { $this->imagen = $imagen; } + + public function save() + { + $db = new DB(); + $result = $db->dml + ( + "insert into plato (id, nombre, descripcion, imagen) values (?, ?, ?, ?)", + $this->id, $this->nombre, $this->descripcion, $this->imagen + ); + return $result > 0; + } +} +?> diff --git a/models/reserva.php b/models/reserva.php new file mode 100644 index 0000000..6e808c8 --- /dev/null +++ b/models/reserva.php @@ -0,0 +1,32 @@ +id; } + public function set_id($id) { $this->id = $id; } + public function get_fecha() { return $this->fecha; } + public function set_fecha($fecha) { $this->fecha = $fecha; } + public function get_cliente_id() { return $this->cliente_id; } + public function set_cliente_id($cliente_id) { $this->cliente_id = $cliente_id; } + + public function save() + { + $db = new DB(); + $result = $db->dml + ( + "insert into reserva (id, fecha, cliente) values (?, ?, ?)", + $this->id, $this->fecha, $this->cliente_id + ); + return $result > 0; + } +} +?> diff --git a/rut_validacion.php b/rut_validacion.php new file mode 100644 index 0000000..8286126 --- /dev/null +++ b/rut_validacion.php @@ -0,0 +1,21 @@ + diff --git a/sql/database.sql b/sql/database.sql new file mode 100644 index 0000000..7ea1c87 --- /dev/null +++ b/sql/database.sql @@ -0,0 +1,32 @@ +drop database if exists alumnos; +create database alumnos; + +use alumnos; + +create table alumno ( + id int primary key auto_increment, + rut varchar(255) not null, + nombre varchar(255) not null +); + +create table asignatura ( + id int primary key auto_increment, + nombre varchar(255) not null +); + +create table alumno_asignatura ( + id int primary key auto_increment, + alumno_id int not null, + asignatura_id int not null, + foreign key (alumno_id) references alumno (id), + foreign key (asignatura_id) references asignatura (id) +); + +create table nota ( + id int primary key auto_increment, + puntaje_total int not null default 0, + puntaje_obtenido int not null default 0, + exigencia int not null default 50, + alumno_asignatura_id int not null, + foreign key (alumno_asignatura_id) references alumno_asignatura (id) +); diff --git a/style.css b/style.css new file mode 100644 index 0000000..cf7a324 --- /dev/null +++ b/style.css @@ -0,0 +1,3 @@ +.navbar { + margin-bottom: 1em; +}