Añadir/editar/borrar sesiones 100% funcional
This commit is contained in:
parent
871a7e1a7f
commit
e207fe0155
@ -11,6 +11,7 @@ class FormSession extends Form {
|
||||
parent::__construct('formSession');
|
||||
}
|
||||
|
||||
//TODO Edit session no funciona correctamente con el seleccionar una pelicula distinta, hay que guardar la id de la sesion de alguna forma y usarla o guardar en la sesion
|
||||
public static function generaCampoFormulario($data, $errores = array()){
|
||||
|
||||
$cinema = $data['cinema'] ?? '';
|
||||
@ -25,9 +26,9 @@ class FormSession extends Form {
|
||||
<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="number" step="0.01" 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/>
|
||||
<input type="hidden" name="film" value="'.$film["idfilm"].'"/>
|
||||
<select name="hall" class="button large">';
|
||||
foreach(Hall::getListHalls($cinema) as $hll){
|
||||
if($hll->getNumber() == $hall){
|
||||
@ -47,19 +48,20 @@ class FormSession extends Form {
|
||||
<input type="date" name="date" value="'.$date.'" placeholder="Fecha de inicio" required/> <br>
|
||||
</fieldset>
|
||||
';
|
||||
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"){
|
||||
$_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>';
|
||||
|
||||
if($film){
|
||||
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(!$_SESSION["or_hall"]) $_SESSION["or_hall"] = $hall;
|
||||
if(!$_SESSION["or_date"]) $_SESSION["or_date"] = $date;
|
||||
if(!$_SESSION["or_start"])$_SESSION["or_start"] = $start;
|
||||
|
||||
$htmlform .= '
|
||||
<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' >
|
||||
@ -70,7 +72,7 @@ class FormSession extends Form {
|
||||
$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>
|
||||
<h2>".str_replace('_', ' ',$film["tittle"])."</h2>
|
||||
<hr />
|
||||
<div class='blockquote'>
|
||||
<p>".$film["description"]."</p>
|
||||
@ -80,7 +82,7 @@ class FormSession extends Form {
|
||||
</section>
|
||||
";
|
||||
}
|
||||
$htmlform .= '<a href="?state=select_film&option='.$data['option'].'" <button name="select_film" class="button large">Seleccionar una Pelicula</button></a><br>
|
||||
$htmlform .= '<button type="submit" name="select_films" form="'.$data['option'].'" formaction="?state=select_film&option='.$data['option'].'" class="button large">Seleccionar una Pelicula</button><br>
|
||||
</div>
|
||||
';
|
||||
return $htmlform;
|
||||
|
@ -44,11 +44,15 @@
|
||||
,"price" => $_POST["price"],"format" => $_POST["format"],"repeat" => $_POST["repeat"], "cinema" => $_SESSION["cinema"]);
|
||||
FormSession::processesForm($data);
|
||||
}
|
||||
|
||||
|
||||
if(isset($_POST['edit_session'])){
|
||||
$data = array("option" => "edit_session","film" => $_POST["film"],"hall" => $_POST["hall"],"date" => $_POST["date"],"start" => $_POST["start"]
|
||||
,"price" => $_POST["price"],"format" => $_POST["format"],"repeat" => $_POST["repeat"], "cinema" => $_SESSION["cinema"]
|
||||
, "origin_hall"=> $_POST["origin_hall"],"origin_date"=> $_POST["origin_date"],"origin_start"=> $_POST["origin_start"]);
|
||||
, "origin_hall"=>$_SESSION["or_hall"],"origin_date"=> $_SESSION["or_date"],"origin_start"=> $_SESSION["or_start"]);
|
||||
|
||||
$_SESSION["or_hall"] = "";
|
||||
$_SESSION["or_date"] = "";
|
||||
$_SESSION["or_start"] = "";
|
||||
FormSession::processesForm($data);
|
||||
}
|
||||
|
||||
|
@ -5,9 +5,15 @@
|
||||
require_once('../assets/php/config.php');
|
||||
//Controller file:
|
||||
include_once('panel_manager.php');
|
||||
//Manager data:
|
||||
include_once('../assets/php/common/manager.php');
|
||||
include_once('../assets/php/common/user.php');
|
||||
|
||||
if($_SESSION["login"] && $_SESSION["rol"] === "manager"){
|
||||
$_SESSION["cinema"] = "1";
|
||||
|
||||
if(!$_SESSION["cinema"])
|
||||
$_SESSION["cinema"] = Manager::getManager(unserialize($_SESSION['user'])->getId())->getIdcinema();
|
||||
|
||||
switch($_GET["state"]){
|
||||
case "view_ruser":
|
||||
case "view_user":
|
||||
@ -65,7 +71,7 @@
|
||||
CompluCine - FDI-cines
|
||||
-->
|
||||
<html lang="es">
|
||||
<link id='estilo' rel='stylesheet' type='text/css' href='includes/manager.css'>
|
||||
<link id='estilo' rel='stylesheet' type='text/css' href='../assets/css/manager.css'>
|
||||
<!-- Head -->
|
||||
<?php
|
||||
$template->print_head();
|
||||
|
@ -11,11 +11,13 @@
|
||||
|
||||
static function welcome(){
|
||||
$name = strtoupper($_SESSION['nombre']);
|
||||
$cinema = strtoupper($_SESSION['cinema']);
|
||||
|
||||
$panel = '<div class="code info">
|
||||
<h1>Bienvenido '.$name.' a tu Panel de Manager.</h1>
|
||||
<hr />
|
||||
<p>Usuario: '.$name.'</p>
|
||||
<p>Cine: '.$cinema.'</p>
|
||||
<p>Espero que estes pasando un buen dia</p>
|
||||
</div>'."\n";
|
||||
|
||||
@ -138,7 +140,6 @@
|
||||
<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.'">
|
||||
<form method="post" action="./?state=edit_session">
|
||||
<input name="film" type="hidden" value="'.$session->getIdfilm().'">
|
||||
<input name="hall" type="hidden" value="'.$session->getIdhall().'">
|
||||
@ -158,36 +159,50 @@
|
||||
$panel.=' <h3> No hay ninguna sesion </h3>';
|
||||
}
|
||||
$panel.='
|
||||
<input type="submit" name="submit" form="filter" value="Añadir" class="button large" formaction="./?state=new_session">
|
||||
<input type="submit" name="new_session" form="filter" value="Añadir" class="button large" formaction="./?state=new_session">
|
||||
</div>
|
||||
';
|
||||
|
||||
return $panel;
|
||||
}
|
||||
|
||||
static function new_session(){
|
||||
$data = array("option" => "new_session","hall" => $_POST['hall'],"cinema" => $_SESSION["cinema"],"date" => $_POST['date']);
|
||||
static function new_session(){
|
||||
echo "inicio";
|
||||
if(isset($_POST["new_session"])){
|
||||
|
||||
$data = array("option" => "new_session","hall" => $_POST['hall'],"cinema" => $_SESSION["cinema"],"date" => $_POST['date']);
|
||||
|
||||
}else if(isset($_POST["select_film"])){
|
||||
|
||||
$film = array("idfilm" => $_POST["id"],"tittle" => $_POST["tittle"], "description" => $_POST["description"], "duration" => $_POST["duration"]);
|
||||
$data = array("option" => "new_session","hall" => $_POST['hall'],"cinema" => $_SESSION["cinema"],"date" => $_POST['date'],"film" => $film, "start" => $_POST['start']
|
||||
, "price" => $_POST['price'], "format" => $_POST['format']);
|
||||
}
|
||||
|
||||
$panel = '<h1>Crear una sesión.</h1><hr /></br>
|
||||
'.FormSession::generaCampoFormulario($data, null);
|
||||
if($data){
|
||||
$panel = '<h1>Crear una sesión.</h1><hr /></br>
|
||||
'.FormSession::generaCampoFormulario($data, null);
|
||||
}else $panel = self::warning();
|
||||
|
||||
return $panel;
|
||||
}
|
||||
|
||||
static function edit_session(){
|
||||
if(isset($_POST["edit_session"])){
|
||||
|
||||
$_SESSION["or_hall"] = "";
|
||||
$_SESSION["or_date"] = "";
|
||||
$_SESSION["or_start"] = "";
|
||||
|
||||
$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"]);
|
||||
|
||||
$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']);
|
||||
}
|
||||
|
||||
if($data){
|
||||
|
Loading…
Reference in New Issue
Block a user