Add files via upload
This commit is contained in:
103
panel_admin/includes/film_dao.php
Normal file
103
panel_admin/includes/film_dao.php
Normal file
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
include_once('film_dto.php');
|
||||
$template = new Template();
|
||||
$prefix = $template->get_prefix();
|
||||
include_once($prefix.'assets/php/dao.php');
|
||||
|
||||
class Film_DAO extends DAO {
|
||||
|
||||
//Constructor:
|
||||
function __construct($bd_name){
|
||||
parent::__construct($bd_name);
|
||||
}
|
||||
|
||||
//Methods:
|
||||
|
||||
//Create a new Session.
|
||||
public function createFilm($id, $tittle, $duration, $language,$description){
|
||||
$sql = sprintf( "INSERT INTO `film`( `id`, `tittle`, `duration`, `language`,`description`)
|
||||
VALUES ( '%d', '%s', '%d', '%s','%s')",
|
||||
$id, $tittle, $duration, $language,$description);
|
||||
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
return $resul;
|
||||
}
|
||||
//Returns a film data .
|
||||
public function GetFilm($tittle,$language){
|
||||
$sql = sprintf( "SELECT * FROM film WHERE film.tittle = '%s'AND film.language='%s'", $tittle,$language );
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
return $resul;
|
||||
}
|
||||
|
||||
//Returns a query to get the film's data.
|
||||
public function FilmData($id){
|
||||
$sql = sprintf( "SELECT * FROM film WHERE id = '%d'", $id );
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
return $resul;
|
||||
}
|
||||
|
||||
//Returns a query to get All the films.
|
||||
public function allFilmData(){
|
||||
$sql = sprintf( "SELECT * FROM film ");
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
while($fila=$resul->fetch_assoc()){
|
||||
$films[] = $this->loadFilm($fila["id"], $fila["tittle"], $fila["duration"], $fila["language"], $fila["description"]);
|
||||
}
|
||||
$resul->free();
|
||||
return $films;
|
||||
}
|
||||
|
||||
|
||||
//Returns a query to get all films tittles.
|
||||
public function tittleFilmData(){
|
||||
$sql = sprintf( "SELECT DISTINCT tittle FROM film ");
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
return $resul;
|
||||
}
|
||||
|
||||
//Returns a query to get all films descriptions.
|
||||
public function descriptionFilmData(){
|
||||
$sql = sprintf( "SELECT description FROM film ");
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
return $resul;
|
||||
}
|
||||
|
||||
/*
|
||||
public function addFilm($films) {
|
||||
$resul = mysqli_query($this->mysqli, $this->createFilm($film.getId(), $film.getTittle(), $film.getDuration(), $film.getLanguage(), $film.getDescription())) or die ('Error into query database');
|
||||
return $resul;
|
||||
}
|
||||
*/
|
||||
|
||||
//Deleted film by "id".
|
||||
public function deleteFilm($id){
|
||||
$sql = sprintf( "DELETE FROM film WHERE film.id = '%d' ;",$id);
|
||||
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
return $resul;
|
||||
}
|
||||
|
||||
//Edit a film.
|
||||
public function editFilm($id, $tittle, $duration, $language,$description){
|
||||
$sql = sprintf( "UPDATE film SET tittle = '%s' , duration = '%d', language ='%s' , description ='%s'
|
||||
WHERE film.id = '%d';",
|
||||
$tittle, $duration, $language, $description, $id);
|
||||
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
return $resul;
|
||||
}
|
||||
|
||||
//Create a new film Data Transfer Object.
|
||||
public function loadFilm($id, $tittle, $duration, $language,$description){
|
||||
return new Film_DTO( $id, $tittle, $duration, $language,$description);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
37
panel_admin/includes/film_dto.php
Normal file
37
panel_admin/includes/film_dto.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
include_once('film_dto_interface.php');
|
||||
|
||||
class Film_DTO implements FilmDTO {
|
||||
|
||||
//Attributes:
|
||||
private $_id; //Film ID.
|
||||
private $_tittle; //Film tittle.
|
||||
private $_duration; //Film duration.
|
||||
private $_language; //Film language.
|
||||
private $_description; //Film description.
|
||||
|
||||
|
||||
//Constructor:
|
||||
function __construct($id, $tittle, $duration, $language, $description){
|
||||
$this->_id = $id;
|
||||
$this->_tittle = $tittle;
|
||||
$this->_duration = $duration;
|
||||
$this->_language = $language;
|
||||
$this->_description = $description;
|
||||
}
|
||||
|
||||
//Methods:
|
||||
|
||||
//Getters && Setters:
|
||||
public function setId($id){ $this->_id = $id; }
|
||||
public function getId(){ return $this->_id; }
|
||||
public function setTittle($tittle) {$this->_tittle = $tittle; }
|
||||
public function getTittle(){return $this->_tittle;}
|
||||
public function setDuration($duration){$this->_duration = $duration; }
|
||||
public function getDuration() {return $this->_duration;}
|
||||
public function setLanguage($language) {$this->_language = $language; }
|
||||
public function getLanguage(){return $this->_language;}
|
||||
public function setDescription($description){ $this->_description = $description;}
|
||||
public function getDescription(){return $this->_description;}
|
||||
}
|
||||
?>
|
14
panel_admin/includes/film_dto_interface.php
Normal file
14
panel_admin/includes/film_dto_interface.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
interface FilmDTO {
|
||||
public function setId($id);
|
||||
public function getId();
|
||||
public function setTittle($tittle);
|
||||
public function getTittle();
|
||||
public function setDuration($duration);
|
||||
public function getDuration();
|
||||
public function setLanguage($language);
|
||||
public function getLanguage();
|
||||
public function setDescription($description);
|
||||
public function getDescription();
|
||||
}
|
||||
?>
|
121
panel_admin/includes/formFilm.php
Normal file
121
panel_admin/includes/formFilm.php
Normal file
@ -0,0 +1,121 @@
|
||||
<?php
|
||||
include_once('../assets/php/config.php');
|
||||
include_once('film_dao.php');
|
||||
include_once('film_dto.php');
|
||||
include_once('../assets/php/form.php');
|
||||
|
||||
class FormFilm extends Form {
|
||||
|
||||
//Atributes:
|
||||
private $correct; // Indicates if the session is correct.
|
||||
private $reply; // Validation response
|
||||
private $option;
|
||||
private $array;
|
||||
//Constructor:
|
||||
public function __construct() {
|
||||
parent::__construct('formFilm');
|
||||
$this->reply = array();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getReply() {
|
||||
if($this->correct){
|
||||
if($this->option == "new"){
|
||||
$this->reply = "<h1> Operacion realizada con exito </h1><hr />
|
||||
<p> Se ha añadido la pelicula correctamente en la base de datos.</p>
|
||||
<a href='../panel_admin/index.php?state=mf'><button>Cerrar Mensaje</button></a>";
|
||||
}else if($this->option == "edit"){
|
||||
$this->reply = "<h1> Operacion realizada con exito </h1><hr />
|
||||
<p> Se ha editado la pelicula correctamente en la base de datos.</p>
|
||||
<a href='../panel_admin/index.php?state=mf'><button>Cerrar Mensaje</button></a>";
|
||||
}else if($this->option == "del"){
|
||||
$this->reply = "<h1> Operacion realizada con exito </h1><hr />
|
||||
<p> Se ha eliminado la pelicula correctamente en la base de datos.</p>
|
||||
<a href='../panel_admin/index.php?state=mf'><button>Cerrar Mensaje</button></a>";
|
||||
} else if($this->option == "show"){
|
||||
$this->reply= $this->array;
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->reply = "<h1> ERROR </h1><hr />
|
||||
<p> Ha habido un error en la operacion. Revisa los datos introducidos</p>
|
||||
<a href='../panel_admin/index.php?state=mf'><button>Panel Admin</button></a>";
|
||||
|
||||
}
|
||||
return $this->reply;
|
||||
}
|
||||
|
||||
//Process form:
|
||||
public function processesForm($_id,$_tittle,$_duration,$_language,$_description, $_option) {
|
||||
$this->correct = true;
|
||||
$this->option = $_option;
|
||||
|
||||
$id= $this->test_input($_id);
|
||||
$tittle=$this->test_input($_tittle);
|
||||
$duration=$this->test_input($_duration);
|
||||
$language=$this->test_input($_language);
|
||||
$description=$this->test_input($_description);
|
||||
|
||||
//Habria que validar todo para que encaje en la base de datos
|
||||
|
||||
$bd = new Film_DAO('complucine');
|
||||
if($bd){
|
||||
if($this->option == "new"){
|
||||
//Primero comprobar si los campos no son vacios y la duracion es mayor que 0
|
||||
if(!empty($tittle)&&$duration>0&&!empty($language)&&!empty($description)){
|
||||
// comprobar si existe una pelicula con el mismo titulo e idioma
|
||||
$exist = $bd-> GetFilm($tittle,$language);
|
||||
if( mysqli_num_rows($exist) != 0){
|
||||
$this->correct =false;
|
||||
}
|
||||
else{
|
||||
$bd->createFilm(null, $tittle,$duration,$language,$description);
|
||||
|
||||
}
|
||||
$exist->free();
|
||||
}
|
||||
else{
|
||||
$this->correct =false;
|
||||
}
|
||||
} else if ($this->option == "del"){
|
||||
//Primero comprobar si existe una pelicula con el mismo id
|
||||
$exist = $bd-> FilmData($id);
|
||||
if( mysqli_num_rows($exist) == 1){
|
||||
$bd->deleteFilm($id);
|
||||
}
|
||||
else{
|
||||
$this->correct =false;
|
||||
}
|
||||
} else if ($this->option == "edit"){
|
||||
//Primero comprobar si los campos no son vacios y la duracion es mayor que 0
|
||||
if(!empty($tittle)&&$duration>0&&!empty($language)&&!empty($description)){
|
||||
//comprobar si existe una pelicula con el mismo id
|
||||
$exist = $bd-> FilmData($id);
|
||||
if( mysqli_num_rows($exist) == 1){
|
||||
$bd->editFilm($id,$tittle,$duration,$language,$description);
|
||||
}
|
||||
else{
|
||||
$this->correct =false;
|
||||
}
|
||||
$exist->free();
|
||||
}
|
||||
else{
|
||||
$this->correct =false;
|
||||
}
|
||||
} else if($this->option == "show") {
|
||||
$this->array = $bd->allFilmData();
|
||||
}
|
||||
else {$this->correct = false;}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected function test_input($input){
|
||||
return htmlspecialchars(trim(strip_tags($input)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
79
panel_admin/index.php
Normal file
79
panel_admin/index.php
Normal file
@ -0,0 +1,79 @@
|
||||
<!DOCTYPE HTML>
|
||||
<?php
|
||||
//General Config File:
|
||||
include_once('../assets/php/config.php');
|
||||
|
||||
require_once('../panel_admin/panelAdmin.php');
|
||||
|
||||
$login=false;
|
||||
if(isset($_SESSION["login"]) && $_SESSION["rol"] == "admin") $login = true;
|
||||
if(isset($_GET['state'])) {
|
||||
$panel = new Panel($_GET['state'], $login);
|
||||
}
|
||||
else {
|
||||
$panel = new Panel('', $login);
|
||||
}
|
||||
// IMPORTANTE:
|
||||
// VERIFICAR QUE ES ADMIN, SI NO, MOSTRAR MENSAJE DE "ERROR"
|
||||
|
||||
?>
|
||||
<!--
|
||||
Práctica 2 - Sistemas Web | Grupo D
|
||||
CompluCine - FDI-cines
|
||||
-->
|
||||
<html lang="es">
|
||||
<!-- Head -->
|
||||
<?php
|
||||
$template->print_head();
|
||||
?>
|
||||
<body>
|
||||
<!-- Header -->
|
||||
<?php
|
||||
$template->print_header();
|
||||
?>
|
||||
|
||||
<!-- Main -->
|
||||
<?php
|
||||
$template->print_main();
|
||||
?>
|
||||
|
||||
<!-- Panel -->
|
||||
<div class="row">
|
||||
<!-- Left Sidebar -->
|
||||
<div class="sidebar left">
|
||||
<ul>
|
||||
<li>Ver como:</li>
|
||||
<ul>
|
||||
<li><a href="index.php?state=un">Usuario no registrado</a></li>
|
||||
<li><a href="index.php?state=ur">Usuario registrado</a></li>
|
||||
<li><a href="index.php?state=ag">Gerente</a></li>
|
||||
</ul><br />
|
||||
<li>Añadir/Editar/Eliminar:</li>
|
||||
<ul>
|
||||
<li><a href="index.php?state=mc">Cines</a></li>
|
||||
<li><a href="index.php?state=mf">Películas</a></li>
|
||||
<li><a href="index.php?state=md">Promociones</a></li>
|
||||
<li><a href="index.php?state=mg">Gerente</a></li>
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
<!-- Contents -->
|
||||
<div class="row">
|
||||
<div class="column side"></div>
|
||||
<div class="column middle">
|
||||
<?php
|
||||
$template->print_msg();
|
||||
$panel->showPanel();
|
||||
?>
|
||||
</div>
|
||||
<div class="column side"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Footer -->
|
||||
<?php
|
||||
$template->print_footer();
|
||||
?>
|
||||
</body>
|
||||
|
||||
</html>
|
67
panel_admin/manage_cinemas.php
Normal file
67
panel_admin/manage_cinemas.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
$cinema = array(
|
||||
"idCine" => "1234",
|
||||
"name" => "cineJuan",
|
||||
"address"=> "calle..",
|
||||
"phone_number"=>"660099000",
|
||||
);
|
||||
|
||||
$delete_cinemas='<!-- delete_cinemas -->
|
||||
<div class="column left">
|
||||
<h2>Lista de cines</h2>
|
||||
<br></br>
|
||||
<div class="row">
|
||||
<table>
|
||||
<tr>
|
||||
<th>idCine</th>
|
||||
<th>nombre</th>
|
||||
<th>Dirección</th>
|
||||
<th>Teléfono</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> '. $cinema['idCine'] .' </td>
|
||||
<td> '. $cinema['name'] .' </td>
|
||||
<td> '. $cinema['address'] .' </td>
|
||||
<td> '. $cinema['phone_number'] .' </td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>'."\n";
|
||||
$add_cinemas='<!-- Add_cinemas -->
|
||||
<div class="column side">
|
||||
<h2>Añadir o modificar cine</h2>
|
||||
<form method="post" action="add_cinema.php">
|
||||
<div class="row">
|
||||
<fieldset id="datos_cine">
|
||||
<legend>Datos del cine</legend>
|
||||
<div class="_idCine">
|
||||
<input type="text" name="idCine" id="idCine" value="" placeholder="IdCine" />
|
||||
</div>
|
||||
<div class="_name">
|
||||
<input type="text" name="name" id="name" value="" placeholder="Nombre" />
|
||||
</div>
|
||||
<div class="_address">
|
||||
<input type="text" name="address" id="address" value="" placeholder="Direccion" />
|
||||
</div>
|
||||
<div class="_phone_number">
|
||||
<input type="number" name="phone_number" id="phone_number" value="" placeholder="Teléfono" />
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class="actions">
|
||||
<input type="submit" id="submit" value="Añadir cine" class="primary" />
|
||||
<input type="reset" id="reset" value="Borrar" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>'."\n";
|
||||
?>
|
92
panel_admin/manage_films.php
Normal file
92
panel_admin/manage_films.php
Normal file
@ -0,0 +1,92 @@
|
||||
<?php
|
||||
include_once('./includes/film_dto.php');
|
||||
include_once('./includes/formFilm.php');
|
||||
/*$f1 = new FilmDTO(1000,"Los vengadores",183,"español","");
|
||||
$f2 = new FilmDTO(2001,"Mecernarios",140,"español","");
|
||||
$f3 = new FilmDTO(3022,"Monster hunter",104,"español","");
|
||||
$f4 = new FilmDTO(4560,"Godzilla vs kong",113,"inglés","");
|
||||
$f5 = new FilmDTO(4260,"Tom y Jerry",131,"inglés","");
|
||||
$f6 = new FilmDTO(4606,"Pequeños Detalles",127,"inglés","");
|
||||
$film= array($f1, $f2, $f3, $f4,$f5,$f6); */
|
||||
|
||||
$film = new FormFilm();
|
||||
$film->processesForm(null, null, null, null, null, "show");
|
||||
|
||||
function drawFilms($films){
|
||||
echo "
|
||||
<table class='alt'>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<th>Título</th>
|
||||
<th>Duracion</th>
|
||||
<th>Idioma</th>
|
||||
<th>Descripcion</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>";
|
||||
foreach($films as $f){
|
||||
echo '
|
||||
<tr>
|
||||
<td>'. $f->getId() .'</td>
|
||||
<td>'. $f->getTittle() .'</td>
|
||||
<td>'. $f->getDuration() .'</td>
|
||||
<td>'. $f->getLanguage() .'</td>
|
||||
<td>'. $f->getDescription().'</td>
|
||||
<td>
|
||||
<form method="post" action="./index.php?state=uf">
|
||||
<input name="id" type="hidden" value="'.$f->getId().'">
|
||||
<input name="tittle" type="hidden" value="'.$f->getTittle().'">
|
||||
<input name="duration" type="hidden" value="'.$f->getDuration().'">
|
||||
<input name="language" type="hidden" value="'.$f->getLanguage().'">
|
||||
<input name="description" type="hidden" value="'.$f->getDescription().'">
|
||||
<input type="submit" id="submit" value="Editar" name="edit_film" class="primary" />
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
<form method="post" action="./index.php?state=uf">
|
||||
<input name="id" type="hidden" value="'.$f->getId().'">
|
||||
<input name="tittle" type="hidden" value="'.$f->getTittle().'">
|
||||
<input name="duration" type="hidden" value="'.$f->getDuration().'">
|
||||
<input name="language" type="hidden" value="'.$f->getLanguage().'">
|
||||
<input name="description" type="hidden" value="'.$f->getDescription().'">
|
||||
<input type="submit" id="submit" value="Eliminar" name="delete_film" class="primary" />
|
||||
</form>
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
echo'<tbody>
|
||||
</table>';
|
||||
}
|
||||
function addFilm(){
|
||||
echo'<div class="column size">
|
||||
<h2>Añadir pelicula</h2>
|
||||
<form method="post" action="update_film.php">
|
||||
<div class="row">
|
||||
<fieldset id="film_form">
|
||||
<legend>Datos de pelicula</legend>
|
||||
<div>
|
||||
<input type="text" name="tittle" id="tittle" placeholder="Título" />
|
||||
</div>
|
||||
<div>
|
||||
<input type="number" name="duration" id="duration" placeholder="Duración" />
|
||||
</div>
|
||||
<div>
|
||||
<input type="text" name="language" id="language" placeholder="Idioma" />
|
||||
</div>
|
||||
<div>
|
||||
<input type="text" name="description" id="description" placeholder="Descripción" />
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class="actions">
|
||||
<input type="submit" id="submit" value="Añadir pelicula" name="add_film" class="primary" />
|
||||
<input type="reset" id="reset" value="Borrar" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>';
|
||||
}
|
||||
drawFilms($film->getReply());
|
||||
addFilm();
|
||||
|
||||
?>
|
30
panel_admin/panelAdmin.php
Normal file
30
panel_admin/panelAdmin.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
class Panel {
|
||||
public $state;
|
||||
public $login;
|
||||
function __construct($panel, $login){
|
||||
$this->state = $panel;
|
||||
$this->login= $login;
|
||||
}
|
||||
|
||||
function showPanel() {
|
||||
if($this->login){
|
||||
switch($this->state) {
|
||||
case 'uf': require_once('updateFilm.php');break;
|
||||
case 'mc': /*require_once('manage_cinemas.php')*/;echo"<h1>En construcción</h1>"; break;
|
||||
case 'mf': require_once('manage_films.php'); break;
|
||||
case 'md': /*require_once('manage_discounts.php')*/;echo"<h1>En construcción</h1>"; break;
|
||||
case 'mm': /*require_once('manage_managers.php')*/;echo"<h1>En construcción</h1>"; break;
|
||||
case 'un': echo"<h1>En construcción</h1>"; break;
|
||||
case 'ur': echo"<h1>En construcción</h1>";; break;
|
||||
case 'ag': echo"<h1>En construcción</h1>";; break;
|
||||
default: echo "<h1>BIENVENIDO AL PANEL DE ADMINISTRADOR</h1>"; break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo "<h1>NO TIENES PERMISOS DE ADMINISTRADOR</h1>";
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
59
panel_admin/updateFilm.php
Normal file
59
panel_admin/updateFilm.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
require_once('../assets/php/dao.php');
|
||||
include_once('./includes/formFilm.php');
|
||||
|
||||
if(isset($_POST['edit_film'])) {
|
||||
echo'<div class="column size">
|
||||
<h2>Editar pelicula</h2>
|
||||
<form method="post" action="update_film.php">
|
||||
<div class="row">
|
||||
<fieldset id="film_form">
|
||||
<legend>Datos de pelicula</legend>
|
||||
<input type="hidden" name="id" value='.$_POST['id'].'/>
|
||||
<div>
|
||||
<input type="text" name="tittle" value="'.$_POST['tittle'].'" />
|
||||
</div>
|
||||
<div>
|
||||
<input type="number" name="duration" id="duration" value='.$_POST['duration'].' />
|
||||
</div>
|
||||
<div>
|
||||
<input type="text" name="language" id="language" value="'.$_POST['language'].'" />
|
||||
</div>
|
||||
<div>
|
||||
<input type="text" name="description" id="description" value="'.$_POST['description'].'"/>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class="actions">
|
||||
<input type="submit" id="submit" value="Editar" name="confirm_edit_film" class="primary" />
|
||||
<input type="reset" id="reset" value="Borrar" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>';
|
||||
}
|
||||
else if(isset($_POST['delete_film'])) {
|
||||
echo'<div class="column size">
|
||||
<h2>Editar pelicula</h2>
|
||||
<form method="post" action="update_film.php">
|
||||
<div class="row">
|
||||
<fieldset id="film_form">
|
||||
<legend>¿Estás seguro de que quieres eliminar esta pelicula?</legend>
|
||||
<input type="hidden" name="id" value='.$_POST['id'].'/>
|
||||
<p>Id: '.$_POST['id'].' </p>
|
||||
<p>Título: '.$_POST['tittle'].' </p>
|
||||
<p>Duración: '.$_POST['duration'].' </p>
|
||||
<p>Idioma: '.$_POST['language'].' </p>
|
||||
<p>Descripción: '.$_POST['description'].' </p>
|
||||
</fieldset>
|
||||
<div class="actions">
|
||||
<input type="submit" id="submit" value="Eliminar" name="confirm_delete_film" class="primary" />
|
||||
<input type="submit" id="submit" value="Cancelar" name="cancel_delete_film" class="primary" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
22
panel_admin/update_film.php
Normal file
22
panel_admin/update_film.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
include_once('./includes/film_dto.php');
|
||||
include_once('./includes/formFilm.php');
|
||||
|
||||
if(isset($_POST['add_film'])) {
|
||||
$film = new FormFilm();
|
||||
$film->processesForm(null, $_POST['tittle'], $_POST['duration'], $_POST['language'], $_POST['description'], "new");
|
||||
$_SESSION['message'] = $film->getReply();
|
||||
}
|
||||
else if(isset($_POST['confirm_delete_film'])) {
|
||||
$film = new FormFilm();
|
||||
$film->processesForm($_POST['id'],null,null,null,null,"del");
|
||||
$_SESSION['message'] = $film->getReply();
|
||||
}
|
||||
else if(isset($_POST['confirm_edit_film'])) {
|
||||
$film = new FormFilm();
|
||||
$film->processesForm($_POST['id'], $_POST['tittle'], $_POST['duration'], $_POST['language'], $_POST['description'], "edit");
|
||||
$_SESSION['message']= $film->getReply();
|
||||
}
|
||||
header('Location: ../panel_admin/index.php?state=mf');
|
||||
|
||||
?>
|
Reference in New Issue
Block a user