Gestion de sesiones usa print->film
This commit is contained in:
parent
a77196d731
commit
52cc4cb49b
@ -1,6 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once($prefix.'assets/php/common/session_dao.php');
|
require_once($prefix.'assets/php/common/session_dao.php');
|
||||||
require_once($prefix.'assets/php/common/film_dao.php');
|
|
||||||
require_once($prefix.'assets/php/common/session.php');
|
require_once($prefix.'assets/php/common/session.php');
|
||||||
require_once($prefix.'assets/php/form.php');
|
require_once($prefix.'assets/php/form.php');
|
||||||
|
|
||||||
@ -9,11 +8,14 @@ class FormSession extends Form {
|
|||||||
|
|
||||||
private $option;
|
private $option;
|
||||||
private $cinema;
|
private $cinema;
|
||||||
|
private $formID;
|
||||||
|
|
||||||
//Constructor:
|
//Constructor:
|
||||||
public function __construct($option, $cinema) {
|
public function __construct($option, $cinema) {
|
||||||
$this->option = $option;
|
$this->option = $option;
|
||||||
$this->cinema = $cinema;
|
$this->cinema = $cinema;
|
||||||
|
$this->formID = 'formSession1';
|
||||||
|
|
||||||
$options = array("action" => "./?state=".$option);
|
$options = array("action" => "./?state=".$option);
|
||||||
parent::__construct('formSession',$options);
|
parent::__construct('formSession',$options);
|
||||||
}
|
}
|
||||||
@ -21,40 +23,38 @@ class FormSession extends Form {
|
|||||||
//TODO Edit session no funciona correctamente con el seleccionar una pelicula distinta, hay que guardar la id de la sesion de alguna forma y usarla o guardar en la sesion
|
//TODO Edit session no funciona correctamente con el seleccionar una pelicula distinta, hay que guardar la id de la sesion de alguna forma y usarla o guardar en la sesion
|
||||||
protected function generaCamposFormulario($data, $errores = array()){
|
protected function generaCamposFormulario($data, $errores = array()){
|
||||||
|
|
||||||
$filmList = new Film_DAO('complucine');
|
$hall = $data['hall'] ?? $_POST["hall"] ?? "";
|
||||||
$films = $filmList->allFilmData();
|
$date = $data['date'] ?? $_POST["date"] ?? "";
|
||||||
|
$start = $data['start'] ?? $_POST["start"] ?? "";
|
||||||
|
$price = $data['price'] ?? $_POST["price"] ?? "";
|
||||||
|
$format = $data['format'] ?? $_POST["format"] ?? "";
|
||||||
|
|
||||||
if($this->option == "new_session") {
|
|
||||||
$film = $data['film'] ?? 1;
|
|
||||||
$hall = $data['hall'] ?? $_POST["hall"];
|
|
||||||
$date = $data['date'] ?? $_POST["date"];
|
|
||||||
$start = $data['start'] ?? '';
|
|
||||||
$price = $data['price'] ?? '';
|
|
||||||
$format = $data['format'] ?? '';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$film = $data['film'] ?? $_POST["film"];
|
|
||||||
$hall = $data['hall'] ?? $_POST["hall"];
|
|
||||||
$date = $data['date'] ?? $_POST["date"];
|
|
||||||
$start = $data['start'] ?? $_POST["start"];
|
|
||||||
$price = $data['price'] ?? $_POST["price"];
|
|
||||||
$format = $data['format'] ?? $_POST["format"];
|
|
||||||
}
|
|
||||||
$or_hall = $data["or_hall"] ?? $hall;
|
$or_hall = $data["or_hall"] ?? $hall;
|
||||||
$or_date = $data["or_date"] ?? $date;
|
$or_date = $data["or_date"] ?? $date;
|
||||||
$or_start = $data["or_start"] ?? $start;
|
$or_start = $data["or_start"] ?? $start;
|
||||||
|
|
||||||
|
$film = $data['film'] ?? $_POST["film"] ?? "";
|
||||||
|
$tittle = $data['tittle'] ?? $_POST["tittle"] ?? "";
|
||||||
|
$duration = $data['duration'] ?? $_POST["duration"] ?? "";
|
||||||
|
$language = $data['language'] ?? $_POST["language"] ?? "";
|
||||||
|
$description = $data['description'] ?? $_POST["description"] ?? "";
|
||||||
|
|
||||||
$htmlErroresGlobales = self::generaListaErroresGlobales($errores);
|
$htmlErroresGlobales = self::generaListaErroresGlobales($errores);
|
||||||
$errorPrice = self::createMensajeError($errores, 'price', 'span', array('class' => 'error'));
|
$errorPrice = self::createMensajeError($errores, 'price', 'span', array('class' => 'error'));
|
||||||
$errorFormat = self::createMensajeError($errores, 'format', 'span', array('class' => 'error'));
|
$errorFormat = self::createMensajeError($errores, 'format', 'span', array('class' => 'error'));
|
||||||
|
$errorDate = self::createMensajeError($errores, 'date', 'span', array('class' => 'error'));
|
||||||
|
$errorStart = self::createMensajeError($errores, 'start', 'span', array('class' => 'error'));
|
||||||
|
|
||||||
$html = '
|
$html = '
|
||||||
<div class="column left">'.$htmlErroresGlobales.' '.$errorPrice.'
|
<div class="column left">'.$htmlErroresGlobales.'
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Datos</legend>
|
<legend>Datos</legend>
|
||||||
<input type="number" step="0.01" name="price" value="'.$price.'" min="0" placeholder="Precio de la entrada" required/> <br>'.$errorFormat.'
|
'.$errorPrice.'
|
||||||
<input type="text" name="format" value="'.$format.'" placeholder="Formato de pelicula" required/> <br>
|
<input type="number" step="0.01" name="price" value="'.$price.'" min="0" placeholder="Precio de la entrada" /> <br>'
|
||||||
|
.$errorFormat.'
|
||||||
|
<input type="text" name="format" value="'.$format.'" placeholder="Formato de pelicula" /> <br>
|
||||||
<input type="hidden" name="film" value="'.$film.'"/>
|
<input type="hidden" name="film" value="'.$film.'"/>
|
||||||
|
<input type="hidden" name="option" value="'.$this->option.'"/>
|
||||||
<select name="hall" class="button large">';
|
<select name="hall" class="button large">';
|
||||||
foreach(Hall::getListHalls($this->cinema) as $hll){
|
foreach(Hall::getListHalls($this->cinema) as $hll){
|
||||||
if($hll->getNumber() == $hall){
|
if($hll->getNumber() == $hall){
|
||||||
@ -71,9 +71,11 @@ class FormSession extends Form {
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Horario</legend>
|
<legend>Horario</legend>
|
||||||
<input type="time" name="start" value="'.$start.'" placeholder="Hora de inicio" required/> <br>
|
'.$errorStart.'
|
||||||
|
<input type="time" name="start" value="'.$start.'" placeholder="Hora de inicio"/> <br>
|
||||||
<input type="hidden" name="or_start" value="'.$or_start.'"/>
|
<input type="hidden" name="or_start" value="'.$or_start.'"/>
|
||||||
<input type="date" name="date" value="'.$date.'" placeholder="Fecha de inicio" required/> <br>
|
'.$errorDate.'
|
||||||
|
<input type="date" name="date" value="'.$date.'" placeholder="Fecha de inicio" /> <br>
|
||||||
<input type="hidden" name="or_date" value="'.$or_date.'"/>
|
<input type="hidden" name="or_date" value="'.$or_date.'"/>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
';
|
';
|
||||||
@ -87,22 +89,29 @@ class FormSession extends Form {
|
|||||||
<input type="submit" name="delete" class="black button" onclick="return confirm(\'Seguro que quieres borrar esta sesion?\')" value="Borrar" /><br>';
|
<input type="submit" name="delete" class="black button" onclick="return confirm(\'Seguro que quieres borrar esta sesion?\')" value="Borrar" /><br>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$html .= '
|
$html .= "
|
||||||
<input type="reset" id="reset" value="Limpiar Campos" />
|
<input type='reset' id='reset' value='Limpiar Campos' >
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="column rigth">
|
<div class='column side'>";
|
||||||
<select name="film" class="button large">
|
if($film){
|
||||||
';
|
$html .= "<section id='".$tittle."'>
|
||||||
foreach($films as $f){
|
<div class='code showtimes'>
|
||||||
if($f->getId() == $film){
|
<div class='image'><img src='../img/films/".$tittle.".jpg' alt='".$tittle."' /></div>
|
||||||
$html .= "<option value=\"". $f->getId() ." \"selected> " . $f->getId() . "|" . $f->getTittle() ." Idioma: " . $f->getLanguage() . "</option>
|
<h2>".str_replace('_', ' ',$tittle)."</h2>
|
||||||
";
|
<hr />
|
||||||
}else{
|
<div class='blockquote'>
|
||||||
$html .= "<option value=\"". $f->getId() ." \"> " . $f->getId() . "|" . $f->getTittle() ." Idioma: " . $f->getLanguage() . "</option>
|
<p>".$description."</p>
|
||||||
";
|
</div>
|
||||||
}
|
<li>Duración: ".$duration." minutos</li>
|
||||||
|
<li>Duración: ".$language." minutos</li>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
";
|
||||||
}
|
}
|
||||||
$html .= '</select>';
|
$html .= '<input type="submit" name="select_film" form="'.$this->formID.'" formaction="?state=select_film" class="button large" Value="Seleccionar una Pelicula" /><br>
|
||||||
|
</div>
|
||||||
|
';
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
//Methods:
|
//Methods:
|
||||||
@ -122,10 +131,21 @@ class FormSession extends Form {
|
|||||||
$or_date = $data["or_date"] ;
|
$or_date = $data["or_date"] ;
|
||||||
$or_start = $data["or_start"] ;
|
$or_start = $data["or_start"] ;
|
||||||
|
|
||||||
if (($price == 0 || empty($price))&& isset($data["sumbit"]) ) {
|
if (($price <= 0 || empty($price))&& isset($data["sumbit"]) ) {
|
||||||
$result['price'] = "<li> No puede haber 0 euros. </li> <br>";
|
$result['price'] = "<li> No puede haber 0 o menos euros. </li> <br>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((empty($format))&& isset($data["sumbit"]) ) {
|
||||||
|
$result['format'] = "<li> El formato no puede estar vacio. </li> <br>";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((empty($date))&& isset($data["sumbit"]) ) {
|
||||||
|
$result['date'] = "<li> No hay una fecha seleccionada. </li> <br>";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((empty($start))&& isset($data["sumbit"]) ) {
|
||||||
|
$result['start'] = "<li> No hay una hora inicial seleccionada. </li> <br>";
|
||||||
|
}
|
||||||
|
|
||||||
if (count($result) === 0 && isset($data["sumbit"]) ) {
|
if (count($result) === 0 && isset($data["sumbit"]) ) {
|
||||||
if($this->option == "new_session"){
|
if($this->option == "new_session"){
|
||||||
|
@ -188,14 +188,19 @@
|
|||||||
|
|
||||||
|
|
||||||
foreach($sessions as $session){
|
foreach($sessions as $session){
|
||||||
|
$film = Session::getThisSessionFilm($session->getIdfilm());
|
||||||
$panel .='
|
$panel .='
|
||||||
<tr>
|
<tr>
|
||||||
<td> '.date("H:i", strtotime( $session->getStartTime())).' </td>
|
<td> '.date("H:i", strtotime( $session->getStartTime())).' </td>
|
||||||
<td> '. str_replace('_', ' ', Session::getThisSessionFilm($session->getIdfilm())["tittle"]) .' </td>
|
<td> '. str_replace('_', ' ', $film["tittle"]) .' </td>
|
||||||
<td> '.$session->getFormat().' </td>
|
<td> '.$session->getFormat().' </td>
|
||||||
<td> '.$session->getSeatPrice().' </td>
|
<td> '.$session->getSeatPrice().' </td>
|
||||||
<form method="post" action="./?state=edit_session">
|
<form method="post" action="./?state=edit_session">
|
||||||
<input name="film" type="hidden" value="'.$session->getIdfilm().'">
|
<input name="film" type="hidden" value="'.$session->getIdfilm().'">
|
||||||
|
<input name="tittle" type="hidden" value="'.$film["tittle"].'">
|
||||||
|
<input name="duration" type="hidden" value="'.$film["duration"].'">
|
||||||
|
<input name="language" type="hidden" value="'.$film["language"].'">
|
||||||
|
<input name="description" type="hidden" value="'.$film["description"].'">
|
||||||
<input name="hall" type="hidden" value="'.$session->getIdhall().'">
|
<input name="hall" type="hidden" value="'.$session->getIdhall().'">
|
||||||
<input name="date" type="hidden" value="'.$session->getDate().'">
|
<input name="date" type="hidden" value="'.$session->getDate().'">
|
||||||
<input name="start" type="hidden" value="'.$session->getStartTime().'">
|
<input name="start" type="hidden" value="'.$session->getStartTime().'">
|
||||||
@ -237,8 +242,8 @@
|
|||||||
|
|
||||||
//TODO: estado al modificar sesiones para la seleccion de peliculas usando el template->print films
|
//TODO: estado al modificar sesiones para la seleccion de peliculas usando el template->print films
|
||||||
static function select_film($template,$manager){
|
static function select_film($template,$manager){
|
||||||
if(isset($_GET["option"])){
|
if(isset($_POST["select_film"]) && isset($_POST["option"])){
|
||||||
$_SESSION["option"] = $_GET["option"];
|
$_SESSION["option"] = $_POST["option"];
|
||||||
$panel = '<h1>Seleccionar Pelicula.</h1><hr /></br>';
|
$panel = '<h1>Seleccionar Pelicula.</h1><hr /></br>';
|
||||||
$panel .= $template->print_fimls();
|
$panel .= $template->print_fimls();
|
||||||
$_SESSION["option"] = "";
|
$_SESSION["option"] = "";
|
||||||
@ -252,7 +257,7 @@
|
|||||||
$panel = '<div class="code info">
|
$panel = '<div class="code info">
|
||||||
<h1>No deberias poder acceder aqui.</h1>
|
<h1>No deberias poder acceder aqui.</h1>
|
||||||
<hr />
|
<hr />
|
||||||
<p> No uses la url para toquitear cosas >.< </p>
|
<p> >.< </p>
|
||||||
</div>'."\n";
|
</div>'."\n";
|
||||||
|
|
||||||
return $panel;
|
return $panel;
|
||||||
|
Loading…
Reference in New Issue
Block a user