2021-05-23 16:23:25 +02:00
|
|
|
<?php
|
|
|
|
//General Config File:
|
|
|
|
require_once('../assets/php/config.php');
|
|
|
|
|
|
|
|
//Get Film to purchase:
|
|
|
|
include_once($prefix.'assets/php/includes/film_dao.php');
|
|
|
|
include_once($prefix.'assets/php/includes/film.php');
|
2021-05-24 12:43:25 +02:00
|
|
|
include_once($prefix.'assets/php/includes/cinema_dao.php');
|
2021-05-23 16:23:25 +02:00
|
|
|
include_once($prefix.'assets/php/includes/cinema.php');
|
2021-05-24 12:43:25 +02:00
|
|
|
include_once($prefix.'assets/php/includes/session.php');
|
2021-05-23 16:23:25 +02:00
|
|
|
|
|
|
|
$film = null;
|
|
|
|
$cinemas = [];
|
|
|
|
if(isset($_GET["film"])){
|
|
|
|
$filmDAO = new Film_DAO("complucine");
|
|
|
|
$film = $filmDAO->FilmData($_GET["film"]);
|
|
|
|
$tittle = $film->getTittle();
|
|
|
|
|
|
|
|
$cinemas = $filmDAO->getCinemas($_GET["film"]);
|
2021-05-24 10:18:17 +02:00
|
|
|
if(!empty($cinemas)){
|
|
|
|
$cinemasNames = array();
|
2021-05-24 12:43:25 +02:00
|
|
|
$cinemasIDs = array();
|
2021-05-24 10:18:17 +02:00
|
|
|
foreach($cinemas as $key=>$value){
|
2021-05-24 12:43:25 +02:00
|
|
|
$cinemasIDs[$key] = $value->getId();
|
2021-05-24 10:18:17 +02:00
|
|
|
$cinemasNames[$key] = $value->getName();
|
|
|
|
}
|
|
|
|
|
|
|
|
$cinemasListHTML = '<select name="cinemas">';
|
|
|
|
foreach($cinemasNames as $value){
|
2021-05-24 12:43:25 +02:00
|
|
|
foreach($cinemasIDs as $id){
|
|
|
|
if($value == reset($cinemasNames)){
|
|
|
|
$cinemasListHTML .= '<option value="'.$id.'" selected>'.$value.'</option>';
|
|
|
|
} else {
|
|
|
|
$cinemasListHTML .='<option value="'.$id.'">'.$value.'</option>';
|
|
|
|
}
|
2021-05-24 10:18:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
$cinemasListHTML .= '</select>';
|
|
|
|
} else {
|
|
|
|
$cinemasListHTML = '<select name="cinemas"><option value="" selected>No hay cines disponibles para esta película.</option></select>';
|
2021-05-23 16:23:25 +02:00
|
|
|
}
|
2021-05-24 12:43:25 +02:00
|
|
|
|
|
|
|
$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>';
|
|
|
|
}
|
2021-05-23 16:23:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//Reply: Depends on whether the purchase is to be made from a selected movie or a cinema.
|
|
|
|
$reply = '<div class="column left">
|
|
|
|
<h2>Película seleccionada: '.str_replace('_', ' ', $tittle).'</h2><hr />
|
|
|
|
<div class="image"><img src="'.$prefix.'img/films/'.$tittle.'.jpg" alt="'.$tittle.'" /></div>
|
2021-05-24 10:18:17 +02:00
|
|
|
<p>Duración: '.$film->getDuration().' minutos</p>
|
2021-05-23 16:23:25 +02:00
|
|
|
<p>Idioma: '.$film->getLanguage().'</p>
|
|
|
|
</div>
|
|
|
|
<div class="column right">
|
2021-05-24 10:18:17 +02:00
|
|
|
<h2>Seleccione un Cine y una Sesión</h2><hr />
|
2021-05-24 12:43:25 +02:00
|
|
|
<br /><h3>Cines</h3>
|
2021-05-23 16:23:25 +02:00
|
|
|
'.$cinemasListHTML.'
|
2021-05-24 12:43:25 +02:00
|
|
|
<h3>Sesiones</h3>
|
|
|
|
'.$sessionsListHTML.'
|
2021-05-23 16:23:25 +02:00
|
|
|
</div>
|
|
|
|
';
|
|
|
|
|
|
|
|
//Page-specific content:
|
|
|
|
$section = '<!-- Purchase -->
|
|
|
|
<section id="purchase">
|
|
|
|
<div class="row">
|
2021-05-24 10:18:17 +02:00
|
|
|
<section class="code purchase">
|
2021-05-23 16:23:25 +02:00
|
|
|
'.$reply.'
|
|
|
|
</section>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
';
|
|
|
|
|
|
|
|
//General page content:
|
|
|
|
require RAIZ_APP.'/HTMLtemplate.php';
|
|
|
|
?>
|