diff --git a/assets/js/deleteConfirm.js b/assets/js/deleteConfirm.js index 2ee9790..b4d41f7 100644 --- a/assets/js/deleteConfirm.js +++ b/assets/js/deleteConfirm.js @@ -9,4 +9,4 @@ function confirmDelete() { } else { location.href = "./"; } -} +} \ No newline at end of file diff --git a/panel_user/panelUser.php b/panel_user/panelUser.php index bb3aefc..016d35e 100644 --- a/panel_user/panelUser.php +++ b/panel_user/panelUser.php @@ -123,7 +123,12 @@ $purchasesHTML .= '
'; } - $purchasesHTML .= '

'.$dates[$i].'


'; + $purchasesHTML .= '

Compara realizada el: '.$dates[$i].'


+

Cine: '.$cinemas[$i].'

+

Sala: '.$halls[$i].'

+

Sesión: '.$sessions[$i].'

+

Asiento(Fila): '.$rows[$i].'

+

Asiento(Columna): '.$columns[$i].'

'; } } diff --git a/purchase/includes/formPurchase.php b/purchase/includes/formPurchase.php index 81696a0..6a35c7b 100644 --- a/purchase/includes/formPurchase.php +++ b/purchase/includes/formPurchase.php @@ -24,7 +24,6 @@ class FormPurchase extends Form { private $_TODAY; // Actual date. public function __construct() { - //$options = array("action" => $_SERVER['PHP_SELF']); parent::__construct('formPurchase'); $sessionDAO = new SessionDAO("complucine"); diff --git a/purchase/includes/formSelectCinemaSession.php b/purchase/includes/formSelectCinemaSession.php new file mode 100644 index 0000000..3d5f907 --- /dev/null +++ b/purchase/includes/formSelectCinemaSession.php @@ -0,0 +1,192 @@ + "confirm.php"); + parent::__construct('formSelectCinemaSession', $options); + + $TODAY = getdate(); + $this->_TODAY = "$TODAY[mday]"."-"."$TODAY[mon]"."-"."$TODAY[year]"; + + $filmDAO = new Film_DAO("complucine"); + $this->film = $filmDAO->FilmData($_GET["film"]); + + } + + protected function generaCamposFormulario($datos, $errores = array()){ + $cinemas = []; + $sessions = []; + + // Se generan los mensajes de error si existen. + $htmlErroresGlobales = self::generaListaErroresGlobales($errores); + $errorCinema = self::createMensajeError($errores, 'cinemas', 'span', array('class' => 'error')); + $errorSession = self::createMensajeError($errores, 'sessions', 'span', array('class' => 'error')); + + $pay = true; + if(isset($_GET["film"])){ + $filmDAO = new Film_DAO("complucine"); + $film = $filmDAO->FilmData($_GET["film"]); + if($film){ + $tittle = $film->getTittle(); + $image = $film->getImg(); + + $cinemas = $filmDAO->getCinemas($_GET["film"]); + $cinema_id = $_GET["cinema"]; + 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(); + + if(isset($cinema_id)){ + $sessionsDAO = new SessionDAO("complucine"); + $sessions = $sessionsDAO->getSessions_Film_Cinema($fiml_id, $cinema_id); + 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] = date_format(date_create($value->getDate()), 'j-n-Y'); + $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"); + + $count = 0; + $sessionsListHTML = ''; + + if($count == 0) { + $sessionsListHTML = ''; + $pay = false; + } + } else { + $sessionsListHTML = ''; + $pay = false; + } + } else { + $sessionsListHTML = ''; + $pay = false; + } + + //Reply: Depends on whether the purchase is to be made from a selected movie or a cinema. + $html = '
+

Película seleccionada: '.str_replace('_', ' ', $tittle).'


+
'.$tittle.'
+

Duración: '.$film->getDuration().' minutos

+

Idioma: '.$film->getLanguage().'

+
+
+

Seleccione un Cine y una Sesión


+

Cines

+ '.$cinemasListHTML.' +

Sesiones

+ '.$sessionsListHTML.' +
'; + } else { + $html = '

No existe la película.

'; + $pay = false; + } + } else if(isset($_GET["cinema"])) { + $html = '

ESTAMOS TRABAJANDO EN ELLO

'; + $pay = false; + } else { + $html = '

No se ha encontrado película ni cine.

'; + $pay = false; + } + + //Pay button: + if($pay){ + $pay = ''; + } + + return ' +
+ '.$html.' +
+
+ '.$pay.' +
'; + } + + protected function procesaFormulario($datos){ + $result = array(); + + $cinema = $this->test_input($datos['cinemas']) ?? null; + if ( empty($cinema) ) { + $result['cinemas'] = "Selecciona un cine."; + } + + $session = $this->test_input($datos['sessions']) ?? null; + if ( empty($session) ) { + $result['sessions'] = "Selecciona una sesión."; + } + + if (count($result) === 0) { + $result = "confirm.php"; + } + + return $result; + } +} +?> \ No newline at end of file diff --git a/purchase/index.php b/purchase/index.php index 3691b21..d5d4d28 100644 --- a/purchase/index.php +++ b/purchase/index.php @@ -2,157 +2,16 @@ //General Config File: require_once('../assets/php/config.php'); - //Get Ticket 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_dao.php'); - include_once($prefix.'assets/php/includes/session.php'); - - $TODAY = getdate(); - $TODAY = "$TODAY[mday]"."-"."$TODAY[mon]"."-"."$TODAY[year]"; - - $pay = true; - $film = null; - $cinema = null; - $cinemas = []; - $sessions = []; - if(isset($_GET["film"])){ - $filmDAO = new Film_DAO("complucine"); - $film = $filmDAO->FilmData($_GET["film"]); - if($film){ - $tittle = $film->getTittle(); - $image = $film->getImg(); - - $cinemas = $filmDAO->getCinemas($_GET["film"]); - $cinema_id = $_GET["cinema"]; - 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(); - - if(isset($cinema_id)){ - $sessionsDAO = new SessionDAO("complucine"); - $sessions = $sessionsDAO->getSessions_Film_Cinema($fiml_id, $cinema_id); - 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] = date_format(date_create($value->getDate()), 'j-n-Y'); - $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"); - - $count = 0; - $sessionsListHTML = '
- '; - - if($count == 0) { - $sessionsListHTML = '
'; - $pay = false; - } - } else { - $sessionsListHTML = '
'; - $pay = false; - } - } else { - $sessionsListHTML = '
'; - $pay = false; - } - - //Reply: Depends on whether the purchase is to be made from a selected movie or a cinema. - $reply = '
-

Película seleccionada: '.str_replace('_', ' ', $tittle).'


-
'.$tittle.'
-

Duración: '.$film->getDuration().' minutos

-

Idioma: '.$film->getLanguage().'

-
-
-

Seleccione un Cine y una Sesión


-

Cines

- '.$cinemasListHTML.' -

Sesiones

- '.$sessionsListHTML.' -
- '; - } else { - $reply = '

No existe la película.

'; - $pay = false; - } - } else if(isset($_GET["cinema"])) { - $reply = '

ESTAMOS TRABAJANDO EN ELLO

'; - $pay = false; - } else { - $reply = '

No se ha encontrado película ni cine.

'; - $pay = false; - } - - //Pay button: - if($pay){ - $pay = ' - '; - } + //Form Ticket to purchase: + require_once('includes/formSelectCinemaSession.php'); + $form = new FormSelectCinemaSession(); + $formHTML = $form->gestiona(); //Page-specific content: $section = '
-
- '.$reply.' -
-
- '.$pay.' -
+ '.$formHTML.'
';