diff --git a/panel_manager/Evento.php b/panel_manager/Evento.php
index f04d955..e6e444e 100644
--- a/panel_manager/Evento.php
+++ b/panel_manager/Evento.php
@@ -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();
diff --git a/panel_manager/eventos.php b/panel_manager/eventos.php
index 9048da9..b6e7c79 100644
--- a/panel_manager/eventos.php
+++ b/panel_manager/eventos.php
@@ -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
diff --git a/panel_manager/index.php b/panel_manager/index.php
index 4b5a8c6..e55b286 100644
--- a/panel_manager/index.php
+++ b/panel_manager/index.php
@@ -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 .= "
@@ -33,6 +32,7 @@
break;
case "view_ruser":
$_SESSION["rol"] = "user";
+ unset($_SESSION["cinema"]);
$panel .= "
@@ -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 = "
@@ -110,6 +114,7 @@
case "view_ruser":
$_SESSION["lastRol"] = $_SESSION["rol"];
$_SESSION["rol"] = "user";
+ unset($_SESSION["cinema"]);
$panel = "
@@ -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 @@
';
diff --git a/panel_manager/panel_manager.php b/panel_manager/panel_manager.php
index f338850..869dc78 100644
--- a/panel_manager/panel_manager.php
+++ b/panel_manager/panel_manager.php
@@ -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 = '
-
Bienvenido '.$name.' a tu Panel de Manager.
-
-
-
-
-
-
Usuario: '.$name.'
-
Cine: '.$c_name.'
-
Dirección: '.$c_dir.'
-
Telefono: '.$c_tel.'
-
Espero que estes pasando un buen dia
-
-
calendario
-
-
-
';
-
+ $panel= '
+
Bienvenido '.$name.' a tu Panel de Manager.
+
+
+
'.strftime("%A %e de %B de %Y | %H:%M").'
+
Usuario: '.$name.'
+
Cine: '.$c_name.'
+
Dirección: '.$c_dir.'
+
Hack para entrar al calendario
+
'."\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 = '
-
Bienvenido '.$name.' a tu Panel de Manager.
-
-
Usuario: '.$name.'
-
Cine: '.$cinema.'
-
Espero que estes pasando un buen dia
+ $panel= '
+
Bienvenido '.$name.' a tu Panel de Manager.
+
+
+
'.strftime("%A %e de %B de %Y | %H:%M").'
+
Usuario: '.$name.'
+
Como administrador puedes escoger el cine que gestionar
+
Cine: '.$c_name.'
+
+
Hack para entrar al calendario
+