Add files via upload
This commit is contained in:
parent
a5f92c9bb0
commit
19168d2f8d
13
panel_admin/add_film.php
Normal file
13
panel_admin/add_film.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
include_once('./includes/film_dto.php');
|
||||||
|
include_once('./includes/formFilm.php');
|
||||||
|
|
||||||
|
if($_REQUEST['add_film']) {
|
||||||
|
$film = new FormFilm();
|
||||||
|
$film->processesForm(null, $_REQUEST['tittle'], $_REQUEST['duration'], $_REQUEST['language'], $_REQUEST['description'], "new");
|
||||||
|
$_SESSION['message'] = $film->getReply();
|
||||||
|
header("Location: ../panel_admin/index.php?state=mf");
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
37
panel_admin/editFilm.php
Normal file
37
panel_admin/editFilm.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
include_once('./includes/film_dto.php');
|
||||||
|
include_once('./includes/formFilm.php');
|
||||||
|
|
||||||
|
if($_REQUEST['edit_film']) {
|
||||||
|
echo'<div class="column size">
|
||||||
|
<h2>Editar pelicula</h2>
|
||||||
|
<form method="post" action="edit_film.php">
|
||||||
|
<div class="row">
|
||||||
|
<fieldset id="film_form">
|
||||||
|
<legend>Datos de pelicula</legend>
|
||||||
|
<input type="hidden" name="id" value='.$_REQUEST['id'].'/>
|
||||||
|
<div>
|
||||||
|
<input type="text" name="tittle" value='.$_REQUEST['tittle'].' />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<input type="number" name="duration" id="duration" value='.$_REQUEST['duration'].' />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<input type="text" name="language" id="language" value='.$_REQUEST['language'].' />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<input type="text" name="description" id="description" value='.$_REQUEST['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>';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
@ -1,40 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
include_once('./includes/film_dto.php');
|
session_start();
|
||||||
include_once('./includes/film_dao.php');
|
include_once('./includes/film_dto.php');
|
||||||
|
include_once('./includes/formFilm.php');
|
||||||
|
if($_REQUEST['confirm_edit_film']) {
|
||||||
$bd = new FilmDAO("complucine");
|
$film = new FormFilm();
|
||||||
|
$film->processesForm($_REQUEST['id'], $_REQUEST['tittle'], $_REQUEST['duration'], $_REQUEST['language'], $_REQUEST['description'], "edit");
|
||||||
if( $_REQUEST['option'] == 'edit') {
|
$_SESSION['message'] = $film->getReply();
|
||||||
$film = ($bd->FilmData($_GET["id"]));
|
header("Location: ../panel_admin/index.php?state=mf");
|
||||||
$filmDto=$bd->loadFilm($film['id'],$film['title'],$film['duration'],$film['languaje'].$film['description']);
|
}
|
||||||
|
|
||||||
echo'<div class="column size">
|
|
||||||
<h2>Editar pelicula</h2>
|
|
||||||
<form method="post" action="../panel_admin/validate.php">
|
|
||||||
<div class="row">
|
|
||||||
<fieldset id="film_form">
|
|
||||||
<legend>Datos de pelicula</legend>
|
|
||||||
<div>
|
|
||||||
<input type="text" name="title" id="title" value=\"".$filmDto.getTittle()."\" placeholder="Título" />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<input type="number" name="duration" id="duration" value=\"".$filmDto.getDuration()."\" placeholder="Duración" />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<input type="text" name="lenguage" id="language" value=\"".$filmDto.getLanguage()."\" placeholder="Idioma" />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<input type="text" name="description" id="description" value=\"".$filmDto.getDescription()."\" placeholder="Descripción" />
|
|
||||||
</div>
|
|
||||||
</fieldset>
|
|
||||||
<div class="actions">
|
|
||||||
<input type="submit" id="submit" value="Editar pelicula" name="edit_film" class="primary" />
|
|
||||||
<input type="reset" id="reset" value="Borrar" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>'."\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
?>
|
@ -14,12 +14,11 @@
|
|||||||
//Create a new Session.
|
//Create a new Session.
|
||||||
public function createFilm($id, $tittle, $duration, $language, $description){
|
public function createFilm($id, $tittle, $duration, $language, $description){
|
||||||
|
|
||||||
$sql = sprintf( "INSERT INTO film( $id, $tittle, $duration, $language, $description)
|
$sql = sprintf( "INSERT INTO film(tittle, duration, language, description)
|
||||||
VALUES ( '%d', '%s', '%d', '%s', '%d')",
|
VALUES ('%s', '%d', '%s', '%s')",
|
||||||
$id, $tittle, $duration, $language, $description);
|
$tittle, $duration, $language, $description);
|
||||||
|
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||||
|
return $resul;
|
||||||
return $sql;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Returns a query to get the film's data.
|
//Returns a query to get the film's data.
|
||||||
@ -52,19 +51,18 @@
|
|||||||
|
|
||||||
public function deleteFilm($id){
|
public function deleteFilm($id){
|
||||||
|
|
||||||
$sql = sprintf( "DELETE FROM `film` WHERE `film`.`id` = '%d' ;",$id);
|
$sql = sprintf( "DELETE FROM film WHERE film.id = '%d' ;",$id);
|
||||||
|
|
||||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||||
|
|
||||||
return $resul;
|
return $resul;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function editFilm($id, $title, $duration, $lenguaje,$description){
|
public function editFilm($id, $tittle, $duration, $language,$description){
|
||||||
|
|
||||||
$sql = sprintf( "UPDATE film
|
$sql = sprintf( "UPDATE film
|
||||||
SET title = '%s' , duration = '%d', lenguaje ='%s' ,`description` ='%s'
|
SET tittle = '%s' , duration = '%d', language ='%s' , description ='%s'
|
||||||
WHERE `film`.`id` = '%d';",
|
WHERE film.id = '%d';",
|
||||||
$title,$duration,$lenguaje, $description,$id );
|
$tittle,$duration,$language, $description,$id);
|
||||||
|
|
||||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ class FormFilm extends Form {
|
|||||||
private $correct; // Indicates if the session is correct.
|
private $correct; // Indicates if the session is correct.
|
||||||
private $reply; // Validation response
|
private $reply; // Validation response
|
||||||
private $option;
|
private $option;
|
||||||
|
private $array;
|
||||||
//Constructor:
|
//Constructor:
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
parent::__construct('formFilm');
|
parent::__construct('formFilm');
|
||||||
@ -18,26 +19,27 @@ class FormFilm extends Form {
|
|||||||
|
|
||||||
|
|
||||||
public function getReply() {
|
public function getReply() {
|
||||||
|
|
||||||
|
|
||||||
if($this->correct){
|
if($this->correct){
|
||||||
if($this->option == "new"){
|
if($this->option == "new"){
|
||||||
$this->reply = "<h1> Operacion realizada con exito </h1><hr />
|
$this->reply = "<h1> Operacion realizada con exito </h1><hr />
|
||||||
<p> Se ha añadido la pelicula correctamente en la base de datos.</p>
|
<p> Se ha añadido la pelicula correctamente en la base de datos.</p>
|
||||||
<a href='../panel_admin/index.php'><button>Panel Admin</button></a>";
|
<a href='../panel_admin/index.php?state=mf'><button>Cerrar Mensaje</button></a>";
|
||||||
}else if($this->option == "edit"){
|
}else if($this->option == "edit"){
|
||||||
$this->reply = "<h1> Operacion realizada con exito </h1><hr />
|
$this->reply = "<h1> Operacion realizada con exito </h1><hr />
|
||||||
<p> Se ha editado la pelicula correctamente en la base de datos.</p>
|
<p> Se ha editado la pelicula correctamente en la base de datos.</p>
|
||||||
<a href='../panel_admin/index.php'><button>Panel Admin</button></a>";
|
<a href='../panel_admin/index.php?state=mf'><button>Cerrar Mensaje</button></a>";
|
||||||
}else if($this->option == "del"){
|
}else if($this->option == "del"){
|
||||||
$this->reply = "<h1> Operacion realizada con exito </h1><hr />
|
$this->reply = "<h1> Operacion realizada con exito </h1><hr />
|
||||||
<p> Se ha eliminado la pelicula correctamente en la base de datos.</p>
|
<p> Se ha eliminado la pelicula correctamente en la base de datos.</p>
|
||||||
<a href='../panel_admin/index.php'><button>Panel Admin</button></a>";
|
<a href='../panel_admin/index.php?state=mf'><button>Cerrar Mensaje</button></a>";
|
||||||
|
} else if($this->option == "show"){
|
||||||
|
$this->reply= $this->array;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$this->reply = "<h1> ERROR </h1><hr />
|
$this->reply = "<h1> ERROR </h1><hr />
|
||||||
<p> Ha habido un error en la operacion. Revisa los datos introducidos</p>
|
<p> Ha habido un error en la operacion. Revisa los datos introducidos</p>
|
||||||
<a href='../panel_admin/index.php'><button>Panel Admin</button></a>";
|
<a href='../panel_admin/index.php?state=mf'><button>Panel Admin</button></a>";
|
||||||
|
|
||||||
}
|
}
|
||||||
return $this->reply;
|
return $this->reply;
|
||||||
@ -47,27 +49,20 @@ class FormFilm extends Form {
|
|||||||
public function processesForm($id,$title,$duration,$languaje,$description, $option) {
|
public function processesForm($id,$title,$duration,$languaje,$description, $option) {
|
||||||
$this->correct = true;
|
$this->correct = true;
|
||||||
$this->option = $option;
|
$this->option = $option;
|
||||||
|
|
||||||
//Habria que validar todo para que encaje en la base de datos
|
//Habria que validar todo para que encaje en la base de datos
|
||||||
|
|
||||||
$start = date('H:i:s', strtotime( $start ) );
|
|
||||||
$date = date('Y-m-d', strtotime( $date ) );
|
|
||||||
|
|
||||||
$bd = new FilmDAO('complucine');
|
$bd = new FilmDAO('complucine');
|
||||||
if($bd ){
|
if($bd ){
|
||||||
if($option == "new"){
|
if($option == "new"){
|
||||||
$selectFilm = $bd->selectSession($cinema, $hall, $start, $date);
|
$bd->createFilm(null, $title,$duration,$languaje,$description);
|
||||||
if($selectSession && $selectSession->num_rows >= 1) {
|
|
||||||
$this->correct = false;
|
|
||||||
} else{
|
|
||||||
$bd->createFilm(null, $title,$duration,$languaje,$description);
|
|
||||||
}
|
|
||||||
mysqli_free_result($selectSession);
|
|
||||||
} else if ($option == "del"){
|
} else if ($option == "del"){
|
||||||
$bd->deleteFilm($id);
|
$bd->deleteFilm($id);
|
||||||
} else if ($option == "edit"){
|
} else if ($option == "edit"){
|
||||||
$bd->editFilm($id,$title,$duration,$languaje,$description);
|
$bd->editFilm($id,$title,$duration,$languaje,$description);
|
||||||
|
} else if($this->option == "show") {
|
||||||
|
$this->array = $bd->allFilmData();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {$this->correct = false;}
|
} else {$this->correct = false;}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
|
||||||
require('./includes/film_dto.php');
|
require('./includes/film_dto.php');
|
||||||
require('./includes/film_dao.php');
|
require('./includes/formFilm.php');
|
||||||
/*$f1 = new FilmDTO(1000,"Los vengadores",183,"español","");
|
/*$f1 = new FilmDTO(1000,"Los vengadores",183,"español","");
|
||||||
$f2 = new FilmDTO(2001,"Mecernarios",140,"español","");
|
$f2 = new FilmDTO(2001,"Mecernarios",140,"español","");
|
||||||
$f3 = new FilmDTO(3022,"Monster hunter",104,"español","");
|
$f3 = new FilmDTO(3022,"Monster hunter",104,"español","");
|
||||||
$f4 = new FilmDTO(4560,"Godzilla vs kong",113,"inglés","");
|
$f4 = new FilmDTO(4560,"Godzilla vs kong",113,"inglés","");
|
||||||
$f5 = new FilmDTO(4260,"Tom y Jerry",131,"inglés","");
|
$f5 = new FilmDTO(4260,"Tom y Jerry",131,"inglés","");
|
||||||
$f6 = new FilmDTO(4606,"Pequeños Detalles",127,"inglés","");
|
$f6 = new FilmDTO(4606,"Pequeños Detalles",127,"inglés","");
|
||||||
$film= array($f1, $f2, $f3, $f4,$f5,$f6); */
|
$film= array($f1, $f2, $f3, $f4,$f5,$f6); */
|
||||||
|
|
||||||
$bd = new FilmDAO("complucine");
|
$film = new FormFilm();
|
||||||
function drawFilms($films){
|
$film->processesForm(null, null, null, null, null, "show");
|
||||||
|
|
||||||
|
function drawFilms($films){
|
||||||
|
|
||||||
echo "
|
echo "
|
||||||
<table class='alt'>
|
<table class='alt'>
|
||||||
<thead>
|
<thead>
|
||||||
@ -25,38 +27,47 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>";
|
<tbody>";
|
||||||
foreach($films as $f){
|
foreach($films as $f){
|
||||||
echo "
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td>" . $f->getId() . "</td>
|
<td>'. $f->getId() .'</td>
|
||||||
<td>" . $f->getTittle() . "</td>
|
<td>'. $f->getTittle() .'</td>
|
||||||
<td>" . $f->getDuration() . "</td>
|
<td>'. $f->getDuration() .'</td>
|
||||||
<td>". $f->getLanguage() . "</td>
|
<td>'. $f->getLanguage() .'</td>
|
||||||
<td>". $f->getDescription()."</td>
|
<td>'. $f->getDescription().'</td>
|
||||||
<td> <input type=submit name=\"submit\" value=\"Editar\" class=\"button\" formaction=\"./?state=edit_film&option=edit&id=". $f->getId()."\"/> </td>
|
<td>
|
||||||
<td> <input type=submit name=\"submit\" value=\"Borrar\" class=\"button\" formaction=\"./?state=validate&option=del&id=" . $f->getId()."\"/> </td>
|
<form method="post" action="./index.php?state=ef">
|
||||||
</tr>";
|
<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> <input type=submit name="submit" value="Borrar" class="button" formaction="delete_film.php"> </td>
|
||||||
|
</tr>';
|
||||||
}
|
}
|
||||||
echo "<tbody>
|
echo'<tbody>
|
||||||
</table>\n";
|
</table>';
|
||||||
}
|
}
|
||||||
function addFilm(){
|
function addFilm(){
|
||||||
echo'<div class="column size">
|
echo'<div class="column size">
|
||||||
<h2>Añadir pelicula</h2>
|
<h2>Añadir pelicula</h2>
|
||||||
<form method=\"post\" action="../panel_admin/validades.php">
|
<form method="post" action="add_film.php">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<fieldset id="film_form">
|
<fieldset id="film_form">
|
||||||
<legend>Datos de pelicula</legend>
|
<legend>Datos de pelicula</legend>
|
||||||
<div>
|
<div>
|
||||||
<input type="text" name="title" id="title" value="" placeholder="Título" />
|
<input type="text" name="tittle" id="tittle" placeholder="Título" />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<input type="number" name="duration" id="duration" value="" placeholder="Duración" />
|
<input type="number" name="duration" id="duration" placeholder="Duración" />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<input type="text" name="lenguage" id="language" value="" placeholder="Idioma" />
|
<input type="text" name="language" id="language" placeholder="Idioma" />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<input type="text" name="description" id="description" value="" placeholder="Descripción" />
|
<input type="text" name="description" id="description" placeholder="Descripción" />
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
@ -65,11 +76,18 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>'."\n";
|
</div>';
|
||||||
|
}
|
||||||
|
function showmessage() {
|
||||||
|
if(isset($_SESSION['message'])){
|
||||||
|
echo '<div>
|
||||||
|
<h3>'.$_SESSION["message"].'</h3>
|
||||||
|
</div>';
|
||||||
|
unset($_SESSION['message']);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
drawFilms($bd->allFilmData());
|
showmessage();
|
||||||
|
drawFilms($film->getReply());
|
||||||
addFilm();
|
addFilm();
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
function showPanel() {
|
function showPanel() {
|
||||||
switch($this->state) {
|
switch($this->state) {
|
||||||
|
case 'ef': require('editFilm.php');break;
|
||||||
case 'mc': require('manage_cinemas.php'); break;
|
case 'mc': require('manage_cinemas.php'); break;
|
||||||
case 'mf': require('manage_films.php'); break;
|
case 'mf': require('manage_films.php'); break;
|
||||||
case 'md': require('manage_discounts.php'); break;
|
case 'md': require('manage_discounts.php'); break;
|
||||||
|
Loading…
Reference in New Issue
Block a user