cinemas
This commit is contained in:
parent
b9383645fe
commit
40d1964d6a
@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Film{
|
||||
|
||||
//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;}
|
||||
|
||||
|
||||
}
|
||||
?>
|
92
panel_admin/includes/formAddCinema.php
Normal file
92
panel_admin/includes/formAddCinema.php
Normal file
@ -0,0 +1,92 @@
|
||||
<?php
|
||||
//General Config File:
|
||||
include_once('../assets/php/config.php');
|
||||
include_once('../assets/php/common/cinema_dao.php');
|
||||
include_once('../assets/php/common/cinema.php');
|
||||
include_once('../assets/php/form.php');
|
||||
|
||||
class formAddCinema extends Form{
|
||||
|
||||
public function __construct(){
|
||||
$op = array("action"= ."./?state=mc">);
|
||||
parent::__construct('formAddCinema',$op)
|
||||
}
|
||||
|
||||
protected function generaCamposFormulario($datos,$errores=array()){
|
||||
|
||||
$htmlErroresGlobales = self::generaListaErroresGlobales($errores);
|
||||
$errorName = self::createMensajeError($errores,'name','span',array('class'=>'error'));
|
||||
$errorDirection = self::createMensajeError($errores,'direction','span',array('class'=>'error'));
|
||||
$errrorPhone = self ::createMensajeError($errores,'phone',array('class'=>'error'));
|
||||
|
||||
$html = '<div class="column side"></div>
|
||||
<fieldset id = "cinema_form">'.$htmlErroresGlobales.'</pre>
|
||||
<legend>Añadir cine</legend>
|
||||
<input type="text" name="name" id="name" placeholder="Nombre" required/><pre>'.$errorName.'</pre>
|
||||
<input type="text" name="direction" id="direction" placeholder="Direccion" required/><pre>'.$errorDirection.'</pre>
|
||||
<input type="text" name="phone" id="phone" placeholder="Teléfono" required/><pre>'.$errrorPhone.'</pre>
|
||||
</fieldset>
|
||||
<div class="actions">
|
||||
<input type="submit" id="submit" value="Añadir cine" name="add_cinema" class="primary" />
|
||||
<input type="reset" id="reset" value="Borrar" />
|
||||
</div>
|
||||
</div> ';
|
||||
return $html;
|
||||
}
|
||||
|
||||
//Process form:
|
||||
public function procesaFormulario($datos) {
|
||||
$result =array();
|
||||
|
||||
$name = $this->test_input($datos['name'])??null;
|
||||
|
||||
if(empty($name)){
|
||||
$result['name']= "El nombre no es válido";
|
||||
}
|
||||
|
||||
$direction = $this -> test_input($datos['direction']) ?? null;
|
||||
|
||||
if(empty($direction)){
|
||||
$result['direction'] = "La dirección no es valida";
|
||||
}
|
||||
|
||||
$phone = $this -> test_input($datos['phone']) ?? null;
|
||||
|
||||
if(empty($phone)){
|
||||
$result['phone'] = "El teléfono no es valido";
|
||||
}
|
||||
|
||||
if(count($result)===0){
|
||||
|
||||
$bd = new Cinema_DAO('complucine');
|
||||
$exist = $bd -> GetCinema($name,$direction);
|
||||
if(mysqli_num_rows($exist)!=0){
|
||||
$result[] = "Ya existe un cine con ese nombre o dirección";
|
||||
}
|
||||
else{
|
||||
$bd->createCinema(null,$name,$direction,$phone);
|
||||
$_SESSION['message'] = "<div class='row'>
|
||||
<div class='column side'></div>
|
||||
<div class='column middle'>
|
||||
<div class='code info'>
|
||||
<h1> Operacion realizada con exito </h1><hr />
|
||||
<p> Se ha añadido el cine correctamente en la base de datos.</p>
|
||||
<a href='../panel_admin/index.php?state=mc'><button>Cerrar Mensaje</button></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class='column side'></div>
|
||||
</div>
|
||||
";
|
||||
$result = './?state=mc';
|
||||
}
|
||||
$exist->free();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function test_input($input){
|
||||
return htmlspecialchars(trim(strip_tags($input)));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
78
panel_admin/includes/formDeleteCinema.php
Normal file
78
panel_admin/includes/formDeleteCinema.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
//General Config File:
|
||||
include_once('../assets/php/config.php');
|
||||
include_once('../assets/php/common/cinema_dao.php');
|
||||
include_once('../assets/php/common/cinema.php');
|
||||
include_once('../assets/php/form.php');
|
||||
|
||||
class formDeleteCinema extends Form{
|
||||
|
||||
public function __construct(){
|
||||
$op = array("action"= ."./?state=mc">);
|
||||
parent::__construct('formDeleteCinema',$op)
|
||||
}
|
||||
|
||||
protected function generaCamposFormulario($datos,$errores=array()){
|
||||
|
||||
$htmlErroresGlobales = self::generaListaErroresGlobales($errores);
|
||||
|
||||
|
||||
$html = '<div class="column side"></div>
|
||||
<fieldset id = "cinema_form">'.$htmlErroresGlobales.'</pre>
|
||||
<legend>¿Estás seguro de que quieres eliminar este cine?</legend>
|
||||
<input type="hidden" name="id" value='.$_POST['name'].'/>
|
||||
<p>Name: '.$_POST['name'].' </p>
|
||||
<p>Dirección: '.$_POST['direction'].' </p>
|
||||
<p>Teléfono: '.$_POST['phone'].' </p>
|
||||
</fieldset>
|
||||
<div class="actions">
|
||||
<input type="submit" id="submit" value="Eliminar" name="delete_cinema" class="primary" />
|
||||
<input type="submit" id="submit" value="Cancelar" class="primary" />
|
||||
</div>
|
||||
</div> ';
|
||||
return $html;
|
||||
}
|
||||
|
||||
//Process form:
|
||||
public function procesaFormulario($datos) {
|
||||
$result =array();
|
||||
|
||||
$id = $this->test_input($datos['id'])??null;
|
||||
|
||||
if(empty($id)){
|
||||
$result['name']= "El nombre no es válido";
|
||||
}
|
||||
|
||||
if(count($result)===0){
|
||||
$bd = new Cinema_DAO('complucine');
|
||||
$exist = $bd -> cinemaData($id);
|
||||
if(mysqli_num_rows($exist)==1){
|
||||
$bd->deleteFilm($id);
|
||||
$_SESSION['message'] = "<div class='row'>
|
||||
<div class='column side'></div>
|
||||
<div class='column middle'>
|
||||
<div class='code info'>
|
||||
<h1> Operacion realizada con exito </h1><hr />
|
||||
<p> Se ha eliminado el cine correctamente en la base de datos.</p>
|
||||
<a href='../panel_admin/index.php?state=mc'><button>Cerrar Mensaje</button></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class='column side'></div>
|
||||
</div>
|
||||
";
|
||||
$result = './?state=mc';
|
||||
}
|
||||
$exist->free()
|
||||
}
|
||||
else{
|
||||
$result[] = "El cine seleccionado no existe.";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function test_input($input){
|
||||
return htmlspecialchars(trim(strip_tags($input)));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
106
panel_admin/includes/formEditCinema.php
Normal file
106
panel_admin/includes/formEditCinema.php
Normal file
@ -0,0 +1,106 @@
|
||||
<?php
|
||||
//General Config File:
|
||||
include_once('../assets/php/config.php');
|
||||
include_once('../assets/php/common/cinema_dao.php');
|
||||
include_once('../assets/php/common/cinema.php');
|
||||
include_once('../assets/php/form.php');
|
||||
|
||||
class formEditCinema extends Form{
|
||||
|
||||
public function __construct(){
|
||||
$op = array("action"= ."./?state=mc">);
|
||||
parent::__construct('formEditCinema',$op)
|
||||
}
|
||||
|
||||
protected function generaCamposFormulario($datos,$errores=array()){
|
||||
|
||||
$htmlErroresGlobales = self::generaListaErroresGlobales($errores);
|
||||
$errorName = self::createMensajeError($errores,'name','span',array('class'=>'error'));
|
||||
$errorDirection = self::createMensajeError($errores,'direction','span',array('class'=>'error'));
|
||||
$errrorPhone = self ::createMensajeError($errores,'phone',array('class'=>'error'));
|
||||
|
||||
$html = '<div class="column side"></div>
|
||||
<div class="column middle">
|
||||
<legend>Editar cines cine</legend>
|
||||
<form method="post" enctype="multipart/form-data" action="index.php?state=mc">
|
||||
<div class="row">
|
||||
<fieldset id="film_form">
|
||||
<legend>Datos de cine </legend>
|
||||
<input type="hidden" name="id" value='.$_POST['id'].'/>
|
||||
<input type="text" name="name" value="'.$_POST['name'].'" required/><pre>'.$errorName.'</pre>
|
||||
<input type="text" name="direction" value="'.$_POST['direction'].'"required/><pre>'.$errorDirection.'</pre>
|
||||
<input type="text" name="phone" value="'.$_POST['phone'].'"required/><pre>'.$errrorPhone.'</pre>
|
||||
</fieldset>
|
||||
<div class="actions">
|
||||
<input type="submit" id="submit" value="Añadir cine" name="add_cinema" class="primary" />
|
||||
<input type="reset" id="reset" value="Borrar" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> ';
|
||||
return $html;
|
||||
}
|
||||
|
||||
//Process form:
|
||||
public function procesaFormulario($datos) {
|
||||
$result =array();
|
||||
|
||||
|
||||
$id = $this->test_input($_POST['id']) ?? null;
|
||||
if ( empty($id)) {
|
||||
$result[] = "El cine seleccionado no existe.";
|
||||
}
|
||||
|
||||
$name = $this->test_input($datos['name'])??null;
|
||||
|
||||
if(empty($name)){
|
||||
$result['name']= "El nombre no es válido";
|
||||
}
|
||||
|
||||
$direction = $this -> test_input($datos['direction']) ?? null;
|
||||
|
||||
if(empty($direction)){
|
||||
$result['direction'] = "La dirección no es valida";
|
||||
}
|
||||
|
||||
$phone = $this -> test_input($datos['phone']) ?? null;
|
||||
|
||||
if(empty($phone)){
|
||||
$result['phone'] = "El teléfono no es valido";
|
||||
}
|
||||
|
||||
if(count($result)===0){
|
||||
|
||||
$bd = new Cinema_DAO('complucine');
|
||||
$exist = $bd -> GetCinema($name,$direction);
|
||||
if(mysqli_num_rows($exist)==1){
|
||||
|
||||
$bd->editCinema($id,$name,$direction,$phone);
|
||||
$_SESSION['message'] = "<div class='row'>
|
||||
<div class='column side'></div>
|
||||
<div class='column middle'>
|
||||
<div class='code info'>
|
||||
<h1> Operacion realizada con exito </h1><hr />
|
||||
<p> Se ha editado el cine correctamente en la base de datos.</p>
|
||||
<a href='../panel_admin/index.php?state=mc'><button>Cerrar Mensaje</button></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class='column side'></div>
|
||||
</div>
|
||||
";
|
||||
$result = './?state=mc';
|
||||
}
|
||||
else{
|
||||
$result[] = "El cine seleccionado no existe.";
|
||||
}
|
||||
$exist->free();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function test_input($input){
|
||||
return htmlspecialchars(trim(strip_tags($input)));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -11,46 +11,33 @@
|
||||
function showPanel($template) {
|
||||
if($this->login){
|
||||
switch($this->state) {
|
||||
case 'mc': require_once('manage_cinemas.php');
|
||||
if(isset($_POST['edit_cinema'])) {
|
||||
case 'mc': if(isset($_POST['edit_cinema'])) {
|
||||
editCinema();
|
||||
}
|
||||
else if(isset($_POST['delete_cinema'])) {
|
||||
deleteCinema();
|
||||
}
|
||||
else if(isset($_POST['add_cinema'])) {
|
||||
confirmAdd();
|
||||
}
|
||||
else if(isset($_POST['confirm_delete_cinema'])) {
|
||||
confirmDelete();
|
||||
}
|
||||
else if(isset($_POST['confirm_edit_cinema'])) {
|
||||
confirmEdit();
|
||||
}
|
||||
addCinema();
|
||||
$template->print_cinemas();
|
||||
}
|
||||
else {
|
||||
addCinema();
|
||||
$template->print_cinemas();
|
||||
|
||||
};
|
||||
break;
|
||||
case 'mf': require_once('manage_films.php');
|
||||
if(isset($_POST['edit_film'])) {
|
||||
editFilm();
|
||||
}
|
||||
case 'mf': if(isset($_POST['edit_film'])) {
|
||||
$this->editFilm();
|
||||
else if(isset($_POST['delete_film'])) {
|
||||
deleteFilm();
|
||||
$this->deleteFilm();
|
||||
}
|
||||
else if(isset($_POST['add_film'])) {
|
||||
confirmAdd();
|
||||
}
|
||||
else if(isset($_POST['confirm_delete_film'])) {
|
||||
confirmDelete();
|
||||
}
|
||||
else if(isset($_POST['confirm_edit_film'])) {
|
||||
confirmEdit();
|
||||
$this->addFilm();
|
||||
$template->print_fimls();
|
||||
}
|
||||
else {
|
||||
addFilm();
|
||||
$this->addFilm();
|
||||
$template->print_fimls();
|
||||
};
|
||||
break;
|
||||
@ -110,15 +97,75 @@
|
||||
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>";
|
||||
}
|
||||
}
|
||||
|
||||
function getTemplate(){
|
||||
return $this->template;
|
||||
}
|
||||
}
|
||||
?>
|
||||
function getTemplate(){
|
||||
return $this->template;
|
||||
}
|
||||
|
||||
//Functions FILMS
|
||||
function addFilm(){
|
||||
include_once('./includes/formAddFilm.php');
|
||||
$formAF = new formAddFilm();
|
||||
$htmlAForm = $formAF->gestiona();
|
||||
echo '<!-- Add film -->
|
||||
<div class="column side"></div>
|
||||
<div class="column middle">
|
||||
'.$htmlAForm.'
|
||||
</div>'."\n";
|
||||
}
|
||||
|
||||
function deleteFilm() {
|
||||
include_once('./includes/formDeleteFilm.php');
|
||||
$formDF = new formDeleteFilm();
|
||||
$htmlDForm = $formDF->gestiona();
|
||||
echo '<!-- Add film -->
|
||||
<div class="column side"></div>
|
||||
<div class="column middle">
|
||||
'.$htmlDForm.'
|
||||
</div>'."\n";
|
||||
}
|
||||
function editFilm() {
|
||||
include_once('./includes/formEditFilm.php');
|
||||
$formEF = new formEditFilm();
|
||||
$htmlDForm = $formEF->gestiona();
|
||||
echo '<!-- Add film -->
|
||||
<div class="column side"></div>
|
||||
<div class="column middle">
|
||||
'.$htmlDForm.'
|
||||
</div>'."\n";
|
||||
}
|
||||
//Functions Cinemas
|
||||
function addCinema(){
|
||||
include_once('./includes/formAddCinema.php');
|
||||
$formAC = new formAddCinema();
|
||||
$htmlAForm = $formAC->gestiona();
|
||||
echo '<!-- Add cinema -->
|
||||
<div class="column side"></div>
|
||||
<div class="column middle">
|
||||
'.$htmlAForm.'
|
||||
</div>'."\n";
|
||||
}
|
||||
|
||||
function deleteCinema() {
|
||||
include_once('./includes/formDeleteCinema.php');
|
||||
$formDC = new formDeleteCinema();
|
||||
$htmlDForm = $formDC->gestiona();
|
||||
echo '<!-- Delete cinema -->
|
||||
<div class="column side"></div>
|
||||
<div class="column middle">
|
||||
'.$htmlDForm.'
|
||||
</div>'."\n";
|
||||
}
|
||||
|
||||
function editCinema() {
|
||||
include_once('./includes/formEditFilm.php');
|
||||
$formEF = new formEditCinema();
|
||||
$htmlDForm = $formEC->gestiona();
|
||||
echo '<!-- Edit cinema -->
|
||||
<div class="column side"></div>
|
||||
<div class="column middle">
|
||||
'.$htmlDForm.'
|
||||
</div>'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user