From 50de669747258aa7ea8681144c3c4306fc9d0c3e Mon Sep 17 00:00:00 2001 From: marian1010 <79144276+marian1010@users.noreply.github.com> Date: Mon, 12 Apr 2021 23:23:55 +0200 Subject: [PATCH] :anguished: --- panel_admin/edit_film.php | 40 +++++ panel_admin/includes/film_dao.php | 22 +++ panel_admin/includes/formFilm.php | 77 +++++++++ .../{manage_films => }/manage_films.php | 148 +++++++++--------- panel_admin/manage_films/delete_film.php | 12 ++ panel_admin/validade.php | 66 ++++++++ 6 files changed, 292 insertions(+), 73 deletions(-) create mode 100644 panel_admin/edit_film.php create mode 100644 panel_admin/includes/formFilm.php rename panel_admin/{manage_films => }/manage_films.php (81%) create mode 100644 panel_admin/manage_films/delete_film.php create mode 100644 panel_admin/validade.php diff --git a/panel_admin/edit_film.php b/panel_admin/edit_film.php new file mode 100644 index 0000000..2e33090 --- /dev/null +++ b/panel_admin/edit_film.php @@ -0,0 +1,40 @@ +FilmData($_GET["id"])); + $filmDto=$bd->loadFilm($film['id'],$film['title'],$film['duration'],$film['languaje'].$film['description']); + + echo'
+

Editar pelicula

+
+
+
+ Datos de pelicula +
+ +
+
+ +
+
+ +
+
+ +
+
+
+ + +
+
+
+
'."\n"; + } + } +?> \ No newline at end of file diff --git a/panel_admin/includes/film_dao.php b/panel_admin/includes/film_dao.php index d8f2933..69ba80a 100644 --- a/panel_admin/includes/film_dao.php +++ b/panel_admin/includes/film_dao.php @@ -50,6 +50,28 @@ return $resul; }*/ + public function deleteFilm($id){ + + $sql = sprintf( "DELETE FROM `film` WHERE `film`.`id` = '%d' ;",$id); + + $resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database'); + + return $resul; + } + + public function editFilm($id, $title, $duration, $lenguaje,$description){ + + $sql = sprintf( "UPDATE film + SET title = '%s' , duration = '%d', lenguaje ='%s' ,`description` ='%s' + WHERE `film`.`id` = '%d';", + $title,$duration,$lenguaje, $description,$id ); + + $resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database'); + + return $resul; + } + + //Returns a query to get all films tittles. public function tittleFilmData(){ $sql = sprintf( "SELECT tittle FROM film "); diff --git a/panel_admin/includes/formFilm.php b/panel_admin/includes/formFilm.php new file mode 100644 index 0000000..34778f9 --- /dev/null +++ b/panel_admin/includes/formFilm.php @@ -0,0 +1,77 @@ +reply = array(); + } + + + + public function getReply() { + + + if($this->correct){ + if($this->option == "new"){ + $this->reply = "

Operacion realizada con exito


+

Se ha añadido la pelicula correctamente en la base de datos.

+ "; + }else if($this->option == "edit"){ + $this->reply = "

Operacion realizada con exito


+

Se ha editado la pelicula correctamente en la base de datos.

+ "; + }else if($this->option == "del"){ + $this->reply = "

Operacion realizada con exito


+

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

+ "; + } + } else { + $this->reply = "

ERROR


+

Ha habido un error en la operacion. Revisa los datos introducidos

+ "; + + } + return $this->reply; + } + + //Process form: + public function processesForm($id,$title,$duration,$languaje,$description, $option) { + $this->correct = true; + $this->option = $option; + //Habria que validar todo para que encaje en la base de datos + + $start = date('H:i:s', strtotime( $start ) ); + $date = date('Y-m-d', strtotime( $date ) ); + + $bd = new FilmDAO('complucine'); + if($bd ){ + if($option == "new"){ + $selectFilm = $bd->selectSession($cinema, $hall, $start, $date); + if($selectSession && $selectSession->num_rows >= 1) { + $this->correct = false; + } else{ + $bd->createFilm(null, $title,$duration,$languaje,$description); + } + mysqli_free_result($selectSession); + } else if ($option == "del"){ + $bd->deleteFilm($id); + } else if ($option == "edit"){ + $bd->editFilm($id,$title,$duration,$languaje,$description); + } + + } else {$this->correct = false;} + + } + +} + +?> \ No newline at end of file diff --git a/panel_admin/manage_films/manage_films.php b/panel_admin/manage_films.php similarity index 81% rename from panel_admin/manage_films/manage_films.php rename to panel_admin/manage_films.php index dab944d..5631df2 100644 --- a/panel_admin/manage_films/manage_films.php +++ b/panel_admin/manage_films.php @@ -1,73 +1,75 @@ - - - - Id - Título - Duracion - Idioma - Descripcion - - - "; - foreach($films as $f){ - echo " - - " . $f->getId() . " - " . $f->getTittle() . " - " . $f->getDuration() . " - ". $f->getLanguage() . " - ". $f->getDescription()." - - "; - } - echo " - \n"; - } - function addFilm(){ - echo'
-

Añadir pelicula

-
-
-
- Datos de pelicula -
- -
-
- -
-
- -
-
- -
-
-
- - -
-
-
-
'."\n"; - } - - drawFilms($bd->allFilmData()); - addFilm(); - - - ?> \ No newline at end of file + + + + Id + Título + Duracion + Idioma + Descripcion + + + "; + foreach($films as $f){ + echo " + + " . $f->getId() . " + " . $f->getTittle() . " + " . $f->getDuration() . " + ". $f->getLanguage() . " + ". $f->getDescription()." + getId()."\"/> + getId()."\"/> + "; + } + echo " + \n"; + } + function addFilm(){ + echo'
+

Añadir pelicula

+
+
+
+ Datos de pelicula +
+ +
+
+ +
+
+ +
+
+ +
+
+
+ + +
+
+
+
'."\n"; + } + + drawFilms($bd->allFilmData()); + addFilm(); + + +?> \ No newline at end of file diff --git a/panel_admin/manage_films/delete_film.php b/panel_admin/manage_films/delete_film.php new file mode 100644 index 0000000..fe696df --- /dev/null +++ b/panel_admin/manage_films/delete_film.php @@ -0,0 +1,12 @@ +deleteFilm($_REQUEST['id']); + } + header("Location: ../panel_admin/index.php?state=mf"); + +?> \ No newline at end of file diff --git a/panel_admin/validade.php b/panel_admin/validade.php new file mode 100644 index 0000000..7120e49 --- /dev/null +++ b/panel_admin/validade.php @@ -0,0 +1,66 @@ +processesForm($id, $_POST["title"], $_POST["duration"], $_POST["languaje"],$_POST["description"], $action); + $reply = $session->getReply(); +?> + + + + + print_head(); + ?> + + + print_header(); + ?> + + +
+
+
+ + +
+
+
+
+
+ +
+
+
+
+
+ + + print_footer(); + ?> + + + + \ No newline at end of file