diff --git a/panel_manager/includes/formSession.php b/panel_manager/includes/formSession.php index 854f976..a9bbc5b 100644 --- a/panel_manager/includes/formSession.php +++ b/panel_manager/includes/formSession.php @@ -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 {
Datos -
+

- +
'; - if($data['option'] == "new_session") - $htmlform .= '
-
'; - if($data['option'] == "edit_session"){ - $_SESSION["session"] = $data['id'] ?? Session::getThisSessionId($cinema, $hall, $start, $date)["id"]; - - $htmlform .= ' - - - -
-
'; - + if($film){ + if($data['option'] == "new_session") + $htmlform .= '
+
'; + + 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 .= ' +
+
'; + } } $htmlform .= " @@ -70,7 +72,7 @@ class FormSession extends Form { $htmlform .= "
".$film["tittle"]."
-

".$film["tittle"]."

+

".str_replace('_', ' ',$film["tittle"])."


".$film["description"]."

@@ -80,7 +82,7 @@ class FormSession extends Form {
"; } - $htmlform .= 'Seleccionar una Pelicula
+ $htmlform .= '
'; return $htmlform; diff --git a/panel_manager/includes/processForm.php b/panel_manager/includes/processForm.php index 157457c..f818d41 100644 --- a/panel_manager/includes/processForm.php +++ b/panel_manager/includes/processForm.php @@ -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); } diff --git a/panel_manager/index.php b/panel_manager/index.php index f2e217b..c9de885 100644 --- a/panel_manager/index.php +++ b/panel_manager/index.php @@ -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 --> - + print_head(); diff --git a/panel_manager/panel_manager.php b/panel_manager/panel_manager.php index f49790d..a5cf736 100644 --- a/panel_manager/panel_manager.php +++ b/panel_manager/panel_manager.php @@ -11,11 +11,13 @@ static function welcome(){ $name = strtoupper($_SESSION['nombre']); + $cinema = strtoupper($_SESSION['cinema']); $panel = '

Bienvenido '.$name.' a tu Panel de Manager.


Usuario: '.$name.'

+

Cine: '.$cinema.'

Espero que estes pasando un buen dia

'."\n"; @@ -138,7 +140,6 @@ '. str_replace('_', ' ', Session::getThisSessionFilm($session->getIdfilm())["tittle"]) .' '.$session->getFormat().' '.$session->getSeatPrice().' - @@ -158,36 +159,50 @@ $panel.='

No hay ninguna sesion

'; } $panel.=' - + '; 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 = '

Crear una sesión.



- '.FormSession::generaCampoFormulario($data, null); + if($data){ + $panel = '

Crear una sesión.



+ '.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){