Nueva estructura

Solo funciona el añadir salas. Estoy arreglando las sesiones para que vayan igual
This commit is contained in:
Markines16 2021-05-05 16:52:04 +02:00 committed by GitHub
parent 055973a459
commit b537db0a1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 186 additions and 78 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
include_once('../assets/php/common/hall_dao.php'); include_once($prefix.'assets/php/common/hall_dao.php');
include_once('../assets/php/form.php'); include_once($prefix.'assets/php/form.php');
class FormHall extends Form { class FormHall extends Form {
@ -16,14 +16,8 @@ class FormHall extends Form {
$this->reply = array(); $this->reply = array();
} }
protected function generaCamposFormulario($datos, $errores = array()){ public static function generaCampoFormulario($datos, $errores = array(), $option){
$this->option = $_SESSION['option']; if($option == "new"){
$_SESSION['option'] = "";
$htmlform = "";
if($this->option == "new"){
$number = $datos['number'] ?? ''; $number = $datos['number'] ?? '';
$rows = $datos['rows'] ?? ''; $rows = $datos['rows'] ?? '';
$cols = $datos['cols'] ?? ''; $cols = $datos['cols'] ?? '';
@ -31,13 +25,15 @@ class FormHall extends Form {
$htmlform .= ' $htmlform .= '
<form method="post" id="new_hall" action="./includes/processForm.php"\>
<fieldset> <fieldset>
<label>Numero de sala:</label> <input type="text" name="number" value="'.$number.'"/> <br> <label>Numero de sala:</label> <input type="number" name="number" value="'.$number.'" required/> <br>
<label>Filas:</label> <input type="text" name="rows" value= "'.$rows.'"/><br> <label>Filas:</label> <input type="number" name="rows" value= "'.$rows.'" required/><br>
<label>Columnas:</label> <input type="text" name="cols" value= "'.$cols.'"/><br> <label>Columnas:</label> <input type="number" name="cols" value= "'.$cols.'" required/><br>
<label>Butacas totales:</label> <input type="text" name="seats" value= "'.$seats.'"/><br> <label>Butacas totales:</label> <input type="number" name="seats" value= "'.$seats.'"/><br>
<button type="submit" name="newHall">Crear</button></div><br> <button type="submit" name="new_hall" class="button large">Crear</button></div><br>
</fieldset> </fieldset>
</form>
'; ';
} }
@ -74,14 +70,11 @@ class FormHall extends Form {
} }
//Process form: //Process form:
public function processesForm($datos){ public static function processesForm($data){
$this->correct = true; if($data["option"] == "new"){
$bd = new HallDAO('complucine'); Hall::create_hall($data);
$_SESSION['msg'] = "La sala se ha añadido correctamente";
header( "Location: ../?state=success" );
if($bd ){
if($option == "list"){
$this->halls = $bd->getAllHalls($cinema);
}else { }else {
/* TODO /* TODO
$start = date('H:i:s', strtotime( $start ) ); $start = date('H:i:s', strtotime( $start ) );
@ -111,8 +104,6 @@ class FormHall extends Form {
} }
*/ */
} }
} else {$this->correct = false;}
} }
} }

View File

@ -1,13 +1,56 @@
<!DOCTYPE HTML> <!DOCTYPE HTML>
<?php <?php
//ini_set('display_errors', 0);
//error_reporting(E_ERROR | E_WARNING | E_PARSE);
//General Config File: //General Config File:
require_once('../assets/php/config.php'); require_once('../assets/php/config.php');
//Controller file:
include_once('panel_manager.php'); include_once('panel_manager.php');
$login = (isset($_SESSION["login"]) && $_SESSION["rol"] == "manager") ? true : false; if($_SESSION["login"] && $_SESSION["rol"] === "manager"){
$panel = isset($_REQUEST['state']) ? new Panel($_REQUEST['state'],$login) : $panel = new Panel('',$login); switch($_GET["state"]){
case "view_ruser":
case "view_user":
$panel = '<div class="column side"></div>
<div class="column middle">
<div class="code info">
<h1>Esta vista aun no esta implementada.</h1><hr />
</div>
</div>
<div class="column side"></div>'."\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 = '<div class="column side"></div>
<div class="column middle">
<div class="code info">
<h1>Debes iniciar sesión para ver el Panel de Manager.</h1><hr />
<p>Inicia Sesión en una cuenta con permisos.</p>
<a href="'.$prefix.'login/" ><button class="button large">Iniciar Sesión</button></a>
</div>
</div>
<div class="column side"></div>'."\n";
}
?> ?>
<!-- <!--
Práctica - Sistemas Web | Grupo D Práctica - Sistemas Web | Grupo D
@ -37,7 +80,7 @@
?> ?>
<!--Contents --> <!--Contents -->
<div class="row"> <div class="row">
<?php $panel->showPanel(); ?> <?php echo $panel; ?>
</div> </div>
</div> </div>
<!-- Footer --> <!-- Footer -->

View File

@ -1,7 +1,10 @@
<?php <?php
class Panel { include_once('../assets/php/common/hall.php');
public $state; include_once('./includes/formHall.php');
public $login;
class Manager_panel {
private $form;
function __construct($panel,$log){ function __construct($panel,$log){
$this->state = $panel; $this->state = $panel;
@ -9,21 +12,92 @@
} }
function showPanel() { static function welcome(){
if($this->login){ $name = strtoupper($_SESSION['nombre']);
switch($this->state) {
case 'us_u': echo "<p> Esta vista no esta implementada </p>"; break; $panel = '<div class="code info">
case 'us_r': echo "<p> Esta vista no esta implementada </p>"; break; <h1>Bienvenido '.$name.' a tu Panel de Manager.</h1>
case 'rooms': require_once('manage_halls.php'); break; <hr />
case 'sessions': require_once('manage_sessions.php'); break; <p>Usuario: '.$name.'</p>
case 'edit_session': require_once('edit_sessions.php'); break; <p>Espero que estes pasando un buen dia</p>
case 'edit_hall': require_once('edit_halls.php'); break; </div>'."\n";
default: require('hello_panel.php'); break;
return $panel;
} }
static function success(){
$panel = '<div class="code info">
<h1>Operacion completada.</h1>
<hr />
<p>'.$_SESSION['msg'].'</p>
</div>'."\n";
$_SESSION['msg'] = "";
return $panel;
} }
else{
echo "<h1> Error no tienes los permisos necesarios de gerente</h1>"; static function manage_halls(){
$panel = '<form method="post" action="./?state=new_hall">
<table class="alt">
<thead>
<tr>
<th>Numero</th>
<th>Filas</th>
<th>Columnas</th>
</tr>
</thead>
<tbody>';
foreach(Hall::getListHalls("1") as $hall){
$panel .='
<tr>
<td> '. $hall->getNumber().'</td>
<td> '. $hall->getNumRows().'</td>
<td> '. $hall->getNumCol().'</td>
<td> <input type="submit" name="edit" value="Editar" class="button" formaction="./?state=edit_hall&number='.$hall->getNumber().'" ></td>
</tr>';
} }
$panel.='
</tbody>
</table>
<input type="submit" name="new" value="Añadir" class="button large" >
</form>';
return $panel;
}
static function new_hall(){
$panel = '<div class="column side"></div>
<div class="column middle">
<h1>Crear una sala.</h1><hr /></br>
'.
FormHall::generaCampoFormulario(null, null, "new");
'.
</div>
<div class="column side"></div>'."\n";
return $panel;
}
static function edit_hall(){
$panel = '<div class="column side"></div>
<div class="column middle">
<h1>Editar una sala.</h1><hr /></br>
</div>
<div class="column side"></div>'."\n";
return $panel;
}
static function manage_sessions(){
$name = strtoupper($_SESSION['nombre']);
$panel = '<div class="code info">
<h1>Bienvenido '.$name.' a tu Panel de Manager.</h1>
<hr />
<p>Usuario: '.$name.'</p>
<p>Espero que estes pasando un buen dia</p>
</div>'."\n";
return $panel;
} }
} }
?> ?>