From 8b86f15a68500c6ba5f693d51d1679533c4e7adf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20M=C3=A9ndez?= <45081533+FerMdez@users.noreply.github.com> Date: Mon, 24 May 2021 12:43:25 +0200 Subject: [PATCH] Add files via upload --- assets/php/includes/cinema_dao.php | 18 +++++++++ purchase/index.php | 61 +++++++++++++++++++++++++++--- register/includes/formRegister.php | 2 +- 3 files changed, 74 insertions(+), 7 deletions(-) diff --git a/assets/php/includes/cinema_dao.php b/assets/php/includes/cinema_dao.php index 4da8133..2719d14 100644 --- a/assets/php/includes/cinema_dao.php +++ b/assets/php/includes/cinema_dao.php @@ -66,6 +66,24 @@ return $resul; } + + //Get sessions associated with a cinema. + public function getSessions($id){ + include_once('session_dao.php'); + $session = new SessionDAO("complucine"); + + $sql = sprintf( " SELECT DISTINCT * FROM session WHERE session.id in + (SELECT session.id FROM session JOIN cinema ON session.idcinema = cinema.id WHERE cinema.id = '%d'); ", $id); + $resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database'); + + $sessions = null; + while($fila = $resul->fetch_assoc()){ + $sessions[] = $session->loadSession($fila["id"], $fila["idfilm"], $fila["idhall"], $fila["idcinema"], $fila["date"], $fila["start_time"], $fila["seat_price"], $fila["format"], $fila["seats_full"]); + } + $resul->free(); + + return $sessions; + } //Create a new film Data Transfer Object. public function loadCinema($id, $name, $direction, $phone){ diff --git a/purchase/index.php b/purchase/index.php index b8f311e..1e11d4b 100644 --- a/purchase/index.php +++ b/purchase/index.php @@ -5,7 +5,9 @@ //Get Film to purchase: include_once($prefix.'assets/php/includes/film_dao.php'); include_once($prefix.'assets/php/includes/film.php'); + include_once($prefix.'assets/php/includes/cinema_dao.php'); include_once($prefix.'assets/php/includes/cinema.php'); + include_once($prefix.'assets/php/includes/session.php'); $film = null; $cinemas = []; @@ -17,22 +19,68 @@ $cinemas = $filmDAO->getCinemas($_GET["film"]); if(!empty($cinemas)){ $cinemasNames = array(); + $cinemasIDs = array(); foreach($cinemas as $key=>$value){ + $cinemasIDs[$key] = $value->getId(); $cinemasNames[$key] = $value->getName(); } $cinemasListHTML = ''; } else { $cinemasListHTML = ''; } + + $cinemaDAO = new Cinema_DAO("complucine"); + $sessions = $cinemaDAO->getSessions($id); + if(!empty($sessions)){ + $sessionsDates = new ArrayIterator(array()); + $sessionsStarts = new ArrayIterator(array()); + $sessionsIDs = new ArrayIterator(array()); + foreach($sessions as $key=>$value){ + $sessionsIDs[$key] = $value->getId(); + $sessionsDates[$key] = $value->getDate(); + $sessionsStarts[$key] = $value->getStartTime(); + } + $sessionsIT = new MultipleIterator(MultipleIterator::MIT_KEYS_ASSOC); + $sessionsIT->attachIterator($sessionsIDs, "ID"); + $sessionsIT->attachIterator($sessionsDates, "DATE"); + $sessionsIT->attachIterator($sessionsStarts, "HOUR"); + + $sessionsListHTML = ''; + } else { + $sessionsListHTML = ''; + } } @@ -45,9 +93,10 @@

Seleccione un Cine y una Sesión


-

Cines

+

Cines

'.$cinemasListHTML.' -

Sesiones

+

Sesiones

+ '.$sessionsListHTML.'
'; diff --git a/register/includes/formRegister.php b/register/includes/formRegister.php index c862421..68aa956 100644 --- a/register/includes/formRegister.php +++ b/register/includes/formRegister.php @@ -96,7 +96,7 @@ class FormRegister extends Form { $_SESSION["nombre"] = $this->user->getName(); $_SESSION["rol"] = $this->user->getRol(); $_SESSION["login"] = true; - $result = "../register/register.php"; + $result = ROUTE_APP."register/register.php"; } } }