2021-05-17 15:29:29 +02:00
|
|
|
<?php
|
|
|
|
//General Config File:
|
|
|
|
include_once('../assets/php/config.php');
|
2021-05-20 15:29:49 +02:00
|
|
|
include_once('../assets/php/includes/cinema_dao.php');
|
|
|
|
include_once('../assets/php/includes/cinema.php');
|
2021-05-17 15:29:29 +02:00
|
|
|
include_once('../assets/php/form.php');
|
|
|
|
|
|
|
|
class formDeleteCinema extends Form{
|
|
|
|
|
|
|
|
public function __construct(){
|
2021-06-08 15:10:08 +02:00
|
|
|
$op = array("action"=>"./?state=mc");
|
2021-05-17 15:29:29 +02:00
|
|
|
parent::__construct('formAddCinema',$op);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function generaCamposFormulario($datos,$errores=array()){
|
2021-06-08 15:27:37 +02:00
|
|
|
$html ="";
|
|
|
|
if (!isset($_SESSION['message'])) {
|
2021-05-17 15:29:29 +02:00
|
|
|
$htmlErroresGlobales = self::generaListaErroresGlobales($errores);
|
|
|
|
$errorId = self::createMensajeError($errores, 'id', 'span', array('class' => 'error'));
|
|
|
|
|
2021-06-08 15:27:37 +02:00
|
|
|
$html .= '
|
2021-05-17 15:29:29 +02:00
|
|
|
<fieldset id = "cinema_form"><pre>'.$htmlErroresGlobales.'</pre>
|
|
|
|
<legend>¿Estás seguro de que quieres eliminar este cine?</legend>
|
|
|
|
<input type="hidden" name="id" value='.$_POST['id'].'/><pre>'.$errorId.'</pre>
|
|
|
|
<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" />
|
2021-06-02 13:06:50 +02:00
|
|
|
</div>';
|
2021-06-08 15:27:37 +02:00
|
|
|
}
|
2021-05-17 15:29:29 +02:00
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Process form:
|
|
|
|
public function procesaFormulario($datos) {
|
|
|
|
$result =array();
|
|
|
|
|
|
|
|
$id = $this->test_input($datos['id'])??null;
|
|
|
|
|
|
|
|
if(is_null($id)){
|
|
|
|
$result['id']= "El nombre no es válido";
|
|
|
|
}
|
|
|
|
|
|
|
|
if(count($result)===0){
|
|
|
|
$bd = new Cinema_DAO('complucine');
|
2021-05-26 11:46:06 +02:00
|
|
|
$exist = $bd -> existCinema($id);
|
2021-05-17 15:29:29 +02:00
|
|
|
if(mysqli_num_rows($exist)==1){
|
|
|
|
$bd->deleteCinema($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>
|
|
|
|
";
|
2021-06-08 13:50:33 +02:00
|
|
|
//$result = './?state=mc';
|
2021-05-17 15:29:29 +02:00
|
|
|
}
|
|
|
|
$exist->free();
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
$result[] = "El cine seleccionado no existe.";
|
|
|
|
}
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|