Todo funcional
This commit is contained in:
@ -8,10 +8,12 @@ require_once($prefix.'assets/php/form.php');
|
||||
class FormSession extends Form {
|
||||
|
||||
private $option;
|
||||
|
||||
private $cinema;
|
||||
|
||||
//Constructor:
|
||||
public function __construct($option) {
|
||||
public function __construct($option, $cinema) {
|
||||
$this->option = $option;
|
||||
$this->cinema = $cinema;
|
||||
$options = array("action" => "./?state=".$option);
|
||||
parent::__construct('formSession',$options);
|
||||
}
|
||||
@ -23,16 +25,14 @@ class FormSession extends Form {
|
||||
$films = $filmList->allFilmData();
|
||||
|
||||
if($this->option == "new_session") {
|
||||
$cinema = $data['cinema'] ?? $_SESSION["cinema"];
|
||||
$film = $data['film'] ?? 1;
|
||||
$hall = $data['hall'] ?? '';
|
||||
$date = $data['date'] ?? '';
|
||||
$hall = $data['hall'] ?? $_POST["hall"];
|
||||
$date = $data['date'] ?? $_POST["date"];
|
||||
$start = $data['start'] ?? '';
|
||||
$price = $data['price'] ?? '';
|
||||
$format = $data['format'] ?? '';
|
||||
}
|
||||
else {
|
||||
$cinema = $data['cinema'] ?? $_SESSION["cinema"];
|
||||
$film = $data['film'] ?? $_POST["film"];
|
||||
$hall = $data['hall'] ?? $_POST["hall"];
|
||||
$date = $data['date'] ?? $_POST["date"];
|
||||
@ -47,17 +47,15 @@ class FormSession extends Form {
|
||||
$htmlErroresGlobales = self::generaListaErroresGlobales($errores);
|
||||
$errorPrice = self::createMensajeError($errores, 'price', 'span', array('class' => 'error'));
|
||||
|
||||
$html .= '<div class="column left">
|
||||
'.$htmlErroresGlobales.'
|
||||
'.$errorPrice.'
|
||||
$html .= '
|
||||
<div class="column left">'.$htmlErroresGlobales.' '.$errorPrice.'
|
||||
<fieldset>
|
||||
<legend>Datos</legend>
|
||||
<input type="number" step="0.01" name="price" value="'.$price.'" min="0" placeholder="Precio de la entrada" required/> <br>
|
||||
'.$errorFormat.'
|
||||
<input type="number" step="0.01" name="price" value="'.$price.'" min="0" placeholder="Precio de la entrada" required/> <br>'.$errorFormat.'
|
||||
<input type="text" name="format" value="'.$format.'" placeholder="Formato de pelicula" required/> <br>
|
||||
<input type="hidden" name="film" value="'.$film.'"/>
|
||||
<select name="hall" class="button large">';
|
||||
foreach(Hall::getListHalls($cinema) as $hll){
|
||||
foreach(Hall::getListHalls($this->cinema) as $hll){
|
||||
if($hll->getNumber() == $hall){
|
||||
$html.= '
|
||||
<option value="'. $hll->getNumber() .'"selected> Sala '. $hll->getNumber() .'</option> ';
|
||||
@ -77,31 +75,33 @@ class FormSession extends Form {
|
||||
<input type="date" name="date" value="'.$date.'" placeholder="Fecha de inicio" required/> <br>
|
||||
<input type="hidden" name="or_date" value="'.$or_date.'"/>
|
||||
</fieldset>
|
||||
';
|
||||
';
|
||||
if($film){
|
||||
if($this->option == "new_session")
|
||||
$html .= '<input type="number" name="repeat" value="" min="0" title="Añadir esta sesion durante los proximos X dias" min="0" max="31" placeholder="Añadir X dias"/> <br>
|
||||
<button type="submit" id="submit" name="sumbit" class="button large">Crear</button><br>';
|
||||
<input type="submit" id="submit" name="sumbit" class="primary" value="Crear" /> <br>';
|
||||
|
||||
if($this->option == "edit_session"){
|
||||
$html .= '
|
||||
<button type="submit" id="submit" name="sumbit" class="button large">Editar</button><br>
|
||||
<button type="submit" id="submit" name="delete" class="primary">Borrar</button><br>';
|
||||
$html .= '<input type="submit" id="submit" name="sumbit" class="primary" value="Editar" /><br>
|
||||
<input type="submit" name="delete" class="black button" onclick="return confirm(\'Seguro que quieres borrar esta sesion?\')" value="Borrar" /><br>';
|
||||
}
|
||||
}
|
||||
$html .= '
|
||||
<input type="reset" value="Limpiar Campos" >
|
||||
<input type="reset" id="reset" value="Limpiar Campos" />
|
||||
</div>
|
||||
<div class="column side">
|
||||
<select name="film" class="button large">';
|
||||
<div class="column rigth">
|
||||
<select name="film" class="button large">
|
||||
';
|
||||
foreach($films as $f){
|
||||
if($f->getId() == $film){
|
||||
$html .= "<option value=\"". $f->getId() ." \"selected> " . $f->getId() . "|" . $f->getTittle() ." Idioma: " . $f->getLanguage() . "</option>";
|
||||
$html .= "<option value=\"". $f->getId() ." \"selected> " . $f->getId() . "|" . $f->getTittle() ." Idioma: " . $f->getLanguage() . "</option>
|
||||
";
|
||||
}else{
|
||||
$html .= "<option value=\"". $f->getId() ." \"> " . $f->getId() . "|" . $f->getTittle() ." Idioma: " . $f->getLanguage() . "</option>";
|
||||
$html .= "<option value=\"". $f->getId() ." \"> " . $f->getId() . "|" . $f->getTittle() ." Idioma: " . $f->getLanguage() . "</option>
|
||||
";
|
||||
}
|
||||
}
|
||||
|
||||
$html .= '</select>';
|
||||
return $html;
|
||||
}
|
||||
//Methods:
|
||||
@ -128,17 +128,17 @@ class FormSession extends Form {
|
||||
|
||||
if (count($result) === 0 && isset($data["sumbit"]) ) {
|
||||
if($this->option == "new_session"){
|
||||
$_SESSION['msg'] = Session::create_session($_SESSION["cinema"], $hall, $start, $date, $film, $price, $format,$repeat);
|
||||
$_SESSION['msg'] = Session::create_session($this->cinema, $hall, $start, $date, $film, $price, $format,$repeat);
|
||||
$result = './?state=success';
|
||||
}
|
||||
if($this->option == "edit_session"){
|
||||
$_SESSION['msg'] = Session::edit_session($_SESSION["cinema"], $or_hall, $or_date, $or_start, $hall, $start, $date, $film, $price, $format);
|
||||
$_SESSION['msg'] = Session::edit_session($this->cinema, $or_hall, $or_date, $or_start, $hall, $start, $date, $film, $price, $format);
|
||||
$result = './?state=success';
|
||||
}
|
||||
}
|
||||
|
||||
if(!isset($result['hall']) && !isset($result['start']) && !isset($result['date']) && isset($data["delete"])) {
|
||||
$_SESSION['msg'] = Session::delete_session($_SESSION["cinema"], $or_hall, $or_start, $or_date);
|
||||
$_SESSION['msg'] = Session::delete_session($this->cinema, $or_hall, $or_start, $or_date);
|
||||
$result = './?state=success';
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user