-Cambiado el alineamiento del fuente en varios archivos

-Cambiado el menú para poder elegir si se abre en la misma hoja en una diferente
-Mantenimiento ahora el contenido se centra en la página.
-El fichero pdf ahora se puede grabar en disco y se puede visualizar en una ventana nueva.
This commit is contained in:
2014-02-14 00:18:47 +01:00
parent fb276bd753
commit c54f604b47
14 changed files with 1098 additions and 794 deletions

View File

@@ -1,64 +1,73 @@
<?php
/**
* @package Inventario
* @copyright Copyright (c) 2008, Ricardo Montañana Gómez
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* This file is part of Inventario.
* Inventario is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Inventario is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Inventario. If not, see <http://www.gnu.org/licenses/>.
*
*/
define ('PIE','<center><a target="_blank" href="http://www.gnu.org/licenses/gpl-3.0-standalone.html"><img src="img/gplv3.png" alt="GPL v3"/></a>'.
'<a target="_blank" href="http://www.apache.org"><img src="img/apache.gif" alt="Sitio web creado con Apache" /></a>'.
'<a target="_blank" href="http://www.mysql.org"><img src="img/mysql.png" width=125 height=47 alt="Gestor de bases de datos mySQL" /></a>'.
'<a target="_blank" href="http://www.php.net"><img src="img/php.gif" alt="PHP Language" /></a> </center>');
define ('FORMULARIO_ACCESO','<form name="formulario_acceso" action="index.php?registrarse" method="POST">'.
'Usuario<br><input type="text" name="usuario" value="" size="8" /><br><br>Clave<br><input type="password" name="clave" value="" size="8" />'.
'<br><br><input type="submit" value="Iniciar" name="iniciar" /></form>');
define ('MENSAJE_DEMO','Puede Iniciar sesi&oacute;n con<br>usuario <i><b>demo</b></i><br>contrase&ntilde;a <i>demo</i><br>');
define ('USUARIO_INCORRECTO','<label class="error">Usuario y clave incorrectos!</label><br><br>');
/**
* @package Inventario
* @copyright Copyright (c) 2008, Ricardo Montañana Gómez
* @license http://www.gnu.org/licenses/gpl-3.0.txt
* This file is part of Inventario.
* Inventario is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Inventario is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Inventario. If not, see <http://www.gnu.org/licenses/>.
*
*/
define('PIE', '<center><a target="_blank" href="http://www.gnu.org/licenses/gpl-3.0-standalone.html"><img src="img/gplv3.png" alt="GPL v3"/></a>' .
'<a target="_blank" href="http://www.apache.org"><img src="img/apache.gif" alt="Sitio web creado con Apache" /></a>' .
'<a target="_blank" href="http://www.mysql.org"><img src="img/mysql.png" width=125 height=47 alt="Gestor de bases de datos mySQL" /></a>' .
'<a target="_blank" href="http://www.php.net"><img src="img/php.gif" alt="PHP Language" /></a> </center>');
define('FORMULARIO_ACCESO', '<form name="formulario_acceso" action="index.php?registrarse" method="POST">' .
'Usuario<br><input type="text" name="usuario" value="" size="8" /><br><br>Clave<br><input type="password" name="clave" value="" size="8" />' .
'<br><br><input type="submit" value="Iniciar" name="iniciar" /></form>');
define('MENSAJE_DEMO', 'Puede Iniciar sesi&oacute;n con<br>usuario <i><b>demo</b></i><br>contrase&ntilde;a <i>demo</i><br>');
define('USUARIO_INCORRECTO', '<label class="error">Usuario y clave incorrectos!</label><br><br>');
// Esta clase aportará el contenido a la plantilla
class AportaContenido {
/**
*
* @var boolean Aporta información sobre si el usuario está registrado o no.
*/
private $registrado;
/**
* @var string Nombre del usuario
*/
private $usuario=NULL;
/**
private $usuario = NULL;
/**
* @var Menu Menú de la página.
*/
private $miMenu;
/**
* @var database Controlador de la base de datos
*/
private $bdd;
/**
* @var string Opción elegida por el usuario
*/
private $opcionActual;
/**
/**
* @var boolean Usuario y clave incorrectos?
*/
private $usuario_inc=false;
private $usuario_inc = false;
/**
* @var array Permisos del usuario
*/
private $perfil;
// El constructor necesita saber cuál es la opción actual
/**
* Constructor de la clase.
@@ -68,40 +77,36 @@ class AportaContenido {
* @param array $perfil Permisos de acceso del usuario
* @param String $opcion Opción elegida por el usuario
*/
public function __construct($baseDatos,$registrado,$usuario,$perfil,$opcion)
{
$this->bdd=$baseDatos;
$this->miMenu=new Menu('inc/inventario.menu');
$this->registrado=$registrado;
$this->usuario=$usuario;
$this->perfil=$perfil;
$this->opcionActual=$opcion;
public function __construct($baseDatos, $registrado, $usuario, $perfil, $opcion) {
$this->bdd = $baseDatos;
$this->miMenu = new Menu('inc/inventario.menu');
$this->registrado = $registrado;
$this->usuario = $usuario;
$this->perfil = $perfil;
$this->opcionActual = $opcion;
}
/**
* Devuelve la fecha actual
* @param string $formato formato de devolución de la fecha
* @param string $idioma idioma para formatear la fecha, p.ej. es_ES
* @return string
*/
public function fechaActual($formato='',$idioma='es_ES')
{
if ($formato=='')
$formato="%d-%b-%Y %H:%M";
setlocale(LC_TIME,$idioma);
public function fechaActual($formato = '', $idioma = 'es_ES') {
if ($formato == '')
$formato = "%d-%b-%Y %H:%M";
setlocale(LC_TIME, $idioma);
return strftime($formato);
}
/**
*
* @return string Mensaje el usuario debe registrarse.
*/
private function mensajeRegistro()
{
/**
* @todo: tarea de prueba
*/
private function mensajeRegistro() {
return 'Debe registrarse para acceder a este apartado';
}
// Procesaremos todas las invocaciones a métodos en
// la función __call()
/**
@@ -110,9 +115,8 @@ class AportaContenido {
* @param string $parametros Parámetros del método
* @return string Contenido devuelto por el método
*/
public function __call($metodo,$parametros)
{
switch($metodo) { // Dependiendo del método invocado
public function __call($metodo, $parametros) {
switch ($metodo) { // Dependiendo del método invocado
case 'titulo': // devolvemos el título
return APLICACION;
case 'usuario':
@@ -126,7 +130,7 @@ class AportaContenido {
if ($this->registrado) {
return $this->miMenu->insertaMenu();
} else {
$salida=FORMULARIO_ACCESO;
$salida = FORMULARIO_ACCESO;
if ($this->usuario_inc) {
$salida.=USUARIO_INCORRECTO;
}
@@ -134,8 +138,8 @@ class AportaContenido {
return $salida;
}
case 'opcion':
list($opcion,$parametro)=explode("&",$this->opcionActual);
switch($opcion) {
list($opcion, $parametro) = explode("&", $this->opcionActual);
switch ($opcion) {
case 'bienvenido':
return "Men&uacute; Principal";
case 'principal':
@@ -145,7 +149,7 @@ class AportaContenido {
case 'ubicaciones':
case 'usuarios':
case 'test':
return "Mantenimiento de ".ucfirst($opcion).".";
return "Mantenimiento de " . ucfirst($opcion) . ".";
case 'configuracion':
return 'Configuraci&oacute;n y Preferencias.';
case 'informeInventario':return "Informe de Inventario";
@@ -160,70 +164,70 @@ class AportaContenido {
// Para incluir el contenido central de la página
case 'contenido':
// tendremos en cuenta cuál es la opción actual
/*echo "opcActual=$this->opcActual<br>";
echo "Metodo=$Metodo<br>";
print_r($Parametros);*/
/* echo "opcActual=$this->opcActual<br>";
echo "Metodo=$Metodo<br>";
print_r($Parametros); */
// if (!$this->registrado) {
// return $this->mensajeRegistro();
// }
list($opcion,$parametro)=explode("&",$this->opcionActual);
switch($opcion) {
list($opcion, $parametro) = explode("&", $this->opcionActual);
switch ($opcion) {
case 'principal': // contenido inicial
return '<br><br><center><img src="img/logo.png" alt="'.PROGRAMA.'">'.
'<br><label>'.PROGRAMA.'</label></center><br><br>'.PIE;
return '<br><br><center><img src="img/logo.png" alt="' . PROGRAMA . '">' .
'<br><label>' . PROGRAMA . '</label></center><br><br>' . PIE;
case 'articulos':
case 'ubicaciones':
case 'test':
case 'elementos':
if ($this->perfil['Consulta']) {
$ele=new Mantenimiento($this->bdd,$this->perfil,$opcion);
$ele = new Mantenimiento($this->bdd, $this->perfil, $opcion);
return $ele->ejecuta();
} else {
return $this->mensajePermisos(ucfirst($opcion));
}
case 'usuarios':
if ($this->perfil['Usuarios']) {
$ele=new Mantenimiento($this->bdd,$this->perfil,$opcion);
$ele = new Mantenimiento($this->bdd, $this->perfil, $opcion);
return $ele->ejecuta();
} else {
return $this->mensajePermisos('Usuarios');
}
case 'bienvenido': // El usuario quiere iniciar sesión
return 'Bienvenido '.$this->usuario.'<br><br><center><img src="img/codigoBarras.png" alt="'.PROGRAMA.'">'.
'<br><label>'.PROGRAMA.'</label></center><br><br>'.PIE;
return 'Bienvenido ' . $this->usuario . '<br><br><center><img src="img/codigoBarras.png" alt="' . PROGRAMA . '">' .
'<br><label>' . PROGRAMA . '</label></center><br><br>' . PIE;
case 'configuracion':
if ($this->perfil['Config']) {
$conf=new Configuracion();
$conf = new Configuracion();
return $conf->ejecuta();
} else {
return $this->mensajePermisos('Configuracion');
}
case 'informeInventario':
if ($this->perfil['Informe']) {
$info=new InformeInventario($this->bdd);
$info = new InformeInventario($this->bdd);
return $info->ejecuta();
} else {
return $this->mensajePermisos('Informes');
}
case 'descuadres':
if ($this->perfil['Informe']) {
$enlace='xml/informe'.ucfirst($opcion).'.xml';
$informe=new InformePDF($this->bdd,$enlace,$this->registrado);
$informe->imprimeInforme();
return;
$enlace = 'xml/informe' . ucfirst($opcion) . '.xml';
$informe = new InformePDF($this->bdd, $enlace, $this->registrado);
$informe->imprimeInforme();
return;
} else {
return $this->mensajePermisos('Informes');
}
} // Fin del contenido
case 'usuario_incorrecto':
$this->usuario_inc=true;
return;
$this->usuario_inc = true;
return;
case 'registro': // Si está registrado mostrar bienvenida
// si no, un enlace
if($this->bEstaRegistrado) {
return "Bienvenido <b>$this->sUsuario</b><hr />".
'<a href="index.php?cerrarSesion">Cerrar sesi&oacute;n</a>';
if ($this->bEstaRegistrado) {
return "Bienvenido <b>$this->sUsuario</b><hr />" .
'<a href="index.php?cerrarSesion">Cerrar sesi&oacute;n</a>';
} else {
return '';
}
@@ -231,14 +235,16 @@ class AportaContenido {
return "Marca {$metodo} queda sin procesar";
}
}
/**
*
* @param string $tipo
* @return string
*/
public function mensajePermisos($tipo)
{
return "<center><h1>No tiene permiso para acceder a ".$tipo."</h1></center>";
public function mensajePermisos($tipo) {
return "<center><h1>No tiene permiso para acceder a " . $tipo . "</h1></center>";
}
}
?>