Delete purchase directory

This commit is contained in:
Fernando Méndez 2021-07-02 17:54:59 +02:00 committed by GitHub
parent e01c135238
commit 0ffda6f698
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 0 additions and 906 deletions

View File

@ -1,19 +0,0 @@
<?php
//General Config File:
require_once('../assets/php/config.php');
//Purchase form:
require_once('includes/formPurchase.php');
$form = new FormPurchase();
$formHTML = $form->gestiona();
//Page-specific content:
$section = '<div class="code pay">
<h2>Completar la Compra</h2><hr />
<!-- Purchase Form -->
'.$formHTML.'
</div>';
//General page content:
require RAIZ_APP.'/HTMLtemplate.php';
?>

View File

@ -1,232 +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');
include_once($prefix.'assets/php/includes/hall_dao.php');
include_once($prefix.'assets/php/includes/hall.php');
include_once($prefix.'assets/php/includes/seat_dao.php');
include_once($prefix.'assets/php/includes/seat.php');
include_once($prefix.'assets/php/includes/purchase_dao.php');
include_once($prefix.'assets/php/includes/purchase.php');
include_once($prefix.'assets/php/includes/promotion_dao.php');
include_once($prefix.'assets/php/includes/user.php');
class FormPurchase extends Form {
//Atributes:
private $film; // Film to be purchased.
private $session; // Session of the film to be purchased.
private $cinema; // Cinema of the film to be purchased.
private $hall; // Hall of the film to be purchased.
private $seat; // Seat of the film to be purchased.
private $row; // Row of the seat.
private $col; // Column of the seat.
private $code; // Promotional code.
private $years; // Actual year.
private $months; // Months of the year.
private $_TODAY; // Actual date.
public function __construct() {
parent::__construct('formPurchase');
$sessionDAO = new SessionDAO("complucine");
$this->session = $sessionDAO->sessionData($_POST["sessions"]);
$filmDAO = new Film_DAO("complucine");
$this->film = $filmDAO->FilmData($this->session->getIdfilm());
$cinemaDAO = new Cinema_DAO("complucine");
$this->cinema = $cinemaDAO->cinemaData($this->session->getIdcinema());
$hallDAO = new HallDAO("complucine");
$this->hall = $hallDAO->HallData($this->session->getIdhall());
$this->seat = array();
$this->row = array();
$this->col = array();
$rows = $this->hall->getNumRows();
$cols = $this->hall->getNumCol();
for($i = 0; $i <= $rows; $i++){
for($j = 0; $j <= $cols; $j++){
$seat = $i.$j;
if(isset($_POST["checkbox".$seat])){
array_push($this->seat, $i."-".$j);
array_push($this->row, $i);
array_push($this->col, $j);
}
}
}
$promoDAO = new Promotion_DAO("complucine");
$this->code = intval(0);
if(isset($_POST["code"]) && $_POST["code"] !== ""){
if($promoDAO->GetPromotion($_POST["code"])->data_seek(0)){
$this->code = intval(2);
}
}
$TODAY = getdate();
$year = "$TODAY[year]";
$this->_TODAY = "$TODAY[year]-$TODAY[month]-$TODAY[mday] $TODAY[hours]:$TODAY[minutes]:$TODAY[seconds]";
$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, 'card-holder', 'span', array('class' => 'error'));
$errorCardNumber = self::createMensajeError($errores, 'card-number-0', 'span', array('class' => 'error'));
$errorCVV = self::createMensajeError($errores, 'card-cvv', 'span', array('class' => 'error'));
$errorCardExpirationMonth = self::createMensajeError($errores, 'card-expiration-month', 'span', array('class' => 'error'));
$errorCardExpirationYear = self::createMensajeError($errores, 'card-expiration-year', 'span', array('class' => 'error'));
$monthsHTML = "";
foreach($this->months as $value){
$monthsHTML .= "<option>".$value."</option>";
}
$yearsHTML = "";
foreach($this->years as $value){
$yearsHTML .= "<option>".$value."</option>";
}
if($this->session->getSeatsFull()){
$html = "<div class='code info'>
<h2>La sesión está llena, no quedan asientos disponibles.</h2><hr />
<p>Vuelva atrás para selecionar otra sesión.</p>
</div>";
} else {
if(!empty($this->seat)){
$seats = "";
foreach($this->seat as $value){
$seats .= $value.", ";
}
$promo = "";
if($this->code > 0) $promo = "<pre>(Se ha aplicado un descuento por código promocional).</pre>";
$html = "<div class='row'>
<fieldset id='datos_entrada'>
<legend>Resumen de la Compra</legend>
<img src='"."../img/films/".$this->film->getImg()."' alt='".$this->film->getTittle()."' />
<p>Película: ".str_replace('_', ' ', strtoupper($this->film->getTittle()))."</p>
<p>Cine: ".$this->cinema->getName()."</p>
<p>Sala: ".$this->session->getIdhall()."</p>
<p>Asiento(s):".$seats."</p>
<p>Fecha: ".date_format(date_create($this->session->getDate()), 'd-m-Y')."</p>
<p>Hora: ".$this->session->getStartTime()."</p>
<p>Precio Total: ".intval($this->session->getSeatPrice()*count($this->seat)-$this->code)." (Precio por asiento: ".$this->session->getSeatPrice()." )</p>
<p>".$promo."</p>
</fieldset>
<fieldset id='pagar_entrada'><pre>".$htmlErroresGlobales."</pre>
<legend>Datos Bancarios</legend>
<label for='card-holder'>Titular de la Tarjeta: <span id='cardNameValid'>&#x2714;</span><span id='cardNameInvalid'>&#x274C;</span></label><pre>".$errorNombre."</pre><br />
<input type='text' name='card-holder' id='card-holder' class='card-holder' placeholder='NOMBRE APELLIDO1 APELLIDO2' required />
<br />
<label for='card-number'>Número de Tarjeta: <span id='carNumberValid'>&#x2714;</span><span id='cardNumerInvalid'>&#x274C;</span></label><pre>".$errorCardNumber."</pre><br />
<input type='num' name='card-number-0' id='card-number-0' class='input-cart-number' placeholder='XXXX' maxlength='4' required />
<input type='num' name='card-number-1' id='card-number-1' class='input-cart-number' placeholder='XXXX' maxlength='4' required />
<input type='num' name='card-number-2' id='card-number-2' class='input-cart-number' placeholder='XXXX' maxlength='4' required />
<input type='num' name='card-number-3' id='card-number-3' class='input-cart-number' placeholder='XXXX' maxlength='4' required />
<label for='card-cvv'>CVV: <span id='cvvValid'>&#x2714;</span><span id='cvvInvalid'>&#x274C;</span></label>
<input type='text' name='card-cvv' id='card-cvv' class='fieldset-cvv' maxlength='3' placeholder='XXX' required /><pre>".$errorCVV."</pre>
<br />
<label for='card-expiration'>Fecha de Expiración: <span id='dateValid'>&#x2714;</span><span id='dateInvalid'>&#x274C;</span></label><pre>".$errorCardExpirationMonth.$errorCardExpirationYear."</pre><br />
<select name='card-expiration-month' id='card-expiration-month' required>
".$monthsHTML."
</select>
<select name='card-expiration-year' id='card-expiration-year' required>
".$yearsHTML."
</select>
</fieldset>
<div class='actions'>
<input type='hidden' name='sessions' id='sessions' value='".$_POST["sessions"]."' />
<input type='hidden' name='row' id='row' value='".serialize($this->row)."' />
<input type='hidden' name='col' id='col' value='".serialize($this->col)."' />
<input type='submit' id='submit' value='Pagar' class='primary' />
<input type='reset' id='reset' value='Borrar' />
</div>
</div>";
} else {
$html = "<div class='code info'>
<h2>No se ha seleccionado asiento(s).</h2>
<p>Vuelva atrás para selecionar una butaca.</p>
<button id='go-back'>Volver</button>
</div>";
}
}
return $html;
}
protected function procesaFormulario($datos){
$result = array();
$nombre = $this->test_input($datos['card-holder']) ?? null;
$nombre = strtolower($nombre);
if ( empty($nombre) ) {
$result['card-holder'] = "El nombre no puede estar vacío.";
}
for($i = 0; $i < 4; $i++){
$card_numer = $this->test_input($datos['card-number-'.$i]) ?? null;
if ( empty($card_numer) || mb_strlen($card_numer) < 4 ) {
$result['card-number-0'] = "La tarjeta debe tener 16 dígitos.";
}
}
$cvv = $this->test_input($datos['card-cvv']) ?? null;
if ( empty($cvv) || mb_strlen($cvv) < 3 ) {
$result['card-cvv'] = "El CVV debe tener 3 números.";
}
$month = $this->test_input($datos['card-expiration-month']) ?? null;
//$TODAY = getdate();
//$actualMonth = "$TODAY[month]";
if ( empty($month) /*|| $month < $actualMonth*/) {
$result['card-expiration-month'] = "El mes de expiración no es correcto.";
}
$year = $this->test_input($datos['card-expiration-year']) ?? null;
if ( empty($year) ) {
$result['card-expiration-year'] = "El año de expiración no es correcto.";
}
if (count($result) === 0) {
if(isset($_SESSION["login"]) && $_SESSION["login"] == true){
$purchaseDAO = new PurchaseDAO("complucine");
$count = count(unserialize($datos["row"]));
$rows = unserialize($datos["row"]); $cols = unserialize($datos["col"]);
for($i = 0; $i < $count; $i++){
if($purchaseDAO->createPurchase(unserialize($_SESSION["user"])->getId(), $this->session->getId(), $this->session->getIdhall(), $this->cinema->getId(), $rows[$i], $cols[$i], date("Y-m-d H:i:s"))){
$purchase = new Purchase(unserialize($_SESSION["user"])->getId(), $this->session->getId(), $this->session->getIdhall(), $this->cinema->getId(), $datos["row"], $datos["col"], strftime("%A %e de %B de %Y a las %H:%M"));
$_SESSION["purchase"] = serialize($purchase);
$_SESSION["film_purchase"] = serialize($this->film);
$result = "resume.php";
} else {
$result[] = "Error al realizar la compra.";
}
}
} else {
$purchase = new Purchase("null", $this->session->getId(), $this->session->getIdhall(), $this->cinema->getId(), $datos["row"], $datos["col"], strftime("%A %e de %B de %Y a las %H:%M"));
$_SESSION["purchase"] = serialize($purchase);
$_SESSION["film_purchase"] = serialize($this->film);
$result = "resume.php";
}
}
return $result;
}
}
?>

