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;