unified code
This commit is contained in:
parent
45d0570e62
commit
ce6c3a92e2
@ -13,17 +13,11 @@
|
||||
|
||||
//Create a new Session.
|
||||
public function createFilm($id, $tittle, $duration, $language,$description){
|
||||
$exist = sprintf( "SELECT * FROM film WHERE tittle = '%s'", $tittle );
|
||||
$film =mysqli_query($this->mysqli, $exist) ;
|
||||
if($film.is_null() ||$film["language"]!=$language){
|
||||
$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');
|
||||
}else{
|
||||
die ('Error into query database film already exist');
|
||||
}
|
||||
return $sql;
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,7 @@ class FormFilm extends Form {
|
||||
$bd = new Film_DAO('complucine');
|
||||
if($bd ){
|
||||
if($option == "new"){
|
||||
//Primero comprobar si existe una pelicula con el mismo titulo e idioma
|
||||
$bd->createFilm(null, $title,$duration,$languaje,$description);
|
||||
} else if ($option == "del"){
|
||||
$bd->deleteFilm($id);
|
||||
|
@ -6,8 +6,6 @@
|
||||
require_once('../panel_admin/panelAdmin.php');
|
||||
$template = new Template();
|
||||
|
||||
if(isset($_SESSION["login"]) && $_SESSION["rol"] == "admin") $login = true;
|
||||
|
||||
if(isset($_REQUEST['state'])) {
|
||||
$panel = new Panel($_REQUEST['state']);
|
||||
}
|
||||
|
@ -35,7 +35,7 @@
|
||||
<td>'. $f->getLanguage() .'</td>
|
||||
<td>'. $f->getDescription().'</td>
|
||||
<td>
|
||||
<form method="post" action="./index.php?state=ef">
|
||||
<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().'">
|
||||
@ -45,7 +45,7 @@
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
<form method="post" action="./index.php?state=df">
|
||||
<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().'">
|
||||
@ -62,7 +62,7 @@
|
||||
function addFilm(){
|
||||
echo'<div class="column size">
|
||||
<h2>Añadir pelicula</h2>
|
||||
<form method="post" action="add_film.php">
|
||||
<form method="post" action="update_film.php">
|
||||
<div class="row">
|
||||
<fieldset id="film_form">
|
||||
<legend>Datos de pelicula</legend>
|
||||
|
@ -8,8 +8,7 @@
|
||||
|
||||
function showPanel() {
|
||||
switch($this->state) {
|
||||
case 'df': require('deleteFilm.php');break;
|
||||
case 'ef': require('editFilm.php');break;
|
||||
case 'uf': require('updateFilm.php');break;
|
||||
case 'mc': require('manage_cinemas.php'); break;
|
||||
case 'mf': require('manage_films.php'); break;
|
||||
case 'md': require('manage_discounts.php'); break;
|
||||
|
60
panel_admin/updateFilm.php
Normal file
60
panel_admin/updateFilm.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
include_once('./includes/film_dto.php');
|
||||
include_once('./includes/formFilm.php');
|
||||
|
||||
if(isset($_REQUEST['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='.$_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>';
|
||||
|
||||
}
|
||||
else if(isset($_REQUEST['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='.$_REQUEST['id'].'/>
|
||||
<p>Id: '.$_REQUEST['id'].' </p>
|
||||
<p>Título: '.$_REQUEST['tittle'].' </p>
|
||||
<p>Duración: '.$_REQUEST['duration'].' </p>
|
||||
<p>Idioma: '.$_REQUEST['language'].' </p>
|
||||
<p>Descripción: '.$_REQUEST['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>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
23
panel_admin/update_film.php
Normal file
23
panel_admin/update_film.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
session_start();
|
||||
include_once('./includes/film_dto.php');
|
||||
include_once('./includes/formFilm.php');
|
||||
|
||||
if(isset($_REQUEST['add_film'])) {
|
||||
$film = new FormFilm();
|
||||
$film->processesForm(null, $_REQUEST['tittle'], $_REQUEST['duration'], $_REQUEST['language'], $_REQUEST['description'], "new");
|
||||
$_SESSION['message'] = $film->getReply();
|
||||
}
|
||||
else if(isset($_REQUEST['confirm_delete_film'])) {
|
||||
$film = new FormFilm();
|
||||
$film->processesForm($_REQUEST['id'],null,null,null,null,"del");
|
||||
$_SESSION['message'] = $film->getReply();
|
||||
}
|
||||
else if(isset($_REQUEST['confirm_edit_film'])) {
|
||||
$film = new FormFilm();
|
||||
$film->processesForm($_REQUEST['id'], $_REQUEST['tittle'], $_REQUEST['duration'], $_REQUEST['language'], $_REQUEST['description'], "edit");
|
||||
$_SESSION['message'] = $film->getReply();
|
||||
}
|
||||
header("Location: ../panel_admin/index.php?state=mf");
|
||||
|
||||
?>
|
Loading…
Reference in New Issue
Block a user