Comprobado toda la logica/seguridad.
En teoria falta actualizar la estructura a como me dijo oscar esta mañana? algo asi
This commit is contained in:
parent
1af724f0a1
commit
b364c69dc8
@ -1,61 +1,66 @@
|
|||||||
<?php
|
<?php
|
||||||
require('./includes/hall_dto.php');
|
//General Config File:
|
||||||
require('./includes/session_dto.php');
|
require_once('../assets/php/config.php');
|
||||||
require('../panel_admin/includes/film_dto.php');
|
|
||||||
|
include_once('./includes/formHall.php');
|
||||||
|
require_once('./includes/hall_dto.php');
|
||||||
|
|
||||||
|
require_once('./includes/session_dto.php');
|
||||||
include_once('./includes/session_dao.php');
|
include_once('./includes/session_dao.php');
|
||||||
|
|
||||||
$r1 = new HallDTO(1,20,20,30); //Esto se deberia cambiar por una llamada a una lista de salas
|
require_once('../panel_admin/includes/film_dto.php');
|
||||||
$r2 = new HallDTO(2,10,30,30);
|
include_once('../panel_admin/includes/film_dao.php');
|
||||||
$rooms = array($r1, $r2);
|
$cinema = "1";
|
||||||
|
|
||||||
|
$formHall = new FormHall();
|
||||||
|
$formHall->processesForm(null, $cinema, null, null, "list");
|
||||||
|
|
||||||
require_once('./includes/listFilms.php');
|
|
||||||
$filmList = new Film_DAO('complucine');
|
$filmList = new Film_DAO('complucine');
|
||||||
$films = $filmList->allFilmData();
|
if($filmList){
|
||||||
|
$films = $filmList->allFilmData();
|
||||||
|
}else {
|
||||||
|
$films = null;
|
||||||
|
}
|
||||||
|
|
||||||
//DISCLAIMER; sabemos que si se edita la ulr se pueden acceder a datos de una sesion que no pertenece al usuario y que incluso puede hasta editarlas/borrarlas en la base de datos
|
//DISCLAIMER; sabemos que si se edita la ulr se pueden acceder a datos de una sesion que no pertenece al usuario y que incluso puede hasta editarlas/borrarlas en la base de datos
|
||||||
if(isset($_REQUEST['option']) && $_REQUEST['option'] == 'edit') {
|
if(isset($_REQUEST['option']) && $_REQUEST['option'] == 'edit') {
|
||||||
$bd = new sessionDAO('complucine');
|
echo "<div class = \"column middle\">
|
||||||
if($bd){
|
<h2>Editar/Eliminar Sesion</h2>
|
||||||
$session = ($bd->sessionData($_GET["id"]))->fetch_assoc();
|
<form method=\"post\" id=\"edit_ses\" action=\"validateSession.php\">
|
||||||
echo "<h2>Editar/Eliminar Sesion</h2>
|
|
||||||
<form method=\"post\" id=\"edit_ses\" action=\"validate.php\">
|
|
||||||
<div class=\"row\">
|
<div class=\"row\">
|
||||||
<fieldset id=\"datos\">
|
<fieldset id=\"datos\">
|
||||||
<legend>Datos</legend>
|
<legend>Datos</legend>
|
||||||
<input type=\"hidden\" name=\"cinema\" value =\"1\" />
|
<input name=\"cinema\" type=\"hidden\" value=\"". $_POST['idcinema']."\">
|
||||||
<input type=\"hidden\" name=\"id\" value =\"". $_GET["id"] ." \" />
|
<input name=\"id\" type=\"hidden\" value=\"". $_POST['id']."\">
|
||||||
<div class=\"_price\">
|
<div class=\"_price\">
|
||||||
<input type=\"number\" name=\"price\" id=\"price\" value=\"". $session['seat_price'] ."\"min=\"0\" placeholder=\"Precio de la entrada\" required/>
|
<input type=\"number\" name=\"price\" id=\"price\" value=\"". $_POST['price'] ."\"min=\"0\" placeholder=\"Precio de la entrada\" required/>
|
||||||
</div>
|
</div>
|
||||||
<select name=\"hall\" class=\"button large\">";
|
<select name=\"hall\" class=\"button large\">";
|
||||||
foreach($rooms as $r){
|
foreach($formHall->getReply() as $r){
|
||||||
if($r->getNumber() == $session['idhall']){
|
if($r->getNumber() == $_POST['hall']){
|
||||||
echo "<option value=\"". $r->getNumber() ." \"selected> Sala ". $r->getNumber() . "</option>";
|
echo "<option value=\"". $r->getNumber() ." \"selected> Sala ". $r->getNumber() . "</option>";
|
||||||
}else{
|
}else{
|
||||||
echo "<option value=\"". $r->getNumber() ." \"> Sala ". $r->getNumber() . "</option>";
|
echo "<option value=\"". $r->getNumber() ." \"> Sala ". $r->getNumber() . "</option>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo "<div class=\"_format\">
|
echo "
|
||||||
<input type=\"text\" name=\"format\" id=\"format\" value=\"". $session['format'] ."\" placeholder=\"Formato\" required/>
|
<div class=\"_format\">
|
||||||
|
<input type=\"text\" name=\"format\" id=\"format\" value=\"". $_POST['format'] ."\" placeholder=\"Formato\" required/>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset id=\"Horario\">
|
<fieldset id=\"Horario\">
|
||||||
<legend>Horario</legend>
|
<legend>Horario</legend>
|
||||||
<div class=\"_start_time\">
|
<div class=\"_start_time\">
|
||||||
<input type=\"time\" name=\"start\" id=\"start_time\" value=\"". $session['start_time'] ."\" placeholder=\"Hora de inicio\" required/>
|
<input type=\"time\" name=\"start\" id=\"start_time\" value=\"". $_POST['start'] ."\" placeholder=\"Hora de inicio\" required/>
|
||||||
</div>
|
</div>
|
||||||
<div class=\"_date\">
|
<div class=\"_date\">
|
||||||
<input type=\"date\" name=\"date\" id=\"date\" value=\"". $session['date'] ."\"Fecha de inicio\" required/>
|
<input type=\"date\" name=\"date\" id=\"date\" value=\"". $_POST['date'] ."\"Fecha de inicio\" required/>
|
||||||
</div>
|
|
||||||
<div class=\"_repeat\">
|
|
||||||
<br> Introducir un numero para añadir esta sesion a los futuros X dias
|
|
||||||
<input type=\"number\" name=\"repeat\" id=\"repeat\" title=\"Repetir esta sesion durante X dias\" min=\"0\" max=\"31\" placeholder=\"Repetir X dias\"/>
|
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<div class=\"actions\">
|
<div class=\"actions\">
|
||||||
<input type=\"submit\" name=\"edit\" value=\"Editar\" class=\"primary\" />
|
<input type=\"submit\" name=\"edit\" value=\"Editar\" class=\"button\" />
|
||||||
<input type=\"reset\" id=\"reset\" value=\"Limpiar\" />
|
<input type=\"reset\" id=\"reset\" value=\"Limpiar\" />
|
||||||
<input type=\"submit\" name=\"del\" value=\"Eliminar\" class=\"primary\" />
|
<input type=\"submit\" name=\"del\" value=\"Eliminar\" class=\"button\" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
@ -63,17 +68,18 @@
|
|||||||
<div class=\"column side\">
|
<div class=\"column side\">
|
||||||
<select name=\"film\" form=\"edit_ses\" class=\"button large\">";
|
<select name=\"film\" form=\"edit_ses\" class=\"button large\">";
|
||||||
foreach($films as $f){
|
foreach($films as $f){
|
||||||
if($f->getId() == $session['idfilm']){
|
if($f->getId() == $_POST['idfilm']){
|
||||||
echo "<option value=\"". $f->getId() ." \"selected> " . $f->getId() . "|" . $f->getTittle() ." Idioma: " . $f->getLanguage() . "</option>";
|
echo "<option value=\"". $f->getId() ." \"selected> " . $f->getId() . "|" . $f->getTittle() ." Idioma: " . $f->getLanguage() . "</option>";
|
||||||
}else{
|
}else{
|
||||||
echo "<option value=\"". $f->getId() ." \"> " . $f->getId() . "|" . $f->getTittle() ." Idioma: " . $f->getLanguage() . "</option>";
|
echo "<option value=\"". $f->getId() ." \"> " . $f->getId() . "|" . $f->getTittle() ." Idioma: " . $f->getLanguage() . "</option>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo "</div>";
|
echo "</div>";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else{
|
else{
|
||||||
echo "<h2>Crear Sesion</h2>
|
echo "<div class = \"column middle\">
|
||||||
|
<h2>Crear Sesion</h2>
|
||||||
<form method=\"post\" id=\"new_ses\" action=\"validateSession.php\">
|
<form method=\"post\" id=\"new_ses\" action=\"validateSession.php\">
|
||||||
<div class=\"row\">
|
<div class=\"row\">
|
||||||
<fieldset id=\"datos\">
|
<fieldset id=\"datos\">
|
||||||
@ -83,14 +89,17 @@
|
|||||||
<input type=\"number\" name=\"price\" id=\"price\" min=\"0\" placeholder=\"Precio de la entrada\" required/>
|
<input type=\"number\" name=\"price\" id=\"price\" min=\"0\" placeholder=\"Precio de la entrada\" required/>
|
||||||
</div>
|
</div>
|
||||||
<select name=\"hall\" class=\"button large\">";
|
<select name=\"hall\" class=\"button large\">";
|
||||||
foreach($rooms as $r){
|
foreach($formHall->getReply() as $r){
|
||||||
if($r->getid() == $_POST['hall']){
|
if($r->getNumber() == $_POST['hall']){
|
||||||
echo "<option value=\"". $r->getid() ." \"selected> Sala ". $r->getid() . "</option>";
|
echo "
|
||||||
}else{
|
<option value=\"". $r->getNumber() ." \"selected> Sala ". $r->getNumber() . "</option>";
|
||||||
echo "<option value=\"". $r->getid() ." \"> Sala ". $r->getid() . "</option>";
|
}else{
|
||||||
|
echo "
|
||||||
|
<option value=\"". $r->getNumber() ." \"> Sala ". $r->getNumber() . "</option>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo "<div class=\"_format\">
|
echo "
|
||||||
|
<div class=\"_format\">
|
||||||
<input type=\"text\" name=\"format\" id=\"format\" value=\"\" placeholder=\"Formato\" required/>
|
<input type=\"text\" name=\"format\" id=\"format\" value=\"\" placeholder=\"Formato\" required/>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
@ -5,8 +5,8 @@ include_once('../assets/php/form.php');
|
|||||||
class FormHall extends Form {
|
class FormHall extends Form {
|
||||||
|
|
||||||
//Atributes:
|
//Atributes:
|
||||||
private $correct; // Indicates if the session is correct.
|
private $correct;
|
||||||
private $reply; // Validation response
|
private $reply;
|
||||||
private $option;
|
private $option;
|
||||||
private $halls;
|
private $halls;
|
||||||
|
|
||||||
@ -20,7 +20,8 @@ class FormHall extends Form {
|
|||||||
|
|
||||||
//Returns validation response:
|
//Returns validation response:
|
||||||
public function getReply() {
|
public function getReply() {
|
||||||
//Habria que comprobar si realmente se ha validado la respuesta antes de escribir una respuesta correcta
|
|
||||||
|
echo "<p> se va a devolver una respuesta </p>";
|
||||||
if($this->correct){
|
if($this->correct){
|
||||||
if($this->option == "new"){
|
if($this->option == "new"){
|
||||||
$this->reply = "<h1> Operacion realizada con exito </h1><hr />
|
$this->reply = "<h1> Operacion realizada con exito </h1><hr />
|
||||||
@ -35,6 +36,7 @@ class FormHall extends Form {
|
|||||||
<p> Se ha eliminado la sala correctamente en la base de datos.</p>
|
<p> Se ha eliminado la sala correctamente en la base de datos.</p>
|
||||||
<a href='../panel_manager/index.php'><button>Panel Gerente</button></a>";
|
<a href='../panel_manager/index.php'><button>Panel Gerente</button></a>";
|
||||||
}else if($this->option == "list"){
|
}else if($this->option == "list"){
|
||||||
|
echo "<p> se va a devolver la lista </p>";
|
||||||
$this->reply = $this->halls;
|
$this->reply = $this->halls;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -56,7 +58,7 @@ class FormHall extends Form {
|
|||||||
if($option == "list"){
|
if($option == "list"){
|
||||||
$this->halls = $bd->getAllHalls($cinema);
|
$this->halls = $bd->getAllHalls($cinema);
|
||||||
}else {
|
}else {
|
||||||
/*
|
/* TODO
|
||||||
$start = date('H:i:s', strtotime( $start ) );
|
$start = date('H:i:s', strtotime( $start ) );
|
||||||
|
|
||||||
if($option == "new"){
|
if($option == "new"){
|
||||||
|
@ -2,25 +2,22 @@
|
|||||||
include_once('session_dao.php');
|
include_once('session_dao.php');
|
||||||
include_once('../assets/php/form.php');
|
include_once('../assets/php/form.php');
|
||||||
|
|
||||||
|
//Receive data from froms and prepare the correct response
|
||||||
class FormSession extends Form {
|
class FormSession extends Form {
|
||||||
|
//Atributes
|
||||||
//Atributes:
|
private $correct;
|
||||||
private $correct; // Indicates if the session is correct.
|
private $reply;
|
||||||
private $reply; // Validation response
|
|
||||||
private $option;
|
private $option;
|
||||||
private $sessions;
|
private $sessions;
|
||||||
|
|
||||||
//Constructor:
|
//Constructor:
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
parent::__construct('formSession');
|
parent::__construct('formSession');
|
||||||
$this->reply = array();
|
$this->reply = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Methods:
|
//Methods:
|
||||||
|
|
||||||
//Returns validation response:
|
|
||||||
public function getReply() {
|
public function getReply() {
|
||||||
//Habria que comprobar si realmente se ha validado la respuesta antes de escribir una respuesta correcta
|
|
||||||
if($this->correct){
|
if($this->correct){
|
||||||
if($this->option == "new"){
|
if($this->option == "new"){
|
||||||
$this->reply = "<h1> Operacion realizada con exito </h1><hr />
|
$this->reply = "<h1> Operacion realizada con exito </h1><hr />
|
||||||
@ -45,46 +42,39 @@ class FormSession extends Form {
|
|||||||
return $this->reply;
|
return $this->reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Process form:
|
|
||||||
public function processesForm($id, $film, $hall, $cinema, $date, $start, $price, $format, $repeat, $option) {
|
public function processesForm($id, $film, $hall, $cinema, $date, $start, $price, $format, $repeat, $option) {
|
||||||
$this->option = $option;
|
$this->option = $option;
|
||||||
$this->correct = true;
|
$this->correct = true;
|
||||||
$bd = new sessionDAO('complucine');
|
|
||||||
|
|
||||||
$date = date('Y-m-d', strtotime( $date ) );
|
$bd = new sessionDAO('complucine');
|
||||||
|
|
||||||
if($bd ){
|
if($bd ){
|
||||||
if($option == "list"){
|
if($option == "list"){
|
||||||
$this->sessions = $bd->getAllSessionsFromDateHallAndCinema($cinema, $hall, $date);
|
$this->sessions = $bd->getAllSessionsFromACinemaHallDate($cinema, $hall, $date);
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
|
|
||||||
$start = date('H:i:s', strtotime( $start ) );
|
|
||||||
|
|
||||||
if($option == "new"){
|
if($option == "new"){
|
||||||
|
$searchSession = $bd->searchSession($cinema, $hall, $start, $date);
|
||||||
$selectSession = $bd->selectSession($cinema, $hall, $start, $date);
|
if($searchSession) {
|
||||||
if($selectSession && $selectSession->num_rows >= 1) {
|
|
||||||
$this->correct = false;
|
$this->correct = false;
|
||||||
} else{
|
} else{
|
||||||
$bd->createSession(null, $film, $hall,$cinema, $date, $start, $price, $format);
|
$bd->createSession(null, $film, $hall,$cinema, $date, $start, $price, $format);
|
||||||
}
|
}
|
||||||
|
|
||||||
mysqli_free_result($selectSession);
|
|
||||||
|
|
||||||
} else if ($option == "del"){
|
} else if ($option == "del"){
|
||||||
$bd->deleteSession($id);
|
$bd->deleteSession($id);
|
||||||
|
|
||||||
} else if ($option == "edit"){
|
} else if ($option == "edit"){
|
||||||
$bd->editSession($id, $film, $hall, $cinema, $date, $start, $price, $format);
|
$bd->editSession($id, $film, $hall, $cinema, $date, $start, $price, $format);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($repeat > "0"){
|
if($repeat > "0"){
|
||||||
$repeat--;
|
$repeat--;
|
||||||
$date = date('Y-m-d', strtotime( $date. ' +1 day') );
|
$date = date('Y-m-d', strtotime( $date. ' +1 day') );
|
||||||
$this->processesForm($film, $hall, $cinema, $date, $start, $price, $format, $repeat);
|
$this->processesForm($id, $film, $hall, $cinema, $date, $start, $price, $format, $repeat, $option);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {$this->correct = false;}
|
} else {$this->correct = false;}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,16 +3,16 @@
|
|||||||
include_once('session_dto.php');
|
include_once('session_dto.php');
|
||||||
|
|
||||||
class SessionDAO extends DAO {
|
class SessionDAO extends DAO {
|
||||||
|
|
||||||
//Constructor:
|
//Constructor:
|
||||||
function __construct($bd_name){
|
function __construct($bd_name){
|
||||||
parent::__construct($bd_name);
|
parent::__construct($bd_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Methods:
|
//Methods:
|
||||||
|
|
||||||
//Create a new Session.
|
|
||||||
public function createSession($id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format){
|
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`)
|
$sql = sprintf( "INSERT INTO `session` (`id`, `idfilm`, `idhall`, `idcinema`, `date`, `start_time`, `seat_price`, `format`)
|
||||||
VALUES ('%d', '%d', '%d', '%d', '%s', '%s', '%d', '%s')",
|
VALUES ('%d', '%d', '%d', '%d', '%s', '%s', '%d', '%s')",
|
||||||
@ -31,23 +31,28 @@
|
|||||||
return $resul;
|
return $resul;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Returns a query to check if the session in this cinema, hall and scheudle exists.
|
//Returns the count of the session searched
|
||||||
public function selectSession($cinema, $hall, $start, $date){
|
public function searchSession($cinema, $hall, $startTime, $date){
|
||||||
if($start == null){
|
$date = date('Y-m-d', strtotime( $date ) );
|
||||||
$sql = sprintf( "SELECT * FROM session WHERE
|
$startTime = date('H:i:s', strtotime( $startTime ) );
|
||||||
idcinema = '%s' AND idhall = '%s' AND date = '%s'",
|
|
||||||
$cinema, $hall, $date);
|
$sql = sprintf( "SELECT COUNT(*) FROM session WHERE
|
||||||
}else{
|
|
||||||
$sql = sprintf( "SELECT * FROM session WHERE
|
|
||||||
idcinema = '%s' AND idhall = '%s' AND date = '%s' AND start_time = '%s'",
|
idcinema = '%s' AND idhall = '%s' AND date = '%s' AND start_time = '%s'",
|
||||||
$cinema, $hall, $date, $start);
|
$cinema, $hall, $date, $startTime);
|
||||||
}
|
|
||||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||||
return $resul;
|
|
||||||
|
$session = null;
|
||||||
|
$session = mysqli_fetch_array($resul);
|
||||||
|
|
||||||
|
mysqli_free_result($resul);
|
||||||
|
|
||||||
|
return $session[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Returns a query to get all the session's data.
|
||||||
|
public function getAllSessionsFromACinemaHallDate($cinema, $hall, $date){
|
||||||
|
$date = date('Y-m-d', strtotime( $date ) );
|
||||||
|
|
||||||
public function getAllSessionsFromDateHallAndCinema($cinema, $hall, $date){
|
|
||||||
$sql = sprintf( "SELECT * FROM session WHERE
|
$sql = sprintf( "SELECT * FROM session WHERE
|
||||||
idcinema = '%s' AND idhall = '%s' AND date = '%s'",
|
idcinema = '%s' AND idhall = '%s' AND date = '%s'",
|
||||||
$cinema, $hall, $date);
|
$cinema, $hall, $date);
|
||||||
@ -58,14 +63,15 @@
|
|||||||
while($fila=mysqli_fetch_array($resul)){
|
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"]);
|
$sessions[] = $this->loadSession($fila["id"], $fila["idfilm"], $fila["idhall"], $fila["idcinema"], $fila["date"], $fila["start_time"], $fila["seat_price"], $fila["format"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
mysqli_free_result($resul);
|
mysqli_free_result($resul);
|
||||||
|
|
||||||
return $sessions;
|
return $sessions;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Edit Session.
|
|
||||||
public function editSession($id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format){
|
public function editSession($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( "UPDATE `session`
|
$sql = sprintf( "UPDATE `session`
|
||||||
SET `idfilm` = '%d' , `idhall` = '%d', `idcinema` = '%d', `date` = '%s',
|
SET `idfilm` = '%d' , `idhall` = '%d', `idcinema` = '%d', `date` = '%s',
|
||||||
@ -78,7 +84,6 @@
|
|||||||
return $resul;
|
return $resul;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Delete Session.
|
|
||||||
public function deleteSession($id){
|
public function deleteSession($id){
|
||||||
|
|
||||||
$sql = sprintf( "DELETE FROM `session` WHERE `session`.`id` = '%d';",$id);
|
$sql = sprintf( "DELETE FROM `session` WHERE `session`.`id` = '%d';",$id);
|
||||||
@ -88,7 +93,6 @@
|
|||||||
return $resul;
|
return $resul;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Create a new Session Data Transfer Object.
|
//Create a new Session Data Transfer Object.
|
||||||
public function loadSession( $id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format){
|
public function loadSession( $id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format){
|
||||||
return new SessionDTO( $id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format);
|
return new SessionDTO( $id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format);
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
class SessionDTO implements SessionsDTO {
|
class SessionDTO implements SessionsDTO {
|
||||||
|
|
||||||
//Attributes:
|
//Attributes:
|
||||||
private $_id; //Session Id.
|
private $_id;
|
||||||
private $_idfilm; //Film Id -> deberia ser un objeto tipo pelicula? para poder sacar el nombre de la pelicula en cuestion
|
private $_idfilm;
|
||||||
private $_idhall; //Hall id -> deberia ser un objeto tipo room/hall/sala de cine por lo mismo
|
private $_idhall;
|
||||||
private $_idcinema;
|
private $_idcinema;
|
||||||
private $_date; //Session date.
|
private $_date;
|
||||||
private $_startTime; //Session start time.
|
private $_startTime;
|
||||||
private $_seatPrice; //Seat price.
|
private $_seatPrice;
|
||||||
private $_format; //Type of film: 3D | 4D | normal | subtitle | mute.
|
private $_format;
|
||||||
|
|
||||||
//Constructor:
|
//Constructor:
|
||||||
function __construct($id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format){
|
function __construct($id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format){
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
public function getIdfilm();
|
public function getIdfilm();
|
||||||
public function setIdhall($film);
|
public function setIdhall($film);
|
||||||
public function getIdhall();
|
public function getIdhall();
|
||||||
|
public function setIdcinema($cinema);
|
||||||
|
public function getIdcinema();
|
||||||
public function setDate($date);
|
public function setDate($date);
|
||||||
public function getDate();
|
public function getDate();
|
||||||
public function setStartTime($startTime);
|
public function setStartTime($startTime);
|
||||||
|
@ -1,16 +1,13 @@
|
|||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
<?php
|
<?php
|
||||||
session_start();
|
//General Config File:
|
||||||
|
require_once('../assets/php/config.php');
|
||||||
require_once('../assets/php/template.php');
|
|
||||||
$template = new Template();
|
|
||||||
$prefix = $template->get_prefix();
|
|
||||||
|
|
||||||
include_once('panel_manager.php');
|
include_once('panel_manager.php');
|
||||||
|
|
||||||
$login = false;
|
$login = false;
|
||||||
|
|
||||||
if(isset($_SESSION["login"]) && $_SESSION["nombre"] == "manager") $login = true;
|
if(isset($_SESSION["login"]) && $_SESSION["rol"] == "manager") $login = true;
|
||||||
|
|
||||||
if(isset($_REQUEST['state'])) {
|
if(isset($_REQUEST['state'])) {
|
||||||
$panel = new Panel($_REQUEST['state'],$login);
|
$panel = new Panel($_REQUEST['state'],$login);
|
||||||
@ -18,8 +15,6 @@
|
|||||||
else {
|
else {
|
||||||
$panel = new Panel('',$login);
|
$panel = new Panel('',$login);
|
||||||
}
|
}
|
||||||
// IMPORTANTE:
|
|
||||||
// VERIFICAR QUE ES MANAGER(GERENTE), SI NO, MOSTRAR MENSAJE DE "ERROR"
|
|
||||||
?>
|
?>
|
||||||
<!--
|
<!--
|
||||||
Práctica 2 - Sistemas Web | Grupo D
|
Práctica 2 - Sistemas Web | Grupo D
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
$rooms = array($r1, $r2, $r3, $r4);
|
$rooms = array($r1, $r2, $r3, $r4);
|
||||||
|
|
||||||
function drawHalls($ros){
|
function drawHalls($ros){
|
||||||
echo "
|
echo " <p> Esta vista esta en desarrollo <p>
|
||||||
<div class=\"column middle\">
|
<div class=\"column middle\">
|
||||||
<table class='alt'>
|
<table class='alt'>
|
||||||
<thead>
|
<thead>
|
||||||
@ -21,17 +21,13 @@
|
|||||||
foreach($ros as $r){
|
foreach($ros as $r){
|
||||||
echo "
|
echo "
|
||||||
<tr>
|
<tr>
|
||||||
<!-- AUN NO HEMOS VISTO JAVASCRIPT -->
|
|
||||||
<!-- ADEMÁS, AUNQUE USÁSEMOS JS, ESO NO SE HARÍA CON UN WINDOWS.LOCATION.HREF, DE MOMENTO, USAD LOS BOTONES COMO OS PONGO EL DE AÑADIR -->
|
|
||||||
<!--<td> <button type=\"button\"> Sala ". $r->getNumber() ."</button> </td> -->
|
|
||||||
<td><a href=\"\" class='button'>Sala". $r->getNumber() ."</a></td>
|
<td><a href=\"\" class='button'>Sala". $r->getNumber() ."</a></td>
|
||||||
<!--<td> <button type=\"button\" onClick=\"Javascript:window.location.href = 'index.php?edit_rooms=true';\")\">Editar</button> </td> MAL, POR LO MISMO-->
|
<td><a href=\"index.php?state=rooms\" class='button'>Editar</a></td>
|
||||||
<td><a href=\"index.php?edit_rooms=true\" class='button'>Editar</a></td>
|
|
||||||
</tr>";
|
</tr>";
|
||||||
}
|
}
|
||||||
echo "<tbody>
|
echo "<tbody>
|
||||||
</table>\n";
|
</table>\n";
|
||||||
echo "<a href=\"index.php?edit_sessions=true\" class='button large'>Añadir</a>
|
echo "<a href=\"index.php?state=rooms\" class='button large'>Añadir</a>
|
||||||
</div>";
|
</div>";
|
||||||
}
|
}
|
||||||
drawHalls($rooms);
|
drawHalls($rooms);
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
require('./includes/hall_dto.php');
|
//General Config File:
|
||||||
require('./includes/formHall.php');
|
require_once('../assets/php/config.php');
|
||||||
|
|
||||||
require('./includes/session_dto.php');
|
include_once('./includes/hall_dto.php');
|
||||||
require('./includes/formSession.php');
|
include_once('./includes/formHall.php');
|
||||||
|
|
||||||
require_once('../assets/php/template.php');
|
include_once('./includes/session_dto.php');
|
||||||
$template = new Template();
|
include_once('./includes/formSession.php');
|
||||||
$prefix = $template->get_prefix();
|
|
||||||
|
|
||||||
require($prefix.'panel_admin/includes/film_dto.php');
|
include_once('../panel_admin/includes/film_dto.php');
|
||||||
require($prefix.'/panel_admin/includes/film_dao.php');
|
include_once('../panel_admin/includes/film_dao.php');
|
||||||
|
|
||||||
$formSession = new FormSession();
|
$formSession = new FormSession();
|
||||||
$formHall = new FormHall();
|
$formHall = new FormHall();
|
||||||
@ -27,9 +26,10 @@
|
|||||||
$formHall->processesForm(null, $cinema, null, null, "list");
|
$formHall->processesForm(null, $cinema, null, null, "list");
|
||||||
$formSession->processesForm(null, null, $placeholder_hall, $cinema, $placeholder_date, null, null, null, null, "list");
|
$formSession->processesForm(null, null, $placeholder_hall, $cinema, $placeholder_date, null, null, null, null, "list");
|
||||||
|
|
||||||
echo" <form method=\"post\">
|
echo"
|
||||||
<!--Session Filter -->
|
<!--Session Filter -->
|
||||||
<div class = \"column left\">
|
<div class = \"column middle\">
|
||||||
|
<form method=\"post\" id=\"addfilter\">
|
||||||
<input type=\"date\" name=\"date\" value=\"". $placeholder_date . "\" min=\"2021-01-01\" max=\"2031-12-31\">
|
<input type=\"date\" name=\"date\" value=\"". $placeholder_date . "\" min=\"2021-01-01\" max=\"2031-12-31\">
|
||||||
<select name=\"hall\" class=\"button large\">";
|
<select name=\"hall\" class=\"button large\">";
|
||||||
|
|
||||||
@ -44,11 +44,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo "
|
echo "
|
||||||
|
</select>
|
||||||
<input type=\"submit\" name=\"filter\" value=\"Filtrar\" class=\"button large\" />
|
<input type=\"submit\" name=\"filter\" value=\"Filtrar\" class=\"button large\" />
|
||||||
</div>";
|
</form>
|
||||||
|
</div>";
|
||||||
|
|
||||||
function drawSessions($sessions,$bd){
|
function drawSessions($sessions,$bd){
|
||||||
echo " <!--Session List -->
|
echo " <!--Session List -->
|
||||||
<div class=\"column right\">
|
<div class=\"column side\">
|
||||||
<table class='alt'>
|
<table class='alt'>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -67,13 +70,25 @@
|
|||||||
<td> " . str_replace('_', ' ', $film["tittle"]) . "</a></td>
|
<td> " . str_replace('_', ' ', $film["tittle"]) . "</a></td>
|
||||||
<td> " . $s->getFormat() . "</a></td>
|
<td> " . $s->getFormat() . "</a></td>
|
||||||
<td> " . $s->getSeatPrice() . "</a></td>
|
<td> " . $s->getSeatPrice() . "</a></td>
|
||||||
<td> <input type=\"submit\" name=\"submit\" value=\"Editar\" class=\"button\" formaction=\"./?state=edit_session&option=edit&id=". $s->getid() ."\"/> </td>
|
<form method=\"post\" action=\"./?state=edit_session&option=edit\">
|
||||||
|
|
||||||
|
<input name=\"id\" type=\"hidden\" value=\"".$s->getId()."\">
|
||||||
|
<input name=\"idfilm\" type=\"hidden\" value=\"".$s->getIdfilm()."\">
|
||||||
|
<input name=\"idhall\" type=\"hidden\" value=\"".$s->getIdhall()."\">
|
||||||
|
<input name=\"idcinema\" type=\"hidden\" value=\"".$s->getIdcinema()."\">
|
||||||
|
<input name=\"date\" type=\"hidden\" value=\"".$s->getDate()."\">
|
||||||
|
<input name=\"start\" type=\"hidden\" value=\"".$s->getStartTime()."\">
|
||||||
|
<input name=\"price\" type=\"hidden\" value=\"".$s->getSeatPrice()."\">
|
||||||
|
<input name=\"format\" type=\"hidden\" value=\"".$s->getFormat()."\">
|
||||||
|
|
||||||
|
<td> <input type=\"submit\" id=\"submit\" value=\"Editar\" class=\"button\" > </td>
|
||||||
|
</form>
|
||||||
</tr>";
|
</tr>";
|
||||||
}
|
}
|
||||||
echo "
|
echo "
|
||||||
<tbody>
|
<tbody>
|
||||||
</table>
|
</table>
|
||||||
<input type=\"submit\" name=\"submit\" value=\"Añadir\" class=\"button large\" formaction=\"./?state=edit_session&option=new\">
|
<input type=\"submit\" name=\"submit\" form=\"addfilter\" value=\"Añadir\" class=\"button large\" formaction=\"./?state=edit_session&option=new\">
|
||||||
</div>";
|
</div>";
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -87,13 +102,11 @@
|
|||||||
</div>";
|
</div>";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
echo "<div class=\"column side\">
|
echo "
|
||||||
<p> No hay ninguna session en la sala ". $placeholder_hall . " el dia ". $placeholder_date . "</p>
|
|
||||||
<input type=\"submit\" name=\"submit\" value=\"Añadir\" class=\"button large\" formaction=\"./?state=edit_session&option=new\">
|
<div class=\"column side\">
|
||||||
</div>";
|
<p> No hay ninguna session en la sala ". $placeholder_hall . " el dia ". $placeholder_date . "</p>
|
||||||
|
<input type=\"submit\" name=\"submit\" form=\"addfilter\" value=\"Añadir\" class=\"button large\" formaction=\"./?state=edit_session&option=new\">
|
||||||
|
</div>";
|
||||||
}
|
}
|
||||||
echo "
|
|
||||||
|
|
||||||
</form>";
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
@ -12,16 +12,16 @@
|
|||||||
function showPanel() {
|
function showPanel() {
|
||||||
if($this->login){
|
if($this->login){
|
||||||
switch($this->state) {
|
switch($this->state) {
|
||||||
case 'us_u': require('user_unregistered_view.php'); break;
|
case 'us_u': echo "<p> Esta vista no esta implementada </p>"; break;
|
||||||
case 'us_r': require('user_registered_view.php'); break;
|
case 'us_r': echo "<p> Esta vista no esta implementada </p>"; break;
|
||||||
case 'rooms': require('manage_rooms.php'); break;
|
case 'rooms': require_once('manage_rooms.php'); break;
|
||||||
case 'sessions': require('manage_sessions.php'); break;
|
case 'sessions': require_once('manage_sessions.php'); break;
|
||||||
case 'edit_session': require('edit_sessions.php'); break;
|
case 'edit_session': require_once('edit_sessions.php'); break;
|
||||||
default: require('hello_panel.php'); break;
|
default: require('hello_panel.php'); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
require('no_permisions_panel.php');
|
echo "<h1> Error no tienes los permisos necesarios de gerente</h1>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,31 +1,22 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
//General Config File:
|
||||||
|
require_once('../assets/php/config.php');
|
||||||
//Depuración (BORRAR):
|
|
||||||
ini_set('display_errors', 1);
|
|
||||||
ini_set('display_startup_errors', 1);
|
|
||||||
error_reporting(E_ALL);
|
|
||||||
|
|
||||||
//HTML template:
|
|
||||||
require_once('../assets/php/template.php');
|
|
||||||
$template = new Template();
|
|
||||||
$action ="";
|
|
||||||
$id = null;
|
|
||||||
if(isset($_POST['new'])){
|
|
||||||
$action = "new";
|
|
||||||
} else if (isset($_POST['edit'])){
|
|
||||||
$action = "edit";
|
|
||||||
$id = $_POST["id"];
|
|
||||||
} else if (isset($_POST['del'])){
|
|
||||||
$action = "del";
|
|
||||||
$id = $_POST["id"];
|
|
||||||
}
|
|
||||||
|
|
||||||
//Login form validate:
|
|
||||||
require_once('./includes/formSession.php');
|
require_once('./includes/formSession.php');
|
||||||
$session = new FormSession();
|
$session = new FormSession();
|
||||||
$session->processesForm($id, $_POST["film"], $_POST["hall"], $_POST["cinema"],$_POST["date"],$_POST["start"],$_POST["price"],$_POST["format"],$_POST["repeat"], $action);
|
$reply = "<p> ERROR DE ACCESO </p>" ;
|
||||||
$reply = $session->getReply();
|
|
||||||
|
if(isset($_POST['new'])){
|
||||||
|
$session->processesForm(null, $_POST["film"], $_POST["hall"], $_POST["cinema"],$_POST["date"],$_POST["start"],$_POST["price"],$_POST["format"],$_POST["repeat"], "new");
|
||||||
|
$reply = $session->getReply();
|
||||||
|
|
||||||
|
} else if (isset($_POST['edit'])){
|
||||||
|
$session->processesForm($_POST["id"], $_POST["film"], $_POST["hall"], $_POST["cinema"],$_POST["date"],$_POST["start"],$_POST["price"],$_POST["format"],"0", "edit");
|
||||||
|
$reply = $session->getReply();
|
||||||
|
|
||||||
|
} else if (isset($_POST['del'])){
|
||||||
|
$session->processesForm($_POST["id"], $_POST["film"], $_POST["hall"], $_POST["cinema"],$_POST["date"],$_POST["start"],$_POST["price"],$_POST["format"],"0", "del");
|
||||||
|
$reply = $session->getReply();
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
|
Loading…
Reference in New Issue
Block a user