Delete purchase directory
This commit is contained in:
parent
4ed406793a
commit
a5c8dd4ff8
@ -1,21 +0,0 @@
|
||||
<?php
|
||||
//General Config File:
|
||||
require_once('../assets/php/config.php');
|
||||
|
||||
//echo $_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';
|
||||
?>
|
@ -1,121 +0,0 @@
|
||||
<?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 FormPurchase extends Form {
|
||||
|
||||
//Atributes:
|
||||
private $session; // Session of the film to be purchased.
|
||||
private $cinema; // Cinema of the film to be purchased.
|
||||
private $film; // Film to be purchased.
|
||||
private $years; // Actual year.
|
||||
private $months; // Months of the year.
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct('formPurchase');
|
||||
|
||||
$sessionDAO = new SessionDAO("complucine");
|
||||
$this->session = $sessionDAO->sessionData($_POST["session_id"]);
|
||||
|
||||
$filmDAO = new Film_DAO("complucine");
|
||||
$this->film = $filmDAO->FilmData($this->session->getIdfilm());
|
||||
|
||||
$cinemaDAO = new Cinema_DAO("complucine");
|
||||
$this->cinema = $cinemaDAO->cinemaData($this->session->getIdcinema());
|
||||
|
||||
$TODAY = getdate();
|
||||
$year = "$TODAY[year]";
|
||||
|
||||
$this->years = array();
|
||||
for($i = $year; $i < $year+10; $i++) array_push($this->years, $i);
|
||||
|
||||
$this->months = array();
|
||||
for($i = 1; $i <= 12; $i++) array_push($this->months, $i);
|
||||
}
|
||||
|
||||
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'));
|
||||
|
||||
$monthsHTML = "";
|
||||
foreach($this->months as $value){
|
||||
$monthsHTML .= "<option>".$value."</option>";
|
||||
}
|
||||
|
||||
$yearsHTML = "";
|
||||
foreach($this->years as $value){
|
||||
$yearsHTML .= "<option>".$value."</option>";
|
||||
}
|
||||
|
||||
$html = "<div class='row'>
|
||||
<fieldset id='datos_entrada'>
|
||||
<legend>Resumen de la Compra</legend>
|
||||
<p>Película: ".str_replace('_', ' ', strtoupper($this->film->getTittle()))."</p>
|
||||
<p>Cine: ".$this->cinema->getName()."</p>
|
||||
<p>Sala: ".$this->session->getIdhall()."</p>
|
||||
<p>Fecha: ".date_format(date_create($this->session->getDate()), 'd-m-Y')."</p>
|
||||
<p>Hora: ".$this->session->getStartTime()."</p>
|
||||
<p>Precio: ".$this->session->getSeatPrice()."€</p>
|
||||
</fieldset>
|
||||
<fieldset id='pagar_entrada'><pre>".$htmlErroresGlobales."</pre>
|
||||
<legend>Datos Bancarios</legend>
|
||||
<label for='card-holder'>Titular de la Tarjeta:</label><br />
|
||||
<input type='text' id='card-holder' class='card-holder' required />
|
||||
<br />
|
||||
<label for='card-number'>Número de Tarjeta: </label><br />
|
||||
<input type='num' id='card-number-0' class='input-cart-number' placeholder='XXXX' maxlength='4' required />
|
||||
<input type='num' id='card-number-1' class='input-cart-number' placeholder='XXXX' maxlength='4' required />
|
||||
<input type='num' id='card-number-2' class='input-cart-number' placeholder='XXXX' maxlength='4' required />
|
||||
<input type='num' id='card-number-3' class='input-cart-number' placeholder='XXXX' maxlength='4' required />
|
||||
<label for='card-cvv'>CVV: </label>
|
||||
<input type='text' id='card-cvv' class='fieldset-cvv' maxlength='3' placeholder='XXX' required />
|
||||
<br />
|
||||
<label for='card-expiration'>Fecha de Expiración:</label><br />
|
||||
<select id='card-expiration-month' required>
|
||||
".$monthsHTML."
|
||||
</select>
|
||||
<select id='card-expiration-year' required>
|
||||
".$yearsHTML."
|
||||
</select>
|
||||
</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;
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,150 +0,0 @@
|
||||
<?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 = '<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"];
|
||||
|
||||
$sessionsDAO = new SessionDAO("complucine");
|
||||
$sessions = $sessionsDAO->getSessions_Film_Cinema($fiml_id, $cinema_id);
|
||||
//print_r($sessions);
|
||||
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>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>';
|
||||
}
|
||||
}
|
||||
}
|
||||
$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 />
|
||||
<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 = '<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';
|
||||
?>
|
Loading…
Reference in New Issue
Block a user