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 <?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 .= '
<fieldset> <form method="post" id="new_hall" action="./includes/processForm.php"\>
<label>Numero de sala:</label> <input type="text" name="number" value="'.$number.'"/> <br> <fieldset>
<label>Filas:</label> <input type="text" name="rows" value= "'.$rows.'"/><br> <label>Numero de sala:</label> <input type="number" name="number" value="'.$number.'" required/> <br>
<label>Columnas:</label> <input type="text" name="cols" value= "'.$cols.'"/><br> <label>Filas:</label> <input type="number" name="rows" value= "'.$rows.'" required/><br>
<label>Butacas totales:</label> <input type="text" name="seats" value= "'.$seats.'"/><br> <label>Columnas:</label> <input type="number" name="cols" value= "'.$cols.'" required/><br>
<button type="submit" name="newHall">Crear</button></div><br> <label>Butacas totales:</label> <input type="number" name="seats" value= "'.$seats.'"/><br>
</fieldset> <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: //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 ){ }else {
if($option == "list"){ /* TODO
$this->halls = $bd->getAllHalls($cinema); $start = date('H:i:s', strtotime( $start ) );
}else {
/* TODO if($option == "new"){
$start = date('H:i:s', strtotime( $start ) );
if($option == "new"){ $selectSession = $bd->selectSession($cinema, $hall, $start, $date);
if($selectSession && $selectSession->num_rows >= 1) {
$selectSession = $bd->selectSession($cinema, $hall, $start, $date); $this->correct = false;
if($selectSession && $selectSession->num_rows >= 1) { } else{
$this->correct = false; $bd->createSession(null, $film, $hall,$cinema, $date, $start, $price, $format);
} 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);
} }
if($repeat > "0"){ mysqli_free_result($selectSession);
$repeat--;
$date = date('Y-m-d', strtotime( $date. ' +1 day') );
$this->processesForm($film, $hall, $cinema, $date, $start, $price, $format, $repeat);
}
*/
}
} 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);
}
*/
}
} }
} }

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);
}
?>