Add files via upload

This commit is contained in:
Fernando Méndez
2021-06-03 11:26:35 +02:00
committed by GitHub
parent d56c04f076
commit 8a65fdb574
9 changed files with 224 additions and 166 deletions

View File

@ -41,13 +41,19 @@ class FormPurchase extends Form {
$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])){ $this->seat = "(Fila) ".$i." - (Columna) ".$j; $this->row = $i; $this->col = $j; }
if(isset($_POST["checkbox".$seat])){
array_push($this->seat, $i."-".$j);
array_push($this->row, $i);
array_push($this->col, $j);
}
}
}
@ -89,6 +95,11 @@ class FormPurchase extends Form {
<p>Vuelva atrás para selecionar otra sesión.</p>
</div>";
} else {
$seats = "";
foreach($this->seat as $value){
$seats .= $value.", ";
}
$html = "<div class='row'>
<fieldset id='datos_entrada'>
<legend>Resumen de la Compra</legend>
@ -96,10 +107,10 @@ class FormPurchase extends Form {
<p>Película: ".str_replace('_', ' ', strtoupper($this->film->getTittle()))."</p>
<p>Cine: ".$this->cinema->getName()."</p>
<p>Sala: ".$this->session->getIdhall()."</p>
<p>Asiento: ".$this->seat."</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: ".$this->session->getSeatPrice()."€</p>
<p>Precio: ".$this->session->getSeatPrice()*count($this->seat)."€</p>
</fieldset>
<fieldset id='pagar_entrada'><pre>".$htmlErroresGlobales."</pre>
<legend>Datos Bancarios</legend>
@ -124,8 +135,8 @@ class FormPurchase extends Form {
</fieldset>
<div class='actions'>
<input type='hidden' name='sessions' id='sessions' value='".$_POST["sessions"]."' />
<input type='hidden' name='row' id='row' value='".$this->row."' />
<input type='hidden' name='col' id='col' value='".$this->col."' />
<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>
@ -168,14 +179,18 @@ class FormPurchase extends Form {
if (count($result) === 0) {
if(isset($_SESSION["login"]) && $_SESSION["login"] == true){
$purchaseDAO = new PurchaseDAO("complucine");
if($purchaseDAO->createPurchase(unserialize($_SESSION["user"])->getId(), $this->session->getId(), $this->session->getIdhall(), $this->cinema->getId(), $datos["row"], $datos["col"], 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"));
$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.";
$_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"));

View File

@ -18,7 +18,11 @@
$cinemaDAO = new Cinema_DAO("complucine");
$cinema = $cinemaDAO->cinemaData($purchase->getCinemaId());
$seat = 1; //$_POST[];
$seatsArray = array_combine(unserialize($purchase->getRow()), unserialize($purchase->getColumn()));
$seats = "";
foreach($seatsArray as $key=>$value){
$seats .= $key."-".$value.", ";
}
unset($_SESSION["purchase"]);
unset($_SESSION["film_purchase"]);
@ -29,16 +33,14 @@
<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>
<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: ".$seat."</p>
<p>Asiento (Columna): ".$purchase->getRow()."</p>
<p>Asiento (Fila): ".$purchase->getColumn()."</p>
<p>Asiento(s): ".$seats."</p>
<p>Fecha de la Compra: ".$purchase->getTime()."</p>
</div>
";