Add files via upload
This commit is contained in:
95
panel_manager/includes/NewSessionForm.php
Normal file
95
panel_manager/includes/NewSessionForm.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
require_once($prefix.'assets/php/includes/film_dao.php');
|
||||
|
||||
class NewSessionForm {
|
||||
|
||||
public static function getForm(){
|
||||
$films = new Film_DAO("complucine");
|
||||
$filmslist = $films->allFilmData();
|
||||
|
||||
$form='
|
||||
<div id="operation_msg" class="operation_msg"> </div>
|
||||
<form id="new_session_form" name="new_session_form" action="eventos.php.php" method="POST">
|
||||
<div id="global_group" class="form_group"></div>
|
||||
<fieldset>
|
||||
<legend>Datos</legend>
|
||||
<div id="price_group" class="form_group">
|
||||
<input type="number" step="0.01" id="price" name="price" value="" min="0" placeholder="Precio de la entrada" /> <br>
|
||||
</div>
|
||||
<div id="format_group" class="form_group">
|
||||
<input type="text" id="format" name="format" value="" placeholder="Formato de pelicula" /> <br>
|
||||
</div>
|
||||
<div id="hall_group" class="form_group">
|
||||
<select id="hall" name="hall" class="button large">>';
|
||||
foreach(Hall::getListHalls($_SESSION["cinema"]) as $hll){
|
||||
$form.= '
|
||||
<option value="'. $hll->getNumber() .'"> Sala '. $hll->getNumber() .'</option>';
|
||||
}
|
||||
$form.=' </select>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>Horario</legend>
|
||||
<div id="date_group" class="form_group">
|
||||
<div class="two-inputs-line">
|
||||
<label> Fecha inicio </label>
|
||||
<label> Fecha final </label>
|
||||
<input type="date" id="startDate" name="startDate" value=""/>
|
||||
<input type="date" id="endDate" name="endDate" value=""/>
|
||||
</div>
|
||||
</div>
|
||||
<div id="hour_group" class="form_group">
|
||||
<div class="one-input-line">
|
||||
<label> Hora sesion </label>
|
||||
<input type="time" id="startHour" name="startHour" value=""/>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<input type="reset" id="reset" value="Limpiar Campos" >
|
||||
<input type="submit" id="submit" name="sumbit" class="primary" value="Crear" />
|
||||
<div id="film_msg_group" class="form_group"> </div>
|
||||
<div id="film_group" class="form_group">
|
||||
<div class="code showtimes">
|
||||
<input type="hidden" id="film_id" name="film_id" value=""/>
|
||||
<h2 id="film_title"> titulo </h2>
|
||||
<hr />
|
||||
<div class="img_desc">
|
||||
<div class="image"> <img src="../img/films/iron_man.jpg" alt="iron man" id="film_img" /> </div>
|
||||
<div class="blockquote">
|
||||
<p id="film_desc">"Un empresario millonario construye un traje blindado y lo usa para combatir el crimen y el terrorismo."</p>
|
||||
</div>
|
||||
</div>
|
||||
<li id="film_dur"> Duración: duracion minutos</li>
|
||||
<li id="film_lan"> Lenguaje: idioma </li>
|
||||
</div>
|
||||
<button type="button" class="button large" id="return"> Cambiar pelicula </button>
|
||||
</div>
|
||||
<div class="film_list" id="film_list">
|
||||
<ul class="tablelist col3">';
|
||||
$parity = "odd";
|
||||
$i = 0;
|
||||
foreach($filmslist as $film){
|
||||
$form .='<div class="'.$parity.'">
|
||||
<input type="hidden" value="'.$film->getId().'" id="id'.$i.'"/>
|
||||
<input type="hidden" value="'.$film->getImg().'" id="img'.$i.'"/>
|
||||
<input type="hidden" value="'.$film->getLanguage().'" id="lan'.$i.'"/>
|
||||
<input type="hidden" value="'.$film->getDescription().'" id="desc'.$i.'"/>
|
||||
<li value="'.$film->getTittle().'"id="title'.$i.'"> '. str_replace('_', ' ',$film->getTittle()).'</li>
|
||||
<li id="dur'.$i.'"> '.$film->getDuration().' min</li>
|
||||
<li> <button type="button" class="film_button" id="'.$i.'"> Seleccionar </button> </li>
|
||||
</div>
|
||||
';
|
||||
$parity = ($parity == "odd") ? "even" : "odd";
|
||||
$i++;
|
||||
}
|
||||
$form.='
|
||||
</ul>
|
||||
</div>
|
||||
</form>';
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
103
panel_manager/includes/SessionForm.php
Normal file
103
panel_manager/includes/SessionForm.php
Normal file
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
require_once($prefix.'assets/php/includes/film_dao.php');
|
||||
|
||||
class SessionForm {
|
||||
|
||||
public static function getForm(){
|
||||
$films = new Film_DAO("complucine");
|
||||
$filmslist = $films->allFilmData();
|
||||
|
||||
$form='
|
||||
<div id="operation_msg" class="operation_msg"> </div>
|
||||
<form id="session_form" name="session_form" action="eventos.php" method="POST">
|
||||
|
||||
<input type="hidden" id="film_id" name="film_id" value=""/>
|
||||
<input type="hidden" id="original_hall" name="film_id" value=""/>
|
||||
<input type="hidden" id="original_date" name="film_id" value=""/>
|
||||
<input type="hidden" id="original_start_time" name="film_id" value=""/>
|
||||
|
||||
<div id="global_group" class="form_group"></div>
|
||||
<fieldset>
|
||||
<legend>Datos</legend>
|
||||
<div id="price_group" class="form_group">
|
||||
<input type="number" step="0.01" id="price" name="price" value="" min="0" placeholder="Precio de la entrada" /> <br>
|
||||
</div>
|
||||
<div id="format_group" class="form_group">
|
||||
<input type="text" id="format" name="format" value="" placeholder="Formato de pelicula" /> <br>
|
||||
</div>
|
||||
<div id="hall_group" class="form_group">
|
||||
<select id="hall" name="hall" class="button large">>';
|
||||
foreach(Hall::getListHalls($_SESSION["cinema"]) as $hll){
|
||||
$form.= '
|
||||
<option value="'. $hll->getNumber() .'"> Sala '. $hll->getNumber() .'</option>';
|
||||
}
|
||||
$form.=' </select>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>Horario</legend>
|
||||
<div id="date_group" class="form_group">
|
||||
<div class="two-inputs-line">
|
||||
<label> Fecha inicio </label>
|
||||
<label> Fecha final </label>
|
||||
<input type="date" id="startDate" name="startDate" value=""/>
|
||||
<input type="date" id="endDate" name="endDate" value=""/>
|
||||
</div>
|
||||
</div>
|
||||
<div id="hour_group" class="form_group">
|
||||
<div class="one-input-line">
|
||||
<label> Hora sesion </label>
|
||||
<input type="time" id="startHour" name="startHour" value=""/>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<input type="reset" id="reset" value="Limpiar Campos" >
|
||||
<input type="submit" id="sumbit_new" name="sumbit_new" class="sumbit" value="Añadir" />
|
||||
<div class="two-inputs-line" id="edit_inputs">
|
||||
<input type="submit" id="sumbit_edit" name="sumbit_edit" class="sumbit" value="Editar" />
|
||||
<input type="submit" id="submit_del" name="submit_del" class="black button" value="Borrar" />
|
||||
</div>
|
||||
<div id="film_msg_group" class="form_group"> </div>
|
||||
<div id="film_group" class="form_group">
|
||||
<div class="code showtimes">
|
||||
<h2 id="film_title"> titulo </h2>
|
||||
<hr />
|
||||
<div class="img_desc">
|
||||
<div class="image"> <img src="../img/films/iron_man.jpg" alt="iron man" id="film_img" /> </div>
|
||||
<div class="blockquote">
|
||||
<li id="film_dur"> Duración: duracion minutos</li>
|
||||
<li id="film_lan"> Lenguaje: idioma </li>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="button large" id="return"> Cambiar pelicula </button>
|
||||
</div>
|
||||
<div class="film_list" id="film_list">
|
||||
<ul class="tablelist col3">';
|
||||
$parity = "odd";
|
||||
$i = 0;
|
||||
foreach($filmslist as $film){
|
||||
$form .='<div class="'.$parity.'">
|
||||
<input type="hidden" value="'.$film->getId().'" id="id'.$i.'"/>
|
||||
<input type="hidden" value="'.$film->getImg().'" id="img'.$i.'"/>
|
||||
<input type="hidden" value="'.$film->getLanguage().'" id="lan'.$i.'"/>
|
||||
<li value="'.$film->getTittle().'"id="title'.$i.'"> '. str_replace('_', ' ',$film->getTittle()).'</li>
|
||||
<li id="dur'.$i.'"> '.$film->getDuration().' min</li>
|
||||
<li> <button type="button" class="film_button" id="'.$i.'"> Seleccionar </button> </li>
|
||||
</div>
|
||||
';
|
||||
$parity = ($parity == "odd") ? "even" : "odd";
|
||||
$i++;
|
||||
}
|
||||
$form.='
|
||||
</ul>
|
||||
</div>
|
||||
</form>
|
||||
';
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
220
panel_manager/includes/formHall-FER_SURFACE.php
Normal file
220
panel_manager/includes/formHall-FER_SURFACE.php
Normal file
@ -0,0 +1,220 @@
|
||||
<?php
|
||||
include_once($prefix.'assets/php/includes/hall.php');
|
||||
include_once($prefix.'assets/php/includes/seat.php');
|
||||
include_once($prefix.'assets/php/form.php');
|
||||
|
||||
class FormHall extends Form {
|
||||
|
||||
private $option;
|
||||
private $cinema;
|
||||
private $og_hall;
|
||||
|
||||
//Constructor:
|
||||
public function __construct($option, $cinema, $hall) {
|
||||
|
||||
$this->option = $option;
|
||||
$this->cinema = $cinema;
|
||||
if($hall)
|
||||
$this->og_hall = $hall;
|
||||
|
||||
if($option == "edit_hall")
|
||||
$options = array("action" => "./?state=".$option."&number=".$hall->getNumber()."&editing");
|
||||
else
|
||||
$options = array("action" => "./?state=".$option."&number=".$hall->getNumber()."");
|
||||
parent::__construct('formHall',$options);
|
||||
}
|
||||
|
||||
protected function generaCamposFormulario($data, $errores = array()){
|
||||
//Prepare the data
|
||||
$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;
|
||||
$seats_map = array();
|
||||
for($i = 1;$i <= $rows; $i++){
|
||||
for($j = 1; $j <= $cols; $j++){
|
||||
$seats_map[$i][$j] = "-1";
|
||||
}
|
||||
}
|
||||
$alltozero = $_POST["alltozero"] ?? 0;
|
||||
//Show the original seats_map once u click restart or the first time u enter this form from manage_halls's form
|
||||
if($this->option == "edit_hall" && !isset($_GET["editing"])){
|
||||
$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();
|
||||
if($seat->getState()>=0){
|
||||
$seats++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}//Show the checkbox seats_map updated and everything to selected if alltoone was pressed
|
||||
else if(!$alltozero){
|
||||
$alltoone = $_POST["alltoone"] ?? 0;
|
||||
for($i = 1;$i <= $rows; $i++){
|
||||
for($j = 1; $j <= $cols; $j++){
|
||||
if($alltoone || isset($data["checkbox".$i.$j])) {
|
||||
$seats_map[$i][$j] = $data["checkbox".$i.$j] ?? "0";
|
||||
$seats++;
|
||||
if($seats_map[$i][$j] == "-1"){
|
||||
$seats_map[$i][$j] = "0";
|
||||
}
|
||||
}else
|
||||
$seats_map[$i][$j] = "-1";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$htmlErroresGlobales = self::generaListaErroresGlobales($errores);
|
||||
$errorNumber = self::createMensajeError($errores, 'number', 'span', array('class' => 'error'));
|
||||
$errorSeats = self::createMensajeError($errores, 'seats', 'span', array('class' => 'error'));
|
||||
$errorRows = self::createMensajeError($errores, 'rows', 'span', array('class' => 'error'));
|
||||
$errorCols = self::createMensajeError($errores, 'cols', 'span', array('class' => 'error'));
|
||||
|
||||
$html = '
|
||||
<div class="column left">'.$htmlErroresGlobales.'
|
||||
<fieldset>
|
||||
<legend>Mapa de Asientos</legend>
|
||||
'.$errorSeats.' '.$errorRows.' '.$errorCols.'
|
||||
<label> Filas: </label> <input type="number" name="rows" min="1" id="rows" value="'.$rows.'" /> <br>
|
||||
<label> Columnas: </label> <input type="number" name="cols" min="1" id="cols" value="'.$cols.'"/> <br>
|
||||
<label> Asientos totales:'.$seats.' </label> <input type="hidden" name="seats" id="seats" value="'.$seats.'"readonly/> <br>
|
||||
<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><br>
|
||||
'.$errorNumber.'
|
||||
<label> Numero de sala: </label>
|
||||
<input type="number" name="number" id="number" value="'.$number.'" placeholder="Numero de la Sala" /><br>
|
||||
';
|
||||
if($this->option == "new_hall")
|
||||
$html .='<input type="submit" id="submit" name="sumbit" value="Crear Sala" class="primary" />
|
||||
';
|
||||
if($this->option == "edit_hall"){
|
||||
$html .='<input type="submit" id="submit" name="sumbit" value="Editar Sala" class="primary" />
|
||||
<input type="submit" id="submit" name="delete" onclick="return confirm(\'Seguro que quieres borrar esta sala?\')" value="Eliminar Sala" class="black button" />
|
||||
';
|
||||
}
|
||||
if(!$errorCols && !$errorRows){
|
||||
$html .='</div>
|
||||
<div class="column right">
|
||||
<input type="submit" name="alltoone" value="Activar todos los asientos" class="button large" />
|
||||
<input type="submit" name="alltozero" value="Desactivar todos los asientos" class="button large" />
|
||||
<h3 class="table_title"> Pantalla </h3>
|
||||
<table class="seat">
|
||||
<thead>
|
||||
<tr>
|
||||
<th> </th>
|
||||
';
|
||||
for($j = 1; $j<=$cols; $j++){
|
||||
$html .= '<th>'.$j.'</th>
|
||||
';
|
||||
}
|
||||
$html .= '</tr>
|
||||
</thead>
|
||||
<tbody>';
|
||||
for($i = 1;$i<=$rows;$i++){
|
||||
$html .= '
|
||||
<tr>
|
||||
<td>'.$i.'</td>
|
||||
';
|
||||
for($j=1; $j<=$cols; $j++){
|
||||
if($seats_map[$i][$j]>=0){
|
||||
$html .= '<td> <input type="checkbox" class="check_box" name="checkbox'.$i.$j.'" value="'.$seats_map[$i][$j].'" id="checkbox'.$i.$j.'" checked> <label for="checkbox'.$i.$j.'"> </td>
|
||||
';}
|
||||
else {
|
||||
$html .= '<td> <input type="checkbox" class="check_box" name="checkbox'.$i.$j.'" value="'.$seats_map[$i][$j].'" id="checkbox'.$i.$j.'" > <label for="checkbox'.$i.$j.'"> </td>
|
||||
';}
|
||||
}
|
||||
$html .='</tr>';
|
||||
}
|
||||
|
||||
$html .= '
|
||||
</tbody>
|
||||
</table>
|
||||
</div>';
|
||||
} else
|
||||
$html .='</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
//Methods:
|
||||
|
||||
//Process form:
|
||||
protected function procesaFormulario($datos){
|
||||
$result = array();
|
||||
|
||||
$rows = $datos['rows'];
|
||||
$cols = $datos['cols'];
|
||||
|
||||
//Prepare the seat_map
|
||||
$seats_map = array();
|
||||
$seats = 0;
|
||||
for($i = 1;$i <= $rows; $i++){
|
||||
for($j = 1; $j <= $cols; $j++){
|
||||
if(isset($datos["checkbox".$i.$j])){
|
||||
$seats_map[$i][$j] = $datos["checkbox".$i.$j];
|
||||
$seats++;
|
||||
if($seats_map[$i][$j] == "-1"){
|
||||
$seats_map[$i][$j] = "0";
|
||||
}
|
||||
}else{
|
||||
$seats_map[$i][$j] = "-1";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($seats == 0 && isset($datos["sumbit"]) ) {
|
||||
$result['seats'] = "<li> No puede haber 0 asientos disponibles. </li> <br>";
|
||||
}
|
||||
|
||||
if ($rows <= 0) {
|
||||
$result['rows'] = "<li> No puede haber 0 o menos filas. </li> <br>";
|
||||
}
|
||||
|
||||
if ($cols <= 0) {
|
||||
$result['cols'] = "<li> No puede haber 0 o menos columnas. </li> <br>";
|
||||
}
|
||||
|
||||
|
||||
$number = $datos['number'] ?? null;
|
||||
if (empty($number) && isset($datos["sumbit"])) {
|
||||
$result['number'] = "<li> El numero de sala tiene que ser mayor que 0. </li> <br>";
|
||||
}
|
||||
|
||||
if(isset($datos["restart"])){
|
||||
return $result = "./?state=".$this->option."&number=".$this->og_hall->getNumber()."";
|
||||
}
|
||||
|
||||
if (count($result) === 0 && isset($datos["sumbit"]) ) {
|
||||
if($this->option == "new_hall"){
|
||||
$_SESSION['msg'] = Hall::create_hall($number, $this->cinema, $rows, $cols, $seats, $seats_map);
|
||||
return $result = './?state=success';
|
||||
}
|
||||
if($this->option == "edit_hall"){
|
||||
$_SESSION['msg'] = Hall::edit_hall($number,$this->cinema, $rows, $cols, $seats, $seats_map, $this->og_hall->getNumber());
|
||||
return $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, $this->og_hall->getNumber());
|
||||
return $result = './?state=success';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
226
panel_manager/includes/formHall.php
Normal file
226
panel_manager/includes/formHall.php
Normal file
@ -0,0 +1,226 @@
|
||||
<?php
|
||||
include_once($prefix.'assets/php/includes/hall.php');
|
||||
include_once($prefix.'assets/php/includes/seat.php');
|
||||
include_once($prefix.'assets/php/form.php');
|
||||
|
||||
class FormHall extends Form {
|
||||
|
||||
private $option;
|
||||
private $cinema;
|
||||
private $og_hall;
|
||||
|
||||
//Constructor:
|
||||
public function __construct($option, $cinema, $hall) {
|
||||
|
||||
$this->option = $option;
|
||||
$this->cinema = $cinema;
|
||||
if($hall)
|
||||
$this->og_hall = $hall;
|
||||
|
||||
if($option == "edit_hall" && $hall)
|
||||
$options = array("action" => "./?state=".$option."&number=".$hall->getNumber()."&editing=true");
|
||||
else
|
||||
$options = array("action" => "./?state=".$option."&editing=false");
|
||||
parent::__construct('formHall',$options);
|
||||
}
|
||||
|
||||
protected function generaCamposFormulario($data, $errores = array()){
|
||||
//Prepare the data
|
||||
$number = $data['number'] ?? $this->og_hall->getNumber() ?? "";
|
||||
$rows = $data['rows'] ?? $this->og_hall->getNumRows() ?? "12";
|
||||
$cols = $data['cols'] ?? $this->og_hall->getNumCol() ?? "8";
|
||||
|
||||
//Init Seats_map
|
||||
$seats = 0;
|
||||
$seats_map = array();
|
||||
for($i = 1;$i <= $rows; $i++){
|
||||
for($j = 1; $j <= $cols; $j++){
|
||||
$seats_map[$i][$j] = "-1";
|
||||
}
|
||||
}
|
||||
$alltozero = $_POST["alltozero"] ?? 0;
|
||||
//Show the original seats_map once u click restart or the first time u enter this form from manage_halls's form
|
||||
if($this->option == "edit_hall" && !isset($_GET["editing"])){
|
||||
$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();
|
||||
if($seat->getState()>=0){
|
||||
$seats++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}//Show the checkbox seats_map updated and everything to selected if alltoone was pressed
|
||||
else if(!$alltozero){
|
||||
$alltoone = $_POST["alltoone"] ?? 0;
|
||||
for($i = 1;$i <= $rows; $i++){
|
||||
for($j = 1; $j <= $cols; $j++){
|
||||
if($alltoone || isset($data["checkbox".$i.$j])) {
|
||||
$seats_map[$i][$j] = $data["checkbox".$i.$j] ?? "0";
|
||||
$seats++;
|
||||
if($seats_map[$i][$j] == "-1"){
|
||||
$seats_map[$i][$j] = "0";
|
||||
}
|
||||
}else
|
||||
$seats_map[$i][$j] = "-1";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$htmlErroresGlobales = self::generaListaErroresGlobales($errores);
|
||||
$errorNumber = self::createMensajeError($errores, 'number', 'span', array('class' => 'error'));
|
||||
$errorSeats = self::createMensajeError($errores, 'seats', 'span', array('class' => 'error'));
|
||||
$errorRows = self::createMensajeError($errores, 'rows', 'span', array('class' => 'error'));
|
||||
$errorCols = self::createMensajeError($errores, 'cols', 'span', array('class' => 'error'));
|
||||
|
||||
$html = '
|
||||
<div class="column left">'.$htmlErroresGlobales.'
|
||||
<fieldset>
|
||||
<legend>Mapa de Asientos</legend>
|
||||
'.$errorSeats.' '.$errorRows.' '.$errorCols.'
|
||||
<label> Filas: </label> <input type="number" name="rows" min="1" id="rows" value="'.$rows.'" /> <br>
|
||||
<label> Columnas: </label> <input type="number" name="cols" min="1" id="cols" value="'.$cols.'"/> <br>
|
||||
<label> Asientos totales:'.$seats.' </label> <input type="hidden" name="seats" id="seats" value="'.$seats.'"readonly/> <br>
|
||||
<input type="submit" name="filter" value="Actualizar mapa de la sala" class="button large" />
|
||||
';
|
||||
$html .='
|
||||
</fieldset><br>
|
||||
'.$errorNumber.'
|
||||
<label> Numero de sala: </label>
|
||||
<input type="number" name="number" id="number" value="'.$number.'" placeholder="Numero de la Sala" /><br>
|
||||
';
|
||||
if($this->option == "new_hall")
|
||||
$html .='<input type="submit" id="submit" name="sumbit" value="Crear Sala" class="primary" />
|
||||
';
|
||||
if($this->option == "edit_hall"){
|
||||
$html .='<input type="submit" id="submit" name="sumbit" value="Editar Sala" class="primary" />
|
||||
<input type="submit" id="submit" name="delete" onclick="return confirm(\'Seguro que quieres borrar esta sala?\')" value="Eliminar Sala" class="black button" />
|
||||
';
|
||||
}
|
||||
if(!$errorCols && !$errorRows){
|
||||
$html .='</div>
|
||||
<div class="column right">
|
||||
<input type="submit" name="alltoone" value="Activar todos los asientos" class="button large" />
|
||||
<input type="submit" name="alltozero" value="Desactivar todos los asientos" class="button large" />
|
||||
<h3 class="table_title"> Pantalla </h3>
|
||||
<table class="seat">
|
||||
<thead>
|
||||
<tr>
|
||||
<th> </th>
|
||||
';
|
||||
for($j = 1; $j<=$cols; $j++){
|
||||
$html .= '<th>'.$j.'</th>
|
||||
';
|
||||
}
|
||||
$html .= '</tr>
|
||||
</thead>
|
||||
<tbody>';
|
||||
for($i = 1;$i<=$rows;$i++){
|
||||
$html .= '
|
||||
<tr>
|
||||
<td>'.$i.'</td>
|
||||
';
|
||||
for($j=1; $j<=$cols; $j++){
|
||||
if($seats_map[$i][$j]>=0){
|
||||
$html .= '<td> <input type="checkbox" class="check_box" name="checkbox'.$i.$j.'" value="'.$seats_map[$i][$j].'" id="checkbox'.$i.$j.'" checked> <label for="checkbox'.$i.$j.'"> </td>
|
||||
';}
|
||||
else {
|
||||
$html .= '<td> <input type="checkbox" class="check_box" name="checkbox'.$i.$j.'" value="'.$seats_map[$i][$j].'" id="checkbox'.$i.$j.'" > <label for="checkbox'.$i.$j.'"> </td>
|
||||
';}
|
||||
}
|
||||
$html .='</tr>';
|
||||
}
|
||||
|
||||
$html .= '
|
||||
</tbody>
|
||||
</table>
|
||||
</div>';
|
||||
} else
|
||||
$html .='</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
//Process form:
|
||||
protected function procesaFormulario($datos){
|
||||
$result = array();
|
||||
|
||||
$rows = $datos['rows'];
|
||||
$cols = $datos['cols'];
|
||||
|
||||
//Prepare the seat_map
|
||||
$seats_map = array();
|
||||
$seats = 0;
|
||||
for($i = 1;$i <= $rows; $i++){
|
||||
for($j = 1; $j <= $cols; $j++){
|
||||
if(isset($datos["checkbox".$i.$j])){
|
||||
$seats_map[$i][$j] = $datos["checkbox".$i.$j];
|
||||
$seats++;
|
||||
if($seats_map[$i][$j] == "-1"){
|
||||
$seats_map[$i][$j] = "0";
|
||||
}
|
||||
}else{
|
||||
$seats_map[$i][$j] = "-1";
|
||||
}
|
||||
}
|
||||
}
|
||||
//Check input errors
|
||||
if ($seats == 0 && isset($datos["sumbit"]) ) {
|
||||
$result['seats'] = "<li> No puede haber 0 asientos disponibles. </li> <br>";
|
||||
}
|
||||
if ($rows <= 0) {
|
||||
$result['rows'] = "<li> No puede haber 0 o menos filas. </li> <br>";
|
||||
}
|
||||
if ($cols <= 0) {
|
||||
$result['cols'] = "<li> No puede haber 0 o menos columnas. </li> <br>";
|
||||
}
|
||||
|
||||
$number = $datos['number'] ?? null;
|
||||
if (empty($number) && isset($datos["sumbit"])) {
|
||||
$result['number'] = "<li> El numero de sala tiene que ser mayor que 0. </li> <br>";
|
||||
}
|
||||
else if (count($result) === 0 && isset($datos["sumbit"]) ) {
|
||||
if($this->option == "new_hall"){
|
||||
$msg = Hall::create_hall($number, $this->cinema, $rows, $cols, $seats, $seats_map);
|
||||
FormHall::prepare_message( $msg );
|
||||
}
|
||||
else if($this->option == "edit_hall"){
|
||||
if($this->og_hall)
|
||||
$msg = Hall::edit_hall($number,$this->cinema, $rows, $cols, $seats, $seats_map, $this->og_hall->getNumber());
|
||||
else
|
||||
$msg = "La sala que intentas editar ya no existe";
|
||||
|
||||
FormHall::prepare_message( $msg );
|
||||
}
|
||||
}
|
||||
else if (!isset($result['number']) && isset($datos["delete"]) ) {
|
||||
if($this->option == "edit_hall"){
|
||||
$msg = Hall::delete_hall($number, $this->cinema, $rows, $cols, $seats, $seats_map, $this->og_hall->getNumber());
|
||||
FormHall::prepare_message( $msg );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function prepare_message( $msg ){
|
||||
$_SESSION['message'] = "<div class='row'>
|
||||
<div class='column side'></div>
|
||||
<div class='column middle'>
|
||||
<div class='code info'>
|
||||
<h1> Operacion Completada </h1><hr />
|
||||
<p>".$msg."</p>
|
||||
<a href='./index.php?state=manage_halls'><button>Cerrar Mensaje</button></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class='column side'></div>
|
||||
</div>
|
||||
";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
170
panel_manager/includes/formSession.php
Normal file
170
panel_manager/includes/formSession.php
Normal file
@ -0,0 +1,170 @@
|
||||
<?php
|
||||
require_once($prefix.'assets/php/includes/session_dao.php');
|
||||
require_once($prefix.'assets/php/includes/session.php');
|
||||
require_once($prefix.'assets/php/form.php');
|
||||
|
||||
//Receive data from froms and prepare the correct response
|
||||
class FormSession extends Form {
|
||||
|
||||
private $option;
|
||||
private $cinema;
|
||||
private $formID;
|
||||
|
||||
//Constructor:
|
||||
public function __construct($option, $cinema) {
|
||||
$this->option = $option;
|
||||
$this->cinema = $cinema;
|
||||
$this->formID = 'formSession1';
|
||||
|
||||
$options = array("action" => "./?state=".$option);
|
||||
parent::__construct('formSession',$options);
|
||||
}
|
||||
|
||||
//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()){
|
||||
|
||||
$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_date = $data["or_date"] ?? $date;
|
||||
$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);
|
||||
$errorPrice = self::createMensajeError($errores, 'price', '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 = '
|
||||
<div class="column left">'.$htmlErroresGlobales.'
|
||||
<fieldset>
|
||||
<legend>Datos</legend>
|
||||
'.$errorPrice.'
|
||||
<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="option" value="'.$this->option.'"/>
|
||||
<select name="hall" class="button large">';
|
||||
foreach(Hall::getListHalls($this->cinema) as $hll){
|
||||
if($hll->getNumber() == $hall){
|
||||
$html.= '
|
||||
<option value="'. $hll->getNumber() .'"selected> Sala '. $hll->getNumber() .'</option> ';
|
||||
}else{
|
||||
$html.= '
|
||||
<option value="'. $hll->getNumber() .'"> Sala '. $hll->getNumber() .'</option>';
|
||||
}
|
||||
}
|
||||
$html.= '
|
||||
</select>
|
||||
<input type="hidden" name="or_hall" value="'.$or_hall.'"/>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>Horario</legend>
|
||||
'.$errorStart.'
|
||||
<input type="time" name="start" value="'.$start.'" placeholder="Hora de inicio"/> <br>
|
||||
<input type="hidden" name="or_start" value="'.$or_start.'"/>
|
||||
'.$errorDate.'
|
||||
<input type="date" name="date" value="'.$date.'" placeholder="Fecha de inicio" /> <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>
|
||||
<input type="submit" id="submit" name="sumbit" class="primary" value="Crear" /> <br>';
|
||||
|
||||
if($this->option == "edit_session"){
|
||||
$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' id='reset' value='Limpiar Campos' >
|
||||
</form>
|
||||
</div>
|
||||
<div class='column side'>";
|
||||
if($film){
|
||||
$html .= "<section id='".$tittle."'>
|
||||
<div class='code showtimes'>
|
||||
<div class='image'><img src='../img/films/".$tittle.".jpg' alt='".$tittle."' /></div>
|
||||
<h2>".str_replace('_', ' ',$tittle)."</h2>
|
||||
<hr />
|
||||
<div class='blockquote'>
|
||||
<p>".$description."</p>
|
||||
</div>
|
||||
<li>Duración: ".$duration." minutos</li>
|
||||
<li>Duración: ".$language." minutos</li>
|
||||
</div>
|
||||
</section>
|
||||
";
|
||||
}
|
||||
$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;
|
||||
}
|
||||
//Methods:
|
||||
|
||||
//Process form:
|
||||
protected function procesaFormulario($data){
|
||||
$result = array();
|
||||
|
||||
$film = $data['film'] ;
|
||||
$hall = $data['hall'] ;
|
||||
$date = $data['date'] ;
|
||||
$start = $data['start'];
|
||||
$price = $data['price'] ;
|
||||
$format = $data['format'] ;
|
||||
$repeat = $data['repeat'] ?? 0;
|
||||
$or_hall = $data["or_hall"] ;
|
||||
$or_date = $data["or_date"] ;
|
||||
$or_start = $data["or_start"] ;
|
||||
|
||||
if (($price <= 0 || empty($price))&& isset($data["sumbit"]) ) {
|
||||
$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($this->option == "new_session"){
|
||||
$_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($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($this->cinema, $or_hall, $or_start, $or_date);
|
||||
$result = './?state=success';
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
65
panel_manager/includes/processForm.php
Normal file
65
panel_manager/includes/processForm.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
//General Config File:
|
||||
require_once('../../assets/php/config.php');
|
||||
|
||||
$prefix ="../../";
|
||||
include_once('formHall.php');
|
||||
include_once('formSession.php');
|
||||
|
||||
if(isset($_POST['new_hall'])){
|
||||
$data = array("option" => "new_hall","number" => $_POST["number"],"cols" => $_POST["cols"],"rows" => $_POST["rows"], "cinema" => $_SESSION["cinema"], "seats" => 0);
|
||||
//Check what checkboxs are seats or not
|
||||
for($i = 1;$i<=$data["rows"];$i++){
|
||||
for($j=1; $j<=$data["cols"]; $j++){
|
||||
if(!empty($_POST['checkbox'.$i.$j.''])){
|
||||
$data[$i][$j] = $_POST['checkbox'.$i.$j.''];
|
||||
$data["seats"]++;
|
||||
} else $data[$i][$j] = "-1";
|
||||
}
|
||||
}
|
||||
FormHall::processesForm($data);
|
||||
}
|
||||
|
||||
if(isset($_POST['edit_hall'])){
|
||||
$data = array("option" => "edit_hall","number" => $_POST["number"],"cols" => $_POST["cols"],"rows" => $_POST["rows"], "cinema" => $_SESSION["cinema"],"seats" => 0);
|
||||
//Check what checkboxs are seats or not
|
||||
for($i = 1;$i<=$data["rows"];$i++){
|
||||
for($j=1; $j<=$data["cols"]; $j++){
|
||||
if(!empty($_POST['checkbox'.$i.$j.''])){
|
||||
$data[$i][$j] = $_POST['checkbox'.$i.$j.''];
|
||||
$data["seats"]++;
|
||||
} else $data[$i][$j] = "-1";
|
||||
}
|
||||
}
|
||||
FormHall::processesForm($data);
|
||||
}
|
||||
|
||||
if(isset($_POST['delete_hall'])){
|
||||
$data = array("option" => "delete_hall","number" => $_POST["number"], "cinema" => $_SESSION["cinema"]);
|
||||
FormHall::processesForm($data);
|
||||
}
|
||||
|
||||
if(isset($_POST['new_session'])){
|
||||
$data = array("option" => "new_session","film" => $_POST["film"],"hall" => $_POST["hall"],"date" => $_POST["date"],"start" => $_POST["start"]
|
||||
,"price" => $_POST["price"],"format" => $_POST["format"],"repeat" => $_POST["repeat"], "cinema" => $_SESSION["cinema"]);
|
||||
FormSession::processesForm($data);
|
||||
}
|
||||
|
||||
if(isset($_POST['edit_session'])){
|
||||
$data = array("option" => "edit_session","film" => $_POST["film"],"hall" => $_POST["hall"],"date" => $_POST["date"],"start" => $_POST["start"]
|
||||
,"price" => $_POST["price"],"format" => $_POST["format"],"repeat" => $_POST["repeat"], "cinema" => $_SESSION["cinema"]
|
||||
, "origin_hall"=>$_SESSION["or_hall"],"origin_date"=> $_SESSION["or_date"],"origin_start"=> $_SESSION["or_start"]);
|
||||
|
||||
$_SESSION["or_hall"] = "";
|
||||
$_SESSION["or_date"] = "";
|
||||
$_SESSION["or_start"] = "";
|
||||
FormSession::processesForm($data);
|
||||
}
|
||||
|
||||
if(isset($_POST['delete_session'])){
|
||||
$data = array("option" => "delete_session","cinema" => $_SESSION["cinema"], "hall"=> $_POST["origin_hall"]
|
||||
,"date"=> $_POST["origin_date"],"start"=> $_POST["origin_start"]);
|
||||
FormSession::processesForm($data);
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user