From b537db0a1bd78bc235c0844d29f43a26a6dc53c6 Mon Sep 17 00:00:00 2001 From: Markines16 <80280295+Markines16@users.noreply.github.com> Date: Wed, 5 May 2021 16:52:04 +0200 Subject: [PATCH] Nueva estructura MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Solo funciona el añadir salas. Estoy arreglando las sesiones para que vayan igual --- panel_manager/includes/formHall.php | 95 +++++++++++------------- panel_manager/index.php | 59 +++++++++++++-- panel_manager/panel_manager.php | 110 +++++++++++++++++++++++----- 3 files changed, 186 insertions(+), 78 deletions(-) diff --git a/panel_manager/includes/formHall.php b/panel_manager/includes/formHall.php index ee45443..8e6b0bb 100644 --- a/panel_manager/includes/formHall.php +++ b/panel_manager/includes/formHall.php @@ -1,6 +1,6 @@ reply = array(); } - protected function generaCamposFormulario($datos, $errores = array()){ - $this->option = $_SESSION['option']; - $_SESSION['option'] = ""; - $htmlform = ""; - - - - if($this->option == "new"){ + public static function generaCampoFormulario($datos, $errores = array(), $option){ + if($option == "new"){ $number = $datos['number'] ?? ''; $rows = $datos['rows'] ?? ''; $cols = $datos['cols'] ?? ''; @@ -31,13 +25,15 @@ class FormHall extends Form { $htmlform .= ' -
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
'; } @@ -74,45 +70,40 @@ class FormHall extends Form { } //Process form: - public function processesForm($datos){ - $this->correct = true; - $bd = new HallDAO('complucine'); - - - if($bd ){ - if($option == "list"){ - $this->halls = $bd->getAllHalls($cinema); - }else { - /* TODO - $start = date('H:i:s', strtotime( $start ) ); + public static function processesForm($data){ + if($data["option"] == "new"){ + Hall::create_hall($data); + $_SESSION['msg'] = "La sala se ha añadido correctamente"; + header( "Location: ../?state=success" ); + }else { + /* TODO + $start = date('H:i:s', strtotime( $start ) ); + + if($option == "new"){ - 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); + $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); } - if($repeat > "0"){ - $repeat--; - $date = date('Y-m-d', strtotime( $date. ' +1 day') ); - $this->processesForm($film, $hall, $cinema, $date, $start, $price, $format, $repeat); - } - */ - } + mysqli_free_result($selectSession); - } else {$this->correct = false;} + } 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/index.php b/panel_manager/index.php index 1b705cf..49d2e4d 100644 --- a/panel_manager/index.php +++ b/panel_manager/index.php @@ -1,13 +1,56 @@ +
+
+

Esta vista aun no esta implementada.


+
+
+
'."\n"; + break; + case "manage_halls": + $panel = Manager_panel::manage_halls(); + break; + case "new_hall": + $panel = Manager_panel::new_hall(); + break; + case "edit_hall": + $panel = Manager_panel::edit_hall(); + break; + case "manage_sessions": + $panel = Manager_panel::manage_sessions(); + break; + case "success": + $panel = Manager_panel::success(); + break; + default: + $panel = Manager_panel::welcome(); + break; + } + } + else{ + $panel = '
+
+
+

Debes iniciar sesión para ver el Panel de Manager.


+

Inicia Sesión en una cuenta con permisos.

+ +
+
+
'."\n"; + } ?>
- showPanel(); ?> +
diff --git a/panel_manager/panel_manager.php b/panel_manager/panel_manager.php index c48f3b1..b1647e8 100644 --- a/panel_manager/panel_manager.php +++ b/panel_manager/panel_manager.php @@ -1,7 +1,10 @@ state = $panel; @@ -9,21 +12,92 @@ } - function showPanel() { - if($this->login){ - switch($this->state) { - case 'us_u': echo "

Esta vista no esta implementada

"; break; - case 'us_r': echo "

Esta vista no esta implementada

"; break; - case 'rooms': require_once('manage_halls.php'); break; - case 'sessions': require_once('manage_sessions.php'); break; - case 'edit_session': require_once('edit_sessions.php'); break; - case 'edit_hall': require_once('edit_halls.php'); break; - default: require('hello_panel.php'); break; - } - } - else{ - echo "

Error no tienes los permisos necesarios de gerente

"; - } + static function welcome(){ + $name = strtoupper($_SESSION['nombre']); + + $panel = '
+

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

+
+

Usuario: '.$name.'

+

Espero que estes pasando un buen dia

+
'."\n"; + + return $panel; + } + + static function success(){ + $panel = '
+

Operacion completada.

+
+

'.$_SESSION['msg'].'

+
'."\n"; + $_SESSION['msg'] = ""; + + return $panel; + } + + static function manage_halls(){ + $panel = '
+ + + + + + + + + '; + foreach(Hall::getListHalls("1") as $hall){ + $panel .=' + + + + + + '; + } + $panel.=' + +
NumeroFilasColumnas
'. $hall->getNumber().' '. $hall->getNumRows().' '. $hall->getNumCol().'
+ +
'; + return $panel; + } + + static function new_hall(){ + $panel = '
+
+

Crear una sala.



+ '. + FormHall::generaCampoFormulario(null, null, "new"); + '. +
+
'."\n"; + + return $panel; + } + + static function edit_hall(){ + $panel = '
+
+

Editar una sala.



+
+
'."\n"; + + return $panel; + } + + 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"; + + return $panel; } } ?> \ No newline at end of file