Add files via upload
This commit is contained in:
		
							
								
								
									
										90
									
								
								root/panel_admin/includes/formAddCinema.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										90
									
								
								root/panel_admin/includes/formAddCinema.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,90 @@
 | 
			
		||||
<?php
 | 
			
		||||
//General Config File:
 | 
			
		||||
include_once('../assets/php/config.php');
 | 
			
		||||
include_once('../assets/php/includes/cinema_dao.php');
 | 
			
		||||
include_once('../assets/php/includes/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,'namecinema','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="namecinema" id="namecinema" 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['namecinema'])??null;
 | 
			
		||||
 | 
			
		||||
        if(empty($name)){
 | 
			
		||||
            $result['namecinema']= "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;	
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
							
								
								
									
										151
									
								
								root/panel_admin/includes/formAddFilm.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										151
									
								
								root/panel_admin/includes/formAddFilm.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,151 @@
 | 
			
		||||
<?php
 | 
			
		||||
//General Config File:
 | 
			
		||||
include_once('../assets/php/config.php');
 | 
			
		||||
include_once('../assets/php/includes/film_dao.php');
 | 
			
		||||
include_once('../assets/php/includes/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="archivo" id="file" placeholder="Imagen promocional" /></div><pre>'.$errorImage.'</pre>
 | 
			
		||||
					</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();
 | 
			
		||||
		
 | 
			
		||||
        $t = $this->test_input($datos['tittle']) ?? null;
 | 
			
		||||
		$tittle = strtolower(str_replace(" ", "_", $t));
 | 
			
		||||
		//|| !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-> GetFilm($tittle,$language);
 | 
			
		||||
			if(mysqli_num_rows($exist) != 0){
 | 
			
		||||
				$result[] = "Ya existe una nueva pelicula con el mismo titulo e idioma.";
 | 
			
		||||
			}
 | 
			
		||||
			else{
 | 
			
		||||
				$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);
 | 
			
		||||
				//finfo_close($finfo);
 | 
			
		||||
				
 | 
			
		||||
				if ( $ok ) {
 | 
			
		||||
					$tmp_name = $_FILES['archivo']['tmp_name'];
 | 
			
		||||
					$nombreBd = strtolower(str_replace(" ", "_", $tittle)).".".pathinfo($nombre, PATHINFO_EXTENSION);
 | 
			
		||||
					if ( !move_uploaded_file($tmp_name, "../img/films/{$nombreBd}") ) {
 | 
			
		||||
					$result['img'] = 'Error al mover el archivo';
 | 
			
		||||
					}
 | 
			
		||||
			
 | 
			
		||||
					//if ( !copy("../img/tmp/{$nombre}", "/{$nombre}") ) {
 | 
			
		||||
					//  $result['img'] = 'Error al mover el archivo';
 | 
			
		||||
					//}
 | 
			
		||||
					//$nombreBd = str_replace("_", " ", $nombre);
 | 
			
		||||
					$bd->createFilm(null, $tittle,$duration,$language,$description, $nombreBd); //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';
 | 
			
		||||
			
 | 
			
		||||
				}else {
 | 
			
		||||
					$result['img'] = 'El archivo tiene un nombre o tipo no soportado';
 | 
			
		||||
				}
 | 
			
		||||
				} else {
 | 
			
		||||
				$result['img'] = 'Error al subir el archivo.';
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
			}
 | 
			
		||||
			$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);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
?>
 | 
			
		||||
							
								
								
									
										146
									
								
								root/panel_admin/includes/formAddManager.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										146
									
								
								root/panel_admin/includes/formAddManager.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,146 @@
 | 
			
		||||
<?php
 | 
			
		||||
//General Config File:
 | 
			
		||||
include_once('../assets/php/config.php');
 | 
			
		||||
include_once('../assets/php/includes/manager_dao.php');
 | 
			
		||||
include_once('../assets/php/includes/manager.php');
 | 
			
		||||
include_once('../assets/php/includes/cinema_dao.php');
 | 
			
		||||
include_once('../assets/php/includes/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()){
 | 
			
		||||
       $html = "";
 | 
			
		||||
 | 
			
		||||
       if (!isset($_SESSION['message'])) {
 | 
			
		||||
        // 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 .= '<h3>AÑADIR GERENTE</h3>
 | 
			
		||||
        <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" class="content-input" name="id" value="'.$ids[$i].'" id="'.$ids[$i].'"><label class="efe" for="'.$ids[$i].'"> '.$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" class="content-input" name="idcinema" value="'.$ids[$i].'" id="'.$ids[$i].'"><label class="efe" for="'.$ids[$i].'">  '.$ids[$i].', '.$names[$i].'
 | 
			
		||||
            </label>
 | 
			
		||||
            ';
 | 
			
		||||
        }
 | 
			
		||||
        return $html;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
							
								
								
									
										162
									
								
								root/panel_admin/includes/formAddPromotion.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										162
									
								
								root/panel_admin/includes/formAddPromotion.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,162 @@
 | 
			
		||||
<?php
 | 
			
		||||
//General Config File:
 | 
			
		||||
include_once('../assets/php/config.php');
 | 
			
		||||
include_once('../assets/php/includes/promotion_dao.php');
 | 
			
		||||
include_once('../assets/php/includes/promotion.php');
 | 
			
		||||
include_once('../assets/php/form.php');
 | 
			
		||||
 | 
			
		||||
class formAddPromotion 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=mp", 'enctype' => 'multipart/form-data');
 | 
			
		||||
        parent::__construct('formAddPromotion', $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'));
 | 
			
		||||
        $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">
 | 
			
		||||
		<h3>AÑADIR PROMOCIÓN</h3>
 | 
			
		||||
					<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 (si/no)" required/><pre>'.$errorActive.'</pre>
 | 
			
		||||
							<div class="file">Imagen promocional:<input type="file" name="archivo" 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();
 | 
			
		||||
        
 | 
			
		||||
		$t = $this->test_input($datos['tittle']) ?? null;
 | 
			
		||||
		$tittle = strtolower(str_replace(" ", "_", $t));
 | 
			
		||||
 | 
			
		||||
        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 = strtolower($this->test_input($datos['active'])) ?? null;
 | 
			
		||||
		//|| !mb_ereg_match(self::HTML5_EMAIL_REGEXP, $description) 
 | 
			
		||||
        if ( strcmp($active,"si") == 0 ||  strcmp($active,"no") == 0) {
 | 
			
		||||
			if ( strcmp($active,"si") == 0 ) {
 | 
			
		||||
				$boolean = 1;
 | 
			
		||||
			}
 | 
			
		||||
			else {
 | 
			
		||||
				$boolean = 0;
 | 
			
		||||
			}
 | 
			
		||||
        }
 | 
			
		||||
		else {
 | 
			
		||||
			$result['active'] = "El valor activo debe ser si/no";
 | 
			
		||||
		}
 | 
			
		||||
        
 | 
			
		||||
        if (count($result) === 0) {
 | 
			
		||||
        	$bd = new Promotion_DAO("complucine");
 | 
			
		||||
			$exist = $bd-> GetPromotion($code);
 | 
			
		||||
			if(mysqli_num_rows($exist) != 0){
 | 
			
		||||
				$result[] = "Ya existe una nueva promocion con el mismo codigo.";
 | 
			
		||||
			}
 | 
			
		||||
			else{
 | 
			
		||||
				$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);
 | 
			
		||||
				//finfo_close($finfo);
 | 
			
		||||
				
 | 
			
		||||
				if ( $ok ) {
 | 
			
		||||
					$tmp_name = $_FILES['archivo']['tmp_name'];
 | 
			
		||||
					$nombreBd = strtolower(str_replace(" ", "_", $tittle)).".".pathinfo($nombre, PATHINFO_EXTENSION);
 | 
			
		||||
					if ( !move_uploaded_file($tmp_name, "../img/promos/{$nombreBd}") ) {
 | 
			
		||||
					$result['img'] = 'Error al mover el archivo';
 | 
			
		||||
					}
 | 
			
		||||
			
 | 
			
		||||
					//if ( !copy("../img/tmp/{$nombre}", "/{$nombre}") ) {
 | 
			
		||||
					//  $result['img'] = 'Error al mover el archivo';
 | 
			
		||||
					//}
 | 
			
		||||
					//$nombreBd = str_replace("_", " ", $nombre);
 | 
			
		||||
					$bd->createPromotion(null, $tittle,$description,$code,$boolean, $nombreBd);
 | 
			
		||||
					$_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';
 | 
			
		||||
			
 | 
			
		||||
				}else {
 | 
			
		||||
					$result['img'] = 'El archivo tiene un nombre o tipo no soportado';
 | 
			
		||||
				}
 | 
			
		||||
				} 
 | 
			
		||||
				else {
 | 
			
		||||
				$result['img'] = 'Error al subir el archivo.';
 | 
			
		||||
				}
 | 
			
		||||
				
 | 
			
		||||
			}
 | 
			
		||||
			$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);
 | 
			
		||||
	}
 | 
			
		||||
		
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
							
								
								
									
										76
									
								
								root/panel_admin/includes/formDeleteCinema.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										76
									
								
								root/panel_admin/includes/formDeleteCinema.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,76 @@
 | 
			
		||||
<?php
 | 
			
		||||
//General Config File:
 | 
			
		||||
