Add files via upload
This commit is contained in:
parent
62d0602d70
commit
fa4769d77b
@ -397,7 +397,7 @@
|
||||
margin: 0 auto;
|
||||
display: flex;
|
||||
}
|
||||
.promotions img {
|
||||
.promotions a {
|
||||
width: 100%;
|
||||
height: 150px;
|
||||
display: block;
|
||||
|
@ -1,3 +1,3 @@
|
||||
function cambiarCSS(nuevo){
|
||||
document.getElementById('estilo').setAttribute('href', nuevo);
|
||||
document.getElementById('estilo').setAttribute('href', nuevo);
|
||||
}
|
131
assets/js/checkForms.js
Normal file
131
assets/js/checkForms.js
Normal file
@ -0,0 +1,131 @@
|
||||
/**
|
||||
* Práctica - Sistemas Web | Grupo D
|
||||
* CompluCine - FDI-cines
|
||||
*/
|
||||
|
||||
//Expresión regular para comprobar que la contraseña tiene al menos 1 mayúscula y 1 número:
|
||||
const regExprPass = /^(?=\w*\d)(?=\w*[A-Z])(?=\w*[a-z])\S{4,16}$/;
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
//Iconos para validar el usuario:
|
||||
$("#userValid").hide();
|
||||
$("#userInvalid").hide();
|
||||
$("#userWarning").hide();
|
||||
|
||||
//Iconos para validar el email:
|
||||
$("#emailValid").hide();
|
||||
$("#emailInvalid").hide();
|
||||
|
||||
//Iconos para validar el password:
|
||||
$("#passValid").hide();
|
||||
$("#passInvalid").hide();
|
||||
$("#passWarning").hide();
|
||||
|
||||
//Comprueba que el nombre de usuario introducido para el login, exista.
|
||||
$("#name").change(function(){
|
||||
var url = "../assets/php/common/checkUser.php?user=" + $("#name").val();
|
||||
$.get(url, userLoginCheck);
|
||||
});
|
||||
|
||||
//Comprueba que el nombre de usuario no esté registrado en la aplicación.
|
||||
$("#new_name").change(function(){
|
||||
var url = "../assets/php/common/checkUser.php?user=" + $("#new_name").val();
|
||||
$.get(url, userCheck);
|
||||
});
|
||||
|
||||
//Comprueba que el email introducido no esté registrado en la aplicación.
|
||||
$("#new_email").change(function(){
|
||||
var url = "../assets/php/common/checkEmail.php?email=" + $("#new_email").val();
|
||||
$.get(url, emailCheck);
|
||||
});
|
||||
|
||||
//Comprueba que la contraseña sea válida en base a los criterios de la aplicación.
|
||||
$("#new_pass").change(function(){
|
||||
const fieldPass = $("#new_pass");
|
||||
fieldPass[0].setCustomValidity("");
|
||||
const isPassValid = fieldPass[0].checkValidity();
|
||||
|
||||
if(fieldPass.val().length < 4){
|
||||
$("#passValid").hide();
|
||||
$("#passInvalid").hide();
|
||||
$("#passWarning").show();
|
||||
fieldPass[0].setCustomValidity("La contraseña debe contener almenos 4 caracteres.");
|
||||
}
|
||||
else if (isPassValid && passCheck(fieldPass.val())) {
|
||||
$("#passValid").show();
|
||||
$("#passInvalid").hide();
|
||||
$("#passWarning").hide();
|
||||
fieldPass[0].setCustomValidity("");
|
||||
} else {
|
||||
$("#passValid").hide();
|
||||
$("#passInvalid").show();
|
||||
$("#passWarning").hide();
|
||||
fieldPass[0].setCustomValidity("La contraseña debe contener al menos 1 mayúscula y 1 número.");
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
//Muestra si el nombre de usuario introducido para el login existe o no.
|
||||
function userLoginCheck(data, status) {
|
||||
const fieldLogin = $("#name");
|
||||
fieldLogin[0].setCustomValidity("");
|
||||
|
||||
if(data === "!avaliable") {
|
||||
fieldLogin[0].setCustomValidity("");
|
||||
} else {
|
||||
fieldLogin[0].setCustomValidity("El nombre de usuario no está registrado.");
|
||||
}
|
||||
}
|
||||
|
||||
//Muestra si el nombre de usuario introducido es válido o no.
|
||||
function userCheck(data, status) {
|
||||
const fieldUser = $("#new_name");
|
||||
fieldUser[0].setCustomValidity("");
|
||||
|
||||
if(fieldUser.val().length < 3){
|
||||
$("#userValid").hide();
|
||||
$("#userInvalid").hide();
|
||||
$("#userWarning").show();
|
||||
fieldUser[0].setCustomValidity("El nombre de usuario debe tener almenos 3 caracteres.");
|
||||
}
|
||||
else if(data === "avaliable") {
|
||||
$("#userValid").show();
|
||||
$("#userInvalid").hide();
|
||||
$("#userWarning").hide();
|
||||
fieldUser[0].setCustomValidity("");
|
||||
} else {
|
||||
$("#userValid").hide();
|
||||
$("#userInvalid").show();
|
||||
$("#userWarning").hide();
|
||||
fieldUser[0].setCustomValidity("El nombre de usuario ya está registrado.");
|
||||
}
|
||||
}
|
||||
|
||||
//Muestra si el email introducido es válido o no.
|
||||
function emailCheck(data, status) {
|
||||
const fieldEmail = $("#new_email");
|
||||
fieldEmail[0].setCustomValidity("");
|
||||
const isEmailValid = fieldEmail[0].checkValidity();
|
||||
|
||||
if(!isEmailValid){
|
||||
$("#emailValid").hide();
|
||||
$("#emailInvalid").show();
|
||||
}
|
||||
else if (data === "avaliable") {
|
||||
$("#emailValid").show();
|
||||
$("#emailInvalid").hide();
|
||||
fieldEmail[0].setCustomValidity("");
|
||||
} else {
|
||||
$("#emailValid").hide();
|
||||
$("#emailInvalid").show();
|
||||
fieldEmail[0].setCustomValidity("El email ya está registrado.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Devuelve true si la contraseña cumple los reuqisitos de seguridad, false en caso contrario.
|
||||
function passCheck(pass) {
|
||||
return regExprPass.test(pass) ? true : false;
|
||||
}
|
||||
})
|
4
assets/js/jquery-3.2.1.min.js
vendored
Normal file
4
assets/js/jquery-3.2.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
15
assets/php/common/checkEmail.php
Normal file
15
assets/php/common/checkEmail.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
include('../../../assets/php/config.php');
|
||||
include('../includes/user_dao.php');
|
||||
|
||||
$bd = new UserDAO('complucine');
|
||||
if($bd){
|
||||
$user = $bd->selectUserEmail(strtolower($_GET["email"]));
|
||||
if ($user->data_seek(0)) {
|
||||
echo "!avaliable";
|
||||
}
|
||||
else{
|
||||
echo "avaliable";
|
||||
}
|
||||
}
|
||||
?>
|
15
assets/php/common/checkUser.php
Normal file
15
assets/php/common/checkUser.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
include('../../../assets/php/config.php');
|
||||
include('../includes/user_dao.php');
|
||||
|
||||
$bd = new UserDAO('complucine');
|
||||
if($bd){
|
||||
$user = $bd->selectUserName(strtolower($_GET["user"]));
|
||||
if ($user->data_seek(0)) {
|
||||
echo "!avaliable";
|
||||
}
|
||||
else{
|
||||
echo "avaliable";
|
||||
}
|
||||
}
|
||||
?>
|
@ -100,6 +100,7 @@ abstract class Form {
|
||||
$this->enctype = $opciones['enctype'];
|
||||
|
||||
if ( !$this->action ) {
|
||||
// Cambiar por << $this->action = htmlentities($_SERVER['REQUEST_URI']); >> para mantener los parámetros de la URL.
|
||||
$this->action = htmlentities($_SERVER['PHP_SELF']);
|
||||
}
|
||||
}
|
||||
|
32
assets/php/includes/cinema.php
Normal file
32
assets/php/includes/cinema.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
class Cinema{
|
||||
|
||||
//Attributes:
|
||||
private $_id; //Cinema ID.
|
||||
private $_name; //Cinema name.
|
||||
private $_direction; //Cinema direction.
|
||||
private $_phone; //Cinema phone.
|
||||
|
||||
|
||||
//Constructor:
|
||||
function __construct($id, $name, $direction, $phone){
|
||||
$this->_id = $id;
|
||||
$this->_name = $name;
|
||||
$this->_direction = $direction;
|
||||
$this->_phone = $phone;
|
||||
}
|
||||
|
||||
//Methods:
|
||||
|
||||
//Getters && Setters:
|
||||
public function setId($id){ $this->_id = $id; }
|
||||
public function getId(){ return $this->_id; }
|
||||
public function setName($name){ $this->_name = $name; }
|
||||
public function getName(){ return $this->_name; }
|
||||
public function setDirection($direction){ $this->_direction = $direction; }
|
||||
public function getDirection(){ return $this->_direction; }
|
||||
public function setPhone($phone){$this->_phone = $phone; }
|
||||
public function getPhone(){ return $this->_phone; }
|
||||
}
|
||||
?>
|
77
assets/php/includes/cinema_dao.php
Normal file
77
assets/php/includes/cinema_dao.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
include_once('cinema.php');
|
||||
|
||||
class Cinema_DAO extends DAO {
|
||||
|
||||
//Constructor:
|
||||
function __construct($bd_name){
|
||||
parent::__construct($bd_name);
|
||||
}
|
||||
|
||||
//Methods:
|
||||
|
||||
//Create a new Session.
|
||||
public function createCinema($id, $name, $direction, $phone){
|
||||
$sql = sprintf( "INSERT INTO `cinema`( `id`, `name`, `direction`, `phone`)
|
||||
VALUES ( '%d', '%s', '%s', '%s')",
|
||||
$id, $name, $direction, $phone);
|
||||
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
return $resul;
|
||||
}
|
||||
|
||||
|
||||
//Returns a query to get All the films.
|
||||
public function allCinemaData(){
|
||||
$sql = sprintf( "SELECT * FROM cinema ");
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
while($fila=$resul->fetch_assoc()){
|
||||
$films[] = $this->loadCinema($fila["id"], $fila["name"], $fila["direction"], $fila["phone"]);
|
||||
}
|
||||
$resul->free();
|
||||
return $films;
|
||||
}
|
||||
|
||||
//Returns a film data .
|
||||
public function GetCinema($name,$direction){
|
||||
$sql = sprintf( "SELECT * FROM cinema WHERE cinema.name = '%s'AND cinema.direction='%s'", $name,$direction );
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
return $resul;
|
||||
}
|
||||
|
||||
//Returns a film data .
|
||||
public function cinemaData($id){
|
||||
$sql = sprintf( "SELECT * FROM cinema WHERE cinema.id = '%d'", $id);
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
return $resul;
|
||||
}
|
||||
|
||||
//Deleted film by "id".
|
||||
public function deleteCinema($id){
|
||||
$sql = sprintf( "DELETE FROM cinema WHERE cinema.id = '%d' ;",$id);
|
||||
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
return $resul;
|
||||
}
|
||||
|
||||
//Edit a film.
|
||||
public function editCinema($id, $name, $direction, $phone){
|
||||
$sql = sprintf( "UPDATE cinema SET name = '%s' , direction = '%s', phone ='%s'
|
||||
WHERE cinema.id = '%d';",
|
||||
$name, $direction, $phone, $id);
|
||||
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
return $resul;
|
||||
}
|
||||
|
||||
//Create a new film Data Transfer Object.
|
||||
public function loadCinema($id, $name, $direction, $phone){
|
||||
return new Cinema($id, $name, $direction, $phone);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
39
assets/php/includes/film.php
Normal file
39
assets/php/includes/film.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
class Film{
|
||||
|
||||
//Attributes:
|
||||
private $_id; //Film ID.
|
||||
private $_tittle; //Film tittle.
|
||||
private $_duration; //Film duration.
|
||||
private $_language; //Film language.
|
||||
private $_description; //Film description.
|
||||
private $_img;
|
||||
|
||||
//Constructor:
|
||||
function __construct($id, $tittle, $duration, $language, $description, $img){
|
||||
$this->_id = $id;
|
||||
$this->_tittle = $tittle;
|
||||
$this->_duration = $duration;
|
||||
$this->_language = $language;
|
||||
$this->_description = $description;
|
||||
$this->_img = $img;
|
||||
}
|
||||
|
||||
//Methods:
|
||||
|
||||
//Getters && Setters:
|
||||
public function setId($id){ $this->_id = $id; }
|
||||
public function getId(){ return $this->_id; }
|
||||
public function setTittle($tittle) {$this->_tittle = $tittle; }
|
||||
public function getTittle(){return $this->_tittle;}
|
||||
public function setDuration($duration){$this->_duration = $duration; }
|
||||
public function getDuration() {return $this->_duration;}
|
||||
public function setLanguage($language) {$this->_language = $language; }
|
||||
public function getLanguage(){return $this->_language;}
|
||||
public function setDescription($description){ $this->_description = $description;}
|
||||
public function getDescription(){return $this->_description;}
|
||||
public function setImg($img){ $this->_img = $img;}
|
||||
public function getImg(){return $this->_img;}
|
||||
}
|
||||
?>
|
100
assets/php/includes/film_dao.php
Normal file
100
assets/php/includes/film_dao.php
Normal file
@ -0,0 +1,100 @@
|
||||
<?php
|
||||
include_once('film.php');
|
||||
|
||||
class Film_DAO extends DAO {
|
||||
|
||||
//Constructor:
|
||||
function __construct($bd_name){
|
||||
parent::__construct($bd_name);
|
||||
}
|
||||
|
||||
//Methods:
|
||||
|
||||
//Create a new Session.
|
||||
public function createFilm($id, $tittle, $duration, $language, $description, $img){
|
||||
$sql = sprintf( "INSERT INTO `film`( `id`, `tittle`, `duration`, `language`,`description`, `img`)
|
||||
VALUES ( '%d', '%s', '%d', '%s','%s', '%s')",
|
||||
$id, $tittle, $duration, $language, $description, $img);
|
||||
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
return $resul;
|
||||
}
|
||||
//Returns a film data .
|
||||
public function GetFilm($tittle,$language){
|
||||
$sql = sprintf( "SELECT * FROM film WHERE film.tittle = '%s'AND film.language='%s'", $tittle,$language );
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
return $resul;
|
||||
}
|
||||
|
||||
//Returns a query to get the film's data.
|
||||
public function FilmData($id){
|
||||
$sql = sprintf( "SELECT * FROM film WHERE id = '%d'", $id );
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
return $resul;
|
||||
}
|
||||
|
||||
//Returns a query to get All the films.
|
||||
public function allFilmData(){
|
||||
$sql = sprintf( "SELECT * FROM film ");
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
while($fila=$resul->fetch_assoc()){
|
||||
$films[] = $this->loadFilm($fila["id"], $fila["tittle"], $fila["duration"], $fila["language"], $fila["description"], $fila["img"]);
|
||||
}
|
||||
$resul->free();
|
||||
return $films;
|
||||
}
|
||||
|
||||
|
||||
//Returns a query to get all films tittles.
|
||||
public function tittleFilmData(){
|
||||
$sql = sprintf( "SELECT DISTINCT tittle FROM film ");
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
return $resul;
|
||||
}
|
||||
|
||||
//Returns a query to get all films descriptions.
|
||||
public function descriptionFilmData(){
|
||||
$sql = sprintf( "SELECT description FROM film ");
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
return $resul;
|
||||
}
|
||||
|
||||
/*
|
||||
public function addFilm($films) {
|
||||
$resul = mysqli_query($this->mysqli, $this->createFilm($film.getId(), $film.getTittle(), $film.getDuration(), $film.getLanguage(), $film.getDescription())) or die ('Error into query database');
|
||||
return $resul;
|
||||
}
|
||||
*/
|
||||
|
||||
//Deleted film by "id".
|
||||
public function deleteFilm($id){
|
||||
$sql = sprintf( "DELETE FROM film WHERE film.id = '%d' ;",$id);
|
||||
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
return $resul;
|
||||
}
|
||||
|
||||
//Edit a film.
|
||||
public function editFilm($id, $tittle, $duration, $language,$description,$img){
|
||||
$sql = sprintf( "UPDATE film SET tittle = '%s' , duration = '%d', language ='%s' , description ='%s', img ='%s'
|
||||
WHERE film.id = '%d';",
|
||||
$tittle, $duration, $language, $description, $img, $id);
|
||||
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
return $resul;
|
||||
}
|
||||
|
||||
//Create a new film Data Transfer Object.
|
||||
public function loadFilm($id, $tittle, $duration, $language,$description, $img){
|
||||
return new Film( $id, $tittle, $duration, $language,$description, $img);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
103
assets/php/includes/hall.php
Normal file
103
assets/php/includes/hall.php
Normal file
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
include_once($prefix.'assets/php/includes/hall_dao.php');
|
||||
include_once('seat_dao.php');
|
||||
|
||||
class Hall{
|
||||
|
||||
//Attributes:
|
||||
private $_number; //Room number.
|
||||
private $_idcinema; //Cinema Id
|
||||
private $_numRows; //Num rows.
|
||||
private $_numCol; //Num columns.
|
||||
private $_total_seats;
|
||||
private $_seats_map;
|
||||
|
||||
//Constructor:
|
||||
function __construct($number, $idcinema, $numRows, $numCol, $total_seats, $seats_map){
|
||||
$this->_number = $number;
|
||||
$this->_idcinema = $idcinema;
|
||||
$this->_numRows = $numRows;
|
||||
$this->_numCol = $numCol;
|
||||
$this->_total_seats = $total_seats;
|
||||
$_seats_map = array();
|
||||
$_seats_map = $seats_map;
|
||||
}
|
||||
|
||||
//Methods:
|
||||
public static function getListHalls($cinema){
|
||||
$bd = new HallDAO('complucine');
|
||||
if($bd )
|
||||
return $bd->getAllHalls($cinema);
|
||||
}
|
||||
|
||||
public static function create_hall($number, $cinema, $rows, $cols, $seats, $seats_map){
|
||||
$bd = new HallDAO('complucine');
|
||||
if($bd ){
|
||||
if(!$bd->searchHall($number, $cinema)){
|
||||
$bd->createHall($number, $cinema, $rows, $cols, $seats, $seats_map);
|
||||
Seat::createSeats($number, $cinema, $rows, $cols, $seats_map);
|
||||
return "Se ha creado la sala con exito";
|
||||
} else {
|
||||
return "Esta sala ya existe";
|
||||
}
|
||||
} else { return "Error al conectarse a la base de datos"; }
|
||||
}
|
||||
|
||||
public static function edit_hall($number, $cinema, $rows, $cols, $seats, $seats_map, $og_number){
|
||||
$bd = new HallDAO('complucine');
|
||||
if($bd ){
|
||||
if($bd->searchHall($og_number, $cinema)){
|
||||
if($og_number == $number){
|
||||
Seat::deleteAllSeats($number, $cinema);
|
||||
$bd->editHall($number, $cinema, $rows, $cols, $seats, $og_number);
|
||||
Seat::createSeats($number, $cinema, $rows, $cols, $seats_map);
|
||||
return "Se ha editado la sala con exito";
|
||||
}else{
|
||||
if(!$bd->searchHall($number, $cinema)){
|
||||
Seat::deleteAllSeats($og_number, $cinema);
|
||||
$bd->editHall($number, $cinema, $rows, $cols, $seats, $og_number);
|
||||
Seat::createSeats($number, $cinema, $rows, $cols, $seats_map);
|
||||
return "Se ha editado la sala con exito";
|
||||
}else
|
||||
return "El nuevo numero de sala ya existe en otra sala";
|
||||
}
|
||||
} else {
|
||||
return "La sala a editar no existe";
|
||||
}
|
||||
} else { return "Error al conectarse a la base de datos"; }
|
||||
}
|
||||
|
||||
public static function delete_hall($number, $cinema, $rows, $cols, $seats, $seats_map, $og_number){
|
||||
$bd = new HallDAO('complucine');
|
||||
if($bd ){
|
||||
if($bd->searchHall($og_number, $cinema)){
|
||||
$bd->deleteHall($og_number, $cinema);
|
||||
Seat::deleteAllSeats($og_number, $cinema);
|
||||
return "La sala se ha eliminado correctamente";
|
||||
} else {
|
||||
return "La sala a borrar no existe";
|
||||
}
|
||||
} else { return "Error al conectarse a la base de datos"; }
|
||||
}
|
||||
|
||||
//Getters && Setters:
|
||||
public function setNumber($number){ $this->_number = $number; }
|
||||
public function getNumber(){ return $this->_number; }
|
||||
|
||||
public function setIdcinema($idcinema){ $this->_idcinema = $idcinema; }
|
||||
public function getIdcinema(){ return $this->_idcinema; }
|
||||
|
||||
public function setNumRows($numRows){ $this->_numRows = $numRows; }
|
||||
public function getNumRows(){ return $this->_numRows; }
|
||||
|
||||
public function setNumCol($numCol){ $this->_numCol = $numCol; }
|
||||
public function getNumCol(){ return $this->_numCol; }
|
||||
|
||||
public function setTotalSeats($totalSeat){ $this->_total_seats = $totalSeat; }
|
||||
public function getTotalSeats(){ return $this->_total_seats; }
|
||||
|
||||
public function setSeatsmap($seats_map){ $this->_seats_map = $seats_map; }
|
||||
public function getSeatsmap(){ return $this->_seats_map; }
|
||||
|
||||
}
|
||||
?>
|
96
assets/php/includes/hall_dao.php
Normal file
96
assets/php/includes/hall_dao.php
Normal file
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
include_once('hall.php');
|
||||
|
||||
|
||||
class HallDAO extends DAO {
|
||||
|
||||
//Constructor:
|
||||
function __construct($bd_name){
|
||||
parent::__construct($bd_name);
|
||||
}
|
||||
|
||||
//Methods:
|
||||
|
||||
//Create a new Hall.
|
||||
public function createHall($number, $cinema, $rows, $cols, $seats, $seats_map){
|
||||
|
||||
$sql = sprintf( "INSERT INTO `hall`( `number`, `idcinema`, `numrows`, `numcolumns`, `total_seats`)
|
||||
VALUES ( '%d', '%d', '%d', '%d', '%d')",
|
||||
$number, $cinema, $rows, $cols, $seats );
|
||||
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error BD createhall');
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
//Returns a query to get the halls data.
|
||||
public function getAllHalls($cinema){
|
||||
$sql = sprintf( "SELECT * FROM hall WHERE
|
||||
idcinema = '%s'",
|
||||
$cinema);
|
||||
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
$hall = null;
|
||||
while($fila=mysqli_fetch_array($resul)){
|
||||
$hall[] = $this->loadHall($fila["number"], $fila["idcinema"], $fila["numrows"], $fila["numcolumns"], $fila["total_seats"], null);
|
||||
}
|
||||
|
||||
mysqli_free_result($resul);
|
||||
|
||||
return $hall;
|
||||
}
|
||||
|
||||
public function searchHall($number, $cinema){
|
||||
|
||||
$sql = sprintf( "SELECT * FROM hall WHERE
|
||||
number = '%s' AND idcinema = '%s'",
|
||||
$number, $cinema);
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
$hall = false;
|
||||
|
||||
if($resul){
|
||||
if($resul->num_rows == 1){
|
||||
$fila = $resul->fetch_assoc();
|
||||
$hall = $this->loadHall($fila["number"], $fila["idcinema"], $fila["numrows"], $fila["numcolumns"], $fila["total_seats"], null);
|
||||
}
|
||||
$resul->free();
|
||||
}
|
||||
|
||||
return $hall;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Create a new Hall Data Transfer Object.
|
||||
public function loadHall($number, $idcinema, $numrows, $numcolumns, $total_seats, $seats_map){
|
||||
return new Hall($number, $idcinema, $numrows, $numcolumns, $total_seats, $seats_map);
|
||||
}
|
||||
|
||||
//Edit Hall.
|
||||
public function editHall($number, $cinema, $rows, $cols, $seats, $og_number){
|
||||
|
||||
$sql = sprintf( "UPDATE `hall`
|
||||
SET `number` = '%d' ,`numrows` = '%d' , `numcolumns` = '%d' , `total_seats` = %d
|
||||
WHERE `hall`.`number` = '%d' AND `hall`.`idcinema` = '%d';",
|
||||
$number, $rows, $cols, $seats, $og_number, $cinema );
|
||||
|
||||
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
return $resul;
|
||||
}
|
||||
|
||||
//Delete Hall.
|
||||
public function deleteHall($number, $cinema){
|
||||
|
||||
$sql = sprintf( "DELETE FROM `hall` WHERE `hall`.`number` = '%d' AND `hall`.`idcinema` = '%d';",$number, $cinema);
|
||||
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
return $resul;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
35
assets/php/includes/manager.php
Normal file
35
assets/php/includes/manager.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
class Manager{
|
||||
|
||||
//Attributes:
|
||||
private $_id; //Manager ID.
|
||||
private $_username; //Manager username.
|
||||
private $_email; //Email.
|
||||
private $_roll; //Roll
|
||||
|
||||
//Constructor:
|
||||
function __construct($id, $idcinema, $username, $email, $roll){
|
||||
$this->_id = $id;
|
||||
$this->_idcinema = $idcinema;
|
||||
$this->_username = $username;
|
||||
$this->_email = $email;
|
||||
$this->_roll = $roll;
|
||||
}
|
||||
|
||||
//Methods:
|
||||
|
||||
//Getters && Setters:
|
||||
public function setId($id){ $this->_id = $id; }
|
||||
public function getId(){ return $this->_id; }
|
||||
public function setIdcinema($idcinema){ $this->_idcinema = $idcinema; }
|
||||
public function getIdcinema(){ return $this->_idcinema; }
|
||||
public function setUsername($username){$this->_username = $username; }
|
||||
public function getUsername(){ return $this->_username;}
|
||||
public function setEmail($email){$this->_email = $email;}
|
||||
public function getEmail(){return $this->_email;}
|
||||
public function setRoll($roll){$this->_roll = $roll;}
|
||||
public function getRoll(){return $this->_roll;}
|
||||
|
||||
}
|
||||
?>
|
77
assets/php/includes/manager_dao.php
Normal file
77
assets/php/includes/manager_dao.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
include_once('manager.php');
|
||||
|
||||
class Manager_DAO extends DAO {
|
||||
|
||||
//Constructor:
|
||||
function __construct($bd_name){
|
||||
parent::__construct($bd_name);
|
||||
}
|
||||
|
||||
//Methods:
|
||||
|
||||
//Returns a query to get All the managers.
|
||||
public function allManagersData(){
|
||||
$sql = sprintf( "SELECT * FROM `users` JOIN `manager` ON manager.id = users.id");
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
while($fila=$resul->fetch_assoc()){
|
||||
$managers[] = $this->loadManager($fila["id"], $fila["idcinema"], $fila["username"], $fila["email"], $fila["rol"]);
|
||||
}
|
||||
$resul->free();
|
||||
return $managers;
|
||||
}
|
||||
|
||||
//Returns a manager data .
|
||||
public function GetManager($id){
|
||||
$sql = sprintf( "SELECT * FROM `manager` WHERE manager.id = '%d'", $id );
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
return $resul;
|
||||
}
|
||||
|
||||
//Returns a manager data .
|
||||
public function GetManagerCinema($id, $idcinema){
|
||||
$sql = sprintf( "SELECT * FROM `manager` WHERE manager.id = '%d' AND manager.idcinema ='%d'", $id, $idcinema );
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
return $resul;
|
||||
}
|
||||
|
||||
//Create a new Session.
|
||||
public function createManager($id, $idcinema){
|
||||
$sql = sprintf( "INSERT INTO `manager`( `id`, `idcinema`)
|
||||
VALUES ( '%d', '%d')",
|
||||
$id, $idcinema);
|
||||
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
return $resul;
|
||||
}
|
||||
|
||||
|
||||
//Deleted manager by "id".
|
||||
public function deleteManager($id){
|
||||
$sql = sprintf( "DELETE FROM `manager` WHERE manager.id = '%d' ;",$id);
|
||||
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
return $resul;
|
||||
}
|
||||
|
||||
//Edit manager.
|
||||
public function editManager($id, $idcinema){
|
||||
$sql = sprintf( "UPDATE `manager` SET manager.idcinema = '%d'
|
||||
WHERE manager.id = '%d';",
|
||||
$idcinema, $id);
|
||||
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
return $resul;
|
||||
}
|
||||
|
||||
//Create a new Manager Data Transfer Object.
|
||||
public function loadManager($id, $idcinema, $username, $email, $rol){
|
||||
return new Manager($id, $idcinema, $username, $email, $rol);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
36
assets/php/includes/promotion.php
Normal file
36
assets/php/includes/promotion.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
class Promotion{
|
||||
|
||||
//Attributes:
|
||||
private $_id; //Cinema ID.
|
||||
private $_tittle; //Cinema name.
|
||||
private $_description; //Cinema direction.
|
||||
private $_code; //Cinema phone.
|
||||
private $_active;
|
||||
|
||||
//Constructor:
|
||||
function __construct($id, $tittle, $description, $code, $active){
|
||||
$this->_id = $id;
|
||||
$this->_tittle = $tittle;
|
||||
$this->_description = $description;
|
||||
$this->_code = $code;
|
||||
$this->_active = $active;
|
||||
}
|
||||
|
||||
//Methods:
|
||||
|
||||
//Getters && Setters:
|
||||
public function setId($id){ $this->_id = $id; }
|
||||
public function getId(){ return $this->_id; }
|
||||
public function setTittle($tittle){ $this->_tittle = $tittle; }
|
||||
public function getTittle(){ return $this->_tittle; }
|
||||
public function setDescription($description){ $this->_description = $description;}
|
||||
public function getDescription(){return $this->_description;}
|
||||
public function setCode($code){ $this->_code = $code;}
|
||||
public function getCode(){return $this->_code;}
|
||||
public function setActive($active){ $this->_active = $active;}
|
||||
public function getActive(){return $this->_active;}
|
||||
|
||||
}
|
||||
?>
|
77
assets/php/includes/promotion_dao.php
Normal file
77
assets/php/includes/promotion_dao.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
include_once('promotion.php');
|
||||
|
||||
class Promotion_DAO extends DAO {
|
||||
|
||||
//Constructor:
|
||||
function __construct($bd_name){
|
||||
parent::__construct($bd_name);
|
||||
}
|
||||
|
||||
//Methods:
|
||||
|
||||
//Create a new Session.
|
||||
public function createPromotion($id, $tittle, $description, $code, $active){
|
||||
$sql = sprintf( "INSERT INTO `promotion`( `id`, `tittle`, `description`, `code`, `active`)
|
||||
VALUES ( '%d', '%s', '%s', '%s', '%s')",
|
||||
$id, $tittle, $description, $code, $active);
|
||||
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
return $resul;
|
||||
}
|
||||
|
||||
|
||||
//Returns a query to get All the films.
|
||||
public function allPromotionData(){
|
||||
$sql = sprintf( "SELECT * FROM promotion ");
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
while($fila=$resul->fetch_assoc()){
|
||||
$promotions[] = $this->loadPromotion($fila["id"], $fila["tittle"], $fila["description"], $fila["code"], $fila["active"]);
|
||||
}
|
||||
$resul->free();
|
||||
return $promotions;
|
||||
}
|
||||
|
||||
//Returns a film data .
|
||||
public function GetPromotion($code){
|
||||
$sql = sprintf( "SELECT * FROM promotion WHERE promotion.code = '%s'", $code );
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
return $resul;
|
||||
}
|
||||
|
||||
//Returns a film data .
|
||||
public function promotionData($id){
|
||||
$sql = sprintf( "SELECT * FROM promotion WHERE promotion.id = '%d'", $id);
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
return $resul;
|
||||
}
|
||||
|
||||
//Deleted film by "id".
|
||||
public function deletePromotion($id){
|
||||
$sql = sprintf( "DELETE FROM promotion WHERE promotion.id = '%d' ;",$id);
|
||||
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
return $resul;
|
||||
}
|
||||
|
||||
//Edit a film.
|
||||
public function editPromotion($id, $tittle, $description, $code, $active){
|
||||
$sql = sprintf( "UPDATE promotion SET tittle = '%s' , description = '%s', code ='%s' , active ='%s'
|
||||
WHERE promotion.id = '%d';",
|
||||
$tittle, $description, $code, $active, $id);
|
||||
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
return $resul;
|
||||
}
|
||||
|
||||
//Create a new film Data Transfer Object.
|
||||
public function loadPromotion($id, $tittle, $description, $code, $active){
|
||||
return new Promotion($id, $tittle, $description, $code, $active);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
63
assets/php/includes/seat.php
Normal file
63
assets/php/includes/seat.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
include_once($prefix.'assets/php/includes/seat_dao.php');
|
||||
|
||||
class Seat{
|
||||
|
||||
//Attributes:
|
||||
private $_idhall;
|
||||
private $_idcinema;
|
||||
private $_numRow;
|
||||
private $_numCol;
|
||||
private $_state;
|
||||
|
||||
//Constructor:
|
||||
function __construct($idhall, $idcinema, $numRow, $numCol, $state){
|
||||
$this->_number = $idhall;
|
||||
$this->_idcinema = $idcinema;
|
||||
$this->_numRow = $numRow;
|
||||
$this->_numCol = $numCol;
|
||||
$this->_state = $state;
|
||||
}
|
||||
|
||||
static public function createSeats($hall, $cinema, $rows, $cols, $seats_map){
|
||||
$bd = new SeatDAO('complucine');
|
||||
|
||||
for($i = 1;$i <= $rows;$i++){
|
||||
for($j = 1; $j <= $cols;$j++){
|
||||
$bd->createSeat($hall, $cinema, $i, $j, $seats_map[$i][$j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static public function getSeatsMap($number, $cinema){
|
||||
$bd = new SeatDAO('complucine');
|
||||
if($bd )
|
||||
return $bd->getAllSeats($number, $cinema);
|
||||
}
|
||||
|
||||
static public function deleteAllSeats($number, $cinema){
|
||||
$bd = new SeatDAO('complucine');
|
||||
if($bd)
|
||||
return $bd->deletemapSeats($number, $cinema);
|
||||
}
|
||||
|
||||
//Getters && Setters:
|
||||
public function setNumber($number){ $this->_number = $number; }
|
||||
public function getNumber(){ return $this->_number; }
|
||||
|
||||
public function setIdcinema($idcinema){ $this->_idcinema = $idcinema; }
|
||||
public function getIdcinema(){ return $this->_idcinema; }
|
||||
|
||||
public function setNumRows($numRow){ $this->_numRow = $numRow; }
|
||||
public function getNumRows(){ return $this->_numRow; }
|
||||
|
||||
public function setNumCol($numCol){ $this->_numCol = $numCol; }
|
||||
public function getNumCol(){ return $this->_numCol; }
|
||||
|
||||
public function setState($state){ $this->_state = $state; }
|
||||
public function getState(){ return $this->_state; }
|
||||
|
||||
|
||||
|
||||
}
|
||||
?>
|
58
assets/php/includes/seat_dao.php
Normal file
58
assets/php/includes/seat_dao.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
include_once('seat.php');
|
||||
|
||||
class SeatDAO extends DAO {
|
||||
|
||||
//Constructor:
|
||||
function __construct($bd_name){
|
||||
parent::__construct($bd_name);
|
||||
}
|
||||
|
||||
//Methods:
|
||||
|
||||
//Create a new Hall.
|
||||
public function createSeat($hall, $cinema, $row, $col, $state){
|
||||
|
||||
$sql = sprintf( "INSERT INTO `seat`( `idhall`, `idcinema`, `numrow`, `numcolum`, `active`)
|
||||
VALUES ( '%d', '%d', '%d', '%d', '%d')",
|
||||
$hall, $cinema, $row, $col, $state);
|
||||
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error BD createSeat');
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
public function getAllSeats($number, $cinema){
|
||||
|
||||
$sql = sprintf( "SELECT * FROM seat WHERE
|
||||
idhall = '%s' AND idcinema = '%s'",
|
||||
$number, $cinema);
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
$seat_map = null;
|
||||
while($fila=mysqli_fetch_array($resul)){
|
||||
$seat_map[] = $this->loadSeat($fila["idhall"], $fila["idcinema"], $fila["numrow"], $fila["numcolum"], $fila["active"]);
|
||||
}
|
||||
|
||||
mysqli_free_result($resul);
|
||||
|
||||
return $seat_map;
|
||||
}
|
||||
|
||||
public function deletemapSeats($hall, $cinema){
|
||||
$sql = sprintf( "DELETE FROM `seat` WHERE
|
||||
idcinema = '%s' AND idhall = '%s'",
|
||||
$cinema, $hall);
|
||||
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
return $resul;
|
||||
}
|
||||
|
||||
public function loadSeat($idhall, $idcinema, $numRow, $numCol, $state){
|
||||
return new Seat($idhall, $idcinema, $numRow, $numCol, $state);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
124
assets/php/includes/session.php
Normal file
124
assets/php/includes/session.php
Normal file
@ -0,0 +1,124 @@
|
||||
<?php
|
||||
include_once($prefix.'assets/php/includes/session_dao.php');
|
||||
|
||||
class Session{
|
||||
|
||||
private $_id;
|
||||
private $_idfilm;
|
||||
private $_idhall;
|
||||
private $_idcinema;
|
||||
private $_date;
|
||||
private $_startTime;
|
||||
private $_seatPrice;
|
||||
private $_format;
|
||||
private $_seats_full;
|
||||
|
||||
function __construct($id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format, $seats_full){
|
||||
$this->_id = $id;
|
||||
$this->_idfilm = $idfilm;
|
||||
$this->_idhall = $idhall;
|
||||
$this->_idcinema = $idcinema;
|
||||
$this->_date = $date;
|
||||
$this->_startTime = $startTime;
|
||||
$this->_seatPrice = $seatPrice;
|
||||
$this->_format = $format;
|
||||
$this->_seats_full = $seats_full;
|
||||
}
|
||||
|
||||
public static function getListSessions($hall,$cinema,$date){
|
||||
$bd = new SessionDAO('complucine');
|
||||
if($bd ) {
|
||||
return $bd->getAllSessions($hall, $cinema, $date);
|
||||
}
|
||||
}
|
||||
|
||||
public static function create_session($cinema, $hall, $start, $date, $film, $price, $format,$repeat){
|
||||
$bd = new SessionDAO('complucine');
|
||||
if($bd ){
|
||||
if(!$bd->searchSession($cinema, $hall, $start, $date)){
|
||||
$bd->createSession(null,$film, $hall, $cinema, $date, $start, $price, $format);
|
||||
|
||||
if($repeat > "0") {
|
||||
$repeats = $repeat;
|
||||
$repeat = $repeat - 1;
|
||||
$date = date('Y-m-d', strtotime( $date . ' +1 day') );
|
||||
self::create_session($cinema, $hall, $start, $date, $film, $price, $format,$repeat);
|
||||
return "Se han creado las ".$repeat ." sesiones con exito";
|
||||
}
|
||||
|
||||
else
|
||||
return "Se ha creado la session con exito";
|
||||
} else
|
||||
return "Esta session ya existe";
|
||||
|
||||
} else return "Error al conectarse a la base de datos";
|
||||
}
|
||||
|
||||
public static function edit_session($cinema, $or_hall, $or_date, $or_start, $hall, $start, $date, $film, $price, $format){
|
||||
$bd = new SessionDAO('complucine');
|
||||
if($bd ){
|
||||
if($bd->searchSession($cinema, $or_hall, $or_start, $or_date)){
|
||||
if(!$bd->searchSession($cinema,$hall,$start,$date)){
|
||||
$origin = array("cinema" => $cinema,"hall" => $or_hall,"start" => $or_start,"date" => $or_date);
|
||||
$bd->editSession($film, $hall, $cinema, $date, $start, $price, $format,$origin);
|
||||
return "Se ha editado la session con exito";
|
||||
}else if($or_hall == $hall && $or_start == $start && $or_date == $date){
|
||||
$origin = array("cinema" => $cinema,"hall" => $or_hall,"start" => $or_start,"date" => $or_date);
|
||||
$bd->editSession($film, $hall, $cinema, $date, $start, $price, $format, $origin);
|
||||
return "Se ha editado la session con exito";
|
||||
}else{
|
||||
return "Ya existe una sesion con los parametros nuevos";
|
||||
}
|
||||
|
||||
} else
|
||||
return "La session a editar no existe";
|
||||
|
||||
} else return "Error al conectarse a la base de datos";
|
||||
}
|
||||
|
||||
public static function delete_session($cinema, $hall, $start, $date){
|
||||
$bd = new SessionDAO('complucine');
|
||||
if($bd ){
|
||||
if($bd->searchSession($cinema, $hall, $start, $date)){
|
||||
$bd->deleteSession($hall, $cinema, $date, $start);
|
||||
return "Se ha eliminado la session con exito";
|
||||
} else
|
||||
return "Esta session no existe";
|
||||
|
||||
} else return "Error al conectarse a la base de datos";
|
||||
}
|
||||
|
||||
//Esto deberia estar en film.php? seguramente
|
||||
public static function getThisSessionFilm($idfilm){
|
||||
$bd = new SessionDAO('complucine');
|
||||
if($bd ) {
|
||||
return $bd->filmTittle($idfilm);
|
||||
}
|
||||
}
|
||||
|
||||
public function setId($id){ $this->_id = $id; }
|
||||
public function getId(){ return $this->_id; }
|
||||
|
||||
public function setIdfilm($idfilm){ $this->_idfilm = $idfilm; }
|
||||
public function getIdfilm(){ return $this->_idfilm; }
|
||||
|
||||
public function setIdhall($idhall){ $this->_idhall = $idhall; }
|
||||
public function getIdhall(){ return $this->_idhall; }
|
||||
|
||||
public function setIdcinema($cinema){ $this->_idcinema = $idcinema; }
|
||||
public function getIdcinema(){ return $this->_idcinema; }
|
||||
|
||||
public function setDate($date){ $this->_date = $date; }
|
||||
public function getDate(){ return $this->_date; }
|
||||
|
||||
public function setStartTime($startTime){ $this->_startTime = $startTime; }
|
||||
public function getStartTime(){ return $this->_startTime; }
|
||||
|
||||
public function setSeatPrice($seatPrice){ $this->_seatPrice = $seatPrice; }
|
||||
public function getSeatPrice(){ return $this->_seatPrice; }
|
||||
|
||||
public function setFormat($format){ $this->_format = $format; }
|
||||
public function getFormat(){ return $this->_format; }
|
||||
|
||||
}
|
||||
?>
|
114
assets/php/includes/session_dao.php
Normal file
114
assets/php/includes/session_dao.php
Normal file
@ -0,0 +1,114 @@
|
||||
<?php
|
||||
include_once('session.php');
|
||||
|
||||
class SessionDAO extends DAO {
|
||||
//Constructor:
|
||||
function __construct($bd_name){
|
||||
parent::__construct($bd_name);
|
||||
}
|
||||
//Methods:
|
||||
|
||||
public function createSession($id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format){
|
||||
$format = $this->mysqli->real_escape_string($format);
|
||||
$date = date('Y-m-d', strtotime( $date ) );
|
||||
$startTime = date('H:i:s', strtotime( $startTime ) );
|
||||
|
||||
$sql = sprintf( "INSERT INTO `session` (`id`, `idfilm`, `idhall`, `idcinema`, `date`, `start_time`, `seat_price`, `format`, `seats_full`)
|
||||
VALUES ('%d', '%d', '%d', '%d', '%s', '%s', '%d', '%s', '%d')",
|
||||
$id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format, "0");
|
||||
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
//Returns a query to get the session's data.
|
||||
public function sessionData($id){
|
||||
$sql = sprintf( "SELECT * FROM `session` WHERE id = '%d'", $id );
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database en sessionData con la id '. $id);
|
||||
|
||||
$resul = mysqli_fetch_array($resul);
|
||||
|
||||
return $resul;
|
||||
}
|
||||
|
||||
public function filmTittle($idfilm){
|
||||
$sql = sprintf("SELECT * FROM film JOIN session ON film.id = session.idfilm WHERE session.idfilm = '%d' ", $idfilm );
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database en sessionData con la id '. $idfilm);
|
||||
|
||||
$resul = mysqli_fetch_array($resul);
|
||||
|
||||
return $resul;
|
||||
}
|
||||
|
||||
//Returns a session
|
||||
public function searchSession($cinema, $hall, $startTime, $date){
|
||||
$date = date('Y-m-d', strtotime( $date ) );
|
||||
$startTime = date('H:i:s', strtotime( $startTime ) );
|
||||
|
||||
$sql = sprintf( "SELECT * FROM session WHERE
|
||||
idcinema = '%s' AND idhall = '%s' AND date = '%s' AND start_time = '%s'",
|
||||
$cinema, $hall, $date, $startTime);
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
$session = mysqli_fetch_array($resul);
|
||||
|
||||
mysqli_free_result($resul);
|
||||
|
||||
return $session;
|
||||
}
|
||||
//Returns a query to get all the session's data.
|
||||
public function getAllSessions($hall, $cinema, $date){
|
||||
$date = date('Y-m-d', strtotime( $date ) );
|
||||
|
||||
$sql = sprintf( "SELECT * FROM session WHERE
|
||||
idcinema = '%s' AND idhall = '%s' AND date = '%s' ORDER BY start_time ASC;",
|
||||
$cinema, $hall, $date);
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
$sessions = null;
|
||||
|
||||
while($fila=mysqli_fetch_array($resul)){
|
||||
$sessions[] = $this->loadSession($fila["id"], $fila["idfilm"], $fila["idhall"], $fila["idcinema"], $fila["date"], $fila["start_time"], $fila["seat_price"], $fila["format"], $fila["seats_full"]);
|
||||
}
|
||||
mysqli_free_result($resul);
|
||||
|
||||
return $sessions;
|
||||
}
|
||||
|
||||
public function editSession($idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format, $origin){
|
||||
$format = $this->mysqli->real_escape_string($format);
|
||||
$date = date('Y-m-d', strtotime( $date ) );
|
||||
$startTime = date('H:i:s', strtotime( $startTime ) );
|
||||
|
||||
$sql = sprintf( "UPDATE `session`
|
||||
SET `idfilm` = '%d' , `idhall` = '%d', `idcinema` = '%d', `date` = '%s',
|
||||
`start_time` = '%s', `seat_price` = '%d', `format` = '%s'
|
||||
WHERE
|
||||
idcinema = '%s' AND idhall = '%s' AND date = '%s' AND start_time = '%s'",
|
||||
$idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format, $origin["cinema"],$origin["hall"],$origin["date"],$origin["start"]);
|
||||
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
return $resul;
|
||||
}
|
||||
|
||||
public function deleteSession($hall, $cinema, $date, $startTime){
|
||||
|
||||
$sql = sprintf( "DELETE FROM `session` WHERE
|
||||
idcinema = '%s' AND idhall = '%s' AND date = '%s' AND start_time = '%s'",
|
||||
$cinema, $hall, $date, $startTime);
|
||||
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
return $resul;
|
||||
}
|
||||
|
||||
//Create a new Session Data Transfer Object.
|
||||
public function loadSession( $id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format, $seats_full){
|
||||
return new Session( $id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format, $seats_full);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
36
assets/php/includes/user.php
Normal file
36
assets/php/includes/user.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
class User {
|
||||
|
||||
//Attributes:
|
||||
private $_id; //User Id.
|
||||
private $_username; //User name.
|
||||
private $_email; //User email.
|
||||
private $_password; //User password.
|
||||
private $_rol; //Type of user: user | manager | admin. --> Será eliminado en la siguiente práctica para usar el modelo relacional de nuestra BD.
|
||||
|
||||
//Constructor:
|
||||
function __construct($id, $username, $email, $password, $rol){
|
||||
$this->_id = $id;
|
||||
$this->_username = $username;
|
||||
$this->_email = $email;
|
||||
$this->_password = $password;
|
||||
$this->_rol = $rol;
|
||||
}
|
||||
|
||||
//Methods:
|
||||
|
||||
//Getters && Setters:
|
||||
public function setId($id){ $this->_id = $id; }
|
||||
public function getId(){ return $this->_id; }
|
||||
public function setName($username){ $this->_username = $username; }
|
||||
public function getName(){ return $this->_username; }
|
||||
public function setEmail($email){ $this->_email = $email; }
|
||||
public function getEmail(){ return $this->_email; }
|
||||
public function setPass($passwd){ $this->_password = $passwd; }
|
||||
public function getPass(){ return $this->_password; }
|
||||
public function setRol($rol){ $this->_rol = $rol; }
|
||||
public function getRol(){ return $this->_rol; }
|
||||
|
||||
}
|
||||
?>
|
165
assets/php/includes/user_dao.php
Normal file
165
assets/php/includes/user_dao.php
Normal file
@ -0,0 +1,165 @@
|
||||
<?php
|
||||
include_once('user.php');
|
||||
|
||||
class UserDAO extends DAO {
|
||||
|
||||
//Constants:
|
||||
private const _USER = "user";
|
||||
private const _MANAGER = "manager";
|
||||
private const _ADMIN = "admin";
|
||||
|
||||
//Attributes:
|
||||
|
||||
//Constructor:
|
||||
function __construct($bd_name){
|
||||
parent::__construct($bd_name);
|
||||
}
|
||||
|
||||
//Methods:
|
||||
|
||||
//Encrypt password with SHA254.
|
||||
private function encryptPass($password){
|
||||
//$password = hash('sha256', $password);
|
||||
$password = password_hash($password, PASSWORD_DEFAULT);
|
||||
|
||||
return $password;
|
||||
}
|
||||
|
||||
//Returns true if the password and hash match, or false otherwise.
|
||||
public function verifyPass($password, $passwd){
|
||||
return password_verify($password, $passwd);
|
||||
}
|
||||
|
||||
|
||||
//All users
|
||||
public function allUsersNotM(){
|
||||
$sql = sprintf( "SELECT * FROM `users` WHERE users.id NOT IN (SELECT id FROM `manager`)");
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
while($fila=$resul->fetch_assoc()){
|
||||
$users[] = $this->loadUser($fila['id'], $fila['username'], $fila['email'], $fila['passwd'], $fila['rol']);
|
||||
}
|
||||
$resul->free();
|
||||
return $users;
|
||||
}
|
||||
|
||||
//Create a new User.
|
||||
public function createUser($id, $username, $email, $password, $rol){
|
||||
$password = $this->encryptPass($password);
|
||||
|
||||
$sql = sprintf( "INSERT INTO users( id, username, email, passwd, rol)
|
||||
VALUES ( '%s', '%s', '%s', '%s', '%s')",
|
||||
$id, $username, $email, $password, $rol );
|
||||
|
||||
$resul = mysqli_query($this->mysqli, $sql);
|
||||
|
||||
return $resul;
|
||||
}
|
||||
|
||||
//Returns a query to check if the user name exists.
|
||||
public function selectUser($username, $password){
|
||||
$username = $this->mysqli->real_escape_string($username);
|
||||
$password = $this->mysqli->real_escape_string($password);
|
||||
|
||||
$sql = sprintf( "SELECT * FROM users WHERE username = '%s'", $username );
|
||||
$resul = mysqli_query($this->mysqli, $sql);
|
||||
|
||||
$resul->data_seek(0);
|
||||
$user = null;
|
||||
while ($fila = $resul->fetch_assoc()) {
|
||||
if($username === $fila['username'] && $this->verifyPass($password, $fila['passwd'])){
|
||||
$user = $this->loadUser($fila['id'], $fila['username'], $fila['email'], $fila['passwd'], $fila['rol']);
|
||||
}
|
||||
}
|
||||
|
||||
//mysqli_free_result($selectUser);
|
||||
$resul->free();
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
//Returns a query to get the user's data.
|
||||
public function userData($id){
|
||||
$id = $this->mysqli->real_escape_string($id);
|
||||
|
||||
$sql = sprintf( "SELECT * FROM users WHERE id = '%d'", $id );
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
return $resul;
|
||||
}
|
||||
|
||||
//Search a user by name.
|
||||
public function selectUserName($username){
|
||||
$username = $this->mysqli->real_escape_string($username);
|
||||
|
||||
$sql = sprintf( "SELECT * FROM users WHERE username = '%s'", $username );
|
||||
$resul = mysqli_query($this->mysqli, $sql);
|
||||
|
||||
return $resul;
|
||||
}
|
||||
|
||||
//Search a user by email.
|
||||
public function selectUserEmail($email){
|
||||
$email = $this->mysqli->real_escape_string($email);
|
||||
|
||||
$sql = sprintf( "SELECT * FROM users WHERE email = '%s'", $email );
|
||||
$resul = mysqli_query($this->mysqli, $sql);
|
||||
|
||||
return $resul;
|
||||
}
|
||||
|
||||
//Change username by id.
|
||||
public function changeUserName($id, $username){
|
||||
$id = $this->mysqli->real_escape_string($id);
|
||||
$username = $this->mysqli->real_escape_string($username);
|
||||
|
||||
$sql = sprintf( "UPDATE users SET username = '%s' WHERE id = '%d'", $username, $id );
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
return $resul;
|
||||
|
||||
}
|
||||
|
||||
//Change userpass by id.
|
||||
public function changeUserPass($id, $password){
|
||||
$id = $this->mysqli->real_escape_string($id);
|
||||
$password = $this->mysqli->real_escape_string($password);
|
||||
$password = $this->encryptPass($password);
|
||||
|
||||
$sql = sprintf( "UPDATE users SET passwd = '%s' WHERE id = '%d'", $password, $id );
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
return $resul;
|
||||
|
||||
}
|
||||
|
||||
//Change user email by id.
|
||||
public function changeUserEmail($id, $email){
|
||||
$id = $this->mysqli->real_escape_string($id);
|
||||
$email = $this->mysqli->real_escape_string($email);
|
||||
|
||||
$sql = sprintf( "UPDATE users SET email = '%s' WHERE id = '%d'", $email, $id );
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
return $resul;
|
||||
|
||||
}
|
||||
|
||||
//Delete user account by id.
|
||||
public function deleteUserAccount($id){
|
||||
$id = $this->mysqli->real_escape_string($id);
|
||||
|
||||
$sql = sprintf( "DELETE FROM users WHERE id = '%d'", $id );
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
return $resul;
|
||||
}
|
||||
|
||||
//Create a new User Data Transfer Object.
|
||||
public function loadUser($id, $username, $email, $password, $rol){
|
||||
return new User($id, $username, $email, $password, $rol);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -49,6 +49,7 @@
|
||||
case strpos($this->page, 'miembros'): $this->page = 'Miembros'; $this->prefix = '../../'; break;
|
||||
case strpos($this->page, 'planificacion'): $this->page = 'Planificación'; $this->prefix = '../../'; break;
|
||||
case strpos($this->page, 'contacto'): $this->page = 'Contacto'; break;
|
||||
case strpos($this->page, 'assets'): $this->prefix = '../../../'; break;
|
||||
default: $this->page = 'FDI-Cines'; $this->prefix = './'; break;
|
||||
}
|
||||
}
|
||||
@ -72,6 +73,8 @@
|
||||
<title>CompluCine | {$page}</title>
|
||||
<meta charset='utf-8' />
|
||||
<link id='estilo' rel='stylesheet' type='text/css' href='{$prefix}assets/css/main.css'>
|
||||
<noscript><h1>Esta página requiere JavaScript para su correcto funcionamiento.
|
||||
Compruebe si JavaScript está deshabilitado en su navegador.</h1></noscript>
|
||||
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
||||
<link rel='icon' href='{$prefix}img/favicon.png' />
|
||||
</head>\n";
|
||||
@ -262,7 +265,7 @@
|
||||
function print_fimls(){
|
||||
$reply = "";
|
||||
//List of the movies:
|
||||
require_once(__DIR__.'/common/film_dao.php');
|
||||
require_once(__DIR__.'/includes/film_dao.php');
|
||||
|
||||
$prefix= $this->get_prefix();
|
||||
|
||||
@ -364,7 +367,7 @@
|
||||
break;
|
||||
|
||||
case "Panel de Gerente":
|
||||
$reply .= "<div class='column'>";
|
||||
$reply .= "<div class='column'>";
|
||||
for($i = 0; $i < count($films_array); $i++){
|
||||
$tittle = str_replace('_', ' ', $tittles[$i]);
|
||||
if($i%2 === 0){
|
||||
@ -409,7 +412,7 @@
|
||||
</section>
|
||||
";
|
||||
}
|
||||
$reply .= "</div>\n";
|
||||
$reply .= "</div>\n";
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -458,7 +461,7 @@
|
||||
$reply = "";
|
||||
|
||||
//List of the cinemas:
|
||||
require_once(__DIR__.'/common/cinema_dao.php');
|
||||
require_once(__DIR__.'/includes/cinema_dao.php');
|
||||
|
||||
$cine = new Cinema_DAO("complucine");
|
||||
$cinemas = $cine->allCinemaData();
|
||||
@ -550,10 +553,15 @@
|
||||
$page = $this->page;
|
||||
|
||||
/* TODO */
|
||||
$css = "{$prefix}assets/css/highContrast.css";
|
||||
$nameCSS = "Alto Contraste";
|
||||
//$css = "{$prefix}assets/css/main.css";
|
||||
//$nameCSS = "Contraste Normal";
|
||||
if(!isset($_SESSION["css"]) || $_SESSION["css"] === "assets/css/main.css"){
|
||||
$css = "{$prefix}assets/css/highContrast.css";
|
||||
$nameCSS = "Alto Contraste";
|
||||
} else {
|
||||
$css = "{$prefix}assets/css/main.css";
|
||||
$nameCSS = "Contraste Normal";
|
||||
}
|
||||
/****/
|
||||
|
||||
|
||||
echo"<footer>
|
||||
<div class='footer'>
|
||||
@ -564,12 +572,14 @@
|
||||
<a href='{$prefix}fdicines/terms_conditions/'>Términos de uso</a> |
|
||||
<a href='{$prefix}cinemas/'>Nuestros cines</a> |
|
||||
<a href='{$prefix}contacto/'>Contacto</a> |
|
||||
<button onclick=\"cambiarCSS('$css');\">$nameCSS</button>
|
||||
<button id='css' onclick=\"cambiarCSS('$css');\">$nameCSS</button>
|
||||
</footer>\n";
|
||||
|
||||
echo"
|
||||
<!-- Scripts -->
|
||||
<script type='text/javascript' src='{$prefix}assets/js/jquery-3.2.1.min.js'></script>
|
||||
<script src='{$prefix}assets/js/cambiarCSS.js'></script>
|
||||
<script src='{$prefix}assets/js/checkForms.js'></script>
|
||||
";
|
||||
if($page === "FDI-Cines") echo"<script src='{$prefix}assets/js/promotions.js'></script>\n";
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
<button id="avanzar">Siguiente</button>
|
||||
</section>
|
||||
<section class="controls">
|
||||
<button id="play">►</button>
|
||||
<button id="play">▶</button>
|
||||
<button id="stop" disabled>||</button>
|
||||
</section>
|
||||
</div>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
include_once($prefix.'assets/php/common/user_dao.php');
|
||||
include_once($prefix.'assets/php/includes/user_dao.php');
|
||||
include_once($prefix.'assets/php/form.php');
|
||||
|
||||
class FormLogin extends Form {
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
//General Config File:
|
||||
include_once('../assets/php/config.php');
|
||||
include_once('../assets/php/common/cinema_dao.php');
|
||||
include_once('../assets/php/common/cinema.php');
|
||||
include_once('../assets/php/includes/cinema_dao.php');
|
||||
include_once('../assets/php/includes/cinema.php');
|
||||
include_once('../assets/php/form.php');
|
||||
|
||||
class formAddCinema extends Form{
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
//General Config File:
|
||||
include_once('../assets/php/config.php');
|
||||
include_once('../assets/php/common/film_dao.php');
|
||||
include_once('../assets/php/common/film.php');
|
||||
include_once('../assets/php/includes/film_dao.php');
|
||||
include_once('../assets/php/includes/film.php');
|
||||
include_once('../assets/php/form.php');
|
||||
|
||||
class formAddFilm extends Form{
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
//General Config File:
|
||||
include_once('../assets/php/config.php');
|
||||
include_once('../assets/php/common/manager_dao.php');
|
||||
include_once('../assets/php/common/manager.php');
|
||||
include_once('../assets/php/common/cinema_dao.php');
|
||||
include_once('../assets/php/common/user_dao.php');
|
||||
include_once('../assets/php/includes/manager_dao.php');
|
||||
include_once('../assets/php/includes/manager.php');
|
||||
include_once('../assets/php/includes/cinema_dao.php');
|
||||
include_once('../assets/php/includes/user_dao.php');
|
||||
include_once('../assets/php/form.php');
|
||||
|
||||
class formAddManager extends Form{
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
//General Config File:
|
||||
include_once('../assets/php/config.php');
|
||||
include_once('../assets/php/common/promotion_dao.php');
|
||||
include_once('../assets/php/common/promotion.php');
|
||||
include_once('../assets/php/includes/promotion_dao.php');
|
||||
include_once('../assets/php/includes/promotion.php');
|
||||
include_once('../assets/php/form.php');
|
||||
|
||||
class formAddPromotion extends Form{
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
//General Config File:
|
||||
include_once('../assets/php/config.php');
|
||||
include_once('../assets/php/common/cinema_dao.php');
|
||||
include_once('../assets/php/common/cinema.php');
|
||||
include_once('../assets/php/includes/cinema_dao.php');
|
||||
include_once('../assets/php/includes/cinema.php');
|
||||
include_once('../assets/php/form.php');
|
||||
|
||||
class formDeleteCinema extends Form{
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
//General Config File:
|
||||
include_once('../assets/php/config.php');
|
||||
include_once('../assets/php/common/film_dao.php');
|
||||
include_once('../assets/php/common/film.php');
|
||||
include_once('../assets/php/includes/film_dao.php');
|
||||
include_once('../assets/php/includes/film.php');
|
||||
include_once('../assets/php/form.php');
|
||||
|
||||
class formDeleteFilm extends Form{
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
//General Config File:
|
||||
include_once('../assets/php/config.php');
|
||||
include_once('../assets/php/common/manager_dao.php');
|
||||
include_once('../assets/php/common/manager.php');
|
||||
include_once('../assets/php/includes/manager_dao.php');
|
||||
include_once('../assets/php/includes/manager.php');
|
||||
include_once('../assets/php/form.php');
|
||||
|
||||
class formDeleteManager extends Form{
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
//General Config File:
|
||||
include_once('../assets/php/config.php');
|
||||
include_once('../assets/php/common/promotion_dao.php');
|
||||
include_once('../assets/php/common/promotion.php');
|
||||
include_once('../assets/php/includes/promotion_dao.php');
|
||||
include_once('../assets/php/includes/promotion.php');
|
||||
include_once('../assets/php/form.php');
|
||||
|
||||
class formDeletePromotion extends Form{
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
//General Config File:
|
||||
include_once('../assets/php/config.php');
|
||||
include_once('../assets/php/common/cinema_dao.php');
|
||||
include_once('../assets/php/common/cinema.php');
|
||||
include_once('../assets/php/includes/cinema_dao.php');
|
||||
include_once('../assets/php/includes/cinema.php');
|
||||
include_once('../assets/php/form.php');
|
||||
|
||||
class formEditCinema extends Form{
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
//General Config File:
|
||||
include_once('../assets/php/config.php');
|
||||
include_once('../assets/php/common/film_dao.php');
|
||||
include_once('../assets/php/common/film.php');
|
||||
include_once('../assets/php/includes/film_dao.php');
|
||||
include_once('../assets/php/includes/film.php');
|
||||
include_once('../assets/php/form.php');
|
||||
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
//General Config File:
|
||||
include_once('../assets/php/config.php');
|
||||
include_once('../assets/php/common/manager_dao.php');
|
||||
include_once('../assets/php/common/manager.php');
|
||||
include_once('../assets/php/common/cinema_dao.php');
|
||||
include_once('../assets/php/includes/manager_dao.php');
|
||||
include_once('../assets/php/includes/manager.php');
|
||||
include_once('../assets/php/includes/cinema_dao.php');
|
||||
include_once('../assets/php/form.php');
|
||||
|
||||
class formEditManager extends Form{
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
//General Config File:
|
||||
include_once('../assets/php/config.php');
|
||||
include_once('../assets/php/common/promotion_dao.php');
|
||||
include_once('../assets/php/common/promotion.php');
|
||||
include_once('../assets/php/includes/promotion_dao.php');
|
||||
include_once('../assets/php/includes/promotion.php');
|
||||
include_once('../assets/php/form.php');
|
||||
|
||||
class formEditPromotion extends Form{
|
||||
|
@ -90,8 +90,8 @@
|
||||
|
||||
//Functions MANAGERS
|
||||
static function print_managers(){
|
||||
include_once('../assets/php/common/manager_dao.php');
|
||||
include_once('../assets/php/common/manager.php');
|
||||
include_once('../assets/php/includes/manager_dao.php');
|
||||
include_once('../assets/php/includes/manager.php');
|
||||
$manager = new Manager_DAO("complucine");
|
||||
$managers = $manager->allManagersData();
|
||||
$ids = array();
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
include_once($prefix.'assets/php/common/hall.php');
|
||||
include_once($prefix.'assets/php/common/seat.php');
|
||||
include_once($prefix.'assets/php/includes/hall.php');
|
||||
include_once($prefix.'assets/php/includes/seat.php');
|
||||
include_once($prefix.'assets/php/form.php');
|
||||
|
||||
class FormHall extends Form {
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
require_once($prefix.'assets/php/common/session_dao.php');
|
||||
require_once($prefix.'assets/php/common/session.php');
|
||||
require_once($prefix.'assets/php/includes/session_dao.php');
|
||||
require_once($prefix.'assets/php/includes/session.php');
|
||||
require_once($prefix.'assets/php/form.php');
|
||||
|
||||
//Receive data from froms and prepare the correct response
|
||||
|
@ -4,9 +4,9 @@
|
||||
require_once('../assets/php/config.php');
|
||||
//Controller file:
|
||||
require_once('panel_manager.php');
|
||||
require_once('../assets/php/common/manager_dao.php');
|
||||
require_once('../assets/php/common/manager.php');
|
||||
require_once('../assets/php/common/user.php');
|
||||
require_once('../assets/php/includes/manager_dao.php');
|
||||
require_once('../assets/php/includes/manager.php');
|
||||
require_once('../assets/php/includes/user.php');
|
||||
|
||||
if($_SESSION["login"] && $_SESSION["lastRol"] === "admin" && $_SESSION["rol"] === "manager") {
|
||||
$manager = false;
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
include_once($prefix.'assets/php/common/hall.php');
|
||||
include_once($prefix.'assets/php/common/session.php');
|
||||
require_once($prefix.'assets/php/common/manager.php');
|
||||
require_once($prefix.'assets/php/common/cinema_dao.php');
|
||||
include_once($prefix.'assets/php/includes/hall.php');
|
||||
include_once($prefix.'assets/php/includes/session.php');
|
||||
require_once($prefix.'assets/php/includes/manager.php');
|
||||
require_once($prefix.'assets/php/includes/cinema_dao.php');
|
||||
include_once('./includes/formHall.php');
|
||||
include_once('./includes/formSession.php');
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
require_once('../assets/php/form.php');
|
||||
include_once('../assets/php/common/user.php');
|
||||
include_once('../assets/php/includes/user.php');
|
||||
|
||||
class FormChangeEmail extends Form {
|
||||
//Constants:
|
||||
@ -24,6 +24,7 @@ class FormChangeEmail extends Form {
|
||||
<fieldset id='email_usuario'><pre>".$htmlErroresGlobales."</pre>
|
||||
<legend>Nuevo email de usuario</legend>
|
||||
<input type='text' name='new_email' id='new_email' value='' placeholder='Nuevo Email' required/><pre>".$errorEmail."</pre>
|
||||
<span id='emailValid'>✔</span></span><span id='emailInvalid'>❌</span>
|
||||
<input type='text' name='remail' id='remail' value='' placeholder='Repita el email' required/><pre>".$errorEmail2."</pre>
|
||||
<input type='password' name='pass' id='pass' value='' placeholder='Contraseña' required/><pre>".$errorPassword."</pre>
|
||||
</fieldset>
|
||||
@ -73,20 +74,28 @@ class FormChangeEmail extends Form {
|
||||
</div>
|
||||
";
|
||||
} else {
|
||||
$bd->changeUserEmail(unserialize($_SESSION['user'])->getId(), $email);
|
||||
$_SESSION['message'] = "<div class='row'>
|
||||
<div class='column side'></div>
|
||||
<div class='column middle'>
|
||||
<div class='code info'>
|
||||
<h1>Operacion realizada con exito</h1><hr />
|
||||
<p>Se ha modificado su email correctamente.</p>
|
||||
<a href=''><button>Cerrar Mensaje</button></a>
|
||||
$user = $bd->selectUserEmail($email);
|
||||
if ($user->data_seek(0)){
|
||||
$result[] = "El email ya está registrado.";
|
||||
} else {
|
||||
$bd->changeUserEmail(unserialize($_SESSION['user'])->getId(), $email);
|
||||
$user = $bd->selectUser(unserialize($_SESSION['user'])->getName(), $password);
|
||||
$_SESSION['user'] = serialize($user);
|
||||
$_SESSION["nombre"] = $user->getName();
|
||||
$_SESSION['message'] = "<div class='row'>
|
||||
<div class='column side'></div>
|
||||
<div class='column middle'>
|
||||
<div class='code info'>
|
||||
<h1>Operacion realizada con exito</h1><hr />
|
||||
<p>Se ha modificado su email correctamente.</p>
|
||||
<a href=''><button>Cerrar Mensaje</button></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class='column side'></div>
|
||||
</div>
|
||||
<div class='column side'></div>
|
||||
</div>
|
||||
";
|
||||
$result = './?option=manage_profile';
|
||||
";
|
||||
$result = './?option=manage_profile';
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
require_once('../assets/php/form.php');
|
||||
include_once('../assets/php/common/user.php');
|
||||
include_once('../assets/php/common/user_dao.php');
|
||||
include_once('../assets/php/includes/user.php');
|
||||
include_once('../assets/php/includes/user_dao.php');
|
||||
|
||||
class FormChangeName extends Form {
|
||||
|
||||
@ -23,6 +23,7 @@ class FormChangeName extends Form {
|
||||
<fieldset id='nombre_usuario'><pre>".$htmlErroresGlobales."</pre>
|
||||
<legend>Nuevo Nombre de usuario</legend>
|
||||
<input type='text' name='new_name' id='new_name' value='' placeholder='Nuevo Nombre' required/><pre>".$errorNombre."</pre>
|
||||
<span id='userValid'>✔</span><span id='userWarning'>⚠</span></span><span id='userInvalid'>❌</span>
|
||||
<input type='text' name='rename' id='rename' value='' placeholder='Repita el nombre' required/><pre>".$errorNombre2."</pre>
|
||||
<input type='password' name='pass' id='pass' value='' placeholder='Contraseña' required/><pre>".$errorPassword."</pre>
|
||||
</fieldset>
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
require_once('../assets/php/form.php');
|
||||
include_once('../assets/php/common/user.php');
|
||||
include_once('../assets/php/includes/user.php');
|
||||
|
||||
class FormChangePass extends Form {
|
||||
//Constants:
|
||||
const HTML5_PASS_REGEXP = '^(?=\w*\d)(?=\w*[A-Z])(?=\w*[a-z])\S{4,16}$';
|
||||
|
||||
public function __construct() {
|
||||
$options = array("action" => "./?option=manage_profile");
|
||||
@ -14,14 +16,15 @@ class FormChangePass extends Form {
|
||||
// Se generan los mensajes de error si existen.
|
||||
$htmlErroresGlobales = self::generaListaErroresGlobales($errores);
|
||||
$errorOldPass = self::createMensajeError($errores, 'old_pass', 'span', array('class' => 'error'));
|
||||
$errorPassword = self::createMensajeError($errores, 'pass', 'span', array('class' => 'error'));
|
||||
$errorPassword = self::createMensajeError($errores, 'new_pass', 'span', array('class' => 'error'));
|
||||
$errorPassword2 = self::createMensajeError($errores, 'repass', 'span', array('class' => 'error'));
|
||||
|
||||
$html = "<div class='row'>
|
||||
<fieldset id='contraseña_usuario'><pre>".$htmlErroresGlobales."</pre>
|
||||
<legend>Nueva Contraseña</legend>
|
||||
<input type='password' name='old_pass' id='old_pass' value='' placeholder='Contraseña Actual' required/><pre>".$errorOldPass."</pre>
|
||||
<input type='password' name='pass' id='pass' value='' placeholder='Nueva Contraseña' required/><pre>".$errorPassword."</pre>
|
||||
<input type='password' name='new_pass' id='new_pass' value='' placeholder='Nueva Contraseña' required/><pre>".$errorPassword."</pre>
|
||||
<span id='passValid'>✔</span><span id='passWarning'>⚠</span></span><span id='passInvalid'>❌</span>
|
||||
<input type='password' name='repass' id='repass' value='' placeholder='Repita la nueva contraseña' required/><pre>".$errorPassword2."</pre>
|
||||
</fieldset>
|
||||
<div class='actions'>
|
||||
@ -41,9 +44,9 @@ class FormChangePass extends Form {
|
||||
$result['old_pass'] = "El password tiene que tener\n una longitud de al menos\n 4 caracteres.";
|
||||
}
|
||||
|
||||
$password = $this->test_input($datos['pass']) ?? null;
|
||||
if ( empty($password) || mb_strlen($password) < 4 ) {
|
||||
$result['pass'] = "El password tiene que tener una\n longitud de al menos\n 4 caracteres.";
|
||||
$password = $this->test_input($datos['new_pass']) ?? null;
|
||||
if ( empty($password) || !mb_ereg_match(self::HTML5_PASS_REGEXP, $password) ) {
|
||||
$result['new_pass'] = "El password tiene que tener\n una longitud de al menos\n 4 caracteres 1 mayúscula y 1 número.";
|
||||
}
|
||||
$password2 = $this->test_input($datos['repass']) ?? null;
|
||||
if ( empty($password2) || strcmp($password, $password2) !== 0 ) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
require_once('../assets/php/form.php');
|
||||
include_once('../assets/php/common/user.php');
|
||||
include_once('../assets/php/common/user_dao.php');
|
||||
include_once('../assets/php/includes/user.php');
|
||||
include_once('../assets/php/includes/user_dao.php');
|
||||
|
||||
class FormDeleteAccount extends Form {
|
||||
//Constants:
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
require_once($prefix.'assets/php/common/user.php');
|
||||
require_once($prefix.'assets/php/includes/user.php');
|
||||
|
||||
class UserPanel {
|
||||
//Atributes:
|
||||
|
@ -1,11 +1,12 @@
|
||||
<?php
|
||||
|
||||
include_once($prefix.'assets/php/common/user_dao.php');
|
||||
include_once($prefix.'assets/php/includes/user_dao.php');
|
||||
include_once($prefix.'assets/php/form.php');
|
||||
|
||||
class FormRegister extends Form {
|
||||
//Constants:
|
||||
const HTML5_EMAIL_REGEXP = '^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$';
|
||||
const HTML5_EMAIL_REGEXP = '^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$';
|
||||
const HTML5_PASS_REGEXP = '^(?=\w*\d)(?=\w*[A-Z])(?=\w*[a-z])\S{4,16}$';
|
||||
|
||||
//Atributes:
|
||||
private $user; // User who is going to log-in.
|
||||
@ -18,21 +19,24 @@ class FormRegister extends Form {
|
||||
//Methods:
|
||||
|
||||
protected function generaCamposFormulario($datos, $errores = array()){
|
||||
//$nombre = $datos['name'] ?? '';
|
||||
//$nombre = $datos['new_name'] ?? '';
|
||||
|
||||
// Se generan los mensajes de error si existen.
|
||||
$htmlErroresGlobales = self::generaListaErroresGlobales($errores);
|
||||
$errorNombre = self::createMensajeError($errores, 'name', 'span', array('class' => 'error'));
|
||||
$errorEmail = self::createMensajeError($errores, 'email', 'span', array('class' => 'error'));
|
||||
$errorPassword = self::createMensajeError($errores, 'pass', 'span', array('class' => 'error'));
|
||||
$errorNombre = self::createMensajeError($errores, 'new_name', 'span', array('class' => 'error'));
|
||||
$errorEmail = self::createMensajeError($errores, 'new_email', 'span', array('class' => 'error'));
|
||||
$errorPassword = self::createMensajeError($errores, 'new_pass', 'span', array('class' => 'error'));
|
||||
$errorPassword2 = self::createMensajeError($errores, 'repass', 'span', array('class' => 'error'));
|
||||
|
||||
$html = "<div class='row'>
|
||||
<fieldset id='datos_personales'><pre>".$htmlErroresGlobales."</pre>
|
||||
<legend>Datos personales</legend>
|
||||
<input type='text' name='name' id='name' value='' placeholder='Nombre de Usuario' required/><pre>".$errorNombre."</pre>
|
||||
<input type='email' name='email' id='email' value='' placeholder='Email' required/><pre>".$errorEmail."</pre>
|
||||
<input type='password' name='pass' id='pass' value='' placeholder='Contraseña' required/><pre>".$errorPassword."</pre>
|
||||
<input type='text' name='new_name' id='new_name' value='' placeholder='Nombre de Usuario' required/><pre>".$errorNombre."</pre>
|
||||
<span id='userValid'>✔</span><span id='userWarning'>⚠</span></span><span id='userInvalid'>❌</span>
|
||||
<input type='email' name='new_email' id='new_email' value='' placeholder='Email' required/><pre>".$errorEmail."</pre>
|
||||
<span id='emailValid'>✔</span></span><span id='emailInvalid'>❌</span>
|
||||
<input type='password' name='new_pass' id='new_pass' value='' placeholder='Contraseña' required/><pre>".$errorPassword."</pre>
|
||||
<span id='passValid'>✔</span><span id='passWarning'>⚠</span></span><span id='passInvalid'>❌</span>
|
||||
<input type='password' name='repass' id='repass' value='' placeholder='Repita la contraseña' required/><pre>".$errorPassword2."</pre>
|
||||
</fieldset>
|
||||
<div class='verify'>
|
||||
@ -51,20 +55,20 @@ class FormRegister extends Form {
|
||||
protected function procesaFormulario($datos){
|
||||
$result = array();
|
||||
|
||||
$nombre = $this->test_input($datos['name']) ?? null;
|
||||
$nombre = $this->test_input($datos['new_name']) ?? null;
|
||||
$nombre = strtolower($nombre);
|
||||
if ( empty($nombre) || mb_strlen($nombre) < 3 || mb_strlen($nombre) > 8 ) {
|
||||
$result['name'] = "El nombre tiene que tener\n una longitud de al menos\n 3 caracteres\n y menos de 8 caracteres.";
|
||||
$result['new_name'] = "El nombre tiene que tener\n una longitud de al menos\n 3 caracteres\n y menos de 8 caracteres.";
|
||||
}
|
||||
|
||||
$email = $this->test_input($datos['email']) ?? null;
|
||||
$email = $this->test_input($datos['new_email']) ?? null;
|
||||
if ( empty($email) || !mb_ereg_match(self::HTML5_EMAIL_REGEXP, $email) ) {
|
||||
$result['email'] = "El email no es válido.";
|
||||
$result['new_email'] = "El email no es válido.";
|
||||
}
|
||||
|
||||
$password = $this->test_input($datos['pass']) ?? null;
|
||||
if ( empty($password) || mb_strlen($password) < 4 ) {
|
||||
$result['pass'] = "El password tiene que tener\n una longitud de al menos\n 4 caracteres.";
|
||||
$password = $this->test_input($datos['new_pass']) ?? null;
|
||||
if ( empty($password) || !mb_ereg_match(self::HTML5_PASS_REGEXP, $password) ) {
|
||||
$result['new_pass'] = "El password tiene que tener\n una longitud de al menos\n 4 caracteres 1 mayúscula y 1 número.";
|
||||
}
|
||||
$password2 = $this->test_input($datos['repass']) ?? null;
|
||||
if ( empty($password2) || strcmp($password, $password2) !== 0 ) {
|
||||
@ -79,15 +83,20 @@ class FormRegister extends Form {
|
||||
$result[] = "El usuario ya existe.";
|
||||
}
|
||||
else{
|
||||
$bd->createUser("", $nombre, $email, $password, "user");
|
||||
$this->user = $bd->selectUser($nombre, $password);
|
||||
if ($this->user) {
|
||||
$this->user->setPass(null);
|
||||
$_SESSION["user"] = serialize($this->user);
|
||||
$_SESSION["nombre"] = $this->user->getName();
|
||||
$_SESSION["rol"] = $this->user->getRol();
|
||||
$_SESSION["login"] = true;
|
||||
$result = "../register/register.php";
|
||||
$this->user = $bd->selectUserEmail($email);
|
||||
if ($this->user->data_seek(0)) {
|
||||
$result[] = "El email ya está registrado.";
|
||||
} else {
|
||||
$bd->createUser("", $nombre, $email, $password, "user");
|
||||
$this->user = $bd->selectUser($nombre, $password);
|
||||
if ($this->user) {
|
||||
$this->user->setPass(null);
|
||||
$_SESSION["user"] = serialize($this->user);
|
||||
$_SESSION["nombre"] = $this->user->getName();
|
||||
$_SESSION["rol"] = $this->user->getRol();
|
||||
$_SESSION["login"] = true;
|
||||
$result = "../register/register.php";
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user