From df9f8176d4662430799080c7402331987c5d4489 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fernando=20M=C3=A9ndez?=
<45081533+FerMdez@users.noreply.github.com>
Date: Sun, 6 Jun 2021 22:16:15 +0200
Subject: [PATCH] Add files via upload
---
assets/php/includes/seat_dao.php | 14 ++++++++++++++
assets/php/template.php | 3 +--
purchase/includes/formPurchase.php | 25 ++++++++++++++++++++++++-
3 files changed, 39 insertions(+), 3 deletions(-)
diff --git a/assets/php/includes/seat_dao.php b/assets/php/includes/seat_dao.php
index 105da1c..2dc1c0e 100644
--- a/assets/php/includes/seat_dao.php
+++ b/assets/php/includes/seat_dao.php
@@ -39,6 +39,7 @@
return $seat_map;
}
+
//Delete a Seat whit the primary key
public function deletemapSeats($hall, $cinema){
$sql = sprintf( "DELETE FROM `seat` WHERE
@@ -49,6 +50,19 @@
return $resul;
}
+
+ //Change state of the seat.
+ public function changeSeatState($hall, $cinema, $row, $col, $state){
+ $id = $this->mysqli->real_escape_string($idHall);
+ $state = $this->mysqli->real_escape_string($state);
+
+ $sql = sprintf( "UPDATE seat SET active = '%d' WHERE idhall = '%d' AND idcinema = '%d' AND numrow = '%d' AND numcolum = '%d'",
+ $state, $hall, $cinema, $row, $col );
+ $resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
+
+ return $resul;
+
+ }
//Create a new Seat Data Transfer Object.
public function loadSeat($idhall, $idcinema, $numRow, $numCol, $state){
diff --git a/assets/php/template.php b/assets/php/template.php
index 9bea21a..c96f471 100644
--- a/assets/php/template.php
+++ b/assets/php/template.php
@@ -712,8 +712,7 @@
if($page === "Comprar Entrada") echo"
\n";
- if($page === "Panel de Gerente") echo"
-
+ if($page === "Panel de Gerente") echo"
diff --git a/purchase/includes/formPurchase.php b/purchase/includes/formPurchase.php
index d78cdcb..7d9fbae 100644
--- a/purchase/includes/formPurchase.php
+++ b/purchase/includes/formPurchase.php
@@ -8,6 +8,8 @@ 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');
@@ -51,7 +53,7 @@ class FormPurchase extends Form {
for($i = 0; $i <= $rows; $i++){
for($j = 0; $j <= $cols; $j++){
$seat = $i.$j;
- if(isset($_POST["checkbox".$seat])){
+ if(isset($_POST["checkbox".$seat])){
array_push($this->seat, $i."-".$j);
array_push($this->row, $i);
array_push($this->col, $j);
@@ -208,6 +210,16 @@ class FormPurchase extends Form {
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"));
+
+ $seatDAO = new SeatDAO("complucine");
+ $seats_list = $seatDAO->getAllSeats($this->session->getIdhall(), $this->cinema->getId());
+ foreach($seats_list as $key=>$value){
+ if( $seats_list[$key]->getNumRows() === $datos["row"][11] &&
+ $seats_list[$key]->getNumCol() === $datos["col"][11] ){
+ $seats_list[$key]->setState(intval(-1));
+ $seatDAO->changeSeatState( $seats_list[$key]->getNumber(), $seats_list[$key]->getIdcinema(), $seats_list[$key]->getNumRows(), $seats_list[$key]->getNumCol(), $seats_list[$key]->getState());
+ }
+ }
$_SESSION["purchase"] = serialize($purchase);
$_SESSION["film_purchase"] = serialize($this->film);
@@ -218,6 +230,17 @@ class FormPurchase extends Form {
}
} 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"));
+
+ $seatDAO = new SeatDAO("complucine");
+ $seats_list = $seatDAO->getAllSeats($this->session->getIdhall(), $this->cinema->getId());
+ foreach($seats_list as $key=>$value){
+ if( $seats_list[$key]->getNumRows() === $datos["row"][11] &&
+ $seats_list[$key]->getNumCol() === $datos["col"][11] ){
+ $seats_list[$key]->setState(intval(-1));
+ $seatDAO->changeSeatState( $seats_list[$key]->getNumber(), $seats_list[$key]->getIdcinema(), $seats_list[$key]->getNumRows(), $seats_list[$key]->getNumCol(), $seats_list[$key]->getState());
+ }
+ }
+
$_SESSION["purchase"] = serialize($purchase);
$_SESSION["film_purchase"] = serialize($this->film);
$result = "resume.php";