Add files via upload

This commit is contained in:
Markines16 2021-05-06 23:23:34 +02:00 committed by GitHub
parent 582cb35477
commit 8bb34474d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 108 additions and 12 deletions

View File

@ -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; }

View File

@ -1,7 +1,8 @@
<?php
require_once($prefix.'assets/php/dao.php');
include_once('hall.php');
include_once('seat_dao.php');
class HallDAO extends DAO {
//Constructor:
@ -12,14 +13,16 @@
//Methods:
//Create a new Hall.
public function createHall($number, $idcinema, $numCol, $numRows){
$sql = sprintf( "INSERT INTO `hall`( `number`, `idcinema`, `numrows`, `numcolumns`)
VALUES ( '%d', '%d', '%d', '%d')",
$number, $idcinema, $numRows, $numCol );
public function createHall($hall){
$sql = sprintf( "INSERT INTO `hall`( `number`, `idcinema`, `numrows`, `numcolumns`, `total_seats`)
VALUES ( '%d', '%d', '%d', '%d', '%d')",
$hall['number'], $hall['cinema'], $hall['rows'], $hall['cols'], $hall['seats'] );
$resul = mysqli_query($this->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);

View File

@ -0,0 +1,54 @@
<?php
include_once($prefix.'assets/php/common/seat_dao.php');
class Seat{
//Attributes:
private $_idhall;
private $_idcinema;
private $_numRow;
private $_numCol;
private $_state;
//Constructor:
function __construct($idhall, $idcinema, $numRow, $numCol, $state){
$this->_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; }
}
?>

View File

@ -0,0 +1,27 @@
<?php
require_once($prefix.'assets/php/dao.php');
include_once('seat.php');
class SeatDAO extends DAO {
//Constructor:
function __construct($bd_name){
parent::__construct($bd_name);
}
//Methods:
//Create a new Hall.
public function createSeat($seat, $row, $col){
$sql = sprintf( "INSERT INTO `seat`( `idhall`, `idcinema`, `numrow`, `numcolum`, `active`)
VALUES ( '%d', '%d', '%d', '%d', '%d')",
$seat['number'], $seat['cinema'], $row, $col, $seat[$row][$col]);
$resul = mysqli_query($this->mysqli, $sql) or die ('Error BD createSeat');
return $sql;
}
}
?>

View File

@ -1,7 +1,7 @@
<?php
include_once('session_dao.php');
include_once('film.php');
include_once('film_dao.php');
include_once($prefix.'assets/php/common/session_dao.php');
include_once($prefix.'panel_admin/includes/film.php');
include_once($prefix.'assets/php/common/film_dao.php');
class Session{
@ -55,7 +55,7 @@
} else return "Error al conectarse a la base de datos";
}
public static function edit_session($session){
$bd = new SessionDAO('complucine');
if($bd ){