Add files via upload

This commit is contained in:
Fernando Méndez 2021-05-27 18:01:24 +02:00 committed by GitHub
parent d9992fde93
commit 6e18e93fc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 313 additions and 54 deletions

View File

@ -701,7 +701,7 @@ form select {
font-weight: 400px; font-weight: 400px;
color: #1f2c3d; color: #1f2c3d;
line-height: 1.3; line-height: 1.3;
padding: .3em 1.4em .3em .4em; padding: 0.2em 0.2em 0.2em 0.2em;
width: 75px; width: 75px;
max-width: 100%; max-width: 100%;
box-sizing: border-box; box-sizing: border-box;

View File

@ -694,7 +694,7 @@ form select {
font-weight: 400px; font-weight: 400px;
color: #1f2c3d; color: #1f2c3d;
line-height: 1.3; line-height: 1.3;
padding: .3em 1.4em .3em .4em; padding: 0.2em 0.2em 0.2em 0.2em;
width: 75px; width: 75px;
max-width: 100%; max-width: 100%;
box-sizing: border-box; box-sizing: border-box;

View File

@ -101,7 +101,7 @@ table.seat td:first-child {
pointer-events: none; pointer-events: none;
} }
.tablelist li:nth-child(3n+) .tablelist li:nth-child(3n)
{ {
clear: both; clear: both;
} }

47
assets/js/selectTicket.js Normal file
View File

@ -0,0 +1,47 @@
// Método 1: recargar la página y enviar un GET.
window.onload = function(){
var select = document.getElementById("select_cinema");
select.onchange = function(){
location.href += "&cinema=" + $('select[id=cinemas]').val();
}
}
// Método 2: enviar una petición AJAX con POST. (NO FUNCIONA)
/*
$(document).ready(function(){
$("#select_cinema_session").change(function(){
var cinema = $('select[id=cinemas]').val();
//console.log($('select[id=cinemas]').val());
$.ajax({
url : 'index.php',
type : 'POST',
dataType : 'text',
data : 'cinema='+cinema,
cache : false,
async : false,
success: function(data){
$("cinemas option").remove();
$("cinemas").append(data);
console.log(cinema);
},
error: function(response)
{
console.log(response + ' ==> Error al seleccionar el cine')
}
});
});
});
*/
//Método 3: enviar una petición AJAX con GET. (NO FUNCIONA)
/*
$(document).ready(function(){
$("#select_cinema_session").change(function(){
var cinema = $('select[id=cinemas]').val();
//console.log($('select[id=cinemas]').val());
$.get(window.location + "?cinema=" + cinema, function(data,status){
console.log(cinema);
});
});
});
*/

View File

@ -701,6 +701,7 @@
"; ";
if($page === "FDI-Cines") echo"<script type='text/javascript' src='{$prefix}assets/js/promotions.js' ></script>\n"; if($page === "FDI-Cines") echo"<script type='text/javascript' src='{$prefix}assets/js/promotions.js' ></script>\n";
if($page === "Panel de Usuario") echo"<script type='text/javascript' src='{$prefix}assets/js/deleteConfirm.js' ></script>\n"; if($page === "Panel de Usuario") echo"<script type='text/javascript' src='{$prefix}assets/js/deleteConfirm.js' ></script>\n";
if($page === "Comprar Entrada") echo"<script type='text/javascript' src='{$prefix}assets/js/selectTicket.js' ></script>\n";
} }
} }

153
purchase/_old.index.php Normal file
View File

