Add files via upload

This commit is contained in:
Fernando Méndez 2021-05-28 14:21:10 +02:00 committed by GitHub
parent 12c61a4683
commit b80a9ae1db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 440 additions and 40 deletions

View File

@ -370,7 +370,7 @@
margin-right: auto; margin-right: auto;
box-shadow: 0 4px 8px 0 #00020f, 0 6px 20px 0 #00020f; box-shadow: 0 4px 8px 0 #00020f, 0 6px 20px 0 #00020f;
} }
.code.purchase { .code.purchase, .code.resume {
text-align: center; text-align: center;
} }
.code.purchase h3 { .code.purchase h3 {

View File

@ -368,7 +368,7 @@ main img {
margin-right: auto; margin-right: auto;
box-shadow: 0 4px 8px 0 #00020f, 0 6px 20px 0 #00020f; box-shadow: 0 4px 8px 0 #00020f, 0 6px 20px 0 #00020f;
} }
.code.purchase { .code.purchase, .code.resume {
text-align: center; text-align: center;
} }
.code.purchase h3 { .code.purchase h3 {

View File

@ -1,3 +1,8 @@
/**
* Práctica - Sistemas Web | Grupo D
* CompluCine - FDI-cines
*/
function cambiarCSS(nuevo){ function cambiarCSS(nuevo){
document.getElementById('estilo').setAttribute('href', nuevo); document.getElementById('estilo').setAttribute('href', nuevo);
} }

89
assets/js/checkPay.js Normal file
View File

@ -0,0 +1,89 @@
/**
* Práctica - Sistemas Web | Grupo D
* CompluCine - FDI-cines
*/
//Expresión regular para validar nombre y apellidos:
const regExpr = /^([A-Za-zÁÉÍÓÚñáéíóúÑ]{0}?[A-Za-zÁÉÍÓÚñáéíóúÑ\']+[\s])+([A-Za-zÁÉÍÓÚñáéíóúÑ]{0}?[A-Za-zÁÉÍÓÚñáéíóúÑ\'])+[\s]?([A-Za-zÁÉÍÓÚñáéíóúÑ]{0}?[A-Za-zÁÉÍÓÚñáéíóúÑ\'])?$/g;
$(document).ready(function() {
//Iconos para validar el titular de la tarjeta:
$("#cardNameValid").hide();
$("#cardNameInvalid").hide();
//Iconos para validar el número de tarjeta:
$("#carNumberValid").hide();
$("#cardNumerInvalid").hide();
//Iconos para validar el CVV:
$("#cvvValid").hide();
$("#cvvInvalid").hide();
//Comprueba que el titular de la tarjeta es válido.
$("#card-holder").change(function(){
const cardHolder = $("#card-holder");
cardHolder[0].setCustomValidity("");
if(cardHolder.val().length > 5 && holderCheck(cardHolder.val())){
$("#cardNameValid").show();
$("#cardNameInvalid").hide();
cardHolder[0].setCustomValidity("");
} else {
$("#cardNameValid").hide();
$("#cardNameInvalid").show();
cardHolder[0].setCustomValidity("El titular de la tarjeta no es válido.");
}
});
//Comprueba que el NÚMERO de la tarjeta es válido.
$("#card-number-0").change(function(){
$("#card-number-1").change(function(){
$("#card-number-2").change(function(){
$("#card-number-3").change(function(){
const cardNumber0 = $("#card-number-0");
const cardNumber1 = $("#card-number-1");
const cardNumber2 = $("#card-number-2");
const cardNumber3 = $("#card-number-3");
cardNumber0[0].setCustomValidity("");
cardNumber1[0].setCustomValidity("");
cardNumber2[0].setCustomValidity("");
cardNumber3[0].setCustomValidity("");
if( (cardNumber0.val().length + cardNumber1.val().length + cardNumber2.val().length +cardNumber3.val().length) === 16 ){
$("#carNumberValid").show();
$("#cardNumerInvalid").hide();
cardNumber0[0].setCustomValidity("");
} else {
$("#carNumberValid").hide();
$("#cardNumerInvalid").show();
cardNumber0[0].setCustomValidity("El número de tarjeta debe tener 16 dígitos.");
}
});
});
});
});
//Comprueba que el CVV de la tarjeta es válido.
$("#card-cvv").change(function(){
const cvv = $("#card-cvv");
cvv[0].setCustomValidity("");
if(cvv.val().length === 3){
$("#cvvValid").show();
$("#cvvInvalid").hide();
cvv[0].setCustomValidity("");
} else {
$("#carcvvValiddNameValid").hide();
$("#cvvInvalid").show();
cvv[0].setCustomValidity("El CVV debe tener 3 dígitos.");
}
});
//Devuelve true si el nombre y apellidos del titular son válidos, false en caso contrario.
function holderCheck(name) {
return regExpr.test(name) ? true : false;
}
})

View File

@ -1,3 +1,28 @@
function newWindow(page){ /**
window.open(page, 'Ventana de Confirmación', 'width=500, height=300'); * Práctica - Sistemas Web | Grupo D
} * CompluCine - FDI-cines
*/
/* TO-DO: NO FUNCIONA LA PETICIÓN AJAX */
$(document).ready(function() {
document.getElementById("submit").onclick=function(){
let _delete = confirm("¿Está seguro de que desea eliminar su cuenta de usuario?\nEsta acción no se puede deshacer.");
if(_delete == true){
//console.log(location.href += "&reply=" + _delete);
//location.href += "&reply=" + _delete;
$.ajax({
url:"./?option=delete_user",
type: "POST",
data: {reply: "true"},
success:function(data){
console.log(data.reply);
},
error:function(data){
console.log(data.reply);
}
});
}
}
});

View File

@ -1,3 +1,9 @@
/**
* Práctica - Sistemas Web | Grupo D
* CompluCine - FDI-cines
*/
/* TO-DO: enviar el contenido del array de promociones */
window.onload = function () { window.onload = function () {
var promos = document.getElementById("promotions").value; var promos = document.getElementById("promotions").value;
console.log(promos); console.log(promos);

View File

@ -1,3 +1,8 @@
/**
* Práctica - Sistemas Web | Grupo D
* CompluCine - FDI-cines
*/
// Método 1: recargar la página y enviar un GET. // Método 1: recargar la página y enviar un GET.
window.onload = function(){ window.onload = function(){
var select = document.getElementById("select_cinema"); var select = document.getElementById("select_cinema");
@ -6,7 +11,7 @@ window.onload = function(){
} }
} }
// Método 2: enviar una petición AJAX con POST. (NO FUNCIONA) // Método 2: enviar una petición AJAX con POST. ==> (NO FUNCIONA, PERO LA IDEA ERA HACERLO ASÍ PARA EVITAR REFRESCAR LA PÁGINA Y LLENAR LA URL)
/* /*
$(document).ready(function(){ $(document).ready(function(){
$("#select_cinema_session").change(function(){ $("#select_cinema_session").change(function(){
@ -20,8 +25,6 @@ $(document).ready(function(){
cache : false, cache : false,
async : false, async : false,
success: function(data){ success: function(data){
$("cinemas option").remove();
$("cinemas").append(data);
console.log(cinema); console.log(cinema);
}, },
error: function(response) error: function(response)
@ -31,17 +34,4 @@ $(document).ready(function(){
}); });
}); });
}); });
*/
//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

@ -22,6 +22,25 @@
return $sql; return $sql;
} }
//Returns the hall's data by ID.
public function HallData($id){
$id = $this->mysqli->real_escape_string($id);
$sql = sprintf( "SELECT * FROM hall WHERE number = '%d'", $id );
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
$resul->data_seek(0);
$hall = null;
while ($fila = $resul->fetch_assoc()) {
$hall = $this->loadHall($fila["number"], $fila["idcinema"], $fila["numrows"], $fila["numcolumns"], $fila["total_seats"], null);
}
//mysqli_free_result($selectUser);
$resul->free();
return $hall;
}
//Returns a query to get the halls data. //Returns a query to get the halls data.
public function getAllHalls($cinema){ public function getAllHalls($cinema){

View File

@ -0,0 +1,43 @@
<?php
class Purchase {
//Attributes:
private $_idUser; //User Id.
private $_idSession; //Session Id.
private $_idHall; //Hall Id.
private $_idCinema; //Cinema Id.
private $_numRow; //Number of row seat.
private $_numColumn; //Number of column seat.
private $_timePurchase; //Time of purchase.
//Constructor:
function __construct($idUser, $idSession, $idHall, $idCinema, $row, $column, $time){
$this->_idUser = $idUser;
$this->_idSession = $idSession;
$this->_idHall = $idHall;
$this->_idCinema = $idCinema;
$this->_numRow = $row;
$this->_numColumn = $column;
$this->_timePurchase = $time;
}
//Methods:
//Getters && Setters:
public function setUserId($idUser){ $this->_idUser = $id; }
public function getUserId(){ return $this->_idUser; }
public function setSessionId($idSession){ $this->_idSession = $idSession; }
public function getSessionId(){ return $this->_idSession; }
public function setHallId($idHall){ $this->_idHall = $idHall; }
public function getHallId(){ return $this->_idHall; }
public function setCinemaId($idCinema){ $this->_idCinema = $idCinema; }
public function getCinemaId(){ return $this->_idCinema; }
public function setRow($row){ $this->_numRow = $row; }
public function getRow(){ return $this->_numRow; }
public function setColumn($column){ $this->_numColumn = $column; }
public function getColumn(){ return $this->_numColumn; }
public function setTime($time){ $this->_timePurchase = $time; }
public function getTime(){ return $this->_timePurchase; }
}
?>

View File

@ -0,0 +1,46 @@
<?php
include_once('purchase.php');
class PurchaseDAO extends DAO {
//Attributes:
//Constructor:
function __construct($bd_name){
parent::__construct($bd_name);
}
//Methods:
//Create a new Purchase.
public function createPurchase($idUser, $idSession, $idHall, $idCinema, $row, $column, $time){
$sql = sprintf( "INSERT INTO purchase( iduser, idsession, idhall, idcinema, numrow, numcolum, time_purchase )
VALUES ( '%d', '%d', '%d', '%d', '%d', '%d', '%s' )",
$idUser, $idSession, $idHall, $idCinema, $row, $column, $time );
$resul = mysqli_query($this->mysqli, $sql);
return $resul;
}
//All purchases of one user.
public function allPurchasesData($idUser){
$sql = sprintf( "SELECT * FROM purchase WHERE iduser = '%d' ", $idUser);
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
$purchases = null;
while($fila=$resul->fetch_assoc()){
$purchases[] = $this->loadPurchase($fila["iduser"], $fila["idsession"], $fila["idhall"], $fila["idcinema"], $fila["numrow"], $fila["numcolum"], $fila["time_purchase"]);
}
$resul->free();
return $purchases;
}
//Create a new User Data Transfer Object.
public function loadPurchase($idUser, $idSession, $idHall, $idCinema, $row, $column, $time){
return new Purchase($idUser, $idSession, $idHall, $idCinema, $row, $column, $time);
}
}
?>

View File

@ -120,5 +120,8 @@
public function setFormat($format){ $this->_format = $format; } public function setFormat($format){ $this->_format = $format; }
public function getFormat(){ return $this->_format; } public function getFormat(){ return $this->_format; }
public function setSeatsFull($bool){ $this->_seats_full = $bool; }
public function getSeatsFull(){ return $this->_seats_full; }
} }
?> ?>

View File

@ -1,5 +1,4 @@
<?php <?php
class User { class User {
//Attributes: //Attributes:

View File

@ -701,9 +701,10 @@
<script type='text/javascript' src='{$prefix}assets/js/cambiarCSS.js'></script> <script type='text/javascript' src='{$prefix}assets/js/cambiarCSS.js'></script>
<script type='text/javascript' src='{$prefix}assets/js/checkForms.js'></script> <script type='text/javascript' src='{$prefix}assets/js/checkForms.js'></script>
"; ";
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"; if($page === "Comprar Entrada") echo"<script type='text/javascript' src='{$prefix}assets/js/selectTicket.js'></script>
<script type='text/javascript' src='{$prefix}assets/js/checkPay.js'></script>\n";
} }
} }

View File

@ -77,11 +77,15 @@ class FormDeleteAccount extends Form {
if( (unserialize($_SESSION['user'])->getId() === $user->getId()) && ($nombre === $user->getName()) if( (unserialize($_SESSION['user'])->getId() === $user->getId()) && ($nombre === $user->getName())
&& ($email === $user->getEmail()) && ($bd->verifyPass($password, $user->getPass())) ){ && ($email === $user->getEmail()) && ($bd->verifyPass($password, $user->getPass())) ){
$bd->deleteUserAccount($user->getId()); if(!isset($_GET['reply'])){
unset($_SESSION); $bd->deleteUserAccount($user->getId());
session_destroy(); unset($_SESSION);
session_destroy();
$result = ROUTE_APP;
$result = ROUTE_APP;
} else {
$result[] = "Operación cancelada.";
}
} else { } else {
$result[] = "Los datos introducidos\nno son válidos."; $result[] = "Los datos introducidos\nno son válidos.";

View File

@ -89,8 +89,47 @@
//User purchase history. //User purchase history.
static function purchases(){ static function purchases(){
require_once('../assets/php/includes/purchase_dao.php');
$purchaseDAO = new PurchaseDAO("complucine");
$purchases = $purchaseDAO->allPurchasesData(unserialize($_SESSION['user'])->getId());
$sessions = array();
$halls = array();
$cinemas = array();
$rows = array();
$columns = array();
$dates = array();
foreach($purchases as $key=>$value){
$sessions[$key] = $value->getSessionId();
$halls[$key] = $value->getHallId();
$cinemas[$key] = $value->getCinemaId();
$rows[$key] = $value->getRow();
$columns[$key] = $value->getColumn();
$dates[$key] = $value->getTime();
}
$purchasesHTML = '';
if(count($purchases) > 0){
for($i = 0; $i < count($purchases); $i++){
if($i%2 === 0){
if($i != 0) $purchasesHTML .= '</div>
';
$purchasesHTML .= '<div class="column left">
';
} else {
if($i != 0) $purchasesHTML .= '</div>
';
$purchasesHTML .= '<div class="column left">
';
}
$purchasesHTML .= '<h1>'.$dates[$i].'</h1><hr />';
}
}
return $reply = '<div class="code info"> return $reply = '<div class="code info">
<h2>Aquí el historial de compras</h2><hr /> <h2>Historial de compras</h2><hr />
'.$purchasesHTML.'
</div>'."\n"; </div>'."\n";
} }

View File

@ -6,15 +6,22 @@ include_once($prefix.'assets/php/includes/film_dao.php');
include_once($prefix.'assets/php/includes/film.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_dao.php');
include_once($prefix.'assets/php/includes/cinema.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/purchase_dao.php');
include_once($prefix.'assets/php/includes/purchase.php');
include_once($prefix.'assets/php/includes/user.php');
class FormPurchase extends Form { class FormPurchase extends Form {
//Atributes: //Atributes:
private $session; // Session of the film to be purchased. private $session; // Session of the film to be purchased.
private $cinema; // Cinema 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 $film; // Film to be purchased.
private $years; // Actual year. private $years; // Actual year.
private $months; // Months of the year. private $months; // Months of the year.
private $_TODAY; // Actual date.
public function __construct() { public function __construct() {
//$options = array("action" => $_SERVER['PHP_SELF']); //$options = array("action" => $_SERVER['PHP_SELF']);
@ -29,9 +36,14 @@ class FormPurchase extends Form {
$cinemaDAO = new Cinema_DAO("complucine"); $cinemaDAO = new Cinema_DAO("complucine");
$this->cinema = $cinemaDAO->cinemaData($this->session->getIdcinema()); $this->cinema = $cinemaDAO->cinemaData($this->session->getIdcinema());
$hallDAO = new HallDAO("complucine");
$this->hall = $hallDAO->HallData($this->session->getIdhall());
$TODAY = getdate(); $TODAY = getdate();
$year = "$TODAY[year]"; $year = "$TODAY[year]";
$this->_TODAY = "$TODAY[year]-$TODAY[month]-$TODAY[mday] $TODAY[hours]:$TODAY[minutes]:$TODAY[seconds]";
$this->years = array(); $this->years = array();
for($i = $year; $i < $year+10; $i++) array_push($this->years, $i); for($i = $year; $i < $year+10; $i++) array_push($this->years, $i);
@ -44,6 +56,10 @@ class FormPurchase extends Form {
// Se generan los mensajes de error si existen. // Se generan los mensajes de error si existen.
$htmlErroresGlobales = self::generaListaErroresGlobales($errores); $htmlErroresGlobales = self::generaListaErroresGlobales($errores);
$errorNombre = self::createMensajeError($errores, 'card-holder', 'span', array('class' => 'error')); $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 = ""; $monthsHTML = "";
foreach($this->months as $value){ foreach($this->months as $value){
@ -55,7 +71,13 @@ class FormPurchase extends Form {
$yearsHTML .= "<option>".$value."</option>"; $yearsHTML .= "<option>".$value."</option>";
} }
$html = "<div class='row'> 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 {
$html = "<div class='row'>
<fieldset id='datos_entrada'> <fieldset id='datos_entrada'>
<legend>Resumen de la Compra</legend> <legend>Resumen de la Compra</legend>
<img src='"."../img/films/".$this->film->getImg()."' alt='".$this->film->getTittle()."' /> <img src='"."../img/films/".$this->film->getImg()."' alt='".$this->film->getTittle()."' />
@ -70,16 +92,19 @@ class FormPurchase extends Form {
<legend>Datos Bancarios</legend> <legend>Datos Bancarios</legend>
<label for='card-holder'>Titular de la Tarjeta:</label><pre>".$errorNombre."</pre><br /> <label for='card-holder'>Titular de la Tarjeta:</label><pre>".$errorNombre."</pre><br />
<input type='text' name='card-holder' id='card-holder' class='card-holder' placeholder='NOMBRE APELLIDO1 APELLIDO2' required /> <input type='text' name='card-holder' id='card-holder' class='card-holder' placeholder='NOMBRE APELLIDO1 APELLIDO2' required />
<span id='cardNameValid'>&#x2714;</span><span id='cardNameInvalid'>&#x274C;</span>
<br /> <br />
<label for='card-number'>Número de Tarjeta: </label><br /> <label for='card-number'>Número de Tarjeta: </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-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-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-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 /> <input type='num' name='card-number-3' id='card-number-3' class='input-cart-number' placeholder='XXXX' maxlength='4' required />
<span id='carNumberValid'>&#x2714;</span><span id='cardNumerInvalid'>&#x274C;</span>
<label for='card-cvv'>CVV: </label> <label for='card-cvv'>CVV: </label>
<input type='text' name='card-cvv' id='card-cvv' class='fieldset-cvv' maxlength='3' placeholder='XXX' required /> <input type='text' name='card-cvv' id='card-cvv' class='fieldset-cvv' maxlength='3' placeholder='XXX' required /><pre>".$errorCVV."</pre>
<span id='cvvValid'>&#x2714;</span><span id='cvvInvalid'>&#x274C;</span>
<br /> <br />
<label for='card-expiration'>Fecha de Expiración:</label><br /> <label for='card-expiration'>Fecha de Expiración:</label><pre>".$errorCardExpirationMonth.$errorCardExpirationYear."</pre><br />
<select name='card-expiration-month' id='card-expiration-month' required> <select name='card-expiration-month' id='card-expiration-month' required>
".$monthsHTML." ".$monthsHTML."
</select> </select>
@ -93,7 +118,7 @@ class FormPurchase extends Form {
<input type='reset' id='reset' value='Borrar' /> <input type='reset' id='reset' value='Borrar' />
</div> </div>
</div>"; </div>";
}
return $html; return $html;
} }
@ -105,9 +130,44 @@ class FormPurchase extends Form {
if ( empty($nombre) ) { if ( empty($nombre) ) {
$result['card-holder'] = "El nombre no puede estar vacío."; $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;
if ( empty($month) ) {
$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 (count($result) === 0) {
$result[] = "La compra aun está en desarrollo. Vuelva en unos días."; if(isset($_SESSION["login"]) && $_SESSION["login"] == true){
$purchaseDAO = new PurchaseDAO("complucine");
$purchaseDAO->createPurchase(unserialize($_SESSION["user"])->getId(), $this->session->getId(), $this->session->getIdhall(), $this->cinema->getId(), rand(1, $this->hall->getNumRows()), rand(1, $this->hall->getNumCol()), date("Y-m-d H:i:s"));
$purchase = new Purchase(unserialize($_SESSION["user"])->getId(), $this->session->getId(), $this->session->getIdhall(), $this->cinema->getId(), rand(1, $this->hall->getNumRows()), rand(1, $this->hall->getNumCol()), 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 {
$purchase = new Purchase("null", $this->session->getId(), $this->session->getIdhall(), $this->cinema->getId(), rand(1, $this->hall->getNumRows()), rand(1, $this->hall->getNumCol()), 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; return $result;

View File

@ -2,7 +2,7 @@
//General Config File: //General Config File:
require_once('../assets/php/config.php'); require_once('../assets/php/config.php');
//Get Film to purchase: //Get Ticket to purchase:
include_once($prefix.'assets/php/includes/film_dao.php'); include_once($prefix.'assets/php/includes/film_dao.php');
include_once($prefix.'assets/php/includes/film.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_dao.php');
@ -160,5 +160,5 @@
//General page content: //General page content:
require RAIZ_APP.'/HTMLtemplate.php'; require RAIZ_APP.'/HTMLtemplate.php';
//TO-DO: añadir elegir promocione sy enviar con el POST. //TO-DO: añadir elegir promociones y enviar con el POST.
?> ?>

71
purchase/resume.php Normal file
View File

@ -0,0 +1,71 @@
<?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');
$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());
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()." </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 (Columna): ".$purchase->getRow()."</p>
<p>Asiento (Fila): ".$purchase->getColumn()."</p>
<p>Hora 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>
';
}
//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';
?>