resolve#9 Creadas las etiquetas de artículos con código qr y paginación.

Sacada la versión y el autor del fichero de configuración.
This commit is contained in:
2014-03-14 01:14:06 +01:00
parent c33a6edaa1
commit e1d50a74dc
12 changed files with 3617 additions and 450 deletions

175
EtiquetasPDF.php Normal file
View File

@@ -0,0 +1,175 @@
<?php
/**
* genera un documento PDF a partir de una descripción dada en un archivo XML
* @author Ricardo Montañana <rmontanana@gmail.com>
* @version 1.0
* @package Inventario
* @copyright Copyright (c) 2008, Ricardo Montañana
* @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/>.
*
*/
require_once 'phpqrcode.php';
class EtiquetasPDF {
/**
*
* @var basedatos Controlador de la base de datos
*/
private $bdd;
private $docu;
private $pdf;
private $def;
/**
* 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
* @param basedatos $bdd manejador de la base de datos
* @param string $definicion fichero con la definición del informe en XML
* @param boolean $registrado usuario registrado si/no
* @return ficheroPDF
* todo: cambiar este comentario
*/
public function __construct($bdd, $definicion, $registrado)
{
if (!$registrado) {
return 'Debe registrarse para acceder a este apartado';
}
// Recuperamos la definición del informe
$this->def = simplexml_load_file($definicion);
$this->bdd = $bdd;
$this->pdf = new FPDF();
$this->pdf->SetMargins(0.2, 0.2, 0.2);
$this->pdf->SetFont('Arial', '', 11);
//echo $def->Titulo.$def->Cabecera;
$this->pdf->setAuthor(AUTOR, true);
$creador = CENTRO . " " . PROGRAMA . VERSION;
$this->pdf->setCreator(html_entity_decode($creador), true);
$this->pdf->setSubject($this->def->Titulo, true);
//$this->pdf->setAutoPageBreak(true, 10);
}
public function crea($definicion)
{
//print_r($def);echo $bdd;die();
// Iniciamos la creación del documento
$this->def = simplexml_load_file($definicion);
$this->bdd->ejecuta(trim($this->def->Datos->Consulta));
//Ejecuta la consulta y prepara las variables de la base de datos.
//$this->bdd->ejecuta(trim($this->def->Datos->Consulta));
//Inicializa las variables para el control de las etiquetas.
$this->pdf->AddPage();
$tamLinea = 5;
$fila = -1;
$primero = true; $i = 0;
$url = split("/", $_SERVER['SCRIPT_NAME']);
$aplicacion = $url[1];
$enlace = "http://".$_SERVER['SERVER_NAME']."/".$aplicacion."/index.php?elementos&opc=editar&id=";
while($tupla = $this->bdd->procesaResultado()) {
if ($i % 2) {
//Columna 2
$etiq1 = 136;
$etiq2 = 105;
} else {
//Columna 1
$etiq1 = 30;
$etiq2 = 1;
$fila++;
}
if ($i % 14 == 0) {
if (!$primero) {
$this->pdf->AddPage();
$fila = 0;
}
$primero = false;
}
$py = 6 + 39 * $fila;
$enlace2=$enlace.$tupla['idEl'];
$fichero = "tmp/etiq".rand(1000,9999).".png";
QRcode::png($enlace2, $fichero);
$this->pdf->image($fichero, $etiq2, $py, 30, 30);
unlink($fichero);
$this->pdf->setxy($etiq1, $py);
$this->pdf->Cell(30, 10, utf8_decode($tupla['descripcion']));
$py+=$tamLinea;
$this->pdf->setxy($etiq1, $py);
$this->pdf->Cell(30, 10, utf8_decode($tupla['marca']));
$py+=$tamLinea;
$this->pdf->setxy($etiq1, $py);
$this->pdf->Cell(30, 10, utf8_decode($tupla['modelo']));
$py+=$tamLinea;
$this->pdf->setxy($etiq1, $py);
$this->pdf->Cell(30, 10, utf8_decode($tupla['numserie']));
$py+=$tamLinea;
$this->pdf->setxy($etiq1, $py);
$this->pdf->Cell(30, 10, $tupla['fechaCompra']);
$py+=$tamLinea;
$this->pdf->setxy($etiq2, $py);
$cadena = "idElemento=" . $tupla['idEl'] . " / idArticulo=" . $tupla['idArt'] . " / idUbicacion=" . $tupla['idUbic'];
$this->pdf->Cell(30, 10, $cadena);
$i++;
}
//$this->pdf->MultiCell(0,30,var_export($filas,true));
}
public function cierraPDF()
{
$this->pdf->Close();
$this->docu = $this->pdf->Output('', 'S');
}
public function getContenido()
{
return $this->docu;
}
public function getCabecera()
{
$cabecera = "Content-type: application/pdf";
$cabecera = $cabecera . "Content-length: " . strlen($this->docu);
$cabecera = $cabecera . "Content-Disposition: inline; filename=tmp/Informe.pdf";
return $cabecera;
}
public function guardaArchivo($nombre = "tmp/Informe.pdf")
{
$fichero = fopen($nombre, "w");
fwrite($fichero, $this->getCabecera());
fwrite($fichero, $this->getContenido(), strlen($this->getContenido()));
fclose($fichero);
}
public function enviaCabecera()
{
header("Content-type: application/pdf");
$longitud = strlen($this->docu);
header("Content-length: $longitud");
header("Content-Disposition: inline; filename=tmp/Informe.pdf");
}
public function imprimeInforme()
{
$this->enviaCabecera();
echo $this->docu;
}
}
?>

