Eliminadas las interaciones con film y film_dao

This commit is contained in:
Markines16 2021-05-07 13:48:20 +02:00 committed by GitHub
parent 2b3a0e60fd
commit fe520f1495
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 77 additions and 37 deletions

View File

@ -3,9 +3,6 @@ require_once($prefix.'assets/php/common/session_dao.php');
require_once($prefix.'assets/php/common/session.php');
require_once($prefix.'assets/php/form.php');
require_once($prefix.'assets/php/common/film.php');
require_once($prefix.'assets/php/common/film_dao.php');
//Receive data from froms and prepare the correct response
class FormSession extends Form {
@ -17,22 +14,20 @@ class FormSession extends Form {
public static function generaCampoFormulario($data, $errores = array()){
$cinema = $data['cinema'] ?? '';
$film = $data['film'] ?? '1';
$hall = $data['hall'] ?? '1';
$film = $data['film'] ?? '';
$hall = $data['hall'] ?? '';
$date = $data['date'] ?? '';
$start = $data['start'] ?? '';
$price = $data['price'] ?? '';
$format = $data['format'] ?? '';
$filmList = new Film_DAO('complucine');
$films = $filmList->allFilmData();
$htmlform .= '<div class="column left">
<form method="post" id="'.$data['option'].'" action="./includes/processForm.php"\>
<fieldset>
<legend>Datos</legend>
<input type="number" name="price" value="'.$price.'" min="0" placeholder="Precio de la entrada" required/> <br>
<input type="text" name="format" value="'.$format.'" placeholder="Formato de pelicula" required/> <br>
<input type="text" name="film" value="'.$film["idfilm"].'" placeholder="Selecciona una Pelicula" readonly/>
<select name="hall" class="button large">';
foreach(Hall::getListHalls($cinema) as $hll){
if($hll->getNumber() == $hall){
@ -55,30 +50,37 @@ class FormSession extends Form {
if($data['option'] == "new_session")
$htmlform .= '<input type="number" name="repeat" value="" min="0" title="Añadir esta sesion durante los proximos X dias" min="0" max="31" placeholder="Añadir X dias"/> <br>
<button type="submit" name="new_session" class="button large">Crear</button><br>';
if($data['option'] == "edit_session")
if($data['option'] == "edit_session"){
$_SESSION["session"] = $data['id'] ?? Session::getThisSessionId($cinema, $hall, $start, $date)["id"];
$htmlform .= '
<input name="origin_hall" type="hidden" value="'.$hall.'">
<input name="origin_date" type="hidden" value="'.$date.'">
<input name="origin_start" type="hidden" value="'.$start.'">
<button type="submit" name="edit_session" class="button large">Editar</button><br>
<button type="submit" name="delete_session" class="primary">Borrar</button><br>';
$htmlform .= '
<input type="reset" value="Limpiar Campos" >
}
$htmlform .= "
<input type='reset' value='Limpiar Campos' >
</form>
</div>
<div class="column right">
<select name="film" form="'.$data['option'].'" class="button large">';
foreach($films as $f){
if($f->getId() == $film){
$htmlform.= '
<option value="'. $f->getId() .'" selected> '.$f->getId().' | '.str_replace('_', ' ',$f->getTittle()).' Idioma: '.$f->getLanguage().' </option>';
}else {
$htmlform.= '
<option value="'. $f->getId() .'"> '.$f->getId().' | '.str_replace('_', ' ',$f->getTittle()).' Idioma: '.$f->getLanguage().' </option>';
<div class='column side'>";
if($film["tittle"]){
$htmlform .= " <section id='".$film["tittle"]."'>
<div class='code showtimes'>
<div class='image'><img src='../img/".$film["tittle"].".jpg' alt='".$film["tittle"]."' /></div>
<h2>".$film["tittle"]."</h2>
<hr />
<div class='blockquote'>
<p>".$film["description"]."</p>
</div>
<p>Duración: ".$film["duration"]." minutos</p>
</div>
</section>
";
}
}
$htmlform .= '
</select>
$htmlform .= '<a href="?state=select_film&option='.$data['option'].'" <button name="select_film" class="button large">Seleccionar una Pelicula</button></a><br>
</div>
';
return $htmlform;

View File

@ -38,6 +38,9 @@
break;
case "edit_session":
$panel = Manager_panel::edit_session();
break;
case "select_film":
$panel = Manager_panel::select_film($template);
break;
case "success":
$panel = Manager_panel::success();

View File

@ -7,11 +7,7 @@
class Manager_panel {
function __construct($panel,$log){
$this->state = $panel;
$this->login = $log;
}
function __construct(){}
static function welcome(){
$name = strtoupper($_SESSION['nombre']);
@ -134,7 +130,7 @@
$panel .='
<tr>
<td> '.date("H:i", strtotime( $session->getStartTime())).' </td>
<td> '. str_replace('_', ' ', Session::getFilmTitle($session->getIdfilm())) .' </td>
<td> '. str_replace('_', ' ', Session::getThisSessionFilm($session->getIdfilm())["tittle"]) .' </td>
<td> '.$session->getFormat().' </td>
<td> '.$session->getSeatPrice().' </td>
<td> <input type="date" name="date" value="'.$date.'">
@ -145,7 +141,7 @@
<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" name="edit" value="Editar" class="button" ></td>
<td> <input type="submit" name="edit_session" value="Editar" class="button" ></td>
</form>
</tr>';
}
@ -174,11 +170,50 @@
}
static function edit_session(){
$data = array("option" => "edit_session","hall" => $_POST["hall"],"cinema" => $_SESSION["cinema"],"date" => $_POST['date'],"film" => $_POST['film'],"start" => $_POST['start'],"price" => $_POST['price'],"format" => $_POST['format']);
if(isset($_POST["edit_session"])){
$film = Session::getThisSessionFilm($_POST["film"]);
$data = array("option" => "edit_session","hall" => $_POST["hall"],"cinema" => $_SESSION["cinema"],"date" => $_POST['date'],"film" => $film,
"start" => $_POST['start'],"price" => $_POST['price'],"format" => $_POST['format']);
}else if(isset($_SESSION["session"])){
$session = Session::getThisSessionFromId($_SESSION["session"]);
$_SESSION["session"] = "";
$film = array("idfilm" => $_POST["id"],"tittle" => $_POST["tittle"], "description" => $_POST["description"], "duration" => $_POST["duration"]);
echo $film["id"] . " y el titulo es: " . $film["tittle"];
$data = array("option" => "edit_session","hall" => $session["idhall"],"cinema" => $_SESSION["cinema"],"date" => $session["date"],"film" => $film,
"start" => $session["start_time"],"price" => $session["seat_price"],"format" => $session["format"]);
}
if($data){
$panel = '<h1>Editar una sesión.</h1><hr /></br>
'.FormSession::generaCampoFormulario($data, null);
} else $panel = self::warning();
return $panel;
}
static function select_film($template){
if(isset($_GET["option"])){
$_SESSION["option"] = $_GET["option"];
$panel = '<h1>Seleccionar Pelicula.</h1><hr /></br>';
$panel .= $template->print_fimls();
$_SESSION["option"] = "";
} else $panel = self::warning();
return $panel;
}
//Funcion que se envia cuando hay inconsistencia en el panel manager, principalmente por tocar cosas con la ulr
static function warning(){
$panel = '<div class="code info">
<h1>No deberias poder acceder aqui.</h1>
<hr />
<p> No uses la url para toquitear cosas >.< </p>
</div>'."\n";
return $panel;
}
}
?>