diff --git a/panel_manager/includes/formHall.php b/panel_manager/includes/formHall.php new file mode 100644 index 0000000..1da2ee0 --- /dev/null +++ b/panel_manager/includes/formHall.php @@ -0,0 +1,93 @@ +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 = "

Operacion realizada con exito


+

Se ha aƱadido la sala correctamente en la base de datos.

+ "; + }else if($this->option == "edit"){ + $this->reply = "

Operacion realizada con exito


+

Se ha editado la sala correctamente en la base de datos.

+ "; + }else if($this->option == "del"){ + $this->reply = "

Operacion realizada con exito


+

Se ha eliminado la sala correctamente en la base de datos.

+ "; + }else if($this->option == "list"){ + $this->reply = $this->halls; + } + } else { + $this->reply = "

ERROR


+

Ha habido un error en la operacion. Revisa los datos introducidos o ponte en contacto con el administrador de la base de datos.

+ "; + } + 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;} + } +} + +?> + diff --git a/panel_manager/includes/formSession.php b/panel_manager/includes/formSession.php index b3f34cf..90e235d 100644 --- a/panel_manager/includes/formSession.php +++ b/panel_manager/includes/formSession.php @@ -1,5 +1,4 @@ correct){ if($this->option == "new"){ @@ -34,52 +34,59 @@ class FormSession extends Form { $this->reply = "

Operacion realizada con exito


Se ha eliminado la sesion correctamente en la base de datos.

"; + }else if($this->option == "list"){ + $this->reply = $this->sessions; } } else { $this->reply = "

ERROR


Ha habido un error en la operacion. Revisa los datos introducidos o ponte en contacto con el administrador de la base de datos.

"; - } 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 - - $start = date('H:i:s', strtotime( $start ) ); - $date = date('Y-m-d', strtotime( $date ) ); - + $this->correct = true; $bd = new sessionDAO('complucine'); + + $date = date('Y-m-d', strtotime( $date ) ); + if($bd ){ - 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); + 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); } - 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); + } + } - 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;} - - - + } else {$this->correct = false;} } - } ?> diff --git a/panel_manager/includes/hall_dao.php b/panel_manager/includes/hall_dao.php index 941f3a2..4c85a7c 100644 --- a/panel_manager/includes/hall_dao.php +++ b/panel_manager/includes/hall_dao.php @@ -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. diff --git a/panel_manager/includes/hall_dto.php b/panel_manager/includes/hall_dto.php index 42d6c0e..40eed19 100644 --- a/panel_manager/includes/hall_dto.php +++ b/panel_manager/includes/hall_dto.php @@ -6,16 +6,15 @@ //Attributes: private $_number; //Room number. private $_idcinema; //Cinema Id + private $_numRows; //Num rows. private $_numCol; //Num columns. - private $_numRows; //Num rows. - //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 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 setNumRows($numRows){ $this->_numRows = $numRows; } - public function getNumRows(){ return $this->_numRows; } + } ?> \ No newline at end of file diff --git a/panel_manager/includes/session_dao.php b/panel_manager/includes/session_dao.php index bea63b6..66bfd80 100644 --- a/panel_manager/includes/session_dao.php +++ b/panel_manager/includes/session_dao.php @@ -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); } }