Add files via upload

This commit is contained in:
Fernando Méndez 2021-05-24 12:43:25 +02:00 committed by GitHub
parent 1ad88d42a2
commit 8b86f15a68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 74 additions and 7 deletions

View File

@ -67,6 +67,24 @@
return $resul; 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. //Create a new film Data Transfer Object.
public function loadCinema($id, $name, $direction, $phone){ public function loadCinema($id, $name, $direction, $phone){
return new Cinema($id, $name, $direction, $phone); return new Cinema($id, $name, $direction, $phone);

View File

@ -5,7 +5,9 @@
//Get Film to purchase: //Get Film to purchase:
include_once($prefix.'assets/php/includes/film_dao.php'); include_once($prefix.'assets/php/includes/film_dao.php');
include_once($prefix.'assets/php/includes/film.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/cinema.php');
include_once($prefix.'assets/php/includes/session.php');
$film = null; $film = null;
$cinemas = []; $cinemas = [];
@ -17,22 +19,68 @@
$cinemas = $filmDAO->getCinemas($_GET["film"]); $cinemas = $filmDAO->getCinemas($_GET["film"]);
if(!empty($cinemas)){ if(!empty($cinemas)){
$cinemasNames = array(); $cinemasNames = array();
$cinemasIDs = array();
foreach($cinemas as $key=>$value){ foreach($cinemas as $key=>$value){
$cinemasIDs[$key] = $value->getId();
$cinemasNames[$key] = $value->getName(); $cinemasNames[$key] = $value->getName();
} }
$cinemasListHTML = '<select name="cinemas">'; $cinemasListHTML = '<select name="cinemas">';
foreach($cinemasNames as $value){ foreach($cinemasNames as $value){
if($value == reset($cinemasNames)){ foreach($cinemasIDs as $id){
$cinemasListHTML .= '<option value="'.$value.'" selected>'.$value.'</option>'; if($value == reset($cinemasNames)){
} else { $cinemasListHTML .= '<option value="'.$id.'" selected>'.$value.'</option>';
$cinemasListHTML .='<option value="'.$value.'">'.$value.'</option>'; } else {
$cinemasListHTML .='<option value="'.$id.'">'.$value.'</option>';
}
} }
} }
$cinemasListHTML .= '</select>'; $cinemasListHTML .= '</select>';
} else { } else {
$cinemasListHTML = '<select name="cinemas"><option value="" selected>No hay cines disponibles para esta película.</option></select>'; $cinemasListHTML = '<select name="cinemas"><option value="" selected>No hay cines disponibles para esta película.</option></select>';
} }
$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 = '<select name="sessions">';
foreach ($sessionsIT as $value) {
if($value == reset($sessionsIT)){
$sessionsListHTML .= '<option value="'.$value["ID"].'" selected>'.$value["DATE"].' | '.$value["HOUR"].'</option>';
} else {
$sessionsListHTML .='<option value="'.$value["ID"].'">'.$value["DATE"].' | '.$value["HOUR"].'</option>';
}
}
/*
foreach($sessionsDates as $value){
foreach($sessionsStarts as $start){
foreach($sessionsIDs as $id){
if($value == reset($sessionsDates)){
$sessionsListHTML .= '<option value="'.$id.'" selected>'.$value.' | '.$start.'</option>';
} else {
$sessionsListHTML .='<option value="'.$id.'">'.$value.' | '.$start.'</option>';
}
}
}
}
*/
$sessionsListHTML .= '</select>';
} else {
$sessionsListHTML = '<select name="sessions"><option value="" selected>No hay sesiones disponibles para esta película.</option></select>';
}
} }
@ -45,9 +93,10 @@
</div> </div>
<div class="column right"> <div class="column right">
<h2>Seleccione un Cine y una Sesión</h2><hr /> <h2>Seleccione un Cine y una Sesión</h2><hr />
<br /><h3>Cines</h3> <br /><h3>Cines</h3>
'.$cinemasListHTML.' '.$cinemasListHTML.'
<h3>Sesiones</h3> <h3>Sesiones</h3>
'.$sessionsListHTML.'
</div> </div>
'; ';

View File

@ -96,7 +96,7 @@ class FormRegister extends Form {
$_SESSION["nombre"] = $this->user->getName(); $_SESSION["nombre"] = $this->user->getName();
$_SESSION["rol"] = $this->user->getRol(); $_SESSION["rol"] = $this->user->getRol();
$_SESSION["login"] = true; $_SESSION["login"] = true;
$result = "../register/register.php"; $result = ROUTE_APP."register/register.php";
} }
} }
} }