@ -0,0 +1,153 @@
<?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');
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;
$cinemas = [];
$sessions = [];
if(isset($_GET["film"])){
$filmDAO = new Film_DAO("complucine");
$film = $filmDAO->FilmData($_GET["film"]);
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 = '<form action="confirm.php" method="post">
<select name="cinemas" id="cinemas">';
foreach($cinemasIT as $value){
if($value == reset($cinemasIT)){
$cinemasListHTML .= '<option value="'.$value["cID"].'" selected>'.$value["NAME"].'</option>';
} else {
$cinemasListHTML .='<option value="'.$value["cID"].'">'.$value["NAME"].'</option>';
}
}
$cinemasListHTML .= '</select>';
} else {
$cinemasListHTML = '<select name="cinemas"><option value="" selected>No hay cines disponibles para esta película.</option></select></form>';
}
$fiml_id = $film->getId();
$cinema_id = $value["cID"];
$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 = '<select name="sessions" id="sessions">';
foreach ($sessionsIT as $value) {
if($TODAY <= $value["DATE"]){
if($value === reset($sessionsIT)){
$sessionsListHTML .= '<option value="'.$value["sID"].'" >Fecha: '.$value["DATE"].' | Hora: '.$value["HOUR"].' | Sala: '.$value["HALL"].'</option>';
} else {
$sessionsListHTML .='<option value="'.$value["sID"].'">Fecha: '.$value["DATE"].' | Hora:'.$value["HOUR"].' | Sala: '.$value["HALL"].'</option>';
}
$count++;
}
}
$sessionsListHTML .= '</select>';
if($count == 0) {
$sessionsListHTML = '<select name="sessions"><option value="" selected>No hay sesiones disponibles para esta película.</option></select>';
$pay = false;
}
} else {
$sessionsListHTML = '<select name="sessions"><option value="" selected>No hay sesiones disponibles para esta película.</option></select>';
$pay = false;
}
//$session_id = $value["sID"];
//$hall_id = $value["HALL"];
//$date_ = $value["DATE"];
//$hour_ = $value["HOUR"];
//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>
<p>Duración: '.$film->getDuration().' minutos</p>
<p>Idioma: '.$film->getLanguage().'</p>
</div>
<div class="column right">
<h2>Seleccione un Cine y una Sesión</h2><hr />
<h3>Cines</h3>
'.$cinemasListHTML.'
<h3>Sesiones</h3>
'.$sessionsListHTML.'
</div>
';
} else {
$reply = '<h1>No existe la película.</h1>';
$pay = false;
}
} else if(isset($_GET["cinema"])) {
$reply = '<h1>ESTAMOS TRABAJANDO EN ELLO</h1>';
$pay = false;
} else {
$reply = '<h1>No se ha encontrado película ni cine.</h1>';
$pay = false;
}
//Pay button:
if($pay){
$pay = '<input type="submit" id="submit" value="Pagar" />
</form>';
} else {
$pay = '</form>';
}
//Page-specific content:
$section = '<!-- Purchase -->
<section id="purchase">
<div class="row">
<section class="code purchase">
'.$reply.'
</section>
<section class="code purchase">
'.$pay.'
</section>
</div>
</section>
';
//General page content:
require RAIZ_APP.'/HTMLtemplate.php';
?>

View File

@ -0,0 +1,50 @@
<?php
include_once($prefix.'assets/php/form.php');
include_once($prefix.'assets/php/includes/session_dao.php');
include_once($prefix.'assets/php/includes/session.php');
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');
class FormSelectTicket extends Form {
public function __construct() {
parent::__construct('formSelectTicket');
}
protected function generaCamposFormulario($datos, $errores = array()){
// Se generan los mensajes de error si existen.
$htmlErroresGlobales = self::generaListaErroresGlobales($errores);
//$errorNombre = self::createMensajeError($errores, 'name', 'span', array('class' => 'error'));
$html = "";
return $html;
}
protected function procesaFormulario($datos){
$result = array();
//$nombre = $this->test_input($datos['name']) ?? null;
$nombre = $datos['name'] ?? null;
$nombre = strtolower($nombre);
if ( empty($nombre) || mb_strlen($nombre) < 3 || mb_strlen($nombre) > 15 ) {
$result['name'] = "El nombre tiene que tener\n una longitud de al menos\n 3 caracteres\n y menos de 15 caracteres.";
}
//$password = $this->test_input($datos['pass']) ?? null;
$password = $datos['pass'] ?? null;
if ( empty($password) || mb_strlen($password) < 4 ) {
$result['pass'] = "El password tiene que tener\n una longitud de al menos\n 4 caracteres.";
}
if (count($result) === 0) {
$result[] = "La compra aun está en desarrollo. Vuelva en unos días.";
}
return $result;
}
}
?>

