Deberia estar todo hecho

This commit is contained in:
Markines16 2021-04-15 22:34:33 +02:00 committed by GitHub
parent a3bc2311e5
commit 2a09ad18b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 40 additions and 25 deletions

View File

@ -10,10 +10,11 @@
require_once('../panel_admin/includes/film_dto.php');
include_once('../panel_admin/includes/film_dao.php');
$cinema = "1";
$formHall = new FormHall();
$formHall->processesForm(null, $cinema, null, null, "list");
$formHall->processesForm(null, $_SESSION["cinema"], null, null, "list");
$filmList = new Film_DAO('complucine');
@ -24,14 +25,16 @@
}
if(isset($_REQUEST['option']) && $_REQUEST['option'] == 'edit') {
$_SESSION["hall"] = $_POST['hall'];
$_SESSION["date"] = $_POST['date'];
$_SESSION["start"] = $_POST['start'];
echo " <div class = \"column middle\">
<h2>Editar/Eliminar Sesion</h2>
<form method=\"post\" id=\"edit_ses\" action=\"validateSession.php\">
<div class=\"row\">
<fieldset id=\"datos\">
<legend>Datos</legend>
<input name=\"cinema\" type=\"hidden\" value=\"". $_POST['idcinema']."\">
<input name=\"id\" type=\"hidden\" value=\"". $_POST['id']."\">
<div class=\"_price\">
<input type=\"number\" name=\"price\" id=\"price\" value=\"". $_POST['price'] ."\"min=\"0\" placeholder=\"Precio de la entrada\" required/>
</div>

View File

@ -21,7 +21,6 @@ class FormHall extends Form {
//Returns validation response:
public function getReply() {
echo "<p> se va a devolver una respuesta </p>";
if($this->correct){
if($this->option == "new"){
$this->reply = "<h1> Operacion realizada con exito </h1><hr />
@ -36,7 +35,6 @@ class FormHall extends Form {
<p> Se ha eliminado la sala correctamente en la base de datos.</p>
<a href='../panel_manager/index.php'><button>Panel Gerente</button></a>";
}else if($this->option == "list"){
echo "<p> se va a devolver la lista </p>";
$this->reply = $this->halls;
}
} else {

View File

@ -42,7 +42,7 @@ class FormSession extends Form {
return $this->reply;
}
public function processesForm($id, $film, $hall, $cinema, $date, $start, $price, $format, $repeat, $option) {
public function processesForm($film, $hall, $cinema, $date, $start, $price, $format, $repeat, $option) {
$this->option = $option;
$this->correct = true;
@ -58,21 +58,21 @@ class FormSession extends Form {
if($searchSession) {
$this->correct = false;
} else{
$bd->createSession(null, $film, $hall,$cinema, $date, $start, $price, $format);
$bd->createSession(null,$film, $hall,$cinema, $date, $start, $price, $format);
}
} else if ($option == "del"){
$bd->deleteSession($id);
$bd->deleteSession($hall, $cinema, $date, $start);
} else if ($option == "edit"){
$bd->editSession($id, $film, $hall, $cinema, $date, $start, $price, $format);
$bd->editSession($film, $hall, $cinema, $date, $start, $price, $format);
}
if($repeat > "0"){
$repeat--;
$date = date('Y-m-d', strtotime( $date. ' +1 day') );
$this->processesForm($id, $film, $hall, $cinema, $date, $start, $price, $format, $repeat, $option);
$this->processesForm($film, $hall, $cinema, $date, $start, $price, $format, $repeat, $option);
}
}
} else {$this->correct = false;}

View File

@ -1,7 +1,7 @@
<?php
require_once('../assets/php/dao.php');
include_once('session_dto.php');
class SessionDAO extends DAO {
//Constructor:
function __construct($bd_name){
@ -68,7 +68,7 @@
return $sessions;
}
public function editSession($id, $idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format){
public function editSession($idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format){
$format = $this->mysqli->real_escape_string($format);
$date = date('Y-m-d', strtotime( $date ) );
$startTime = date('H:i:s', strtotime( $startTime ) );
@ -76,17 +76,20 @@
$sql = sprintf( "UPDATE `session`
SET `idfilm` = '%d' , `idhall` = '%d', `idcinema` = '%d', `date` = '%s',
`start_time` = '%s', `seat_price` = '%d', `format` = '%s'
WHERE `session`.`id` = '%d';",
$idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format, $id);
WHERE
idcinema = '%s' AND idhall = '%s' AND date = '%s' AND start_time = '%s'",
$idfilm, $idhall, $idcinema, $date, $startTime, $seatPrice, $format, $_SESSION["cinema"],$_SESSION["hall"],$_SESSION["date"],$_SESSION["start"]);
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
return $resul;
}
public function deleteSession($id){
public function deleteSession($hall, $cinema, $date, $startTime){
$sql = sprintf( "DELETE FROM `session` WHERE `session`.`id` = '%d';",$id);
$sql = sprintf( "DELETE FROM `session` WHERE
idcinema = '%s' AND idhall = '%s' AND date = '%s' AND start_time = '%s'",
$cinema, $hall, $date, $startTime);
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');

View File

@ -16,15 +16,16 @@
$placeholder_date = date("Y-m-d");
$placeholder_hall = "1";
$cinema = "1";
$_SESSION["cinema"] = "1";
if(isset($_POST['filter'])) {
$placeholder_date = $_POST["date"];
$placeholder_hall = $_POST["hall"];
}
$formHall->processesForm(null, $cinema, null, null, "list");
$formSession->processesForm(null, null, $placeholder_hall, $cinema, $placeholder_date, null, null, null, null, "list");
$formHall->processesForm(null, $_SESSION["cinema"], null, null, "list");
$formSession->processesForm(null, $placeholder_hall, $_SESSION["cinema"], $placeholder_date, null, null, null, null, "list");
echo"
<!--Session Filter -->
@ -72,10 +73,8 @@
<td> " . $s->getFormat() . "</a></td>
<td> " . $s->getSeatPrice() . "</a></td>
<form method=\"post\" action=\"./?state=edit_session&option=edit\">
<input name=\"id\" type=\"hidden\" value=\"".$s->getId()."\">
<input name=\"idfilm\" type=\"hidden\" value=\"".$s->getIdfilm()."\">
<input name=\"hall\" type=\"hidden\" value=\"".$s->getIdhall()."\">
<input name=\"idcinema\" type=\"hidden\" value=\"".$s->getIdcinema()."\">
<input name=\"date\" type=\"hidden\" value=\"".$s->getDate()."\">
<input name=\"start\" type=\"hidden\" value=\"".$s->getStartTime()."\">
<input name=\"price\" type=\"hidden\" value=\"".$s->getSeatPrice()."\">

View File

@ -6,16 +6,28 @@
$reply = "<p> ERROR DE ACCESO </p>" ;
if(isset($_POST['new'])){
$session->processesForm(null, $_POST["film"], $_POST["hall"], $_POST["cinema"],$_POST["date"],$_POST["start"],$_POST["price"],$_POST["format"],$_POST["repeat"], "new");
$session->processesForm($_POST["film"], $_POST["hall"], $_SESSION["cinema"],$_POST["date"],$_POST["start"],$_POST["price"],$_POST["format"],$_POST["repeat"], "new");
$reply = $session->getReply();
$_SESSION["cinema"] = "";
$_SESSION["hall"] = "";
$_SESSION["date"] = "";
$_SESSION["start"] = "";
} else if (isset($_POST['edit'])){
$session->processesForm($_POST["id"], $_POST["film"], $_POST["hall"], $_POST["cinema"],$_POST["date"],$_POST["start"],$_POST["price"],$_POST["format"],"0", "edit");
$session->processesForm($_POST["film"], $_POST["hall"], $_SESSION["cinema"],$_POST["date"],$_POST["start"],$_POST["price"],$_POST["format"],"0", "edit");
$reply = $session->getReply();
$_SESSION["cinema"] = "";
$_SESSION["hall"] = "";
$_SESSION["date"] = "";
$_SESSION["start"] = "";
} else if (isset($_POST['del'])){
$session->processesForm($_POST["id"], $_POST["film"], $_POST["hall"], $_POST["cinema"],$_POST["date"],$_POST["start"],$_POST["price"],$_POST["format"],"0", "del");
$session->processesForm($_POST["film"], $_POST["hall"], $_SESSION["cinema"],$_POST["date"],$_POST["start"],$_POST["price"],$_POST["format"],"0", "del");
$reply = $session->getReply();
$_SESSION["cinema"] = "";
$_SESSION["hall"] = "";
$_SESSION["date"] = "";
$_SESSION["start"] = "";
}
?>