diff --git a/panel_admin/includes/formAddFilm.php b/panel_admin/includes/formAddFilm.php
new file mode 100644
index 0000000..7027f20
--- /dev/null
+++ b/panel_admin/includes/formAddFilm.php
@@ -0,0 +1,111 @@
+ "./?state=mf");
+ parent::__construct('formAddFilm', $options);
+ }
+
+ protected function generaCamposFormulario($datos, $errores = array()){
+
+
+ // Se generan los mensajes de error si existen.
+ $htmlErroresGlobales = self::generaListaErroresGlobales($errores);
+ $errorTittle = self::createMensajeError($errores, 'tittle', 'span', array('class' => 'error'));
+ $errorDuration = self::createMensajeError($errores, 'duration', 'span', array('class' => 'error'));
+ $errorLanguage = self::createMensajeError($errores, 'language', 'span', array('class' => 'error'));
+ $errorDescription = self::createMensajeError($errores, 'description', 'span', array('class' => 'error'));
+ //$errorImage = self::createMensajeError($errores, 'image', 'span', array('class' => 'error'));
+
+ $html = '
+ ';
+
+ return $html;
+ }
+
+ protected function procesaFormulario($datos){
+ $result = array();
+
+ $tittle = $this->test_input($datos['tittle']) ?? null;
+ //|| !mb_ereg_match(self::HTML5_EMAIL_REGEXP, $tittle)
+ if ( empty($tittle) ) {
+ $result['tittle'] = "El título no es válido";
+ }
+
+ $duration = $this->test_input($datos['duration']) ?? null;
+ //||!mb_ereg_match(self::HTML5_EMAIL_REGEXP, $duration)
+ if ( empty($duration) || $duration <0) {
+ $result['duration'] = "La duración no es válida";
+ }
+
+ $language = $this->test_input($datos['language']) ?? null;
+ //|| !mb_ereg_match(self::HTML5_EMAIL_REGEXP, $language)
+ if ( empty($language) ) {
+ $result['language'] = "El idioma no es válido";
+ }
+
+ $description = $this->test_input($datos['description']) ?? null;
+ //|| !mb_ereg_match(self::HTML5_EMAIL_REGEXP, $description)
+ if ( empty($language)) {
+ $result['language'] = "La descripcion no es válida";
+ }
+
+ if (count($result) === 0) {
+ $bd = new Film_DAO("complucine");
+
+ //FALTARIA SUBIR LA IMAGEN
+ $exist = $bd-> GetFilm($tittle,$language);
+ if(mysqli_num_rows($exist) != 0){
+ $result[] = "Ya existe una nueva pelicula con el mismo titulo e idioma.";
+ }
+ else{
+ $bd->createFilm(null, $tittle,$duration,$language,$description);
+ $_SESSION['message'] = "
+
+
+
+
Operacion realizada con exito
+
Se ha añadido la pelicula correctamente en la base de datos.
+
+
+
+
+
+ ";
+ $result = './?state=mf';
+
+ }
+ $exist->free();
+ }
+ return $result;
+ }
+
+ protected function test_input($input){
+ return htmlspecialchars(trim(strip_tags($input)));
+ }
+
+
+}
+
+?>
\ No newline at end of file
diff --git a/panel_admin/includes/formDeleteFilm.php b/panel_admin/includes/formDeleteFilm.php
new file mode 100644
index 0000000..4b15f0d
--- /dev/null
+++ b/panel_admin/includes/formDeleteFilm.php
@@ -0,0 +1,89 @@
+ "./?state=mf");
+ parent::__construct('formDeleteFilm', $options);
+ }
+
+ protected function generaCamposFormulario($datos, $errores = array()){
+
+
+ // Se generan los mensajes de error si existen.
+ $htmlErroresGlobales = self::generaListaErroresGlobales($errores);
+ //$errorTittle = self::createMensajeError($errores, 'tittle', 'span', array('class' => 'error'));
+ //$errorDuration = self::createMensajeError($errores, 'duration', 'span', array('class' => 'error'));
+ //$errorLanguage = self::createMensajeError($errores, 'language', 'span', array('class' => 'error'));
+ //$errorDescription = self::createMensajeError($errores, 'description', 'span', array('class' => 'error'));
+ //$errorImage = self::createMensajeError($errores, 'image', 'span', array('class' => 'error'));
+
+ $html = '
+
+
+
+
+
+
';
+
+ return $html;
+ }
+
+ protected function procesaFormulario($datos){
+ $result = array();
+ $id = $this->test_input($_POST['id']) ?? null;
+ if ( empty($id)) {
+ $result[] = "La pelicula seleccionada no existe.";
+ }
+
+ if (count($result) === 0) {
+ $bd = new Film_DAO("complucine");
+ $exist = $bd-> FilmData($id);
+ if( mysqli_num_rows($exist) == 1){
+ $bd->deleteFilm($id);
+ $_SESSION['message'] = "
+
+
+
+
Operacion realizada con exito
+
Se ha eliminado la pelicula correctamente en la base de datos.
+
+
+
+
+
+ ";
+ $result = './?state=mf';
+ }
+ else{
+ $result[] = "La pelicula seleccionada no existe.";
+ }
+
+ $exist->free();
+ }
+ return $result;
+ }
+
+ protected function test_input($input){
+ return htmlspecialchars(trim(strip_tags($input)));
+ }
+
+
+}
+
+?>
\ No newline at end of file
diff --git a/panel_admin/includes/formEditFilm.php b/panel_admin/includes/formEditFilm.php
new file mode 100644
index 0000000..2bde6cc
--- /dev/null
+++ b/panel_admin/includes/formEditFilm.php
@@ -0,0 +1,123 @@
+ "./?state=mf");
+ parent::__construct('formEditFilm', $options);
+ }
+
+ protected function generaCamposFormulario($datos, $errores = array()){
+
+
+ // Se generan los mensajes de error si existen.
+ $htmlErroresGlobales = self::generaListaErroresGlobales($errores);
+ $errorTittle = self::createMensajeError($errores, 'tittle', 'span', array('class' => 'error'));
+ $errorDuration = self::createMensajeError($errores, 'duration', 'span', array('class' => 'error'));
+ $errorLanguage = self::createMensajeError($errores, 'language', 'span', array('class' => 'error'));
+ $errorDescription = self::createMensajeError($errores, 'description', 'span', array('class' => 'error'));
+ $errorImage = self::createMensajeError($errores, 'image', 'span', array('class' => 'error'));
+
+ $html = '
+
+
+ ';
+
+ return $html;
+ }
+
+ protected function procesaFormulario($datos){
+ $result = array();
+
+ $id = $this->test_input($_POST['id']) ?? null;
+ if ( empty($id)) {
+ $result[] = "La pelicula seleccionada no existe.";
+ }
+
+ $tittle = $this->test_input($datos['tittle']) ?? null;
+ //|| !mb_ereg_match(self::HTML5_EMAIL_REGEXP, $tittle)
+ if ( empty($tittle) ) {
+ $result['tittle'] = "El título no es válido";
+ }
+
+ $duration = $this->test_input($datos['duration']) ?? null;
+ //||!mb_ereg_match(self::HTML5_EMAIL_REGEXP, $duration)
+ if ( empty($duration) || $duration <0) {
+ $result['duration'] = "La duración no es válida";
+ }
+
+ $language = $this->test_input($datos['language']) ?? null;
+ //|| !mb_ereg_match(self::HTML5_EMAIL_REGEXP, $language)
+ if ( empty($language) ) {
+ $result['language'] = "El idioma no es válido";
+ }
+
+ $description = $this->test_input($datos['description']) ?? null;
+ //|| !mb_ereg_match(self::HTML5_EMAIL_REGEXP, $description)
+ if ( empty($language)) {
+ $result['language'] = "La descripcion no es válida";
+ }
+
+
+ if (count($result) === 0) {
+ $bd = new Film_DAO("complucine");
+ $exist = $bd-> FilmData($id);
+ if( mysqli_num_rows($exist) == 1){
+ $bd->editFilm($id,$tittle,$duration,$language,$description);
+ $_SESSION['message'] = "
+
+
+
+
Operacion realizada con exito
+
Se ha editado la pelicula correctamente en la base de datos.
+
+
+
+
+
+ ";
+ $result = './?state=mf';
+ }
+ else{
+ $result[] = "La pelicula seleccionada no existe.";
+ }
+ $exist->free();
+ }
+ return $result;
+ }
+
+ protected function test_input($input){
+ return htmlspecialchars(trim(strip_tags($input)));
+ }
+
+
+}
+
+?>
\ No newline at end of file
diff --git a/panel_admin/includes/formManager.php b/panel_admin/includes/formManager.php
index 730f4f9..ff5fca0 100644
--- a/panel_admin/includes/formManager.php
+++ b/panel_admin/includes/formManager.php
@@ -90,7 +90,7 @@ class FormManager extends Form {
if($bd){
if($this->option == "new"){
//Check if any var is empty
- if(!is_null($id)&&!is_null($idcinema)){
+ if(!is_null($id)&&!empty($idcinema)){
// check if already exist a manager with same name
$exist = $bd->GetManagerCinema($id, $idcinema);
if( mysqli_num_rows($exist) != 0){
diff --git a/panel_admin/manage_managers.php b/panel_admin/manage_managers.php
index 3b9c226..dded178 100644
--- a/panel_admin/manage_managers.php
+++ b/panel_admin/manage_managers.php
@@ -21,15 +21,15 @@
$usernames = array();
$email = array();
$rol = array();
- if(is_array($managers)){
- foreach($managers as $key => $value){
- $ids[$key] = $value->getId();
- $idscinemas[$key] = $value->getIdcinema();
- $usernames[$key] = $value->getUsername();
- $email[$key] = $value->getEmail();
- $rol[$key] = $value->getRoll();
- }
+
+ foreach($managers as $key => $value){
+ $ids[$key] = $value->getId();
+ $idscinemas[$key] = $value->getIdcinema();
+ $usernames[$key] = $value->getUsername();
+ $email[$key] = $value->getEmail();
+ $rol[$key] = $value->getRoll();
}
+
echo "
@@ -47,38 +47,36 @@
";
- if(is_array($managers)){
- for($i = 0; $i < count($managers); $i++){
- echo '
- '. $ids[$i] .' |
- '. $idscinemas[$i] .' |
- '. $usernames[$i] .' |
- '. $email[$i] .' |
- '. $rol[$i] .' |
-
-
- |
-
-
- |
-
- ';
- }
- }
+ for($i = 0; $i < count($managers); $i++){
+ echo '
+ '. $ids[$i] .' |
+ '. $idscinemas[$i] .' |
+ '. $usernames[$i] .' |
+ '. $email[$i] .' |
+ '. $rol[$i] .' |
+
+
+ |
+
+
+ |
+
+ ';
+ }
echo'
diff --git a/panel_admin/panelAdmin.php b/panel_admin/panelAdmin.php
index b0eea44..cf09f00 100644
--- a/panel_admin/panelAdmin.php
+++ b/panel_admin/panelAdmin.php
@@ -33,24 +33,18 @@
};
break;
- case 'mf': require_once('manage_films.php');
- if(isset($_POST['edit_film'])) {
- editFilm();
+ case 'mf': if(isset($_POST['edit_film'])) {
+ $this->editFilm();
}
else if(isset($_POST['delete_film'])) {
- deleteFilm();
+ $this->deleteFilm();
}
else if(isset($_POST['add_film'])) {
- confirmAdd();
- }
- else if(isset($_POST['confirm_delete_film'])) {
- confirmDelete();
- }
- else if(isset($_POST['confirm_edit_film'])) {
- confirmEdit();
+ $this->addFilm();
+ $template->print_fimls();
}
else {
- addFilm();
+ $this->addFilm();
$template->print_fimls();
};
break;
@@ -119,6 +113,40 @@
function getTemplate(){
return $this->template;
}
+
+ //Functions FILMS
+ function addFilm(){
+ include_once('./includes/formAddFilm.php');
+ $formAF = new formAddFilm();
+ $htmlAForm = $formAF->gestiona();
+ echo '
+
+
+ '.$htmlAForm.'
+
'."\n";
+ }
+
+ function deleteFilm() {
+ include_once('./includes/formDeleteFilm.php');
+ $formDF = new formDeleteFilm();
+ $htmlDForm = $formDF->gestiona();
+ echo '
+
+
+ '.$htmlDForm.'
+
'."\n";
+ }
+ function editFilm() {
+ include_once('./includes/formEditFilm.php');
+ $formEF = new formEditFilm();
+ $htmlDForm = $formEF->gestiona();
+ echo '
+
+
+ '.$htmlDForm.'
+
'."\n";
+ }
}
+
?>