diff --git a/AportaContenido.php b/AportaContenido.php index 652d12a..16b4633 100644 --- a/AportaContenido.php +++ b/AportaContenido.php @@ -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 diff --git a/Inventario.php b/Inventario.php index 1469c58..2e94ec3 100644 --- a/Inventario.php +++ b/Inventario.php @@ -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; + } } diff --git a/Mantenimiento.php b/Mantenimiento.php index e011ec7..6fa20da 100644 --- a/Mantenimiento.php +++ b/Mantenimiento.php @@ -255,7 +255,9 @@ class Mantenimiento { $za = 'desc'; $this->restoreURL(); if ($this->perfil['Informe']) { - $informe = 'informe'; + $this->datosURL['opc'] = "informe"; + $inf = $this->montaURL(); + $informe = 'informe'; } else { $informe = ""; } diff --git a/Pdf_mysql_table.php b/Pdf_mysql_table.php index 402a9e9..370c945 100644 --- a/Pdf_mysql_table.php +++ b/Pdf_mysql_table.php @@ -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()."
Query: $query"); + $res=$this->bdd->query($query) or die('Error: '.$this->bdd->error."
Query: $query"); //Add all columns if none was specified if(count($this->aCols)==0) { diff --git a/xml/informeArticulos.xml b/xml/informeArticulos.xml index d6b73ab..47cd995 100644 --- a/xml/informeArticulos.xml +++ b/xml/informeArticulos.xml @@ -2,10 +2,10 @@ - select * from Articulos order by descripcion; + select * from Articulos where descripcion like '%{filtro}%' order by {orden}; - Relación alfabética + Relación Artículos diff --git a/xml/informeElementos.xml b/xml/informeElementos.xml index 42bd0ab..7ea4858 100644 --- a/xml/informeElementos.xml +++ b/xml/informeElementos.xml @@ -4,9 +4,9 @@ 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}; diff --git a/xml/informeUbicaciones.xml b/xml/informeUbicaciones.xml index 593d7e1..c56b178 100644 --- a/xml/informeUbicaciones.xml +++ b/xml/informeUbicaciones.xml @@ -2,10 +2,10 @@ - select * from Ubicaciones order by Descripcion; + select * from Ubicaciones where descripcion like '%{filtro}%' order by {orden}; - Relación alfabética + Relación de Ubicaciones diff --git a/xml/informeUsuarios.xml b/xml/informeUsuarios.xml index 3bbadbb..0752803 100644 --- a/xml/informeUsuarios.xml +++ b/xml/informeUsuarios.xml @@ -2,7 +2,7 @@ - select * from Usuarios order by Nombre; + select * from Usuarios where nombre like '%{filtro}%' order by {orden}; Relación alfabética diff --git a/xml/mantenimientoUsuarios.xml b/xml/mantenimientoUsuarios.xml index 6d259a2..e8c2a55 100644 --- a/xml/mantenimientoUsuarios.xml +++ b/xml/mantenimientoUsuarios.xml @@ -7,7 +7,7 @@ - +