SW/panel_manager/manage_sessions.php

110 lines
3.7 KiB
PHP
Raw Normal View History

<?php
//General Config File:
require_once('../assets/php/config.php');
include_once('./includes/hall_dto.php');
include_once('./includes/formHall.php');
include_once('./includes/session_dto.php');
include_once('./includes/formSession.php');
2021-04-14 19:59:52 +02:00
include_once('../panel_admin/includes/film_dto.php');
include_once('../panel_admin/includes/film_dao.php');
$formSession = new FormSession();
$formHall = new FormHall();
2021-04-11 17:58:01 +02:00
$placeholder_date = date("Y-m-d");
$placeholder_hall = "1";
2021-04-15 22:34:33 +02:00
$_SESSION["cinema"] = "1";
2021-04-14 19:59:52 +02:00
if(isset($_POST['filter'])) {
2021-04-11 17:58:01 +02:00
$placeholder_date = $_POST["date"];
$placeholder_hall = $_POST["hall"];
}
2021-04-14 19:59:52 +02:00
2021-04-15 22:34:33 +02:00
$formHall->processesForm(null, $_SESSION["cinema"], null, null, "list");
$formSession->processesForm(null, $placeholder_hall, $_SESSION["cinema"], $placeholder_date, null, null, null, null, "list");
2021-04-14 19:59:52 +02:00
echo"
<!--Session Filter -->
<div class = \"column middle\">
<form method=\"post\" id=\"addfilter\">
2021-04-11 17:58:01 +02:00
<input type=\"date\" name=\"date\" value=\"". $placeholder_date . "\" min=\"2021-01-01\" max=\"2031-12-31\">
<select name=\"hall\" class=\"button large\">";
foreach($formHall->getReply() as $r){
2021-04-12 17:21:59 +02:00
if($r->getNumber() == $placeholder_hall){
2021-04-11 17:58:01 +02:00
echo "
2021-04-12 17:21:59 +02:00
<option value=\"". $r->getNumber() ." \"selected> Sala ". $r->getNumber() . "</option>";
2021-04-11 17:58:01 +02:00
}else{
echo "
2021-04-12 17:21:59 +02:00
<option value=\"". $r->getNumber() ." \"> Sala ". $r->getNumber() . "</option>";
2021-04-11 17:58:01 +02:00
}
}
echo "
</select>
<input type=\"submit\" name=\"filter\" value=\"Filtrar\" class=\"button large\" />
</form>
</div>";
2021-04-14 19:59:52 +02:00
function drawSessions($sessions,$bd){
2021-04-15 21:43:06 +02:00
echo "
<!--Session List -->
<div class=\"column side\">
<table class='alt'>
<thead>
<tr>
<th>Hora</th>
<th>Pelicula</th>
<th>Formato</th>
<th>Precio</th>
</tr>
</thead>
<tbody>";
foreach($sessions as $s){
2021-04-14 19:59:52 +02:00
$film = mysqli_fetch_array($bd->FilmData($s->getIdfilm()));
2021-04-11 17:58:01 +02:00
echo "
2021-04-15 21:43:06 +02:00
<tr>
<td> " . date('H:i', strtotime( $s->getStartTime())) . "</a></td>
<td> " . str_replace('_', ' ', $film["tittle"]) . "</a></td>
<td> " . $s->getFormat() . "</a></td>
<td> " . $s->getSeatPrice() . "</a></td>
<form method=\"post\" action=\"./?state=edit_session&option=edit\">
<input name=\"idfilm\" type=\"hidden\" value=\"".$s->getIdfilm()."\">
<input name=\"hall\" type=\"hidden\" value=\"".$s->getIdhall()."\">
<input name=\"date\" type=\"hidden\" value=\"".$s->getDate()."\">
<input name=\"start\" type=\"hidden\" value=\"".$s->getStartTime()."\">
<input name=\"price\" type=\"hidden\" value=\"".$s->getSeatPrice()."\">
<input name=\"format\" type=\"hidden\" value=\"".$s->getFormat()."\">
<td> <input type=\"submit\" id=\"submit\" value=\"Editar\" class=\"button\" > </td>
</form>
</tr>";
2021-04-11 17:58:01 +02:00
}
echo "
2021-04-15 21:43:06 +02:00
<tbody>
</table>
<input type=\"submit\" name=\"submit\" form=\"addfilter\" value=\"Añadir\" class=\"button large\" formaction=\"./?state=edit_session&option=new\">
</div>\n";
2021-04-11 19:55:21 +02:00
2021-04-11 17:58:01 +02:00
}
2021-04-14 19:59:52 +02:00
if($formSession->getReply()){
$bd = new Film_DAO('complucine');
if($bd){
drawSessions($formSession->getReply(), $bd);
} else {
echo "<div class=\"column side\">
<p> Hay un error en la conexion </p>
</div>";
}
} else {
echo "
<div class=\"column side\">
<p> No hay ninguna session en la sala ". $placeholder_hall . " el dia ". $placeholder_date . "</p>
<input type=\"submit\" name=\"submit\" form=\"addfilter\" value=\"Añadir\" class=\"button large\" formaction=\"./?state=edit_session&option=new\">
2021-04-15 21:43:06 +02:00
</div>\n";
}
?>