Add files via upload

This commit is contained in:
Markines16 2021-05-05 21:11:27 +02:00 committed by GitHub
parent 1c5e449cdb
commit cdb9b25754
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 51 additions and 10 deletions

View File

@ -1,7 +1,5 @@
<?php
include_once('film_dto.php');
$template = new Template();
$prefix = $template->get_prefix();
include_once($prefix.'assets/php/dao.php');
class Film_DAO extends DAO {

View File

@ -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');

View File

@ -1,4 +1,8 @@
<?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{
private $_id;
@ -9,7 +13,7 @@
private $_startTime;
private $_seatPrice;
private $_format;
function __construct($id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format){
$this->_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; }

View File

@ -1,6 +1,6 @@
<?php
require_once('../assets/php/dao.php');
include_once('session_dto.php');
require_once($prefix.'assets/php/dao.php');
include_once('session.php');
class SessionDAO extends DAO {
//Constructor:
@ -48,13 +48,12 @@
return $session[0];
}
//Returns a query to get all the session's data.
public function getAllSessionsFromACinemaHallDate($cinema, $hall, $date){
public function getAllSessions($hall, $cinema, $date){
$date = date('Y-m-d', strtotime( $date ) );
$sql = sprintf( "SELECT * FROM session WHERE
idcinema = '%s' AND idhall = '%s' AND date = '%s'",
idcinema = '%s' AND idhall = '%s' AND date = '%s' ORDER BY start_time ASC;",
$cinema, $hall, $date);
$resul = mysqli_query($this->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);
}
}