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
require('./includes/room_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') {
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{
echo "<h2>Crear Sesion</h2>
<form method=\"post\" action=\"validate.php\">
<form method=\"post\" id=\"new_ses\" action=\"validate.php\">
<div class=\"row\">
<fieldset id=\"datos\">
<legend>Datos</legend>
<input type=\"hidden\" name=\"cinema\" value =\"1\" />
<div class=\"_price\">
<input type=\"number\" name=\"price\" id=\"price\" min=\"0\" placeholder=\"Precio de la entrada\" required/>
</div>
<div class=\"_film\">
<input type=\"text\" name=\"film\" id=\"film\" value=\"\" placeholder=\"ID de la pelicula\" required/>
</div>
<div class=\"_format\">
<select name=\"hall\" class=\"button large\">";
foreach($rooms as $r){
if($r->getid() == $_POST['hall']){
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/>
</div>
</fieldset>
@ -26,15 +42,25 @@
<div class=\"_start_time\">
<input type=\"time\" name=\"start\" id=\"start_time\" value=\"\" placeholder=\"Hora de inicio\" required/>
</div>
<div class=\"_date\">
<input type=\"date\" name=\"date\" id=\"date\" value=\"". $_POST['date'] . "\"Fecha de inicio\" required/>
</div>
</fieldset>
<div class=\"actions\">
<input type=\"submit\" id=\"submit\" value=\"Añadir\" class=\"primary\" />
<input type=\"reset\" id=\"reset\" value=\"Borrar\" />
</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:
public function processesForm($price, $film, $format, $start) {
public function processesForm($film, $hall, $cinema, $date, $start, $price, $format) {
$this->correct = true;
$hall = 2;
$cinema = 1;
$date = "2021-04-10";
//Habria que validar todo para que encaje en la base de datos
$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 $size;
private $cinema;
private $hall;
private $date;
//Constructor:
public function __construct($cinema,$hall,$date) {
public function __construct() {
$this->array = array();
$this->cinema = $cinema;
$this->hall = $hall;
$this->date = $date;
}
//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
public function filterList() {
//Update the array with new values
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');
if($bd){
$selectSession = $bd->selectSession($this->cinema, $this->hall, null, $this->date);
$selectSession = $bd->selectSession($cinema, $hall, null, $date);
$selectSession->data_seek(0);
$this->size = 0;
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++;
}
mysqli_free_result($selectSession);

View File

@ -53,17 +53,14 @@
<li>Añadir/Editar/Eliminar:</li>
<ul>
<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>
</div>
<!--Contents -->
<div class="row">
<div class="column middle">
<?php
$panel->showPanel();
?>
<?php $panel->showPanel(); ?>
</div>
</div>
<!-- Footer -->

View File

@ -1,69 +1,84 @@
<?php
require('./includes/room_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');
$sessionList = new ListSessions("1", "1", "2021-04-10");
$sessionList = new ListSessions();
?>
<input type="date" name="fecha" min="2021-01-01" max="2031-12-31">
<?php
$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);
$placeholder_date = date("Y-m-d");
$placeholder_hall = "1";
$filtered = false;
function drawRooms($ros){
echo "<table>";
foreach($ros as $r){
echo "
<tr>
<td> <button type=\"button\"> Sala ". $r->getId() ."</button> </td>
</tr>";
if(isset($_POST['submit'])) {
$sessionList->filterList(1,$_POST["hall"],$_POST["date"]);
$placeholder_date = $_POST["date"];
$placeholder_hall = $_POST["hall"];
$filtered = true;
}
echo "
</table>\n";
}
drawRooms($rooms);
?>
</div>
<div class="column side">
<?php
$sessionList->filterList();
$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 "
<table class='alt'>
<thead>
<tr>
<th>Hora</th>
<th>idPelícula</th>
<th>Pelicula</th>
<th>Formato</th>
<th>Precio</th>
</tr>
</thead>
<tbody>";
foreach($ses as $s){
$fila = ($bd->FilmData($s->getIdfilm()))->fetch_assoc();
echo "
<tr>
<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->getSeatPrice() . "</a></td>
</tr>"
;
</tr>";
}
echo "<tbody>
</table>\n";
echo "<a href=\"./?state=edit_session&option=new\" class='button large'>Añadir</a>";
echo "
<tbody>
</table>";
}
drawSessions($sessions);
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>";
?>
</div>

View File

@ -13,7 +13,7 @@
//Login form validate:
require_once('./includes/formSession.php');
$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();
?>