Add files via upload

This commit is contained in:
Markines16 2021-05-04 21:14:38 +02:00 committed by GitHub
parent 43219ccefa
commit 62db2dcd23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 55 additions and 52 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 .= '
<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>
</fieldset>
<form method="post" id="new_hall" action="./includes/processForm.php"\>
<fieldset>
<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,45 +70,40 @@ class FormHall extends Form {
}
//Process form:
public function processesForm($datos){
$this->correct = true;
$bd = new HallDAO('complucine');
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($bd ){
if($option == "list"){
$this->halls = $bd->getAllHalls($cinema);
}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);
$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 if ($option == "del"){
$bd->deleteSession($id);
} else if ($option == "edit"){
$bd->editSession($id, $film, $hall, $cinema, $date, $start, $price, $format);
}
} else {$this->correct = false;}
if($repeat > "0"){
$repeat--;
$date = date('Y-m-d', strtotime( $date. ' +1 day') );
$this->processesForm($film, $hall, $cinema, $date, $start, $price, $format, $repeat);
}
*/
}
}
}

View File

@ -0,0 +1,12 @@
<?php
//General Config File:
require_once('../../assets/php/config.php');
$prefix ="../../";
include_once('formHall.php');
if(isset($_POST['new_hall'])){
$data = array("option" => "new","number" => $_POST["number"],"cols" => $_POST["cols"],"rows" => $_POST["rows"], "cinema" => "1");
FormHall::processesForm($data);
}
?>