From d2c4fdd77ff136aa4758b37bf4d5b667df2ad578 Mon Sep 17 00:00:00 2001 From: Markines16 <80280295+Markines16@users.noreply.github.com> Date: Thu, 13 May 2021 14:06:07 +0200 Subject: [PATCH] Add files via upload --- assets/php/common/hall.php | 1 - assets/php/common/hall_dao.php | 18 +++++++++++------- assets/php/common/session.php | 28 ++++++---------------------- 3 files changed, 17 insertions(+), 30 deletions(-) diff --git a/assets/php/common/hall.php b/assets/php/common/hall.php index 92a5377..bc22af9 100644 --- a/assets/php/common/hall.php +++ b/assets/php/common/hall.php @@ -28,7 +28,6 @@ $bd = new HallDAO('complucine'); if($bd ) return $bd->getAllHalls($cinema); - return ""; } public static function create_hall($number, $cinema, $rows, $cols, $seats, $seats_map){ diff --git a/assets/php/common/hall_dao.php b/assets/php/common/hall_dao.php index 15d49b7..9b4574e 100644 --- a/assets/php/common/hall_dao.php +++ b/assets/php/common/hall_dao.php @@ -42,19 +42,23 @@ return $hall; } - //Returns the count of the hall searched public function searchHall($number, $cinema){ - $sql = sprintf( "SELECT COUNT(*) FROM hall WHERE + $sql = sprintf( "SELECT * FROM hall WHERE number = '%s' AND idcinema = '%s'", $number, $cinema); $resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database'); + $hall = false; - $hall = mysqli_fetch_array($resul); - - mysqli_free_result($resul); - - return $hall[0]; + if($resul){ + if($resul->num_rows == 1){ + $fila = $resul->fetch_assoc(); + $hall = $this->loadHall($fila["number"], $fila["idcinema"], $fila["numrows"], $fila["numcolumns"], $fila["total_seats"], null); + } + $resul->free(); + } + + return $hall; } diff --git a/assets/php/common/session.php b/assets/php/common/session.php index 404ca60..275fafa 100644 --- a/assets/php/common/session.php +++ b/assets/php/common/session.php @@ -30,7 +30,6 @@ if($bd ) { return $bd->getAllSessions($hall, $cinema, $date); } - return ""; } public static function create_session($cinema, $hall, $start, $date, $film, $price, $format,$repeat){ @@ -59,10 +58,12 @@ $bd = new SessionDAO('complucine'); if($bd ){ if($bd->searchSession($cinema, $or_hall, $or_start, $or_date)){ - $origin = array("cinema" => $cinema,"hall" => $or_hall,"start" => $or_start,"date" => $or_date); - $bd->editSession($film, $hall, $cinema, $date, - $start, $price, $format,$origin); - return "Se ha editado la session con exito"; + if(!$bd->searchSession($cinema,$hall,$start,$date)){ + $origin = array("cinema" => $cinema,"hall" => $or_hall,"start" => $or_start,"date" => $or_date); + $bd->editSession($film, $hall, $cinema, $date, $start, $price, $format,$origin); + return "Se ha editado la session con exito"; + }else + return "Ya existe una sesion con los parametros nuevos"; } else return "Esta session no existe"; @@ -87,23 +88,6 @@ if($bd ) { return $bd->filmTittle($idfilm); } - return ""; - } - - public static function getThisSessionId($cinema, $hall, $start, $date){ - $bd = new SessionDAO('complucine'); - if($bd ) { - return $bd->searchSession($cinema, $hall, $start, $date); - } - return ""; - } - - public static function getThisSessionFromId($id){ - $bd = new SessionDAO('complucine'); - if($bd ) { - return $bd->sessionData($id); - } - return ""; } public function setId($id){ $this->_id = $id; }