From 19168d2f8d1042cc1b0a0544cd6815f1474cdabe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Mu=C3=B1oz=20Garcia?=
<73303506+danimu03@users.noreply.github.com>
Date: Tue, 13 Apr 2021 13:50:23 +0200
Subject: [PATCH] Add files via upload
---
panel_admin/add_film.php | 13 ++++++
panel_admin/editFilm.php | 37 +++++++++++++++++
panel_admin/edit_film.php | 49 +++++-----------------
panel_admin/includes/film_dao.php | 22 +++++-----
panel_admin/includes/formFilm.php | 29 ++++++-------
panel_admin/manage_films.php | 68 +++++++++++++++++++------------
panel_admin/panelAdmin.php | 1 +
7 files changed, 126 insertions(+), 93 deletions(-)
create mode 100644 panel_admin/add_film.php
create mode 100644 panel_admin/editFilm.php
diff --git a/panel_admin/add_film.php b/panel_admin/add_film.php
new file mode 100644
index 0000000..a334ac8
--- /dev/null
+++ b/panel_admin/add_film.php
@@ -0,0 +1,13 @@
+processesForm(null, $_REQUEST['tittle'], $_REQUEST['duration'], $_REQUEST['language'], $_REQUEST['description'], "new");
+ $_SESSION['message'] = $film->getReply();
+ header("Location: ../panel_admin/index.php?state=mf");
+ }
+
+?>
\ No newline at end of file
diff --git a/panel_admin/editFilm.php b/panel_admin/editFilm.php
new file mode 100644
index 0000000..3ac8f90
--- /dev/null
+++ b/panel_admin/editFilm.php
@@ -0,0 +1,37 @@
+
+
Editar pelicula
+
+ ';
+
+ }
+
+
+?>
\ No newline at end of file
diff --git a/panel_admin/edit_film.php b/panel_admin/edit_film.php
index 2e33090..2dae5d1 100644
--- a/panel_admin/edit_film.php
+++ b/panel_admin/edit_film.php
@@ -1,40 +1,11 @@
-FilmData($_GET["id"]));
- $filmDto=$bd->loadFilm($film['id'],$film['title'],$film['duration'],$film['languaje'].$film['description']);
-
- echo''."\n";
- }
- }
+processesForm($_REQUEST['id'], $_REQUEST['tittle'], $_REQUEST['duration'], $_REQUEST['language'], $_REQUEST['description'], "edit");
+ $_SESSION['message'] = $film->getReply();
+ header("Location: ../panel_admin/index.php?state=mf");
+ }
?>
\ No newline at end of file
diff --git a/panel_admin/includes/film_dao.php b/panel_admin/includes/film_dao.php
index 69ba80a..a342a1e 100644
--- a/panel_admin/includes/film_dao.php
+++ b/panel_admin/includes/film_dao.php
@@ -14,12 +14,11 @@
//Create a new Session.
public function createFilm($id, $tittle, $duration, $language, $description){
- $sql = sprintf( "INSERT INTO film( $id, $tittle, $duration, $language, $description)
- VALUES ( '%d', '%s', '%d', '%s', '%d')",
- $id, $tittle, $duration, $language, $description);
-
-
- return $sql;
+ $sql = sprintf( "INSERT INTO film(tittle, duration, language, description)
+ VALUES ('%s', '%d', '%s', '%s')",
+ $tittle, $duration, $language, $description);
+ $resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
+ return $resul;
}
//Returns a query to get the film's data.
@@ -52,19 +51,18 @@
public function deleteFilm($id){
- $sql = sprintf( "DELETE FROM `film` WHERE `film`.`id` = '%d' ;",$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){
-
+ public function editFilm($id, $tittle, $duration, $language,$description){
$sql = sprintf( "UPDATE film
- SET title = '%s' , duration = '%d', lenguaje ='%s' ,`description` ='%s'
- WHERE `film`.`id` = '%d';",
- $title,$duration,$lenguaje, $description,$id );
+ SET tittle = '%s' , duration = '%d', language ='%s' , description ='%s'
+ WHERE film.id = '%d';",
+ $tittle,$duration,$language, $description,$id);
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
diff --git a/panel_admin/includes/formFilm.php b/panel_admin/includes/formFilm.php
index 34778f9..9982558 100644
--- a/panel_admin/includes/formFilm.php
+++ b/panel_admin/includes/formFilm.php
@@ -9,6 +9,7 @@ class FormFilm extends Form {
private $correct; // Indicates if the session is correct.
private $reply; // Validation response
private $option;
+ private $array;
//Constructor:
public function __construct() {
parent::__construct('formFilm');
@@ -18,26 +19,27 @@ class FormFilm extends Form {
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 if($this->option == "show"){
+ $this->reply= $this->array;
}
+
} else {
$this->reply = " ERROR
Ha habido un error en la operacion. Revisa los datos introducidos
- ";
+ ";
}
return $this->reply;
@@ -47,27 +49,20 @@ class FormFilm extends 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);
+ $bd->createFilm(null, $title,$duration,$languaje,$description);
} else if ($option == "del"){
$bd->deleteFilm($id);
} else if ($option == "edit"){
$bd->editFilm($id,$title,$duration,$languaje,$description);
+ } else if($this->option == "show") {
+ $this->array = $bd->allFilmData();
}
-
} else {$this->correct = false;}
}
diff --git a/panel_admin/manage_films.php b/panel_admin/manage_films.php
index 5631df2..4011d5b 100644
--- a/panel_admin/manage_films.php
+++ b/panel_admin/manage_films.php
@@ -1,17 +1,19 @@
processesForm(null, null, null, null, null, "show");
+
+ function drawFilms($films){
+
echo "
\n";
+ echo'
+ ';
}
function addFilm(){
echo''."\n";
+ ';
+ }
+ function showmessage() {
+ if(isset($_SESSION['message'])){
+ echo '
+
'.$_SESSION["message"].'
+ ';
+ unset($_SESSION['message']);
}
-
- drawFilms($bd->allFilmData());
+ }
+ showmessage();
+ drawFilms($film->getReply());
addFilm();
-
?>
\ No newline at end of file
diff --git a/panel_admin/panelAdmin.php b/panel_admin/panelAdmin.php
index c23ee65..f39057d 100644
--- a/panel_admin/panelAdmin.php
+++ b/panel_admin/panelAdmin.php
@@ -8,6 +8,7 @@
function showPanel() {
switch($this->state) {
+ case 'ef': require('editFilm.php');break;
case 'mc': require('manage_cinemas.php'); break;
case 'mf': require('manage_films.php'); break;
case 'md': require('manage_discounts.php'); break;