From 1c5e449cdb0950a60816e6334c40a7a7b02c7345 Mon Sep 17 00:00:00 2001 From: Markines16 <80280295+Markines16@users.noreply.github.com> Date: Wed, 5 May 2021 21:10:46 +0200 Subject: [PATCH] Estructura terminada Sigue faltando edit/delete halls y sessions --- panel_manager/includes/formHall.php | 105 ++++------------- panel_manager/includes/formSession.php | 149 ++++++++++++++----------- panel_manager/includes/processForm.php | 11 +- panel_manager/index.php | 20 ++-- panel_manager/panel_manager.php | 149 +++++++++++++++++++------ 5 files changed, 238 insertions(+), 196 deletions(-) diff --git a/panel_manager/includes/formHall.php b/panel_manager/includes/formHall.php index 8e6b0bb..fdb13ca 100644 --- a/panel_manager/includes/formHall.php +++ b/panel_manager/includes/formHall.php @@ -4,105 +4,42 @@ include_once($prefix.'assets/php/form.php'); class FormHall extends Form { - //Atributes: - private $correct; - private $reply; - private $option; - private $halls; - //Constructor: public function __construct() { - parent::__construct('formSession'); - $this->reply = array(); + parent::__construct('formHall'); } - public static function generaCampoFormulario($datos, $errores = array(), $option){ - if($option == "new"){ - $number = $datos['number'] ?? ''; - $rows = $datos['rows'] ?? ''; - $cols = $datos['cols'] ?? ''; - $seats = $datos['seats'] ?? ''; - - - $htmlform .= ' -
-
-
-
-
-
-
-
-
- '; - } + public static function generaCampoFormulario($data, $errores = array()){ + + $number = $data['number'] ?? ''; + $rows = $data['rows'] ?? ''; + $cols = $data['cols'] ?? ''; + $seats = $data['seats'] ?? ''; + $htmlform .= '
+
+
+
+
+
+ '; + if($data['option'] == "new_hall") + $htmlform .= '
'; + $htmlform .= ' +
+
'; return $htmlform; } //Methods: - //Returns validation response: - public function getReply() { - - if($this->correct){ - if($this->option == "new"){ - $this->reply = "

Operacion realizada con exito


-

Se ha añadido la sala correctamente en la base de datos.

- "; - }else if($this->option == "edit"){ - $this->reply = "

Operacion realizada con exito


-

Se ha editado la sala correctamente en la base de datos.

- "; - }else if($this->option == "del"){ - $this->reply = "

Operacion realizada con exito


-

Se ha eliminado la sala correctamente en la base de datos.

- "; - }else if($this->option == "list"){ - $this->reply = $this->halls; - } - } else { - $this->reply = "

ERROR


-

Ha habido un error en la operacion. Revisa los datos introducidos o ponte en contacto con el administrador de la base de datos.

- "; - } - return $this->reply; - } - //Process form: public static function processesForm($data){ - if($data["option"] == "new"){ - Hall::create_hall($data); - $_SESSION['msg'] = "La sala se ha añadido correctamente"; + if($data["option"] == "new_hall"){ + $_SESSION['msg'] = Hall::create_hall($data); header( "Location: ../?state=success" ); }else { - /* TODO - $start = date('H:i:s', strtotime( $start ) ); - if($option == "new"){ - - $selectSession = $bd->selectSession($cinema, $hall, $start, $date); - if($selectSession && $selectSession->num_rows >= 1) { - $this->correct = false; - } else{ - $bd->createSession(null, $film, $hall,$cinema, $date, $start, $price, $format); - } - - mysqli_free_result($selectSession); - - } else if ($option == "del"){ - $bd->deleteSession($id); - - } else if ($option == "edit"){ - $bd->editSession($id, $film, $hall, $cinema, $date, $start, $price, $format); - } - - if($repeat > "0"){ - $repeat--; - $date = date('Y-m-d', strtotime( $date. ' +1 day') ); - $this->processesForm($film, $hall, $cinema, $date, $start, $price, $format, $repeat); - } - */ } } } diff --git a/panel_manager/includes/formSession.php b/panel_manager/includes/formSession.php index ac81f3c..9fb5b8c 100644 --- a/panel_manager/includes/formSession.php +++ b/panel_manager/includes/formSession.php @@ -1,81 +1,94 @@ reply = array(); } - //Methods: - public function getReply() { - if($this->correct){ - if($this->option == "new"){ - $this->reply = "

Operacion realizada con exito


-

Se ha añadido la sesion correctamente en la base de datos.

- "; - }else if($this->option == "edit"){ - $this->reply = "

Operacion realizada con exito


-

Se ha editado la sesion correctamente en la base de datos.

- "; - }else if($this->option == "del"){ - $this->reply = "

Operacion realizada con exito


-

Se ha eliminado la sesion correctamente en la base de datos.

- "; - }else if($this->option == "list"){ - $this->reply = $this->sessions; - } - } else if($this->correct == false) { - $this->reply = "

ERROR


-

Ha habido un error en la operacion. Revisa los datos introducidos o ponte en contacto con el administrador de la base de datos.

- "; - } - return $this->reply; - } - - public function processesForm($film, $hall, $cinema, $date, $start, $price, $format, $repeat, $option) { - $this->option = $option; - $this->correct = true; - - $bd = new sessionDAO('complucine'); - - if($bd ){ - if($option == "list"){ - $this->sessions = $bd->getAllSessionsFromACinemaHallDate($cinema, $hall, $date); - - }else { - if($option == "new"){ - $searchSession = $bd->searchSession($cinema, $hall, $start, $date); - if($searchSession) { - $this->correct = false; - } else{ - $bd->createSession(null,$film, $hall,$cinema, $date, $start, $price, $format); - } - - } else if ($option == "del"){ - $bd->deleteSession($hall, $cinema, $date, $start); - - } else if ($option == "edit"){ - $bd->editSession($film, $hall, $cinema, $date, $start, $price, $format); + public static function generaCampoFormulario($data, $errores = array()){ + $cinema = $data['cinema'] ?? ''; + $film = $data['film'] ?? '1'; + $hall = $data['hall'] ?? '1'; + $date = $data['date'] ?? ''; + $start = $data['start'] ?? ''; + $price = $data['price'] ?? ''; + $format = $data['format'] ?? ''; + + $filmList = new Film_DAO('complucine'); + $films = $filmList->allFilmData(); + + $htmlform .= '
+
+
+ Datos +
+
+ +
+
+ Horario +
+
+
+
+ + '; + if($data['option'] == "new_session") + $htmlform .= '
'; + if($data['option'] == "edit_session") + $htmlform .= '
+
'; + $htmlform .= ' +
+
+
+ +
+'; + return $htmlform; + } + //Methods: + + //Process form: + public static function processesForm($data){ + if($data["option"] == "new_session"){ + $_SESSION['msg'] = Session::create_session($data); + header( "Location: ../?state=success" ); + }else { + + } } } diff --git a/panel_manager/includes/processForm.php b/panel_manager/includes/processForm.php index 542c400..c0b9bee 100644 --- a/panel_manager/includes/processForm.php +++ b/panel_manager/includes/processForm.php @@ -1,12 +1,19 @@ "new","number" => $_POST["number"],"cols" => $_POST["cols"],"rows" => $_POST["rows"], "cinema" => "1"); + $data = array("option" => "new_hall","number" => $_POST["number"],"cols" => $_POST["cols"],"rows" => $_POST["rows"], "cinema" => $_SESSION["cinema"]); FormHall::processesForm($data); } + if(isset($_POST['new_session'])){ + $data = array("option" => "new_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"]); + FormSession::processesForm($data); + } ?> \ No newline at end of file diff --git a/panel_manager/index.php b/panel_manager/index.php index 49d2e4d..011064e 100644 --- a/panel_manager/index.php +++ b/panel_manager/index.php @@ -9,6 +9,7 @@ include_once('panel_manager.php'); if($_SESSION["login"] && $_SESSION["rol"] === "manager"){ + $_SESSION["cinema"] = "1"; switch($_GET["state"]){ case "view_ruser": case "view_user": @@ -31,6 +32,12 @@ break; case "manage_sessions": $panel = Manager_panel::manage_sessions(); + break; + case "new_session": + $panel = Manager_panel::new_session(); + break; + case "edit_session": + $panel = Manager_panel::edit_session(); break; case "success": $panel = Manager_panel::success(); @@ -75,14 +82,13 @@
- print_panelMenu($_SESSION["rol"]); - ?> + print_panelMenu($_SESSION["rol"]); ?> +
-
- -
- +
+ +
+ print_footer(); diff --git a/panel_manager/panel_manager.php b/panel_manager/panel_manager.php index b1647e8..05f0ffa 100644 --- a/panel_manager/panel_manager.php +++ b/panel_manager/panel_manager.php @@ -1,11 +1,12 @@ state = $panel; $this->login = $log; @@ -38,39 +39,39 @@ static function manage_halls(){ $panel = '
- - - - - - - - - '; - foreach(Hall::getListHalls("1") as $hall){ +
NumeroFilasColumnas
+ + + + + + + + '; + foreach(Hall::getListHalls($_SESSION["cinema"]) as $hall){ $panel .=' - - - - - - '; + + + + + + '; } $panel.=' - -
NumeroFilasColumnas
'. $hall->getNumber().' '. $hall->getNumRows().' '. $hall->getNumCol().'
'. $hall->getNumber().' '. $hall->getNumRows().' '. $hall->getNumCol().'
- -
'; + + + + +'; return $panel; } static function new_hall(){ + $data = array("option" => "new_hall"); $panel = '
-
+

Crear una sala.



- '. - FormHall::generaCampoFormulario(null, null, "new"); - '. + '. FormHall::generaCampoFormulario($data, null).'
'."\n"; @@ -81,6 +82,7 @@ $panel = '

Editar una sala.



+

En desarrollo...

'."\n"; @@ -88,16 +90,93 @@ } static function manage_sessions(){ - $name = strtoupper($_SESSION['nombre']); - - $panel = '
-

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

-
-

Usuario: '.$name.'

-

Espero que estes pasando un buen dia

-
'."\n"; + //Base filtering values + $date = isset($_POST['date']) ? $_POST['date'] : date("Y-m-d"); + $hall = isset($_POST['hall']) ? $_POST['hall'] : "1"; + + //Session filter + $panel='
+
+ + + +
+
+ '; + //Session list + $panel .='
'; + $sessions = Session::getListSessions($hall,$_SESSION["cinema"],$date); + + if($sessions) { + $panel .=' +
+ + + + + + + + + + '; + + foreach($sessions as $session){ + $panel .=' + + + + + + + '; + } + $panel.=' + +
HoraPeliculaFormatoPrecio
'.date("H:i", strtotime( $session->getStartTime())).' '. str_replace('_', ' ', Session::getFilmTitle($session->getIdfilm())) .' '.$session->getFormat().' '.$session->getSeatPrice().'
+
'; + } else { + $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']); + + $panel = '

Crear una sesión.



+ '.FormSession::generaCampoFormulario($data, null); + + return $panel; + } + + static function edit_session(){ + $panel = '
+
+

Editar una session.



+

En desarrollo...

+
+
'."\n"; + + return $panel; + } } ?> \ No newline at end of file