View File

@ -1,272 +0,0 @@
<?php
include_once($prefix.'assets/php/form.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');
include_once($prefix.'assets/php/includes/session_dao.php');
include_once($prefix.'assets/php/includes/session.php');
include_once($prefix.'assets/php/includes/hall_dao.php');
include_once($prefix.'assets/php/includes/hall.php');
class FormSelectCinemaSession extends Form {
//Atributes:
//private $session; // Session of the film to be purchased.
//private $cinema; // Cinema of the film to be purchased.
//private $hall; // Hall of the film to be purchased.
//private $film; // Film to be purchased.
private $_TODAY; // Actual date.
public function __construct() {
$options = array("action" => "selectSeat.php");
parent::__construct('formSelectCinemaSession', $options);
$TODAY = getdate();
$this->_TODAY = "$TODAY[mday]"."-"."$TODAY[mon]"."-"."$TODAY[year]";
}
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'));
$errorFilm = self::createMensajeError($errores, 'films', 'span', array('class' => 'error'));
$errorSession = self::createMensajeError($errores, 'sessions', 'span', array('class' => 'error'));
$errorCode = self::createMensajeError($errores, 'code', '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 = '<section id="select_cinema"><pre>'.$htmlErroresGlobales.'</pre>
<select name="cinemas" id="cinemas"><pre>'.$errorCinema.'</pre>';
if(!isset($cinema_id)){
$cinemasListHTML .= '<option value="" selected>Selecciona un cine</option>';
foreach($cinemasIT as $value){
$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>
</section>';
} else {
$cinemasListHTML = '<select name="cinemas"><option value="" selected>No hay cines disponibles para esta película.</option></select>';
}
$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 = '<select name="sessions" id="sessions"><pre>'.$errorSession.'</pre>';
foreach ($sessionsIT as $value) {
if(strtotime($this->_TODAY) <= strtotime($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;
}
} else {
$sessionsListHTML = '<select name="sessions"><option value="" selected>Primero seleccione un cine.</option></select>';
$pay = false;
}
//Reply: Depends on whether the purchase is to be made from a selected movie or a cinema.
$html = '<div class="column left">
<h2>Película seleccionada: '.str_replace('_', ' ', $tittle).'</h2><hr />
<div class="image"><img src="../img/films/'.$image.'" 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.'
<h3><a href="../promotions/" target="_blank">Aplicar código promocional</a><span id="codeValid">&#x2714;</span><span id="codeInvalid">&#x274C;</span></h3>
<input type="text" name="code" id="code" value="" placeholder="Código pormocional" /><pre>'.$errorCode.'</pre>
</div>';
} else {
$html = '<h1>No existe la película.</h1>';
$pay = false;
}
} else if(isset($_GET["cinema"])) {
$pay = false;
$cinemaDAO = new Cinema_DAO("complucine");
$cinema = $cinemaDAO->cinemaData($_GET["cinema"]);
if($cinema){
$cinema_name = $cinema->getName();
$cinema_address = $cinema->getDirection();
$cinema_tlf = $cinema->getPhone();
$films = $cinemaDAO->getFilms($_GET["cinema"]);
$film_id = $_GET["film"];
if(!empty($films)){
$filmsNames = new ArrayIterator(array());
$filmsIDs = new ArrayIterator(array());
foreach($films as $key=>$value){
$filmsIDs[$key] = $value->getId();
$filmsNames[$key] = str_replace('_', ' ', $value->getTittle());
}
$filmsIT = new MultipleIterator(MultipleIterator::MIT_KEYS_ASSOC);
$filmsIT->attachIterator($filmsIDs, "fID");
$filmsIT->attachIterator($filmsNames, "NAME");
$filmsListHTML = '<section id="select_film"><pre>'.$htmlErroresGlobales.'</pre>
<select name="films" id="films"><pre>'.$errorFilm.'</pre>';
if(!empty($films)){
$filmsListHTML .= '<option value="" selected>Selecciona una película</option>';
foreach($filmsIT as $value){
$filmsListHTML .='<option value="'.$value["fID"].'">'.$value["NAME"].'</option>';
}
} else {
foreach($filmsIT as $value){
if($value["cID"] == $film_id){
$filmsListHTML .= '<option value="'.$value["fID"].'" selected>'.$value["NAME"].'</option>';
} else {
$filmsListHTML .='<option value="'.$value["fID"].'">'.$value["NAME"].'</option>';
}
}
}
$filmsListHTML .= '</select>
</section>';
} else {
$filmsListHTML = '<select name="films"><option value="" selected>No hay películas disponibles para este cine.</option></select>';
}
//Reply: Depends on whether the purchase is to be made from a selected movie or a cinema.
$html = '<div class="column left">
<h2>Cine seleccionado: '.$cinema_name.'</h2><hr />
<div class="image"><img src="../img/sala1.jpg" alt="'.$cinema_name.'" /></div>
<p>Dirección: '.$cinema_address.'</p>
<p>Teléfono: '.$cinema_tlf.'</p>
</div>
<div class="column right">
<h2>Seleccione una Película y una Sesión</h2><hr />
<h3>Películas</h3>
'.$filmsListHTML.'
<h3>Sesiones</h3>
<select>
<option value="" selected>Primero selecione una película.</option>
<select>
</div>';
} else {
$html = '<h1>No existe el cine.</h1>';
$pay = false;
}
} else {
$html = '<h1>No se ha encontrado película ni cine.</h1>
<button id="go-back">Volver</button>';
$pay = false;
}
//Select seat button:
if($pay){
$pay = '<input type="submit" id="submit" value="Seleccionar Asiento" />';
} else {
$pay = '<button id="go-back">Volver</button>';
}
return '
<section class="code purchase">
'.$html.'
</section>
<section class="code purchase">
'.$pay.'
</section>';
}
protected function procesaFormulario($datos){
$result = array();
$cinema = $this->test_input($datos['cinemas']) ?? null;
if ( empty($cinema) ) {
$result['cinemas'] = "Selecciona un cine.";
}
$films = $this->test_input($datos['films']) ?? null;
if ( empty($films) ) {
$result['films'] = "Selecciona una película.";
}
$session = $this->test_input($datos['sessions']) ?? null;
if ( empty($session) ) {
$result['sessions'] = "Selecciona una sesión.";
}
$code = $this->test_input($datos['code']) ?? null;
$avaliable = "../assets/php/common/checkPromo.php?code=".$code;
if ( !empty($code) && mb_strlen($code) != 8 && $avaliable === "avaliable") {
$result['code'] = "El código promocional no es válido.";
}
if (count($result) === 0) {
$result = "selectSeat.php";
}
return $result;
}
}
?>

