Add files via upload
This commit is contained in:
parent
1ad88d42a2
commit
8b86f15a68
@ -67,6 +67,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){
|
||||
return new Cinema($id, $name, $direction, $phone);
|
||||
|
@ -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 = '<select name="cinemas">';
|
||||
foreach($cinemasNames as $value){
|
||||
foreach($cinemasIDs as $id){
|
||||
if($value == reset($cinemasNames)){
|
||||
$cinemasListHTML .= '<option value="'.$value.'" selected>'.$value.'</option>';
|
||||
$cinemasListHTML .= '<option value="'.$id.'" selected>'.$value.'</option>';
|
||||
} else {
|
||||
$cinemasListHTML .='<option value="'.$value.'">'.$value.'</option>';
|
||||
$cinemasListHTML .='<option value="'.$id.'">'.$value.'</option>';
|
||||
}
|
||||
}
|
||||
}
|
||||
$cinemasListHTML .= '</select>';
|
||||
} else {
|
||||
$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>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -48,6 +96,7 @@
|
||||
<br /><h3>Cines</h3>
|
||||
'.$cinemasListHTML.'
|
||||
<h3>Sesiones</h3>
|
||||
'.$sessionsListHTML.'
|
||||
</div>
|
||||
';
|
||||
|
||||
|
@ -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";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user