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,24 +19,18 @@ 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"];
$start = $_GET["start"];
$end = $_GET["end"];
// 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]))/")));
$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) { if ($start) {
$result = Event::searchEventsBetween2dates($start, $end, $hall,$cinema);
$startDateTime = $start . ' 00:00:00';
$endDateTime = $end;
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);
} }
// Generamos un array de eventos en formato JSON // Generamos un array de eventos en formato JSON
@ -44,12 +38,12 @@ switch($_SERVER['REQUEST_METHOD']) {
http_response_code(200); // 200 OK http_response_code(200); // 200 OK
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"} ?? "";
@ -144,7 +139,7 @@ switch($_SERVER['REQUEST_METHOD']) {
$format = $dictionary->{"format"} ?? ""; $format = $dictionary->{"format"} ?? "";
$new_date = $dictionary->{"newDate"} ?? ""; $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); $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) if(strcmp($msg,$correct_response)!== 0)
@ -159,7 +154,8 @@ switch($_SERVER['REQUEST_METHOD']) {
$startDate = $dictionary->{"startDate"} ?? ""; $startDate = $dictionary->{"startDate"} ?? "";
$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"} ?? "";
@ -191,7 +187,8 @@ switch($_SERVER['REQUEST_METHOD']) {
if (!is_numeric($idfilm) && $idfilm <= 0 ) if (!is_numeric($idfilm) && $idfilm <= 0 )
$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)
@ -207,7 +204,7 @@ switch($_SERVER['REQUEST_METHOD']) {
$data['success'] = true; $data['success'] = true;
} }
} }
echo json_encode($data); echo json_encode($data);
break; break;
//Delete a session //Delete a session

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){
$panel =' if($halls){
<div class="row"> $panel ='
<div class="column side"></div> <div class="row">
<div class="column middle"> <div class="column side"></div>
<br> <div class="column middle">
<select id="hall_selector" class="button large">'; <br>
foreach(Hall::getListHalls($_SESSION["cinema"]) as $hll){ <select id="hall_selector" class="button large">';
if($hll->getNumber() == $hall){ foreach(Hall::getListHalls($_SESSION["cinema"]) as $hll){
$panel.= ' if($hll->getNumber() == $hall){
<option data-feed="./eventsProcess.php?hall='.$hll->getNumber().'" value="'. $hll->getNumber() .'"selected> Sala '. $hll->getNumber() .'</option> '; $panel.= '
}else{ <option data-feed="./eventsProcess.php?hall='.$hll->getNumber().'" value="'. $hll->getNumber() .'"selected> Sala '. $hll->getNumber() .'</option> ';
$panel.= ' }else{
<option data-feed="./eventsProcess.php?hall='.$hll->getNumber().'" value="'. $hll->getNumber() .'"> Sala '. $hll->getNumber() .'</option>'; $panel.= '
<option data-feed="./eventsProcess.php?hall='.$hll->getNumber().'" value="'. $hll->getNumber() .'"> Sala '. $hll->getNumber() .'</option>';
}
} }
} $panel.='
$panel.=' </select>
</select> </div>
</div> <div class="column side"></div>
<div class="column side"></div> </div>
</div> <div class="row fc-container">
<div class="row fc-container"> <div id="calendar"></div>
<div id="calendar"></div> <div id="myModal" class="modal">
<div id="myModal" class="modal">
<div class="modal-content"> <div class="modal-content">
<span class="close">&times;</span> <br> <br> <span class="close">&times;</span> <br> <br>
'.SessionForm::getForm().' '.SessionForm::getForm().'
</div>
</div> </div>
</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"; $parity = "odd";
foreach($listhall as $hall){ foreach($listhall as $hall){
$panel .='<div class="'.$parity.'"> $panel .='<div class="'.$parity.'">
<a class="h2long" href="?state=edit_hall&number='. $hall->getNumber().'"> <a class="h2long" href="?state=edit_hall&number='. $hall->getNumber().'">
<li> '. $hall->getNumber().'</li> <li> '. $hall->getNumber().'</li>
<li> '.$hall->getTotalSeats().' </li> <li> '.$hall->getTotalSeats().' </li>
</a> </a>
<a href="?state=manage_sessions&hall='. $hall->getNumber().'"> <a href="?state=manage_sessions&hall='. $hall->getNumber().'">
<li> Sesiones </li> <li> Sesiones </li>
</a> </a>
</div> </div>
'; ';
$parity = ($parity == "odd") ? "even" : "odd"; $parity = ($parity == "odd") ? "even" : "odd";
}
$panel.='
</ul>';
} }
$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;
} }