Add files via upload
This commit is contained in:
parent
987476b585
commit
b0cf43c313
93
panel_manager/includes/formHall.php
Normal file
93
panel_manager/includes/formHall.php
Normal 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;}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
include_once('session_dao.php');
|
||||
include_once('../assets/php/form.php');
|
||||
|
||||
@ -9,6 +8,8 @@ class FormSession extends Form {
|
||||
private $correct; // Indicates if the session is correct.
|
||||
private $reply; // Validation response
|
||||
private $option;
|
||||
private $sessions;
|
||||
|
||||
//Constructor:
|
||||
public function __construct() {
|
||||
parent::__construct('formSession');
|
||||
@ -19,7 +20,6 @@ class FormSession extends Form {
|
||||
|
||||
//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"){
|
||||
@ -34,37 +34,46 @@ class FormSession extends Form {
|
||||
$this->reply = "<h1> Operacion realizada con exito </h1><hr />
|
||||
<p> Se ha eliminado la sesion 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->sessions;
|
||||
}
|
||||
} 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($id, $film, $hall, $cinema, $date, $start, $price, $format, $repeat, $option) {
|
||||
$this->correct = true;
|
||||
$this->option = $option;
|
||||
//Habria que validar todo para que encaje en la base de datos
|
||||
$this->correct = true;
|
||||
$bd = new sessionDAO('complucine');
|
||||
|
||||
$start = date('H:i:s', strtotime( $start ) );
|
||||
$date = date('Y-m-d', strtotime( $date ) );
|
||||
|
||||
$bd = new sessionDAO('complucine');
|
||||
if($bd ){
|
||||
if($option == "list"){
|
||||
$this->sessions = $bd->getAllSessionsFromDateHallAndCinema($cinema, $hall, $date);
|
||||
}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);
|
||||
}
|
||||
@ -74,12 +83,10 @@ class FormSession extends Form {
|
||||
$date = date('Y-m-d', strtotime( $date. ' +1 day') );
|
||||
$this->processesForm($film, $hall, $cinema, $date, $start, $price, $format, $repeat);
|
||||
}
|
||||
} else {$this->correct = false;}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
} else {$this->correct = false;}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -22,18 +22,27 @@
|
||||
}
|
||||
|
||||
//Returns a query to get the halls data.
|
||||
public function hallData($id,$idcinema){
|
||||
$sql = sprintf( "SELECT * FROM `hall`
|
||||
WHERE `hall`.`number` = '%d' AND `hall`.`idcinema` = '%d';",
|
||||
$id, $idcinema );
|
||||
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');
|
||||
|
||||
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.
|
||||
public function loadHall($id, $idcinema, $numCol, $numRows){
|
||||
return new HallDTO($id, $idcinema, $numCol, $numRows);
|
||||
public function loadHall($number, $idcinema, $numrows, $numcolumns){
|
||||
return new HallDTO($number, $idcinema, $numrows, $numcolumns);
|
||||
}
|
||||
|
||||
//Edit Hall.
|
||||
|
@ -6,16 +6,15 @@
|
||||
//Attributes:
|
||||
private $_number; //Room number.
|
||||
private $_idcinema; //Cinema Id
|
||||
private $_numCol; //Num columns.
|
||||
private $_numRows; //Num rows.
|
||||
|
||||
private $_numCol; //Num columns.
|
||||
|
||||
//Constructor:
|
||||
function __construct($number, $idcinema, $numCol, $numRows){
|
||||
function __construct($number, $idcinema, $numRows, $numCol){
|
||||
$this->_number = $number;
|
||||
$this->_idcinema = $idcinema;
|
||||
$this->_numCol = $numCol;
|
||||
$this->_numRows = $numRows;
|
||||
$this->_numCol = $numCol;
|
||||
}
|
||||
|
||||
//Methods:
|
||||
@ -27,11 +26,13 @@
|
||||
public function setIdcinema($idcinema){ $this->_idcinema = $idcinema; }
|
||||
public function getIdcinema(){ return $this->_idcinema; }
|
||||
|
||||
public function setNumCol($numCol){ $this->_numCol = $numCol; }
|
||||
public function getNumCol(){ return $this->_numCol; }
|
||||
|
||||
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; }
|
||||
|
||||
|
||||
|
||||
}
|
||||
?>
|
@ -46,6 +46,24 @@
|
||||
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.
|
||||
public function editSession($id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format){
|
||||
|
||||
@ -72,8 +90,8 @@
|
||||
|
||||
|
||||
//Create a new Session Data Transfer Object.
|
||||
public function loadSession( $id, $idfilm, $idhall, $date, $startTime, $seatPrice, $format){
|
||||
return new SessionDTO( $id, $idfilm, $idhall, $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);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user