😧
This commit is contained in:
@ -50,6 +50,28 @@
|
||||
return $resul;
|
||||
}*/
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function editFilm($id, $title, $duration, $lenguaje,$description){
|
||||
|
||||
$sql = sprintf( "UPDATE film
|
||||
SET title = '%s' , duration = '%d', lenguaje ='%s' ,`description` ='%s'
|
||||
WHERE `film`.`id` = '%d';",
|
||||
$title,$duration,$lenguaje, $description,$id );
|
||||
|
||||
$resul = mysqli_query($this->mysqli, $sql) or die ('Error into query database');
|
||||
|
||||
return $resul;
|
||||
}
|
||||
|
||||
|
||||
//Returns a query to get all films tittles.
|
||||
public function tittleFilmData(){
|
||||
$sql = sprintf( "SELECT tittle FROM film ");
|
||||
|
77
panel_admin/includes/formFilm.php
Normal file
77
panel_admin/includes/formFilm.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
include_once('film_dao.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;
|
||||
//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'><button>Panel Admin</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'><button>Panel Admin</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'><button>Panel Admin</button></a>";
|
||||
}
|
||||
} 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'><button>Panel Admin</button></a>";
|
||||
|
||||
}
|
||||
return $this->reply;
|
||||
}
|
||||
|
||||
//Process form:
|
||||
public function processesForm($id,$title,$duration,$languaje,$description, $option) {
|
||||
$this->correct = true;
|
||||
$this->option = $option;
|
||||
//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');
|
||||
if($bd ){
|
||||
if($option == "new"){
|
||||
$selectFilm = $bd->selectSession($cinema, $hall, $start, $date);
|
||||
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"){
|
||||
$bd->deleteFilm($id);
|
||||
} else if ($option == "edit"){
|
||||
$bd->editFilm($id,$title,$duration,$languaje,$description);
|
||||
}
|
||||
|
||||
} else {$this->correct = false;}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user