Add files via upload

This commit is contained in:
Fernando Méndez 2021-05-25 12:21:50 +02:00 committed by GitHub
parent bf0bb38838
commit 4e1cdc6522
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 298 additions and 18 deletions

View File

@ -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") // Promociones (Cambiar por el contenido del array "promotions")
const IMAGENES = [ const IMAGENES = [
'../img/promos/promo_vuelve.jpg', '../img/promos/promo_vuelve.jpg',

View File

@ -30,5 +30,10 @@
$template->print_footer(); $template->print_footer();
?> ?>
<!-- Scripts -->
<?php
$template->print_scripts();
?>
</body> </body>
</html> </html>

View File

@ -121,6 +121,24 @@
return $cinemas; 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. //Create a new film Data Transfer Object.
public function loadFilm($id, $tittle, $duration, $language,$description, $img){ public function loadFilm($id, $tittle, $duration, $language,$description, $img){
return new Film( $id, $tittle, $duration, $language,$description, $img); return new Film( $id, $tittle, $duration, $language,$description, $img);

View File

@ -27,9 +27,12 @@
$sql = sprintf( "SELECT * FROM `session` WHERE id = '%d'", $id ); $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_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){ public function filmTittle($idfilm){
@ -57,6 +60,7 @@
return $session; return $session;
} }
//Returns a query to get all the session's data. //Returns a query to get all the session's data.
public function getAllSessions($hall, $cinema, $date){ public function getAllSessions($hall, $cinema, $date){
$date = date('Y-m-d', strtotime( $date ) ); $date = date('Y-m-d', strtotime( $date ) );

View File

@ -678,14 +678,18 @@
<a href='{$prefix}contacto/'>Contacto</a> | <a href='{$prefix}contacto/'>Contacto</a> |
<button id='css' onclick=\"cambiarCSS('$css');\">$nameCSS</button> <button id='css' onclick=\"cambiarCSS('$css');\">$nameCSS</button>
</footer>\n"; </footer>\n";
}
echo" //Print JS scripts:
<!-- Scripts --> function print_scripts(){
<script type='text/javascript' src='{$prefix}assets/js/jquery-3.2.1.min.js'></script> $prefix = $this->prefix;
<script src='{$prefix}assets/js/cambiarCSS.js'></script> $page = $this->page;
<script src='{$prefix}assets/js/checkForms.js'></script>
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";
} }
} }

View File

@ -2,6 +2,8 @@
//General Config File: //General Config File:
require_once(__DIR__.'/assets/php/config.php'); require_once(__DIR__.'/assets/php/config.php');
$promotions = "HOLA MUNDO";
//Page-specific content: //Page-specific content:
$section = '<!-- Undercard --> $section = '<!-- Undercard -->
<section id="cartelera"> <section id="cartelera">
@ -13,6 +15,7 @@
</section> </section>
<section id="promociones" class="row"> <section id="promociones" class="row">
<div class="code"> <div class="code">
<h2>Promociones</h2>
<section class="promotions"> <section class="promotions">
<button id="retroceder">Anterior</button> <button id="retroceder">Anterior</button>
<a href="promotions/" class="imagen"></a> <a href="promotions/" class="imagen"></a>
@ -24,6 +27,7 @@
</section> </section>
</div> </div>
</section> </section>
<input type="hidden" id="promotions" value="'.$promotions.'" />
'; ';
//General page content: //General page content:

View File

@ -4,11 +4,11 @@
//Specific page content: //Specific page content:
$section = '<!-- Promotions --> $section = '<!-- Promotions -->
<div class="row"> <section class="row">
<section id="promociones"> <section id="promociones">
'.$template->print_promotions().' '.$template->print_promotions().'
</section> </section>
</div> </section>
'; ';
//General page content: //General page content:

View File

@ -1,3 +1,24 @@
<?php <?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';
?> ?>

View 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
View 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';
?>

View File

@ -9,6 +9,9 @@
include_once($prefix.'assets/php/includes/cinema.php'); include_once($prefix.'assets/php/includes/cinema.php');
include_once($prefix.'assets/php/includes/session.php'); include_once($prefix.'assets/php/includes/session.php');
$TODAY = getdate();
$TODAY = "$TODAY[mday]"."-"."$TODAY[mon]"."-"."$TODAY[year]";
$pay = true; $pay = true;
$film = null; $film = null;
$cinemas = []; $cinemas = [];
@ -47,8 +50,7 @@
$fiml_id = $film->getId(); $fiml_id = $film->getId();
$cinema_id = $value["cID"]; $cinema_id = $value["cID"];
$cinemaDAO = new Cinema_DAO("complucine"); $sessions = $filmDAO->getSessions($_GET["film"]);
$sessions = $cinemaDAO->getSessions($value["cID"]);
if(!empty($sessions)){ if(!empty($sessions)){
$sessionsDates = new ArrayIterator(array()); $sessionsDates = new ArrayIterator(array());
$sessionsStarts = new ArrayIterator(array()); $sessionsStarts = new ArrayIterator(array());
@ -56,7 +58,7 @@
$sessionsIDs = new ArrayIterator(array()); $sessionsIDs = new ArrayIterator(array());
foreach($sessions as $key=>$value){ foreach($sessions as $key=>$value){
$sessionsIDs[$key] = $value->getId(); $sessionsIDs[$key] = $value->getId();
$sessionsDates[$key] = $value->getDate(); $sessionsDates[$key] = date_format(date_create($value->getDate()), 'j-n-Y');
$sessionsHalls[$key] = $value->getIdhall(); $sessionsHalls[$key] = $value->getIdhall();
$sessionsStarts[$key] = $value->getStartTime(); $sessionsStarts[$key] = $value->getStartTime();
} }
@ -68,10 +70,12 @@
$sessionsListHTML = '<select name="sessions">'; $sessionsListHTML = '<select name="sessions">';
foreach ($sessionsIT as $value) { foreach ($sessionsIT as $value) {
if($value == reset($sessionsIT)){ if($TODAY <= $value["DATE"]){
$sessionsListHTML .= '<option value="'.$value["sID"].'" selected>'.$value["DATE"].' | '.$value["HOUR"].' (Sala: '.$value["HALL"].') '.'</option>'; if($value == reset($sessionsIT)){
} else { $sessionsListHTML .= '<option value="'.$value["sID"].'" selected>'.$value["DATE"].' | '.$value["HOUR"].' (Sala: '.$value["HALL"].') '.'</option>';
$sessionsListHTML .='<option value="'.$value["sID"].'">'.$value["DATE"].' | '.$value["HOUR"].' (Sala: '.$value["HALL"].') '.'</option>'; } else {
$sessionsListHTML .='<option value="'.$value["sID"].'">'.$value["DATE"].' | '.$value["HOUR"].' (Sala: '.$value["HALL"].') '.'</option>';
}
} }
} }
$sessionsListHTML .= '</select>'; $sessionsListHTML .= '</select>';
@ -81,6 +85,8 @@
$session_id = $value["sID"]; $session_id = $value["sID"];
$hall_id = $value["HALL"]; $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">
@ -117,6 +123,8 @@
<input type="hidden" name="cinema_id" id="cinema_id" value='.$cinema_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="session_id" id="session_id" value='.$session_id.' />
<input type="hidden" name="hall_id" id="hall_id" value='.$hall_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" /> <input type="submit" id="submit" value="Pagar" />
</form>'; </form>';
} }