Edicion del index y el panel

Todavia no estan tocadas las funcionalidades de ver como
This commit is contained in:
marian1010 2021-05-20 10:45:10 +02:00
parent 4dbefa6860
commit e93b191100
2 changed files with 228 additions and 257 deletions

View File

@ -4,55 +4,139 @@
require_once($prefix.'panel_admin/panelAdmin.php'); require_once($prefix.'panel_admin/panelAdmin.php');
$login=false;
if(isset($_SESSION["login"]) && $_SESSION["rol"] == "admin") $login = true; if(($_SESSION["login"]) && $_SESSION["rol"] == "admin"){
if(isset($_GET['state'])) { if(!isset($_GET["state"]))
$panel = new Panel($_GET['state'], $login); $_GET["state"] =null;
switch($_GET["state"]){
case 'mc': if(isset($_POST['edit_cinema'])) {
$reply=AdminPanel::editCinema();
}
else if(isset($_POST['delete_cinema'])) {
$reply=AdminPanel::deleteCinema();
} }
else { else {
$panel = new Panel('', $login); $reply=AdminPanel::addCinema();
$reply.= ($template->print_cinemas());
};
break;
case 'mf': if(isset($_POST['edit_film'])) {
$reply=AdminPanel::editFilm();
}
else if(isset($_POST['delete_film'])) {
$reply=AdminPanel::deleteFilm();
}
else {
$reply=AdminPanel::addFilm();
$reply.= $template->print_fimls();
};
break;
case 'mp':
if(isset($_POST['edit_promotion'])) {
$reply=AdminPanel::editPromotion();
}
else if(isset($_POST['delete_promotion'])) {
$reply=AdminPanel::deletePromotion();
}
else {
$reply=AdminPanel::addPromotion();
$reply.=AdminPanel::print_promotions();
};
break;
case 'mg': if(isset($_POST['edit_manager'])) {
$reply=AdminPanel::editManager();
}
else if(isset($_POST['delete_manager'])) {
$reply=AdminPanel::deleteManager();
}
else if(isset($_POST['add_manager'])) {
$reply=AdminPanel::addManager();
} }
?> else {
<!DOCTYPE HTML> $reply=AdminPanel::showAddBotton();
<!-- $reply.=AdminPanel::print_managers();
Práctica - Sistemas Web | Grupo D };
CompluCine - FDI-cines break;
--> case 'un':
<html lang="es"> $_SESSION["lastRol"] = $_SESSION["rol"];
<!-- Head --> //unset($_SESSION["rol"]);
<?php $_SESSION["rol"] = null;
$template->print_head(); header("Location: {$_SERVER['PHP_SELF']}");
?> $_SESSION['message'] = "<div class='row'>
<body> <div class='column side'></div>
<!-- Header --> <div class='column middle'>
<?php <div class='code info'>
$template->print_header(); <h1> ¡ATENCIÓN! </h1><hr />
?> <p>Está viendo la web como un Usuario NO Registrado.</p>
<a href=''><button>Cerrar Mensaje</button></a>
</div>
</div>
<div class='column side'></div>
</div>
";
break;
case 'ur':
$_SESSION["lastRol"] = $_SESSION["rol"];
$_SESSION["rol"] = "user";
header("Location: {$_SERVER['PHP_SELF']}");
$_SESSION['message'] = "<div class='row'>
<div class='column side'></div>
<div class='column middle'>
<div class='code info'>
<h1> ¡ATENCIÓN! </h1><hr />
<p>Está viendo la web como un Usuario Registrado.</p>
<a href=''><button>Cerrar Mensaje</button></a>
</div>
</div>
<div class='column side'></div>
</div>
";
break;
case 'ag':
$_SESSION["lastRol"] = $_SESSION["rol"];
$_SESSION["rol"] = "manager";
header("Location: {$_SERVER['PHP_SELF']}");
$_SESSION['message'] = "<div class='row'>
<div class='column side'></div>
<div class='column middle'>
<div class='code info'>
<h1> ¡ATENCIÓN! </h1><hr />
<p>Está viendo la web como un Gerente.</p>
<a href=''><button>Cerrar Mensaje</button></a>
</div>
</div>
<div class='column side'></div>
</div>
";
break;
default:
$reply=AdminPanel:: panel();
break;
}
}
else{
$reply ='<div class="column side"></div>
<div class="column middle">
<div class="code info">
<h1>No tienes permiso de administrador.</h1><hr />
<p>Inicia Sesión con una cuenta de administtación.</p>
<a href="'.$prefix.'login/"><button>Iniciar Sesión</button></a>
</div>
</div>
<div class="column side"></div>'."\n";
}
<!-- Main --> $section = '<!-- Manager Admin -->
<?php <section id="admin_panel">
$template->print_main();
?>
<!-- Panel -->
<div class="row">
<!-- Panel Menu -->
<?php
$template->print_panelMenu($_SESSION["rol"]);
?>
<!-- Contents --> <!-- Contents -->
<div class="row"> <div class="row">
<?php '.$reply.'
$template->print_msg();
$panel->showPanel($template);
?>
</div> </div>
</div> </section>';
<!-- Footer -->
<?php
$template->print_footer();
?>
</body>
</html> require RAIZ_APP.'/HTMLtemplate.php';
?>

