Add files via upload

This commit is contained in:
Markines16 2021-04-11 17:58:01 +02:00 committed by GitHub
parent d04592392d
commit b072147e03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 174 additions and 98 deletions

View File

@ -1,23 +1,39 @@
<?php <?php
require('./includes/room_dto.php'); require('./includes/room_dto.php');
require('./includes/session_dto.php'); require('./includes/session_dto.php');
require('../panel_admin/includes/film_dto.php');
$r1 = new RoomDTO(1,20,20,30); //Esto se deberia cambiar por una llamada a una lista de salas
$r2 = new RoomDTO(2,10,30,30);
$rooms = array($r1, $r2);
require_once('./includes/listFilms.php');
$filmList = new ListFilms();
$films = $filmList->getArray();
if(isset($_REQUEST['option']) && $_REQUEST['option'] == 'edit') { if(isset($_REQUEST['option']) && $_REQUEST['option'] == 'edit') {
echo "<p> Este es el panel de editar o eliminar una sesion. Deberia tener el formulario de crear una sesion nueva pero con los datos ya situados y quizas que solo aqui aparezca el boton de eliminar </p>"; echo "<p> Este es el panel de editar o eliminar una sesion. Deberia tener el formulario de crear una sesion nueva pero con los datos ya situados y quizas que solo aqui aparezca el boton de eliminar </p>";
} }
else{ else{
echo "<h2>Crear Sesion</h2> echo "<h2>Crear Sesion</h2>
<form method=\"post\" action=\"validate.php\"> <form method=\"post\" id=\"new_ses\" action=\"validate.php\">
<div class=\"row\"> <div class=\"row\">
<fieldset id=\"datos\"> <fieldset id=\"datos\">
<legend>Datos</legend> <legend>Datos</legend>
<input type=\"hidden\" name=\"cinema\" value =\"1\" />
<div class=\"_price\"> <div class=\"_price\">
<input type=\"number\" name=\"price\" id=\"price\" min=\"0\" placeholder=\"Precio de la entrada\" required/> <input type=\"number\" name=\"price\" id=\"price\" min=\"0\" placeholder=\"Precio de la entrada\" required/>
</div> </div>
<div class=\"_film\"> <select name=\"hall\" class=\"button large\">";
<input type=\"text\" name=\"film\" id=\"film\" value=\"\" placeholder=\"ID de la pelicula\" required/> foreach($rooms as $r){
</div> if($r->getid() == $_POST['hall']){
<div class=\"_format\"> echo "<option value=\"". $r->getid() ." \"selected> Sala ". $r->getid() . "</option>";
}else{
echo "<option value=\"". $r->getid() ." \"> Sala ". $r->getid() . "</option>";
}
}
echo "<div class=\"_format\">
<input type=\"text\" name=\"format\" id=\"format\" value=\"\" placeholder=\"Formato\" required/> <input type=\"text\" name=\"format\" id=\"format\" value=\"\" placeholder=\"Formato\" required/>
</div> </div>
</fieldset> </fieldset>
@ -26,15 +42,25 @@
<div class=\"_start_time\"> <div class=\"_start_time\">
<input type=\"time\" name=\"start\" id=\"start_time\" value=\"\" placeholder=\"Hora de inicio\" required/> <input type=\"time\" name=\"start\" id=\"start_time\" value=\"\" placeholder=\"Hora de inicio\" required/>
</div> </div>
<div class=\"_date\">
<input type=\"date\" name=\"date\" id=\"date\" value=\"". $_POST['date'] . "\"Fecha de inicio\" required/>
</div>
</fieldset> </fieldset>
<div class=\"actions\"> <div class=\"actions\">
<input type=\"submit\" id=\"submit\" value=\"Añadir\" class=\"primary\" /> <input type=\"submit\" id=\"submit\" value=\"Añadir\" class=\"primary\" />
<input type=\"reset\" id=\"reset\" value=\"Borrar\" /> <input type=\"reset\" id=\"reset\" value=\"Borrar\" />
</div> </div>
</div> </div>
</form>"; </form>
<div>
<div class=\"column side\">
<select name=\"film\" form=\"new_ses\" class=\"button large\">";
foreach($films as $f){
echo "<option value=\"". $f->getId() ." \"> " . $f->getId() . "|" . $f->getTittle() ." Idioma: " . $f->getLanguage() . "</option>";
} }
echo "</div>" echo "</div>";
}
?> ?>

View File

