diff --git a/panel_admin/includes/film_dao.php b/panel_admin/includes/film_dao.php index 3f34771..07c41c6 100644 --- a/panel_admin/includes/film_dao.php +++ b/panel_admin/includes/film_dao.php @@ -39,12 +39,7 @@ public function allFilmData(){ $sql = sprintf( "SELECT * FROM film "); $resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database'); - - while($fila=mysqli_fetch_array($resul)){ - $films[] = $this->loadFilm($fila["id"], $fila["tittle"], $fila["duration"], $fila["language"], $fila["description"]); - } - $resul->free(); - return $films; + return $resul; } //Returns a query to get all films tittles. diff --git a/panel_admin/includes/formFilm.php b/panel_admin/includes/formFilm.php index 37caafb..f14bd0b 100644 --- a/panel_admin/includes/formFilm.php +++ b/panel_admin/includes/formFilm.php @@ -1,6 +1,7 @@ correct =false; } else{ - $bd->createFilm(null, $tittle,$duration,$language,$description); + $resul=$bd->createFilm(null, $tittle,$duration,$language,$description); + $resul->free(); } + $exist->free(); } else{ $this->correct =false; @@ -72,7 +75,7 @@ class FormFilm extends Form { } else if ($option == "del"){ //Primero comprobar si existe una pelicula con el mismo id $exist = $bd-> FilmData($id); - if( mysqli_num_rows($exist) != 0){ + if( mysqli_num_rows($exist) == 1){ $bd->deleteFilm($id); } else{ @@ -83,21 +86,28 @@ class FormFilm extends Form { if(!empty($tittle)&&$duration>0&&!empty($language)&&!empty($description)){ //comprobar si existe una pelicula con el mismo id $exist = $bd-> FilmData($id); - if( mysqli_num_rows($exist) != 0){ - $bd->editFilm($id,$tittle,$duration,$language,$description); + if( mysqli_num_rows($exist) == 1){ + $resul = $bd->editFilm($id,$tittle,$duration,$language,$description); + $resul->free(); } else{ $this->correct =false; } + $exist->free(); } else{ $this->correct =false; } } else if($this->option == "show") { - $this->array = $bd->allFilmData(); + $resul = $bd->allFilmData(); + while($fila=mysqli_fetch_assoc($resul)){ + $this->array = new FilmDTO($fila["id"], $fila["tittle"], $fila["duration"], $fila["language"], $fila["description"]); + } + $resul->free(); } else {$this->correct = false;} } + $bd->__destruct(); } } diff --git a/panel_admin/index.php b/panel_admin/index.php index 5e79460..a152f5c 100644 --- a/panel_admin/index.php +++ b/panel_admin/index.php @@ -41,23 +41,18 @@ diff --git a/panel_admin/manage_films.php b/panel_admin/manage_films.php index 7b8340d..079dcc8 100644 --- a/panel_admin/manage_films.php +++ b/panel_admin/manage_films.php @@ -1,6 +1,6 @@ state = $panel; + $this->login= $login; } function showPanel() { - switch($this->state) { - case 'uf': require('updateFilm.php');break; - case 'mc': require('manage_cinemas.php'); break; - case 'mf': require('manage_films.php'); break; - case 'md': require('manage_discounts.php'); break; - case 'mm': require('manage_managers.php'); break; - default: echo "

BIENVENIDO AL PANEL DE ADMINISTRADOR

"; break; + if($this->login){ + switch($this->state) { + case 'uf': require_once('updateFilm.php');break; + case 'mc': /*require_once('manage_cinemas.php')*/;echo"

En construcción

"; break; + case 'mf': require_once('manage_films.php'); break; + case 'md': /*require_once('manage_discounts.php')*/;echo"

En construcción

"; break; + case 'mm': /*require_once('manage_managers.php')*/;echo"

En construcción

"; break; + case 'un': echo"

En construcción

"; break; + case 'ur': echo"

En construcción

";; break; + case 'ag': echo"

En construcción

";; break; + default: echo "

BIENVENIDO AL PANEL DE ADMINISTRADOR

"; break; + } + } + else { + echo "

NO TIENES PERMISOS DE ADMINISTRADOR

"; } } } diff --git a/panel_admin/updateFilm.php b/panel_admin/updateFilm.php index e3e24f1..70a5818 100644 --- a/panel_admin/updateFilm.php +++ b/panel_admin/updateFilm.php @@ -1,7 +1,7 @@

Editar pelicula

@@ -30,7 +30,6 @@ '; - } else if(isset($_POST['delete_film'])) { echo'