View File

@ -1,108 +0,0 @@
<?php
include_once($prefix.'assets/php/form.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');
include_once($prefix.'assets/php/includes/session_dao.php');
include_once($prefix.'assets/php/includes/session.php');
include_once($prefix.'assets/php/includes/hall_dao.php');
include_once($prefix.'assets/php/includes/hall.php');
include_once($prefix.'assets/php/includes/seat_dao.php');
include_once($prefix.'assets/php/includes/seat.php');
class FormSelectSeat extends Form {
//Atributes:
public function __construct() {
$options = array("action" => "confirm.php");
parent::__construct('formSelectSeat', $options);
}
protected function generaCamposFormulario($datos, $errores = array()){
// Se generan los mensajes de error, si existen.
$htmlErroresGlobales = self::generaListaErroresGlobales($errores);
$errorSeat = self::createMensajeError($errores, 'seats', 'span', array('class' => 'error'));
$sessionDAO = new SessionDAO("complucine");
$session = $sessionDAO->sessionData($_POST["sessions"]);
$hallDAO = new HallDAO("complucine");
$hall = $hallDAO->HallData($session->getIdhall());
$seatDAO = new SeatDAO("complucine");
$seats = $seatDAO->getAllSeats($session->getIdhall(), $session->getIdcinema());
$rows = $hall->getNumRows();
$cols = $hall->getNumCol();
//$seats = $hall->getTotalSeats();
$seats_map = array();
for($i = 1; $i <= $rows; $i++){
for($j = 1; $j <= $cols; $j++){
$seats_map[$i][$j] = $seats[$i]->getState();
}
}
$html ='<h2>Seleccionar un Asiento</h2><hr />
<h3 class="table_title">Pantalla</h3>
<table class="seat">
<thead>
<tr>
<th> </th>
';
for($j = 1; $j <= $cols; $j++){
$html .= '<th>'.$j.'</th>
';
}
$html .= '</tr>
</thead>
<tbody>';
for($i = 1; $i <= $rows; $i++){
$html .= '
<tr>
<td>'.$i.'</td>
';
for($j = 1; $j <= $cols; $j++){
if($seats_map[$i][$j] >= 0){
$html .= '<td> <input type="checkbox" class="check_box" name="checkbox'.$i.$j.'" value="'.$seats_map[$i][$j].'" id="checkbox'.$i.$j.'" /> <label for="checkbox'.$i.$j.'"> </td> <!-- checked -->
';}
else {
$html .= '<td> <input type="checkbox" class="check_box" name="checkbox'.$i.$j.'" value="'.$seats_map[$i][$j].'" id="checkbox'.$i.$j.'" disabled /> <label for="checkbox'.$i.$j.'"> </td>
';}
}
$html .='</tr>';
}
$html .= '
</tbody>
</table>';
//Pay button:
$pay = '<input type="hidden" name="sessions" id="sessions" value="'.$_POST["sessions"].'" />
<input type="hidden" name="code" id="code" value="'.$_POST["code"].'" />
<input type="submit" id="submit" value="Pagar" />';
return '
<section class="code purchase">
'.$html.'
</section>
<section class="code purchase">
'.$pay.'
</section>';
}
protected function procesaFormulario($datos){
$result = array();
if (count($result) === 0) {
$result = "confirm.php";
}
return $result;
}
}
?>

View File

@ -1,153 +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 = '<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

@ -1,23 +0,0 @@
<?php
//General Config File:
require_once('../assets/php/config.php');
//Form Ticket to purchase:
require_once('includes/formSelectCinemaSession.php');
$form = new FormSelectCinemaSession();
$formHTML = $form->gestiona();
//Page-specific content:
$section = '<!-- Purchase -->
<section id="purchase">
<div class="row">
'.$formHTML.'
</div>
</section>
';
//General page content:
require RAIZ_APP.'/HTMLtemplate.php';
//TO-DO: añadir selección de butaca y elegir promociones y enviar con el POST.
?>

View File

@ -1,81 +0,0 @@
<?php
//General Config File:
require_once('../assets/php/config.php');
//Get purchase summary
include_once($prefix.'assets/php/includes/purchase.php');
include_once($prefix.'assets/php/includes/film.php');
include_once($prefix.'assets/php/includes/session_dao.php');
include_once($prefix.'assets/php/includes/session.php');
include_once($prefix.'assets/php/includes/cinema_dao.php');
include_once($prefix.'assets/php/includes/cinema.php');
if(isset($_SESSION["purchase"]) && isset($_SESSION["film_purchase"])){
$purchase = unserialize($_SESSION["purchase"]);
$film_purchase = unserialize($_SESSION["film_purchase"]);
$sessionDAO = new SessionDAO("complucine");
$session = $sessionDAO->sessionData($purchase->getSessionId());
$cinemaDAO = new Cinema_DAO("complucine");
$cinema = $cinemaDAO->cinemaData($purchase->getCinemaId());
$seatsArray = array_combine(unserialize($purchase->getRow()), unserialize($purchase->getColumn()));
$seats = "";
for($i=0; $i < count(unserialize($purchase->getRow())); $i++){
$seats .= unserialize($purchase->getRow())[$i]."-".unserialize($purchase->getColumn())[$i].", ";
}
unset($_SESSION["purchase"]);
unset($_SESSION["film_purchase"]);
$reply = "<h2>Se ha realizado su compra con éxito, a continuación puede ver el resumen:</h2><hr />
<div class='column left'>
<img src='".$prefix."img/films/".$film_purchase->getImg()."' alt='".$film_purchase->getTittle()."' />
<p>Película: ".str_replace('_', ' ', strtoupper($film_purchase->getTittle()))."</p>
<p>Duración: ".$film_purchase->getDuration()." minutos</p>
<p>Idioma: ".$film_purchase->getLanguage()."</p>
<p>Precio: ".$session->getSeatPrice()*count(unserialize($purchase->getRow()))." </p>
</div>
<div class='column right'>
<p>Sesión (Fecha): ".$session->getDate()."</p>
<p>Sesión (Hora): ".$session->getStartTime()."</p>
<p>Cine: ".$cinema->getName()."</p>
<p>Sala: ".$purchase->getHallId()."</p>
<p>Asiento(s): ".$seats."</p>
<p>Fecha de la Compra: ".$purchase->getTime()."</p>
</div>
";
if(isset($_SESSION["login"]) && $_SESSION["login"] == true){
$actions = '<h3>Guarde esta información y enséñela para entrar al cine.</h3><hr />
<p>Se ha guardado la información de la compra en su panel de usuario.</p>
<button onclick="javascript:window.print()">Imprimir<//button>
<a href="'.$prefix.'panel_user/?option=purchases"><button>Mi Historial</button></a>
';
} else {
$actions = '<h3>Guarde esta información y enséñela para entrar al cine.</h3><hr />
<button onclick="javascript:window.print()">Imprimir<//button>
<!-- <button onclick="javascript:window.print()">Guardar<//button> -->
';
}
} else {
$reply = '<h2>No se han encontrado datos de compra<h2>';
$actions = '';
}
//Page-specific content:
$section = '<!-- Purchase Summary -->
<section id="purchase_summary">
<div class="row">
<section class="code">
'.$reply.'
</section>
<section class="code resume">
'.$actions.'
</section>
</div>
</section>
';
//General page content:
require RAIZ_APP.'/HTMLtemplate.php';
?>

View File

@ -1,18 +0,0 @@
<?php
//General Config File:
require_once('../assets/php/config.php');
//Seats form:
require_once('includes/formSelectSeat.php');
$form = new FormSelectSeat();
$formHTML = $form->gestiona();
//Page-specific content:
$section = '<section class="row">
<!-- Seat Form -->
'.$formHTML.'
</div>';
//General page content:
require RAIZ_APP.'/HTMLtemplate.php';
?>