CALENDAR Sala y cine filtro
This commit is contained in:
parent
7ffb4662bf
commit
91177751b4
@ -15,14 +15,14 @@ class Evento implements \JsonSerializable
|
||||
*
|
||||
* @return array[Evento] Lista de eventos del usuario con id $userId.
|
||||
*/
|
||||
public static function buscaTodosEventos(int $userId, $idhall)
|
||||
public static function buscaTodosEventos(int $userId, $idhall, $cinema)
|
||||
{
|
||||
if (!$userId) {
|
||||
// throw new \BadMethodCallException('$userId no puede ser nulo.');
|
||||
}
|
||||
|
||||
$result = [];
|
||||
$sessions = Session::getListSessions($idhall,"1",null);
|
||||
$sessions = Session::getListSessions($idhall,$cinema,null);
|
||||
|
||||
foreach($sessions as $s){
|
||||
$e = new Evento();
|
||||
@ -41,7 +41,7 @@ class Evento implements \JsonSerializable
|
||||
*
|
||||
* @return Evento Evento encontrado.
|
||||
*/
|
||||
public static function buscaPorId(int $idEvento, $idhall)
|
||||
public static function buscaPorId(int $idEvento, $idhall, $cinema)
|
||||
{
|
||||
if (!$idEvento) {
|
||||
throw new \BadMethodCallException('$idEvento no puede ser nulo.');
|
||||
@ -76,7 +76,7 @@ class Evento implements \JsonSerializable
|
||||
*
|
||||
* @return array[Evento] Lista de eventos encontrados.
|
||||
*/
|
||||
public static function buscaEntreFechas(int $userId, string $start, string $end = null, $idhall)
|
||||
public static function buscaEntreFechas(int $userId, string $start, string $end = null, $idhall, $cinema)
|
||||
{
|
||||
if (!$userId) {
|
||||
//throw new \BadMethodCallException('$userId no puede ser nulo.');
|
||||
@ -101,7 +101,7 @@ class Evento implements \JsonSerializable
|
||||
|
||||
$result = [];
|
||||
|
||||
$sessions = Session::getListSessionsBetween2Dates($idhall,"1",$startDate,$endDate);
|
||||
$sessions = Session::getListSessionsBetween2Dates($idhall,$cinema,$startDate,$endDate);
|
||||
|
||||
foreach($sessions as $s){
|
||||
$e = new Evento();
|
||||
|
@ -31,12 +31,13 @@ switch($_SERVER['REQUEST_METHOD']) {
|
||||
// Consulta de datos
|
||||
case 'GET':
|
||||
$hall = $_GET["hall"];
|
||||
$cinema = $_SESSION["cinema"];
|
||||
// Comprobamos si es una consulta de un evento concreto -> eventos.php?idEvento=XXXXX
|
||||
$idEvento = filter_input(INPUT_GET, 'idEvento', FILTER_VALIDATE_INT);
|
||||
if ($idEvento) {
|
||||
|
||||
$result = [];
|
||||
$result[] = Evento::buscaPorId((int)$idEvento,$hall);
|
||||
$result[] = Evento::buscaPorId((int)$idEvento,$hall,$cinema);
|
||||
} else {
|
||||
// Comprobamos si es una lista de eventos entre dos fechas -> eventos.php?start=XXXXX&end=YYYYY
|
||||
$start = filter_input(INPUT_GET, 'start', FILTER_VALIDATE_REGEXP, array("options" => array("regexp"=>"/\d{4}-((0[1-9])|(1[0-2]))-((0[1-9])|([1-2][0-9])|(3[0-1]))/")));
|
||||
@ -48,11 +49,11 @@ switch($_SERVER['REQUEST_METHOD']) {
|
||||
if ($end) {
|
||||
$endDateTime = $end. ' 00:00:00';
|
||||
}
|
||||
$result = Evento::buscaEntreFechas(1, $startDateTime, $endDateTime, $hall);
|
||||
$result = Evento::buscaEntreFechas(1, $startDateTime, $endDateTime, $hall,$cinema);
|
||||
} else {
|
||||
|
||||
// Comprobamos si es una lista de eventos completa
|
||||
$result = Evento::buscaTodosEventos(1, $hall); // HACK: normalmente debería de ser App::getSingleton()->idUsuario();
|
||||
$result = Evento::buscaTodosEventos(1, $hall,$cinema); // HACK: normalmente debería de ser App::getSingleton()->idUsuario();
|
||||
}
|
||||
}
|
||||
// Generamos un array de eventos en formato JSON
|
||||
|
@ -10,14 +10,13 @@
|
||||
if($_SESSION["login"] && isset($_SESSION["lastRol"]) && ($_SESSION["lastRol"] === "admin" || $_SESSION["rol"] === "manager")) {
|
||||
$manager = new Manager(null, null, null, null, null);
|
||||
if(isset($_POST['changecinema']))$_SESSION['cinema'] = $_POST['cinema'];
|
||||
if(!is_null($_SESSION['cinema'])) $manager->setIdcinema($_SESSION['cinema']);
|
||||
|
||||
|
||||
|
||||
$state = isset($_GET['state']) ? $_GET['state'] : '';
|
||||
switch($state){
|
||||
case "view_user":
|
||||
$_SESSION["rol"] = null;
|
||||
|
||||
$panel .= "<div class='row'>
|
||||
<div class='column side'></div>
|
||||
<div class='column middle'>
|
||||
@ -33,6 +32,7 @@
|
||||
break;
|
||||
case "view_ruser":
|
||||
$_SESSION["rol"] = "user";
|
||||
unset($_SESSION["cinema"]);
|
||||
$panel .= "<div class='row'>
|
||||
<div class='column side'></div>
|
||||
<div class='column middle'>
|
||||
@ -47,25 +47,28 @@
|
||||
";
|
||||
break;
|
||||
case "manage_halls":
|
||||
$panel = Manager_panel::manage_halls($manager);
|
||||
$panel = Manager_panel::manage_halls();
|
||||
break;
|
||||
case "new_hall":
|
||||
$panel = Manager_panel::new_hall($manager);
|
||||
$panel = Manager_panel::new_hall();
|
||||
break;
|
||||
case "edit_hall":
|
||||
$panel = Manager_panel::edit_hall($manager);
|
||||
$panel = Manager_panel::edit_hall();
|
||||
break;
|
||||
case "manage_sessions":
|
||||
$panel = Manager_panel::manage_sessions($manager);
|
||||
$panel = Manager_panel::manage_sessions();
|
||||
break;
|
||||
case "new_session":
|
||||
$panel = Manager_panel::new_session($manager);
|
||||
$panel = Manager_panel::new_session();
|
||||
break;
|
||||
case "edit_session":
|
||||
$panel = Manager_panel::edit_session($manager);
|
||||
$panel = Manager_panel::edit_session();
|
||||
break;
|
||||
case "select_film":
|
||||
$panel = Manager_panel::select_film($template,$manager);
|
||||
$panel = Manager_panel::select_film($template);
|
||||
break;
|
||||
case "calendar":
|
||||
$panel = Manager_panel::calendar();
|
||||
break;
|
||||
case "success":
|
||||
$panel = Manager_panel::success();
|
||||
@ -76,24 +79,25 @@
|
||||
}
|
||||
}
|
||||
else if($_SESSION["login"] && $_SESSION["rol"] === "manager"){
|
||||
$bd = new Manager_DAO('complucine');
|
||||
$manager = false;
|
||||
if($bd && !$manager){
|
||||
$user = unserialize($_SESSION["user"]);
|
||||
$manager = $bd->GetManager($user->getId());
|
||||
|
||||
if($manager){
|
||||
if($manager->num_rows == 1){
|
||||
$fila = $manager->fetch_assoc();
|
||||
$manager = new Manager($fila["id"], $fila["idcinema"], null, null, null);
|
||||
}
|
||||
if(!isset($_SESSION['cinema'])){
|
||||
$bd = new Manager_DAO('complucine');
|
||||
if($bd){
|
||||
$user = unserialize($_SESSION["user"]);
|
||||
$manager = $bd->GetManager($user->getId());
|
||||
$manager = $manager->fetch_assoc();
|
||||
|
||||
$_SESSION['cinema'] = $manager["idcinema"];
|
||||
}
|
||||
}
|
||||
|
||||
$state = isset($_GET['state']) ? $_GET['state'] : '';
|
||||
|
||||
switch($state){
|
||||
case "view_user":
|
||||
$_SESSION["lastRol"] = $_SESSION["rol"];
|
||||
$_SESSION["rol"] = null;
|
||||
unset($_SESSION["cinema"]);
|
||||
$panel = "<div class='row'>
|
||||
<div class='column side'></div>
|
||||
<div class='column middle'>
|
||||
@ -110,6 +114,7 @@
|
||||
case "view_ruser":
|
||||
$_SESSION["lastRol"] = $_SESSION["rol"];
|
||||
$_SESSION["rol"] = "user";
|
||||
unset($_SESSION["cinema"]);
|
||||
$panel = "<div class='row'>
|
||||
<div class='column side'></div>
|
||||
<div class='column middle'>
|
||||
@ -124,34 +129,34 @@
|
||||
";
|
||||
break;
|
||||
case "manage_halls":
|
||||
$panel = Manager_panel::manage_halls($manager);
|
||||
$panel = Manager_panel::manage_halls();
|
||||
break;
|
||||
case "new_hall":
|
||||
$panel = Manager_panel::new_hall($manager);
|
||||
$panel = Manager_panel::new_hall();
|
||||
break;
|
||||
case "edit_hall":
|
||||
$panel = Manager_panel::edit_hall($manager);
|
||||
$panel = Manager_panel::edit_hall();
|
||||
break;
|
||||
case "manage_sessions":
|
||||
$panel = Manager_panel::manage_sessions($manager);
|
||||
$panel = Manager_panel::manage_sessions();
|
||||
break;
|
||||
case "new_session":
|
||||
$panel = Manager_panel::new_session($manager);
|
||||
$panel = Manager_panel::new_session();
|
||||
break;
|
||||
case "edit_session":
|
||||
$panel = Manager_panel::edit_session($manager);
|
||||
$panel = Manager_panel::edit_session();
|
||||
break;
|
||||
case "select_film":
|
||||
$panel = Manager_panel::select_film($template,$manager);
|
||||
$panel = Manager_panel::select_film($template);
|
||||
break;
|
||||
case "success":
|
||||
$panel = Manager_panel::success();
|
||||
break;
|
||||
case "calendar":
|
||||
$panel = Manager_panel::calendar($manager);
|
||||
$panel = Manager_panel::calendar();
|
||||
break;
|
||||
default:
|
||||
$panel = Manager_panel::welcome($manager);
|
||||
$panel = Manager_panel::welcome();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -175,7 +180,6 @@
|
||||
<section id="manager_panel">
|
||||
<!-- Contents -->
|
||||
<div class="row">
|
||||
|
||||
'.$panel.'
|
||||
</div>
|
||||
</section>';
|
||||
|
@ -11,54 +11,60 @@
|
||||
|
||||
function __construct(){}
|
||||
|
||||
static function welcome($manager){
|
||||
static function welcome(){
|
||||
$bd = new Cinema_DAO('complucine');
|
||||
if($bd){
|
||||
$cinema = $bd->cinemaData($manager->getIdcinema());
|
||||
|
||||
$cinema = $bd->cinemaData($_SESSION["cinema"]);
|
||||
$c_name = $cinema->getName();
|
||||
$c_dir = $cinema->getDirection();
|
||||
$c_tel = $cinema->getPhone();
|
||||
}
|
||||
$name = strtoupper($_SESSION["nombre"]);
|
||||
$userPic = USER_PICS.strtolower($name).".jpg";
|
||||
$cinema = strtoupper( $manager->getIdcinema());
|
||||
|
||||
$panel = '<div class="code">
|
||||
<h1>Bienvenido '.$name.' a tu Panel de Manager.</h1>
|
||||
<hr />
|
||||
<div class="column side"></div>
|
||||
<div class="column middle">
|
||||
|
||||
<img src='.$userPic.' alt="user_profile_picture"/>
|
||||
<p>Usuario: '.$name.'</p> <br>
|
||||
<p>Cine: '.$c_name.'</p>
|
||||
<p>Dirección: '.$c_dir.'</p>
|
||||
<p>Telefono: '.$c_tel.'</p> <br>
|
||||
<p>Espero que estes pasando un buen dia</p>
|
||||
|
||||
<a href="?state=calendar"> calendario </a>
|
||||
</div>
|
||||
<div class="column side"></div>
|
||||
</div>';
|
||||
$panel= '<div class="code welcome">
|
||||
<h1>Bienvenido '.$name.' a tu Panel de Manager.</h1>
|
||||
<hr />
|
||||
<img src='.$userPic.' alt="user_profile_picture"/>
|
||||
<h3>'.strftime("%A %e de %B de %Y | %H:%M").'</h3>
|
||||
<p>Usuario: '.$name.'</p> <br>
|
||||
<p>Cine: '.$c_name.'</p>
|
||||
<p>Dirección: '.$c_dir.'</p>
|
||||
<a href="?state=calendar"> <p> Hack para entrar al calendario <p> </a>
|
||||
</div>'."\n";
|
||||
|
||||
return $panel;
|
||||
}
|
||||
|
||||
static function welcomeAdmin($manager) {
|
||||
static function welcomeAdmin() {
|
||||
$cinemaList = new Cinema_DAO('complucine');
|
||||
$cinemas = $cinemaList->allCinemaData();
|
||||
$cinema;
|
||||
|
||||
$bd = new Cinema_DAO('complucine');
|
||||
|
||||
$c_name = "Aun no se ha escogido un cine";
|
||||
|
||||
if($bd && $_SESSION["cinema"] ){
|
||||
|
||||
$cinema = $bd->cinemaData($_SESSION["cinema"]);
|
||||
$c_name = $cinema->getName();
|
||||
$cinema = $cinema->getId();
|
||||
}
|
||||
|
||||
$name = strtoupper($_SESSION["nombre"]);
|
||||
$userPic = USER_PICS.strtolower($name).".jpg";
|
||||
|
||||
if($manager->getIdcinema() != null) $cinema = strtoupper( $manager->getIdcinema());
|
||||
$panel= '<div class="code welcome">
|
||||
<h1>Bienvenido '.$name.' a tu Panel de Manager.</h1>
|
||||
<hr />
|
||||
<img src='.$userPic.' alt="user_profile_picture"/>
|
||||
<h3>'.strftime("%A %e de %B de %Y | %H:%M").'</h3>
|
||||
<p>Usuario: '.$name.'</p> <br>
|
||||
<h3>Como administrador puedes escoger el cine que gestionar</h3>
|
||||
<p>Cine: '.$c_name.'</p>
|
||||
|
||||
<a href="?state=calendar"> <p> Hack para entrar al calendario <p> </a>
|
||||
|
||||
$panel = '<div class="code info">
|
||||
<h1>Bienvenido '.$name.' a tu Panel de Manager.</h1>
|
||||
<hr />
|
||||
<p>Usuario: '.$name.'</p>
|
||||
<p>Cine: '.$cinema.'</p>
|
||||
<p>Espero que estes pasando un buen dia</p>
|
||||
<form method="post" id="changecinema" action="index.php">
|
||||
<select name="cinema" class="button large">
|
||||
';
|
||||
@ -78,10 +84,10 @@
|
||||
|
||||
return $panel;
|
||||
}
|
||||
static function calendar($manager){
|
||||
static function calendar(){
|
||||
|
||||
$hall = $_POST['hall'] ?? $_GET['hall'] ?? "1";
|
||||
$halls = Hall::getListHalls($manager->getIdcinema());
|
||||
$halls = Hall::getListHalls($_SESSION["cinema"]);
|
||||
|
||||
if($halls){
|
||||
$panel ='
|
||||
@ -90,7 +96,7 @@
|
||||
<div class="column middle">
|
||||
<br>
|
||||
<select id="hall_selector" class="button large">';
|
||||
foreach(Hall::getListHalls($manager->getIdcinema()) as $hll){
|
||||
foreach(Hall::getListHalls($_SESSION["cinema"]) as $hll){
|
||||
if($hll->getNumber() == $hall){
|
||||
$panel.= '
|
||||
<option data-feed="./eventos.php?hall='.$hll->getNumber().'" value="'. $hll->getNumber() .'"selected> Sala '. $hll->getNumber() .'</option> ';
|
||||
@ -128,11 +134,11 @@
|
||||
return $panel;
|
||||
}
|
||||
|
||||
static function manage_halls($manager){
|
||||
static function manage_halls(){
|
||||
|
||||
$panel = '<div class="column side"></div>
|
||||
<div class="column middle">';
|
||||
$listhall = Hall::getListHalls($manager->getIdcinema());
|
||||
$listhall = Hall::getListHalls($_SESSION["cinema"]);
|
||||
if(!$listhall){
|
||||
$panel .= "<h2> No hay ninguna sala en este cine";
|
||||
}else{
|
||||
@ -149,7 +155,7 @@
|
||||
<li> '. $hall->getNumber().'</li>
|
||||
<li> '.$hall->getTotalSeats().' </li>
|
||||
</a>
|
||||
<a href="?state=manage_sessions&hall='. $hall->getNumber().'">
|
||||
<a href="?state=calendar&hall='. $hall->getNumber().'">
|
||||
<li> Sesiones </li>
|
||||
</a>
|
||||
</div>
|
||||
@ -168,30 +174,30 @@
|
||||
return $panel;
|
||||
}
|
||||
|
||||
static function new_hall($manager){
|
||||
static function new_hall(){
|
||||
|
||||
$formHall = new FormHall("new_hall",$manager->getIdcinema(),new Hall(null, null, null, null, null, null));
|
||||
$formHall = new FormHall("new_hall",$_SESSION["cinema"],new Hall(null, null, null, null, null, null));
|
||||
|
||||
$panel = '<h1>Crear una sala.</h1><hr/></br>
|
||||
'.$formHall->gestiona();
|
||||
return $panel;
|
||||
}
|
||||
|
||||
static function edit_hall($manager){
|
||||
$hall = Hall::search_hall($_GET["number"], $manager->getIdcinema());
|
||||
static function edit_hall(){
|
||||
$hall = Hall::search_hall($_GET["number"], $_SESSION["cinema"]);
|
||||
|
||||
if($hall || isset($_POST["restart"]) || isset($_POST["filter"]) || isset($_POST["sumbit"]) ){
|
||||
|
||||
$formHall = new FormHall("edit_hall",$manager->getIdcinema(), $hall);
|
||||
$formHall = new FormHall("edit_hall",$_SESSION["cinema"], $hall);
|
||||
$panel = '<h1>Editar una sala.</h1><hr/></br>
|
||||
'.$formHall->gestiona();
|
||||
return $panel;
|
||||
} else{
|
||||
return Manager_panel::warning($manager);
|
||||
return Manager_panel::warning();
|
||||
}
|
||||
}
|
||||
|
||||
static function manage_sessions($manager){
|
||||
static function manage_sessions(){
|
||||
//Base filtering values
|
||||
$date = $_POST['date'] ?? $_GET['date'] ?? date("Y-m-d");
|
||||
$hall = $_POST['hall'] ?? $_GET['hall'] ?? "1";
|
||||
@ -202,7 +208,7 @@
|
||||
<input type="date" name="date" value="'.$date.'" min="2021-01-01" max="2031-12-31">
|
||||
<select name="hall" class="button large">';
|
||||
|
||||
foreach(Hall::getListHalls($manager->getIdcinema()) as $hll){
|
||||
foreach(Hall::getListHalls($_SESSION["cinema"]) as $hll){
|
||||
if($hll->getNumber() == $hall){
|
||||
$panel.= '
|
||||
<option value="'. $hll->getNumber() .'"selected> Sala '. $hll->getNumber() .'</option> ';
|
||||
@ -219,7 +225,7 @@
|
||||
';
|
||||
//Session list
|
||||
$panel .=' <div class = "column right">';
|
||||
$sessions = Session::getListSessions($hall,$manager->getIdcinema(),$date);
|
||||
$sessions = Session::getListSessions($hall,$_SESSION["cinema"],$date);
|
||||
|
||||
if($sessions) {
|
||||
$panel .='
|
||||
@ -273,16 +279,16 @@
|
||||
return $panel;
|
||||
}
|
||||
|
||||
static function new_session($manager){
|
||||
$formSession = new FormSession("new_session", $manager->getIdcinema() );
|
||||
static function new_session(){
|
||||
$formSession = new FormSession("new_session", $_SESSION["cinema"] );
|
||||
|
||||
$panel = '<h1>Crear una sesion.</h1> <hr/> </br>
|
||||
'.$formSession->gestiona();
|
||||
return $panel;
|
||||
}
|
||||
|
||||
static function edit_session($manager){
|
||||
$formSession = new FormSession("edit_session", $manager->getIdcinema() );
|
||||
static function edit_session(){
|
||||
$formSession = new FormSession("edit_session", $_SESSION["cinema"] );
|
||||
|
||||
$panel = '<h1>Editar una sesion.</h1><hr/></br>
|
||||
'.$formSession->gestiona();
|
||||
@ -290,19 +296,19 @@
|
||||
}
|
||||
|
||||
//TODO: estado al modificar sesiones para la seleccion de peliculas usando el template->print films
|
||||
static function select_film($template,$manager){
|
||||
static function select_film($template){
|
||||
if(isset($_POST["select_film"]) && isset($_POST["option"])){
|
||||
$_SESSION["option"] = $_POST["option"];
|
||||
$panel = '<h1>Seleccionar Pelicula.</h1><hr /></br>';
|
||||
$panel .= $template->print_fimls();
|
||||
$_SESSION["option"] = "";
|
||||
} else $panel = self::warning($manager);
|
||||
} else $panel = self::warning();
|
||||
|
||||
return $panel;
|
||||
}
|
||||
|
||||
//Funcion que se envia cuando hay inconsistencia en el panel manager, principalmente por tocar cosas con la ulr
|
||||
static function warning($manager){
|
||||
static function warning(){
|
||||
$panel = '<div class="code info">
|
||||
<h1>Ha habido un error.</h1>
|
||||
<hr />
|
||||
|
Loading…
Reference in New Issue
Block a user