diff --git a/purchase/index.php b/purchase/index.php
index 59f4aa3..cec00d8 100644
--- a/purchase/index.php
+++ b/purchase/index.php
@@ -9,81 +9,81 @@
include_once($prefix.'assets/php/includes/cinema.php');
include_once($prefix.'assets/php/includes/session.php');
+ $pay = true;
$film = null;
$cinemas = [];
$sessions = [];
if(isset($_GET["film"])){
$filmDAO = new Film_DAO("complucine");
$film = $filmDAO->FilmData($_GET["film"]);
- $tittle = $film->getTittle();
+ if($film){
+ $tittle = $film->getTittle();
- $cinemas = $filmDAO->getCinemas($_GET["film"]);
- if(!empty($cinemas)){
- $cinemasNames = new ArrayIterator(array());
- $cinemasIDs = new ArrayIterator(array());
- foreach($cinemas as $key=>$value){
- $cinemasIDs[$key] = $value->getId();
- $cinemasNames[$key] = $value->getName();
- }
- $cinemasIT = new MultipleIterator(MultipleIterator::MIT_KEYS_ASSOC);
- $cinemasIT->attachIterator($cinemasIDs, "cID");
- $cinemasIT->attachIterator($cinemasNames, "NAME");
-
- $cinemasListHTML = '';
- } else {
- $cinemasListHTML = '';
- }
-
- $fiml_id = $film->getId();
- $cinema_id = $value["cID"];
-
- $cinemaDAO = new Cinema_DAO("complucine");
- $sessions = $cinemaDAO->getSessions($value["cID"]);
- if(!empty($sessions)){
- $sessionsDates = new ArrayIterator(array());
- $sessionsStarts = new ArrayIterator(array());
- $sessionsHalls = new ArrayIterator(array());
- $sessionsIDs = new ArrayIterator(array());
- foreach($sessions as $key=>$value){
- $sessionsIDs[$key] = $value->getId();
- $sessionsDates[$key] = $value->getDate();
- $sessionsHalls[$key] = $value->getIdhall();
- $sessionsStarts[$key] = $value->getStartTime();
- }
- $sessionsIT = new MultipleIterator(MultipleIterator::MIT_KEYS_ASSOC);
- $sessionsIT->attachIterator($sessionsIDs, "sID");
- $sessionsIT->attachIterator($sessionsDates, "DATE");
- $sessionsIT->attachIterator($sessionsHalls, "HALL");
- $sessionsIT->attachIterator($sessionsStarts, "HOUR");
-
- $sessionsListHTML = '';
- } else {
- $sessionsListHTML = '';
- }
- $session_id = $value["sID"];
- $hall_id = $value["HALL"];
- }
-
+ $fiml_id = $film->getId();
+ $cinema_id = $value["cID"];
- //Reply: Depends on whether the purchase is to be made from a selected movie or a cinema.
- $reply = '
+ $cinemaDAO = new Cinema_DAO("complucine");
+ $sessions = $cinemaDAO->getSessions($value["cID"]);
+ if(!empty($sessions)){
+ $sessionsDates = new ArrayIterator(array());
+ $sessionsStarts = new ArrayIterator(array());
+ $sessionsHalls = new ArrayIterator(array());
+ $sessionsIDs = new ArrayIterator(array());
+ foreach($sessions as $key=>$value){
+ $sessionsIDs[$key] = $value->getId();
+ $sessionsDates[$key] = $value->getDate();
+ $sessionsHalls[$key] = $value->getIdhall();
+ $sessionsStarts[$key] = $value->getStartTime();
+ }
+ $sessionsIT = new MultipleIterator(MultipleIterator::MIT_KEYS_ASSOC);
+ $sessionsIT->attachIterator($sessionsIDs, "sID");
+ $sessionsIT->attachIterator($sessionsDates, "DATE");
+ $sessionsIT->attachIterator($sessionsHalls, "HALL");
+ $sessionsIT->attachIterator($sessionsStarts, "HOUR");
+
+ $sessionsListHTML = '
';
+ foreach ($sessionsIT as $value) {
+ if($value == reset($sessionsIT)){
+ $sessionsListHTML .= '';
+ } else {
+ $sessionsListHTML .='';
+ }
+ }
+ $sessionsListHTML .= '';
+ } else {
+ $sessionsListHTML = '
';
+ }
+
+ $session_id = $value["sID"];
+ $hall_id = $value["HALL"];
+
+ //Reply: Depends on whether the purchase is to be made from a selected movie or a cinema.
+ $reply = '
Película seleccionada: '.str_replace('_', ' ', $tittle).'
Duración: '.$film->getDuration().' minutos
@@ -97,7 +97,22 @@
'.$sessionsListHTML.'
';
+ } else {
+ $reply = '
No existe la película.
';
+ $pay = false;
+ }
+ }
+ //Pay button:
+ if($pay){
+ $pay = '
';
+ }
//Page-specific content:
$section = '
@@ -106,13 +121,7 @@
'.$reply.'