Add files via upload

This commit is contained in:
Markines16 2021-04-13 21:15:28 +02:00 committed by GitHub
parent 987476b585
commit b0cf43c313
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 175 additions and 47 deletions

View File

@ -0,0 +1,93 @@
<?php
include_once('hall_dao.php');
include_once('../assets/php/form.php');
class FormHall extends Form {
//Atributes:
private $correct; // Indicates if the session is correct.
private $reply; // Validation response
private $option;
private $halls;
//Constructor:
public function __construct() {
parent::__construct('formSession');
$this->reply = array();
}
//Methods:
//Returns validation response:
public function getReply() {
//Habria que comprobar si realmente se ha validado la respuesta antes de escribir una respuesta correcta
if($this->correct){
if($this->option == "new"){
$this->reply = "<h1> Operacion realizada con exito </h1><hr />
<p> Se ha añadido la sala correctamente en la base de datos.</p>
<a href='../panel_manager/index.php'><button>Panel Gerente</button></a>";
}else if($this->option == "edit"){
$this->reply = "<h1> Operacion realizada con exito </h1><hr />
<p> Se ha editado la sala correctamente en la base de datos.</p>
<a href='../panel_manager/index.php'><button>Panel Gerente</button></a>";
}else if($this->option == "del"){
$this->reply = "<h1> Operacion realizada con exito </h1><hr />
<p> Se ha eliminado la sala correctamente en la base de datos.</p>
<a href='../panel_manager/index.php'><button>Panel Gerente</button></a>";
}else if($this->option == "list"){
$this->reply = $this->halls;
}
} else {
$this->reply = "<h1> ERROR </h1><hr />
<p> Ha habido un error en la operacion. Revisa los datos introducidos o ponte en contacto con el administrador de la base de datos.</p>
<a href='../panel_manager/index.php'><button>Panel Gerente</button></a>";
}
return $this->reply;
}
//Process form:
public function processesForm($number, $cinema, $rows, $cols, $option) {
$this->option = $option;
$this->correct = true;
$bd = new HallDAO('complucine');
if($bd ){
if($option == "list"){
$this->halls = $bd->getAllHalls($cinema);
}else {
/*
$start = date('H:i:s', strtotime( $start ) );
if($option == "new"){
$selectSession = $bd->selectSession($cinema, $hall, $start, $date);
if($selectSession && $selectSession->num_rows >= 1) {
$this->correct = false;
} else{
$bd->createSession(null, $film, $hall,$cinema, $date, $start, $price, $format);
}
mysqli_free_result($selectSession);
} else if ($option == "del"){
$bd->deleteSession($id);
} else if ($option == "edit"){
$bd->editSession($id, $film, $hall, $cinema, $date, $start, $price, $format);
}
if($repeat > "0"){
$repeat--;
$date = date('Y-m-d', strtotime( $date. ' +1 day') );
$this->processesForm($film, $hall, $cinema, $date, $start, $price, $format, $repeat);
}
*/
}
} else {$this->correct = false;}
}
}
?>

View File

@ -1,5 +1,4 @@
<?php <?php
include_once('session_dao.php'); include_once('session_dao.php');
include_once('../assets/php/form.php'); include_once('../assets/php/form.php');
@ -9,6 +8,8 @@ class FormSession extends Form {
private $correct; // Indicates if the session is correct. private $correct; // Indicates if the session is correct.
private $reply; // Validation response private $reply; // Validation response
private $option; private $option;
private $sessions;
//Constructor: //Constructor:
public function __construct() { public function __construct() {
parent::__construct('formSession'); parent::__construct('formSession');
@ -19,7 +20,6 @@ class FormSession 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 //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"){
@ -34,52 +34,59 @@ class FormSession extends Form {
$this->reply = "<h1> Operacion realizada con exito </h1><hr /> $this->reply = "<h1> Operacion realizada con exito </h1><hr />
<p> Se ha eliminado la sesion correctamente en la base de datos.</p> <p> Se ha eliminado la sesion 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"){
$this->reply = $this->sessions;
} }
} else { } else {
$this->reply = "<h1> ERROR </h1><hr /> $this->reply = "<h1> ERROR </h1><hr />
<p> Ha habido un error en la operacion. Revisa los datos introducidos o ponte en contacto con el administrador de la base de datos.</p> <p> Ha habido un error en la operacion. Revisa los datos introducidos o ponte en contacto con el administrador de 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>";
} }
return $this->reply; return $this->reply;
} }
//Process form: //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->correct = true;
$this->option = $option; $this->option = $option;
//Habria que validar todo para que encaje en la base de datos $this->correct = true;
$start = date('H:i:s', strtotime( $start ) );
$date = date('Y-m-d', strtotime( $date ) );
$bd = new sessionDAO('complucine'); $bd = new sessionDAO('complucine');
$date = date('Y-m-d', strtotime( $date ) );
if($bd ){ if($bd ){
if($option == "new"){ if($option == "list"){
$selectSession = $bd->selectSession($cinema, $hall, $start, $date); $this->sessions = $bd->getAllSessionsFromDateHallAndCinema($cinema, $hall, $date);
if($selectSession && $selectSession->num_rows >= 1) { }else {
$this->correct = false;
} else{ $start = date('H:i:s', strtotime( $start ) );
$bd->createSession(null, $film, $hall,$cinema, $date, $start, $price, $format);
if($option == "new"){
$selectSession = $bd->selectSession($cinema, $hall, $start, $date);
if($selectSession && $selectSession->num_rows >= 1) {
$this->correct = false;
} else{
$bd->createSession(null, $film, $hall,$cinema, $date, $start, $price, $format);
}
mysqli_free_result($selectSession);
} else if ($option == "del"){
$bd->deleteSession($id);
} else if ($option == "edit"){
$bd->editSession($id, $film, $hall, $cinema, $date, $start, $price, $format);
} }
mysqli_free_result($selectSession);
} else if ($option == "del"){ if($repeat > "0"){
$bd->deleteSession($id); $repeat--;
} else if ($option == "edit"){ $date = date('Y-m-d', strtotime( $date. ' +1 day') );
$bd->editSession($id, $film, $hall, $cinema, $date, $start, $price, $format); $this->processesForm($film, $hall, $cinema, $date, $start, $price, $format, $repeat);
} }
}
if($repeat > "0"){ } else {$this->correct = false;}
$repeat--;
$date = date('Y-m-d', strtotime( $date. ' +1 day') );
$this->processesForm($film, $hall, $cinema, $date, $start, $price, $format, $repeat);
}
} else {$this->correct = false;}
} }
} }
?> ?>

