diff --git a/panel_manager/Evento.php b/panel_manager/Evento.php
index e0676a7..f04d955 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)
+ public static function buscaTodosEventos(int $userId, $idhall)
{
if (!$userId) {
// throw new \BadMethodCallException('$userId no puede ser nulo.');
}
$result = [];
- $sessions = Session::getListSessions("1","1",null);
+ $sessions = Session::getListSessions($idhall,"1",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)
+ public static function buscaPorId(int $idEvento, $idhall)
{
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)
+ public static function buscaEntreFechas(int $userId, string $start, string $end = null, $idhall)
{
if (!$userId) {
//throw new \BadMethodCallException('$userId no puede ser nulo.');
@@ -101,7 +101,7 @@ class Evento implements \JsonSerializable
$result = [];
- $sessions = Session::getListSessionsBetween2Dates("1","1",$startDate,$endDate);
+ $sessions = Session::getListSessionsBetween2Dates($idhall,"1",$startDate,$endDate);
foreach($sessions as $s){
$e = new Evento();
@@ -292,8 +292,11 @@ class Evento implements \JsonSerializable
private $end;
private $idfilm;
- /*private $idhall;
- private $idcinema;
+
+
+ /*
+ private $idhall;
+ private $idcinema;
private $date;
private $start_time;
private $seat_price;
@@ -309,7 +312,7 @@ class Evento implements \JsonSerializable
{
return $this->id;
}
-
+
public function getUserId()
{
return $this->userId;
@@ -404,7 +407,7 @@ class Evento implements \JsonSerializable
$film = Session::getThisSessionFilm($session->getIdfilm());
$dur = $film["duration"]+$extraDurationBetweenFilms;
- $tittle = "Sala: ".$session->getIdhall()." ".$film["tittle"];
+ $tittle = str_replace('_', ' ', $film["tittle"]) ;
$start = $session->getDate()." ".$session->getStartTime();
$end = date('Y-m-d H:i:s', strtotime( $start . ' +'.$dur.' minute'));
@@ -541,6 +544,7 @@ class Evento implements \JsonSerializable
$this->idfilm = $idfilm;
}
}
+
/*
if (array_key_exists('idhall', $diccionario)) {
$idhall = $diccionario['idhall'] ?? null;
diff --git a/panel_manager/eventos.php b/panel_manager/eventos.php
index 543d156..9048da9 100644
--- a/panel_manager/eventos.php
+++ b/panel_manager/eventos.php
@@ -30,11 +30,13 @@ $result = null;
switch($_SERVER['REQUEST_METHOD']) {
// Consulta de datos
case 'GET':
+ $hall = $_GET["hall"];
// 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);
+ $result[] = Evento::buscaPorId((int)$idEvento,$hall);
} 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]))/")));
@@ -46,11 +48,11 @@ switch($_SERVER['REQUEST_METHOD']) {
if ($end) {
$endDateTime = $end. ' 00:00:00';
}
- $result = Evento::buscaEntreFechas(1, $startDateTime, $endDateTime);
+ $result = Evento::buscaEntreFechas(1, $startDateTime, $endDateTime, $hall);
} else {
// Comprobamos si es una lista de eventos completa
- $result = Evento::buscaTodosEventos(1); // HACK: normalmente debería de ser App::getSingleton()->idUsuario();
+ $result = Evento::buscaTodosEventos(1, $hall); // HACK: normalmente debería de ser App::getSingleton()->idUsuario();
}
}
// Generamos un array de eventos en formato JSON
@@ -75,6 +77,7 @@ switch($_SERVER['REQUEST_METHOD']) {
// 3. Reprocesamos el cuerpo de la petición como un array PHP
$dictionary = json_decode($entityBody, true);
$dictionary['userId'] = 1;// HACK: normalmente debería de ser App::getSingleton()->idUsuario();
+
$e = Evento::creaDesdeDicionario($dictionary);
// 4. Guardamos el evento en BD
diff --git a/panel_manager/panel_manager.php b/panel_manager/panel_manager.php
index 286a87c..f338850 100644
--- a/panel_manager/panel_manager.php
+++ b/panel_manager/panel_manager.php
@@ -23,17 +23,22 @@
$userPic = USER_PICS.strtolower($name).".jpg";
$cinema = strtoupper( $manager->getIdcinema());
- $panel = '
+ $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
+
+
+
+
+
Usuario: '.$name.'
+
Cine: '.$c_name.'
+
Dirección: '.$c_dir.'
+
Telefono: '.$c_tel.'
+
Espero que estes pasando un buen dia
+
+
calendario
+
+
';
return $panel;
@@ -73,11 +78,42 @@
return $panel;
}
- static function calendar(){
- $panel = '
-
';
+ static function calendar($manager){
+
+ $hall = $_POST['hall'] ?? $_GET['hall'] ?? "1";
+ $halls = Hall::getListHalls($manager->getIdcinema());
+
+ if($halls){
+ $panel ='
+
+
+
+
+
+
+
+
+
';
+ }else{
+ $panel ='
';
+ }
+
return $panel;
}
diff --git a/panel_manager/sessioncalendar.js b/panel_manager/sessioncalendar.js
index 998f0cb..f44ea5c 100644
--- a/panel_manager/sessioncalendar.js
+++ b/panel_manager/sessioncalendar.js
@@ -1,108 +1,118 @@
- $(document).ready(function() {
- var calendar = $('#calendar').fullCalendar({
- editable:true,
- header:{
- left:'prev,next today',
- center:'title',
- right:'month,agendaWeek,agendaDay'
- },
- events: 'eventos.php',
- selectable:true,
- selectHelper:true,
- timeFormat: 'H:mm',
- select: function(start, end, allDay)
- {
- var title = prompt("Enter Event Title");
- if(title)
- {
- var e = {
- "start" : $.fullCalendar.formatDate(start, "Y-MM-DD HH:mm:ss"),
- "end" : $.fullCalendar.formatDate(end, "Y-MM-DD HH:mm:ss"),
- "title" : title
- };
- $.ajax({
- url:"eventos.php",
- type:"POST",
- contentType: 'application/json; charset=utf-8',
- dataType: "json",
- data:JSON.stringify(e),
- success:function()
- {
- calendar.fullCalendar('refetchEvents');
- alert("Added Successfully");
- }
- })
- }
- },
- editable:true,
- eventResize:function(event)
- {
- var e = {
- "id" : event.id,
- "userId": event.userId,
- "start" : $.fullCalendar.formatDate(event.start, "Y-MM-DD HH:mm:ss"),
- "end" : $.fullCalendar.formatDate(event.end, "Y-MM-DD HH:mm:ss"),
- "title" : event.title
- };
-
- $.ajax({
- url:"eventos.php?idEvento="+event.id,
- type:"PUT",
- contentType: 'application/json; charset=utf-8',
- dataType:"json",
- data:JSON.stringify(e),
- success:function(){
- calendar.fullCalendar('refetchEvents');
- alert('Event Update');
- }
- })
- },
+$(document).ready(function(){
+
+ var selectedFeed = $('#hall_selector').find(':selected').data('feed');
+
+ var calendar = $('#calendar').fullCalendar({
+ editable:true,
+ header:{
+ left:'prev,next today',
+ center:'title',
+ right:'month,agendaWeek,agendaDay'
+ },
+ eventSources: [ selectedFeed ],
+ selectable:true,
+ selectHelper:true,
+ timeFormat: 'H:mm',
+ select: function(start, end, allDay)
+ {
- eventDrop:function(event)
- {
- var e = {
- "id" : event.id,
- "userId": event.userId,
- "start" : $.fullCalendar.formatDate(event.start, "Y-MM-DD HH:mm:ss"),
- "end" : $.fullCalendar.formatDate(event.end, "Y-MM-DD HH:mm:ss"),
- "title" : event.title
- };
- $.ajax({
- url:"eventos.php?idEvento="+event.id,
- contentType: 'application/json; charset=utf-8',
- dataType: "json",
- type:"PUT",
- data:JSON.stringify(e),
- success:function()
- {
- calendar.fullCalendar('refetchEvents');
- alert("Event Updated");
- }
- });
- },
+ var e = {
+ "date" : $.fullCalendar.formatDate(allDay,"Y-MM-DD"),
+ "start" : $.fullCalendar.formatDate(start, "HH:mm"),
+ "end" : $.fullCalendar.formatDate(end, "HH:mm")
+ };
+ $.ajax({
+ url:"eventos.php",
+ type:"POST",
+ contentType: 'application/json; charset=utf-8',
+ dataType: "json",
+ data:JSON.stringify(e),
+ success:function()
+ {
+ calendar.fullCalendar('refetchEvents');
+ alert("Added Successfully");
+ }
+ })
+ },
+ editable:true,
+ eventResize:function(event)
+ {
+ var e = {
+ "id" : event.id,
+ "userId": event.userId,
+ "start" : $.fullCalendar.formatDate(event.start, "Y-MM-DD HH:mm:ss"),
+ "end" : $.fullCalendar.formatDate(event.end, "Y-MM-DD HH:mm:ss"),
+ "title" : event.title
+ };
+
+ $.ajax({
+ url:"eventos.php?idEvento="+event.id,
+ type:"PUT",
+ contentType: 'application/json; charset=utf-8',
+ dataType:"json",
+ data:JSON.stringify(e),
+ success:function(){
+ calendar.fullCalendar('refetchEvents');
+ alert('Event Update');
+ }
+ })
+ },
- eventClick:function(event)
- {
- if(confirm("Are you sure you want to remove it?"))
- {
- var id = event.id;
- $.ajax({
- url:"eventos.php?idEvento="+id,
- contentType: 'application/json; charset=utf-8',
- dataType: "json",
- type:"DELETE",
- success:function()
- {
- calendar.fullCalendar('refetchEvents');
- alert("Event Removed");
- },
- error: function(XMLHttpRequest, textStatus, errorThrown) {
- alert("Status: " + textStatus); alert("Error: " + errorThrown);
- }
- })
- }
- },
+ eventDrop:function(event)
+ {
+ var e = {
+ "id" : event.id,
+ "userId": event.userId,
+ "start" : $.fullCalendar.formatDate(event.start, "Y-MM-DD HH:mm:ss"),
+ "end" : $.fullCalendar.formatDate(event.end, "Y-MM-DD HH:mm:ss"),
+ "title" : event.title
+ };
+ $.ajax({
+ url:"eventos.php?idEvento="+event.id,
+ contentType: 'application/json; charset=utf-8',
+ dataType: "json",
+ type:"PUT",
+ data:JSON.stringify(e),
+ success:function()
+ {
+ calendar.fullCalendar('refetchEvents');
+ alert("Event Updated");
+ }
+ });
+ },
- });
- });
\ No newline at end of file
+ eventClick:function(event)
+ {
+ if(confirm("Are you sure you want to remove it?"))
+ {
+ var id = event.id;
+ $.ajax({
+ url:"eventos.php?idEvento="+id,
+ contentType: 'application/json; charset=utf-8',
+ dataType: "json",
+ type:"DELETE",
+ success:function()
+ {
+ calendar.fullCalendar('refetchEvents');
+ alert("Event Removed");
+ },
+ error: function(XMLHttpRequest, textStatus, errorThrown) {
+ alert("Status: " + textStatus); alert("Error: " + errorThrown);
+ }
+ })
+ }
+ },
+
+ });
+
+ $('#hall_selector').change(onSelectChangeFeed);
+
+ function onSelectChangeFeed() {
+ var feed = $(this).find(':selected').data('feed');
+ $('#calendar').fullCalendar('removeEventSource', selectedFeed);
+ $('#calendar').fullCalendar('addEventSource', feed);
+ selectedFeed = feed;
+ };
+});
+