@ -35,11 +35,8 @@ class FormSession extends Form {
} }
//Process form: //Process form:
public function processesForm($price, $film, $format, $start) { public function processesForm($film, $hall, $cinema, $date, $start, $price, $format) {
$this->correct = true; $this->correct = true;
$hall = 2;
$cinema = 1;
$date = "2021-04-10";
//Habria que validar todo para que encaje en la base de datos //Habria que validar todo para que encaje en la base de datos
$start = date('H:i:s', strtotime( $start ) ); $start = date('H:i:s', strtotime( $start ) );

View File

@ -0,0 +1,53 @@
<?php
require('../panel_admin/includes/film_dao.php');
class ListFilms{
//Atributes:
private $array;
private $size;
//Constructor:
public function __construct() {
$this->array = array();
$this->updateArray();
}
//Methods:
//Returns the whole session array
public function getArray() {
return $this->array;
}
//Returns the value i from the array
public function getiArray($i) {
if($i < $size){
return $this->array($i);
} else {
return null;
}
}
//Update the array with new values
public function updateArray() {
$bd = new Film_DAO('complucine');
if($bd){
$selectFilms = $bd->allFilmData();
$selectFilms->data_seek(0);
$this->size = 0;
while ($fila = $selectFilms->fetch_assoc()) {
$this->array[]= new Film_DTO($fila['id'], $fila['tittle'], $fila['duration'], $fila['language'], "no hay descripcion en la base de datos");
$this->size++;
}
mysqli_free_result($selectFilms);
}
}
}
?>

View File

@ -9,17 +9,9 @@ class ListSessions{
private $array; private $array;
private $size; private $size;
private $cinema;
private $hall;
private $date;
//Constructor: //Constructor:
public function __construct($cinema,$hall,$date) { public function __construct() {
$this->array = array(); $this->array = array();
$this->cinema = $cinema;
$this->hall = $hall;
$this->date = $date;
} }
//Methods: //Methods:
@ -37,24 +29,20 @@ class ListSessions{
} }
} }
//Change the patterns of the filter
public function setCinema($cinema){$this->cinema = $cinema;}
public function setHall($hall){$this->hall = $hall;}
public function setDate($date){$this->date = $date;}
//Update the array with current filter values //Update the array with new values
public function filterList() { public function filterList($cinema, $hall, $date) {
$this->date = date('Y-m-d', strtotime( $this->date ) ); $date = date('Y-m-d', strtotime( $date ) );
$bd = new sessionDAO('complucine'); $bd = new sessionDAO('complucine');
if($bd){ if($bd){
$selectSession = $bd->selectSession($this->cinema, $this->hall, null, $this->date); $selectSession = $bd->selectSession($cinema, $hall, null, $date);
$selectSession->data_seek(0); $selectSession->data_seek(0);
$this->size = 0; $this->size = 0;
while ($fila = $selectSession->fetch_assoc()) { while ($fila = $selectSession->fetch_assoc()) {
$this->array[]= new SessionDTO($fila['id'], $fila['idfilm'], $fila['idhall'], $fila['idcinema'], $fila['date'], date('h:i', strtotime( $fila['start_time'])) , $fila['seat_price'], $fila['format']); $this->array[]= new SessionDTO($fila['id'], $fila['idfilm'], $fila['idhall'], $fila['idcinema'], $fila['date'], date('H:i', strtotime( $fila['start_time'])) , $fila['seat_price'], $fila['format']);
$this->size++; $this->size++;
} }
mysqli_free_result($selectSession); mysqli_free_result($selectSession);

View File

@ -53,17 +53,14 @@
<li>Añadir/Editar/Eliminar:</li> <li>Añadir/Editar/Eliminar:</li>
<ul> <ul>
<li><a href='./?state=rooms'>Salas</a></li> <li><a href='./?state=rooms'>Salas</a></li>
<li><a href='./?state=sessions&login=".$this->login."'>Sesiones</a></li> <li><a href='./?state=sessions'>Sesiones</a></li>
</ul> </ul>
</ul> </ul>
</div> </div>
<!--Contents --> <!--Contents -->
<div class="row"> <div class="row">
<div class="column middle"> <div class="column middle">
<?php <?php $panel->showPanel(); ?>
$panel->showPanel();
?>
</div> </div>
</div> </div>
<!-- Footer --> <!-- Footer -->

View File

@ -1,69 +1,84 @@
<?php <?php
require('./includes/room_dto.php'); require('./includes/room_dto.php');
require('./includes/session_dto.php'); require('./includes/session_dto.php');
require('../panel_admin/includes/film_dto.php');
require('../panel_admin/includes/film_dao.php');
//Login form validate:
require_once('./includes/listSessions.php'); require_once('./includes/listSessions.php');
$sessionList = new ListSessions("1", "1", "2021-04-10"); $sessionList = new ListSessions();
?> $placeholder_date = date("Y-m-d");
<input type="date" name="fecha" min="2021-01-01" max="2031-12-31"> $placeholder_hall = "1";
<?php $filtered = false;
$r1 = new RoomDTO(0,20,20,30);
$r2 = new RoomDTO(1,10,30,30);
$r3 = new RoomDTO(2,30,10,30);
$r4 = new RoomDTO(3,15,15,30);
$rooms = array($r1, $r2, $r3, $r4);
function drawRooms($ros){ if(isset($_POST['submit'])) {
echo "<table>"; $sessionList->filterList(1,$_POST["hall"],$_POST["date"]);
foreach($ros as $r){ $placeholder_date = $_POST["date"];
echo " $placeholder_hall = $_POST["hall"];
<tr> $filtered = true;
<td> <button type=\"button\"> Sala ". $r->getId() ."</button> </td>
</tr>";
} }
echo "
</table>\n";
}
drawRooms($rooms);
?>
</div>
<div class="column side">
<?php
$sessionList->filterList();
$sessions = $sessionList->getArray(); $sessions = $sessionList->getArray();
function drawSessions($ses){ $r1 = new RoomDTO(1,20,20,30); //Esto se deberia cambiar por una llamada a una lista de salas
$r2 = new RoomDTO(2,10,30,30);
$rooms = array($r1, $r2);
echo"
<form method=\"post\">
<input type=\"date\" name=\"date\" value=\"". $placeholder_date . "\" min=\"2021-01-01\" max=\"2031-12-31\">
<select name=\"hall\" class=\"button large\">";
foreach($rooms as $r){
if($r->getid() == $placeholder_hall){
echo "
<option value=\"". $r->getid() ." \"selected> Sala ". $r->getid() . "</option>";
}else{
echo "
<option value=\"". $r->getid() ." \"> Sala ". $r->getid() . "</option>";
}
}
echo "
<input type=\"submit\" name=\"submit\" value=\"Filtrar\" class=\"button large\" />
</div>";
?>
<div class="column side"> <?php
function drawSessions($ses,$bd){
echo " echo "
<table class='alt'> <table class='alt'>
<thead> <thead>
<tr> <tr>
<th>Hora</th> <th>Hora</th>
<th>idPelícula</th> <th>Pelicula</th>
<th>Formato</th> <th>Formato</th>
<th>Precio</th> <th>Precio</th>
</tr> </tr>
</thead> </thead>
<tbody>"; <tbody>";
foreach($ses as $s){ foreach($ses as $s){
$fila = ($bd->FilmData($s->getIdfilm()))->fetch_assoc();
echo " echo "
<tr> <tr>
<td><a href=\"./?state=edit_session&option=edit\">" . $s->getStartTime() . "</a></td> <td><a href=\"./?state=edit_session&option=edit\">" . $s->getStartTime() . "</a></td>
<td><a href=\"./?state=edit_session&option=edit\">" . $s->getIdfilm() . "</a></td> <td><a href=\"./?state=edit_session&option=edit\">" .$fila['tittle'] . "</a></td>
<td><a href=\"./?state=edit_session&option=edit\">" . $s->getFormat() . "</a></td> <td><a href=\"./?state=edit_session&option=edit\">" . $s->getFormat() . "</a></td>
<td><a href=\"./?state=edit_session&option=edit\">". $s->getSeatPrice() . "</a></td> <td><a href=\"./?state=edit_session&option=edit\">". $s->getSeatPrice() . "</a></td>
</tr>";
}
echo "
<tbody>
</table>";
}
if($filtered){
$bd = new Film_DAO('complucine');
if($bd){
drawSessions($sessions,$bd);
echo "
<input type=\"submit\" name=\"submit\" value=\"Añadir\" class=\"button large\" formaction=\"./?state=edit_session&option=new\"/>\n";
}
}
echo " </form>
</div>";
?>
</tr>"
;
}
echo "<tbody>
</table>\n";
echo "<a href=\"./?state=edit_session&option=new\" class='button large'>Añadir</a>";
}
drawSessions($sessions);
?>
</div>

View File

@ -13,7 +13,7 @@
//Login form validate: //Login form validate:
require_once('./includes/formSession.php'); require_once('./includes/formSession.php');
$session = new FormSession(); $session = new FormSession();
$session->processesForm($_POST["price"], $_POST["film"], $_POST["format"],$_POST["start"]); $session->processesForm($_POST["film"], $_POST["hall"], $_POST["cinema"],$_POST["date"],$_POST["start"],$_POST["price"],$_POST["format"]);
$reply = $session->getReply(); $reply = $session->getReply();
?> ?>