mirror of
https://github.com/rmontanana/inventario2.git
synced 2025-08-17 16:35:58 +00:00
ref #9 Crear etiquetas de un artículo. Cambiar el nombre del archivo por omisión del informe de etiquetas. Ajuste para cuadrar con etiquetas del centro.
This commit is contained in:
@@ -37,6 +37,7 @@ class EtiquetasPDF {
|
|||||||
private $docu;
|
private $docu;
|
||||||
private $pdf;
|
private $pdf;
|
||||||
private $def;
|
private $def;
|
||||||
|
private $nombreFichero = "tmp/informeEtiquetas.pdf";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* El constructor recibe como argumento el nombre del archivo XML con la definición, encargándose de recuperarla y guardar toda la información localmente
|
* El constructor recibe como argumento el nombre del archivo XML con la definición, encargándose de recuperarla y guardar toda la información localmente
|
||||||
@@ -57,6 +58,7 @@ class EtiquetasPDF {
|
|||||||
$this->pdf = new FPDF();
|
$this->pdf = new FPDF();
|
||||||
$this->pdf->SetMargins(0.2, 0.2, 0.2);
|
$this->pdf->SetMargins(0.2, 0.2, 0.2);
|
||||||
$this->pdf->SetFont('Arial', '', 11);
|
$this->pdf->SetFont('Arial', '', 11);
|
||||||
|
$this->pdf->setAutoPageBreak(false);
|
||||||
//echo $def->Titulo.$def->Cabecera;
|
//echo $def->Titulo.$def->Cabecera;
|
||||||
$this->pdf->setAuthor(AUTOR, true);
|
$this->pdf->setAuthor(AUTOR, true);
|
||||||
$creador = CENTRO . " " . PROGRAMA . VERSION;
|
$creador = CENTRO . " " . PROGRAMA . VERSION;
|
||||||
@@ -67,7 +69,6 @@ class EtiquetasPDF {
|
|||||||
|
|
||||||
public function crea($definicion)
|
public function crea($definicion)
|
||||||
{
|
{
|
||||||
|
|
||||||
//print_r($def);echo $bdd;die();
|
//print_r($def);echo $bdd;die();
|
||||||
// Iniciamos la creación del documento
|
// Iniciamos la creación del documento
|
||||||
$this->def = simplexml_load_file($definicion);
|
$this->def = simplexml_load_file($definicion);
|
||||||
@@ -79,7 +80,7 @@ class EtiquetasPDF {
|
|||||||
$tamLinea = 5;
|
$tamLinea = 5;
|
||||||
$fila = -1;
|
$fila = -1;
|
||||||
$primero = true; $i = 0;
|
$primero = true; $i = 0;
|
||||||
$url = split("/", $_SERVER['SCRIPT_NAME']);
|
$url = explode("/", $_SERVER['SCRIPT_NAME']);
|
||||||
$aplicacion = $url[1];
|
$aplicacion = $url[1];
|
||||||
$enlace = "http://".$_SERVER['SERVER_NAME']."/".$aplicacion."/index.php?elementos&opc=editar&id=";
|
$enlace = "http://".$_SERVER['SERVER_NAME']."/".$aplicacion."/index.php?elementos&opc=editar&id=";
|
||||||
while($tupla = $this->bdd->procesaResultado()) {
|
while($tupla = $this->bdd->procesaResultado()) {
|
||||||
@@ -100,14 +101,14 @@ class EtiquetasPDF {
|
|||||||
}
|
}
|
||||||
$primero = false;
|
$primero = false;
|
||||||
}
|
}
|
||||||
$py = 6 + 39 * $fila;
|
$py = 6 + 41 * $fila;
|
||||||
$enlace2=$enlace.$tupla['idEl'];
|
$enlace2=$enlace.$tupla['idEl'];
|
||||||
$fichero = "tmp/etiq".rand(1000,9999).".png";
|
$fichero = "tmp/etiq".rand(1000,9999).".png";
|
||||||
QRcode::png($enlace2, $fichero);
|
QRcode::png($enlace2, $fichero);
|
||||||
$this->pdf->image($fichero, $etiq2, $py, 30, 30);
|
$this->pdf->image($fichero, $etiq2, $py, 30, 30);
|
||||||
unlink($fichero);
|
unlink($fichero);
|
||||||
$this->pdf->setxy($etiq1, $py);
|
$this->pdf->setxy($etiq1, $py);
|
||||||
$this->pdf->Cell(30, 10, utf8_decode($tupla['descripcion']));
|
$this->pdf->Cell(30, 10, utf8_decode($tupla['articulo']));
|
||||||
$py+=$tamLinea;
|
$py+=$tamLinea;
|
||||||
$this->pdf->setxy($etiq1, $py);
|
$this->pdf->setxy($etiq1, $py);
|
||||||
$this->pdf->Cell(30, 10, utf8_decode($tupla['marca']));
|
$this->pdf->Cell(30, 10, utf8_decode($tupla['marca']));
|
||||||
@@ -120,7 +121,10 @@ class EtiquetasPDF {
|
|||||||
$py+=$tamLinea;
|
$py+=$tamLinea;
|
||||||
$this->pdf->setxy($etiq1, $py);
|
$this->pdf->setxy($etiq1, $py);
|
||||||
$this->pdf->Cell(30, 10, $tupla['fechaCompra']);
|
$this->pdf->Cell(30, 10, $tupla['fechaCompra']);
|
||||||
$py+=$tamLinea;
|
$py+=$tamLinea-1;
|
||||||
|
$this->pdf->setxy($etiq2, $py);
|
||||||
|
$this->pdf->Cell(30, 10, utf8_decode($tupla['ubicacion']));
|
||||||
|
$py+=$tamLinea-1;
|
||||||
$this->pdf->setxy($etiq2, $py);
|
$this->pdf->setxy($etiq2, $py);
|
||||||
$cadena = "idElemento=" . $tupla['idEl'] . " / idArticulo=" . $tupla['idArt'] . " / idUbicacion=" . $tupla['idUbic'];
|
$cadena = "idElemento=" . $tupla['idEl'] . " / idArticulo=" . $tupla['idArt'] . " / idUbicacion=" . $tupla['idUbic'];
|
||||||
$this->pdf->Cell(30, 10, $cadena);
|
$this->pdf->Cell(30, 10, $cadena);
|
||||||
@@ -144,7 +148,7 @@ class EtiquetasPDF {
|
|||||||
{
|
{
|
||||||
$cabecera = "Content-type: application/pdf";
|
$cabecera = "Content-type: application/pdf";
|
||||||
$cabecera = $cabecera . "Content-length: " . strlen($this->docu);
|
$cabecera = $cabecera . "Content-length: " . strlen($this->docu);
|
||||||
$cabecera = $cabecera . "Content-Disposition: inline; filename=tmp/Informe.pdf";
|
$cabecera = $cabecera . "Content-Disposition: inline; filename=" . $this->nombreFichero;
|
||||||
return $cabecera;
|
return $cabecera;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,6 +157,7 @@ class EtiquetasPDF {
|
|||||||
$fichero = fopen($nombre, "w");
|
$fichero = fopen($nombre, "w");
|
||||||
fwrite($fichero, $this->getCabecera());
|
fwrite($fichero, $this->getCabecera());
|
||||||
fwrite($fichero, $this->getContenido(), strlen($this->getContenido()));
|
fwrite($fichero, $this->getContenido(), strlen($this->getContenido()));
|
||||||
|
$this->nombreFichero = $nombre;
|
||||||
fclose($fichero);
|
fclose($fichero);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,7 +166,7 @@ class EtiquetasPDF {
|
|||||||
header("Content-type: application/pdf");
|
header("Content-type: application/pdf");
|
||||||
$longitud = strlen($this->docu);
|
$longitud = strlen($this->docu);
|
||||||
header("Content-length: $longitud");
|
header("Content-length: $longitud");
|
||||||
header("Content-Disposition: inline; filename=tmp/Informe.pdf");
|
header("Content-Disposition: inline; filename=" . $this->nombreFichero);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function imprimeInforme()
|
public function imprimeInforme()
|
||||||
@@ -169,7 +174,6 @@ class EtiquetasPDF {
|
|||||||
$this->enviaCabecera();
|
$this->enviaCabecera();
|
||||||
echo $this->docu;
|
echo $this->docu;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
26
xml/inventarioArticuloEtiquetas.xml
Normal file
26
xml/inventarioArticuloEtiquetas.xml
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<Informe>
|
||||||
|
<Titulo Texto="{Descripcion}" id="{id}"/>
|
||||||
|
<Datos>
|
||||||
|
<Consulta>
|
||||||
|
select A.id as id, A.Descripcion as articulo, A.Marca as marca, A.Modelo as modelo, E.id as idEl, U.id as idUbic,U.Descripcion as ubicacion,E.numserie as numserie,
|
||||||
|
E.fechaCompra as fechaCompra,E.Cantidad as cantidad, E.Cantidad as cantReal, 'N' as Baja
|
||||||
|
from Elementos E, Articulos A, Ubicaciones U where A.id=E.id_Articulo and U.id=E.id_Ubicacion
|
||||||
|
and A.id='{id}' order by U.Descripcion,numserie;
|
||||||
|
</Consulta>
|
||||||
|
</Datos>
|
||||||
|
<Pagina Orientacion="P" Formato="A4">
|
||||||
|
<Cabecera>Articulo</Cabecera>
|
||||||
|
<Cuerpo>
|
||||||
|
<Col Nombre="Baja" Titulo="Baja"/>
|
||||||
|
<Col Nombre="idEl" Titulo="idElem"/>
|
||||||
|
<Col Nombre="idUbic" Titulo="idUbic"/>
|
||||||
|
<Col Nombre="articulo" Titulo="Articulo"/>
|
||||||
|
<Col Nombre="ubicacion" Titulo="Ubicación"/>
|
||||||
|
<Col Nombre="numserie" Titulo="N Serie"/>
|
||||||
|
<Col Nombre="fechaCompra" Titulo="Fecha C." />
|
||||||
|
<Col Nombre="cantidad" Titulo="Cantidad"/>
|
||||||
|
<Col Nombre="cantReal" Titulo="Cant. Real"/>
|
||||||
|
</Cuerpo>
|
||||||
|
</Pagina>
|
||||||
|
</Informe>
|
@@ -3,8 +3,8 @@
|
|||||||
<Titulo Texto="{Descripcion}" id="{id}"/>
|
<Titulo Texto="{Descripcion}" id="{id}"/>
|
||||||
<Datos>
|
<Datos>
|
||||||
<Consulta>
|
<Consulta>
|
||||||
select A.id as idArt,E.id as idEl,U.id as idUbic,A.Marca as marca,A.Modelo as modelo,E.numSerie as numserie,
|
select A.id as idArt,E.id as idEl,U.id as idUbic,U.Descripcion as ubicacion,A.Marca as marca,A.Modelo as modelo,E.numSerie as numserie,
|
||||||
E.fechaCompra as fechaCompra,A.Descripcion as descripcion,E.Cantidad as cantidad, E.Cantidad as cantReal, 'N' as Baja
|
E.fechaCompra as fechaCompra,A.Descripcion as articulo,E.Cantidad as cantidad, E.Cantidad as cantReal, 'N' as Baja
|
||||||
from Elementos E, Articulos A, Ubicaciones U where A.id=E.id_Articulo and U.id=E.id_Ubicacion
|
from Elementos E, Articulos A, Ubicaciones U where A.id=E.id_Articulo and U.id=E.id_Ubicacion
|
||||||
and U.id='{id}' order by A.descripcion;
|
and U.id='{id}' order by A.descripcion;
|
||||||
</Consulta>
|
</Consulta>
|
||||||
@@ -16,7 +16,8 @@
|
|||||||
<Col Nombre="idEl" Titulo="idElem"/>
|
<Col Nombre="idEl" Titulo="idElem"/>
|
||||||
<Col Nombre="idArt" Titulo="idArt"/>
|
<Col Nombre="idArt" Titulo="idArt"/>
|
||||||
<Col Nombre="idUbic" Titulo="idUbic"/>
|
<Col Nombre="idUbic" Titulo="idUbic"/>
|
||||||
<Col Nombre="descripcion" Titulo="Artículo"/>
|
<Col Nombre="ubicacion" Titulo="Ubicacion"/>
|
||||||
|
<Col Nombre="articulo" Titulo="Artículo"/>
|
||||||
<Col Nombre="marca" Titulo="Marca"/>
|
<Col Nombre="marca" Titulo="Marca"/>
|
||||||
<Col Nombre="modelo" Titulo="Modelo"/>
|
<Col Nombre="modelo" Titulo="Modelo"/>
|
||||||
<Col Nombre="numserie" Titulo="N Serie"/>
|
<Col Nombre="numserie" Titulo="N Serie"/>
|
||||||
|
Reference in New Issue
Block a user