From db298d1ea60d7fdceeb8a375c00e27bc66264e3e Mon Sep 17 00:00:00 2001 From: OscarRui <79144467+OscarRui@users.noreply.github.com> Date: Thu, 6 May 2021 10:32:11 +0200 Subject: [PATCH] Editar/Eliminar sesiones --- assets/php/common/session.php | 28 ++++++++++++++++++++++++++++ assets/php/common/session_dao.php | 4 ++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/assets/php/common/session.php b/assets/php/common/session.php index b844cf3..dc6e939 100644 --- a/assets/php/common/session.php +++ b/assets/php/common/session.php @@ -55,6 +55,34 @@ } else return "Error al conectarse a la base de datos"; } + + public static function edit_session($session){ + $bd = new SessionDAO('complucine'); + if($bd ){ + if($bd->searchSession($session['cinema'], $session['origin_hall'],$session['origin_start'],$session['origin_date'])){ + $origin = array("cinema" => $session['cinema'],"hall" => $session['origin_hall'],"start" => $session['origin_start'],"date" => $session['origin_date']); + $bd->editSession($session['film'], $session['hall'], $session['cinema'], $session['date'], + $session['start'], $session['price'], $session['format'],$origin); + return "Se ha editado la session con exito"; + } else + return "Esta session no existe"; + + } else return "Error al conectarse a la base de datos"; + } + + public static function delete_session($session){ + $bd = new SessionDAO('complucine'); + if($bd ){ + if($bd->searchSession($session['cinema'], $session['hall'],$session['start'],$session['date'])){ + $bd->deleteSession($session['hall'], $session['cinema'], $session['date'], $session['start']); + return "Se ha eliminado la session con exito"; + } else + return "Esta session no existe"; + + } else return "Error al conectarse a la base de datos"; + } + + //Esto deberia estar en film.php? seguramente public static function getFilmTitle($idfilm){ $bd = new Film_DAO('complucine'); diff --git a/assets/php/common/session_dao.php b/assets/php/common/session_dao.php index 6330e5d..8d8abea 100644 --- a/assets/php/common/session_dao.php +++ b/assets/php/common/session_dao.php @@ -67,7 +67,7 @@ return $sessions; } - public function editSession($idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format){ + public function editSession($idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format, $origin){ $format = $this->mysqli->real_escape_string($format); $date = date('Y-m-d', strtotime( $date ) ); $startTime = date('H:i:s', strtotime( $startTime ) ); @@ -77,7 +77,7 @@ `start_time` = '%s', `seat_price` = '%d', `format` = '%s' WHERE idcinema = '%s' AND idhall = '%s' AND date = '%s' AND start_time = '%s'", - $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format, $_SESSION["cinema"],$_SESSION["hall"],$_SESSION["date"],$_SESSION["start"]); + $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format, $origin["cinema"],$origin["hall"],$origin["date"],$origin["start"]); $resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');