From 54d6e99c1d3f39af9fea294e62cd5abd87ce2957 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Mu=C3=B1oz=20Garcia?=
<73303506+danimu03@users.noreply.github.com>
Date: Thu, 13 May 2021 11:48:20 +0200
Subject: [PATCH] forms Manager
---
panel_admin/includes/formAddManager.php | 147 +++++++++++++++++++++
panel_admin/includes/formDeleteManager.php | 85 ++++++++++++
panel_admin/includes/formEditManager.php | 118 +++++++++++++++++
3 files changed, 350 insertions(+)
create mode 100644 panel_admin/includes/formAddManager.php
create mode 100644 panel_admin/includes/formDeleteManager.php
create mode 100644 panel_admin/includes/formEditManager.php
diff --git a/panel_admin/includes/formAddManager.php b/panel_admin/includes/formAddManager.php
new file mode 100644
index 0000000..cb5b2de
--- /dev/null
+++ b/panel_admin/includes/formAddManager.php
@@ -0,0 +1,147 @@
+ "./?state=mg");
+ parent::__construct('formAddManager', $options);
+ }
+
+ protected function generaCamposFormulario($datos, $errores = array()){
+
+
+ // Se generan los mensajes de error si existen.
+ $htmlErroresGlobales = self::generaListaErroresGlobales($errores);
+ //$errorId = self::createMensajeError($errores, 'id', 'span', array('class' => 'error'));
+ //$errorIdCinema = self::createMensajeError($errores, 'idcinema', 'span', array('class' => 'error'));
+
+ $html = '
+
+
+
+
Operacion realizada con exito
+
Se ha añadido el gerente correctamente en la base de datos.
+
Cerrar Mensaje
+
+
+
+ ";
+ $result = './?state=mg';
+ }
+ $exist->free();
+
+
+ }
+ return $result;
+ }
+
+ protected function test_input($input){
+ return htmlspecialchars(trim(strip_tags($input)));
+ }
+
+ private function showUsers() {
+ $user = new UserDAO("complucine");
+ $users = $user->allUsersNotM();
+ $ids = array();
+ $usernames = array();
+ $emails = array();
+ $roles = array();
+
+
+ foreach($users as $key => $value){
+ $ids[$key] = $value->getId();
+ $usernames[$key] = $value->getName();
+ $emails[$key] = $value->getEmail();
+ $roles[$key] = $value->getRol();
+ }
+ $html='';
+ for($i = 0; $i < count($users); $i++){
+ $html .= '
+
'.$ids[$i].', '.$usernames[$i].', '.$usernames[$key].'
+
+ ';
+ }
+ return $html;
+ }
+
+ private function showCinemas() {
+ $cine = new Cinema_DAO("complucine");
+ $cinemas = $cine->allCinemaData();
+ $ids = array();
+ $names = array();
+ $directions = array();
+ $phones = array();
+
+ foreach($cinemas as $key => $value){
+ $ids[$key] = $value->getId();
+ $names[$key] = $value->getName();
+ $directions[$key] = $value->getDirection();
+ $phones[$key] = $value->getPhone();
+ }
+ $html = '';
+ for($i = 0; $i < count($cinemas); $i++){
+ $html.= '
+
'.$ids[$i].', '.$names[$i].'
+
+ ';
+ }
+ return $html;
+ }
+
+
+}
+
+?>
\ No newline at end of file
diff --git a/panel_admin/includes/formDeleteManager.php b/panel_admin/includes/formDeleteManager.php
new file mode 100644
index 0000000..051ba92
--- /dev/null
+++ b/panel_admin/includes/formDeleteManager.php
@@ -0,0 +1,85 @@
+ "./?state=mg");
+ parent::__construct('formDeleteManager', $options);
+ }
+
+ protected function generaCamposFormulario($datos, $errores = array()){
+
+
+ // Se generan los mensajes de error si existen.
+ $htmlErroresGlobales = self::generaListaErroresGlobales($errores);
+ //$errorId = self::createMensajeError($errores, 'id', 'span', array('class' => 'error'));
+ //$errorIdCinema = self::createMensajeError($errores, 'idcinema', 'span', array('class' => 'error'));
+
+ $html = '
+
+ ¿Estás seguro de que quieres eliminar este gerente?
+
+ Id: '.$_POST['id'].'
+ IdCinema: '.$_POST['idcinema'].'
+ Nombre: '.$_POST['username'].'
+ Email: '.$_POST['email'].'
+ Rol: '.$_POST['rol'].'
+
+
+
+
+
+
';
+
+ return $html;
+ }
+
+ protected function procesaFormulario($datos){
+ $result = array();
+
+ $id = $this->test_input($datos['id']) ?? null;
+ if (is_null($id) ) {
+ $result[] = "ERROR. No existe un manager con ese ID";
+ }
+
+ if (count($result) === 0) {
+ $bd = new Manager_DAO('complucine');
+ $exist = $bd-> GetManager($id);
+ if( mysqli_num_rows($exist) == 1){
+ $bd->deleteManager($id);
+ $_SESSION['message'] = "
+
+
+
+
Operacion realizada con exito
+
Se ha eliminado el gerente correctamente en la base de datos.
+
Cerrar Mensaje
+
+
+
";
+ $result = './?state=mg';
+ }
+ else{
+ $result[] = "ERROR. No existe un manager con ese ID";
+ }
+
+
+ }
+ 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/formEditManager.php b/panel_admin/includes/formEditManager.php
new file mode 100644
index 0000000..1d43e46
--- /dev/null
+++ b/panel_admin/includes/formEditManager.php
@@ -0,0 +1,118 @@
+ "./?state=mg");
+ parent::__construct('formEditManager', $options);
+ }
+
+ protected function generaCamposFormulario($datos, $errores = array()){
+
+
+ // Se generan los mensajes de error si existen.
+ $htmlErroresGlobales = self::generaListaErroresGlobales($errores);
+ //$errorId = self::createMensajeError($errores, 'id', 'span', array('class' => 'error'));
+ //$errorIdCinema = self::createMensajeError($errores, 'idcinema', 'span', array('class' => 'error'));
+
+ $html = '
+
';
+
+ return $html;
+ }
+
+ protected function procesaFormulario($datos){
+ $result = array();
+
+ $id = $this->test_input($datos['id']) ?? null;
+ if (is_null($id) ) {
+ $result[] = "ERROR. No existe un usuario con ese ID";
+ }
+
+ $idcinema = $this->test_input($datos['idcinema']) ?? null;
+ //||!mb_ereg_match(self::HTML5_EMAIL_REGEXP, $duration)
+ if (is_null($idcinema)) {
+ $result[] = "ERROR. No existe un cine con ese ID";
+ }
+
+
+ if (count($result) === 0) {
+ $bd = new Manager_DAO("complucine");
+ $exist = $bd-> GetManager($id);
+ if( mysqli_num_rows($exist) == 1){
+ $bd->editManager($id,$idcinema);
+ $_SESSION['message'] = "
+
+
+
+
Operacion realizada con exito
+
Se ha editado el gerente correctamente en la base de datos.
+
Cerrar Mensaje
+
+
+
";
+ $result = './?state=mg';
+
+ }
+ else{
+ $result[] = "ERROR. No existe un cine con ese ID";
+ }
+ $exist->free();
+
+
+ }
+ return $result;
+ }
+
+ protected function test_input($input){
+ return htmlspecialchars(trim(strip_tags($input)));
+ }
+
+
+ private function showCinemas() {
+ $cine = new Cinema_DAO("complucine");
+ $cinemas = $cine->allCinemaData();
+ $ids = array();
+ $names = array();
+ $directions = array();
+ $phones = array();
+
+ foreach($cinemas as $key => $value){
+ $ids[$key] = $value->getId();
+ $names[$key] = $value->getName();
+ $directions[$key] = $value->getDirection();
+ $phones[$key] = $value->getPhone();
+ }
+ $html = '';
+ for($i = 0; $i < count($cinemas); $i++){
+ $html.= '
+
'.$ids[$i].', '.$names[$i].'
+
+ ';
+ }
+ return $html;
+ }
+
+
+}
+
+?>
\ No newline at end of file