SW/assets/php/common/session.php

118 lines
4.2 KiB
PHP
Raw Normal View History

<?php
2021-05-06 23:23:34 +02:00
include_once($prefix.'assets/php/common/session_dao.php');
2021-05-05 21:11:27 +02:00
class Session{
private $_id;
private $_idfilm;
private $_idhall;
private $_idcinema;
private $_date;
private $_startTime;
private $_seatPrice;
private $_format;
2021-05-07 13:48:50 +02:00
private $_seats_full;
2021-05-05 21:11:27 +02:00
2021-05-07 13:48:50 +02:00
function __construct($id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format, $seats_full){
$this->_id = $id;
$this->_idfilm = $idfilm;
$this->_idhall = $idhall;
$this->_idcinema = $idcinema;
$this->_date = $date;
$this->_startTime = $startTime;
$this->_seatPrice = $seatPrice;
$this->_format = $format;
2021-05-07 13:48:50 +02:00
$this->_seats_full = $seats_full;
}
2021-05-05 21:11:27 +02:00
public static function getListSessions($hall,$cinema,$date){
$bd = new SessionDAO('complucine');
if($bd ) {
return $bd->getAllSessions($hall, $cinema, $date);
}
}
2021-05-13 10:12:09 +02:00
public static function create_session($cinema, $hall, $start, $date, $film, $price, $format,$repeat){
2021-05-05 21:11:27 +02:00
$bd = new SessionDAO('complucine');
if($bd ){
2021-05-13 10:12:09 +02:00
if(!$bd->searchSession($cinema, $hall, $start, $date)){
$bd->createSession(null,$film, $hall, $cinema, $date, $start, $price, $format);
if($repeat > "0") {
$repeats = $repeat;
$repeat = $repeat - 1;
$date = date('Y-m-d', strtotime( $date . ' +1 day') );
self::create_session($cinema, $hall, $start, $date, $film, $price, $format,$repeat);
2021-05-05 21:11:27 +02:00
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";
}
2021-05-06 23:23:34 +02:00
2021-05-13 10:12:09 +02:00
public static function edit_session($cinema, $or_hall, $or_date, $or_start, $hall, $start, $date, $film, $price, $format){
2021-05-06 18:11:12 +02:00
$bd = new SessionDAO('complucine');
if($bd ){
2021-05-13 10:12:09 +02:00
if($bd->searchSession($cinema, $or_hall, $or_start, $or_date)){
2021-05-13 14:06:07 +02:00
if(!$bd->searchSession($cinema,$hall,$start,$date)){
$origin = array("cinema" => $cinema,"hall" => $or_hall,"start" => $or_start,"date" => $or_date);
$bd->editSession($film, $hall, $cinema, $date, $start, $price, $format,$origin);
return "Se ha editado la session con exito";
}else
return "Ya existe una sesion con los parametros nuevos";
2021-05-06 18:11:12 +02:00
} else
return "Esta session no existe";
} else return "Error al conectarse a la base de datos";
}
2021-05-13 10:12:09 +02:00
public static function delete_session($cinema, $hall, $start, $date){
2021-05-06 18:11:12 +02:00
$bd = new SessionDAO('complucine');
if($bd ){
2021-05-13 10:12:09 +02:00
if($bd->searchSession($cinema, $hall, $start, $date)){
$bd->deleteSession($hall, $cinema, $date, $start);
2021-05-06 18:11:12 +02:00
return "Se ha eliminado la session con exito";
} else
return "Esta session no existe";
} else return "Error al conectarse a la base de datos";
}
2021-05-05 21:11:27 +02:00
//Esto deberia estar en film.php? seguramente
2021-05-07 13:48:50 +02:00
public static function getThisSessionFilm($idfilm){
$bd = new SessionDAO('complucine');
if($bd ) {
return $bd->filmTittle($idfilm);
}
2021-05-05 21:11:27 +02:00
}
public function setId($id){ $this->_id = $id; }
public function getId(){ return $this->_id; }
public function setIdfilm($idfilm){ $this->_idfilm = $idfilm; }
public function getIdfilm(){ return $this->_idfilm; }
public function setIdhall($idhall){ $this->_idhall = $idhall; }
public function getIdhall(){ return $this->_idhall; }
public function setIdcinema($cinema){ $this->_idcinema = $idcinema; }
public function getIdcinema(){ return $this->_idcinema; }
public function setDate($date){ $this->_date = $date; }
public function getDate(){ return $this->_date; }
public function setStartTime($startTime){ $this->_startTime = $startTime; }
public function getStartTime(){ return $this->_startTime; }
public function setSeatPrice($seatPrice){ $this->_seatPrice = $seatPrice; }
public function getSeatPrice(){ return $this->_seatPrice; }
public function setFormat($format){ $this->_format = $format; }
public function getFormat(){ return $this->_format; }
}
?>