2021-05-13 11:48:20 +02:00
|
|
|
<?php
|
|
|
|
//General Config File:
|
|
|
|
include_once('../assets/php/config.php');
|
|
|
|
include_once('../assets/php/common/manager_dao.php');
|
|
|
|
include_once('../assets/php/common/manager.php');
|
|
|
|
include_once('../assets/php/form.php');
|
|
|
|
|
|
|
|
class formDeleteManager extends Form{
|
|
|
|
//Constants:
|
|
|
|
const HTML5_EMAIL_REGEXP = '^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$';
|
|
|
|
|
|
|
|
public function __construct() {
|
|
|
|
$options = array("action" => "./?state=mg");
|
|
|
|
parent::__construct('formDeleteManager', $options);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function generaCamposFormulario($datos, $errores = array()){
|
|
|
|
|
|
|
|
|
|
|
|
// Se generan los mensajes de error si existen.
|
|
|
|
$htmlErroresGlobales = self::generaListaErroresGlobales($errores);
|
2021-05-13 12:37:15 +02:00
|
|
|
$errorId = self::createMensajeError($errores, 'id', 'span', array('class' => 'error'));
|
2021-05-13 11:48:20 +02:00
|
|
|
//$errorIdCinema = self::createMensajeError($errores, 'idcinema', 'span', array('class' => 'error'));
|
|
|
|
|
|
|
|
$html = '<div class="row">
|
2021-05-13 17:37:09 +02:00
|
|
|
<fieldset id="manager_form"><pre>'.$htmlErroresGlobales.'</pre>
|
2021-05-14 16:53:59 +02:00
|
|
|
<legend>¿Estás seguro de que quieres eliminar este gerente?</legend><pre>'.$errorId.'</pre>
|
2021-05-13 11:48:20 +02:00
|
|
|
<input type="hidden" name="id" value='.$_POST['id'].'/>
|
|
|
|
<p>Id: '.$_POST['id'].' </p>
|
|
|
|
<p>IdCinema: '.$_POST['idcinema'].' </p>
|
|
|
|
<p>Nombre: '.$_POST['username'].' </p>
|
|
|
|
<p>Email: '.$_POST['email'].' </p>
|
|
|
|
<p>Rol: '.$_POST['rol'].' </p>
|
|
|
|
</fieldset>
|
|
|
|
<div class="actions">
|
|
|
|
<input type="submit" id="submit" value="Eliminar" name="delete_manager" class="primary" />
|
|
|
|
<input type="submit" id="submit" value="Cancelar" class="primary" />
|
|
|
|
</div>
|
|
|
|
</div>';
|
|
|
|
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function procesaFormulario($datos){
|
|
|
|
$result = array();
|
|
|
|
|
|
|
|
$id = $this->test_input($datos['id']) ?? null;
|
|
|
|
if (is_null($id) ) {
|
2021-05-13 12:37:15 +02:00
|
|
|
$result['id'] = "ERROR. No existe un manager con ese ID";
|
2021-05-13 11:48:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (count($result) === 0) {
|
|
|
|
$bd = new Manager_DAO('complucine');
|
|
|
|
$exist = $bd-> GetManager($id);
|
|
|
|
if( mysqli_num_rows($exist) == 1){
|
|
|
|
$bd->deleteManager($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 gerente correctamente en la base de datos.</p>
|
|
|
|
<a href='../panel_admin/index.php?state=mg'><button>Cerrar Mensaje</button></a>
|
|
|
|
</div>
|
|
|
|
<div class='column side'></div>
|
|
|
|
</div>";
|
|
|
|
$result = './?state=mg';
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
$result[] = "ERROR. No existe un manager con ese ID";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|