Add files via upload

This commit is contained in:
Markines16 2021-05-07 13:48:50 +02:00 committed by GitHub
parent fe520f1495
commit 7be148840e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 17 deletions

View File

@ -8,6 +8,7 @@
private $_idcinema; //Cinema Id
private $_numRows; //Num rows.
private $_numCol; //Num columns.
private $_total_seats;
//Constructor:
function __construct($number, $idcinema, $numRows, $numCol){

View File

@ -1,7 +1,5 @@
<?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{
@ -13,8 +11,9 @@
private $_startTime;
private $_seatPrice;
private $_format;
private $_seats_full;
function __construct($id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format){
function __construct($id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format, $seats_full){
$this->_id = $id;
$this->_idfilm = $idfilm;
$this->_idhall = $idhall;
@ -23,6 +22,7 @@
$this->_startTime = $startTime;
$this->_seatPrice = $seatPrice;
$this->_format = $format;
$this->_seats_full = $seats_full;
}
public static function getListSessions($hall,$cinema,$date){
@ -83,11 +83,26 @@
}
//Esto deberia estar en film.php? seguramente
public static function getFilmTitle($idfilm){
$bd = new Film_DAO('complucine');
public static function getThisSessionFilm($idfilm){
$bd = new SessionDAO('complucine');
if($bd ) {
$film = mysqli_fetch_array($bd->FilmData($idfilm));
return $film["tittle"];
return $bd->filmTittle($idfilm);
}
return "";
}
public static function getThisSessionId($cinema, $hall, $start, $date){
$bd = new SessionDAO('complucine');
if($bd ) {
return $bd->searchSession($cinema, $hall, $start, $date);
}
return "";
}
public static function getThisSessionFromId($id){
$bd = new SessionDAO('complucine');
if($bd ) {
return $bd->sessionData($id);
}
return "";
}

View File

@ -14,9 +14,9 @@
$date = date('Y-m-d', strtotime( $date ) );
$startTime = date('H:i:s', strtotime( $startTime ) );
$sql = sprintf( "INSERT INTO `session` (`id`, `idfilm`, `idhall`, `idcinema`, `date`, `start_time`, `seat_price`, `format`)
VALUES ('%d', '%d', '%d', '%d', '%s', '%s', '%d', '%s')",
$id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format);
$sql = sprintf( "INSERT INTO `session` (`id`, `idfilm`, `idhall`, `idcinema`, `date`, `start_time`, `seat_price`, `format`, `seats_full`)
VALUES ('%d', '%d', '%d', '%d', '%s', '%s', '%d', '%s', '%d')",
$id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format, "0");
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
@ -28,25 +28,35 @@
$sql = sprintf( "SELECT * FROM `session` WHERE id = '%d'", $id );
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database en sessionData con la id '. $id);
$resul = mysqli_fetch_array($resul);
return $resul;
}
//Returns the count of the session searched
public function filmTittle($idfilm){
$sql = sprintf("SELECT * FROM film JOIN session ON film.id = session.idfilm WHERE session.idfilm = '%d' ", $idfilm );
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database en sessionData con la id '. $idfilm);
$resul = mysqli_fetch_array($resul);
return $resul;
}
//Returns a session
public function searchSession($cinema, $hall, $startTime, $date){
$date = date('Y-m-d', strtotime( $date ) );
$startTime = date('H:i:s', strtotime( $startTime ) );
$sql = sprintf( "SELECT COUNT(*) FROM session WHERE
$sql = sprintf( "SELECT * FROM session WHERE
idcinema = '%s' AND idhall = '%s' AND date = '%s' AND start_time = '%s'",
$cinema, $hall, $date, $startTime);
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
$session = null;
$session = mysqli_fetch_array($resul);
mysqli_free_result($resul);
return $session[0];
return $session;
}
//Returns a query to get all the session's data.
public function getAllSessions($hall, $cinema, $date){
@ -60,7 +70,7 @@
$sessions = null;
while($fila=mysqli_fetch_array($resul)){
$sessions[] = $this->loadSession($fila["id"], $fila["idfilm"], $fila["idhall"], $fila["idcinema"], $fila["date"], $fila["start_time"], $fila["seat_price"], $fila["format"]);
$sessions[] = $this->loadSession($fila["id"], $fila["idfilm"], $fila["idhall"], $fila["idcinema"], $fila["date"], $fila["start_time"], $fila["seat_price"], $fila["format"], $fila["seats_full"]);
}
mysqli_free_result($resul);
@ -96,8 +106,8 @@
}
//Create a new Session Data Transfer Object.
public function loadSession( $id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format){
return new Session( $id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format);
public function loadSession( $id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format, $seats_full){
return new Session( $id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format, $seats_full);
}
}