2021-05-17 15:29:29 +02:00
|
|
|
<?php
|
2021-05-20 15:29:49 +02:00
|
|
|
include_once($prefix.'assets/php/includes/hall.php');
|
|
|
|
include_once($prefix.'assets/php/includes/session.php');
|
|
|
|
require_once($prefix.'assets/php/includes/manager.php');
|
|
|
|
require_once($prefix.'assets/php/includes/cinema_dao.php');
|
2021-05-17 15:29:29 +02:00
|
|
|
include_once('./includes/formHall.php');
|
|
|
|
include_once('./includes/formSession.php');
|
|
|
|
|
|
|
|
|
|
|
|
class Manager_panel {
|
|
|
|
|
|
|
|
function __construct(){}
|
|
|
|
|
2021-06-03 14:09:25 +02:00
|
|
|
static function welcome(){
|
2021-05-25 00:51:11 +02:00
|
|
|
$bd = new Cinema_DAO('complucine');
|
|
|
|
if($bd){
|
2021-06-03 14:09:25 +02:00
|
|
|
|
|
|
|
$cinema = $bd->cinemaData($_SESSION["cinema"]);
|
2021-05-27 14:28:17 +02:00
|
|
|
$c_name = $cinema->getName();
|
|
|
|
$c_dir = $cinema->getDirection();
|
2021-05-25 00:51:11 +02:00
|
|
|
}
|
2021-05-17 15:29:29 +02:00
|
|
|
$name = strtoupper($_SESSION["nombre"]);
|
2021-06-02 09:36:59 +02:00
|
|
|
$userPic = USER_PICS.strtolower($name).".jpg";
|
2021-06-03 12:53:53 +02:00
|
|
|
|
2021-06-03 14:09:25 +02:00
|
|
|
$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";
|
|
|
|
|
2021-05-17 15:29:29 +02:00
|
|
|
return $panel;
|
|
|
|
}
|
2021-05-20 11:45:16 +02:00
|
|
|
|
2021-06-03 14:09:25 +02:00
|
|
|
static function welcomeAdmin() {
|
2021-05-20 10:53:47 +02:00
|
|
|
$cinemaList = new Cinema_DAO('complucine');
|
|
|
|
$cinemas = $cinemaList->allCinemaData();
|
2021-06-03 14:09:25 +02:00
|
|
|
|
|
|
|
$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();
|
|
|
|
}
|
2021-05-20 10:53:47 +02:00
|
|
|
|
|
|
|
$name = strtoupper($_SESSION["nombre"]);
|
2021-06-03 14:09:25 +02:00
|
|
|
$userPic = USER_PICS.strtolower($name).".jpg";
|
2021-05-20 10:53:47 +02:00
|
|
|
|
2021-06-03 14:09:25 +02:00
|
|
|
$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>
|
|
|
|
|
2021-05-20 10:53:47 +02:00
|
|
|
<form method="post" id="changecinema" action="index.php">
|
2021-05-27 20:41:45 +02:00
|
|
|
<select name="cinema" class="button large">
|
2021-05-20 10:53:47 +02:00
|
|
|
';
|
|
|
|
foreach($cinemas as $c){
|
|
|
|
if($c->getId() == $cinema){
|
2021-05-27 20:41:45 +02:00
|
|
|
$panel .= "<option value=\"". $c->getId() ." \"selected> " . $c->getName() ."</option>
|
2021-05-20 10:53:47 +02:00
|
|
|
";
|
|
|
|
}else{
|
2021-05-27 20:41:45 +02:00
|
|
|
$panel .= "<option value=\"". $c->getId() ." \"> " . $c->getName() . "</option>
|
2021-05-20 10:53:47 +02:00
|
|
|
";
|
|
|
|
}
|
|
|
|
}
|
2021-06-01 12:30:28 +02:00
|
|
|
$panel .= ' <input type="submit" name="changecinema" value="Cambiar" /><br>
|
2021-05-20 10:53:47 +02:00
|
|
|
</select>
|
|
|
|
</form>
|
|
|
|
</div>';
|
2021-05-20 11:45:16 +02:00
|
|
|
|
2021-05-20 10:53:47 +02:00
|
|
|
return $panel;
|
|
|
|
}
|
2021-06-03 14:09:25 +02:00
|
|
|
static function calendar(){
|
2021-06-03 12:53:53 +02:00
|
|
|
|
|
|
|
$hall = $_POST['hall'] ?? $_GET['hall'] ?? "1";
|
2021-06-03 14:09:25 +02:00
|
|
|
$halls = Hall::getListHalls($_SESSION["cinema"]);
|
2021-06-03 12:53:53 +02:00
|
|
|
|
|
|
|
if($halls){
|
|
|
|
$panel ='
|
|
|
|
<div class="row">
|
|
|
|
<div class="column side"></div>
|
|
|
|
<div class="column middle">
|
|
|
|
<br>
|
|
|
|
<select id="hall_selector" class="button large">';
|
2021-06-03 14:09:25 +02:00
|
|
|
foreach(Hall::getListHalls($_SESSION["cinema"]) as $hll){
|
2021-06-03 12:53:53 +02:00
|
|
|
if($hll->getNumber() == $hall){
|
|
|
|
$panel.= '
|
|
|
|
<option data-feed="./eventos.php?hall='.$hll->getNumber().'" value="'. $hll->getNumber() .'"selected> Sala '. $hll->getNumber() .'</option> ';
|
|
|
|
}else{
|
|
|
|
$panel.= '
|
|
|
|
<option data-feed="./eventos.php?hall='.$hll->getNumber().'" value="'. $hll->getNumber() .'"> Sala '. $hll->getNumber() .'</option>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$panel.='
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
<div class="column side"></div>
|
|
|
|
</div>
|
|
|
|
<div class="row">
|
|
|
|
<div id="calendar"></div>
|
|
|
|
</div>';
|
|
|
|
}else{
|
|
|
|
$panel ='<div class="row">
|
|
|
|
<h3> No hay ninguna sala en este cine </h3>
|
|
|
|
<a href=."/?state=new_hall"> Añadir Sala </a>
|
|
|
|
</div>';
|
|
|
|
}
|
|
|
|
|
2021-05-30 23:42:30 +02:00
|
|
|
|
|
|
|
return $panel;
|
|
|
|
}
|
2021-05-17 15:29:29 +02:00
|
|
|
static function success(){
|
|
|
|
$panel = '<div class="code info">
|
|
|
|
<h1>Operacion completada.</h1>
|
|
|
|
<hr />
|
|
|
|
<p>'.$_SESSION['msg'].'</p>
|
|
|
|
</div>'."\n";
|
|
|
|
$_SESSION['msg'] = "";
|
|
|
|
|
|
|
|
return $panel;
|
|
|
|
}
|
|
|
|
|
2021-06-03 14:09:25 +02:00
|
|
|
static function manage_halls(){
|
2021-05-17 15:29:29 +02:00
|
|
|
|
|
|
|
$panel = '<div class="column side"></div>
|
|
|
|
<div class="column middle">';
|
2021-06-03 14:09:25 +02:00
|
|
|
$listhall = Hall::getListHalls($_SESSION["cinema"]);
|
2021-05-17 15:29:29 +02:00
|
|
|
if(!$listhall){
|
|
|
|
$panel .= "<h2> No hay ninguna sala en este cine";
|
|
|
|
}else{
|
|
|
|
$panel .= '
|
2021-05-27 20:41:45 +02:00
|
|
|
<ul class="tablelist col3">
|
|
|
|
<li class="title"> Sala </li>
|
2021-05-27 14:18:25 +02:00
|
|
|
<li class="title"> Asientos </li>
|
2021-05-27 20:41:45 +02:00
|
|
|
<li class="title"> Sesión </li>
|
2021-05-25 00:51:11 +02:00
|
|
|
';
|
2021-05-27 14:18:25 +02:00
|
|
|
$parity = "odd";
|
2021-05-17 15:29:29 +02:00
|
|
|
foreach($listhall as $hall){
|
2021-05-27 20:41:45 +02:00
|
|
|
$panel .='<div class="'.$parity.'">
|
|
|
|
<a class="h2long" href="?state=edit_hall&number='. $hall->getNumber().'">
|
2021-05-27 14:18:25 +02:00
|
|
|
<li> '. $hall->getNumber().'</li>
|
|
|
|
<li> '.$hall->getTotalSeats().' </li>
|
|
|
|
</a>
|
2021-06-03 14:09:25 +02:00
|
|
|
<a href="?state=calendar&hall='. $hall->getNumber().'">
|
2021-05-27 20:41:45 +02:00
|
|
|
<li> Sesiones </li>
|
2021-05-27 14:18:25 +02:00
|
|
|
</a>
|
|
|
|
</div>
|
2021-05-25 00:51:11 +02:00
|
|
|
';
|
2021-05-27 14:18:25 +02:00
|
|
|
$parity = ($parity == "odd") ? "even" : "odd";
|
2021-05-17 15:29:29 +02:00
|
|
|
}
|
|
|
|
$panel.='
|
2021-05-27 20:41:45 +02:00
|
|
|
</ul>';
|
2021-05-17 15:29:29 +02:00
|
|
|
}
|
|
|
|
$panel.='
|
|
|
|
<form method="post" action="./?state=new_hall">
|
|
|
|
<input type="submit" name="new_hall" value="Añadir Sala" class="button large" />
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
<div class="column side"></div>';
|
|
|
|
return $panel;
|
|
|
|
}
|
|
|
|
|
2021-06-03 14:09:25 +02:00
|
|
|
static function new_hall(){
|
2021-05-17 15:29:29 +02:00
|
|
|
|
2021-06-03 14:09:25 +02:00
|
|
|
$formHall = new FormHall("new_hall",$_SESSION["cinema"],new Hall(null, null, null, null, null, null));
|
2021-05-17 15:29:29 +02:00
|
|
|
|
|
|
|
$panel = '<h1>Crear una sala.</h1><hr/></br>
|
|
|
|
'.$formHall->gestiona();
|
|
|
|
return $panel;
|
|
|
|
}
|
|
|
|
|
2021-06-03 14:09:25 +02:00
|
|
|
static function edit_hall(){
|
|
|
|
$hall = Hall::search_hall($_GET["number"], $_SESSION["cinema"]);
|
2021-05-25 00:51:11 +02:00
|
|
|
|
|
|
|
if($hall || isset($_POST["restart"]) || isset($_POST["filter"]) || isset($_POST["sumbit"]) ){
|
|
|
|
|
2021-06-03 14:09:25 +02:00
|
|
|
$formHall = new FormHall("edit_hall",$_SESSION["cinema"], $hall);
|
2021-05-25 00:51:11 +02:00
|
|
|
$panel = '<h1>Editar una sala.</h1><hr/></br>
|
|
|
|
'.$formHall->gestiona();
|
|
|
|
return $panel;
|
|
|
|
} else{
|
2021-06-03 14:09:25 +02:00
|
|
|
return Manager_panel::warning();
|
2021-05-25 00:51:11 +02:00
|
|
|
}
|
2021-05-17 15:29:29 +02:00
|
|
|
}
|
|
|
|
|
2021-06-03 14:09:25 +02:00
|
|
|
static function manage_sessions(){
|
2021-05-17 15:29:29 +02:00
|
|
|
//Base filtering values
|
2021-05-25 00:51:11 +02:00
|
|
|
$date = $_POST['date'] ?? $_GET['date'] ?? date("Y-m-d");
|
|
|
|
$hall = $_POST['hall'] ?? $_GET['hall'] ?? "1";
|
2021-05-17 15:29:29 +02:00
|
|
|
|
|
|
|
//Session filter
|
|
|
|
$panel='<div class = "column left">
|
|
|
|
<form method="post" id="filter" action="./?state=manage_sessions">
|
|
|
|
<input type="date" name="date" value="'.$date.'" min="2021-01-01" max="2031-12-31">
|
|
|
|
<select name="hall" class="button large">';
|
|
|
|
|
2021-06-03 14:09:25 +02:00
|
|
|
foreach(Hall::getListHalls($_SESSION["cinema"]) as $hll){
|
2021-05-17 15:29:29 +02:00
|
|
|
if($hll->getNumber() == $hall){
|
|
|
|
$panel.= '
|
|
|
|
<option value="'. $hll->getNumber() .'"selected> Sala '. $hll->getNumber() .'</option> ';
|
|
|
|
}else{
|
|
|
|
$panel.= '
|
|
|
|
<option value="'. $hll->getNumber() .'"> Sala '. $hll->getNumber() .'</option>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$panel.='
|
|
|
|
</select>
|
|
|
|
<input type="submit" name="filter" value="Filtrar" class="button large"/>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
';
|
|
|
|
//Session list
|
|
|
|
$panel .=' <div class = "column right">';
|
2021-06-03 14:09:25 +02:00
|
|
|
$sessions = Session::getListSessions($hall,$_SESSION["cinema"],$date);
|
2021-05-17 15:29:29 +02:00
|
|
|
|
|
|
|
if($sessions) {
|
|
|
|
$panel .='
|
|
|
|
<form method="post" action="./?state=edit_session">
|
|
|
|
<table class="alt">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Hora</th>
|
|
|
|
<th>Pelicula</th>
|
|
|
|
<th>Formato</th>
|
|
|
|
<th>Precio</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>';
|
|
|
|
|
|
|
|
|
|
|
|
foreach($sessions as $session){
|
2021-05-20 11:45:16 +02:00
|
|
|
$film = Session::getThisSessionFilm($session->getIdfilm());
|
2021-05-17 15:29:29 +02:00
|
|
|
$panel .='
|
|
|
|
<tr>
|
|
|
|
<td> '.date("H:i", strtotime( $session->getStartTime())).' </td>
|
2021-05-20 11:45:16 +02:00
|
|
|
<td> '. str_replace('_', ' ', $film["tittle"]) .' </td>
|
2021-05-17 15:29:29 +02:00
|
|
|
<td> '.$session->getFormat().' </td>
|
|
|
|
<td> '.$session->getSeatPrice().' </td>
|
|
|
|
<form method="post" action="./?state=edit_session">
|
|
|
|
<input name="film" type="hidden" value="'.$session->getIdfilm().'">
|
2021-05-20 11:45:16 +02:00
|
|
|
<input name="tittle" type="hidden" value="'.$film["tittle"].'">
|
|
|
|
<input name="duration" type="hidden" value="'.$film["duration"].'">
|
|
|
|
<input name="language" type="hidden" value="'.$film["language"].'">
|
|
|
|
<input name="description" type="hidden" value="'.$film["description"].'">
|
2021-05-17 15:29:29 +02:00
|
|
|
<input name="hall" type="hidden" value="'.$session->getIdhall().'">
|
|
|
|
<input name="date" type="hidden" value="'.$session->getDate().'">
|
|
|
|
<input name="start" type="hidden" value="'.$session->getStartTime().'">
|
|
|
|
<input name="price" type="hidden" value="'.$session->getSeatPrice().'">
|
|
|
|
<input name="format" type="hidden" value="'.$session->getFormat().'">
|
|
|
|
<td> <input type="submit" id="submit" name ="edit_session" value="Editar" class="primary" /> </td>
|
|
|
|
</form>
|
|
|
|
</tr>';
|
|
|
|
}
|
|
|
|
$panel.='
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</form>';
|
|
|
|
} else {
|
|
|
|
$panel.=' <h3> No hay ninguna sesion </h3>';
|
|
|
|
}
|
|
|
|
$panel.='
|
|
|
|
<input type="submit" name="new_session" form="filter" value="Añadir" class="button large" formaction="./?state=new_session">
|
|
|
|
</div>';
|
|
|
|
|
|
|
|
return $panel;
|
|
|
|
}
|
|
|
|
|
2021-06-03 14:09:25 +02:00
|
|
|
static function new_session(){
|
|
|
|
$formSession = new FormSession("new_session", $_SESSION["cinema"] );
|
2021-05-17 15:29:29 +02:00
|
|
|
|
|
|
|
$panel = '<h1>Crear una sesion.</h1> <hr/> </br>
|
|
|
|
'.$formSession->gestiona();
|
|
|
|
return $panel;
|
|
|
|
}
|
|
|
|
|
2021-06-03 14:09:25 +02:00
|
|
|
static function edit_session(){
|
|
|
|
$formSession = new FormSession("edit_session", $_SESSION["cinema"] );
|
2021-05-17 15:29:29 +02:00
|
|
|
|
|
|
|
$panel = '<h1>Editar una sesion.</h1><hr/></br>
|
|
|
|
'.$formSession->gestiona();
|
|
|
|
return $panel;
|
|
|
|
}
|
|
|
|
|
|
|
|
//TODO: estado al modificar sesiones para la seleccion de peliculas usando el template->print films
|
2021-06-03 14:09:25 +02:00
|
|
|
static function select_film($template){
|
2021-05-20 11:45:16 +02:00
|
|
|
if(isset($_POST["select_film"]) && isset($_POST["option"])){
|
|
|
|
$_SESSION["option"] = $_POST["option"];
|
2021-05-17 15:29:29 +02:00
|
|
|
$panel = '<h1>Seleccionar Pelicula.</h1><hr /></br>';
|
|
|
|
$panel .= $template->print_fimls();
|
|
|
|
$_SESSION["option"] = "";
|
2021-06-03 14:09:25 +02:00
|
|
|
} else $panel = self::warning();
|
2021-05-17 15:29:29 +02:00
|
|
|
|
|
|
|
return $panel;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Funcion que se envia cuando hay inconsistencia en el panel manager, principalmente por tocar cosas con la ulr
|
2021-06-03 14:09:25 +02:00
|
|
|
static function warning(){
|
2021-05-17 15:29:29 +02:00
|
|
|
$panel = '<div class="code info">
|
2021-05-25 00:51:11 +02:00
|
|
|
<h1>Ha habido un error.</h1>
|
2021-05-17 15:29:29 +02:00
|
|
|
<hr />
|
2021-05-20 11:45:16 +02:00
|
|
|
<p> >.< </p>
|
2021-05-17 15:29:29 +02:00
|
|
|
</div>'."\n";
|
|
|
|
|
|
|
|
return $panel;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2021-05-27 14:28:17 +02:00
|
|
|
?>
|