Add files via upload

This commit is contained in:
Markines16 2021-05-25 00:51:11 +02:00 committed by GitHub
parent 045e93198e
commit bf0bb38838
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 60 additions and 59 deletions

View File

@ -7,23 +7,28 @@ class FormHall extends Form {
private $option;
private $cinema;
private $og_hall;
private $first;
//Constructor:
public function __construct($option, $cinema) {
public function __construct($option, $cinema, $hall) {
$this->option = $option;
$this->cinema = $cinema;
$options = array("action" => "./?state=".$option);
$this->og_hall = $hall;
if($option == "edit_hall")
$this->first = true;
$options = array("action" => "./?state=".$option."&number=".$hall->getNumber()."");
parent::__construct('formHall',$options);
}
protected function generaCamposFormulario($data, $errores = array()){
//Prepare the data
$number = $data['number'] ?? $_POST["number"] ?? "";
$rows = $data['rows'] ?? $_POST["rows"] ?? "12";
$cols = $data['cols'] ?? $_POST["cols"] ?? "8";
$og_number = $data['og_number'] ?? $number;
$og_rows = $data['og_rows'] ?? $rows;
$og_cols = $data['og_cols'] ?? $cols;
$number = $data['number'] ?? $this->og_hall->getNumber() ?? "";
$rows = $data['rows'] ?? $this->og_hall->getNumRows() ?? "12";
$cols = $data['cols'] ?? $this->og_hall->getNumCol() ?? "8";
//Seats_map
$seats = 0;
@ -35,10 +40,11 @@ class FormHall extends Form {
}
//Show the original seats_map once u click restart or the first time u enter this form from manage_halls's form
if(isset($data["restart"]) || isset($_POST["edit_hall"]) ){
$rows = $og_rows;
$cols = $og_cols;
$seat_list = Seat::getSeatsMap($og_number, $this->cinema);
if(isset($data["restart"]) || $this->first){
$first = false;
$rows = $this->og_hall->getNumRows();
$cols = $this->og_hall->getNumCol();
$seat_list = Seat::getSeatsMap($this->og_hall->getNumber(), $this->cinema);
if($seat_list){
foreach($seat_list as $seat){
$seats_map[$seat->getNumRows()][$seat->getNumCol()] = $seat->getState();
@ -76,21 +82,17 @@ class FormHall extends Form {
<legend>Mapa de Asientos</legend>
'.$errorSeats.' '.$errorRows.' '.$errorCols.'
<label> Filas: </label> <input type="number" name="rows" min="1" id="rows" value="'.$rows.'" required/> <br>
<input type="Hidden" name="og_rows" value="'.$og_rows.'"/> <br>
<label> Columnas: </label> <input type="number" name="cols" min="1" id="cols" value="'.$cols.'"required/> <br>
<input type="Hidden" name="og_cols" value="'.$og_cols.'"/> <br>
<label> Asientos totales:'.$seats.' </label> <input type="hidden" name="seats" id="seats" value="'.$seats.'"readonly/> <br>
<input type="submit" name="alltoone" value="Activar todos los asientos" class="button large" />';
<input type="submit" name="filter" value="Actualizar mapa de la sala" class="button large" />
';
if($this->option == "edit_hall")
$html .= ' <input type="submit" id="restart" name="restart" value="Restaurar mapa original" class="black button" />';
$html .='
</fieldset>
<input type="submit" name="filter" value="Actualizar mapa de la sala" class="button large" /> '.$errorNumber.'
<fieldset>
</fieldset><br>
'.$errorNumber.'
<label> Numero de sala: </label>
<input type="number" min="1" name="number" id="number" value="'.$number.'" placeholder="Numero de la Sala" /><br>
<input type="hidden" name="og_number" value="'.$og_number.'" /><br>
</fieldset>
';
if($this->option == "new_hall")
$html .='<input type="submit" id="submit" name="sumbit" value="Crear Sala" class="primary" />
@ -103,6 +105,7 @@ class FormHall extends Form {
if(!$errorCols && !$errorRows){
$html .='</div>
<div class="column right">
<input type="submit" name="alltoone" value="Activar todos los asientos" class="button large" />
<h3 class="table_title"> Pantalla </h3>
<table class="seat">
<thead>
@ -150,7 +153,6 @@ class FormHall extends Form {
$rows = $datos['rows'];
$cols = $datos['cols'];
$og_number = $datos["og_number"];
//Prepare the seat_map
$seats_map = array();
@ -193,14 +195,14 @@ class FormHall extends Form {
$result = './?state=success';
}
if($this->option == "edit_hall"){
$_SESSION['msg'] = Hall::edit_hall($number,$this->cinema, $rows, $cols, $seats, $seats_map, $og_number);
$_SESSION['msg'] = Hall::edit_hall($number,$this->cinema, $rows, $cols, $seats, $seats_map, $this->og_hall->getNumber());
$result = './?state=success';
}
}
if (!isset($result['number']) && isset($datos["delete"]) ) {
if($this->option == "edit_hall"){
$_SESSION['msg'] = Hall::delete_hall($number, $this->cinema, $rows, $cols, $seats, $seats_map, $og_number);
$_SESSION['msg'] = Hall::delete_hall($number, $this->cinema, $rows, $cols, $seats, $seats_map, $this->og_hall->getNumber());
$result = './?state=success';
}
}

View File

@ -12,14 +12,23 @@
function __construct(){}
static function welcome($manager){
$bd = new Cinema_DAO('complucine');
if($bd){
$cinema = ($bd->cinemaData($manager->getIdcinema()))->fetch_assoc();
$c_name = $cinema["name"];
$c_dir = $cinema["direction"];
$c_tel = $cinema["phone"];
}
$name = strtoupper($_SESSION["nombre"]);
$cinema = strtoupper( $manager->getIdcinema());
$panel = '<div class="code info">
<h1>Bienvenido '.$name.' a tu Panel de Manager.</h1>
<hr />
<p>Usuario: '.$name.'</p>
<p>Cine: '.$cinema.'</p>
<p>Usuario: '.$name.'</p> <br>
<p>Cine: '.$c_name.'</p>
<p>Dirección: '.$c_dir.'</p>
<p>Telefono: '.$c_tel.'</p> <br>
<p>Espero que estes pasando un buen dia</p>
</div>';
@ -84,36 +93,20 @@
$panel .= "<h2> No hay ninguna sala en este cine";
}else{
$panel .= '
<table class="alt">
<thead>
<tr>
<th>Numero</th>
<th>Filas</th>
<th>Columnas</th>
<th>Asientos Disponibles</th>
</tr>
</thead>
<tbody>';
<h3 class="tablelike_title"> Salas </h3> <h3 class="tablelike_title"> Asientos </h3> <br>
<ul class="tablelike">
';
foreach($listhall as $hall){
$panel .='
<tr>
<td> '. $hall->getNumber().'</td>
<td> '. $hall->getNumRows().'</td>
<td> '. $hall->getNumCol().'</td>
<td> '.$hall->getTotalSeats().' </td>
<form method="post" action="./?state=edit_session">
<input name="number" type="hidden" value="'. $hall->getNumber().'"/>
<input name="rows" type="hidden" value="'. $hall->getNumRows().'"/>
<input name="cols" type="hidden" value="'. $hall->getNumCol().'"/>
<input name="seats" type="hidden" value="'.$hall->getTotalSeats().'"/>
<td> <input type="submit" id="submit" name ="edit_hall" formaction="./?state=edit_hall" value="Editar" class="primary" /> </td>
</form>
</tr>';
<li class="tablelike"> '. $hall->getNumber().'</li>
<li class="tablelike"> '.$hall->getTotalSeats().' </li>
<a class="tablelike_link" href="?state=edit_hall&number='. $hall->getNumber().'"> Editar </a>
<a class="tablelike_link" href="?state=manage_sessions&number='. $hall->getNumber().'"> Sessiones </a>
';
}
$panel.='
</tbody>
</table>';
</ul>';
}
$panel.='
<form method="post" action="./?state=new_hall">
@ -133,18 +126,24 @@
return $panel;
}
static function edit_hall($manager){
$formHall = new FormHall("edit_hall",$manager->getIdcinema());
$panel = '<h1>Editar una sala.</h1><hr/></br>
'.$formHall->gestiona();
return $panel;
static function edit_hall($manager){
$hall = Hall::search_hall($_GET["number"], $manager->getIdcinema());
if($hall || isset($_POST["restart"]) || isset($_POST["filter"]) || isset($_POST["sumbit"]) ){
$formHall = new FormHall("edit_hall",$manager->getIdcinema(), $hall);
$panel = '<h1>Editar una sala.</h1><hr/></br>
'.$formHall->gestiona();
return $panel;
} else{
return Manager_panel::warning($manager);
}
}
static function manage_sessions($manager){
//Base filtering values
$date = isset($_POST['date']) ? $_POST['date'] : date("Y-m-d");
$hall = isset($_POST['hall']) ? $_POST['hall'] : "1";
$date = $_POST['date'] ?? $_GET['date'] ?? date("Y-m-d");
$hall = $_POST['hall'] ?? $_GET['hall'] ?? "1";
//Session filter
$panel='<div class = "column left">
@ -254,7 +253,7 @@
//Funcion que se envia cuando hay inconsistencia en el panel manager, principalmente por tocar cosas con la ulr
static function warning($manager){
$panel = '<div class="code info">
<h1>No deberias poder acceder aqui.</h1>
<h1>Ha habido un error.</h1>
<hr />
<p> >.< </p>
</div>'."\n";