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
include_once('../assets/php/common/hall_dao.php');
include_once('../assets/php/form.php');
include_once($prefix.'assets/php/common/hall_dao.php');
include_once($prefix.'assets/php/form.php');
class FormHall extends Form {
@ -16,14 +16,8 @@ class FormHall extends Form {
$this->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 .= '
<form method="post" id="new_hall" action="./includes/processForm.php"\>
<fieldset>
<label>Numero de sala:</label> <input type="text" name="number" value="'.$number.'"/> <br>
<label>Filas:</label> <input type="text" name="rows" value= "'.$rows.'"/><br>
<label>Columnas:</label> <input type="text" name="cols" value= "'.$cols.'"/><br>
<label>Butacas totales:</label> <input type="text" name="seats" value= "'.$seats.'"/><br>
<button type="submit" name="newHall">Crear</button></div><br>
<label>Numero de sala:</label> <input type="number" name="number" value="'.$number.'" required/> <br>
<label>Filas:</label> <input type="number" name="rows" value= "'.$rows.'" required/><br>
<label>Columnas:</label> <input type="number" name="cols" value= "'.$cols.'" required/><br>
<label>Butacas totales:</label> <input type="number" name="seats" value= "'.$seats.'"/><br>
<button type="submit" name="new_hall" class="button large">Crear</button></div><br>
</fieldset>
</form>
';
}
@ -74,14 +70,11 @@ 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);
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 ) );
@ -111,8 +104,6 @@ class FormHall extends Form {
}
*/
}
} else {$this->correct = false;}
}
}

View File

@ -1,13 +1,56 @@
<!DOCTYPE HTML>
<?php
//ini_set('display_errors', 0);
//error_reporting(E_ERROR | E_WARNING | E_PARSE);
//General Config File:
require_once('../assets/php/config.php');
//Controller file:
include_once('panel_manager.php');
$login = (isset($_SESSION["login"]) && $_SESSION["rol"] == "manager") ? true : false;
$panel = isset($_REQUEST['state']) ? new Panel($_REQUEST['state'],$login) : $panel = new Panel('',$login);
if($_SESSION["login"] && $_SESSION["rol"] === "manager"){
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
@ -37,7 +80,7 @@
?>
<!--Contents -->
<div class="row">
<?php $panel->showPanel(); ?>
<?php echo $panel; ?>
</div>
</div>
<!-- Footer -->

View File

@ -1,7 +1,10 @@
<?php
class Panel {
public $state;
public $login;
include_once('../assets/php/common/hall.php');
include_once('./includes/formHall.php');
class Manager_panel {
private $form;
function __construct($panel,$log){
$this->state = $panel;
@ -9,21 +12,92 @@
}
function showPanel() {
if($this->login){
switch($this->state) {
case 'us_u': echo "<p> Esta vista no esta implementada </p>"; break;
case 'us_r': echo "<p> Esta vista no esta implementada </p>"; 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;
static function welcome(){
$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;
}
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;
}
}
?>