Add files via upload
This commit is contained in:
parent
8d21c86642
commit
4a7f89bdbe
@ -6,6 +6,9 @@
|
||||
//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;
|
||||
|
||||
//Expresión regular para validar un código promocional:
|
||||
const refExprCode = /^0?[xX]?[0-9a-fA-F]*$/;
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
//Iconos para validar el titular de la tarjeta:
|
||||
@ -20,6 +23,10 @@ $(document).ready(function() {
|
||||
$("#cvvValid").hide();
|
||||
$("#cvvInvalid").hide();
|
||||
|
||||
//Iconos para validar el código promocional:
|
||||
$("#codeValid").hide();
|
||||
$("#codeInvalid").hide();
|
||||
|
||||
|
||||
//Comprueba que el titular de la tarjeta es válido.
|
||||
$("#card-holder").change(function(){
|
||||
@ -118,14 +125,46 @@ $(document).ready(function() {
|
||||
$("#cvvInvalid").hide();
|
||||
cvv[0].setCustomValidity("");
|
||||
} else {
|
||||
$("#carcvvValiddNameValid").hide();
|
||||
$("#cvvValid").hide();
|
||||
$("#cvvInvalid").show();
|
||||
cvv[0].setCustomValidity("El CVV debe tener 3 dígitos.");
|
||||
}
|
||||
});
|
||||
|
||||
//Comprueba el código promocional introducido:
|
||||
$("#code").change(function(){
|
||||
var url = "../assets/php/common/checkPromo.php?code=" + $("#code").val();
|
||||
$.get(url, codeCheck);
|
||||
});
|
||||
|
||||
|
||||
//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;
|
||||
}
|
||||
})
|
||||
|
||||
//Devuelve true si el código promocional es válido, false en caso contrario.
|
||||
function holderCheck(code) {
|
||||
return regExprCode.test(code) ? true : false;
|
||||
}
|
||||
|
||||
//Muestra si el código promocional introducido existe o no.
|
||||
function codeCheck(data, status) {
|
||||
const code = $("#code");
|
||||
code[0].setCustomValidity("");
|
||||
|
||||
if(code.val().length === 8 && data === "avaliable"){
|
||||
$("#codeValid").show();
|
||||
$("#codeInvalid").hide();
|
||||
code[0].setCustomValidity("");
|
||||
} else if(code.val().length > 0 ){
|
||||
$("#codeValid").hide();
|
||||
$("#codeInvalid").show();
|
||||
code[0].setCustomValidity("El código promocional no es válido.");
|
||||
} else if(code.val().length === 0 ){
|
||||
$("#codeValid").hide();
|
||||
$("#codeInvalid").hide();
|
||||
code[0].setCustomValidity("");
|
||||
}
|
||||
}
|
||||
});
|
15
assets/php/common/checkPromo.php
Normal file
15
assets/php/common/checkPromo.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
include('../../../assets/php/config.php');
|
||||
include('../includes/promotion_dao.php');
|
||||
|
||||
$bd = new Promotion_DAO('complucine');
|
||||
if($bd){
|
||||
$promo = $bd->GetPromotionObj($_GET["code"]);
|
||||
if ($promo && $promo->getActive()) {
|
||||
echo "avaliable";
|
||||
}
|
||||
else{
|
||||
echo "!avaliable";
|
||||
}
|
||||
}
|
||||
?>
|
@ -27,7 +27,7 @@
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
while($fila=$resul->fetch_assoc()){
|
||||
$promotions[] = $this->loadPromotion($fila["id"], $fila["tittle"], $fila["description"], $fila["code"], $fila["active"], $fila["img"],);
|
||||
$promotions[] = $this->loadPromotion($fila["id"], $fila["tittle"], $fila["description"], $fila["code"], $fila["active"], $fila["img"]);
|
||||
}
|
||||
$resul->free();
|
||||
return $promotions;
|
||||
@ -76,6 +76,20 @@
|
||||
|
||||
return $resul;
|
||||
}
|
||||
|
||||
//Returns a film data .
|
||||
public function GetPromotionObj($code){
|
||||
$sql = sprintf( "SELECT * FROM promotion WHERE promotion.code = '%s'", $code );
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
$promo = null;
|
||||
while($fila = $resul->fetch_assoc()){
|
||||
$promo = $this->loadPromotion($fila["id"], $fila["tittle"], $fila["description"], $fila["code"], $fila["active"], $fila["img"]);
|
||||
}
|
||||
$resul->free();
|
||||
|
||||
return $promo;
|
||||
}
|
||||
|
||||
//Create a new film Data Transfer Object.
|
||||
public function loadPromotion($id, $tittle, $description, $code, $active, $img){
|
||||
|
@ -89,19 +89,16 @@ class FormPurchase extends Form {
|
||||
</fieldset>
|
||||
<fieldset id='pagar_entrada'><pre>".$htmlErroresGlobales."</pre>
|
||||
<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: <span id='cardNameValid'>✔</span><span id='cardNameInvalid'>❌</span></label><pre>".$errorNombre."</pre><br />
|
||||
<input type='text' name='card-holder' id='card-holder' class='card-holder' placeholder='NOMBRE APELLIDO1 APELLIDO2' required />
|
||||
<span id='cardNameValid'>✔</span><span id='cardNameInvalid'>❌</span>
|
||||
<br />
|
||||
<label for='card-number'>Número de Tarjeta: </label><pre>".$errorCardNumber."</pre><br />
|
||||
<label for='card-number'>Número de Tarjeta: <span id='carNumberValid'>✔</span><span id='cardNumerInvalid'>❌</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 />
|
||||
<span id='carNumberValid'>✔</span><span id='cardNumerInvalid'>❌</span>
|
||||
<label for='card-cvv'>CVV: </label>
|
||||
<label for='card-cvv'>CVV: <span id='cvvValid'>✔</span><span id='cvvInvalid'>❌</span></label>
|
||||
<input type='text' name='card-cvv' id='card-cvv' class='fieldset-cvv' maxlength='3' placeholder='XXX' required /><pre>".$errorCVV."</pre>
|
||||
<span id='cvvValid'>✔</span><span id='cvvInvalid'>❌</span>
|
||||
<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>
|
||||
|
@ -32,10 +32,11 @@ class FormSelectCinemaSession extends Form {
|
||||
$cinemas = [];
|
||||
$sessions = [];
|
||||
|
||||
// Se generan los mensajes de error si existen.
|
||||
// Se generan los mensajes de error, si existen.
|
||||
$htmlErroresGlobales = self::generaListaErroresGlobales($errores);
|
||||
$errorCinema = self::createMensajeError($errores, 'cinemas', '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"])){
|
||||
@ -58,8 +59,8 @@ class FormSelectCinemaSession extends Form {
|
||||
$cinemasIT->attachIterator($cinemasIDs, "cID");
|
||||
$cinemasIT->attachIterator($cinemasNames, "NAME");
|
||||
|
||||
$cinemasListHTML = '<section id="select_cinema">
|
||||
<select name="cinemas" id="cinemas">';
|
||||
$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){
|
||||
@ -103,7 +104,7 @@ class FormSelectCinemaSession extends Form {
|
||||
$sessionsIT->attachIterator($sessionsStarts, "HOUR");
|
||||
|
||||
$count = 0;
|
||||
$sessionsListHTML = '<select name="sessions" id="sessions">';
|
||||
$sessionsListHTML = '<select name="sessions" id="sessions"><pre>'.$errorSession.'</pre>';
|
||||
foreach ($sessionsIT as $value) {
|
||||
if($this->_TODAY <= $value["DATE"]){
|
||||
if($value === reset($sessionsIT)){
|
||||
@ -142,6 +143,9 @@ class FormSelectCinemaSession extends Form {
|
||||
'.$cinemasListHTML.'
|
||||
<h3>Sesiones</h3>
|
||||
'.$sessionsListHTML.'
|
||||
<h3>Aplicar código promocional<span id="codeValid">✔</span><span id="codeInvalid">❌</span></h3>
|
||||
<input type="text" name="code" id="code" value="" placeholder="Código pormocional" /><pre>'.$errorPromo.'</pre>
|
||||
|
||||
</div>';
|
||||
} else {
|
||||
$html = '<h1>No existe la película.</h1>';
|
||||
@ -182,6 +186,12 @@ class FormSelectCinemaSession extends Form {
|
||||
$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 = "confirm.php";
|
||||
}
|
||||
|
@ -19,5 +19,5 @@
|
||||
//General page content:
|
||||
require RAIZ_APP.'/HTMLtemplate.php';
|
||||
|
||||
//TO-DO: añadir elegir promociones y enviar con el POST.
|
||||
//TO-DO: añadir selección de butaca y elegir promociones y enviar con el POST.
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user