View File

@ -22,18 +22,27 @@
} }
//Returns a query to get the halls data. //Returns a query to get the halls data.
public function hallData($id,$idcinema){ public function getAllHalls($cinema){
$sql = sprintf( "SELECT * FROM `hall` $sql = sprintf( "SELECT * FROM hall WHERE
WHERE `hall`.`number` = '%d' AND `hall`.`idcinema` = '%d';", idcinema = '%s'",
$id, $idcinema ); $cinema);
$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; $hall = null;
while($fila=mysqli_fetch_array($resul)){
$hall[] = $this->loadHall($fila["number"], $fila["idcinema"], $fila["numrows"], $fila["numcolumns"]);
}
mysqli_free_result($resul);
return $hall;
} }
//Create a new Hall Data Transfer Object. //Create a new Hall Data Transfer Object.
public function loadHall($id, $idcinema, $numCol, $numRows){ public function loadHall($number, $idcinema, $numrows, $numcolumns){
return new HallDTO($id, $idcinema, $numCol, $numRows); return new HallDTO($number, $idcinema, $numrows, $numcolumns);
} }
//Edit Hall. //Edit Hall.

View File

@ -6,16 +6,15 @@
//Attributes: //Attributes:
private $_number; //Room number. private $_number; //Room number.
private $_idcinema; //Cinema Id private $_idcinema; //Cinema Id
private $_numRows; //Num rows.
private $_numCol; //Num columns. private $_numCol; //Num columns.
private $_numRows; //Num rows.
//Constructor: //Constructor:
function __construct($number, $idcinema, $numCol, $numRows){ function __construct($number, $idcinema, $numRows, $numCol){
$this->_number = $number; $this->_number = $number;
$this->_idcinema = $idcinema; $this->_idcinema = $idcinema;
$this->_numCol = $numCol;
$this->_numRows = $numRows; $this->_numRows = $numRows;
$this->_numCol = $numCol;
} }
//Methods: //Methods:
@ -27,11 +26,13 @@
public function setIdcinema($idcinema){ $this->_idcinema = $idcinema; } public function setIdcinema($idcinema){ $this->_idcinema = $idcinema; }
public function getIdcinema(){ return $this->_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 setNumCol($numCol){ $this->_numCol = $numCol; }
public function getNumCol(){ return $this->_numCol; } public function getNumCol(){ return $this->_numCol; }
public function setNumRows($numRows){ $this->_numRows = $numRows; }
public function getNumRows(){ return $this->_numRows; }
} }
?> ?>

View File

@ -46,6 +46,24 @@
return $resul; return $resul;
} }
public function getAllSessionsFromDateHallAndCinema($cinema, $hall, $date){
$sql = sprintf( "SELECT * FROM session WHERE
idcinema = '%s' AND idhall = '%s' AND date = '%s'",
$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"]);
}
mysqli_free_result($resul);
return $sessions;
}
//Edit Session. //Edit Session.
public function editSession($id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format){ public function editSession($id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format){
@ -72,8 +90,8 @@
//Create a new Session Data Transfer Object. //Create a new Session Data Transfer Object.
public function loadSession( $id, $idfilm, $idhall, $date, $startTime, $seatPrice, $format){ public function loadSession( $id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format){
return new SessionDTO( $id, $idfilm, $idhall, $date, $startTime, $seatPrice, $format); return new SessionDTO( $id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format);
} }
} }