This commit is contained in:
Daniel Muñoz Garcia 2021-05-13 17:37:09 +02:00 committed by GitHub
parent 58e8f0a17f
commit 7a52e6a6a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 51 additions and 64 deletions

View File

@ -27,7 +27,7 @@ class formAddCinema extends Form{
<input type="text" name="phone" id="phone" placeholder="Teléfono" required/><pre>'.$errrorPhone.'</pre> <input type="text" name="phone" id="phone" placeholder="Teléfono" required/><pre>'.$errrorPhone.'</pre>
</fieldset> </fieldset>
<div class="actions"> <div class="actions">
<input type="submit" id="submit" value="Añadir cine" name="add_cinema" class="primary" /> <input type="submit" id="submit" value="Añadir cine" class="primary" />
<input type="reset" id="reset" value="Borrar" /> <input type="reset" id="reset" value="Borrar" />
</div> </div>
</div> '; </div> ';

View File

@ -35,7 +35,7 @@ class formAddFilm extends Form{
<div class="file">Imagen promocional:<input type="file" name="file" id="file" placeholder="Imagen promocional" /></div> <div class="file">Imagen promocional:<input type="file" name="file" id="file" placeholder="Imagen promocional" /></div>
</fieldset> </fieldset>
<div class="actions"> <div class="actions">
<input type="submit" id="submit" value="Añadir pelicula" name="add_film" class="primary" /> <input type="submit" id="submit" value="Añadir pelicula" class="primary" />
<input type="reset" id="reset" value="Borrar" /> <input type="reset" id="reset" value="Borrar" />
</div> </div>
</div> </div>

View File

@ -35,7 +35,7 @@ class formAddPromotion extends Form{
<div class="file">Imagen promocional:<input type="file" name="file" id="file" placeholder="Imagen promocional" /></div> <div class="file">Imagen promocional:<input type="file" name="file" id="file" placeholder="Imagen promocional" /></div>
</fieldset> </fieldset>
<div class="actions"> <div class="actions">
<input type="submit" id="submit" value="Añadir promocion" name="add_promotion" class="primary" /> <input type="submit" id="submit" value="Añadir promocion" class="primary" />
<input type="reset" id="reset" value="Borrar" /> <input type="reset" id="reset" value="Borrar" />
</div> </div>
</div> </div>

View File

@ -8,19 +8,19 @@ include_once('../assets/php/form.php');
class formDeleteCinema extends Form{ class formDeleteCinema extends Form{
public function __construct(){ public function __construct(){
$op = array("action"=>"./?state=mc">); $op = array("action"=>"./?state=mc");
parent::__construct('formAddCinema',$op); parent::__construct('formAddCinema',$op);
} }
protected function generaCamposFormulario($datos,$errores=array()){ protected function generaCamposFormulario($datos,$errores=array()){
$htmlErroresGlobales = self::generaListaErroresGlobales($errores); $htmlErroresGlobales = self::generaListaErroresGlobales($errores);
$errorId = self::createMensajeError($errores, 'id', 'span', array('class' => 'error'));
$html = '<div class="column side"></div> $html = '<div class="column side"></div>
<fieldset id = "cinema_form">'.$htmlErroresGlobales.'</pre> <fieldset id = "cinema_form">'.$htmlErroresGlobales.'</pre>
<legend>¿Estás seguro de que quieres eliminar este cine?</legend> <legend>¿Estás seguro de que quieres eliminar este cine?</legend>
<input type="hidden" name="id" value='.$_POST['name'].'/> <input type="hidden" name="id" value='.$_POST['id'].'/>
<p>Name: '.$_POST['name'].' </p> <p>Name: '.$_POST['name'].' </p>
<p>Dirección: '.$_POST['direction'].' </p> <p>Dirección: '.$_POST['direction'].' </p>
<p>Teléfono: '.$_POST['phone'].' </p> <p>Teléfono: '.$_POST['phone'].' </p>
@ -39,15 +39,15 @@ class formDeleteCinema extends Form{
$id = $this->test_input($datos['id'])??null; $id = $this->test_input($datos['id'])??null;
if(empty($id)){ if(is_null($id)){
$result['name']= "El nombre no es válido"; $result['id']= "El nombre no es válido";
} }
if(count($result)===0){ if(count($result)===0){
$bd = new Cinema_DAO('complucine'); $bd = new Cinema_DAO('complucine');
$exist = $bd -> cinemaData($id); $exist = $bd -> cinemaData($id);
if(mysqli_num_rows($exist)==1){ if(mysqli_num_rows($exist)==1){
$bd->deleteFilm($id); $bd->deleteCinema($id);
$_SESSION['message'] = "<div class='row'> $_SESSION['message'] = "<div class='row'>
<div class='column side'></div> <div class='column side'></div>
<div class='column middle'> <div class='column middle'>
@ -62,7 +62,7 @@ class formDeleteCinema extends Form{
"; ";
$result = './?state=mc'; $result = './?state=mc';
} }
$exist->free() $exist->free();
} }
else{ else{
$result[] = "El cine seleccionado no existe."; $result[] = "El cine seleccionado no existe.";

View File

@ -47,8 +47,8 @@ class formDeleteFilm extends Form{
protected function procesaFormulario($datos){ protected function procesaFormulario($datos){
$result = array(); $result = array();
$id = $this->test_input($_POST['id']) ?? null; $id = $this->test_input($datos['id']) ?? null;
if ( empty($id)) { if ( is_null($id)) {
$result['id'] = "La pelicula seleccionada no existe."; $result['id'] = "La pelicula seleccionada no existe.";
} }

View File

@ -23,7 +23,7 @@ class formDeleteManager extends Form{
//$errorIdCinema = self::createMensajeError($errores, 'idcinema', 'span', array('class' => 'error')); //$errorIdCinema = self::createMensajeError($errores, 'idcinema', 'span', array('class' => 'error'));
$html = '<div class="row"> $html = '<div class="row">
<fieldset id="promotion_form"><pre>'.$htmlErroresGlobales.'</pre> <fieldset id="manager_form"><pre>'.$htmlErroresGlobales.'</pre>
<legend>¿Estás seguro de que quieres eliminar este gerente?</legend> <legend>¿Estás seguro de que quieres eliminar este gerente?</legend>
<input type="hidden" name="id" value='.$_POST['id'].'/> <input type="hidden" name="id" value='.$_POST['id'].'/>
<p>Id: '.$_POST['id'].' </p> <p>Id: '.$_POST['id'].' </p>

View File

@ -19,6 +19,7 @@ class formDeletePromotion extends Form{
// Se generan los mensajes de error si existen. // Se generan los mensajes de error si existen.
$htmlErroresGlobales = self::generaListaErroresGlobales($errores); $htmlErroresGlobales = self::generaListaErroresGlobales($errores);
$errorId = self::createMensajeError($errores, 'id', 'span', array('class' => 'error'));
//$errorTittle = self::createMensajeError($errores, 'tittle', 'span', array('class' => 'error')); //$errorTittle = self::createMensajeError($errores, 'tittle', 'span', array('class' => 'error'));
//$errorDescription = self::createMensajeError($errores, 'description', 'span', array('class' => 'error')); //$errorDescription = self::createMensajeError($errores, 'description', 'span', array('class' => 'error'));
//$errorCode = self::createMensajeError($errores, 'code', 'span', array('class' => 'error')); //$errorCode = self::createMensajeError($errores, 'code', 'span', array('class' => 'error'));
@ -26,14 +27,14 @@ class formDeletePromotion extends Form{
//$errorImage = self::createMensajeError($errores, 'image', 'span', array('class' => 'error')); //$errorImage = self::createMensajeError($errores, 'image', 'span', array('class' => 'error'));
$html = '<div class="row"> $html = '<div class="row">
<fieldset id= "promotion_form"> <fieldset id="promotion_form"><pre>'.$htmlErroresGlobales.'</pre>
<legend>¿Estás seguro de que quieres eliminar esta promocion?</legend> <legend>¿Estás seguro de que quieres eliminar esta promocion?</legend>
<input type="hidden" name="id" value='.$_POST['id'].'/> <input type="hidden" name="id" value='.$_POST['id'].'/>
<p>Id: '.$_POST['id'].' </p> <p>Id: '.$_POST['id'].' </p>
<p>Nombre: '.$_POST['tittle']'</p> <p>Nombre: '.$_POST['tittle'].'</p>
<p>Description:'.$_POST['description']'</p> <p>Description:'.$_POST['description'].'</p>
<p>Codigo: '.$_POST['code']'</p> <p>Codigo: '.$_POST['code'].'</p>
<p>Activa: '.$_POST['active']'</p> <p>Activa: '.$_POST['active'].'</p>
<div class="file">Imagen promocional:<input type="file" name="file" id="file" placeholder="Imagen promocional" /></div> <div class="file">Imagen promocional:<input type="file" name="file" id="file" placeholder="Imagen promocional" /></div>
</fieldset> </fieldset>
<div class="actions"> <div class="actions">
@ -51,7 +52,7 @@ class formDeletePromotion extends Form{
$id = $this->test_input($_POST['id']) ?? null; $id = $this->test_input($_POST['id']) ?? null;
if ( is_null($id)) { if ( is_null($id)) {
$result[] = "La promoción seleccionada no existe."; $result['id'] = "La promoción seleccionada no existe.";
} }
if (count($result) === 0) { if (count($result) === 0) {

View File

@ -8,31 +8,28 @@ include_once('../assets/php/form.php');
class formEditCinema extends Form{ class formEditCinema extends Form{
public function __construct(){ public function __construct(){
$op = array("action"=>"./?state=mc">); $op = array("action"=>"./?state=mc");
parent::__construct('formAddCinema',$op); parent::__construct('formAddCinema',$op);
} }
protected function generaCamposFormulario($datos,$errores=array()){ protected function generaCamposFormulario($datos,$errores=array()){
$htmlErroresGlobales = self::generaListaErroresGlobales($errores); $htmlErroresGlobales = self::generaListaErroresGlobales($errores);
$errorId= self::createMensajeError($errores,'id','span',array('class'=>'error'));
$errorName = self::createMensajeError($errores,'name','span',array('class'=>'error')); $errorName = self::createMensajeError($errores,'name','span',array('class'=>'error'));
$errorDirection = self::createMensajeError($errores,'direction','span',array('class'=>'error')); $errorDirection = self::createMensajeError($errores,'direction','span',array('class'=>'error'));
$errrorPhone = self ::createMensajeError($errores,'phone',array('class'=>'error')); $errrorPhone = self ::createMensajeError($errores,'phone',array('class'=>'error'));
$html = '<div class="column side"></div> $html = '<div class="row">
<div class="column middle"> <fieldset id="film_form"><pre>'.$htmlErroresGlobales.'</pre>
<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> <legend>Datos de cine </legend>
<input type="hidden" name="id" value='.$_POST['id'].'/> <input type="hidden" name="id" value='.$_POST['id'].'/>
<input type="text" name="name" value="'.$_POST['name'].'" required/><pre>'.$errorName.'</pre> <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="direction" value="'.$_POST['direction'].'"required/><pre>'.$errorDirection.'</pre>
<input type="text" name="phone" value="'.$_POST['phone'].'"required/><pre>'.$errrorPhone.'</pre> <input type="text" name="phone" value="'.$_POST['phone'].'"required/><pre>'.$errrorPhone.'</pre>
</fieldset> </fieldset>
<div class="actions"> <div class="actions">
<input type="submit" id="submit" value="Añadir cine" name="add_cinema" class="primary" /> <input type="submit" id="submit" value="Editar" name="edit_cinema" class="primary" />
<input type="reset" id="reset" value="Borrar" /> <input type="reset" id="reset" value="Borrar" />
</div> </div>
</div> </div>
@ -46,10 +43,10 @@ class formEditCinema extends Form{
$result =array(); $result =array();
$id = $this->test_input($_POST['id']) ?? null; $id = $this->test_input($datos['id']) ?? null;
if ( empty($id)) { // if (is_null($id)) {
$result[] = "El cine seleccionado no existe."; // $result['id'] = "El cine seleccionado no existe.";
} //}
$name = $this->test_input($datos['name'])??null; $name = $this->test_input($datos['name'])??null;
@ -57,7 +54,7 @@ class formEditCinema extends Form{
$result['name']= "El nombre no es válido"; $result['name']= "El nombre no es válido";
} }
$direction = $this -> test_input($datos['direction']) ?? null; $direction = $this->test_input($datos['direction']) ?? null;
if(empty($direction)){ if(empty($direction)){
$result['direction'] = "La dirección no es valida"; $result['direction'] = "La dirección no es valida";
@ -70,11 +67,9 @@ class formEditCinema extends Form{
} }
if(count($result)===0){ if(count($result)===0){
$bd = new Cinema_DAO('complucine'); $bd = new Cinema_DAO('complucine');
$exist = $bd -> GetCinema($name,$direction); $exist = $bd -> cinemaData($id);
if(mysqli_num_rows($exist)==1){ if(mysqli_num_rows($exist)==1){
$bd->editCinema($id,$name,$direction,$phone); $bd->editCinema($id,$name,$direction,$phone);
$_SESSION['message'] = "<div class='row'> $_SESSION['message'] = "<div class='row'>
<div class='column side'></div> <div class='column side'></div>

View File

@ -54,8 +54,8 @@ class formEditFilm extends Form{
protected function procesaFormulario($datos){ protected function procesaFormulario($datos){
$result = array(); $result = array();
$id = $this->test_input($_POST['id']) ?? null; $id = $this->test_input($datos['id']) ?? null;
if ( empty($id)) { if (is_null($id)) {
$result[] = "La pelicula seleccionada no existe."; $result[] = "La pelicula seleccionada no existe.";
} }

View File

@ -19,6 +19,7 @@ class formEditPromotion extends Form{
// Se generan los mensajes de error si existen. // Se generan los mensajes de error si existen.
$htmlErroresGlobales = self::generaListaErroresGlobales($errores); $htmlErroresGlobales = self::generaListaErroresGlobales($errores);
$errorId = self::createMensajeError($errores, 'id', 'span', array('class' => 'error'));
$errorTittle = self::createMensajeError($errores, 'tittle', 'span', array('class' => 'error')); $errorTittle = self::createMensajeError($errores, 'tittle', 'span', array('class' => 'error'));
$errorDescription = self::createMensajeError($errores, 'description', 'span', array('class' => 'error')); $errorDescription = self::createMensajeError($errores, 'description', 'span', array('class' => 'error'));
$errorCode = self::createMensajeError($errores, 'code', 'span', array('class' => 'error')); $errorCode = self::createMensajeError($errores, 'code', 'span', array('class' => 'error'));
@ -50,8 +51,8 @@ class formEditPromotion extends Form{
$result = array(); $result = array();
$id = $this->test_input($_POST['id']) ?? null; $id = $this->test_input($_POST['id']) ?? null;
if ( is_null($id)) { if (is_null($id)) {
$result[] = "La promoción seleccionada no existe."; $result['id'] = "La promoción seleccionada no existe.";
} }
$tittle = $this->test_input($datos['tittle']) ?? null; $tittle = $this->test_input($datos['tittle']) ?? null;

View File

@ -12,20 +12,16 @@
if($this->login){ if($this->login){
switch($this->state) { switch($this->state) {
case 'mc': if(isset($_POST['edit_cinema'])) { case 'mc': if(isset($_POST['edit_cinema'])) {
$this->editCinema(); $this->editCinema();
} }
else if(isset($_POST['delete_cinema'])) { else if(isset($_POST['delete_cinema'])) {
$this->deleteCinema(); $this->deleteCinema();
} }
else if(isset($_POST['add_cinema'])) { else {
$this->addCinema(); $this-> addCinema();
echo ($template->print_cinemas()); echo ($template->print_cinemas());
}
else { };
$this-> addCinema();
echo ($template->print_cinemas());
};
break; break;
case 'mf': if(isset($_POST['edit_film'])) { case 'mf': if(isset($_POST['edit_film'])) {
$this->editFilm(); $this->editFilm();
@ -33,10 +29,6 @@
else if(isset($_POST['delete_film'])) { else if(isset($_POST['delete_film'])) {
$this->deleteFilm(); $this->deleteFilm();
} }
else if(isset($_POST['add_film'])) {
$this->addFilm();
echo ( $template->print_fimls());
}
else { else {
$this->addFilm(); $this->addFilm();
echo( $template->print_fimls()); echo( $template->print_fimls());
@ -49,9 +41,6 @@
else if(isset($_POST['delete_promotion'])) { else if(isset($_POST['delete_promotion'])) {
$this->deletePromotion(); $this->deletePromotion();
} }
else if(isset($_POST['add_promotion'])) {
$this->addPromotion();
}
else { else {
$this->addPromotion(); $this->addPromotion();
$this->print_promotions(); $this->print_promotions();
@ -145,8 +134,8 @@
} }
function editCinema() { function editCinema() {
include_once('./includes/formEditFilm.php'); include_once('./includes/formEditCinema.php');
$formEF = new formEditCinema(); $formEC = new formEditCinema();
$htmlDForm = $formEC->gestiona(); $htmlDForm = $formEC->gestiona();
echo '<!-- Edit cinema --> echo '<!-- Edit cinema -->
<div class="column side"></div> <div class="column side"></div>
@ -186,7 +175,6 @@
<th>IdCinema</th> <th>IdCinema</th>
<th>Nombre</th> <th>Nombre</th>
<th>Email</th> <th>Email</th>
<th>password</th>
<th>Rol</th> <th>Rol</th>
</tr> </tr>
</thead> </thead>
@ -274,6 +262,8 @@
</div>'."\n"; </div>'."\n";
} }
//Functions PROMOTIONS
function addPromotion(){ function addPromotion(){
include_once('./includes/formAddPromotion.php'); include_once('./includes/formAddPromotion.php');
$formAP = new formAddPromotion(); $formAP = new formAddPromotion();