Add files via upload
This commit is contained in:
89
panel_admin/includes/formAddCinema.php
Normal file
89
panel_admin/includes/formAddCinema.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?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="row"></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" 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
167
panel_admin/includes/formAddFilm.php
Normal file
167
panel_admin/includes/formAddFilm.php
Normal file
@ -0,0 +1,167 @@
|
||||
<?php
|
||||
//General Config File:
|
||||
include_once('../assets/php/config.php');
|
||||
include_once('../assets/php/common/film_dao.php');
|
||||
include_once('../assets/php/common/film.php');
|
||||
include_once('../assets/php/form.php');
|
||||
|
||||
class formAddFilm 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])?)*$';
|
||||
const EXTENSIONS = array('gif','jpg','jpe','jpeg','png');
|
||||
|
||||
public function __construct() {
|
||||
$options = array("action" => "./?state=mf", 'enctype' => 'multipart/form-data');
|
||||
parent::__construct('formAddFilm', $options);
|
||||
}
|
||||
|
||||
protected function generaCamposFormulario($datos, $errores = array()){
|
||||
|
||||
|
||||
// Se generan los mensajes de error si existen.
|
||||
$htmlErroresGlobales = self::generaListaErroresGlobales($errores);
|
||||
$errorTittle = self::createMensajeError($errores, 'tittle', 'span', array('class' => 'error'));
|
||||
$errorDuration = self::createMensajeError($errores, 'duration', 'span', array('class' => 'error'));
|
||||
$errorLanguage = self::createMensajeError($errores, 'language', 'span', array('class' => 'error'));
|
||||
$errorDescription = self::createMensajeError($errores, 'description', 'span', array('class' => 'error'));
|
||||
$errorImage = self::createMensajeError($errores, 'img', 'span', array('class' => 'error'));
|
||||
|
||||
$html = '<div class="row">
|
||||
<fieldset id="film_form"><pre>'.$htmlErroresGlobales.'</pre>
|
||||
<legend>AÑADIR PELÍCULA</legend>
|
||||
<input type="text" name="tittle" id="tittle" placeholder="Título" required/><pre>'.$errorTittle.'</pre>
|
||||
<input type="number" name="duration" id="duration" placeholder="Duración" required/><pre>'.$errorDuration.'</pre>
|
||||
<input type="text" name="language" id="language" placeholder="Idioma" required/><pre>'.$errorLanguage.'</pre>
|
||||
<input type="text" name="description" id="description" placeholder="Descripción" required/><pre>'.$errorDescription.'</pre>
|
||||
<div class="file">Imagen promocional:<input type="file" name="file" id="file" placeholder="Imagen promocional" /></div><pre>'.$errorImage.'</pre></p>
|
||||
</fieldset>
|
||||
<div class="actions">
|
||||
<input type="submit" id="submit" value="Añadir pelicula" class="primary" />
|
||||
<input type="reset" id="reset" value="Borrar" />
|
||||
</div>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
protected function procesaFormulario($datos){
|
||||
$result = array();
|
||||
|
||||
|
||||
/* PROCESAR LA SUBIDA DE IMAGEN
|
||||
$ok = count($_FILES) == 1 && $_FILES['archivo']['error'] == UPLOAD_ERR_OK;
|
||||
if ( $ok ) {
|
||||
$archivo = $_FILES['archivo'];
|
||||
$nombre = $_FILES['archivo']['name'];
|
||||
//1.a) Valida el nombre del archivo
|
||||
$ok = $this->check_file_uploaded_name($nombre) && $this->check_file_uploaded_length($nombre) ;
|
||||
|
||||
// 1.b) Sanitiza el nombre del archivo
|
||||
//$ok = $this->sanitize_file_uploaded_name($nombre);
|
||||
//
|
||||
|
||||
// 1.c) Utilizar un id de la base de datos como nombre de archivo
|
||||
|
||||
// 2. comprueba si la extensión está permitida
|
||||
$ok = $ok && in_array(pathinfo($nombre, PATHINFO_EXTENSION), self::EXTENSIONS);
|
||||
|
||||
// 3. comprueba el tipo mime del archivo correspode a una imagen image
|
||||
$finfo = new \finfo(FILEINFO_MIME_TYPE);
|
||||
$mimeType = $finfo->file($_FILES['archivo']['tmp_name']);
|
||||
$ok = preg_match('/image\/*./', $mimeType);
|
||||
|
||||
if ( $ok ) {
|
||||
$tmp_name = $_FILES['archivo']['tmp_name'];
|
||||
|
||||
if ( !move_uploaded_file($tmp_name, "../img/films/{$nombre}") ) {
|
||||
$result['img'] = 'Error al mover el archivo';
|
||||
}
|
||||
|
||||
//if ( !copy("../img/tmp/{$nombre}", "/{$nombre}") ) {
|
||||
// $result['img'] = 'Error al mover el archivo';
|
||||
//}
|
||||
|
||||
}else {
|
||||
$result['img'] = 'El archivo tiene un nombre o tipo no soportado';
|
||||
}
|
||||
} else {
|
||||
$result['img'] = 'Error al subir el archivo.';
|
||||
}
|
||||
*/
|
||||
|
||||
$tittle = $this->test_input($datos['tittle']) ?? null;
|
||||
//|| !mb_ereg_match(self::HTML5_EMAIL_REGEXP, $tittle)
|
||||
if ( empty($tittle) ) {
|
||||
$result['tittle'] = "El título no es válido";
|
||||
}
|
||||
|
||||
$duration = $this->test_input($datos['duration']) ?? null;
|
||||
//||!mb_ereg_match(self::HTML5_EMAIL_REGEXP, $duration)
|
||||
if ( empty($duration) || $duration <0) {
|
||||
$result['duration'] = "La duración no es válida";
|
||||
}
|
||||
|
||||
$language = $this->test_input($datos['language']) ?? null;
|
||||
//|| !mb_ereg_match(self::HTML5_EMAIL_REGEXP, $language)
|
||||
if ( empty($language) ) {
|
||||
$result['language'] = "El idioma no es válido";
|
||||
}
|
||||
|
||||
$description = $this->test_input($datos['description']) ?? null;
|
||||
//|| !mb_ereg_match(self::HTML5_EMAIL_REGEXP, $description)
|
||||
if ( empty($language)) {
|
||||
$result['language'] = "La descripcion no es válida";
|
||||
}
|
||||
|
||||
if (count($result) === 0) {
|
||||
$bd = new Film_DAO("complucine");
|
||||
|
||||
//FALTARIA SUBIR LA IMAGEN
|
||||
$exist = $bd-> GetFilm($tittle,$language);
|
||||
if(mysqli_num_rows($exist) != 0){
|
||||
$result[] = "Ya existe una nueva pelicula con el mismo titulo e idioma.";
|
||||
}
|
||||
else{
|
||||
|
||||
/* PROCESAR SUBIDA DE IMAGEN
|
||||
$tmp_name = $_FILES['img']['tmp_name'];
|
||||
if ( !move_uploaded_file($tmp_name, "../img/films/{$nombre}") ) {
|
||||
$result[] = 'Error al mover el archivo';
|
||||
}
|
||||
//else if ( !copy(DIR_ALMACEN. "/{$nombre}", DIR_ALMACEN_PROTEGIDO. "/{$nombre}") ) {
|
||||
// $result[] = 'Error al mover el archivo';
|
||||
//}
|
||||
*/
|
||||
//else {
|
||||
$bd->createFilm(null, $tittle,$duration,$language,$description, null); //Null hasta tener $nombre
|
||||
$_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 la pelicula correctamente en la base de datos.</p>
|
||||
<a href='../panel_admin/index.php?state=mf'><button>Cerrar Mensaje</button></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class='column side'></div>
|
||||
</div>
|
||||
";
|
||||
$result = './?state=mf';
|
||||
//}
|
||||
|
||||
}
|
||||
$exist->free();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function check_file_uploaded_name ($filename) {
|
||||
return (bool) ((mb_ereg_match('/^[0-9A-Z-_\.]+$/i',$filename) === 1) ? true : false );
|
||||
}
|
||||
private function check_file_uploaded_length ($filename) {
|
||||
return (bool) ((mb_strlen($filename,'UTF-8') < 250) ? true : false);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
142
panel_admin/includes/formAddManager.php
Normal file
142
panel_admin/includes/formAddManager.php
Normal file
@ -0,0 +1,142 @@
|
||||
<?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/common/cinema_dao.php');
|
||||
include_once('../assets/php/common/user_dao.php');
|
||||
include_once('../assets/php/form.php');
|
||||
|
||||
class formAddManager 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('formAddManager', $options);
|
||||
}
|
||||
|
||||
protected function generaCamposFormulario($datos, $errores = array()){
|
||||
|
||||
|
||||
// Se generan los mensajes de error si existen.
|
||||
$htmlErroresGlobales = self::generaListaErroresGlobales($errores);
|
||||
$errorId = self::createMensajeError($errores, 'id', 'span', array('class' => 'error'));
|
||||
$errorIdCinema = self::createMensajeError($errores, 'idcinema', 'span', array('class' => 'error'));
|
||||
|
||||
$html = '<fieldset id="film_form"><pre>'.$htmlErroresGlobales.'</pre>
|
||||
<legend>Selecciona usuario.</legend><pre>'.$errorId.'</pre>'
|
||||
.$this->showUsers().
|
||||
'</fieldset>
|
||||
<fieldset>
|
||||
<legend>Selecciona cine.</legend><pre>'.$errorIdCinema.'</pre>'
|
||||
.$this->showCinemas().
|
||||
'</fieldset>
|
||||
<div class="actions">
|
||||
<input type="submit" id="submit" value="Seleccionar" name="add_manager" class="primary" />
|
||||
<input type="reset" id="reset" value="Borrar" />
|
||||
</div>
|
||||
</div>
|
||||
';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
protected function procesaFormulario($datos){
|
||||
$result = array();
|
||||
|
||||
$id = $this->test_input($datos['id']) ?? null;
|
||||
if (is_null($id) ) {
|
||||
$result['id'] = "ERROR. No existe un usuario con ese ID";
|
||||
}
|
||||
|
||||
$idcinema = $this->test_input($datos['idcinema']) ?? null;
|
||||
//||!mb_ereg_match(self::HTML5_EMAIL_REGEXP, $duration)
|
||||
if (empty($idcinema)) {
|
||||
$result['idcinema'] = "ERROR. No existe un cine con ese ID";
|
||||
}
|
||||
|
||||
|
||||
if (count($result) === 0) {
|
||||
$bd = new Manager_DAO("complucine");
|
||||
|
||||
// check if already exist a manager with same name
|
||||
$exist = $bd->GetManagerCinema($id, $idcinema);
|
||||
if( mysqli_num_rows($exist) != 0){
|
||||
$result[] = "Ya existe un manager asociado a este usuario y cine";
|
||||
}
|
||||
else{
|
||||
$bd->createManager($id, $idcinema);
|
||||
$_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 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';
|
||||
}
|
||||
$exist->free();
|
||||
|
||||
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function showUsers() {
|
||||
$user = new UserDAO("complucine");
|
||||
$users = $user->allUsersNotM();
|
||||
$ids = array();
|
||||
$usernames = array();
|
||||
$emails = array();
|
||||
$roles = array();
|
||||
|
||||
|
||||
foreach($users as $key => $value){
|
||||
$ids[$key] = $value->getId();
|
||||
$usernames[$key] = $value->getName();
|
||||
$emails[$key] = $value->getEmail();
|
||||
$roles[$key] = $value->getRol();
|
||||
}
|
||||
$html='';
|
||||
for($i = 0; $i < count($users); $i++){
|
||||
$html .= '
|
||||
<input type="radio" name="id" value='.$ids[$i].' > <label> '.$ids[$i].', '.$usernames[$i].', '.$usernames[$key].'
|
||||
</label>
|
||||
';
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
private function showCinemas() {
|
||||
$cine = new Cinema_DAO("complucine");
|
||||
$cinemas = $cine->allCinemaData();
|
||||
$ids = array();
|
||||
$names = array();
|
||||
$directions = array();
|
||||
$phones = array();
|
||||
|
||||
foreach($cinemas as $key => $value){
|
||||
$ids[$key] = $value->getId();
|
||||
$names[$key] = $value->getName();
|
||||
$directions[$key] = $value->getDirection();
|
||||
$phones[$key] = $value->getPhone();
|
||||
}
|
||||
$html = '';
|
||||
for($i = 0; $i < count($cinemas); $i++){
|
||||
$html.= '
|
||||
<input type="radio" name="idcinema" value='.$ids[$i].' > <label> '.$ids[$i].', '.$names[$i].'
|
||||
</label>
|
||||
';
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
107
panel_admin/includes/formAddPromotion.php
Normal file
107
panel_admin/includes/formAddPromotion.php
Normal file
@ -0,0 +1,107 @@
|
||||
<?php
|
||||
//General Config File:
|
||||
include_once('../assets/php/config.php');
|
||||
include_once('../assets/php/common/promotion_dao.php');
|
||||
include_once('../assets/php/common/promotion.php');
|
||||
include_once('../assets/php/form.php');
|
||||
|
||||
class formAddPromotion extends Form{
|
||||
//Constants:
|
||||
|
||||
|
||||
public function __construct() {
|
||||
$op = array("action" => "./?state=mp");
|
||||
parent::__construct('formAddPromotion', $op);
|
||||
}
|
||||
|
||||
protected function generaCamposFormulario($datos, $errores = array()){
|
||||
|
||||
|
||||
// Se generan los mensajes de error si existen.
|
||||
$htmlErroresGlobales = self::generaListaErroresGlobales($errores);
|
||||
$errorTittle = self::createMensajeError($errores, 'tittle', 'span', array('class' => 'error'));
|
||||
$errorDescription = self::createMensajeError($errores, 'description', 'span', array('class' => 'error'));
|
||||
$errorCode = self::createMensajeError($errores, 'code', 'span', array('class' => 'error'));
|
||||
$errorActive = self::createMensajeError($errores, 'active', 'span', array('class' => 'error'));
|
||||
//$errorImage = self::createMensajeError($errores, 'image', 'span', array('class' => 'error'));
|
||||
|
||||
$html = '<div class="row">
|
||||
<fieldset id="promotion_form"><pre>'.$htmlErroresGlobales.'</pre>
|
||||
<legend>AÑADIR PROMOCIÓN</legend>
|
||||
<input type="text" name="tittle" id="tittle" placeholder="Título" required/><pre>'.$errorTittle.'</pre>
|
||||
<input type="text" name="description" id="description" placeholder="Descripción" required/><pre>'.$errorDescription.'</pre>
|
||||
<input type="text" name="code" id="code" placeholder="Codigo" required/><pre>'.$errorCode.'</pre>
|
||||
<input type="text" name="active" id="active" placeholder="Activo" required/><pre>'.$errorActive.'</pre>
|
||||
<div class="file">Imagen promocional:<input type="file" name="file" id="file" placeholder="Imagen promocional" /></div>
|
||||
</fieldset>
|
||||
<div class="actions">
|
||||
<input type="submit" id="submit" value="Añadir promocion" class="primary" />
|
||||
<input type="reset" id="reset" value="Borrar" />
|
||||
</div>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
protected function procesaFormulario($datos){
|
||||
$result = array();
|
||||
|
||||
$tittle = $this->test_input($datos['tittle']) ?? null;
|
||||
|
||||
if ( empty($tittle) ) {
|
||||
$result['tittle'] = "El título no es válido";
|
||||
}
|
||||
|
||||
$description = $this->test_input($datos['description']) ?? null;
|
||||
|
||||
if ( empty($description)) {
|
||||
$result['description'] = "La descripcion no es válida";
|
||||
}
|
||||
|
||||
$code = $this->test_input($datos['code']) ?? null;
|
||||
|
||||
if ( empty($code) ) {
|
||||
$result['code'] = "El idioma no es válido";
|
||||
}
|
||||
|
||||
$active = $this->test_input($datos['active']) ?? null;
|
||||
//|| !mb_ereg_match(self::HTML5_EMAIL_REGEXP, $description)
|
||||
if ( $active>1 ||$active<0 ) {
|
||||
$result['active'] = "La descripcion no es válida";
|
||||
}
|
||||
|
||||
if (count($result) === 0) {
|
||||
$bd = new Promotion_DAO("complucine");
|
||||
|
||||
//FALTARIA SUBIR LA IMAGEN
|
||||
$exist = $bd-> GetPromotion($code);
|
||||
if(mysqli_num_rows($exist) != 0){
|
||||
$result[] = "Ya existe una nueva promocion con el mismo codigo.";
|
||||
}
|
||||
else{
|
||||
$bd->createPromotion(null, $tittle,$description,$code,$active);
|
||||
$_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 la promocion correctamente en la base de datos.</p>
|
||||
<a href='../panel_admin/index.php?state=mp'><button>Cerrar Mensaje</button></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class='column side'></div>
|
||||
</div>
|
||||
";
|
||||
$result = './?state=mp';
|
||||
|
||||
}
|
||||
$exist->free();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
75
panel_admin/includes/formDeleteCinema.php
Normal file
75
panel_admin/includes/formDeleteCinema.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?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('formAddCinema',$op);
|
||||
}
|
||||
|
||||
protected function generaCamposFormulario($datos,$errores=array()){
|
||||
|
||||
$htmlErroresGlobales = self::generaListaErroresGlobales($errores);
|
||||
$errorId = self::createMensajeError($errores, 'id', 'span', array('class' => 'error'));
|
||||
|
||||
$html = '<div class="column side"></div>
|
||||
<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" />
|
||||
</div>
|
||||
</div> ';
|
||||
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');
|
||||
$exist = $bd -> cinemaData($id);
|
||||
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>
|
||||
";
|
||||
$result = './?state=mc';
|
||||
}
|
||||
$exist->free();
|
||||
}
|
||||
else{
|
||||
$result[] = "El cine seleccionado no existe.";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
86
panel_admin/includes/formDeleteFilm.php
Normal file
86
panel_admin/includes/formDeleteFilm.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
//General Config File:
|
||||
include_once('../assets/php/config.php');
|
||||
include_once('../assets/php/common/film_dao.php');
|
||||
include_once('../assets/php/common/film.php');
|
||||
include_once('../assets/php/form.php');
|
||||
|
||||
class formDeleteFilm 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=mf");
|
||||
parent::__construct('formDeleteFilm', $options);
|
||||
}
|
||||
|
||||
protected function generaCamposFormulario($datos, $errores = array()){
|
||||
|
||||
|
||||
// Se generan los mensajes de error si existen.
|
||||
$htmlErroresGlobales = self::generaListaErroresGlobales($errores);
|
||||
$errorId = self::createMensajeError($errores, 'id', 'span', array('class' => 'error'));
|
||||
//$errorTittle = self::createMensajeError($errores, 'tittle', 'span', array('class' => 'error'));
|
||||
//$errorDuration = self::createMensajeError($errores, 'duration', 'span', array('class' => 'error'));
|
||||
//$errorLanguage = self::createMensajeError($errores, 'language', 'span', array('class' => 'error'));
|
||||
//$errorDescription = self::createMensajeError($errores, 'description', 'span', array('class' => 'error'));
|
||||
//$errorImage = self::createMensajeError($errores, 'image', 'span', array('class' => 'error'));
|
||||
|
||||
$html = '<div class="row">
|
||||
<fieldset id="film_form"><pre>'.$htmlErroresGlobales.'</pre>
|
||||
<legend>¿Estás seguro de que quieres eliminar esta pelicula?</legend>
|
||||
<input type="hidden" name="id" value='.$_POST['id'].'/><pre>'.$errorId.'</pre>
|
||||
<p>Id: '.$_POST['id'].' </p>
|
||||
<p>Título: '.$_POST['tittle'].' </p>
|
||||
<p>Duración: '.$_POST['duration'].' </p>
|
||||
<p>Idioma: '.$_POST['language'].' </p>
|
||||
<p>Descripción: '.$_POST['description'].' </p>
|
||||
</fieldset>
|
||||
<div class="actions">
|
||||
<input type="submit" id="submit" value="Eliminar" name="delete_film" 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)) {
|
||||
$result['id'] = "La pelicula seleccionada no existe.";
|
||||
}
|
||||
|
||||
if (count($result) === 0) {
|
||||
$bd = new Film_DAO("complucine");
|
||||
$exist = $bd-> FilmData($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 la pelicula correctamente en la base de datos.</p>
|
||||
<a href='../panel_admin/index.php?state=mf'><button>Cerrar Mensaje</button></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class='column side'></div>
|
||||
</div>
|
||||
";
|
||||
$result = './?state=mf';
|
||||
}
|
||||
else{
|
||||
$result[] = "La pelicula seleccionada no existe.";
|
||||
}
|
||||
|
||||
$exist->free();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
81
panel_admin/includes/formDeleteManager.php
Normal file
81
panel_admin/includes/formDeleteManager.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?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);
|
||||
$errorId = self::createMensajeError($errores, 'id', 'span', array('class' => 'error'));
|
||||
//$errorIdCinema = self::createMensajeError($errores, 'idcinema', 'span', array('class' => 'error'));
|
||||
|
||||
$html = '<div class="row">
|
||||
<fieldset id="manager_form"><pre>'.$htmlErroresGlobales.'</pre>
|
||||
<legend>¿Estás seguro de que quieres eliminar este gerente?</legend><pre>'.$errorId.'</pre>
|
||||
<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) ) {
|
||||
$result['id'] = "ERROR. No existe un manager con ese ID";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
89
panel_admin/includes/formDeletePromotion.php
Normal file
89
panel_admin/includes/formDeletePromotion.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
//General Config File:
|
||||
include_once('../assets/php/config.php');
|
||||
include_once('../assets/php/common/promotion_dao.php');
|
||||
include_once('../assets/php/common/promotion.php');
|
||||
include_once('../assets/php/form.php');
|
||||
|
||||
class formDeletePromotion extends Form{
|
||||
//Constants:
|
||||
|
||||
|
||||
public function __construct() {
|
||||
$op = array("action" => "./?state=mp");
|
||||
parent::__construct('formEditPromotion', $op);
|
||||
}
|
||||
|
||||
protected function generaCamposFormulario($datos, $errores = array()){
|
||||
|
||||
|
||||
// Se generan los mensajes de error si existen.
|
||||
$htmlErroresGlobales = self::generaListaErroresGlobales($errores);
|
||||
$errorId = self::createMensajeError($errores, 'id', 'span', array('class' => 'error'));
|
||||
//$errorTittle = self::createMensajeError($errores, 'tittle', 'span', array('class' => 'error'));
|
||||
//$errorDescription = self::createMensajeError($errores, 'description', 'span', array('class' => 'error'));
|
||||
//$errorCode = self::createMensajeError($errores, 'code', 'span', array('class' => 'error'));
|
||||
//$errorActive = self::createMensajeError($errores, 'active', 'span', array('class' => 'error'));
|
||||
//$errorImage = self::createMensajeError($errores, 'image', 'span', array('class' => 'error'));
|
||||
|
||||
$html = '<div class="row">
|
||||
<fieldset id="promotion_form"><pre>'.$htmlErroresGlobales.'</pre>
|
||||
<legend>¿Estás seguro de que quieres eliminar esta promocion?</legend>
|
||||
<input type="hidden" name="id" value='.$_POST['id'].'/><pre>'.$errorId.'</pre>
|
||||
<p>Id: '.$_POST['id'].' </p>
|
||||
<p>Nombre: '.$_POST['tittle'].'</p>
|
||||
<p>Description:'.$_POST['description'].'</p>
|
||||
<p>Codigo: '.$_POST['code'].'</p>
|
||||
<p>Activa: '.$_POST['active'].'</p>
|
||||
<div class="file">Imagen promocional:<input type="file" name="file" id="file" placeholder="Imagen promocional" /></div>
|
||||
</fieldset>
|
||||
<div class="actions">
|
||||
<input type="submit" id="submit" value="Eliminar" name="delete_promotion" class="primary" />
|
||||
<input type="submit" id="submit" value="Cancelar" class="primary" />
|
||||
</div>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
protected function procesaFormulario($datos){
|
||||
$result = array();
|
||||
|
||||
$id = $this->test_input($_POST['id']) ?? null;
|
||||
if ( is_null($id)) {
|
||||
$result['id'] = "La promoción seleccionada no existe.";
|
||||
}
|
||||
|
||||
if (count($result) === 0) {
|
||||
$bd = new Promotion_DAO("complucine");
|
||||
|
||||
//FALTARIA SUBIR LA IMAGEN
|
||||
$exist = $bd-> promotionData($id);
|
||||
if(mysqli_num_rows($exist) == 1){
|
||||
$bd->deletePromotion($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 la promocion correctamente en la base de datos.</p>
|
||||
<a href='../panel_admin/index.php?state=mp'><button>Cerrar Mensaje</button></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class='column side'></div>
|
||||
</div>
|
||||
";
|
||||
$result = './?state=mp';
|
||||
}
|
||||
else{
|
||||
|
||||
$result[] = "La promocion seleccionada no existe.";
|
||||
}
|
||||
$exist->free();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
98
panel_admin/includes/formEditCinema.php
Normal file
98
panel_admin/includes/formEditCinema.php
Normal file
@ -0,0 +1,98 @@
|
||||
<?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('formAddCinema',$op);
|
||||
}
|
||||
|
||||
protected function generaCamposFormulario($datos,$errores=array()){
|
||||
|
||||
$htmlErroresGlobales = self::generaListaErroresGlobales($errores);
|
||||
$errorId= self::createMensajeError($errores,'id','span',array('class'=>'error'));
|
||||
$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="row">
|
||||
<fieldset id="film_form"><pre>'.$htmlErroresGlobales.'</pre>
|
||||
<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="Editar" name="edit_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($datos['id']) ?? null;
|
||||
// if (is_null($id)) {
|
||||
// $result['id'] = "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 -> cinemaData($id);
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
115
panel_admin/includes/formEditFilm.php
Normal file
115
panel_admin/includes/formEditFilm.php
Normal file
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
//General Config File:
|
||||
include_once('../assets/php/config.php');
|
||||
include_once('../assets/php/common/film_dao.php');
|
||||
include_once('../assets/php/common/film.php');
|
||||
include_once('../assets/php/form.php');
|
||||
|
||||
|
||||
class formEditFilm 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=mf");
|
||||
parent::__construct('formEditFilm', $options);
|
||||
}
|
||||
|
||||
protected function generaCamposFormulario($datos, $errores = array()){
|
||||
|
||||
|
||||
// Se generan los mensajes de error si existen.
|
||||
$htmlErroresGlobales = self::generaListaErroresGlobales($errores);
|
||||
$errorId = self::createMensajeError($errores, 'id', 'span', array('class' => 'error'));
|
||||
$errorTittle = self::createMensajeError($errores, 'tittle', 'span', array('class' => 'error'));
|
||||
$errorDuration = self::createMensajeError($errores, 'duration', 'span', array('class' => 'error'));
|
||||
$errorLanguage = self::createMensajeError($errores, 'language', 'span', array('class' => 'error'));
|
||||
$errorDescription = self::createMensajeError($errores, 'description', 'span', array('class' => 'error'));
|
||||
$errorImage = self::createMensajeError($errores, 'image', 'span', array('class' => 'error'));
|
||||
|
||||
$html = '
|
||||
<div class="row">
|
||||
<fieldset id="film_form"><pre>'.$htmlErroresGlobales.'</pre>
|
||||
<legend>Datos de pelicula</legend>
|
||||
<input type="hidden" name="id" value='.$_POST['id'].'/>
|
||||
<input type="text" name="tittle" value='.$_POST['tittle'].' required/><pre>'.$errorTittle.'</pre>
|
||||
<input type="number" name="duration" id="duration" value='.$_POST['duration'].' required/><pre>'.$errorDuration.'</pre>
|
||||
<input type="text" name="language" id="language" value="'.$_POST['language'].'" required/><pre>'.$errorLanguage.'</pre>
|
||||
<input type="text" name="description" id="description" value="'.$_POST['description'].'"required/><pre>'.$errorDescription.'</pre>
|
||||
<div class="file">Imagen promocional:<input type="file" name="file" id="file" placeholder="Imagen promocional" /></div>
|
||||
</fieldset>
|
||||
<div class="actions">
|
||||
<input type="submit" id="submit" value="Editar" name="edit_film" class="primary" />
|
||||
<input type="reset" id="reset" value="Borrar" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="column side"></div>
|
||||
';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
protected function procesaFormulario($datos){
|
||||
$result = array();
|
||||
|
||||
$id = $this->test_input($datos['id']) ?? null;
|
||||
if (is_null($id)) {
|
||||
$result[] = "La pelicula seleccionada no existe.";
|
||||
}
|
||||
|
||||
$tittle = $this->test_input($datos['tittle']) ?? null;
|
||||
//|| !mb_ereg_match(self::HTML5_EMAIL_REGEXP, $tittle)
|
||||
if ( empty($tittle) ) {
|
||||
$result['tittle'] = "El título no es válido";
|
||||
}
|
||||
|
||||
$duration = $this->test_input($datos['duration']) ?? null;
|
||||
//||!mb_ereg_match(self::HTML5_EMAIL_REGEXP, $duration)
|
||||
if ( empty($duration) || $duration <0) {
|
||||
$result['duration'] = "La duración no es válida";
|
||||
}
|
||||
|
||||
$language = $this->test_input($datos['language']) ?? null;
|
||||
//|| !mb_ereg_match(self::HTML5_EMAIL_REGEXP, $language)
|
||||
if ( empty($language) ) {
|
||||
$result['language'] = "El idioma no es válido";
|
||||
}
|
||||
|
||||
$description = $this->test_input($datos['description']) ?? null;
|
||||
//|| !mb_ereg_match(self::HTML5_EMAIL_REGEXP, $description)
|
||||
if ( empty($language)) {
|
||||
$result['language'] = "La descripcion no es válida";
|
||||
}
|
||||
|
||||
|
||||
if (count($result) === 0) {
|
||||
$bd = new Film_DAO("complucine");
|
||||
$exist = $bd-> FilmData($id);
|
||||
if( mysqli_num_rows($exist) == 1){
|
||||
$bd->editFilm($id, $tittle, $duration, $language, $description, $img = null /* Cambiar cuando se ñaladan las imágenes */);
|
||||
$_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 la pelicula correctamente en la base de datos.</p>
|
||||
<a href='../panel_admin/index.php?state=mf'><button>Cerrar Mensaje</button></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class='column side'></div>
|
||||
</div>
|
||||
";
|
||||
$result = './?state=mf';
|
||||
}
|
||||
else{
|
||||
$result[] = "La pelicula seleccionada no existe.";
|
||||
}
|
||||
$exist->free();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
113
panel_admin/includes/formEditManager.php
Normal file
113
panel_admin/includes/formEditManager.php
Normal file
@ -0,0 +1,113 @@
|
||||
<?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/common/cinema_dao.php');
|
||||
include_once('../assets/php/form.php');
|
||||
|
||||
class formEditManager 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('formEditManager', $options);
|
||||
}
|
||||
|
||||
protected function generaCamposFormulario($datos, $errores = array()){
|
||||
|
||||
|
||||
// Se generan los mensajes de error si existen.
|
||||
$htmlErroresGlobales = self::generaListaErroresGlobales($errores);
|
||||
$errorId = self::createMensajeError($errores, 'id', 'span', array('class' => 'error'));
|
||||
$errorIdCinema = self::createMensajeError($errores, 'idcinema', 'span', array('class' => 'error'));
|
||||
|
||||
$html = '<div class="row">
|
||||
<h1>EDITAR GERENTE ID:'.$_POST['id'].'</h1>
|
||||
<fieldset id="film_form"><pre>'.$htmlErroresGlobales.'</pre>
|
||||
<legend>Selecciona cine.</legend><pre>'.$errorIdCinema.'</pre>
|
||||
<input type="hidden" name="id" value='.$_POST['id'].'/><pre>'.$errorId.'</pre>'
|
||||
.$this->showCinemas().
|
||||
'</fieldset>
|
||||
<div class="actions">
|
||||
<input type="submit" id="submit" value="Seleccionar" name="edit_manager" class="primary" />
|
||||
<input type="reset" id="reset" value="Borrar" />
|
||||
</div>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
protected function procesaFormulario($datos){
|
||||
$result = array();
|
||||
|
||||
$id = $this->test_input($datos['id']) ?? null;
|
||||
if (is_null($id) ) {
|
||||
$result['id'] = "ERROR. No existe un usuario con ese ID";
|
||||
}
|
||||
|
||||
$idcinema = $this->test_input($datos['idcinema']) ?? null;
|
||||
//||!mb_ereg_match(self::HTML5_EMAIL_REGEXP, $duration)
|
||||
if (is_null($idcinema)) {
|
||||
$result['idcinema'] = "ERROR. No existe un cine con ese ID";
|
||||
}
|
||||
|
||||
|
||||
if (count($result) === 0) {
|
||||
$bd = new Manager_DAO("complucine");
|
||||
$exist = $bd-> GetManager($id);
|
||||
if( mysqli_num_rows($exist) == 1){
|
||||
$bd->editManager($id,$idcinema);
|
||||
$_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 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 cine con ese ID";
|
||||
}
|
||||
$exist->free();
|
||||
|
||||
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function showCinemas() {
|
||||
$cine = new Cinema_DAO("complucine");
|
||||
$cinemas = $cine->allCinemaData();
|
||||
$ids = array();
|
||||
$names = array();
|
||||
$directions = array();
|
||||
$phones = array();
|
||||
|
||||
foreach($cinemas as $key => $value){
|
||||
$ids[$key] = $value->getId();
|
||||
$names[$key] = $value->getName();
|
||||
$directions[$key] = $value->getDirection();
|
||||
$phones[$key] = $value->getPhone();
|
||||
}
|
||||
$html = '';
|
||||
for($i = 0; $i < count($cinemas); $i++){
|
||||
$html.= '
|
||||
<input type="radio" name="idcinema" value='.$ids[$i].' > <label> '.$ids[$i].', '.$names[$i].'
|
||||
</label>
|
||||
';
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
115
panel_admin/includes/formEditPromotion.php
Normal file
115
panel_admin/includes/formEditPromotion.php
Normal file
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
//General Config File:
|
||||
include_once('../assets/php/config.php');
|
||||
include_once('../assets/php/common/promotion_dao.php');
|
||||
include_once('../assets/php/common/promotion.php');
|
||||
include_once('../assets/php/form.php');
|
||||
|
||||
class formEditPromotion extends Form{
|
||||
//Constants:
|
||||
|
||||
|
||||
public function __construct() {
|
||||
$op = array("action" => "./?state=mp");
|
||||
parent::__construct('formEditPromotion', $op);
|
||||
}
|
||||
|
||||
protected function generaCamposFormulario($datos, $errores = array()){
|
||||
|
||||
|
||||
// Se generan los mensajes de error si existen.
|
||||
$htmlErroresGlobales = self::generaListaErroresGlobales($errores);
|
||||
$errorId = self::createMensajeError($errores, 'id', 'span', array('class' => 'error'));
|
||||
$errorTittle = self::createMensajeError($errores, 'tittle', 'span', array('class' => 'error'));
|
||||
$errorDescription = self::createMensajeError($errores, 'description', 'span', array('class' => 'error'));
|
||||
$errorCode = self::createMensajeError($errores, 'code', 'span', array('class' => 'error'));
|
||||
$errorActive = self::createMensajeError($errores, 'active', 'span', array('class' => 'error'));
|
||||
//$errorImage = self::createMensajeError($errores, 'image', 'span', array('class' => 'error'));
|
||||
|
||||
$html = '<div class="row">
|
||||
<fieldset id="promotion_form"><pre>'.$htmlErroresGlobales.'</pre>
|
||||
<fieldset id="film_form">
|
||||
<legend>Datos de promocion</legend>
|
||||
<input type="hidden" name="id" value='.$_POST['id'].'/>
|
||||
<input type="text" name="tittle" id="tittle"value="'.$_POST['tittle'].'"required/><pre>'.$errorTittle.'</pre>
|
||||
<input type="text" name="description" id="description" value="'.$_POST['description'].'" required/><pre>'.$errorDescription.'</pre>
|
||||
<input type="text" name="code" id="code" value="'.$_POST['code'].'" required/><pre>'.$errorCode.'</pre>
|
||||
<input type="text" name="active" id="active" value="'.$_POST['active'].'"required/><pre>'.$errorActive.'</pre>
|
||||
<div class="file">Imagen promocional:<input type="file" name="file" id="file" placeholder="Imagen promocional" /></div>
|
||||
</fieldset>
|
||||
<div class="actions">
|
||||
<input type="submit" id="submit" value="Editar promocion" name="edit_promotion" class="primary" />
|
||||
<input type="reset" id="reset" value="Borrar" />
|
||||
</div>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
protected function procesaFormulario($datos){
|
||||
$result = array();
|
||||
|
||||
$id = $this->test_input($_POST['id']) ?? null;
|
||||
if (is_null($id)) {
|
||||
$result['id'] = "La promoción seleccionada no existe.";
|
||||
}
|
||||
|
||||
$tittle = $this->test_input($datos['tittle']) ?? null;
|
||||
|
||||
if ( empty($tittle) ) {
|
||||
$result['tittle'] = "El título no es válido";
|
||||
}
|
||||
|
||||
$description = $this->test_input($datos['description']) ?? null;
|
||||
|
||||
if ( empty($description)) {
|
||||
$result['description'] = "La descripcion no es válida";
|
||||
}
|
||||
|
||||
$code = $this->test_input($datos['code']) ?? null;
|
||||
|
||||
if ( empty($code) ) {
|
||||
$result['code'] = "El idioma no es válido";
|
||||
}
|
||||
|
||||
$active = $this->test_input($datos['active']) ?? null;
|
||||
//|| !mb_ereg_match(self::HTML5_EMAIL_REGEXP, $description)
|
||||
if ( $active>1 ||$active<0 ) {
|
||||
$result['active'] = "La descripcion no es válida";
|
||||
}
|
||||
|
||||
if (count($result) === 0) {
|
||||
$bd = new Promotion_DAO("complucine");
|
||||
|
||||
//FALTARIA SUBIR LA IMAGEN
|
||||
$exist = $bd-> promotionData($id);
|
||||
if(mysqli_num_rows($exist) == 1){
|
||||
$bd->editPromotion($id, $tittle,$description,$code,$active);
|
||||
$_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 modificado la promocion correctamente en la base de datos.</p>
|
||||
<a href='../panel_admin/index.php?state=mp'><button>Cerrar Mensaje</button></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class='column side'></div>
|
||||
</div>
|
||||
";
|
||||
$result = './?state=mp';
|
||||
}
|
||||
else{
|
||||
|
||||
$result[] = "La promocion seleccionada no existe.";
|
||||
}
|
||||
$exist->free();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
58
panel_admin/index.php
Normal file
58
panel_admin/index.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
//General Config File:
|
||||
include_once('../assets/php/config.php');
|
||||
|
||||
require_once($prefix.'panel_admin/panelAdmin.php');
|
||||
|
||||
$login=false;
|
||||
if(isset($_SESSION["login"]) && $_SESSION["rol"] == "admin") $login = true;
|
||||
if(isset($_GET['state'])) {
|
||||
$panel = new Panel($_GET['state'], $login);
|
||||
}
|
||||
else {
|
||||
$panel = new Panel('', $login);
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE HTML>
|
||||
<!--
|
||||
Práctica - Sistemas Web | Grupo D
|
||||
CompluCine - FDI-cines
|
||||
-->
|
||||
<html lang="es">
|
||||
<!-- Head -->
|
||||
<?php
|
||||
$template->print_head();
|
||||
?>
|
||||
<body>
|
||||
<!-- Header -->
|
||||
<?php
|
||||
$template->print_header();
|
||||
?>
|
||||
|
||||
<!-- Main -->
|
||||
<?php
|
||||
$template->print_main();
|
||||
?>
|
||||
|
||||
<!-- Panel -->
|
||||
<div class="row">
|
||||
<!-- Panel Menu -->
|
||||
<?php
|
||||
$template->print_panelMenu($_SESSION["rol"]);
|
||||
?>
|
||||
<!-- Contents -->
|
||||
<div class="row">
|
||||
<?php
|
||||
$template->print_msg();
|
||||
$panel->showPanel($template);
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Footer -->
|
||||
<?php
|
||||
$template->print_footer();
|
||||
?>
|
||||
</body>
|
||||
|
||||
</html>
|
398
panel_admin/panelAdmin.php
Normal file
398
panel_admin/panelAdmin.php
Normal file
@ -0,0 +1,398 @@
|
||||
<?php
|
||||
class Panel {
|
||||
private $state;
|
||||
private $login;
|
||||
private $prefix;
|
||||
|
||||
function __construct($panel, $login){
|
||||
$this->state = $panel;
|
||||
$this->login= $login;
|
||||
}
|
||||
|
||||
function showPanel($template) {
|
||||
$this->prefix = $template->get_prefix();
|
||||
if($this->login){
|
||||
switch($this->state) {
|
||||
case 'mc': if(isset($_POST['edit_cinema'])) {
|
||||
$this->editCinema();
|
||||
}
|
||||
else if(isset($_POST['delete_cinema'])) {
|
||||
$this->deleteCinema();
|
||||
}
|
||||
else {
|
||||
$this-> addCinema();
|
||||
echo ($template->print_cinemas());
|
||||
|
||||
};
|
||||
break;
|
||||
case 'mf': if(isset($_POST['edit_film'])) {
|
||||
$this->editFilm();
|
||||
}
|
||||
else if(isset($_POST['delete_film'])) {
|
||||
$this->deleteFilm();
|
||||
}
|
||||
else {
|
||||
$this->addFilm();
|
||||
echo( $template->print_fimls());
|
||||
};
|
||||
break;
|
||||
case 'mp':
|
||||
if(isset($_POST['edit_promotion'])) {
|
||||
$this->editPromotion();
|
||||
}
|
||||
else if(isset($_POST['delete_promotion'])) {
|
||||
$this->deletePromotion();
|
||||
}
|
||||
else {
|
||||
$this->addPromotion();
|
||||
$this->print_promotions();
|
||||
|
||||
};
|
||||
break;
|
||||
case 'mg': if(isset($_POST['edit_manager'])) {
|
||||
$this->editManager();
|
||||
}
|
||||
else if(isset($_POST['delete_manager'])) {
|
||||
$this->deleteManager();
|
||||
}
|
||||
else if(isset($_POST['add_manager'])) {
|
||||
$this->addManager();
|
||||
}
|
||||
|
||||
else {
|
||||
$this->showAddBotton();
|
||||
$this->print_managers();
|
||||
};
|
||||
break;
|
||||
case 'un': echo"<div class='code info'><h1>En construcción</h1><hr /></div>"; break;
|
||||
case 'ur': echo"<div class='code info'><h1>En construcción</h1><hr /></div>"; break;
|
||||
case 'ag': echo"<div class='code info'><h1>En construcción</h1><hr /></div>"; break;
|
||||
default: echo '<div class="code info">
|
||||
<h1>Bienvenido al Panel de Administrador.</h1>
|
||||
<hr />
|
||||
</div>'."\n"; break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo '<div class="column side"></div>
|
||||
<div class="column middle">
|
||||
<div class="code info">
|
||||
<h1>No tienes permiso de administrador.</h1><hr />
|
||||
<p>Inicia Sesión con una cuenta de administtación.</p>
|
||||
<a href="'.$this->prefix.'login/"><button>Iniciar Sesión</button></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column side"></div>'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
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/formEditCinema.php');
|
||||
$formEC = new formEditCinema();
|
||||
$htmlDForm = $formEC->gestiona();
|
||||
echo '<!-- Edit cinema -->
|
||||
<div class="column side"></div>
|
||||
<div class="column middle">
|
||||
'.$htmlDForm.'
|
||||
</div>'."\n";
|
||||
}
|
||||
|
||||
|
||||
//Functions MANAGERS
|
||||
function print_managers(){
|
||||
include_once('../assets/php/common/manager_dao.php');
|
||||
include_once('../assets/php/common/manager.php');
|
||||
$manager = new Manager_DAO("complucine");
|
||||
$managers = $manager->allManagersData();
|
||||
$ids = array();
|
||||
$idscinemas = array();
|
||||
$usernames = array();
|
||||
$email = array();
|
||||
$rol = array();
|
||||
if(is_array($managers)){
|
||||
foreach($managers as $key => $value){
|
||||
$ids[$key] = $value->getId();
|
||||
$idscinemas[$key] = $value->getIdcinema();
|
||||
$usernames[$key] = $value->getUsername();
|
||||
$email[$key] = $value->getEmail();
|
||||
$rol[$key] = $value->getRoll();
|
||||
}
|
||||
}
|
||||
echo "<div class='row'>
|
||||
<div class='column side'></div>
|
||||
<div class='column middle'>
|
||||
<table class='alt'>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<th>IdCinema</th>
|
||||
<th>Nombre</th>
|
||||
<th>Email</th>
|
||||
<th>Rol</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
";
|
||||
if(is_array($managers)){
|
||||
for($i = 0; $i < count($managers); $i++){
|
||||
echo '<tr>
|
||||
<td>'. $ids[$i] .'</td>
|
||||
<td>'. $idscinemas[$i] .'</td>
|
||||
<td>'. $usernames[$i] .'</td>
|
||||
<td>'. $email[$i] .'</td>
|
||||
<td>'. $rol[$i] .'</td>
|
||||
<td>
|
||||
<form method="post" action="index.php?state=mg">
|
||||
<input name="id" type="hidden" value="'.$ids[$i].'">
|
||||
<input name="idcinema" type="hidden" value="'.$idscinemas[$i].'">
|
||||
<input type="submit" id="submit" value="Editar" name="edit_manager" class="primary" />
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
<form method="post" action="index.php?state=mg">
|
||||
<input name="id" type="hidden" value="'.$ids[$i].'">
|
||||
<input name="idcinema" type="hidden" value="'.$idscinemas[$i].'">
|
||||
<input name="username" type="hidden" value="'.$usernames[$i].'">
|
||||
<input name="email" type="hidden" value="'.$email[$i].'">
|
||||
<input name="rol" type="hidden" value="'.$rol[$i].'">
|
||||
<input type="submit" id="submit" value="Eliminar" name="delete_manager" class="primary" />
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
';
|
||||
}
|
||||
}
|
||||
echo'</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="column side"></div>
|
||||
</div>
|
||||
';
|
||||
}
|
||||
function showAddBotton() {
|
||||
echo' <div class="column side"></div>
|
||||
<div class="column middle">
|
||||
<h2>Añadir gerente</h2>
|
||||
<form method="post" action="index.php?state=mg">
|
||||
<div class="actions">
|
||||
<input type="submit" id="submit" value="Añadir gerente" name="add_manager" class="primary" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="column side"></div>
|
||||
</div>
|
||||
';
|
||||
}
|
||||
function addManager(){
|
||||
include_once('./includes/formAddManager.php');
|
||||
$formAM = new formAddManager();
|
||||
$htmlAForm = $formAM->gestiona();
|
||||
echo '<!-- ADD MANAGER -->
|
||||
<div class="column side"></div>
|
||||
<div class="column middle">
|
||||
<h3>AÑADIR GERENTE</h3>
|
||||
'.$htmlAForm.'
|
||||
</div>
|
||||
<div class="column side"></div>'."\n";
|
||||
}
|
||||
function editManager(){
|
||||
include_once('./includes/formEditManager.php');
|
||||
$formEM = new formEditManager();
|
||||
$htmlEForm = $formEM->gestiona();
|
||||
echo '<!-- EDIT MANAGER -->
|
||||
<div class="column side"></div>
|
||||
<div class="column middle">
|
||||
<h3>EDITAR GERENTE</h3>
|
||||
'.$htmlEForm.'
|
||||
</div>
|
||||
<div class="column side"></div>'."\n";
|
||||
}
|
||||
|
||||
function deleteManager(){
|
||||
include_once('./includes/formDeleteManager.php');
|
||||
$formDM = new formDeleteManager();
|
||||
$htmlDForm = $formDM->gestiona();
|
||||
echo '<!-- DELETE MANAGER -->
|
||||
<div class="column side"></div>
|
||||
<div class="column middle">
|
||||
<h3>ELIMINAR GERENTE</h3>
|
||||
'.$htmlDForm.'
|
||||
</div>
|
||||
<div class="column side"></div>'."\n";
|
||||
}
|
||||
|
||||
|
||||
//Functions PROMOTIONS
|
||||
function addPromotion(){
|
||||
include_once('./includes/formAddPromotion.php');
|
||||
$formAP = new formAddPromotion();
|
||||
$htmlAForm = $formAP->gestiona();
|
||||
echo '<!-- ADD PROMOTION -->
|
||||
<div class="column side"></div>
|
||||
<div class="column middle">
|
||||
<h3>AÑADIR PROMOCIÓN</h3>
|
||||
'.$htmlAForm.'
|
||||
</div>
|
||||
<div class="column side"></div>'."\n";
|
||||
}
|
||||
function editPromotion(){
|
||||
include_once('./includes/formEditPromotion.php');
|
||||
$formEP = new formEditPromotion();
|
||||
$htmlEForm = $formEP->gestiona();
|
||||
echo '<!-- EDIT MANAGER -->
|
||||
<div class="column side"></div>
|
||||
<div class="column middle">
|
||||
<h3>EDITAR PROMOCIÓN</h3>
|
||||
'.$htmlEForm.'
|
||||
</div>
|
||||
<div class="column side"></div>'."\n";
|
||||
}
|
||||
|
||||
function deletePromotion(){
|
||||
include_once('./includes/formDeletePromotion.php');
|
||||
$formDP = new formDeletePromotion();
|
||||
$htmlDForm = $formDP->gestiona();
|
||||
echo '<!-- DELETE MANAGER -->
|
||||
<div class="column side"></div>
|
||||
<div class="column middle">
|
||||
<h3>ELIMINAR PROMOCIÓN</h3>
|
||||
'.$htmlDForm.'
|
||||
</div>'."\n";
|
||||
}
|
||||
|
||||
function print_promotions(){
|
||||
$promo = new Promotion_DAO("complucine");
|
||||
$promos = $promo->allPromotionData();
|
||||
$ids = array();
|
||||
$tittles = array();
|
||||
$descriptions = array();
|
||||
$codes = array();
|
||||
$actives = array();
|
||||
|
||||
if(is_array($promos)){
|
||||
foreach($promos as $key => $value){
|
||||
$ids[$key] = $value->getId();
|
||||
$tittles[$key] = $value->getTittle();
|
||||
$descriptions[$key] = $value->getDescription();
|
||||
$codes[$key] = $value->getCode();
|
||||
$actives[$key] = $value->getActive();
|
||||
}
|
||||
}
|
||||
|
||||
echo "
|
||||
<div class='column middle'>
|
||||
<table class='alt'>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<th>Título</th>
|
||||
<th>Descripcion</th>
|
||||
<th>Código</th>
|
||||
<th>Activo</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
";
|
||||
if(is_array($promos)){
|
||||
for($i = 0; $i < count($promos); $i++){
|
||||
echo '<tr>
|
||||
<td>'. $ids[$i] .'</td>
|
||||
<td>'. $tittles[$i] .'</td>
|
||||
<td>'. $descriptions[$i] .'</td>
|
||||
<td>'. $codes[$i] .'</td>
|
||||
<td>'. $actives[$i] .'</td>
|
||||
<td>
|
||||
<form method="post" action="index.php?state=mp">
|
||||
<input name="id" type="hidden" value="'.$ids[$i].'">
|
||||
<input name="tittle" type="hidden" value="'.$tittles[$i].'">
|
||||
<input name="description" type="hidden" value="'.$descriptions[$i].'">
|
||||
<input name="code" type="hidden" value="'.$codes[$i].'">
|
||||
<input name="active" type="hidden" value="'.$actives[$i].'">
|
||||
<input type="submit" id="submit" value="Editar" name="edit_promotion" class="primary" />
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
<form method="post" action="index.php?state=mp">
|
||||
<input name="id" type="hidden" value="'.$ids[$i].'">
|
||||
<input name="tittle" type="hidden" value="'.$tittles[$i].'">
|
||||
<input name="description" type="hidden" value="'.$descriptions[$i].'">
|
||||
<input name="code" type="hidden" value="'.$codes[$i].'">
|
||||
<input name="active" type="hidden" value="'.$actives[$i].'">
|
||||
<input type="submit" id="submit" value="Eliminar" name="delete_promotion" class="primary" />
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
';
|
||||
}
|
||||
}
|
||||
echo'</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="column side"></div>
|
||||
';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
Reference in New Issue
Block a user