include_once('../assets/php/config.php');
 | 
			
		||||
include_once('../assets/php/includes/cinema_dao.php');
 | 
			
		||||
include_once('../assets/php/includes/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()){
 | 
			
		||||
        $html ="";
 | 
			
		||||
        if (!isset($_SESSION['message'])) {
 | 
			
		||||
        $htmlErroresGlobales = self::generaListaErroresGlobales($errores);
 | 
			
		||||
        $errorId = self::createMensajeError($errores, 'id', 'span', array('class' => 'error'));
 | 
			
		||||
 | 
			
		||||
        $html .= '
 | 
			
		||||
                    <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>';
 | 
			
		||||
        }
 | 
			
		||||
         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 -> existCinema($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;	
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
							
								
								
									
										88
									
								
								root/panel_admin/includes/formDeleteFilm.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										88
									
								
								root/panel_admin/includes/formDeleteFilm.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,88 @@
 | 
			
		||||
<?php
 | 
			
		||||
//General Config File:
 | 
			
		||||
include_once('../assets/php/config.php');
 | 
			
		||||
include_once('../assets/php/includes/film_dao.php');
 | 
			
		||||
include_once('../assets/php/includes/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()){
 | 
			
		||||
		$html ="";
 | 
			
		||||
        if (!isset($_SESSION['message'])) {
 | 
			
		||||
 | 
			
		||||
        // 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-> existFilm($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;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
							
								
								
									
										83
									
								
								root/panel_admin/includes/formDeleteManager.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										83
									
								
								root/panel_admin/includes/formDeleteManager.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,83 @@
 | 
			
		||||
<?php
 | 
			
		||||
//General Config File:
 | 
			
		||||
include_once('../assets/php/config.php');
 | 
			
		||||
include_once('../assets/php/includes/manager_dao.php');
 | 
			
		||||
include_once('../assets/php/includes/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()){
 | 
			
		||||
        $html ="";
 | 
			
		||||
        if (!isset($_SESSION['message'])) {
 | 
			
		||||
 | 
			
		||||
        // 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">
 | 
			
		||||
        <h3>ELIMINAR GERENTE</h3>
 | 
			
		||||
                    <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;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
							
								
								
									
										90
									
								
								root/panel_admin/includes/formDeletePromotion.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										90
									
								
								root/panel_admin/includes/formDeletePromotion.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,90 @@
 | 
			
		||||
<?php
 | 
			
		||||
//General Config File:
 | 
			
		||||
include_once('../assets/php/config.php');
 | 
			
		||||
include_once('../assets/php/includes/promotion_dao.php');
 | 
			
		||||
include_once('../assets/php/includes/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()){
 | 
			
		||||
		$html ="";
 | 
			
		||||
        if (!isset($_SESSION['message'])) {
 | 
			
		||||
 | 
			
		||||
        // 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">
 | 
			
		||||
		<h3>ELIMINAR PROMOCIÓN</h3>
 | 
			
		||||
						<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>			
 | 
			
		||||
					</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");
 | 
			
		||||
 | 
			
		||||
			
 | 
			
		||||
			$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;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
							
								
								
									
										101
									
								
								root/panel_admin/includes/formEditCinema.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										101
									
								
								root/panel_admin/includes/formEditCinema.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,101 @@
 | 
			
		||||
<?php
 | 
			
		||||
//General Config File:
 | 
			
		||||
include_once('../assets/php/config.php');
 | 
			
		||||
include_once('../assets/php/includes/cinema_dao.php');
 | 
			
		||||
include_once('../assets/php/includes/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()){
 | 
			
		||||
        $html ="";
 | 
			
		||||
        if(!isset($_SESSION['message'])) {
 | 
			
		||||
            $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 -> existCinema($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;	
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
							
								
								
									
										180
									
								
								root/panel_admin/includes/formEditFilm.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										180
									
								
								root/panel_admin/includes/formEditFilm.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,180 @@
 | 
			
		||||
<?php
 | 
			
		||||
//General Config File:
 | 
			
		||||
include_once('../assets/php/config.php');
 | 
			
		||||
include_once('../assets/php/includes/film_dao.php');
 | 
			
		||||
include_once('../assets/php/includes/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])?)*$'; 
 | 
			
		||||
    const EXTENSIONS = array('gif','jpg','jpe','jpeg','png');
 | 
			
		||||
 | 
			
		||||
    public function __construct() {
 | 
			
		||||
        $options = array("action" => "./?state=mf", 'enctype' => 'multipart/form-data');
 | 
			
		||||
        parent::__construct('formEditFilm', $options);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
	protected function generaCamposFormulario($datos, $errores = array()){
 | 
			
		||||
        $html ="";
 | 
			
		||||
        if (!isset($_SESSION['message'])) {
 | 
			
		||||
 | 
			
		||||
        // 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, 'img', '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="archivo" id="file" placeholder="Imagen promocional" /></div><pre>'.$errorImage.'</pre>
 | 
			
		||||
                    </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.";
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
        $t = $this->test_input($datos['tittle']) ?? null;
 | 
			
		||||
		$tittle = strtolower(str_replace(" ", "_", $t));
 | 
			
		||||
		//|| !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-> existFilm($id);
 | 
			
		||||
                if( mysqli_num_rows($exist) == 1){
 | 
			
		||||
                     $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);
 | 
			
		||||
                     //finfo_close($finfo);
 | 
			
		||||
                     
 | 
			
		||||
                     if ( $ok ) {
 | 
			
		||||
                         $tmp_name = $_FILES['archivo']['tmp_name'];
 | 
			
		||||
                         $nombreBd = strtolower(str_replace(" ", "_", $tittle)).".".pathinfo($nombre, PATHINFO_EXTENSION);
 | 
			
		||||
                         if ( !move_uploaded_file($tmp_name, "../img/films/{$nombreBd}") ) {
 | 
			
		||||
                         $result['img'] = 'Error al mover el archivo';
 | 
			
		||||
                         }
 | 
			
		||||
                 
 | 
			
		||||
                         //if ( !copy("../img/tmp/{$nombre}", "/{$nombre}") ) {
 | 
			
		||||
                         //  $result['img'] = 'Error al mover el archivo';
 | 
			
		||||
                         //}
 | 
			
		||||
                        //$nombreBd = str_replace("_", " ", $nombre);
 | 
			
		||||
                        $bd->editFilm($id, $tittle, $duration, $language, $description, $nombreBd);
 | 
			
		||||
                        $_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['img'] = 'El archivo tiene un nombre o tipo no soportado';
 | 
			
		||||
                     }
 | 
			
		||||
                     } else {
 | 
			
		||||
                        $bd->editFilmNoImg($id, $tittle, $duration, $language, $description);
 | 
			
		||||
                        $_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;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    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);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
							
								
								
									
										113
									
								
								root/panel_admin/includes/formEditManager.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										113
									
								
								root/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/includes/manager_dao.php');
 | 
			
		||||
include_once('../assets/php/includes/manager.php');
 | 
			
		||||
include_once('../assets/php/includes/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()){
 | 
			
		||||
       
 | 
			
		||||
        $html ="";
 | 
			
		||||
        if (!isset($_SESSION['message'])) {
 | 
			
		||||
        // 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 .= '
 | 
			
		||||
                    <h1>EDITAR GERENTE ID:'.$_POST['id'].'</h1>
 | 
			
		||||
                    <fieldset><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>';
 | 
			
		||||
        }
 | 
			
		||||
        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" class="content-input" name="idcinema" value="'.$ids[$i].'" id="'.$ids[$i].'"><label class="efe" for="'.$ids[$i].'">  '.$ids[$i].', '.$names[$i].'
 | 
			
		||||
            </label>
 | 
			
		||||
            ';
 | 
			
		||||
        }
 | 
			
		||||
        return $html;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
							
								
								
									
										183
									
								
								root/panel_admin/includes/formEditPromotion.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										183
									
								
								root/panel_admin/includes/formEditPromotion.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,183 @@
 | 
			
		||||
<?php
 | 
			
		||||
//General Config File:
 | 
			
		||||
include_once('../assets/php/config.php');
 | 
			
		||||
include_once('../assets/php/includes/promotion_dao.php');
 | 
			
		||||
include_once('../assets/php/includes/promotion.php');
 | 
			
		||||
include_once('../assets/php/form.php');
 | 
			
		||||
 | 
			
		||||
class formEditPromotion extends Form{
 | 
			
		||||
	//Constants:
 | 
			
		||||
	//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=mp", 'enctype' => 'multipart/form-data');
 | 
			
		||||
        parent::__construct('formEditPromotion', $options);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
	protected function generaCamposFormulario($datos, $errores = array()){
 | 
			
		||||
		$html ="";
 | 
			
		||||
        if (!isset($_SESSION['message'])) {
 | 
			
		||||
 | 
			
		||||
        // 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'));
 | 
			
		||||
		$errorImg = self::createMensajeError($errores, 'img', 'span', array('class' => 'error'));
 | 
			
		||||
 | 
			
		||||
		$html .= '<div class="row">
 | 
			
		||||
		<h3>EDITAR PROMOCIÓN</h3>
 | 
			
		||||
                    <fieldset id="film_form"><pre>'.$htmlErroresGlobales.'</pre>
 | 
			
		||||
                        <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="archivo" id="file" placeholder="Imagen promocional" /><pre>'.$errorImg.'</pre></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.";
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$t = $this->test_input($datos['tittle']) ?? null;
 | 
			
		||||
		$tittle = strtolower(str_replace(" ", "_", $t));
 | 
			
		||||
        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 = strtolower($this->test_input($datos['active'])) ?? null;
 | 
			
		||||
		//|| !mb_ereg_match(self::HTML5_EMAIL_REGEXP, $description) 
 | 
			
		||||
        if ( strcmp($active,"si") == 0 ||  strcmp($active,"no") == 0) {
 | 
			
		||||
			if ( strcmp($active,"si") == 0 ) {
 | 
			
		||||
				$boolean = 1;
 | 
			
		||||
			}
 | 
			
		||||
			else {
 | 
			
		||||
				$boolean = 0;
 | 
			
		||||
			}
 | 
			
		||||
        }
 | 
			
		||||
		else {
 | 
			
		||||
			$result['active'] = "El valor activo debe ser si/no";
 | 
			
		||||
		}
 | 
			
		||||
        
 | 
			
		||||
        if (count($result) === 0) {
 | 
			
		||||
        	$bd = new Promotion_DAO("complucine");
 | 
			
		||||
 | 
			
		||||
			$exist = $bd-> promotionData($id);
 | 
			
		||||
			if(mysqli_num_rows($exist) == 1){
 | 
			
		||||
				$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);
 | 
			
		||||
				//finfo_close($finfo);
 | 
			
		||||
				
 | 
			
		||||
				if ( $ok ) {
 | 
			
		||||
					$tmp_name = $_FILES['archivo']['tmp_name'];
 | 
			
		||||
					$nombreBd = strtolower(str_replace(" ", "_", $tittle)).".".pathinfo($nombre, PATHINFO_EXTENSION);
 | 
			
		||||
					if ( !move_uploaded_file($tmp_name, "../img/promos/{$nombreBd}") ) {
 | 
			
		||||
					$result['img'] = 'Error al mover el archivo';
 | 
			
		||||
					}
 | 
			
		||||
			
 | 
			
		||||
					//if ( !copy("../img/tmp/{$nombre}", "/{$nombre}") ) {
 | 
			
		||||
					//  $result['img'] = 'Error al mover el archivo';
 | 
			
		||||
					//}
 | 
			
		||||
					//$nombreBd = str_replace("_", " ", $nombre);
 | 
			
		||||
				   $bd->editPromotion($id, $tittle,$description,$code,$boolean, $nombreBd);
 | 
			
		||||
				   $_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['img'] = 'El archivo tiene un nombre o tipo no soportado';
 | 
			
		||||
				}
 | 
			
		||||
				} else {
 | 
			
		||||
				   $bd->editPromotionNoImg($id, $tittle,$description,$code,$boolean);
 | 
			
		||||
				   $_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;
 | 
			
		||||
	}
 | 
			
		||||
	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);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
							
								
								
									
										110
									
								
								root/panel_admin/index.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										110
									
								
								root/panel_admin/index.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,110 @@
 | 
			
		||||
<?php
 | 
			
		||||
    //General Config File:
 | 
			
		||||
    include_once('../assets/php/config.php');
 | 
			
		||||
    
 | 
			
		||||
    require_once($prefix.'panel_admin/panelAdmin.php');
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    if(($_SESSION["login"]) && $_SESSION["rol"] == "admin"){
 | 
			
		||||
    if(!isset($_GET["state"]))
 | 
			
		||||
        $_GET["state"] =null;
 | 
			
		||||
        switch($_GET["state"]){
 | 
			
		||||
                    case 'mc': if(isset($_POST['edit_cinema'])) {
 | 
			
		||||
                                    $reply=AdminPanel::editCinema();
 | 
			
		||||
                                }
 | 
			
		||||
                                else if(isset($_POST['delete_cinema'])) {
 | 
			
		||||
                                    $reply=AdminPanel::deleteCinema();
 | 
			
		||||
                                }                             
 | 
			
		||||
                                else {
 | 
			
		||||
                                    if(isset($_GET["cinema"])){
 | 
			
		||||
                                        if(isset($_GET["cinema"])){
 | 
			
		||||
                                            if(isset($_GET["number"])) {
 | 
			
		||||
                                                 $reply = AdminPanel::showSessions($_GET["cinema"]);
 | 
			
		||||
                                             }
 | 
			
		||||
                                             else { 
 | 
			
		||||
                                                 $reply = AdminPanel::showHalls($_GET["cinema"]);
 | 
			
		||||
                                             }
 | 
			
		||||
                                         }
 | 
			
		||||
                                    }
 | 
			
		||||
                                    else {
 | 
			
		||||
                                        $reply=AdminPanel::addCinema();
 | 
			
		||||
                                        $reply.= ($template->print_cinemas()); 
 | 
			
		||||
                                    }
 | 
			
		||||
                                };  
 | 
			
		||||
                    break;
 | 
			
		||||
                    case 'mf': if(isset($_POST['edit_film'])) {
 | 
			
		||||
                                $reply=AdminPanel::editFilm();
 | 
			
		||||
                            }
 | 
			
		||||
                            else if(isset($_POST['delete_film'])) {
 | 
			
		||||
                                $reply=AdminPanel::deleteFilm();
 | 
			
		||||
                            }
 | 
			
		||||
                            else {
 | 
			
		||||
                                $reply=AdminPanel::addFilm();
 | 
			
		||||
                                $reply.= $template->print_fimls();
 | 
			
		||||
                            };  
 | 
			
		||||
                    break;
 | 
			
		||||
                    case 'mp': 
 | 
			
		||||
                                if(isset($_POST['edit_promotion'])) {
 | 
			
		||||
                                    $reply=AdminPanel::editPromotion();
 | 
			
		||||
                                }
 | 
			
		||||
                                else if(isset($_POST['delete_promotion'])) {
 | 
			
		||||
                                    $reply=AdminPanel::deletePromotion();
 | 
			
		||||
                                }
 | 
			
		||||
                                else {
 | 
			
		||||
                                    $reply=AdminPanel::addPromotion();
 | 
			
		||||
                                    $reply.=AdminPanel::print_promotions();
 | 
			
		||||
                                
 | 
			
		||||
                                }; 
 | 
			
		||||
                    break;
 | 
			
		||||
                    case 'mg': if(isset($_POST['edit_manager'])) {
 | 
			
		||||
                                    $reply=AdminPanel::editManager();
 | 
			
		||||
                                }
 | 
			
		||||
                                else if(isset($_POST['delete_manager'])) {
 | 
			
		||||
                                    $reply=AdminPanel::deleteManager();
 | 
			
		||||
                                }
 | 
			
		||||
                                else if(isset($_POST['add_manager'])) {
 | 
			
		||||
                                    $reply=AdminPanel::addManager();
 | 
			
		||||
                                }
 | 
			
		||||
                                
 | 
			
		||||
                                else {  
 | 
			
		||||
                                    $reply=AdminPanel::print_managers();
 | 
			
		||||
                                    $reply.=AdminPanel::showAddBotton();
 | 
			
		||||
                                }; 
 | 
			
		||||
                    break;
 | 
			
		||||
                    case 'un': 
 | 
			
		||||
                        $reply=AdminPanel::see_like_user();
 | 
			
		||||
                        break;
 | 
			
		||||
                    case 'ur': 
 | 
			
		||||
                        $reply=AdminPanel::see_like_registed_user(); 
 | 
			
		||||
                        break;
 | 
			
		||||
                    case 'ag': 
 | 
			
		||||
                        $reply=AdminPanel::see_like_manager();
 | 
			
		||||
                        break;
 | 
			
		||||
                    default:
 | 
			
		||||
                        $reply=AdminPanel:: panel(); 
 | 
			
		||||
                    break;
 | 
			
		||||
                }
 | 
			
		||||
        }
 | 
			
		||||
        else{
 | 
			
		||||
            $reply ='<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="'.$prefix.'login/"><button>Iniciar Sesión</button></a>
 | 
			
		||||
                            </div>
 | 
			
		||||
                        </div>
 | 
			
		||||
                        <div class="column side"></div>'."\n";
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        $section = '<!-- Manager Admin -->
 | 
			
		||||
        <section id="admin_panel">
 | 
			
		||||
			<!-- Contents -->
 | 
			
		||||
			<div class="row">
 | 
			
		||||
				'.$reply.'
 | 
			
		||||
			</div>
 | 
			
		||||
        </section>';
 | 
			
		||||
 | 
			
		||||
        require RAIZ_APP.'/HTMLtemplate.php';
 | 
			
		||||
            
 | 
			
		||||
?>
 | 
			
		||||
							
								
								
									
										505
									
								
								root/panel_admin/panelAdmin-FER_SURFACE.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										505
									
								
								root/panel_admin/panelAdmin-FER_SURFACE.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,505 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
    class AdminPanel {
 | 
			
		||||
        private $state;
 | 
			
		||||
        private $login;
 | 
			
		||||
        private $prefix;
 | 
			
		||||
 | 
			
		||||
        function __construct(){}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        function getTemplate(){
 | 
			
		||||
            return $this->template;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        static function panel(){
 | 
			
		||||
            include_once('../assets/php/includes/user.php');
 | 
			
		||||
 | 
			
		||||
            $name = strtoupper(unserialize($_SESSION['user'])->getName());
 | 
			
		||||
            $email = unserialize($_SESSION['user'])->getEmail();
 | 
			
		||||
            $userPic = USER_PICS.strtolower($name).".jpg";
 | 
			
		||||
 | 
			
		||||
            return $reply=  '<div class="code info">
 | 
			
		||||
            <h1>Bienvenido al Panel de Administrador.</h1>
 | 
			
		||||
            <hr />
 | 
			
		||||
            <img src='.$userPic.' alt="user_profile_picture"/>
 | 
			
		||||
            <h3>'.strftime("%A %e de %B de %Y | %H:%M").'</h3>
 | 
			
		||||
            <p>Administrador: '.$name.'</p>
 | 
			
		||||
            <p>Email empresarial: '.$email.'</p>
 | 
			
		||||
            </div>'."\n"; 
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //Functions FILMS
 | 
			
		||||
        static function addFilm(){
 | 
			
		||||
            include_once('./includes/formAddFilm.php');
 | 
			
		||||
            $formAF = new formAddFilm();
 | 
			
		||||
            $htmlAForm = $formAF->gestiona();
 | 
			
		||||
            return $reply=   '<!-- Add film -->
 | 
			
		||||
            <div class="column side"></div>
 | 
			
		||||
                    <div class="column middle">
 | 
			
		||||
                    '.$htmlAForm."\n";
 | 
			
		||||
        }
 | 
			
		||||
    
 | 
			
		||||
        static function deleteFilm() {
 | 
			
		||||
            include_once('./includes/formDeleteFilm.php');
 | 
			
		||||
            $formDF = new formDeleteFilm();
 | 
			
		||||
            $htmlDForm = $formDF->gestiona();
 | 
			
		||||
            return $reply=   '<!-- Add film -->
 | 
			
		||||
            <div class="column side"></div>
 | 
			
		||||
                    <div class="column middle">
 | 
			
		||||
                    '.$htmlDForm.'
 | 
			
		||||
                    </div>'."\n";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        static function editFilm() {
 | 
			
		||||
            include_once('./includes/formEditFilm.php');
 | 
			
		||||
            $formEF = new formEditFilm();
 | 
			
		||||
            $htmlDForm = $formEF->gestiona();
 | 
			
		||||
            return $reply=  '<!-- Add film -->
 | 
			
		||||
            <div class="column side"></div>
 | 
			
		||||
                    <div class="column middle">
 | 
			
		||||
                    '.$htmlDForm.'
 | 
			
		||||
                    </div>'."\n";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
         //Functions Cinemas
 | 
			
		||||
         static function addCinema(){
 | 
			
		||||
            include_once('./includes/formAddCinema.php');
 | 
			
		||||
            $formAC = new formAddCinema();
 | 
			
		||||
            $htmlAForm = $formAC->gestiona();
 | 
			
		||||
            return $reply=   '<!-- Add cinema -->
 | 
			
		||||
            <div class="column side"></div>
 | 
			
		||||
                    <div class="column middle">
 | 
			
		||||
                    '.$htmlAForm.'
 | 
			
		||||
                    </div>'."\n";
 | 
			
		||||
        }
 | 
			
		||||
    
 | 
			
		||||
        static function deleteCinema() {
 | 
			
		||||
            include_once('./includes/formDeleteCinema.php');
 | 
			
		||||
            $formDC = new formDeleteCinema();
 | 
			
		||||
            $htmlDForm = $formDC->gestiona();
 | 
			
		||||
            return $reply=  '<!-- Delete cinema -->
 | 
			
		||||
            <div class="column side"></div>
 | 
			
		||||
                    <div class="column middle">
 | 
			
		||||
                    '.$htmlDForm.'
 | 
			
		||||
                    </div>'."\n";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        static function editCinema() {
 | 
			
		||||
            include_once('./includes/formEditCinema.php');
 | 
			
		||||
            $formEC = new formEditCinema();
 | 
			
		||||
            $htmlDForm = $formEC->gestiona();
 | 
			
		||||
            return $reply=  '<!-- Edit cinema -->
 | 
			
		||||
            <div class="column side"></div>
 | 
			
		||||
                    <div class="column middle">
 | 
			
		||||
                    '.$htmlDForm.'
 | 
			
		||||
                    </div>'."\n";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        static function showHalls($idCinema) {
 | 
			
		||||
            include_once('../assets/php/includes/hall.php');
 | 
			
		||||
            include_once('../assets/php/includes/hall_dao.php');
 | 
			
		||||
			$panel = '<div class="column side"></div>
 | 
			
		||||
                <div class="column middle">';
 | 
			
		||||
            $listhall = Hall::getListHalls($idCinema);
 | 
			
		||||
            if(!$listhall){
 | 
			
		||||
                $panel .= "<h2> No hay ninguna sala en este cine";
 | 
			
		||||
            }else{
 | 
			
		||||
            $panel .= '
 | 
			
		||||
                <div class="row">
 | 
			
		||||
                <ul class="tablelist col3">
 | 
			
		||||
                    <li class="title"> Sala </li>
 | 
			
		||||
                    <li class="title"> Asientos </li>
 | 
			
		||||
                    <li class="title"> Sesión </li>
 | 
			
		||||
                            '; 
 | 
			
		||||
            $parity = "odd";
 | 
			
		||||
            foreach($listhall as $hall){ 
 | 
			
		||||
                $panel .='<div class="'.$parity.'">
 | 
			
		||||
                                <li> '. $hall->getNumber().'</li>
 | 
			
		||||
                                <li> '.$hall->getTotalSeats().' </li>
 | 
			
		||||
                            </a>
 | 
			
		||||
                            <a  href="?state=mc&cinema='.$idCinema.'&number=1">
 | 
			
		||||
                                <li> Sesiones </li>
 | 
			
		||||
                            </a>
 | 
			
		||||
                        </div>
 | 
			
		||||
                        ';
 | 
			
		||||
                $parity = ($parity == "odd") ? "even" : "odd";
 | 
			
		||||
                }
 | 
			
		||||
            $panel.='
 | 
			
		||||
                </ul>';
 | 
			
		||||
            }
 | 
			
		||||
            $panel.='
 | 
			
		||||
                </div>
 | 
			
		||||
                <div class="column side"></div>';			
 | 
			
		||||
            return $panel;
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        static function showSessions($idCinema){
 | 
			
		||||
            include_once('../assets/php/includes/hall.php');
 | 
			
		||||
            include_once('../assets/php/includes/hall_dao.php');
 | 
			
		||||
            include_once('../assets/php/includes/session_dao.php');
 | 
			
		||||
            include_once('../assets/php/includes/session.php');
 | 
			
		||||
			//Base filtering values
 | 
			
		||||
			$date = $_POST['date'] ?? $_GET['date'] ?? date("Y-m-d");
 | 
			
		||||
			$hall = $_POST['hall'] ?? $_GET['hall'] ?? "1";
 | 
			
		||||
			
 | 
			
		||||
			//Session filter
 | 
			
		||||
			$panel='<div class = "column left">
 | 
			
		||||
					<form method="post" id="filter" action="?state=mc&cinema=1&number=1">
 | 
			
		||||
						<input type="date" name="date" value="'.$date.'" min="2021-01-01" max="2031-12-31">
 | 
			
		||||
							<select name="hall" class="button large">';
 | 
			
		||||
						
 | 
			
		||||
			foreach(Hall::getListHalls($idCinema) as $hll){
 | 
			
		||||
				if($hll->getNumber() == $hall){
 | 
			
		||||
					$panel.= '
 | 
			
		||||
								<option value="'. $hll->getNumber() .'"selected> Sala '. $hll->getNumber() .'</option> ';
 | 
			
		||||
				}else{ 
 | 
			
		||||
					$panel.= '
 | 
			
		||||
								<option value="'. $hll->getNumber() .'"> Sala '. $hll->getNumber() .'</option>';
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			$panel.='
 | 
			
		||||
							</select>
 | 
			
		||||
						<input type="submit" name="filter" value="Filtrar" class="button large"/>
 | 
			
		||||
					</form>
 | 
			
		||||
				</div>
 | 
			
		||||
			';
 | 
			
		||||
			//Session list
 | 
			
		||||
			$panel .='	<div class = "column right">';
 | 
			
		||||
			$sessions = Session::getListSessions($hall,$idCinema,$date);
 | 
			
		||||
			
 | 
			
		||||
			if($sessions) {
 | 
			
		||||
				$panel .='
 | 
			
		||||
					<form method="post" action="./?state=edit_session">
 | 
			
		||||
						<table class="alt">
 | 
			
		||||
							<thead>
 | 
			
		||||
								<tr>
 | 
			
		||||
									<th>Hora</th>
 | 
			
		||||
									<th>Pelicula</th>
 | 
			
		||||
									<th>Formato</th>
 | 
			
		||||
									<th>Precio</th>
 | 
			
		||||
								</tr>
 | 
			
		||||
							</thead>
 | 
			
		||||
							<tbody>'; 
 | 
			
		||||
				
 | 
			
		||||
				
 | 
			
		||||
				foreach($sessions as $session){ 
 | 
			
		||||
					$film = Session::getThisSessionFilm($session->getIdfilm());
 | 
			
		||||
					$panel .='
 | 
			
		||||
								<tr>
 | 
			
		||||
									<td> '.date("H:i", strtotime( $session->getStartTime())).' </td>
 | 
			
		||||
									<td> '. str_replace('_', ' ', $film["tittle"]) .' </td>
 | 
			
		||||
									<td> '.$session->getFormat().' </td>
 | 
			
		||||
									<td> '.$session->getSeatPrice().' </td>
 | 
			
		||||
								</tr>';
 | 
			
		||||
					}
 | 
			
		||||
				$panel.='
 | 
			
		||||
							</tbody>
 | 
			
		||||
						</table>
 | 
			
		||||
					</form>';
 | 
			
		||||
			} else {
 | 
			
		||||
				$panel.=' <h3> No hay ninguna sesion </h3>';
 | 
			
		||||
			}
 | 
			
		||||
			$panel.='</div>';
 | 
			
		||||
			
 | 
			
		||||
			return $panel;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //Functions MANAGERS
 | 
			
		||||
        static function print_managers(){
 | 
			
		||||
            include_once('../assets/php/includes/manager_dao.php');
 | 
			
		||||
            include_once('../assets/php/includes/manager.php');
 | 
			
		||||
            $manager = new Manager_DAO("complucine");
 | 
			
		||||
            $managers = $manager->allManagersData();
 | 
			
		||||
            $ids = array();
 | 
			
		||||
            $idscinemas = array();
 | 
			
		||||
            $usernames = array();
 | 
			
		||||
            $email = array();
 | 
			
		||||
            $rol = array();
 | 
			
		||||
            if(!is_array($managers)){ 
 | 
			
		||||
            $reply = "<h2> No hay ningun manager</h2>";
 | 
			
		||||
            }
 | 
			
		||||
            else{
 | 
			
		||||
                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();
 | 
			
		||||
                }
 | 
			
		||||
            
 | 
			
		||||
            $reply= "<div class='row'>
 | 
			
		||||
                        <ul class ='tablelist col7'>
 | 
			
		||||
                            <li class='title'>Id</li>
 | 
			
		||||
                            <li class='title'>IdCinema</li>
 | 
			
		||||
                            <li class='title'>Nombre</li>
 | 
			
		||||
                            <li class='title'>Email</li>
 | 
			
		||||
                            <li class='title'>Rol</li>
 | 
			
		||||
                            <li class='title'>Editar</li>
 | 
			
		||||
                            <li class='title'>Eliminar</li>
 | 
			
		||||
                        "; 
 | 
			
		||||
                    $parity = "odd";   
 | 
			
		||||
                for($i = 0; $i < count($managers); $i++){
 | 
			
		||||
                    $reply.= '
 | 
			
		||||
                            <div class="'.$parity.'">
 | 
			
		||||
                            <li>'. $ids[$i] .'</li>
 | 
			
		||||
                            <li>'. $idscinemas[$i] .'</li>
 | 
			
		||||
                            <li>'. $usernames[$i] .'</li>
 | 
			
		||||
                            <li>'. $email[$i] .'</li>
 | 
			
		||||
                            <li>'. $rol[$i] .'</li>
 | 
			
		||||
                            <li>
 | 
			
		||||
                                <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> 
 | 
			
		||||
                            </li> 
 | 
			
		||||
                            <li> 
 | 
			
		||||
                                <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> 
 | 
			
		||||
                            </li> 
 | 
			
		||||
                            </div>
 | 
			
		||||
                        '; 
 | 
			
		||||
                        $parity = ($parity == "odd") ? "even" : "odd";
 | 
			
		||||
                } 
 | 
			
		||||
            
 | 
			
		||||
            $reply.='</ul>
 | 
			
		||||
                </div>
 | 
			
		||||
            ';
 | 
			
		||||
            }
 | 
			
		||||
            return $reply;
 | 
			
		||||
        }
 | 
			
		||||
        static function showAddBotton() {
 | 
			
		||||
            return $reply = '<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>
 | 
			
		||||
                ';
 | 
			
		||||
        }
 | 
			
		||||
        static function addManager(){
 | 
			
		||||
            include_once('./includes/formAddManager.php');
 | 
			
		||||
            $formAM = new formAddManager();
 | 
			
		||||
            $htmlAForm = $formAM->gestiona();
 | 
			
		||||
            return $reply=   '<!-- ADD MANAGER -->
 | 
			
		||||
                <div class="column side"></div>
 | 
			
		||||
                <div class="column middle">
 | 
			
		||||
                    <h3>AÑADIR GERENTE</h3>
 | 
			
		||||
                    '.$htmlAForm.'
 | 
			
		||||
                </div>
 | 
			
		||||
                <div class="column side"></div>'."\n";
 | 
			
		||||
        }
 | 
			
		||||
        static function editManager(){
 | 
			
		||||
            include_once('./includes/formEditManager.php');
 | 
			
		||||
            $formEM = new formEditManager();
 | 
			
		||||
            $htmlEForm = $formEM->gestiona();
 | 
			
		||||
            return $reply=   '<!-- EDIT MANAGER -->
 | 
			
		||||
 | 
			
		||||
                <div class="column side"></div>
 | 
			
		||||
                <div class="column middle">
 | 
			
		||||
                    '.$htmlEForm.'
 | 
			
		||||
                </div>';
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        static function deleteManager(){
 | 
			
		||||
            include_once('./includes/formDeleteManager.php');
 | 
			
		||||
            $formDM = new formDeleteManager();
 | 
			
		||||
            $htmlDForm = $formDM->gestiona();
 | 
			
		||||
            return $reply=  '<!-- 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
 | 
			
		||||
        static function addPromotion(){
 | 
			
		||||
            include_once('./includes/formAddPromotion.php');
 | 
			
		||||
            $formAP = new formAddPromotion();
 | 
			
		||||
            $htmlAForm = $formAP->gestiona();
 | 
			
		||||
            return $reply=   '<!-- ADD PROMOTION -->
 | 
			
		||||
                <div class="column side"></div>
 | 
			
		||||
                <div class="column middle">
 | 
			
		||||
                    <h3>AÑADIR PROMOCIÓN</h3>
 | 
			
		||||
                    '.$htmlAForm.'
 | 
			
		||||
                </div>';
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
         static function editPromotion(){
 | 
			
		||||
            include_once('./includes/formEditPromotion.php');
 | 
			
		||||
            $formEP = new formEditPromotion();
 | 
			
		||||
            $htmlEForm = $formEP->gestiona();
 | 
			
		||||
            return $reply=  '<!-- EDIT MANAGER -->
 | 
			
		||||
                <div class="column side"></div>
 | 
			
		||||
                <div class="column middle">
 | 
			
		||||
                    <h3>EDITAR PROMOCIÓN</h3>
 | 
			
		||||
                    '.$htmlEForm.'
 | 
			
		||||
                </div>
 | 
			
		||||
                <div class="column side"></div>'."\n";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        static function deletePromotion(){
 | 
			
		||||
            include_once('./includes/formDeletePromotion.php');
 | 
			
		||||
            $formDP = new formDeletePromotion();
 | 
			
		||||
            $htmlDForm = $formDP->gestiona();
 | 
			
		||||
            return $reply=  '<!-- DELETE MANAGER -->
 | 
			
		||||
            <div class="column side"></div>
 | 
			
		||||
                    <div class="column middle">
 | 
			
		||||
                    <h3>ELIMINAR PROMOCIÓN</h3>
 | 
			
		||||
                    '.$htmlDForm.'
 | 
			
		||||
                    </div>'."\n";
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        static 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)){ 
 | 
			
		||||
             $reply = "<h2> No hay promociones </h2>";
 | 
			
		||||
            }
 | 
			
		||||
            else{
 | 
			
		||||
                foreach($promos as $key => $value){
 | 
			
		||||
                    $ids[$key] = $value->getId();
 | 
			
		||||
                    $tittles[$key] = $value->getTittle();
 | 
			
		||||
                    $descriptions[$key] = $value->getDescription();
 | 
			
		||||
                    $codes[$key] = $value->getCode();
 | 
			
		||||
                    if ($value->getActive() == 0) {
 | 
			
		||||
                        $actives[$key] = "si";
 | 
			
		||||
                    }
 | 
			
		||||
                    else{
 | 
			
		||||
                        $actives[$key] = "no";
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            
 | 
			
		||||
             $reply= "<div class='row'>
 | 
			
		||||
                        <ul class='tablelist col7'>   
 | 
			
		||||
                                <li class='title'>Id</li>
 | 
			
		||||
                                <li class='title'>Título</li>
 | 
			
		||||
                                <li class='title'>Descripcion</li>
 | 
			
		||||
                                <li class='title'>Código</li>
 | 
			
		||||
                                <li class='title'>Activo</li>
 | 
			
		||||
                                <li class='title'>Editar</li>
 | 
			
		||||
                                <li class='title'>Eliminar</li>
 | 
			
		||||
                            "; 
 | 
			
		||||
                $parity ="odd";
 | 
			
		||||
            for($i = 0; $i < count($promos); $i++){
 | 
			
		||||
                $reply.= '
 | 
			
		||||
                            <li>'. $ids[$i] .'</li>
 | 
			
		||||
                            <li>'. $tittles[$i] .'</li>
 | 
			
		||||
                            <li>'. $descriptions[$i] .'</li>
 | 
			
		||||
                            <li>'. $codes[$i] .'</li>
 | 
			
		||||
                            <li>'. $actives[$i] .'</li>
 | 
			
		||||
                            <li>
 | 
			
		||||
                                <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> 
 | 
			
		||||
                           
 | 
			
		||||
                            <li> 
 | 
			
		||||
                                <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> 
 | 
			
		||||
                            </li> 
 | 
			
		||||
                        </li>
 | 
			
		||||
                        </div>
 | 
			
		||||
                    '; 
 | 
			
		||||
                    $parity = ($parity=="odd")? "even":"odd";
 | 
			
		||||
            } 
 | 
			
		||||
                    
 | 
			
		||||
             $reply.='</ul>
 | 
			
		||||
                        
 | 
			
		||||
                    </div> 
 | 
			
		||||
            ';
 | 
			
		||||
            }
 | 
			
		||||
              return  $reply ;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        static function see_like_user(){
 | 
			
		||||
            $_SESSION["lastRol"] = $_SESSION["rol"];
 | 
			
		||||
            //unset($_SESSION["rol"]);
 | 
			
		||||
            $_SESSION["rol"] = null;
 | 
			
		||||
            //header("Location: {$_SERVER['PHP_SELF']}");
 | 
			
		||||
            return $reply = "<div class=''>
 | 
			
		||||
                                    <div class='column side'></div>
 | 
			
		||||
                                    <div class='column middle'>
 | 
			
		||||
                                        <div class='code info'>
 | 
			
		||||
                                            <h1> ¡ATENCIÓN! </h1><hr />
 | 
			
		||||
                                            <p>Está viendo la web como un Usuario NO Registrado.</p>
 | 
			
		||||
                                            <a href='../../'><button>Cerrar Mensaje</button></a>
 | 
			
		||||
                                        </div>
 | 
			
		||||
                                    </div>
 | 
			
		||||
                                    <div class='column side'></div>
 | 
			
		||||
                                </div>
 | 
			
		||||
                                ";
 | 
			
		||||
        }
 | 
			
		||||
        static function see_like_registed_user(){
 | 
			
		||||
            $_SESSION["lastRol"] = $_SESSION["rol"];
 | 
			
		||||
            $_SESSION["rol"] = "user";
 | 
			
		||||
            //header("Location: {$_SERVER['PHP_SELF']}");
 | 
			
		||||
            return $reply = "<div class='row'>
 | 
			
		||||
                                     <div class='column side'></div>
 | 
			
		||||
                                      <div class='column middle'>
 | 
			
		||||
                                             <div class='code info'>
 | 
			
		||||
                                                <h1> ¡ATENCIÓN! </h1><hr />
 | 
			
		||||
                                                 <p>Está viendo la web como un Usuario Registrado.</p>
 | 
			
		||||
                                                 <a href='../../panel_user'><button>Cerrar Mensaje</button></a>
 | 
			
		||||
                                             </div>
 | 
			
		||||
                                     </div>
 | 
			
		||||
                                     <div class='column side'></div>
 | 
			
		||||
                                    </div>
 | 
			
		||||
                                    ";
 | 
			
		||||
            }
 | 
			
		||||
        static function see_like_manager(){
 | 
			
		||||
            $_SESSION["lastRol"] = $_SESSION["rol"];
 | 
			
		||||
            $_SESSION["rol"] = "manager";
 | 
			
		||||
            //header("Location: {$_SERVER['PHP_SELF']}");
 | 
			
		||||
            return $reply = "<div class='row'>
 | 
			
		||||
                                      <div class='column side'></div>
 | 
			
		||||
                                       <div class='column middle'>
 | 
			
		||||
                                                 <div class='code info'>
 | 
			
		||||
                                                    <h1> ¡ATENCIÓN! </h1><hr />
 | 
			
		||||
                                                    <p>Está viendo la web como un Gerente.</p>
 | 
			
		||||
                                                    <a href='../../panel_manager'><button>Cerrar Mensaje</button></a>
 | 
			
		||||
                                                  </div>
 | 
			
		||||
                                        </div>
 | 
			
		||||
                                        <div class='column side'></div>
 | 
			
		||||
                                    </div>
 | 
			
		||||
                                    ";
 | 
			
		||||
            }
 | 
			
		||||
    }
 | 
			
		||||
   
 | 
			
		||||
?>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										500
									
								
								root/panel_admin/panelAdmin.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										500
									
								
								root/panel_admin/panelAdmin.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,500 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
    class AdminPanel {
 | 
			
		||||
        private $state;
 | 
			
		||||
        private $login;
 | 
			
		||||
        private $prefix;
 | 
			
		||||
 | 
			
		||||
        function __construct(){}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        function getTemplate(){
 | 
			
		||||
            return $this->template;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        static function panel(){
 | 
			
		||||
            include_once('../assets/php/includes/user.php');
 | 
			
		||||
 | 
			
		||||
            $name = strtoupper(unserialize($_SESSION['user'])->getName());
 | 
			
		||||
            $email = unserialize($_SESSION['user'])->getEmail();
 | 
			
		||||
            $userPic = USER_PICS.strtolower($name).".jpg";
 | 
			
		||||
 | 
			
		||||
            return $reply=  '<div class="code info">
 | 
			
		||||
            <h1>Bienvenido al Panel de Administrador.</h1>
 | 
			
		||||
            <hr />
 | 
			
		||||
            <img src='.$userPic.' alt="user_profile_picture"/>
 | 
			
		||||
            <h3>'.strftime("%A %e de %B de %Y | %H:%M").'</h3>
 | 
			
		||||
            <p>Administrador: '.$name.'</p>
 | 
			
		||||
            <p>Email empresarial: '.$email.'</p>
 | 
			
		||||
            </div>'."\n"; 
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //Functions FILMS
 | 
			
		||||
        static function addFilm(){
 | 
			
		||||
            include_once('./includes/formAddFilm.php');
 | 
			
		||||
            $formAF = new formAddFilm();
 | 
			
		||||
            $htmlAForm = $formAF->gestiona();
 | 
			
		||||
            return $reply=   '<!-- Add film -->
 | 
			
		||||
            <div class="column side"></div>
 | 
			
		||||
                    <div class="column middle">
 | 
			
		||||
                    '.$htmlAForm."\n";
 | 
			
		||||
        }
 | 
			
		||||
    
 | 
			
		||||
        static function deleteFilm() {
 | 
			
		||||
            include_once('./includes/formDeleteFilm.php');
 | 
			
		||||
            $formDF = new formDeleteFilm();
 | 
			
		||||
            $htmlDForm = $formDF->gestiona();
 | 
			
		||||
            return $reply=   '<!-- Add film -->
 | 
			
		||||
            <div class="column side"></div>
 | 
			
		||||
                    <div class="column middle">
 | 
			
		||||
                    '.$htmlDForm.'
 | 
			
		||||
                    </div>'."\n";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        static function editFilm() {
 | 
			
		||||
            include_once('./includes/formEditFilm.php');
 | 
			
		||||
            $formEF = new formEditFilm();
 | 
			
		||||
            $htmlDForm = $formEF->gestiona();
 | 
			
		||||
            return $reply=  '<!-- Add film -->
 | 
			
		||||
            <div class="column side"></div>
 | 
			
		||||
                    <div class="column middle">
 | 
			
		||||
                    '.$htmlDForm.'
 | 
			
		||||
                    </div>'."\n";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
         //Functions Cinemas
 | 
			
		||||
         static function addCinema(){
 | 
			
		||||
            include_once('./includes/formAddCinema.php');
 | 
			
		||||
            $formAC = new formAddCinema();
 | 
			
		||||
            $htmlAForm = $formAC->gestiona();
 | 
			
		||||
            return $reply=   '<!-- Add cinema -->
 | 
			
		||||
            <div class="column side"></div>
 | 
			
		||||
                    <div class="column middle">
 | 
			
		||||
                    '.$htmlAForm.'
 | 
			
		||||
                    </div>'."\n";
 | 
			
		||||
        }
 | 
			
		||||
    
 | 
			
		||||
        static function deleteCinema() {
 | 
			
		||||
            include_once('./includes/formDeleteCinema.php');
 | 
			
		||||
            $formDC = new formDeleteCinema();
 | 
			
		||||
            $htmlDForm = $formDC->gestiona();
 | 
			
		||||
            return $reply=  '<!-- Delete cinema -->
 | 
			
		||||
            <div class="column side"></div>
 | 
			
		||||
                    <div class="column middle">
 | 
			
		||||
                    '.$htmlDForm.'
 | 
			
		||||
                    </div>'."\n";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        static function editCinema() {
 | 
			
		||||
            include_once('./includes/formEditCinema.php');
 | 
			
		||||
            $formEC = new formEditCinema();
 | 
			
		||||
            $htmlDForm = $formEC->gestiona();
 | 
			
		||||
            return $reply=  '<!-- Edit cinema -->
 | 
			
		||||
            <div class="column side"></div>
 | 
			
		||||
                    <div class="column middle">
 | 
			
		||||
                    '.$htmlDForm.'
 | 
			
		||||
                    </div>'."\n";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        static function showHalls($idCinema) {
 | 
			
		||||
            include_once('../assets/php/includes/hall.php');
 | 
			
		||||
            include_once('../assets/php/includes/hall_dao.php');
 | 
			
		||||
			$panel = '<div class="column side"></div>
 | 
			
		||||
                <div class="column middle">';
 | 
			
		||||
            $listhall = Hall::getListHalls($idCinema);
 | 
			
		||||
            if(!$listhall){
 | 
			
		||||
                $panel .= "<h2> No hay ninguna sala en este cine";
 | 
			
		||||
            }else{
 | 
			
		||||
            $panel .= '
 | 
			
		||||
                <div class="row">
 | 
			
		||||
                <ul class="tablelist col3">
 | 
			
		||||
                    <li class="title"> Sala </li>
 | 
			
		||||
                    <li class="title"> Asientos </li>
 | 
			
		||||
                    <li class="title"> Sesión </li>
 | 
			
		||||
                            '; 
 | 
			
		||||
            $parity = "odd";
 | 
			
		||||
            foreach($listhall as $hall){ 
 | 
			
		||||
                $panel .='<div class="'.$parity.'">
 | 
			
		||||
                                <li> '. $hall->getNumber().'</li>
 | 
			
		||||
                                <li> '.$hall->getTotalSeats().' </li>
 | 
			
		||||
                            </a>
 | 
			
		||||
                            <a  href="?state=mc&cinema='.$idCinema.'&number=1">
 | 
			
		||||
                                <li> Sesiones </li>
 | 
			
		||||
                            </a>
 | 
			
		||||
                        </div>
 | 
			
		||||
                        ';
 | 
			
		||||
                $parity = ($parity == "odd") ? "even" : "odd";
 | 
			
		||||
                }
 | 
			
		||||
            $panel.='
 | 
			
		||||
                </ul>';
 | 
			
		||||
            }
 | 
			
		||||
            $panel.='
 | 
			
		||||
                </div>
 | 
			
		||||
                <div class="column side"></div>';			
 | 
			
		||||
            return $panel;
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        static function showSessions($idCinema){
 | 
			
		||||
            include_once('../assets/php/includes/hall.php');
 | 
			
		||||
            include_once('../assets/php/includes/hall_dao.php');
 | 
			
		||||
            include_once('../assets/php/includes/session_dao.php');
 | 
			
		||||
            include_once('../assets/php/includes/session.php');
 | 
			
		||||
			//Base filtering values
 | 
			
		||||
			$date = $_POST['date'] ?? $_GET['date'] ?? date("Y-m-d");
 | 
			
		||||
			$hall = $_POST['hall'] ?? $_GET['hall'] ?? "1";
 | 
			
		||||
			
 | 
			
		||||
			//Session filter
 | 
			
		||||
			$panel='<div class = "column left">
 | 
			
		||||
					<form method="post" id="filter" action="?state=mc&cinema=1&number=1">
 | 
			
		||||
						<input type="date" name="date" value="'.$date.'" min="2021-01-01" max="2031-12-31">
 | 
			
		||||
							<select name="hall" class="button large">';
 | 
			
		||||
						
 | 
			
		||||
			foreach(Hall::getListHalls($idCinema) as $hll){
 | 
			
		||||
				if($hll->getNumber() == $hall){
 | 
			
		||||
					$panel.= '
 | 
			
		||||
								<option value="'. $hll->getNumber() .'"selected> Sala '. $hll->getNumber() .'</option> ';
 | 
			
		||||
				}else{ 
 | 
			
		||||
					$panel.= '
 | 
			
		||||
								<option value="'. $hll->getNumber() .'"> Sala '. $hll->getNumber() .'</option>';
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			$panel.='
 | 
			
		||||
							</select>
 | 
			
		||||
						<input type="submit" name="filter" value="Filtrar" class="button large"/>
 | 
			
		||||
					</form>
 | 
			
		||||
				</div>
 | 
			
		||||
			';
 | 
			
		||||
			//Session list
 | 
			
		||||
			$panel .='	<div class = "column right">';
 | 
			
		||||
			$sessions = Session::getListSessions($hall,$idCinema,$date);
 | 
			
		||||
			
 | 
			
		||||
			if($sessions) {
 | 
			
		||||
				$panel .='
 | 
			
		||||
					<form method="post" action="./?state=edit_session">
 | 
			
		||||
						<table class="alt">
 | 
			
		||||
							<thead>
 | 
			
		||||
								<tr>
 | 
			
		||||
									<th>Hora</th>
 | 
			
		||||
									<th>Pelicula</th>
 | 
			
		||||
									<th>Formato</th>
 | 
			
		||||
									<th>Precio</th>
 | 
			
		||||
								</tr>
 | 
			
		||||
							</thead>
 | 
			
		||||
							<tbody>'; 
 | 
			
		||||
				
 | 
			
		||||
				
 | 
			
		||||
				foreach($sessions as $session){ 
 | 
			
		||||
					$film = Session::getThisSessionFilm($session->getIdfilm());
 | 
			
		||||
					$panel .='
 | 
			
		||||
								<tr>
 | 
			
		||||
									<td> '.date("H:i", strtotime( $session->getStartTime())).' </td>
 | 
			
		||||
									<td> '. str_replace('_', ' ', $film["tittle"]) .' </td>
 | 
			
		||||
									<td> '.$session->getFormat().' </td>
 | 
			
		||||
									<td> '.$session->getSeatPrice().' </td>
 | 
			
		||||
								</tr>';
 | 
			
		||||
					}
 | 
			
		||||
				$panel.='
 | 
			
		||||
							</tbody>
 | 
			
		||||
						</table>
 | 
			
		||||
					</form>';
 | 
			
		||||
			} else {
 | 
			
		||||
				$panel.=' <h3> No hay ninguna sesion </h3>';
 | 
			
		||||
			}
 | 
			
		||||
			$panel.='</div>';
 | 
			
		||||
			
 | 
			
		||||
			return $panel;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //Functions MANAGERS
 | 
			
		||||
        static function print_managers(){
 | 
			
		||||
            include_once('../assets/php/includes/manager_dao.php');
 | 
			
		||||
            include_once('../assets/php/includes/manager.php');
 | 
			
		||||
            $manager = new Manager_DAO("complucine");
 | 
			
		||||
            $managers = $manager->allManagersData();
 | 
			
		||||
            $ids = array();
 | 
			
		||||
            $idscinemas = array();
 | 
			
		||||
            $usernames = array();
 | 
			
		||||
            $email = array();
 | 
			
		||||
            $rol = array();
 | 
			
		||||
            if(!is_array($managers)){ 
 | 
			
		||||
            $reply = "<h2> No hay ningun manager</h2>";
 | 
			
		||||
            }
 | 
			
		||||
            else{
 | 
			
		||||
                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();
 | 
			
		||||
                }
 | 
			
		||||
            
 | 
			
		||||
            $reply= "<div class='row'>
 | 
			
		||||
                        <ul class ='tablelist col7'>
 | 
			
		||||
                            <li class='title'>Id</li>
 | 
			
		||||
                            <li class='title'>IdCinema</li>
 | 
			
		||||
                            <li class='title'>Nombre</li>
 | 
			
		||||
                            <li class='title'>Email</li>
 | 
			
		||||
                            <li class='title'>Rol</li>
 | 
			
		||||
                            <li class='title'>Editar</li>
 | 
			
		||||
                            <li class='title'>Eliminar</li>
 | 
			
		||||
                        "; 
 | 
			
		||||
                    $parity = "odd";   
 | 
			
		||||
                for($i = 0; $i < count($managers); $i++){
 | 
			
		||||
                    $reply.= '
 | 
			
		||||
                            <div class="'.$parity.'">
 | 
			
		||||
                            <li>'. $ids[$i] .'</li>
 | 
			
		||||
                            <li>'. $idscinemas[$i] .'</li>
 | 
			
		||||
                            <li>'. $usernames[$i] .'</li>
 | 
			
		||||
                            <li>'. $email[$i] .'</li>
 | 
			
		||||
                            <li>'. $rol[$i] .'</li>
 | 
			
		||||
                            <li>
 | 
			
		||||
                                <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> 
 | 
			
		||||
                            </li> 
 | 
			
		||||
                            <li> 
 | 
			
		||||
                                <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> 
 | 
			
		||||
                            </li> 
 | 
			
		||||
                            </div>
 | 
			
		||||
                        '; 
 | 
			
		||||
                        $parity = ($parity == "odd") ? "even" : "odd";
 | 
			
		||||
                } 
 | 
			
		||||
            
 | 
			
		||||
            $reply.='</ul>
 | 
			
		||||
                </div>
 | 
			
		||||
            ';
 | 
			
		||||
            }
 | 
			
		||||
            return $reply;
 | 
			
		||||
        }
 | 
			
		||||
        static function showAddBotton() {
 | 
			
		||||
            return $reply = '<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>
 | 
			
		||||
                ';
 | 
			
		||||
        }
 | 
			
		||||
        static function addManager(){
 | 
			
		||||
            include_once('./includes/formAddManager.php');
 | 
			
		||||
            $formAM = new formAddManager();
 | 
			
		||||
            $htmlAForm = $formAM->gestiona();
 | 
			
		||||
            return $reply=   '<!-- ADD MANAGER -->
 | 
			
		||||
                <div class="column side"></div>
 | 
			
		||||
                <div class="column middle">  
 | 
			
		||||
                    '.$htmlAForm.'
 | 
			
		||||
                </div>
 | 
			
		||||
                <div class="column side"></div>'."\n";
 | 
			
		||||
        }
 | 
			
		||||
        static function editManager(){
 | 
			
		||||
            include_once('./includes/formEditManager.php');
 | 
			
		||||
            $formEM = new formEditManager();
 | 
			
		||||
            $htmlEForm = $formEM->gestiona();
 | 
			
		||||
            return $reply=   '<!-- EDIT MANAGER -->
 | 
			
		||||
                <div class="column side"></div>
 | 
			
		||||
                <div class="column middle">
 | 
			
		||||
                    '.$htmlEForm.'
 | 
			
		||||
                </div>';
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        static function deleteManager(){
 | 
			
		||||
            include_once('./includes/formDeleteManager.php');
 | 
			
		||||
            $formDM = new formDeleteManager();
 | 
			
		||||
            $htmlDForm = $formDM->gestiona();
 | 
			
		||||
            return $reply=  '<!-- DELETE MANAGER -->
 | 
			
		||||
                <div class="column side"></div>
 | 
			
		||||
                <div class="column middle">
 | 
			
		||||
                    '.$htmlDForm.'
 | 
			
		||||
                </div>
 | 
			
		||||
                <div class="column side"></div>'."\n";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //Functions PROMOTIONS
 | 
			
		||||
        static function addPromotion(){
 | 
			
		||||
            include_once('./includes/formAddPromotion.php');
 | 
			
		||||
            $formAP = new formAddPromotion();
 | 
			
		||||
            $htmlAForm = $formAP->gestiona();
 | 
			
		||||
            return $reply=   '<!-- ADD PROMOTION -->
 | 
			
		||||
                <div class="column side"></div>
 | 
			
		||||
                <div class="column middle">
 | 
			
		||||
                    '.$htmlAForm.'
 | 
			
		||||
                </div>';
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
         static function editPromotion(){
 | 
			
		||||
            include_once('./includes/formEditPromotion.php');
 | 
			
		||||
            $formEP = new formEditPromotion();
 | 
			
		||||
            $htmlEForm = $formEP->gestiona();
 | 
			
		||||
            return $reply=  '<!-- EDIT MANAGER -->
 | 
			
		||||
                <div class="column side"></div>
 | 
			
		||||
                <div class="column middle">
 | 
			
		||||
                    '.$htmlEForm.'
 | 
			
		||||
                </div>
 | 
			
		||||
                <div class="column side"></div>'."\n";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        static function deletePromotion(){
 | 
			
		||||
            include_once('./includes/formDeletePromotion.php');
 | 
			
		||||
            $formDP = new formDeletePromotion();
 | 
			
		||||
            $htmlDForm = $formDP->gestiona();
 | 
			
		||||
            return $reply=  '<!-- DELETE MANAGER -->
 | 
			
		||||
            <div class="column side"></div>
 | 
			
		||||
                    <div class="column middle">
 | 
			
		||||
                    '.$htmlDForm.'
 | 
			
		||||
                    </div>'."\n";
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        static 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)){ 
 | 
			
		||||
             $reply = "<h2> No hay promociones </h2>";
 | 
			
		||||
            }
 | 
			
		||||
            else{
 | 
			
		||||
                foreach($promos as $key => $value){
 | 
			
		||||
                    $ids[$key] = $value->getId();
 | 
			
		||||
                    $tittles[$key] = $value->getTittle();
 | 
			
		||||
                    $descriptions[$key] = $value->getDescription();
 | 
			
		||||
                    $codes[$key] = $value->getCode();
 | 
			
		||||
                    if ($value->getActive() == 0) {
 | 
			
		||||
                        $actives[$key] = "no";
 | 
			
		||||
                    }
 | 
			
		||||
                    else{
 | 
			
		||||
                        $actives[$key] = "si";
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            
 | 
			
		||||
             $reply= "<div class='row'>
 | 
			
		||||
                        <ul class='tablelist col7'>   
 | 
			
		||||
                                <li class='title'>Id</li>
 | 
			
		||||
                                <li class='title'>Título</li>
 | 
			
		||||
                                <li class='title'>Descripcion</li>
 | 
			
		||||
                                <li class='title'>Código</li>
 | 
			
		||||
                                <li class='title'>Activo</li>
 | 
			
		||||
                                <li class='title'>Editar</li>
 | 
			
		||||
                                <li class='title'>Eliminar</li>
 | 
			
		||||
                            "; 
 | 
			
		||||
                $parity ="odd";
 | 
			
		||||
            for($i = 0; $i < count($promos); $i++){
 | 
			
		||||
                $reply.= '
 | 
			
		||||
                            <div class="'.$parity.'">
 | 
			
		||||
                            <li>'. $ids[$i] .'</li>
 | 
			
		||||
                            <li>'. $tittles[$i] .'</li>
 | 
			
		||||
                            <li>'. $descriptions[$i] .'</li>
 | 
			
		||||
                            <li>'. $codes[$i] .'</li>
 | 
			
		||||
                            <li>'. $actives[$i] .'</li>
 | 
			
		||||
                            <li>
 | 
			
		||||
                                <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> 
 | 
			
		||||
                           
 | 
			
		||||
                            <li> 
 | 
			
		||||
                                <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> 
 | 
			
		||||
                            </li> 
 | 
			
		||||
                        </li>
 | 
			
		||||
                        </div>
 | 
			
		||||
                    '; 
 | 
			
		||||
                    $parity = ($parity=="odd")? "even":"odd";
 | 
			
		||||
            } 
 | 
			
		||||
                    
 | 
			
		||||
             $reply.='</ul>
 | 
			
		||||
                        
 | 
			
		||||
                    </div> 
 | 
			
		||||
            ';
 | 
			
		||||
            }
 | 
			
		||||
              return  $reply ;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        static function see_like_user(){
 | 
			
		||||
            $_SESSION["lastRol"] = $_SESSION["rol"];
 | 
			
		||||
            //unset($_SESSION["rol"]);
 | 
			
		||||
            $_SESSION["rol"] = null;
 | 
			
		||||
            //header("Location: {$_SERVER['PHP_SELF']}");
 | 
			
		||||
            return $reply = "<div class=''>
 | 
			
		||||
                                    <div class='column side'></div>
 | 
			
		||||
                                    <div class='column middle'>
 | 
			
		||||
                                        <div class='code info'>
 | 
			
		||||
                                            <h1> ¡ATENCIÓN! </h1><hr />
 | 
			
		||||
                                            <p>Está viendo la web como un Usuario NO Registrado.</p>
 | 
			
		||||
                                            <a href='../../'><button>Cerrar Mensaje</button></a>
 | 
			
		||||
                                        </div>
 | 
			
		||||
                                    </div>
 | 
			
		||||
                                    <div class='column side'></div>
 | 
			
		||||
                                </div>
 | 
			
		||||
                                ";
 | 
			
		||||
        }
 | 
			
		||||
        static function see_like_registed_user(){
 | 
			
		||||
            $_SESSION["lastRol"] = $_SESSION["rol"];
 | 
			
		||||
            $_SESSION["rol"] = "user";
 | 
			
		||||
            //header("Location: {$_SERVER['PHP_SELF']}");
 | 
			
		||||
            return $reply = "<div class='row'>
 | 
			
		||||
                                     <div class='column side'></div>
 | 
			
		||||
                                      <div class='column middle'>
 | 
			
		||||
                                             <div class='code info'>
 | 
			
		||||
                                                <h1> ¡ATENCIÓN! </h1><hr />
 | 
			
		||||
                                                 <p>Está viendo la web como un Usuario Registrado.</p>
 | 
			
		||||
                                                 <a href='../../panel_user'><button>Cerrar Mensaje</button></a>
 | 
			
		||||
                                             </div>
 | 
			
		||||
                                     </div>
 | 
			
		||||
                                     <div class='column side'></div>
 | 
			
		||||
                                    </div>
 | 
			
		||||
                                    ";
 | 
			
		||||
            }
 | 
			
		||||
        static function see_like_manager(){
 | 
			
		||||
            $_SESSION["lastRol"] = $_SESSION["rol"];
 | 
			
		||||
            $_SESSION["rol"] = "manager";
 | 
			
		||||
            //header("Location: {$_SERVER['PHP_SELF']}");
 | 
			
		||||
            return $reply = "<div class='row'>
 | 
			
		||||
                                      <div class='column side'></div>
 | 
			
		||||
                                       <div class='column middle'>
 | 
			
		||||
                                                 <div class='code info'>
 | 
			
		||||
                                                    <h1> ¡ATENCIÓN! </h1><hr />
 | 
			
		||||
                                                    <p>Está viendo la web como un Gerente.</p>
 | 
			
		||||
                                                    <a href='../../panel_manager'><button>Cerrar Mensaje</button></a>
 | 
			
		||||
                                                  </div>
 | 
			
		||||
                                        </div>
 | 
			
		||||
                                        <div class='column side'></div>
 | 
			
		||||
                                    </div>
 | 
			
		||||
                                    ";
 | 
			
		||||
            }
 | 
			
		||||
    }
 | 
			
		||||
   
 | 
			
		||||
?>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user