Delete panel_manager directory

This commit is contained in:
Fernando Méndez 2021-07-02 17:54:39 +02:00 committed by GitHub
parent f1895fd4f6
commit e1fe17d695
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 0 additions and 969 deletions

View File

@ -1,258 +0,0 @@
<?php
require_once('../assets/php/config.php');
include_once($prefix.'assets/php/includes/event.php');
include_once($prefix.'assets/php/includes/session.php');
$contentType= $_SERVER['CONTENT_TYPE'] ?? 'application/json';
$contentType = strtolower(str_replace(' ', '', $contentType));
// Verify the content type is supported
$acceptedContentTypes = array('application/json;charset=utf-8', 'application/json');
$found = false;
foreach ($acceptedContentTypes as $acceptedContentType) {
if (substr($contentType, 0, strlen($acceptedContentType)) === $acceptedContentType) {
$found=true;
break;
}
}
switch($_SERVER['REQUEST_METHOD']) {
// Get Events
case 'GET':
$hall = $_GET["hall"];
$cinema = $_SESSION["cinema"];
$start = $_GET["start"];
$end = $_GET["end"];
if ($start) {
$result = Event::searchEventsBetween2dates($start, $end, $hall,$cinema);
} else {
// Comprobamos si es una lista de eventos completa
$result = Event::searchAllEvents($hall,$cinema);
}
// Generamos un array de eventos en formato JSON
$json = json_encode($result, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
http_response_code(200); // 200 OK
header('Content-Type: application/json; charset=utf-8');
header('Content-Length: ' . mb_strlen($json));;
echo $json;
break;
// Add Session
case 'POST':
$errors = [];
$data = [];
//Correct reply to verify the session has been correctly added
$correct_response = 'Operación completada';
//Check if the body is ok
$entityBody = file_get_contents('php://input');
$dictionary = json_decode($entityBody);
if (!is_object($dictionary))
$errors['global'] = 'El cuerpo de la petición no es valido';
$price = $dictionary->{"price"} ?? "";
$format = $dictionary->{"format"} ?? "";
$hall = $dictionary->{"hall"} ?? "";
$startDate = $dictionary->{"startDate"} ?? "";
$endDate = $dictionary->{"endDate"} ?? "";
$startHour = $dictionary->{"startHour"} ?? "";
$idfilm = $dictionary->{"idFilm"} ?? "";
//Check errors in inputs
if (empty($price) || $price <= 0 )
$errors['price'] = 'El precio no puede ser 0.';
if (empty($format))
$errors['format'] = 'El formato no puede estar vacio. Ej: 3D, 2D, voz original';
if (empty($hall) || $hall<=0 )
$errors['hall'] = 'La sala no puede ser 0 o menor';
if (empty($startDate))
$errors['startDate'] = 'Las sesiones tienen que empezar algun dia.';
else if (empty($endDate))
$errors['endDate'] = 'Las sesiones tienen que teminar algun dia.';
else {
$start = strtotime($startDate);
$end = strtotime($endDate);
$start = date('Y-m-d', $start);
$end = date('Y-m-d', $end);
if($start > $end)
$errors['date'] = 'La fecha inicial no puede ser antes o el mismo dia que la final.';
}
if (empty($startHour))
$errors['startHour'] = 'Es necesario escoger el horario de la sesion.';
if (!is_numeric($idfilm) && $idfilm <= 0 )
$errors['idfilm'] = 'No se ha seleccionado una pelicula.';
//Create as many sessions as the diference between start and end date tell us. 1 session per day
while($startDate < $endDate && empty($errors)){
$msg = Session::create_session($_SESSION["cinema"], $hall, $startHour, $startDate, $idfilm, $price, $format);
if(strcmp($msg,$correct_response)!== 0)
$errors['global'] = $msg;
else
$data['message'] = $msg;
$startDate = date('Y-m-d H:i:s', strtotime( $startDate . ' +1 day'));
}
if (!empty($errors)) {
$data['success'] = false;
$data['errors'] = $errors;
} else {
$data['success'] = true;
}
echo json_encode($data);
break;
//Edit session
case 'PUT':
//Correct reply to verify the session has been correctly edited
$correct_response = 'Se ha editado la session con exito';
$errors = [];
$data = [];
//Check if the body is ok
$entityBody = file_get_contents('php://input');
$dictionary = json_decode($entityBody);
if (!is_object($dictionary))
$errors['global'] = 'El cuerpo de la petición no es valido';
//Check if the user is droping an event in a new date
if(isset($_GET["drop"]) && $_GET["drop"]){
$or_hall = $dictionary->{"idhall"} ?? "";
$or_date = $dictionary->{"startDate"} ?? "";
$or_start = $dictionary->{"startHour"} ?? "";
$price = $dictionary->{"price"} ?? "";
$idfilm = $dictionary->{"idfilm"} ?? "";
$format = $dictionary->{"format"} ?? "";
$new_date = $dictionary->{"newDate"} ?? "";
$msg = Session::edit_session($_SESSION["cinema"], $or_hall, $or_date, $or_start, $or_hall, $new_date, $new_date, $idfilm, $price, $format);
if(strcmp($msg,$correct_response)!== 0)
http_response_code(400);
else
http_response_code(200);
}else{
//Edit session from a form
$price = $dictionary->{"price"} ?? "";
$format = $dictionary->{"format"} ?? "";
$hall = $dictionary->{"hall"} ?? "";
$startDate = $dictionary->{"startDate"} ?? "";
$endDate = $dictionary->{"endDate"} ?? "";
$startHour = $dictionary->{"startHour"} ?? "";
$idfilm = $dictionary->{"idFilm"} ?? "";
$or_hall = $dictionary->{"og_hall"} ?? "";
$or_date = $dictionary->{"og_date"} ?? "";
$or_start = $dictionary->{"og_start"} ?? "";
//Check errors in inputs
if (empty($price) || $price <= 0 )
$errors['price'] = 'El precio no puede ser 0.';
if (empty($format))
$errors['format'] = 'El formato no puede estar vacio. Ej: 3D, 2D, voz original';
if (empty($hall) || $hall<=0 )
$errors['hall'] = 'La sala no puede ser 0 o menor';
if (empty($startDate))
$errors['startDate'] = 'Las sesiones tienen que empezar algun dia.';
else if (empty($endDate))
$errors['endDate'] = 'Las sesiones tienen que teminar algun dia.';
else {
$start = strtotime($startDate);
$end = strtotime($endDate);
$start = date('Y-m-d', $start);
$end = date('Y-m-d', $end);
if($start > $end)
$errors['date'] = 'La fecha inicial no puede ser antes o el mismo dia que la final.';
}
if (empty($startHour))
$errors['startHour'] = 'Es necesario escoger el horario de la sesion.';
if (!is_numeric($idfilm) && $idfilm <= 0 )
$errors['idfilm'] = 'No se ha seleccionado una pelicula.';
if(empty($errors)){
$msg = Session::edit_session($_SESSION["cinema"], $or_hall, $or_date, $or_start, $hall, $startHour, $startDate, $idfilm, $price, $format);
if(strcmp($msg,$correct_response)!== 0)
$errors['global'] = $msg;
else
$data['message'] = $msg;
}
if (!empty($errors)) {
$data['success'] = false;
$data['errors'] = $errors;
} else {
$data['success'] = true;
}
}
echo json_encode($data);
break;
//Delete a session
case 'DELETE':
$errors = [];
$data = [];
//Correct reply to verify the session has been correctly edited
$correct_response = 'Se ha eliminado la session con exito';
//Check if the body is ok
$entityBody = file_get_contents('php://input');
$dictionary = json_decode($entityBody);
if (!is_object($dictionary))
$errors['global'] = 'El cuerpo de la petición no es valido';
$or_hall = $dictionary->{"og_hall"} ?? "";
$or_date = $dictionary->{"og_date"} ?? "";
$or_start = $dictionary->{"og_start"} ?? "";
//Check errors in inputs
if(empty($or_hall))
$errors['global'] = 'El nº de sala a borrar no existe';
if(empty($or_date))
$errors['global'] = 'La fecha de donde borrar no existe';
if(empty($or_start))
$errors['global'] = 'La hora de donde borrar no existe';
if(empty($errors)){
$msg = Session::delete_session($_SESSION["cinema"], $or_hall, $or_start, $or_date);
if(strcmp($msg,$correct_response)!== 0)
$errors['global'] = $msg;
else
$data['message'] = $msg;
}
if (!empty($errors)) {
$data['success'] = false;
$data['errors'] = $errors;
} else {
$data['success'] = true;
}
echo json_encode($data);
break;
default:
break;
}

View File

@ -1,103 +0,0 @@
<?php
require_once($prefix.'assets/php/includes/film_dao.php');
class SessionForm {
public static function getForm(){
$films = new Film_DAO("complucine");
$filmslist = $films->allFilmData();
$form='
<div id="operation_msg" class="operation_msg"> </div>
<form id="session_form" name="session_form" action="eventos.php" method="POST">
<input type="hidden" id="film_id" name="film_id" value=""/>
<input type="hidden" id="original_hall" name="film_id" value=""/>
<input type="hidden" id="original_date" name="film_id" value=""/>
<input type="hidden" id="original_start_time" name="film_id" value=""/>
<div id="global_group" class="form_group"></div>
<fieldset>
<legend>Datos</legend>
<div id="price_group" class="form_group">
<input type="number" step="0.01" id="price" name="price" value="" min="0" placeholder="Precio de la entrada" /> <br>
</div>
<div id="format_group" class="form_group">
<input type="text" id="format" name="format" value="" placeholder="Formato de pelicula" /> <br>
</div>
<div id="hall_group" class="form_group">
<select id="hall" name="hall" class="button large">>';
foreach(Hall::getListHalls($_SESSION["cinema"]) as $hll){
$form.= '
<option value="'. $hll->getNumber() .'"> Sala '. $hll->getNumber() .'</option>';
}
$form.=' </select>
</div>
</fieldset>
<fieldset>
<legend>Horario</legend>
<div id="date_group" class="form_group">
<div class="two-inputs-line">
<label> Fecha inicio </label>
<label> Fecha final </label>
<input type="date" id="startDate" name="startDate" value=""/>
<input type="date" id="endDate" name="endDate" value=""/>
</div>
</div>
<div id="hour_group" class="form_group">
<div class="one-input-line">
<label> Hora sesion </label>
<input type="time" id="startHour" name="startHour" value=""/>
</div>
</div>
</fieldset>
<input type="reset" id="reset" value="Limpiar Campos" >
<input type="submit" id="sumbit_new" name="sumbit_new" class="sumbit" value="Añadir" />
<div class="two-inputs-line" id="edit_inputs">
<input type="submit" id="sumbit_edit" name="sumbit_edit" class="sumbit" value="Editar" />
<input type="submit" id="submit_del" name="submit_del" class="black button" value="Borrar" />
</div>
<div id="film_msg_group" class="form_group"> </div>
<div id="film_group" class="form_group">
<div class="code showtimes">
<h2 id="film_title"> titulo </h2>
<hr />
<div class="img_desc">
<div class="image"> <img src="../img/films/iron_man.jpg" alt="iron man" id="film_img" /> </div>
<div class="blockquote">
<li id="film_dur"> Duración: duracion minutos</li>
<li id="film_lan"> Lenguaje: idioma </li>
</div>
</div>
</div>
<button type="button" class="button large" id="return"> Cambiar pelicula </button>
</div>
<div class="film_list" id="film_list">
<ul class="tablelist col3">';
$parity = "odd";
$i = 0;
foreach($filmslist as $film){
$form .='<div class="'.$parity.'">
<input type="hidden" value="'.$film->getId().'" id="id'.$i.'"/>
<input type="hidden" value="'.$film->getImg().'" id="img'.$i.'"/>
<input type="hidden" value="'.$film->getLanguage().'" id="lan'.$i.'"/>
<li value="'.$film->getTittle().'"id="title'.$i.'"> '. str_replace('_', ' ',$film->getTittle()).'</li>
<li id="dur'.$i.'"> '.$film->getDuration().' min</li>
<li> <button type="button" class="film_button" id="'.$i.'"> Seleccionar </button> </li>
</div>
';
$parity = ($parity == "odd") ? "even" : "odd";
$i++;
}
$form.='
</ul>
</div>
</form>
';
return $form;
}
}
?>

View File

@ -1,226 +0,0 @@
<?php
include_once($prefix.'assets/php/includes/hall.php');
include_once($prefix.'assets/php/includes/seat.php');
include_once($prefix.'assets/php/form.php');
class FormHall extends Form {
private $option;
private $cinema;
private $og_hall;
//Constructor:
public function __construct($option, $cinema, $hall) {
$this->option = $option;
$this->cinema = $cinema;
if($hall)
$this->og_hall = $hall;
if($option == "edit_hall" && $hall)
$options = array("action" => "./?state=".$option."&number=".$hall->getNumber()."&editing=true");
else
$options = array("action" => "./?state=".$option."&editing=false");
parent::__construct('formHall',$options);
}
protected function generaCamposFormulario($data, $errores = array()){
//Prepare the data
$number = $data['number'] ?? $this->og_hall->getNumber() ?? "";
$rows = $data['rows'] ?? $this->og_hall->getNumRows() ?? "12";
$cols = $data['cols'] ?? $this->og_hall->getNumCol() ?? "8";
//Init Seats_map
$seats = 0;
$seats_map = array();
for($i = 1;$i <= $rows; $i++){
for($j = 1; $j <= $cols; $j++){
$seats_map[$i][$j] = "-1";
}
}
$alltozero = $_POST["alltozero"] ?? 0;
//Show the original seats_map once u click restart or the first time u enter this form from manage_halls's form
if($this->option == "edit_hall" && !isset($_GET["editing"])){
$rows = $this->og_hall->getNumRows();
$cols = $this->og_hall->getNumCol();
$seat_list = Seat::getSeatsMap($this->og_hall->getNumber(), $this->cinema);
if($seat_list){
foreach($seat_list as $seat){
$seats_map[$seat->getNumRows()][$seat->getNumCol()] = $seat->getState();
if($seat->getState()>=0){
$seats++;
}
}
}
}//Show the checkbox seats_map updated and everything to selected if alltoone was pressed
else if(!$alltozero){
$alltoone = $_POST["alltoone"] ?? 0;
for($i = 1;$i <= $rows; $i++){
for($j = 1; $j <= $cols; $j++){
if($alltoone || isset($data["checkbox".$i.$j])) {
$seats_map[$i][$j] = $data["checkbox".$i.$j] ?? "0";
$seats++;
if($seats_map[$i][$j] == "-1"){
$seats_map[$i][$j] = "0";
}
}else
$seats_map[$i][$j] = "-1";
}
}
}
$htmlErroresGlobales = self::generaListaErroresGlobales($errores);
$errorNumber = self::createMensajeError($errores, 'number', 'span', array('class' => 'error'));
$errorSeats = self::createMensajeError($errores, 'seats', 'span', array('class' => 'error'));
$errorRows = self::createMensajeError($errores, 'rows', 'span', array('class' => 'error'));
$errorCols = self::createMensajeError($errores, 'cols', 'span', array('class' => 'error'));
$html = '
<div class="column left">'.$htmlErroresGlobales.'
<fieldset>
<legend>Mapa de Asientos</legend>
'.$errorSeats.' '.$errorRows.' '.$errorCols.'
<label> Filas: </label> <input type="number" name="rows" min="1" id="rows" value="'.$rows.'" /> <br>
<label> Columnas: </label> <input type="number" name="cols" min="1" id="cols" value="'.$cols.'"/> <br>
<label> Asientos totales:'.$seats.' </label> <input type="hidden" name="seats" id="seats" value="'.$seats.'"readonly/> <br>
<input type="submit" name="filter" value="Actualizar mapa de la sala" class="button large" />
';
$html .='
</fieldset><br>
'.$errorNumber.'
<label> Numero de sala: </label>
<input type="number" name="number" id="number" value="'.$number.'" placeholder="Numero de la Sala" /><br>
';
if($this->option == "new_hall")
$html .='<input type="submit" id="submit" name="sumbit" value="Crear Sala" class="primary" />
';
if($this->option == "edit_hall"){
$html .='<input type="submit" id="submit" name="sumbit" value="Editar Sala" class="primary" />
<input type="submit" id="submit" name="delete" onclick="return confirm(\'Seguro que quieres borrar esta sala?\')" value="Eliminar Sala" class="black button" />
';
}
if(!$errorCols && !$errorRows){
$html .='</div>
<div class="column right">
<input type="submit" name="alltoone" value="Activar todos los asientos" class="button large" />
<input type="submit" name="alltozero" value="Desactivar todos los asientos" class="button large" />
<h3 class="table_title"> Pantalla </h3>
<table class="seat">
<thead>
<tr>
<th> </th>
';
for($j = 1; $j<=$cols; $j++){
$html .= '<th>'.$j.'</th>
';
}
$html .= '</tr>
</thead>
<tbody>';
for($i = 1;$i<=$rows;$i++){
$html .= '
<tr>
<td>'.$i.'</td>
';
for($j=1; $j<=$cols; $j++){
if($seats_map[$i][$j]>=0){
$html .= '<td> <input type="checkbox" class="check_box" name="checkbox'.$i.$j.'" value="'.$seats_map[$i][$j].'" id="checkbox'.$i.$j.'" checked> <label for="checkbox'.$i.$j.'"> </td>
';}
else {
$html .= '<td> <input type="checkbox" class="check_box" name="checkbox'.$i.$j.'" value="'.$seats_map[$i][$j].'" id="checkbox'.$i.$j.'" > <label for="checkbox'.$i.$j.'"> </td>
';}
}
$html .='</tr>';
}
$html .= '
</tbody>
</table>
</div>';
} else
$html .='</div>';
return $html;
}
//Process form:
protected function procesaFormulario($datos){
$result = array();
$rows = $datos['rows'];
$cols = $datos['cols'];
//Prepare the seat_map
$seats_map = array();
$seats = 0;
for($i = 1;$i <= $rows; $i++){
for($j = 1; $j <= $cols; $j++){
if(isset($datos["checkbox".$i.$j])){
$seats_map[$i][$j] = $datos["checkbox".$i.$j];
$seats++;
if($seats_map[$i][$j] == "-1"){
$seats_map[$i][$j] = "0";
}
}else{
$seats_map[$i][$j] = "-1";
}
}
}
//Check input errors
if ($seats == 0 && isset($datos["sumbit"]) ) {
$result['seats'] = "<li> No puede haber 0 asientos disponibles. </li> <br>";
}
if ($rows <= 0) {
$result['rows'] = "<li> No puede haber 0 o menos filas. </li> <br>";
}
if ($cols <= 0) {
$result['cols'] = "<li> No puede haber 0 o menos columnas. </li> <br>";
}
$number = $datos['number'] ?? null;
if (empty($number) && isset($datos["sumbit"])) {
$result['number'] = "<li> El numero de sala tiene que ser mayor que 0. </li> <br>";
}
else if (count($result) === 0 && isset($datos["sumbit"]) ) {
if($this->option == "new_hall"){
$msg = Hall::create_hall($number, $this->cinema, $rows, $cols, $seats, $seats_map);
FormHall::prepare_message( $msg );
}
else if($this->option == "edit_hall"){
if($this->og_hall)
$msg = Hall::edit_hall($number,$this->cinema, $rows, $cols, $seats, $seats_map, $this->og_hall->getNumber());
else
$msg = "La sala que intentas editar ya no existe";
FormHall::prepare_message( $msg );
}
}
else if (!isset($result['number']) && isset($datos["delete"]) ) {
if($this->option == "edit_hall"){
$msg = Hall::delete_hall($number, $this->cinema, $rows, $cols, $seats, $seats_map, $this->og_hall->getNumber());
FormHall::prepare_message( $msg );
}
}
return $result;
}
public static function prepare_message( $msg ){
$_SESSION['message'] = "<div class='row'>
<div class='column side'></div>
<div class='column middle'>
<div class='code info'>
<h1> Operacion Completada </h1><hr />
<p>".$msg."</p>
<a href='./index.php?state=manage_halls'><button>Cerrar Mensaje</button></a>
</div>
</div>
<div class='column side'></div>
</div>
";
}
}
?>

View File

@ -1,159 +0,0 @@
<?php
//General Config File:
require_once('../assets/php/config.php');
//Controller file:
require_once('panel_manager.php');
require_once('../assets/php/includes/manager_dao.php');
require_once('../assets/php/includes/manager.php');
require_once('../assets/php/includes/user.php');
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'];
$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'>
<div class='code info'>
<h1> ¡ATENCIÓN! </h1><hr />
<p>Está viendo la web como un Usuario NO Registrado.</p>
<a href='".$prefix."'><button>Cerrar Mensaje</button></a>
</div>
</div>
<div class='column side'></div>
</div>
";
break;
case "view_ruser":
$_SESSION["rol"] = "user";
unset($_SESSION["cinema"]);
$panel .= "<div class='row'>
<div class='column side'></div>
<div class='column middle'>
<div class='code info'>
<h1> ¡ATENCIÓN! </h1><hr />
<p>Está viendo la web como un Usuario Registrado.</p>
<a href='".$prefix."'><button>Cerrar Mensaje</button></a>
</div>
</div>
<div class='column side'></div>
</div>
";
break;
case "manage_halls":
$panel = Manager_panel::manage_halls();
break;
case "new_hall":
$panel = Manager_panel::new_hall();
break;
case "edit_hall":
$panel = Manager_panel::edit_hall();
break;
case "manage_sessions":
$panel = Manager_panel::calendar();
break;
default:
$panel = Manager_panel::welcomeAdmin($manager);
break;
}
}
else if($_SESSION["login"] && $_SESSION["rol"] === "manager"){
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'>
<div class='code info'>
<h1> ¡ATENCIÓN! </h1><hr />
<p>Está viendo la web como un Usuario NO Registrado.</p>
<a href='".$prefix."'><button>Cerrar Mensaje</button></a>
</div>
</div>
<div class='column side'></div>
</div>
";
break;
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'>
<div class='code info'>
<h1> ¡ATENCIÓN! </h1><hr />
<p>Está viendo la web como un Usuario Registrado.</p>
<a href='".$prefix."'><button>Cerrar Mensaje</button></a>
</div>
</div>
<div class='column side'></div>
</div>
";
break;
case "manage_halls":
$panel = Manager_panel::manage_halls();
break;
case "new_hall":
$panel = Manager_panel::new_hall();
break;
case "edit_hall":
$panel = Manager_panel::edit_hall();
break;
case "manage_sessions":
$panel = Manager_panel::calendar();
break;
default:
$panel = Manager_panel::welcome();
break;
}
}
else{
$panel = '<div class="column side"></div>
<div class="column middle">
<div class="code info">
<h1>Debes iniciar sesión para ver el Panel de Manager.</h1><hr />
<p>Inicia Sesión con una cuenta de Gerente.</p>
<a href="'.$prefix.'login/" ><button class="button large">Iniciar Sesión</button></a>
</div>
</div>
<div class="column side"></div>'."\n";
}
//Specific page content:
$section = '<!-- Manager Panel -->
<link rel="stylesheet" href="../assets/css/manager.css">
<section id="manager_panel">
<!-- Contents -->
<div class="row">
'.$panel.'
</div>
</section>';
//General page content:
require RAIZ_APP.'/HTMLtemplate.php';
?>

