This commit is contained in:
Daniel Muñoz Garcia 2021-05-13 11:47:47 +02:00 committed by GitHub
parent 4dad0c48ee
commit 258829ae2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -64,33 +64,19 @@
}; };
break; break;
case 'mg': require_once('manage_managers.php'); case 'mg': if(isset($_POST['edit_manager'])) {
if(isset($_POST['edit_manager'])) { $this->editManager();
editManager();
} }
else if(isset($_POST['delete_manager'])) { else if(isset($_POST['delete_manager'])) {
deleteManager(); $this->deleteManager();
}
else if(isset($_POST['select_user'])) {
selectUser();
}
else if(isset($_POST['select_cinema'])) {
selectCinema();
} }
else if(isset($_POST['add_manager'])) { else if(isset($_POST['add_manager'])) {
confirmAdd(); $this->addManager();
} }
else if(isset($_POST['confirm_delete_manager'])) {
confirmDelete();
}
else if(isset($_POST['confirm_edit_manager'])) {
confirmEdit();
}
else { else {
addManager(); $this->showAddBotton();
print_managers(); $this->print_managers();
}; };
break; break;
case 'un': echo"<h1>En construcción</h1>"; break; case 'un': echo"<h1>En construcción</h1>"; break;
@ -99,7 +85,11 @@
default: echo "<h1>BIENVENIDO AL PANEL DE ADMINISTRADOR</h1>"; break; default: echo "<h1>BIENVENIDO AL PANEL DE ADMINISTRADOR</h1>"; break;
} }
} }
else {
echo "<h1>NO TIENES PERMISOS DE ADMINISTRADOR</h1>";
} }
}
function getTemplate(){ function getTemplate(){
return $this->template; return $this->template;
} }
@ -136,6 +126,7 @@
'.$htmlDForm.' '.$htmlDForm.'
</div>'."\n"; </div>'."\n";
} }
//Functions Cinemas //Functions Cinemas
function addCinema(){ function addCinema(){
include_once('./includes/formAddCinema.php'); include_once('./includes/formAddCinema.php');
@ -169,6 +160,126 @@
'.$htmlDForm.' '.$htmlDForm.'
</div>'."\n"; </div>'."\n";
} }
//Functions MANAGERS
function print_managers(){
include_once('../assets/php/common/manager_dao.php');
include_once('../assets/php/common/manager.php');
$manager = new Manager_DAO("complucine");
$managers = $manager->allManagersData();
$ids = array();
$idscinemas = array();
$usernames = array();
$email = array();
$rol = array();
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 "<div class='row'>
<div class='column side'></div>
<div class='column middle'>
<table class='alt'>
<thead>
<tr>
<th>Id</th>
<th>IdCinema</th>
<th>Nombre</th>
<th>Email</th>
<th>password</th>
<th>Rol</th>
</tr>
</thead>
<tbody>
";
for($i = 0; $i < count($managers); $i++){
echo '<tr>
<td>'. $ids[$i] .'</td>
<td>'. $idscinemas[$i] .'</td>
<td>'. $usernames[$i] .'</td>
<td>'. $email[$i] .'</td>
<td>'. $rol[$i] .'</td>
<td>
<form method="post" action="index.php?state=mg">
<input name="id" type="hidden" value="'.$ids[$i].'">
<input name="idcinema" type="hidden" value="'.$idscinemas[$i].'">
<input type="submit" id="submit" value="Editar" name="edit_manager" class="primary" />
</form>
</td>
<td>
<form method="post" action="index.php?state=mg">
<input name="id" type="hidden" value="'.$ids[$i].'">
<input name="idcinema" type="hidden" value="'.$idscinemas[$i].'">
<input name="username" type="hidden" value="'.$usernames[$i].'">
<input name="email" type="hidden" value="'.$email[$i].'">
<input name="rol" type="hidden" value="'.$rol[$i].'">
<input type="submit" id="submit" value="Eliminar" name="delete_manager" class="primary" />
</form>
</td>
</tr>
';
}
echo'</tbody>
</table>
</div>
<div class="column side"></div>
';
}
function showAddBotton() {
echo'<div class="column side"></div>
<div class="column middle">
<h2>Añadir gerente</h2>
<form method="post" action="index.php?state=mg">
<div class="actions">
<input type="submit" id="submit" value="Añadir gerente" name="add_manager" class="primary" />
</div>
</form>
</div>
</div>';
}
function addManager(){
include_once('./includes/formAddManager.php');
$formAM = new formAddManager();
$htmlAForm = $formAM->gestiona();
echo '<!-- ADD MANAGER -->
<div class="column side"></div>
<div class="column middle">
<h3>AÑADIR GERENTE</h3>
'.$htmlAForm.'
</div>'."\n";
}
function editManager(){
include_once('./includes/formEditManager.php');
$formEM = new formEditManager();
$htmlEForm = $formEM->gestiona();
echo '<!-- EDIT MANAGER -->
<div class="column side"></div>
<div class="column middle">
<h3>EDITAR GERENTE</h3>
'.$htmlEForm.'
</div>'."\n";
}
function deleteManager(){
include_once('./includes/formDeleteManager.php');
$formDM = new formDeleteManager();
$htmlDForm = $formDM->gestiona();
echo '<!-- DELETE MANAGER -->
<div class="column side"></div>
<div class="column middle">
<h3>ELIMINAR GERENTE</h3>
'.$htmlDForm.'
</div>'."\n";
}
} }
?> ?>