diff --git a/panel_admin/manage_managers.php b/panel_admin/manage_managers.php index 12ca0a9..dded178 100644 --- a/panel_admin/manage_managers.php +++ b/panel_admin/manage_managers.php @@ -5,25 +5,28 @@ include_once('../assets/php/common/manager.php'); + include_once('../assets/php/common/cinema_dao.php'); + + include_once('../assets/php/common/user_dao.php'); + include_once(__DIR__.'/includes/formManager.php'); - // View functions function print_managers(){ $manager = new Manager_DAO("complucine"); $managers = $manager->allManagersData(); $ids = array(); + $idscinemas = array(); $usernames = array(); $email = array(); - $pass = array(); $rol = array(); foreach($managers as $key => $value){ $ids[$key] = $value->getId(); + $idscinemas[$key] = $value->getIdcinema(); $usernames[$key] = $value->getUsername(); $email[$key] = $value->getEmail(); - $pass[$key] = $value->getPass(); $rol[$key] = $value->getRoll(); } @@ -35,6 +38,7 @@ Id + IdCinema Nombre Email password @@ -43,29 +47,29 @@ "; - for($i = 0; $i < count($promos); $i++){ + for($i = 0; $i < count($managers); $i++){ echo ' '. $ids[$i] .' + '. $idscinemas[$i] .' '. $usernames[$i] .' '. $email[$i] .' - '. $pass[$i] .' '. $rol[$i] .' -
+ + -
-
+ + -
@@ -78,6 +82,8 @@
'; + + } @@ -85,25 +91,9 @@ echo'

Añadir gerente

-
-
- Datos del manager -
- -
-
- -
-
- -
-
- -
-
+
- - +
@@ -111,19 +101,66 @@ '; } + + function selectUser() { + echo'
+
+

Selecciona el usuario al que quieres dar privilegios.

+
+
+
+ Selecciona usuario.'; + + showUsers(); + echo '
+
+ + +
+
+
+
+
+ '; + + } + + function selectCinema() { + echo'
+
+

Selecciona el cine asociado al nuevo manager.

+
+
+
+ Selecciona cine.'; + + showCinemas(); + echo '
+
+ + + +
+
+
+
+
+ '; + + } function deleteManager() { echo'

Borrar gerente

-
+
¿Estás seguro de que quieres eliminar este gerente?

Id: '.$_POST['id'].'

+

IdCinema: '.$_POST['idcinema'].'

Nombre: '.$_POST['username'].'

Email: '.$_POST['email'].'

-

Password: '.$_POST['pass'].'

Rol: '.$_POST['rol'].'

@@ -136,54 +173,95 @@
'; } + + function editManager() { + echo'
-
-

Editar gerente

- +
+

Editar gerente ID: '.$_POST['id'].'

+
- Datos de la promoción - -
- -
-
- -
-
- -
-
+ Selecciona su cine.'; + showCinemas(); + echo '
+
- -
-
+ +
+
+ '; + + } + + // Show cinemas and users functions + 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(); + } + for($i = 0; $i < count($cinemas); $i++){ + echo ' + '; + } + } + 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(); + } + for($i = 0; $i < count($users); $i++){ + echo ' + + '; + } } // Logic Functions function confirmDelete() { - $cine = new FormPromotion(); - $cine->processesForm($_POST['id'],null,null,null,null,"del"); + $cine = new FormManager(); + $cine->processesForm($_POST['id'], null,"del"); $_SESSION['message'] = $cine->getReply(); - header('Location: ../panel_admin/index.php?state=mp'); + header('Location: ../panel_admin/index.php?state=mg'); } function confirmEdit() { - $cine = new FormPromotion(); - $cine->processesForm($_POST['id'], $_POST['username'], $_POST['email'], $_POST['pass'],"manager","edit"); - $_SESSION['message']= $cine->getReply(); - header('Location: ../panel_admin/index.php?state=mp'); + $manager = new FormManager(); + $manager->processesForm($_POST['id'], $_POST['idcinema'],"edit"); + $_SESSION['message']= $manager->getReply(); + header('Location: ../panel_admin/index.php?state=mg'); } function confirmAdd() { - $cine = new FormPromotion(); - $cine->processesForm(null,$_POST['username'], $_POST['email'], $_POST['pass'],"manager","new"); - $_SESSION['message'] = $cine->getReply(); - header('Location: ../panel_admin/index.php?state=mp'); + $manager = new FormManager(); + $manager->processesForm($_POST['iduser'], $_POST['idcinema'],"new"); + $_SESSION['message'] = $manager->getReply(); + header('Location: ../panel_admin/index.php?state=mg'); } diff --git a/panel_admin/panelAdmin.php b/panel_admin/panelAdmin.php index c8f3c0b..d1a86c2 100644 --- a/panel_admin/panelAdmin.php +++ b/panel_admin/panelAdmin.php @@ -34,6 +34,9 @@ }; break; case 'mf': require_once('manage_films.php'); + //echo $_SERVER['DOCUMENT_ROOT']."/../img"; + echo TMP_DIR; + //echo $_SERVER['PHP_SELF']; if(isset($_POST['edit_film'])) { editFilm(); } @@ -83,9 +86,16 @@ else if(isset($_POST['delete_manager'])) { deleteManager(); } + else if(isset($_POST['select_user'])) { + selectUser(); + } + else if(isset($_POST['select_cinema'])) { + selectCinema(); + } else if(isset($_POST['add_manager'])) { confirmAdd(); } + else if(isset($_POST['confirm_delete_manager'])) { confirmDelete(); }