View File

@ -1,172 +1,52 @@
<?php <?php
class Panel { class AdminPanel {
private $state; private $state;
private $login; private $login;
private $prefix; private $prefix;
function __construct($panel, $login){ function __construct(){}
$this->state = $panel;
$this->login= $login;
}
function showPanel($template) {
$this->prefix = $template->get_prefix();
if($this->login){
switch($this->state) {
case 'mc': if(isset($_POST['edit_cinema'])) {
$this->editCinema();
}
else if(isset($_POST['delete_cinema'])) {
$this->deleteCinema();
}
else {
$this-> addCinema();
echo ($template->print_cinemas());
};
break;
case 'mf': if(isset($_POST['edit_film'])) {
$this->editFilm();
}
else if(isset($_POST['delete_film'])) {
$this->deleteFilm();
}
else {
$this->addFilm();
echo( $template->print_fimls());
};
break;
case 'mp':
if(isset($_POST['edit_promotion'])) {
$this->editPromotion();
}
else if(isset($_POST['delete_promotion'])) {
$this->deletePromotion();
}
else {
$this->addPromotion();
$this->print_promotions();
};
break;
case 'mg': if(isset($_POST['edit_manager'])) {
$this->editManager();
}
else if(isset($_POST['delete_manager'])) {
$this->deleteManager();
}
else if(isset($_POST['add_manager'])) {
$this->addManager();
}
else {
$this->showAddBotton();
$this->print_managers();
};
break;
case 'un':
$_SESSION["lastRol"] = $_SESSION["rol"];
//unset($_SESSION["rol"]);
$_SESSION["rol"] = null;
header("Location: {$_SERVER['PHP_SELF']}");
$_SESSION['message'] = "<div class='row'>
<div class='column side'></div>
<div class='column middle'>
<div class='code info'>
<h1> ¡ATENCIÓN! </h1><hr />
<p>Está viendo la web como un Usuario NO Registrado.</p>
<a href=''><button>Cerrar Mensaje</button></a>
</div>
</div>
<div class='column side'></div>
</div>
";
break;
case 'ur':
$_SESSION["lastRol"] = $_SESSION["rol"];
$_SESSION["rol"] = "user";
header("Location: {$_SERVER['PHP_SELF']}");
$_SESSION['message'] = "<div class='row'>
<div class='column side'></div>
<div class='column middle'>
<div class='code info'>
<h1> ¡ATENCIÓN! </h1><hr />
<p>Está viendo la web como un Usuario Registrado.</p>
<a href=''><button>Cerrar Mensaje</button></a>
</div>
</div>
<div class='column side'></div>
</div>
";
break;
case 'ag':
$_SESSION["lastRol"] = $_SESSION["rol"];
$_SESSION["rol"] = "manager";
header("Location: {$_SERVER['PHP_SELF']}");
$_SESSION['message'] = "<div class='row'>
<div class='column side'></div>
<div class='column middle'>
<div class='code info'>
<h1> ¡ATENCIÓN! </h1><hr />
<p>Está viendo la web como un Gerente.</p>
<a href=''><button>Cerrar Mensaje</button></a>
</div>
</div>
<div class='column side'></div>
</div>
";
break;
default: echo '<div class="code info">
<h1>Bienvenido al Panel de Administrador.</h1>
<hr />
</div>'."\n"; break;
}
}
else {
echo '<div class="column side"></div>
<div class="column middle">
<div class="code info">
<h1>No tienes permiso de administrador.</h1><hr />
<p>Inicia Sesión con una cuenta de administtación.</p>
<a href="'.$this->prefix.'login/"><button>Iniciar Sesión</button></a>
</div>
</div>
<div class="column side"></div>'."\n";
}
}
function getTemplate(){ function getTemplate(){
return $this->template; return $this->template;
} }
static function panel(){
return $reply= '<div class="code info">
<h1>Bienvenido al Panel de Administrador.</h1>
<hr />
</div>'."\n";
}
//Functions FILMS //Functions FILMS
function addFilm(){ static function addFilm(){
include_once('./includes/formAddFilm.php'); include_once('./includes/formAddFilm.php');
$formAF = new formAddFilm(); $formAF = new formAddFilm();
$htmlAForm = $formAF->gestiona(); $htmlAForm = $formAF->gestiona();
echo '<!-- Add film --> return $reply= '<!-- Add film -->
<div class="column side"></div> <div class="column side"></div>
<div class="column middle"> <div class="column middle">
'.$htmlAForm.' '.$htmlAForm.'
</div>'."\n"; </div>'."\n";
} }
function deleteFilm() { static function deleteFilm() {
include_once('./includes/formDeleteFilm.php'); include_once('./includes/formDeleteFilm.php');
$formDF = new formDeleteFilm(); $formDF = new formDeleteFilm();
$htmlDForm = $formDF->gestiona(); $htmlDForm = $formDF->gestiona();
echo '<!-- Add film --> return $reply= '<!-- Add film -->
<div class="column side"></div> <div class="column side"></div>
<div class="column middle"> <div class="column middle">
'.$htmlDForm.' '.$htmlDForm.'
</div>'."\n"; </div>'."\n";
} }
function editFilm() {
static function editFilm() {
include_once('./includes/formEditFilm.php'); include_once('./includes/formEditFilm.php');
$formEF = new formEditFilm(); $formEF = new formEditFilm();
$htmlDForm = $formEF->gestiona(); $htmlDForm = $formEF->gestiona();
echo '<!-- Add film --> return $reply= '<!-- Add film -->
<div class="column side"></div> <div class="column side"></div>
<div class="column middle"> <div class="column middle">
'.$htmlDForm.' '.$htmlDForm.'
@ -174,33 +54,33 @@
} }
//Functions Cinemas //Functions Cinemas
function addCinema(){ static function addCinema(){
include_once('./includes/formAddCinema.php'); include_once('./includes/formAddCinema.php');
$formAC = new formAddCinema(); $formAC = new formAddCinema();
$htmlAForm = $formAC->gestiona(); $htmlAForm = $formAC->gestiona();
echo '<!-- Add cinema --> return $reply= '<!-- Add cinema -->
<div class="column side"></div> <div class="column side"></div>
<div class="column middle"> <div class="column middle">
'.$htmlAForm.' '.$htmlAForm.'
</div>'."\n"; </div>'."\n";
} }
function deleteCinema() { static function deleteCinema() {
include_once('./includes/formDeleteCinema.php'); include_once('./includes/formDeleteCinema.php');
$formDC = new formDeleteCinema(); $formDC = new formDeleteCinema();
$htmlDForm = $formDC->gestiona(); $htmlDForm = $formDC->gestiona();
echo '<!-- Delete cinema --> return $reply= '<!-- Delete cinema -->
<div class="column side"></div> <div class="column side"></div>
<div class="column middle"> <div class="column middle">
'.$htmlDForm.' '.$htmlDForm.'
</div>'."\n"; </div>'."\n";
} }
function editCinema() { static function editCinema() {
include_once('./includes/formEditCinema.php'); include_once('./includes/formEditCinema.php');
$formEC = new formEditCinema(); $formEC = new formEditCinema();
$htmlDForm = $formEC->gestiona(); $htmlDForm = $formEC->gestiona();
echo '<!-- Edit cinema --> return $reply= '<!-- Edit cinema -->
<div class="column side"></div> <div class="column side"></div>
<div class="column middle"> <div class="column middle">
'.$htmlDForm.' '.$htmlDForm.'
@ -209,7 +89,7 @@
//Functions MANAGERS //Functions MANAGERS
function print_managers(){ static function print_managers(){
include_once('../assets/php/common/manager_dao.php'); include_once('../assets/php/common/manager_dao.php');
include_once('../assets/php/common/manager.php'); include_once('../assets/php/common/manager.php');
$manager = new Manager_DAO("complucine"); $manager = new Manager_DAO("complucine");
@ -228,7 +108,7 @@
$rol[$key] = $value->getRoll(); $rol[$key] = $value->getRoll();
} }
} }
echo "<div class='row'> $reply= "<div class='row'>
<div class='column side'></div> <div class='column side'></div>
<div class='column middle'> <div class='column middle'>
<table class='alt'> <table class='alt'>
@ -245,7 +125,7 @@
"; ";
if(is_array($managers)){ if(is_array($managers)){
for($i = 0; $i < count($managers); $i++){ for($i = 0; $i < count($managers); $i++){
echo '<tr> $reply.= '<tr>
<td>'. $ids[$i] .'</td> <td>'. $ids[$i] .'</td>
<td>'. $idscinemas[$i] .'</td> <td>'. $idscinemas[$i] .'</td>
<td>'. $usernames[$i] .'</td> <td>'. $usernames[$i] .'</td>
@ -272,15 +152,16 @@
'; ';
} }
} }
echo'</tbody> $reply.='</tbody>
</table> </table>
</div> </div>
<div class="column side"></div> <div class="column side"></div>
</div> </div>
'; ';
return $reply;
} }
function showAddBotton() { static function showAddBotton() {
echo' <div class="column side"></div> return $reply = '<div class="column side"></div>
<div class="column middle"> <div class="column middle">
<h2>Añadir gerente</h2> <h2>Añadir gerente</h2>
<form method="post" action="index.php?state=mg"> <form method="post" action="index.php?state=mg">
@ -293,11 +174,11 @@
</div> </div>
'; ';
} }
function addManager(){ static function addManager(){
include_once('./includes/formAddManager.php'); include_once('./includes/formAddManager.php');
$formAM = new formAddManager(); $formAM = new formAddManager();
$htmlAForm = $formAM->gestiona(); $htmlAForm = $formAM->gestiona();
echo '<!-- ADD MANAGER --> return $reply= '<!-- ADD MANAGER -->
<div class="column side"></div> <div class="column side"></div>
<div class="column middle"> <div class="column middle">
<h3>AÑADIR GERENTE</h3> <h3>AÑADIR GERENTE</h3>
@ -305,11 +186,11 @@
</div> </div>
<div class="column side"></div>'."\n"; <div class="column side"></div>'."\n";
} }
function editManager(){ static function editManager(){
include_once('./includes/formEditManager.php'); include_once('./includes/formEditManager.php');
$formEM = new formEditManager(); $formEM = new formEditManager();
$htmlEForm = $formEM->gestiona(); $htmlEForm = $formEM->gestiona();
echo '<!-- EDIT MANAGER --> return $reply= '<!-- EDIT MANAGER -->
<div class="column side"></div> <div class="column side"></div>
<div class="column middle"> <div class="column middle">
<h3>EDITAR GERENTE</h3> <h3>EDITAR GERENTE</h3>
@ -318,11 +199,11 @@
<div class="column side"></div>'."\n"; <div class="column side"></div>'."\n";
} }
function deleteManager(){ static function deleteManager(){
include_once('./includes/formDeleteManager.php'); include_once('./includes/formDeleteManager.php');
$formDM = new formDeleteManager(); $formDM = new formDeleteManager();
$htmlDForm = $formDM->gestiona(); $htmlDForm = $formDM->gestiona();
echo '<!-- DELETE MANAGER --> return $reply= '<!-- DELETE MANAGER -->
<div class="column side"></div> <div class="column side"></div>
<div class="column middle"> <div class="column middle">
<h3>ELIMINAR GERENTE</h3> <h3>ELIMINAR GERENTE</h3>
@ -333,11 +214,11 @@
//Functions PROMOTIONS //Functions PROMOTIONS
function addPromotion(){ static function addPromotion(){
include_once('./includes/formAddPromotion.php'); include_once('./includes/formAddPromotion.php');
$formAP = new formAddPromotion(); $formAP = new formAddPromotion();
$htmlAForm = $formAP->gestiona(); $htmlAForm = $formAP->gestiona();
echo '<!-- ADD PROMOTION --> return $reply= '<!-- ADD PROMOTION -->
<div class="column side"></div> <div class="column side"></div>
<div class="column middle"> <div class="column middle">
<h3>AÑADIR PROMOCIÓN</h3> <h3>AÑADIR PROMOCIÓN</h3>
@ -345,11 +226,12 @@
</div> </div>
<div class="column side"></div>'."\n"; <div class="column side"></div>'."\n";
} }
function editPromotion(){
static function editPromotion(){
include_once('./includes/formEditPromotion.php'); include_once('./includes/formEditPromotion.php');
$formEP = new formEditPromotion(); $formEP = new formEditPromotion();
$htmlEForm = $formEP->gestiona(); $htmlEForm = $formEP->gestiona();
echo '<!-- EDIT MANAGER --> return $reply= '<!-- EDIT MANAGER -->
<div class="column side"></div> <div class="column side"></div>
<div class="column middle"> <div class="column middle">
<h3>EDITAR PROMOCIÓN</h3> <h3>EDITAR PROMOCIÓN</h3>
@ -358,11 +240,11 @@
<div class="column side"></div>'."\n"; <div class="column side"></div>'."\n";
} }
function deletePromotion(){ static function deletePromotion(){
include_once('./includes/formDeletePromotion.php'); include_once('./includes/formDeletePromotion.php');
$formDP = new formDeletePromotion(); $formDP = new formDeletePromotion();
$htmlDForm = $formDP->gestiona(); $htmlDForm = $formDP->gestiona();
echo '<!-- DELETE MANAGER --> return $reply= '<!-- DELETE MANAGER -->
<div class="column side"></div> <div class="column side"></div>
<div class="column middle"> <div class="column middle">
<h3>ELIMINAR PROMOCIÓN</h3> <h3>ELIMINAR PROMOCIÓN</h3>
@ -370,7 +252,7 @@
</div>'."\n"; </div>'."\n";
} }
function print_promotions(){ static function print_promotions(){
$promo = new Promotion_DAO("complucine"); $promo = new Promotion_DAO("complucine");
$promos = $promo->allPromotionData(); $promos = $promo->allPromotionData();
$ids = array(); $ids = array();
@ -389,7 +271,8 @@
} }
} }
echo " $reply= "<div class='row'>
<div class='column middle'> <div class='column middle'>
<table class='alt'> <table class='alt'>
<thead> <thead>
@ -405,7 +288,7 @@
"; ";
if(is_array($promos)){ if(is_array($promos)){
for($i = 0; $i < count($promos); $i++){ for($i = 0; $i < count($promos); $i++){
echo '<tr> $reply.= '<tr>
<td>'. $ids[$i] .'</td> <td>'. $ids[$i] .'</td>
<td>'. $tittles[$i] .'</td> <td>'. $tittles[$i] .'</td>
<td>'. $descriptions[$i] .'</td> <td>'. $descriptions[$i] .'</td>
@ -435,14 +318,18 @@
'; ';
} }
} }
echo'</tbody> $reply.='</tbody>
</table> </table>
</div> </div>
<div class="column side"></div> <div class="column side"></div>
</div>
'; ';
return $reply ;
} }
} }
?> ?>