View File

@ -15,6 +15,7 @@
$pay = true; $pay = true;
$film = null; $film = null;
$cinema = null;
$cinemas = []; $cinemas = [];
$sessions = []; $sessions = [];
if(isset($_GET["film"])){ if(isset($_GET["film"])){
@ -24,6 +25,7 @@
$tittle = $film->getTittle(); $tittle = $film->getTittle();
$cinemas = $filmDAO->getCinemas($_GET["film"]); $cinemas = $filmDAO->getCinemas($_GET["film"]);
$cinema_id = $_GET["cinema"];
if(!empty($cinemas)){ if(!empty($cinemas)){
$cinemasNames = new ArrayIterator(array()); $cinemasNames = new ArrayIterator(array());
$cinemasIDs = new ArrayIterator(array()); $cinemasIDs = new ArrayIterator(array());
@ -34,71 +36,79 @@
$cinemasIT = new MultipleIterator(MultipleIterator::MIT_KEYS_ASSOC); $cinemasIT = new MultipleIterator(MultipleIterator::MIT_KEYS_ASSOC);
$cinemasIT->attachIterator($cinemasIDs, "cID"); $cinemasIT->attachIterator($cinemasIDs, "cID");
$cinemasIT->attachIterator($cinemasNames, "NAME"); $cinemasIT->attachIterator($cinemasNames, "NAME");
$cinemasListHTML = '<form action="confirm.php" method="post"> $cinemasListHTML = '<form id="select_cinema">
<select name="cinemas" id="cinemas">'; <select name="cinemas" id="cinemas">';
foreach($cinemasIT as $value){ if(!isset($cinema_id)){
if($value == reset($cinemasIT)){ $cinemasListHTML .= '<option value="" selected>Selecciona un cine</option>';
$cinemasListHTML .= '<option value="'.$value["cID"].'" selected>'.$value["NAME"].'</option>'; foreach($cinemasIT as $value){
} else {
$cinemasListHTML .='<option value="'.$value["cID"].'">'.$value["NAME"].'</option>'; $cinemasListHTML .='<option value="'.$value["cID"].'">'.$value["NAME"].'</option>';
} }
} else {
foreach($cinemasIT as $value){
if($value["cID"] == $cinema_id){
$cinemasListHTML .= '<option value="'.$value["cID"].'" selected>'.$value["NAME"].'</option>';
} else {
$cinemasListHTML .='<option value="'.$value["cID"].'">'.$value["NAME"].'</option>';
}
}
} }
$cinemasListHTML .= '</select>'; $cinemasListHTML .= '</select>
</form>';
} else { } else {
$cinemasListHTML = '<select name="cinemas"><option value="" selected>No hay cines disponibles para esta película.</option></select></form>'; $cinemasListHTML = '<select name="cinemas"><option value="" selected>No hay cines disponibles para esta película.</option></select></form>';
} }
$fiml_id = $film->getId(); $fiml_id = $film->getId();
$cinema_id = $value["cID"];
$sessionsDAO = new SessionDAO("complucine"); if(isset($cinema_id)){
$sessions = $sessionsDAO->getSessions_Film_Cinema($fiml_id, $cinema_id); $sessionsDAO = new SessionDAO("complucine");
if(!empty($sessions)){ $sessions = $sessionsDAO->getSessions_Film_Cinema($fiml_id, $cinema_id);
$sessionsDates = new ArrayIterator(array()); if(!empty($sessions)){
$sessionsStarts = new ArrayIterator(array()); $sessionsDates = new ArrayIterator(array());
$sessionsHalls = new ArrayIterator(array()); $sessionsStarts = new ArrayIterator(array());
$sessionsIDs = new ArrayIterator(array()); $sessionsHalls = new ArrayIterator(array());
foreach($sessions as $key=>$value){ $sessionsIDs = new ArrayIterator(array());
$sessionsIDs[$key] = $value->getId(); foreach($sessions as $key=>$value){
$sessionsDates[$key] = date_format(date_create($value->getDate()), 'j-n-Y'); $sessionsIDs[$key] = $value->getId();
$sessionsHalls[$key] = $value->getIdhall(); $sessionsDates[$key] = date_format(date_create($value->getDate()), 'j-n-Y');
$sessionsStarts[$key] = $value->getStartTime(); $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 = '<select name="sessions" id="sessions">';
foreach ($sessionsIT as $value) {
if($TODAY <= $value["DATE"]){
if($value === reset($sessionsIT)){
$sessionsListHTML .= '<option value="'.$value["sID"].'" >Fecha: '.$value["DATE"].' | Hora: '.$value["HOUR"].' | Sala: '.$value["HALL"].'</option>';
} else {
$sessionsListHTML .='<option value="'.$value["sID"].'">Fecha: '.$value["DATE"].' | Hora:'.$value["HOUR"].' | Sala: '.$value["HALL"].'</option>';
}
$count++;
} }
} $sessionsIT = new MultipleIterator(MultipleIterator::MIT_KEYS_ASSOC);
$sessionsListHTML .= '</select>'; $sessionsIT->attachIterator($sessionsIDs, "sID");
$sessionsIT->attachIterator($sessionsDates, "DATE");
$sessionsIT->attachIterator($sessionsHalls, "HALL");
$sessionsIT->attachIterator($sessionsStarts, "HOUR");
if($count == 0) { $count = 0;
$sessionsListHTML = '<select name="sessions"><option value="" selected>No hay sesiones disponibles para esta película.</option></select>'; $sessionsListHTML = '<form id="select_session" action="confirm.php" method="post">
<select name="sessions" id="sessions">';
foreach ($sessionsIT as $value) {
if($TODAY <= $value["DATE"]){
if($value === reset($sessionsIT)){
$sessionsListHTML .= '<option value="'.$value["sID"].'" >Fecha: '.$value["DATE"].' | Hora: '.$value["HOUR"].' | Sala: '.$value["HALL"].'</option>';
} else {
$sessionsListHTML .='<option value="'.$value["sID"].'">Fecha: '.$value["DATE"].' | Hora:'.$value["HOUR"].' | Sala: '.$value["HALL"].'</option>';
}
$count++;
}
}
$sessionsListHTML .= '</select>';
if($count == 0) {
$sessionsListHTML = '<form><select name="sessions"><option value="" selected>No hay sesiones disponibles para esta película.</option></select></form>';
$pay = false;
}
} else {
$sessionsListHTML = '<form><select name="sessions"><option value="" selected>No hay sesiones disponibles para esta película.</option></select></form>';
$pay = false; $pay = false;
} }
} else { } else {
$sessionsListHTML = '<select name="sessions"><option value="" selected>No hay sesiones disponibles para esta película.</option></select>'; $sessionsListHTML = '<form><select name="sessions"><option value="" selected>Seleccione primero un cine.</option></select></form>';
$pay = false; $pay = false;
} }
//$session_id = $value["sID"];
//$hall_id = $value["HALL"];
//$date_ = $value["DATE"];
//$hour_ = $value["HOUR"];
//Reply: Depends on whether the purchase is to be made from a selected movie or a cinema. //Reply: Depends on whether the purchase is to be made from a selected movie or a cinema.
$reply = '<div class="column left"> $reply = '<div class="column left">
<h2>Película seleccionada: '.str_replace('_', ' ', $tittle).'</h2><hr /> <h2>Película seleccionada: '.str_replace('_', ' ', $tittle).'</h2><hr />
@ -126,14 +136,12 @@
$pay = false; $pay = false;
} }
//Pay button: //Pay button:
if($pay){ if($pay){
$pay = '<input type="submit" id="submit" value="Pagar" /> $pay = '<input type="submit" id="submit" value="Pagar" />
</form>'; </form>';
} else {
$pay = '</form>';
} }
//Page-specific content: //Page-specific content:
$section = '<!-- Purchase --> $section = '<!-- Purchase -->
<section id="purchase"> <section id="purchase">