View File

@ -1,223 +0,0 @@
<?php
include_once($prefix.'assets/php/includes/hall.php');
include_once($prefix.'assets/php/includes/session.php');
require_once($prefix.'assets/php/includes/cinema_dao.php');
include_once('./includes/formHall.php');
include_once('./includes/SessionForm.php');
class Manager_panel {
function __construct(){}
static function welcome(){
$bd = new Cinema_DAO('complucine');
if($bd){
$cinema = $bd->cinemaData($_SESSION["cinema"]);
$c_name = $cinema->getName();
$c_dir = $cinema->getDirection();
}
$name = strtoupper($_SESSION["nombre"]);
$userPic = USER_PICS.strtolower($name).".jpg";
$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>
</div>'."\n";
return $panel;
}
// Admin welcome panel allows to change the cinema linked to the admin-like-manager
static function welcomeAdmin() {
$cinemaList = new Cinema_DAO('complucine');
$cinemas = $cinemaList->allCinemaData();
$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";
$panel= '<div class="code welcome">
<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"/>
<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>
<form method="post" id="changecinema" action="index.php">
<select name="cinema" class="button large">
';
foreach($cinemas as $c){
if($c->getId() == $cinema){
$panel .= "<option value=\"". $c->getId() ." \"selected> " . $c->getName() ."</option>
";
}else{
$panel .= "<option value=\"". $c->getId() ." \"> " . $c->getName() . "</option>
";
}
}
$panel .= ' <input type="submit" id="submit" name="changecinema" value="Cambiar" class="primary" />
</select>
</form>
</div>
<div class="column side"> </div>
';
return $panel;
}
//Manage the sessions using full calendar js events and a pop up form which is constantly edited with more js
static function calendar(){
if(isset($_SESSION["cinema"])){
$hall = $_POST['hall'] ?? $_GET['hall'] ?? "1";
$halls = Hall::getListHalls($_SESSION["cinema"]);
if($halls){
$panel ='
<div class="row">
<div class="column side"></div>
<div class="column middle">
<br>
<select id="hall_selector" class="button large">';
foreach(Hall::getListHalls($_SESSION["cinema"]) as $hll){
if($hll->getNumber() == $hall){
$panel.= '
<option data-feed="./eventsProcess.php?hall='.$hll->getNumber().'" value="'. $hll->getNumber() .'"selected> Sala '. $hll->getNumber() .'</option> ';
}else{
$panel.= '
<option data-feed="./eventsProcess.php?hall='.$hll->getNumber().'" value="'. $hll->getNumber() .'"> Sala '. $hll->getNumber() .'</option>';
}
}
$panel.='
</select>
</div>
<div class="column side"></div>
</div>
<div class="row fc-container">
<div id="calendar"></div>
<div id="myModal" class="modal">
<div class="modal-content">
<span class="close">&times;</span> <br> <br>
'.SessionForm::getForm().'
</div>
</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>';
}
}else{
$panel = '<div class="code info">
<h1>Aun no se ha seleccionado un cine.</h1>
<hr />
<p> >.< </p>
<p> Selecciona un cine en el panel principal </p>
</div>'."\n";
}
return $panel;
}
static function manage_halls(){
if(isset($_SESSION["cinema"])){
$panel = '<div class="column side"></div>
<div class="column middle">';
$listhall = Hall::getListHalls($_SESSION["cinema"]);
if(!$listhall){
$panel .= "<h2> No hay ninguna sala en este cine";
}else{
$panel .= '
<ul class="tablelist col3">
<li class="title"> Sala </li>
<li class="title"> Asientos </li>
<li class="title"> Sesión </li>
';
$parity = "odd";
foreach($listhall as $hall){
$panel .='<div class="'.$parity.'">
<a class="h2long" href="?state=edit_hall&number='. $hall->getNumber().'">
<li> '. $hall->getNumber().'</li>
<li> '.$hall->getTotalSeats().' </li>
</a>
<a href="?state=manage_sessions&hall='. $hall->getNumber().'">
<li> Sesiones </li>
</a>
</div>
';
$parity = ($parity == "odd") ? "even" : "odd";
}
$panel.='
</ul>';
}
$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>';
}else{
$panel = '<div class="code info">
<h1>Aun no se ha seleccionado un cine.</h1>
<hr />
<p> >.< </p>
<p> Selecciona un cine en el panel principal </p>
</div>'."\n";
}
return $panel;
}
static function new_hall(){
$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(){
$hall = Hall::search_hall($_GET["number"], $_SESSION["cinema"]);
if($hall || isset($_POST["restart"]) || isset($_POST["filter"]) || isset($_POST["sumbit"]) ){
$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();
}
}
//this function is used as an answer to wrong url parameters accesing a formhall edit. The formsession version has been replaced by other js error replys
static function warning(){
$panel = '<div class="code info">
<h1>Ha habido un error.</h1>
<hr />
<p> >.< </p>
</div>'."\n";
return $panel;
}
}
?>