Add files via upload

This commit is contained in:
Markines16 2021-06-07 23:16:42 +02:00 committed by GitHub
parent d78ef81c3e
commit 8162f84100
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 107 additions and 94 deletions

View File

@ -19,21 +19,15 @@ foreach ($acceptedContentTypes as $acceptedContentType) {
switch($_SERVER['REQUEST_METHOD']) { switch($_SERVER['REQUEST_METHOD']) {
// Get Events // Get Events
case 'GET': case 'GET':
error_log("GET");
$hall = $_GET["hall"]; $hall = $_GET["hall"];
$cinema = $_SESSION["cinema"]; $cinema = $_SESSION["cinema"];
// Comprobamos si es una lista de eventos entre dos fechas -> eventos.php?start=XXXXX&end=YYYYY $start = $_GET["start"];
$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]))/"))); $end = $_GET["end"];
$end = filter_input(INPUT_GET, 'end', FILTER_VALIDATE_REGEXP, array("options" => array("default" => null, "regexp"=>"/\d{4}-((0[1-9])|(1[0-2]))-((0[1-9])|([1-2][0-9])|(3[0-1]))/")));
if ($start) {
$startDateTime = $start . ' 00:00:00'; if ($start) {
$endDateTime = $end; $result = Event::searchEventsBetween2dates($start, $end, $hall,$cinema);
if ($end) {
$endDateTime = $end. ' 00:00:00';
}
$result = Event::searchEventsBetween2dates($startDateTime, $endDateTime, $hall,$cinema);
} else { } else {
// Comprobamos si es una lista de eventos completa // Comprobamos si es una lista de eventos completa
$result = Event::searchAllEvents($hall,$cinema); $result = Event::searchAllEvents($hall,$cinema);
@ -45,11 +39,11 @@ switch($_SERVER['REQUEST_METHOD']) {
header('Content-Type: application/json; charset=utf-8'); header('Content-Type: application/json; charset=utf-8');
header('Content-Length: ' . mb_strlen($json));; header('Content-Length: ' . mb_strlen($json));;
echo $json; echo $json;
break; break;
// Add Session // Add Session
case 'POST': case 'POST':
error_log("POST");
$errors = []; $errors = [];
$data = []; $data = [];
@ -136,6 +130,7 @@ switch($_SERVER['REQUEST_METHOD']) {
//Check if the user is droping an event in a new date //Check if the user is droping an event in a new date
if(isset($_GET["drop"]) && $_GET["drop"]){ if(isset($_GET["drop"]) && $_GET["drop"]){
$or_hall = $dictionary->{"idhall"} ?? ""; $or_hall = $dictionary->{"idhall"} ?? "";
$or_date = $dictionary->{"startDate"} ?? ""; $or_date = $dictionary->{"startDate"} ?? "";
$or_start = $dictionary->{"startHour"} ?? ""; $or_start = $dictionary->{"startHour"} ?? "";
@ -160,6 +155,7 @@ switch($_SERVER['REQUEST_METHOD']) {
$endDate = $dictionary->{"endDate"} ?? ""; $endDate = $dictionary->{"endDate"} ?? "";
$startHour = $dictionary->{"startHour"} ?? ""; $startHour = $dictionary->{"startHour"} ?? "";
$idfilm = $dictionary->{"idFilm"} ?? ""; $idfilm = $dictionary->{"idFilm"} ?? "";
$or_hall = $dictionary->{"og_hall"} ?? ""; $or_hall = $dictionary->{"og_hall"} ?? "";
@ -192,6 +188,7 @@ switch($_SERVER['REQUEST_METHOD']) {
$errors['idfilm'] = 'No se ha seleccionado una pelicula.'; $errors['idfilm'] = 'No se ha seleccionado una pelicula.';
if(empty($errors)){ if(empty($errors)){
$msg = Session::edit_session($_SESSION["cinema"], $or_hall, $or_date, $or_start, $hall, $startHour, $startDate, $idfilm, $price, $format); $msg = Session::edit_session($_SESSION["cinema"], $or_hall, $or_date, $or_start, $hall, $startHour, $startDate, $idfilm, $price, $format);
if(strcmp($msg,$correct_response)!== 0) if(strcmp($msg,$correct_response)!== 0)

View File

@ -66,12 +66,11 @@ class SessionForm {
<div class="img_desc"> <div class="img_desc">
<div class="image"> <img src="../img/films/iron_man.jpg" alt="iron man" id="film_img" /> </div> <div class="image"> <img src="../img/films/iron_man.jpg" alt="iron man" id="film_img" /> </div>
<div class="blockquote"> <div class="blockquote">
<p id="film_desc">"Un empresario millonario construye un traje blindado y lo usa para combatir el crimen y el terrorismo."</p> <li id="film_dur"> Duración: duracion minutos</li>
<li id="film_lan"> Lenguaje: idioma </li>
</div> </div>
</div> </div>
<li id="film_dur"> Duración: duracion minutos</li> </div>
<li id="film_lan"> Lenguaje: idioma </li>
</div>
<button type="button" class="button large" id="return"> Cambiar pelicula </button> <button type="button" class="button large" id="return"> Cambiar pelicula </button>
</div> </div>
<div class="film_list" id="film_list"> <div class="film_list" id="film_list">
@ -83,7 +82,6 @@ class SessionForm {
<input type="hidden" value="'.$film->getId().'" id="id'.$i.'"/> <input type="hidden" value="'.$film->getId().'" id="id'.$i.'"/>
<input type="hidden" value="'.$film->getImg().'" id="img'.$i.'"/> <input type="hidden" value="'.$film->getImg().'" id="img'.$i.'"/>
<input type="hidden" value="'.$film->getLanguage().'" id="lan'.$i.'"/> <input type="hidden" value="'.$film->getLanguage().'" id="lan'.$i.'"/>
<input type="hidden" value="'.$film->getDescription().'" id="desc'.$i.'"/>
<li value="'.$film->getTittle().'"id="title'.$i.'"> '. str_replace('_', ' ',$film->getTittle()).'</li> <li value="'.$film->getTittle().'"id="title'.$i.'"> '. str_replace('_', ' ',$film->getTittle()).'</li>
<li id="dur'.$i.'"> '.$film->getDuration().' min</li> <li id="dur'.$i.'"> '.$film->getDuration().' min</li>
<li> <button type="button" class="film_button" id="'.$i.'"> Seleccionar </button> </li> <li> <button type="button" class="film_button" id="'.$i.'"> Seleccionar </button> </li>

View File

@ -85,47 +85,57 @@
} }
//Manage the sessions using full calendar js events and a pop up form which is constantly edited with more js //Manage the sessions using full calendar js events and a pop up form which is constantly edited with more js
static function calendar(){ static function calendar(){
$hall = $_POST['hall'] ?? $_GET['hall'] ?? "1"; if(isset($_SESSION["cinema"])){
$halls = Hall::getListHalls($_SESSION["cinema"]); $hall = $_POST['hall'] ?? $_GET['hall'] ?? "1";
$halls = Hall::getListHalls($_SESSION["cinema"]);
if($halls){ if($halls){
$panel =' $panel ='
<div class="row"> <div class="row">
<div class="column side"></div> <div class="column side"></div>
<div class="column middle"> <div class="column middle">
<br> <br>
<select id="hall_selector" class="button large">'; <select id="hall_selector" class="button large">';
foreach(Hall::getListHalls($_SESSION["cinema"]) as $hll){ foreach(Hall::getListHalls($_SESSION["cinema"]) as $hll){
if($hll->getNumber() == $hall){ if($hll->getNumber() == $hall){
$panel.= ' $panel.= '
<option data-feed="./eventsProcess.php?hall='.$hll->getNumber().'" value="'. $hll->getNumber() .'"selected> Sala '. $hll->getNumber() .'</option> '; <option data-feed="./eventsProcess.php?hall='.$hll->getNumber().'" value="'. $hll->getNumber() .'"selected> Sala '. $hll->getNumber() .'</option> ';
}else{ }else{
$panel.= ' $panel.= '
<option data-feed="./eventsProcess.php?hall='.$hll->getNumber().'" value="'. $hll->getNumber() .'"> Sala '. $hll->getNumber() .'</option>'; <option data-feed="./eventsProcess.php?hall='.$hll->getNumber().'" value="'. $hll->getNumber() .'"> Sala '. $hll->getNumber() .'</option>';
}
} }
} $panel.='
$panel.=' </select>
</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>
</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{ }else{
$panel ='<div class="row"> $panel = '<div class="code info">
<h3> No hay ninguna sala en este cine </h3> <h1>Aun no se ha seleccionado un cine.</h1>
<a href=."/?state=new_hall"> Añadir Sala </a> <hr />
</div>'; <p> >.< </p>
<p> Selecciona un cine en el panel principal </p>
</div>'."\n";
} }
return $panel; return $panel;
} }
static function success(){ static function success(){
@ -140,42 +150,50 @@
} }
static function manage_halls(){ static function manage_halls(){
if(isset($_SESSION["cinema"])){
$panel = '<div class="column side"></div> $panel = '<div class="column side"></div>
<div class="column middle">'; <div class="column middle">';
$listhall = Hall::getListHalls($_SESSION["cinema"]); $listhall = Hall::getListHalls($_SESSION["cinema"]);
if(!$listhall){ if(!$listhall){
$panel .= "<h2> No hay ninguna sala en este cine"; $panel .= "<h2> No hay ninguna sala en este cine";
}else{ }else{
$panel .= ' $panel .= '
<ul class="tablelist col3"> <ul class="tablelist col3">
<li class="title"> Sala </li> <li class="title"> Sala </li>
<li class="title"> Asientos </li> <li class="title"> Asientos </li>
<li class="title"> Sesión </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 = "odd"; $parity = ($parity == "odd") ? "even" : "odd";
foreach($listhall as $hall){ }
$panel .='<div class="'.$parity.'"> $panel.='
<a class="h2long" href="?state=edit_hall&number='. $hall->getNumber().'"> </ul>';
<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.=' $panel.='
</ul>'; <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";
} }
$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; return $panel;
} }