diff --git a/assets/php/common/film_dao.php b/assets/php/common/film_dao.php index 3afc769..41c5b25 100644 --- a/assets/php/common/film_dao.php +++ b/assets/php/common/film_dao.php @@ -1,7 +1,5 @@ get_prefix(); include_once($prefix.'assets/php/dao.php'); class Film_DAO extends DAO { diff --git a/assets/php/common/hall_dao.php b/assets/php/common/hall_dao.php index da50159..e31c4d3 100644 --- a/assets/php/common/hall_dao.php +++ b/assets/php/common/hall_dao.php @@ -15,7 +15,7 @@ public function createHall($number, $idcinema, $numCol, $numRows){ $sql = sprintf( "INSERT INTO `hall`( `number`, `idcinema`, `numrows`, `numcolumns`) - VALUES ( '%d', '%d', '%i', '%i')", + VALUES ( '%d', '%d', '%d', '%d')", $number, $idcinema, $numRows, $numCol ); $resul = mysqli_query($this->mysqli, $sql) or die ('Error BD createhall'); diff --git a/assets/php/common/session.php b/assets/php/common/session.php index fb1bd9a..b844cf3 100644 --- a/assets/php/common/session.php +++ b/assets/php/common/session.php @@ -1,4 +1,8 @@ _id = $id; $this->_idfilm = $idfilm; @@ -21,6 +25,46 @@ $this->_format = $format; } + public static function getListSessions($hall,$cinema,$date){ + $bd = new SessionDAO('complucine'); + if($bd ) { + return $bd->getAllSessions($hall, $cinema, $date); + } + return ""; + } + + public static function create_session($session){ + $bd = new SessionDAO('complucine'); + if($bd ){ + if(!$bd->searchSession($session['cinema'], $session['hall'],$session['start'],$session['date'])){ + $bd->createSession(null,$session['film'], $session['hall'], $session['cinema'], $session['date'], + $session['start'], $session['price'], $session['format']); + + if($session['repeat'] > "0") { + $repeat = $session['repeat']; + $session['repeat'] = $session['repeat'] - 1; + $session['date'] = date('Y-m-d', strtotime( $session['date'] . ' +1 day') ); + self::create_session($session); + return "Se han creado las ".$repeat ." sesiones con exito"; + } + + else + return "Se ha creado la session con exito"; + } else + return "Esta session ya 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'); + if($bd ) { + $film = mysqli_fetch_array($bd->FilmData($idfilm)); + return $film["tittle"]; + } + return ""; + } + public function setId($id){ $this->_id = $id; } public function getId(){ return $this->_id; } diff --git a/assets/php/common/session_dao.php b/assets/php/common/session_dao.php index 381e55a..6330e5d 100644 --- a/assets/php/common/session_dao.php +++ b/assets/php/common/session_dao.php @@ -1,6 +1,6 @@ mysqli, $sql) or die ('Error into query database'); @@ -98,7 +97,7 @@ //Create a new Session Data Transfer Object. public function loadSession( $id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format){ - return new SessionDTO( $id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format); + return new Session( $id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format); } }