Add files via upload
This commit is contained in:
parent
bf0bb38838
commit
4e1cdc6522
@ -1,4 +1,6 @@
|
||||
window.onload = function (promotions) {
|
||||
window.onload = function () {
|
||||
var promos = document.getElementById("promotions").value;
|
||||
console.log(promos);
|
||||
// Promociones (Cambiar por el contenido del array "promotions")
|
||||
const IMAGENES = [
|
||||
'../img/promos/promo_vuelve.jpg',
|
||||
|
@ -30,5 +30,10 @@
|
||||
$template->print_footer();
|
||||
?>
|
||||
|
||||
<!-- Scripts -->
|
||||
<?php
|
||||
$template->print_scripts();
|
||||
?>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -121,6 +121,24 @@
|
||||
return $cinemas;
|
||||
}
|
||||
|
||||
//Get sessions associated with a film.
|
||||
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 film ON session.idfilm = film.id WHERE film.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 loadFilm($id, $tittle, $duration, $language,$description, $img){
|
||||
return new Film( $id, $tittle, $duration, $language,$description, $img);
|
||||
|
@ -27,9 +27,12 @@
|
||||
$sql = sprintf( "SELECT * FROM `session` WHERE id = '%d'", $id );
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database en sessionData con la id '. $id);
|
||||
|
||||
$resul = mysqli_fetch_array($resul);
|
||||
while($fila=$resul->fetch_assoc()){
|
||||
$session = $this->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 $resul;
|
||||
return $session;
|
||||
}
|
||||
|
||||
public function filmTittle($idfilm){
|
||||
@ -57,6 +60,7 @@
|
||||
|
||||
return $session;
|
||||
}
|
||||
|
||||
//Returns a query to get all the session's data.
|
||||
public function getAllSessions($hall, $cinema, $date){
|
||||
$date = date('Y-m-d', strtotime( $date ) );
|
||||
|
@ -678,14 +678,18 @@
|
||||
<a href='{$prefix}contacto/'>Contacto</a> |
|
||||
<button id='css' onclick=\"cambiarCSS('$css');\">$nameCSS</button>
|
||||
</footer>\n";
|
||||
}
|
||||
|
||||
echo"
|
||||
<!-- Scripts -->
|
||||
<script type='text/javascript' src='{$prefix}assets/js/jquery-3.2.1.min.js'></script>
|
||||
<script src='{$prefix}assets/js/cambiarCSS.js'></script>
|
||||
<script src='{$prefix}assets/js/checkForms.js'></script>
|
||||
//Print JS scripts:
|
||||
function print_scripts(){
|
||||
$prefix = $this->prefix;
|
||||
$page = $this->page;
|
||||
|
||||
echo"<script type='text/javascript' src='{$prefix}assets/js/jquery-3.2.1.min.js'></script>
|
||||
<script type='text/javascript' src='{$prefix}assets/js/cambiarCSS.js'></script>
|
||||
<script type='text/javascript' src='{$prefix}assets/js/checkForms.js'></script>
|
||||
";
|
||||
if($page === "FDI-Cines") echo"<script 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";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,8 @@
|
||||
//General Config File:
|
||||
require_once(__DIR__.'/assets/php/config.php');
|
||||
|
||||
$promotions = "HOLA MUNDO";
|
||||
|
||||
//Page-specific content:
|
||||
$section = '<!-- Undercard -->
|
||||
<section id="cartelera">
|
||||
@ -13,6 +15,7 @@
|
||||
</section>
|
||||
<section id="promociones" class="row">
|
||||
<div class="code">
|
||||
<h2>Promociones</h2>
|
||||
<section class="promotions">
|
||||
<button id="retroceder">Anterior</button>
|
||||
<a href="promotions/" class="imagen"></a>
|
||||
@ -24,6 +27,7 @@
|
||||
</section>
|
||||
</div>
|
||||
</section>
|
||||
<input type="hidden" id="promotions" value="'.$promotions.'" />
|
||||
';
|
||||
|
||||
//General page content:
|
||||
|
@ -4,11 +4,11 @@
|
||||
|
||||
//Specific page content:
|
||||
$section = '<!-- Promotions -->
|
||||
<div class="row">
|
||||
<section class="row">
|
||||
<section id="promociones">
|
||||
'.$template->print_promotions().'
|
||||
</section>
|
||||
</div>
|
||||
</section>
|
||||
';
|
||||
|
||||
//General page content:
|
||||
|
@ -1,3 +1,24 @@
|
||||
<?php
|
||||
//General Config File:
|
||||
require_once('../assets/php/config.php');
|
||||
|
||||
$sessionDAO = new SessionDAO("complucine");
|
||||
//$session = $sessionDAO->loadSession($_POST["session_id"], $_POST["film_id"], $_POST["hall_id"], $_POST["cinema_id"], $_POST["date_"], $_POST["hour_"], "12", null, null);
|
||||
$session = $sessionDAO->sessionData($_POST["session_id"]);
|
||||
|
||||
|
||||
//Purchase form:
|
||||
require_once('includes/formPurchase.php');
|
||||
$form = new FormPurchase();
|
||||
$formHTML = $form->gestiona();
|
||||
|
||||
//Page-specific content:
|
||||
$section = '<div class="code">
|
||||
<h2>Completar la Compra</h2><hr />
|
||||
<!-- Purchase Form -->
|
||||
'.$formHTML.'
|
||||
</div>';
|
||||
|
||||
//General page content:
|
||||
require RAIZ_APP.'/HTMLtemplate.php';
|
||||
?>
|
66
purchase/includes/formPurchase.php
Normal file
66
purchase/includes/formPurchase.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?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');
|
||||
|
||||
class FormPurchase extends Form {
|
||||
|
||||
//Atributes:
|
||||
private $user; // User who is going to log-in.
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct('formPurchase');
|
||||
}
|
||||
|
||||
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'));
|
||||
$errorPassword = self::createMensajeError($errores, 'pass', 'span', array('class' => 'error'));
|
||||
|
||||
$html = "<div class='row'>
|
||||
<fieldset id='pagar_entrada'><pre>".$htmlErroresGlobales."</pre>
|
||||
<legend>Resumen de la Compra</legend>
|
||||
<p>Película: ".$session->getIdfilm()."</p>
|
||||
<p>Cine: ".$session->getIdcinema()."</p>
|
||||
<p>Sala: ".$session->getIdhall()."</p>
|
||||
<p>Fecha: ".date_format(date_create($session->getDate()), 'd-m-Y')."</p>
|
||||
<p>Hora: ".$session->getStartTime()."</p>
|
||||
<p>Precio: ".$session->getSeatPrice()."€</p>
|
||||
<legend>Datos Bancarios</legend>
|
||||
<input type='text' name='account' id='account' value='' placeholder='Cuenta Bancaria [En desarrollo...]' required/><pre>".$errorNombre."</pre>
|
||||
</fieldset>
|
||||
<div class='actions'>
|
||||
<input type='submit' id='submit' value='Pagar' class='primary' />
|
||||
<input type='reset' id='reset' value='Borrar' />
|
||||
</div>
|
||||
</div>";
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
?>
|
148
purchase/index copy.php
Normal file
148
purchase/index copy.php
Normal file
@ -0,0 +1,148 @@
|
||||
<?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.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 = '<select name="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>';
|
||||
}
|
||||
|
||||
$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] = 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");
|
||||
|
||||
$sessionsListHTML = '<select name="sessions">';
|
||||
foreach ($sessionsIT as $value) {
|
||||
if($TODAY <= $value["DATE"]){
|
||||
if($value == reset($sessionsIT)){
|
||||
$sessionsListHTML .= '<option value="'.$value["sID"].'" selected>'.$value["DATE"].' | '.$value["HOUR"].' (Sala: '.$value["HALL"].') '.'</option>';
|
||||
} else {
|
||||
$sessionsListHTML .='<option value="'.$value["sID"].'">'.$value["DATE"].' | '.$value["HOUR"].' (Sala: '.$value["HALL"].') '.'</option>';
|
||||
}
|
||||
}
|
||||
}
|
||||
$sessionsListHTML .= '</select>';
|
||||
} else {
|
||||
$sessionsListHTML = '<select name="sessions"><option value="" selected>No hay sesiones disponibles para esta película.</option></select>';
|
||||
}
|
||||
|
||||
$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 />
|
||||
<br /><h3>Cines</h3>
|
||||
'.$cinemasListHTML.'<br />
|
||||
<br/><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 = '<form action="confirm.php" method="post">
|
||||
<input type="hidden" name="film_id" id="film_id" value='.$fiml_id.' />
|
||||
<input type="hidden" name="cinema_id" id="cinema_id" value='.$cinema_id.' />
|
||||
<input type="hidden" name="session_id" id="session_id" value='.$session_id.' />
|
||||
<input type="hidden" name="hall_id" id="hall_id" value='.$hall_id.' />
|
||||
<input type="hidden" name="date_" id="date_" value='.$date_.' />
|
||||
<input type="hidden" name="hour_" id="hour_" value='.$hour_.' />
|
||||
<input type="submit" id="submit" value="Pagar" />
|
||||
</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';
|
||||
?>
|
@ -9,6 +9,9 @@
|
||||
include_once($prefix.'assets/php/includes/cinema.php');
|
||||
include_once($prefix.'assets/php/includes/session.php');
|
||||
|
||||
$TODAY = getdate();
|
||||
$TODAY = "$TODAY[mday]"."-"."$TODAY[mon]"."-"."$TODAY[year]";
|
||||
|
||||
$pay = true;
|
||||
$film = null;
|
||||
$cinemas = [];
|
||||
@ -47,8 +50,7 @@
|
||||
$fiml_id = $film->getId();
|
||||
$cinema_id = $value["cID"];
|
||||
|
||||
$cinemaDAO = new Cinema_DAO("complucine");
|
||||
$sessions = $cinemaDAO->getSessions($value["cID"]);
|
||||
$sessions = $filmDAO->getSessions($_GET["film"]);
|
||||
if(!empty($sessions)){
|
||||
$sessionsDates = new ArrayIterator(array());
|
||||
$sessionsStarts = new ArrayIterator(array());
|
||||
@ -56,7 +58,7 @@
|
||||
$sessionsIDs = new ArrayIterator(array());
|
||||
foreach($sessions as $key=>$value){
|
||||
$sessionsIDs[$key] = $value->getId();
|
||||
$sessionsDates[$key] = $value->getDate();
|
||||
$sessionsDates[$key] = date_format(date_create($value->getDate()), 'j-n-Y');
|
||||
$sessionsHalls[$key] = $value->getIdhall();
|
||||
$sessionsStarts[$key] = $value->getStartTime();
|
||||
}
|
||||
@ -68,12 +70,14 @@
|
||||
|
||||
$sessionsListHTML = '<select name="sessions">';
|
||||
foreach ($sessionsIT as $value) {
|
||||
if($TODAY <= $value["DATE"]){
|
||||
if($value == reset($sessionsIT)){
|
||||
$sessionsListHTML .= '<option value="'.$value["sID"].'" selected>'.$value["DATE"].' | '.$value["HOUR"].' (Sala: '.$value["HALL"].') '.'</option>';
|
||||
} else {
|
||||
$sessionsListHTML .='<option value="'.$value["sID"].'">'.$value["DATE"].' | '.$value["HOUR"].' (Sala: '.$value["HALL"].') '.'</option>';
|
||||
}
|
||||
}
|
||||
}
|
||||
$sessionsListHTML .= '</select>';
|
||||
} else {
|
||||
$sessionsListHTML = '<select name="sessions"><option value="" selected>No hay sesiones disponibles para esta película.</option></select>';
|
||||
@ -81,6 +85,8 @@
|
||||
|
||||
$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">
|
||||
@ -117,6 +123,8 @@
|
||||
<input type="hidden" name="cinema_id" id="cinema_id" value='.$cinema_id.' />
|
||||
<input type="hidden" name="session_id" id="session_id" value='.$session_id.' />
|
||||
<input type="hidden" name="hall_id" id="hall_id" value='.$hall_id.' />
|
||||
<input type="hidden" name="date_" id="date_" value='.$date_.' />
|
||||
<input type="hidden" name="hour_" id="hour_" value='.$hour_.' />
|
||||
<input type="submit" id="submit" value="Pagar" />
|
||||
</form>';
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user