From 162f7c1a8d24e7d17a3bd80f5544b04f48c03589 Mon Sep 17 00:00:00 2001 From: Markines16 <80280295+Markines16@users.noreply.github.com> Date: Sun, 6 Jun 2021 13:31:43 +0200 Subject: [PATCH] Add files via upload --- assets/php/includes/session.php | 44 ++++++++++++++++----------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/assets/php/includes/session.php b/assets/php/includes/session.php index 82a44b5..f698b04 100644 --- a/assets/php/includes/session.php +++ b/assets/php/includes/session.php @@ -34,33 +34,29 @@ return $bd->getAllSessions($hall, $cinema, null, null); } } + public static function getListSessionsBetween2Dates($hall,$cinema,$start,$end){ $bd = new SessionDAO('complucine'); if($bd ) { return $bd->getAllSessions($hall, $cinema, $start, $end); } } - - public static function create_session($cinema, $hall, $start, $date, $film, $price, $format,$repeat){ + public static function searchSessionActivesAtStartTimeAndFilmDuration(){ + $bd = new SessionDAO('complucine'); + $bd->searchSessionActivesAtStartTimeAndFilmDuration(1, 1, 1, 1, 1); + + } + public static function create_session($cinema, $hall, $start, $date, $film, $price, $format){ $bd = new SessionDAO('complucine'); if($bd ){ - if(!$bd->searchSession($cinema, $hall, $start, $date)){ + if(!$bd->searchSessionActivesAtStartTimeAndFilmDuration($cinema, $hall, $start, $date, $film)){ $bd->createSession(null,$film, $hall, $cinema, $date, $start, $price, $format); - - if($repeat > "0") { - $repeats = $repeat; - $repeat = $repeat - 1; - $date = date('Y-m-d', strtotime( $date . ' +1 day') ); - self::create_session($cinema, $hall, $start, $date, $film, $price, $format,$repeat); - return "Se han creado las ".$repeat ." sesiones con exito"; - } - - else - return "Se ha creado la session con exito"; + return 'OperaciĆ³n completada'; } else - return "Esta session ya existe"; - - } else return "Error al conectarse a la base de datos"; + return 'La session del dia '.$date.' coincide con otra'; + + } else return 'Error al conectarse a la base de datos'; + } public static function edit_session($cinema, $or_hall, $or_date, $or_start, $hall, $start, $date, $film, $price, $format){ @@ -69,8 +65,9 @@ if($bd->searchSession($cinema, $or_hall, $or_start, $or_date)){ 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"; + $bd->editSession($film, $hall, $cinema, $date, $start, $price, $format, $origin); + return "Se ha editado la session con exito"; + }else if($or_hall == $hall && $or_start == $start && $or_date == $date){ $origin = array("cinema" => $cinema,"hall" => $or_hall,"start" => $or_start,"date" => $or_date); $bd->editSession($film, $hall, $cinema, $date, $start, $price, $format, $origin); @@ -78,7 +75,7 @@ }else{ return "Ya existe una sesion con los parametros nuevos"; } - + } else return "La session a editar no existe"; @@ -93,15 +90,18 @@ return "Se ha eliminado la session con exito"; } else return "Esta session no existe"; - } else return "Error al conectarse a la base de datos"; + + return "Se ha eliminado la session con exito"; } //Esto deberia estar en film.php? seguramente public static function getThisSessionFilm($idfilm){ $bd = new SessionDAO('complucine'); if($bd ) { - return $bd->filmTittle($idfilm); + $film = $bd->filmTittle($idfilm); + $film["tittle"] = str_replace('_', ' ',$film["tittle"]); + return $film; } }