View File

@@ -40,12 +40,19 @@ class InformeInventario {
private function listarUbicacion() {
$salidaInforme = isset($_POST['salida']) ? $_POST['salida'] : 'pantalla';
if ($salidaInforme == "pantalla") {
$fichero = "xml/inventarioUbicacion.xml";
$salida = "tmp/inventarioUbicacion.xml";
} else {
$fichero = "xml/inventarioUbicacionCSV.xml";
$salida = "tmp/inventarioUbicacionCSV.xml";
switch ($salidaInforme) {
case "pantalla":
$fichero = "xml/inventarioUbicacion.xml";
$salida = "tmp/inventarioUbicacion.xml";
break;
case "csv":
$fichero = "xml/inventarioUbicacionCSV.xml";
$salida = "tmp/inventarioUbicacionCSV.xml";
break;
case "etiquetas":
$fichero = "xml/inventarioUbicacionEtiquetas.xml";
$salida = "tmp/inventarioUbicacionEtiquetas.xml";
break;
}
$plantilla = file_get_contents($fichero) or die('Fallo en la apertura de la plantilla ' . $fichero);
$id = $_POST['id'] == NULL ? $_GET['id'] : $_POST['id'];
@@ -58,30 +65,47 @@ class InformeInventario {
$plantilla = str_replace("{id}", $id, $plantilla);
$plantilla = str_replace("{Descripcion}", $fila['Descripcion'], $plantilla);
file_put_contents($salida, $plantilla) or die('Fallo en la escritura de la plantilla ' . $salida);
if ($salidaInforme == "pantalla") {
$informe = new InformePDF($this->bdd, $salida, true);
$informe->crea($salida);
$informe->cierraPDF();
$informe->guardaArchivo("tmp/Informe.pdf");
echo '<script type="text/javascript"> window.open( "tmp/Informe.pdf" ) </script>';
} else {
//Genera una hoja de cálculo en formato csv
$nombre = "tmp/Ubicacion" . strftime("%Y%m%d") . rand(100, 999) . ".csv";
$hoja = new Csv($this->bdd);
$hoja->crea($nombre);
$hoja->ejecutaConsulta($salida);
echo '<script type="text/javascript"> window.open( "' . $nombre . '" ) </script>';
switch ($salidaInforme) {
case "pantalla":
$informe = new InformePDF($this->bdd, $salida, true);
$informe->crea($salida);
$informe->cierraPDF();
$informe->guardaArchivo("tmp/Informe.pdf");
echo '<script type="text/javascript"> window.open( "tmp/Informe.pdf" ) </script>';
break;
case "csv":
//Genera una hoja de cálculo en formato csv
$nombre = "tmp/Ubicacion" . strftime("%Y%m%d") . rand(100, 999) . ".csv";
$hoja = new Csv($this->bdd);
$hoja->crea($nombre);
$hoja->ejecutaConsulta($salida);
echo '<script type="text/javascript"> window.open( "' . $nombre . '" ) </script>';
break;
case "etiquetas":
$etiquetas = new EtiquetasPDF($this->bdd, $salida, true);
$etiquetas->crea($salida);
$etiquetas->cierraPDF();
$etiquetas->guardaArchivo("tmp/EtiquetasUbicacion.pdf");
echo '<script type="text/javascript"> window.open( "tmp/EtiquetasUbicacion.pdf" ) </script>';
break;
}
}
private function listarArticulo() {
$salidaInforme = isset($_POST['salida']) ? $_POST['salida'] : 'pantalla';
if ($salidaInforme == "pantalla") {
$fichero = "xml/inventarioArticulo.xml";
$salida = "tmp/inventarioArticulo.xml";
} else {
$fichero = "xml/inventarioArticuloCSV.xml";
$salida = "tmp/inventarioArticuloCSV.xml";
switch ($salidaInforme) {
case "pantalla":
$fichero = "xml/inventarioArticulo.xml";
$salida = "tmp/inventarioArticulo.xml";
break;
case "csv":
$fichero = "xml/inventarioArticuloCSV.xml";
$salida = "tmp/inventarioArticuloCSV.xml";
break;
case "etiquetas":
$fichero = "xml/inventarioArticuloEtiquetas.xml";
$salida = "tmp/inventarioArticuloEtiquetas.xml";
break;
}
$plantilla = file_get_contents($fichero) or die('Fallo en la apertura de la plantilla ' . $fichero);
$id = $_POST['id'] == NULL ? $_GET['id'] : $_POST['id'];
@@ -96,21 +120,30 @@ class InformeInventario {
$plantilla = str_replace("{Marca}", $fila['marca'], $plantilla);
$plantilla = str_replace("{Modelo}", $fila['modelo'], $plantilla);
file_put_contents($salida, $plantilla) or die('Fallo en la escritura de la plantilla ' . $salida);
if ($salidaInforme == "pantalla") {
$informe = new InformePDF($this->bdd, $salida, true);
$informe->crea($salida);
$informe->cierraPDF();
$informe->guardaArchivo("tmp/Informe.pdf");
echo '<script type="text/javascript"> window.open( "tmp/Informe.pdf" ) </script>';
} else {
//Genera una hoja de cálculo en formato csv
$nombre = "tmp/Articulo" . strftime("%Y%m%d") . rand(100, 999) . ".csv";
$hoja = new Csv($this->bdd);
$hoja->crea($nombre);
$hoja->ejecutaConsulta($salida);
echo '<script type="text/javascript"> window.open( "' . $nombre . '" ) </script>';
switch ($salidaInforme) {
case "pantalla":
$informe = new InformePDF($this->bdd, $salida, true);
$informe->crea($salida);
$informe->cierraPDF();
$informe->guardaArchivo("tmp/Informe.pdf");
echo '<script type="text/javascript"> window.open( "tmp/Informe.pdf" ) </script>';
break;
case "csv":
//Genera una hoja de cálculo en formato csv
$nombre = "tmp/Articulo" . strftime("%Y%m%d") . rand(100, 999) . ".csv";
$hoja = new Csv($this->bdd);
$hoja->crea($nombre);
$hoja->ejecutaConsulta($salida);
echo '<script type="text/javascript"> window.open( "' . $nombre . '" ) </script>';
break;
case "etiquetas":
$etiquetas = new EtiquetasPDF($this->bdd, $salida, true);
$etiquetas->crea($salida);
$etiquetas->cierraPDF();
$etiquetas->guardaArchivo("tmp/EtiquetasArticulo.pdf");
echo '<script type="text/javascript"> window.open( "tmp/EtiquetasArticulo.pdf" ) </script>';
break;
}
//header('Location: index.php');
}
private function listaUbicaciones() {
@@ -149,6 +182,7 @@ class InformeInventario {
$salida.="<br><br><label for='salida'>Salida del informe por:</label>";
$salida.='<div class="radio"><label><input type="radio" name="salida" value="pantalla" checked>Pantalla</label></div>';
$salida.='<div class="radio"><label><input type="radio" name="salida" value="csv">Archivo CSV</label></div>';
$salida.='<div class="radio"><label><input type="radio" name="salida" value="etiquetas">Etiquetas</label></div>';
$salida.="<br><br></fieldset><p>";
$salida.='<p align="center"><button type=submit class="btn btn-primary">Aceptar</button></p><br></div>' . "\n";
return $salida;
@@ -192,7 +226,6 @@ class InformeInventario {
$informe->cierraPDF();
$informe->imprimeInforme();
}
}
?>

View File

@@ -1,147 +0,0 @@
<?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/>.
*
*/
class InformeInventario {
private $bdd;
public function __construct($baseDatos)
{
$this->bdd=$baseDatos;
}
public function ejecuta()
{
$opc=$_GET['opc'];
switch ($opc) {
case 'Ubicacion':return $this->formularioUbicacion();
case 'listarUbicacion':return $this->listarUbicacion();
case 'listarArticulo':return $this->listarArticulo();
case 'Articulo':return $this->formularioArticulo();
case 'Total':return $this->inventarioTotal();
}
}
private function listarUbicacion()
{
$fichero="xml/inventarioUbicacion.xml";
$salida="tmp/inventarioUbicacion.xml";
$plantilla=file_get_contents($fichero)
or die('Fallo en la apertura de la plantilla '.$fichero);
$comando="select * from Ubicaciones where id='".$_POST['id']."';";
$resultado=$this->bdd->ejecuta($comando);
if (!$resultado) {
return $this->bdd->mensajeError($comando);
}
$fila=$this->bdd->procesaResultado();
$plantilla=str_replace("{id}",$_POST['id'],$plantilla);
$plantilla=str_replace("{Descripcion}",utf8_encode($fila['Descripcion']),$plantilla);
file_put_contents($salida,$plantilla)
or die('Fallo en la escritura de la plantilla '.$salida);
$informe=new InformePDF($this->bdd,$salida,true);
}
private function listarArticulo()
{
$fichero="xml/inventarioArticulo.xml";
$salida="tmp/inventarioArticulo.xml";
$plantilla=file_get_contents($fichero)
or die('Fallo en la apertura de la plantilla '.$fichero);
$comando="select * from Articulos where id='".$_POST['id']."';";
$resultado=$this->bdd->ejecuta($comando);
if (!$resultado) {
return $this->bdd->mensajeError($comando);
}
$fila=$this->bdd->procesaResultado();
$plantilla=str_replace("{id}",$_POST['id'],$plantilla);
$plantilla=str_replace("{Descripcion}",utf8_encode($fila['descripcion']),$plantilla);
$plantilla=str_replace("{Marca}",utf8_encode($fila['marca']),$plantilla);
$plantilla=str_replace("{Modelo}",utf8_encode($fila['modelo']),$plantilla);
file_put_contents($salida,$plantilla)
or die('Fallo en la escritura de la plantilla '.$salida);
$informe=new InformePDF($this->bdd,$salida,true);
}
private function listaUbicaciones()
{
$salida="<select name=\"id\">\n";
$comando="select * from Ubicaciones order by Descripcion";
$resultado=$this->bdd->ejecuta($comando);
if (!$resultado) {
return $this->bdd->mensajeError($comando);
}
while($fila=$this->bdd->procesaResultado()) {
$salida.="<option value=".$fila['id'].">".$fila['Descripcion']."</option><br>\n";
}
$salida.="</select>\n";
return $salida;
}
private function listaArticulos()
{
$salida="<select name=\"id\">\n";
$comando="select * from Articulos order by descripcion, marca, modelo";
$resultado=$this->bdd->ejecuta($comando);
if (!$resultado) {
return $this->bdd->mensajeError($comando);
}
while($fila=$this->bdd->procesaResultado()) {
$salida.="<option value=".$fila['id'].">".$fila['descripcion']."-".$fila['marca']."-".$fila['modelo']."</option><br>\n";
}
$salida.="</select>\n";
return $salida;
}
private function formulario($accion,$etiqueta,$lista)
{
$salida='<form name="mantenimiento.form" method="post" action="'.$accion.'">'."\n";
$salida.="<fieldset style=\"width: 96%;\"><p><legend style=\"color: red;\"><b>Elige $etiqueta</b></legend>\n";
$salida.="<br><br><label>$etiqueta</label>";
$salida.=$lista;
$salida.="<br><br></fieldset><p>";
$salida.='<p align="center"><button type=submit>Aceptar</button></p><br>'."\n";
return $salida;
}
private function formularioUbicacion()
{
//Genera un formulario con las ubicaciones disponibles.
$accion="index.php?informeInventario&opc=listarUbicacion";
return $this->formulario($accion,'Ubicaci&oacute;n',$this->listaUbicaciones());
}
private function formularioArticulo()
{
$accion="index.php?informeInventario&opc=listarArticulo";
return $this->formulario($accion,'Art&iacute;culo',$this->listaArticulos());
}
private function inventarioTotal()
{
$fichero="xml/inventarioUbicacion.xml";
$salida="tmp/inventarioUbicacion.xml";
$comando="select * from Ubicaciones where id='".$_POST['id']."';";
$resultado=$this->bdd->ejecuta($comando);
if (!$resultado) {
return $this->bdd->mensajeError($comando);
}
$salidaTotal='';
while ($fila=$this->bdd->procesaResultado()) {
$plantilla=file_get_contents($fichero)
or die('Fallo en la apertura de la plantilla '.$fichero);
$plantilla=str_replace("{id}",$_POST['id'],$plantilla);
$plantilla=str_replace("{Descripcion}",utf8_encode($fila['Descripcion']),$plantilla);
file_put_contents($salida,$plantilla)
or die('Fallo en la escritura de la plantilla '.$salida);
$salidaTotal+=$salida;
}
$informe=new InformePDF($this->bdd,$salidaTotal,true);
}
}
?>

View File

@@ -1,85 +0,0 @@
<?php
/**
* genera un documento PDF a partir de una descripción dada en un archivo XML
* @author Ricardo Montañana <rmontanana@gmail.com>
* @version 1.0
* @package Inventario
* @copyright Copyright (c) 2008, Ricardo Montañana
* @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/>.
*
*/
class InformePDF
{
/**
*
* @var basedatos Controlador de la base de datos
*/
private $bdd;
/**
* 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
* @param basedatos $bdd manejador de la base de datos
* @param string $definicion fichero con la definición del informe en XML
* @param boolean $registrado usuario registrado si/no
* @return ficheroPDF
*/
public function __construct($bdd,$definicion,$registrado)
{
if (!$registrado) {
return 'Debe registrarse para acceder a este apartado';
}
$this->bdd=$bdd;
// Recuperamos la definición del informe
$def=simplexml_load_file($definicion);
//print_r($def);echo $bdd;die();
// Iniciamos la creación del documento
$pdf=new Pdf_mysql_table($this->bdd->obtieneManejador(),(string)$def->Pagina['Orientacion'],
(string)$def->Pagina['Formato'],
(string)$def->Titulo['Texto'],(string)$def->Pagina->Cabecera);
echo $def->Titulo.$def->Cabecera;
$pdf->Open();
$pdf->setAuthor(utf8_decode(AUTOR));
$pdf->setCreator(html_entity_decode(APLICACION));
$pdf->setSubject(utf8_decode($def->Titulo));
$pdf->setAutoPageBreak(true,10);
$this->bdd->ejecuta(trim($def->Datos->Consulta));
$filas=$this->bdd->procesaResultado();
$pdf->AddPage();
// Recuperamos los datos del cuerpo
foreach($def->Pagina->Cuerpo->Col as $columna) {
$pdf->AddCol((string)$columna['Nombre'],(string)$columna['Ancho'],
(string)$columna['Titulo'],(string)$columna['Ajuste'],
(string)$columna['Total']);
}
$prop=array('HeaderColor'=>array(255,150,100),
'color1'=>array(210,245,255),
'color2'=>array(255,255,210),
'padding'=>2);
$pdf->Table($def->Datos->Consulta,$prop);
$pdf->Close();
// Obtenemos el documento y su longitud
$documento=$pdf->Output('','S');
$longitud=strlen($documento);
// y lo enviamos como resultado
header("Content-type: application/pdf");
header("Content-length: $longitud");
header("Content-Disposition: inline; filename=Informe.pdf");
echo $documento;
}
}
?>

View File

@@ -21,13 +21,13 @@
* along with Inventario. If not, see <http://www.gnu.org/licenses/>.
*
*/
define('AUTOR', 'Ricardo Montañana Gómez');
require_once 'version.inc';
define('SERVIDOR', 'localhost'); //Ubicación del servidor MySQL
define('BASEDATOS', 'Inventario2'); //Nombre de la base de datos.
define('BASEDATOSTEST', 'Inventario_test'); //Base de datos para los tests.
define('USUARIO', 'test'); //Usuario con permisos de lectura/escritura en la base de datos
define('CLAVE', 'tset'); //contraseña del usuario.
define('VERSION', '1.02');
define('PROGRAMA', 'Gesti&oacute;n de Inventario.');
define('CENTRO', 'I.E.S.O. Pascual Serrano');
define('NUMFILAS', '17'); // Número de registros a mostrar en las pantallas de consulta iniciales

27
inc/version.inc Normal file
View File

@@ -0,0 +1,27 @@
<?php
/**
* Fichero de configuración donde se introducirán los valores
* de autor y de la versión
* @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('AUTOR', 'Ricardo Montañana Gómez');
define('VERSION', '1.03b');
?>

View File

@@ -1,3 +0,0 @@
<?
phpinfo();
?>

3312
phpqrcode.php Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,55 +0,0 @@
<?php
/**
* Test de la clase Sql
*/
include 'Sql.php';
$bd=new Sql("localhost","test","tset","Inventario2");
if ($bd->error()) {
die("Error al conectar\n");
}
if (!$bd->ejecuta("select * from Articulos limit 0,10")) {
die("No pudo ejecutar consulta. ".$bd->mensajeError()."\n");
}
echo "Hay ".$bd->numeroTuplas()." registros.<br>\n";
while ($datos=$bd->procesaResultado()) {
foreach($datos as $clave => $valor) {
echo "[$clave]=[$valor] ";
}
echo "<br>\n";
}
$datos=$bd->estructura("Elementos");
for ($i=0;$i<count($datos);$i++) {
$campos[$datos[$i]["Field"]]=$datos[$i];
}
//print_r($datos);
echo "Hay ".count($campos)." tuplas.";
foreach($campos as $clave => $valor) {
$trozos=explode(",",$valor["Comment"]);
//echo "Trozos=";print_r($trozos);//print_r($campos);
foreach($trozos as $trozo) {
if (strstr($trozo,"foreign")) {
$temp=substr($trozo,8,-1);
list($tabla,$atributo)=explode(";",$temp);
$salida[$clave]=$tabla.",".$atributo;
echo "[$clave],[$tabla],[$atributo]<br>\n";
$existen=true;
}
}
}
/*for ($i=0;$i<count($datos);$i++) {
echo $datos[$i]["Field"]."<br>";
/*foreach($datos[$i] as $clave => $valor) {
echo "[$clave]=[$valor] ";
}
echo "<br>\n";
}*/
if ($bd->error()) {
echo $bd->mensajeError();
}
?>

View File

@@ -1,118 +0,0 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
// Timer Bar - Version 1.0
// Author: Brian Gosselin of http://scriptasylum.com
// Script featured on http://www.dynamicdrive.com
var loadedcolor='darkgray' ; // PROGRESS BAR COLOR
var unloadedcolor='lightgrey'; // COLOR OF UNLOADED AREA
var bordercolor='navy'; // COLOR OF THE BORDER
var barheight=15; // HEIGHT OF PROGRESS BAR IN PIXELS
var barwidth=300; // WIDTH OF THE BAR IN PIXELS
var waitTime=5; // NUMBER OF SECONDS FOR PROGRESSBAR
// THE FUNCTION BELOW CONTAINS THE ACTION(S) TAKEN ONCE BAR REACHES 100%.
// IF NO ACTION IS DESIRED, TAKE EVERYTHING OUT FROM BETWEEN THE CURLY BRACES ({})
// BUT LEAVE THE FUNCTION NAME AND CURLY BRACES IN PLACE.
// PRESENTLY, IT IS SET TO DO NOTHING, BUT CAN BE CHANGED EASILY.
// TO CAUSE A REDIRECT TO ANOTHER PAGE, INSERT THE FOLLOWING LINE:
// window.location="http://redirect_page.html";
// JUST CHANGE THE ACTUAL URL OF COURSE :)
// @todo prueba
/**
*@todo prueba
*TODO prueba
*@todo: prueba
*/
var action=function()
{
alert("Welcome to Dynamic Drive!");
//window.location="http://www.dynamicdrive.com
}
//*****************************************************//
//********** DO NOT EDIT BEYOND THIS POINT **********//
//*****************************************************//
var ns4=(document.layers)?true:false;
var ie4=(document.all)?true:false;
var blocksize=(barwidth-2)/waitTime/10;
var loaded=0;
var PBouter;
var PBdone;
var PBbckgnd;
var Pid=0;
var txt='';
if(ns4){
txt+='<table border=0 cellpadding=0 cellspacing=0><tr><td>';
txt+='<ilayer name="PBouter" visibility="hide" height="'+barheight+'" width="'+barwidth+'" onmouseup="hidebar()">';
txt+='<layer width="'+barwidth+'" height="'+barheight+'" bgcolor="'+bordercolor+'" top="0" left="0"></layer>';
txt+='<layer width="'+(barwidth-2)+'" height="'+(barheight-2)+'" bgcolor="'+unloadedcolor+'" top="1" left="1"></layer>';
txt+='<layer name="PBdone" width="'+(barwidth-2)+'" height="'+(barheight-2)+'" bgcolor="'+loadedcolor+'" top="1" left="1"></layer>';
txt+='</ilayer>';
txt+='</td></tr></table>';
}else{
txt+='<div id="PBouter" onmouseup="hidebar()" style="position:relative; visibility:hidden; background-color:'+bordercolor+'; width:'+barwidth+'px; height:'+barheight+'px;">';
txt+='<div style="position:absolute; top:1px; left:1px; width:'+(barwidth-2)+'px; height:'+(barheight-2)+'px; background-color:'+unloadedcolor+'; font-size:1px;"></div>';
txt+='<div id="PBdone" style="position:absolute; top:1px; left:1px; width:0px; height:'+(barheight-2)+'px; background-color:'+loadedcolor+'; font-size:1px;"></div>';
txt+='</div>';
}
document.write(txt);
function incrCount(){
window.status="Loading...";
loaded++;
if(loaded<0)loaded=0;
if(loaded>=waitTime*10){
clearInterval(Pid);
loaded=waitTime*10;
setTimeout('hidebar()',100);
}
resizeEl(PBdone, 0, blocksize*loaded, barheight-2, 0);
}
function hidebar(){
clearInterval(Pid);
window.status='';
//if(ns4)PBouter.visibility="hide";
//else PBouter.style.visibility="hidden";
action();
}
//THIS FUNCTION BY MIKE HALL OF BRAINJAR.COM
function findlayer(name,doc){
var i,layer;
for(i=0;i<doc.layers.length;i++){
layer=doc.layers[i];
if(layer.name==name)return layer;
if(layer.document.layers.length>0)
if((layer=findlayer(name,layer.document))!=null)
return layer;
}
return null;
}
function progressBarInit(){
PBouter=(ns4)?findlayer('PBouter',document):(ie4)?document.all['PBouter']:document.getElementById('PBouter');
PBdone=(ns4)?PBouter.document.layers['PBdone']:(ie4)?document.all['PBdone']:document.getElementById('PBdone');
resizeEl(PBdone,0,0,barheight-2,0);
if(ns4)PBouter.visibility="show";
else PBouter.style.visibility="visible";
Pid=setInterval('incrCount()',95);
}
function resizeEl(id,t,r,b,l){
if(ns4){
id.clip.left=l;
id.clip.top=t;
id.clip.right=r;
id.clip.bottom=b;
}else id.style.width=r+'px';
}
window.onload=progressBarInit;

View File

@@ -0,0 +1,28 @@
<?xml version="1.0"?>
<Informe>
<Titulo Texto="{Descripcion}" id="{id}"/>
<Datos>
<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,
E.fechaCompra as fechaCompra,A.Descripcion as descripcion,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 U.id='{id}' order by A.descripcion;
</Consulta>
</Datos>
<Pagina Horizontal="2" Vertical="7">
<Cabecera>Ubicacion</Cabecera>
<Cuerpo>
<Col Nombre="Qr" Valor="{url}"/>
<Col Nombre="idEl" Titulo="idElem"/>
<Col Nombre="idArt" Titulo="idArt"/>
<Col Nombre="idUbic" Titulo="idUbic"/>
<Col Nombre="descripcion" Titulo="Artículo"/>
<Col Nombre="marca" Titulo="Marca"/>
<Col Nombre="modelo" Titulo="Modelo"/>
<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>