mirror of
https://github.com/rmontanana/inventario2.git
synced 2025-08-15 15:35:56 +00:00
resolve #1
-Corregido mensaje de error en Pdf_mysql_table -Los informes de tablas se gestionan ahora en AportaContenido en lugar de en Inventario -El enlace al informe en Mantenimiento incluye en la URL los datos de filtrado y orden -Las definiciones de los informes incluyen variables para el orden y el filtrado -El mantenimiento de usuarios permite buscar usuarios y lo tiene en cuenta para el informe
This commit is contained in:
@@ -67,6 +67,12 @@ class AportaContenido {
|
||||
* @var array Permisos del usuario
|
||||
*/
|
||||
private $perfil;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var array Datos pasados en la URL
|
||||
*/
|
||||
private $datosURL = array();
|
||||
|
||||
// El constructor necesita saber cuál es la opción actual
|
||||
/**
|
||||
@@ -181,6 +187,29 @@ class AportaContenido {
|
||||
case 'ubicaciones':
|
||||
case 'test':
|
||||
case 'elementos':
|
||||
$this->cargaDatosURL();
|
||||
if ($this->datosURL['opc'] == "informe") {
|
||||
if (!$this->pefil['Informe']) {
|
||||
$this->procesaURL();
|
||||
$fichero = 'xml/informe' . ucfirst($opcion) . '.xml';
|
||||
$salida = 'tmp/informe' . ucfirst($opcion) . '.xml';
|
||||
//Establece los posibles parámetros del listado.
|
||||
$orden = $this->datosURL['orden'];
|
||||
$sentido = $this->datosURL['sentido'] == "asc" ? ' ' : ' desc ';
|
||||
$filtro = isset($this->datosURL['buscar']) ? $this->bdd->filtra($this->datosURL['buscar']) : '';
|
||||
$plantilla = file_get_contents($fichero) or die('Fallo en la apertura de la plantilla ' . $fichero);
|
||||
$plantilla = str_replace("{filtro}", $filtro, $plantilla);
|
||||
$plantilla = str_replace("{orden}", $orden . $sentido, $plantilla);
|
||||
file_put_contents($salida, $plantilla) or die('Fallo en la escritura de la plantilla ' . $salida);
|
||||
$informe = new InformePDF($this->bdd, $salida, $this->registrado);
|
||||
$informe->crea($salida);
|
||||
$informe->cierraPDF();
|
||||
$informe->imprimeInforme();
|
||||
return;
|
||||
} else {
|
||||
return $this->mensajePermisos("Informes");
|
||||
}
|
||||
}
|
||||
if ($this->perfil['Consulta']) {
|
||||
$ele = new Mantenimiento($this->bdd, $this->perfil, $opcion);
|
||||
return $ele->ejecuta();
|
||||
@@ -189,6 +218,29 @@ class AportaContenido {
|
||||
}
|
||||
case 'usuarios':
|
||||
if ($this->perfil['Usuarios']) {
|
||||
$this->cargaDatosURL();
|
||||
if ($this->datosURL['opc'] == "informe") {
|
||||
if (!$this->pefil['Informe']) {
|
||||
$this->procesaURL();
|
||||
$fichero = 'xml/informe' . ucfirst($opcion) . '.xml';
|
||||
$salida = 'tmp/informe' . ucfirst($opcion) . '.xml';
|
||||
//Establece los posibles parámetros del listado.
|
||||
$orden = $this->datosURL['orden'];
|
||||
$sentido = $this->datosURL['sentido'] == "asc" ? ' ' : ' desc ';
|
||||
$filtro = isset($this->datosURL['buscar']) ? $this->bdd->filtra($this->datosURL['buscar']) : '';
|
||||
$plantilla = file_get_contents($fichero) or die('Fallo en la apertura de la plantilla ' . $fichero);
|
||||
$plantilla = str_replace("{filtro}", $filtro, $plantilla);
|
||||
$plantilla = str_replace("{orden}", $orden . $sentido, $plantilla);
|
||||
file_put_contents($salida, $plantilla) or die('Fallo en la escritura de la plantilla ' . $salida);
|
||||
$informe = new InformePDF($this->bdd, $salida, $this->registrado);
|
||||
$informe->crea($salida);
|
||||
$informe->cierraPDF();
|
||||
$informe->imprimeInforme();
|
||||
return;
|
||||
} else {
|
||||
return $this->mensajePermisos("Informes");
|
||||
}
|
||||
}
|
||||
$ele = new Mantenimiento($this->bdd, $this->perfil, $opcion);
|
||||
return $ele->ejecuta();
|
||||
} else {
|
||||
@@ -276,7 +328,15 @@ class AportaContenido {
|
||||
return "Marca {$metodo} queda sin procesar";
|
||||
}
|
||||
}
|
||||
|
||||
public function cargaDatosURL()
|
||||
{
|
||||
$this->datosURL['opc'] = isset($_GET['opc']) ? $_GET['opc'] : 'inicial';
|
||||
$this->datosURL['orden'] = isset($_GET['orden']) ? $_GET['orden'] : 'id';
|
||||
$this->datosURL['sentido'] = isset($_GET['sentido']) ? $_GET['sentido'] : 'asc';
|
||||
$this->datosURL['pag'] = isset($_GET['pag']) ? $_GET['pag'] : '0';
|
||||
$this->datosURL['buscar'] = isset($_GET['buscar']) ? $_GET['buscar'] : null;
|
||||
$this->datosURL['id'] = isset($_GET['id']) ? $_GET['id'] : null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param string $tipo
|
||||
|
@@ -124,22 +124,10 @@ class Inventario {
|
||||
// Creamos un objeto Distribución facilitándole el
|
||||
// nombre del archivo plantilla y el objeto que aportará
|
||||
// el contenido
|
||||
$opc = $_GET['opc'];
|
||||
list($opcion, $parametro) = explode("&", $this->opcActual);
|
||||
switch ($opc) {
|
||||
case 'informe':
|
||||
$enlace = 'xml/informe' . ucfirst($opcion) . '.xml';
|
||||
//$enlace="tmp/inventarioUbicacion.xml";
|
||||
$informe = new InformePDF($this->bdd, $enlace, $this->registrado);
|
||||
$informe->crea($enlace);
|
||||
$informe->cierraPDF();
|
||||
$informe->imprimeInforme();
|
||||
return;
|
||||
default:
|
||||
$salida = new Distribucion($this->plant, $this->creaContenido());
|
||||
echo $salida->procesaPlantilla();
|
||||
break;
|
||||
}
|
||||
$salida = new Distribucion($this->plant, $this->creaContenido());
|
||||
echo $salida->procesaPlantilla();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -255,7 +255,9 @@ class Mantenimiento {
|
||||
$za = '<a href="' . $za . '"><img alt="desc" title="Orden descendente" src="img/' . ESTILO . '/descendente.png"></a>';
|
||||
$this->restoreURL();
|
||||
if ($this->perfil['Informe']) {
|
||||
$informe = '<a href="index.php?' . $tabla . '&opc=informe" target="_blank"><img src="img/' . ESTILO . '/informe.png" alt="informe" title="Informe pdf"></a>';
|
||||
$this->datosURL['opc'] = "informe";
|
||||
$inf = $this->montaURL();
|
||||
$informe = '<a href="' . $inf . '" target="_blank"><img src="img/' . ESTILO . '/informe.png" alt="informe" title="Informe pdf"></a>';
|
||||
} else {
|
||||
$informe = "";
|
||||
}
|
||||
|
@@ -161,7 +161,7 @@ class Pdf_mysql_table extends Fpdf
|
||||
function Table($query,$prop=array())
|
||||
{
|
||||
//Issue query
|
||||
$res=$this->bdd->query($query) or die('Error: '.$this->bdd->mysql_error()."<BR>Query: $query");
|
||||
$res=$this->bdd->query($query) or die('Error: '.$this->bdd->error."<BR>Query: $query");
|
||||
//Add all columns if none was specified
|
||||
if(count($this->aCols)==0)
|
||||
{
|
||||
|
@@ -2,10 +2,10 @@
|
||||
<Informe>
|
||||
<Titulo Texto="Informe de Artículos" />
|
||||
<Datos>
|
||||
<Consulta>select * from Articulos order by descripcion;</Consulta>
|
||||
<Consulta>select * from Articulos where descripcion like '%{filtro}%' order by {orden};</Consulta>
|
||||
</Datos>
|
||||
<Pagina Orientacion="P" Formato="A4">
|
||||
<Cabecera>Relación alfabética</Cabecera>
|
||||
<Cabecera>Relación Artículos</Cabecera>
|
||||
<Cuerpo>
|
||||
<Col Nombre="id" Ancho="10" Ajuste="D" Titulo="id"/>
|
||||
<Col Nombre="descripcion" Ancho="70" Ajuste="I" Titulo="Descripción"/>
|
||||
|
@@ -4,9 +4,9 @@
|
||||
<Datos>
|
||||
<Consulta>
|
||||
SELECT E.id as id,U.Descripcion as ubicacion,A.Descripcion as articulo,A.Marca as marca,A.Modelo as modelo,E.numserie as numserie,E.cantidad,
|
||||
DATE_FORMAT(E.fechacompra, '%d/%m/%Y') as fechaCompra
|
||||
FROM Elementos E inner join Articulos A on E.id_articulo=A.id inner join
|
||||
Ubicaciones U on E.id_ubicacion=U.id order by ubicacion,articulo,marca,modelo,numserie;
|
||||
DATE_FORMAT(E.fechacompra, '%d/%m/%Y') as fechaCompra
|
||||
FROM Elementos E inner join Articulos A on E.id_articulo=A.id inner join
|
||||
Ubicaciones U on E.id_ubicacion=U.id where A.Descripcion like '%{filtro}%' order by {orden};
|
||||
</Consulta>
|
||||
</Datos>
|
||||
<Pagina Orientacion="L" Formato="A4">
|
||||
|
@@ -2,10 +2,10 @@
|
||||
<Informe>
|
||||
<Titulo Texto="Informe de Ubicaciones" />
|
||||
<Datos>
|
||||
<Consulta>select * from Ubicaciones order by Descripcion;</Consulta>
|
||||
<Consulta>select * from Ubicaciones where descripcion like '%{filtro}%' order by {orden};</Consulta>
|
||||
</Datos>
|
||||
<Pagina Orientacion="P" Formato="A4">
|
||||
<Cabecera>Relación alfabética</Cabecera>
|
||||
<Cabecera>Relación de Ubicaciones</Cabecera>
|
||||
<Cuerpo>
|
||||
<Col Nombre="id" Ancho="10" Ajuste="D" Titulo="id"/>
|
||||
<Col Nombre="Descripcion" Ancho="80" Ajuste="I" Titulo="Descripción"/>
|
||||
|
@@ -2,7 +2,7 @@
|
||||
<Informe>
|
||||
<Titulo Texto="Informe de Usuarios" />
|
||||
<Datos>
|
||||
<Consulta>select * from Usuarios order by Nombre;</Consulta>
|
||||
<Consulta>select * from Usuarios where nombre like '%{filtro}%' order by {orden};</Consulta>
|
||||
</Datos>
|
||||
<Pagina Orientacion="P" Formato="A4">
|
||||
<Cabecera>Relación alfabética</Cabecera>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
</Consulta>
|
||||
<Campos>
|
||||
<Col Campo="id" Nombre="id" Ancho="5" Ajuste="D" Titulo="id" Tipo="int(6)"/>
|
||||
<Col Campo="nombre" Nombre="nombre" Ancho="8" Ajuste="L" Titulo="Nombre" Varios="ordenable" Editable="si"/>
|
||||
<Col Campo="nombre" Nombre="nombre" Ancho="8" Ajuste="L" Titulo="Nombre" Varios="ordenable,buscable/nombre" Editable="si"/>
|
||||
<Col Campo="clave" Nombre="clave" Ancho="16" Ajuste="L" Titulo="Clave" Tipo="Password" Editable="si"/>
|
||||
<Col Campo="idSesion" Nombre="idSesion" Ancho="32" Ajuste="L" Titulo="id Sesión" Editable="si"/>
|
||||
<Col Campo="alta" Nombre="alta" Ancho="1" Ajuste="R" Tipo="Boolean" Titulo="Altas" Editable="si"/>
|
||||
|
Reference in New Issue
Block a user