From 7be148840e5cd03b4705b1c2c995eea0a97fecc5 Mon Sep 17 00:00:00 2001 From: Markines16 <80280295+Markines16@users.noreply.github.com> Date: Fri, 7 May 2021 13:48:50 +0200 Subject: [PATCH] Add files via upload --- assets/php/common/hall.php | 1 + assets/php/common/session.php | 29 ++++++++++++++++++++++------- assets/php/common/session_dao.php | 30 ++++++++++++++++++++---------- 3 files changed, 43 insertions(+), 17 deletions(-) diff --git a/assets/php/common/hall.php b/assets/php/common/hall.php index b6dd8d6..95447cb 100644 --- a/assets/php/common/hall.php +++ b/assets/php/common/hall.php @@ -8,6 +8,7 @@ private $_idcinema; //Cinema Id private $_numRows; //Num rows. private $_numCol; //Num columns. + private $_total_seats; //Constructor: function __construct($number, $idcinema, $numRows, $numCol){ diff --git a/assets/php/common/session.php b/assets/php/common/session.php index ae885ed..7ffc0d3 100644 --- a/assets/php/common/session.php +++ b/assets/php/common/session.php @@ -1,7 +1,5 @@ _id = $id; $this->_idfilm = $idfilm; $this->_idhall = $idhall; @@ -23,6 +22,7 @@ $this->_startTime = $startTime; $this->_seatPrice = $seatPrice; $this->_format = $format; + $this->_seats_full = $seats_full; } public static function getListSessions($hall,$cinema,$date){ @@ -83,11 +83,26 @@ } //Esto deberia estar en film.php? seguramente - public static function getFilmTitle($idfilm){ - $bd = new Film_DAO('complucine'); + public static function getThisSessionFilm($idfilm){ + $bd = new SessionDAO('complucine'); if($bd ) { - $film = mysqli_fetch_array($bd->FilmData($idfilm)); - return $film["tittle"]; + return $bd->filmTittle($idfilm); + } + return ""; + } + + public static function getThisSessionId($cinema, $hall, $start, $date){ + $bd = new SessionDAO('complucine'); + if($bd ) { + return $bd->searchSession($cinema, $hall, $start, $date); + } + return ""; + } + + public static function getThisSessionFromId($id){ + $bd = new SessionDAO('complucine'); + if($bd ) { + return $bd->sessionData($id); } return ""; } diff --git a/assets/php/common/session_dao.php b/assets/php/common/session_dao.php index 8d8abea..251e5e8 100644 --- a/assets/php/common/session_dao.php +++ b/assets/php/common/session_dao.php @@ -14,9 +14,9 @@ $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`) - VALUES ('%d', '%d', '%d', '%d', '%s', '%s', '%d', '%s')", - $id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format); + $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'); @@ -28,25 +28,35 @@ $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; } - //Returns the count of the session searched + 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 COUNT(*) FROM session WHERE + $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 = null; $session = mysqli_fetch_array($resul); mysqli_free_result($resul); - return $session[0]; + return $session; } //Returns a query to get all the session's data. public function getAllSessions($hall, $cinema, $date){ @@ -60,7 +70,7 @@ $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"]); + $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); @@ -96,8 +106,8 @@ } //Create a new Session Data Transfer Object. - public function loadSession( $id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format){ - return new Session( $id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format); + 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); } }