diff --git a/assets/php/common/hall.php b/assets/php/common/hall.php index b0cd581..b6dd8d6 100644 --- a/assets/php/common/hall.php +++ b/assets/php/common/hall.php @@ -25,6 +25,18 @@ return ""; } + public static function create_hall($hall){ + $bd = new HallDAO('complucine'); + if($bd ){ + if(!$bd->searchHall($hall)){ + $bd->createHall($hall); + return "Se ha creado la sala con exito"; + } else { + return "Esta sala ya existe"; + } + } else { return "Error al conectarse a la base de datos"; } + } + //Getters && Setters: public function setNumber($number){ $this->_number = $number; } public function getNumber(){ return $this->_number; } diff --git a/assets/php/common/hall_dao.php b/assets/php/common/hall_dao.php index e31c4d3..a6b6a85 100644 --- a/assets/php/common/hall_dao.php +++ b/assets/php/common/hall_dao.php @@ -1,7 +1,8 @@ mysqli, $sql) or die ('Error BD createhall'); + Seat::createSeats($hall); + return $sql; } @@ -43,11 +46,11 @@ } //Returns the count of the hall searched - public function searchHall($number, $cinema){ + public function searchHall($hall){ $sql = sprintf( "SELECT COUNT(*) FROM hall WHERE idcinema = '%s' AND number = '%s'", - $cinema, $number); + $hall['cinema'], $hall['number']); $resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database'); $hall = mysqli_fetch_array($resul); diff --git a/assets/php/common/seat.php b/assets/php/common/seat.php new file mode 100644 index 0000000..eb3b950 --- /dev/null +++ b/assets/php/common/seat.php @@ -0,0 +1,54 @@ +_number = $idhall; + $this->_idcinema = $idcinema; + $this->_numRow = $numRow; + $this->_numCol = $numCol; + $this->_state = $state; + } + + static public function createSeats($seat){ + $bd = new SeatDAO('complucine'); + + for($i = 1;$i <= $seat["rows"];$i++){ + for($j = 1; $j <= $seat["cols"];$j++){ + error_log("DAO ===> number ->".$seat['number']." cinema ->".$seat['cinema']." fila -> ". $i. " columna ->".$j." activa -> ".$seat[$i][$j]); + if($seat[$i][$j] == "1"){ + $bd->createSeat($seat, $i, $j); + } + } + } + } + + //Getters && Setters: + public function setNumber($number){ $this->_number = $number; } + public function getNumber(){ return $this->_number; } + + public function setIdcinema($idcinema){ $this->_idcinema = $idcinema; } + public function getIdcinema(){ return $this->_idcinema; } + + public function setNumRows($numRow){ $this->_numRow = $numRow; } + public function getNumRows(){ return $this->_numRow; } + + public function setNumCol($numCol){ $this->_numCol = $numCol; } + public function getNumCol(){ return $this->_numCol; } + + public function setState($state){ $this->_state = $state; } + public function getState(){ return $this->_state; } + + + + } +?> \ No newline at end of file diff --git a/assets/php/common/seat_dao.php b/assets/php/common/seat_dao.php new file mode 100644 index 0000000..c97f8e3 --- /dev/null +++ b/assets/php/common/seat_dao.php @@ -0,0 +1,27 @@ +mysqli, $sql) or die ('Error BD createSeat'); + + return $sql; + } + } + +?> \ No newline at end of file diff --git a/assets/php/common/session.php b/assets/php/common/session.php index 93dede9..ae885ed 100644 --- a/assets/php/common/session.php +++ b/assets/php/common/session.php @@ -1,7 +1,7 @@