From 2a09ad18b9340a38059fc59728786c2d8eda74fd Mon Sep 17 00:00:00 2001 From: Markines16 <80280295+Markines16@users.noreply.github.com> Date: Thu, 15 Apr 2021 22:34:33 +0200 Subject: [PATCH] Deberia estar todo hecho --- panel_manager/edit_sessions.php | 11 +++++++---- panel_manager/includes/formHall.php | 2 -- panel_manager/includes/formSession.php | 10 +++++----- panel_manager/includes/session_dao.php | 15 +++++++++------ panel_manager/manage_sessions.php | 9 ++++----- panel_manager/validateSession.php | 18 +++++++++++++++--- 6 files changed, 40 insertions(+), 25 deletions(-) diff --git a/panel_manager/edit_sessions.php b/panel_manager/edit_sessions.php index e7811d9..da6e69f 100644 --- a/panel_manager/edit_sessions.php +++ b/panel_manager/edit_sessions.php @@ -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 "

Editar/Eliminar Sesion

Datos - -
diff --git a/panel_manager/includes/formHall.php b/panel_manager/includes/formHall.php index d8e580a..8bf817d 100644 --- a/panel_manager/includes/formHall.php +++ b/panel_manager/includes/formHall.php @@ -21,7 +21,6 @@ class FormHall extends Form { //Returns validation response: public function getReply() { - echo "

se va a devolver una respuesta

"; if($this->correct){ if($this->option == "new"){ $this->reply = "

Operacion realizada con exito


@@ -36,7 +35,6 @@ class FormHall extends Form {

Se ha eliminado la sala correctamente en la base de datos.

"; }else if($this->option == "list"){ - echo "

se va a devolver la lista

"; $this->reply = $this->halls; } } else { diff --git a/panel_manager/includes/formSession.php b/panel_manager/includes/formSession.php index aab2439..73dc013 100644 --- a/panel_manager/includes/formSession.php +++ b/panel_manager/includes/formSession.php @@ -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;} diff --git a/panel_manager/includes/session_dao.php b/panel_manager/includes/session_dao.php index a304030..381e55a 100644 --- a/panel_manager/includes/session_dao.php +++ b/panel_manager/includes/session_dao.php @@ -1,7 +1,7 @@ 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'); diff --git a/panel_manager/manage_sessions.php b/panel_manager/manage_sessions.php index 47ab637..dcc8551 100644 --- a/panel_manager/manage_sessions.php +++ b/panel_manager/manage_sessions.php @@ -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" @@ -72,10 +73,8 @@ " . $s->getFormat() . " " . $s->getSeatPrice() . " - getId()."\"> getIdfilm()."\"> getIdhall()."\"> - getIdcinema()."\"> getDate()."\"> getStartTime()."\"> getSeatPrice()."\"> diff --git a/panel_manager/validateSession.php b/panel_manager/validateSession.php index 18921a6..d97aedd 100644 --- a/panel_manager/validateSession.php +++ b/panel_manager/validateSession.php @@ -6,16 +6,28 @@ $reply = "

ERROR DE ACCESO

" ; 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"] = ""; } ?>