mirror of
https://github.com/rmontanana/inventario2.git
synced 2025-08-17 00:16:01 +00:00
Apply fixes from StyleCI
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
<?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.
|
||||
@@ -17,10 +16,9 @@
|
||||
*
|
||||
* 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 {
|
||||
|
||||
class InformeInventario
|
||||
{
|
||||
private $bdd;
|
||||
|
||||
public function __construct($baseDatos)
|
||||
@@ -48,67 +46,71 @@ class InformeInventario {
|
||||
$informe = new InformePDF($this->bdd, $enlace, true);
|
||||
$informe->crea($enlace);
|
||||
$informe->cierraPDF();
|
||||
|
||||
return $this->devuelveInforme($informe);
|
||||
}
|
||||
|
||||
private function devuelveInforme($informe)
|
||||
{
|
||||
$letras = "abcefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
|
||||
$nombre = TMP."/informe" . substr(str_shuffle($letras), 0, 10) . ".pdf";
|
||||
$letras = 'abcefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
|
||||
$nombre = TMP.'/informe'.substr(str_shuffle($letras), 0, 10).'.pdf';
|
||||
$informe->guardaArchivo($nombre);
|
||||
|
||||
return '<div class="container">
|
||||
<!--<a href="' . $nombre . '" target="_blank"><span class="glyphicon glyphicon-cloud-download" style="font-size:1.5em;"></span>Descargar Informe</a>-->
|
||||
<object data="' . $nombre . '" type="application/pdf" width="100%" height="700" style="float:left;">
|
||||
<!--<a href="'.$nombre.'" target="_blank"><span class="glyphicon glyphicon-cloud-download" style="font-size:1.5em;"></span>Descargar Informe</a>-->
|
||||
<object data="'.$nombre.'" type="application/pdf" width="100%" height="700" style="float:left;">
|
||||
</object>
|
||||
</div>';
|
||||
}
|
||||
|
||||
|
||||
private function listarUbicacion()
|
||||
{
|
||||
$salidaInforme = isset($_POST['salida']) ? $_POST['salida'] : 'pantalla';
|
||||
switch ($salidaInforme) {
|
||||
case "pantalla":
|
||||
$fichero = "xml/inventarioUbicacion.xml";
|
||||
$salida = TMP."/inventarioUbicacion.xml";
|
||||
case 'pantalla':
|
||||
$fichero = 'xml/inventarioUbicacion.xml';
|
||||
$salida = TMP.'/inventarioUbicacion.xml';
|
||||
break;
|
||||
case "csv":
|
||||
$fichero = "xml/inventarioUbicacionCSV.xml";
|
||||
$salida = TMP."/inventarioUbicacionCSV.xml";
|
||||
case 'csv':
|
||||
$fichero = 'xml/inventarioUbicacionCSV.xml';
|
||||
$salida = TMP.'/inventarioUbicacionCSV.xml';
|
||||
break;
|
||||
case "etiquetas":
|
||||
$fichero = "xml/inventarioUbicacionEtiquetas.xml";
|
||||
$salida = TMP."/inventarioUbicacionEtiquetas.xml";
|
||||
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'];
|
||||
$comando = "select * from Ubicaciones where id='" . $id . "';";
|
||||
$plantilla = file_get_contents($fichero) or die('Fallo en la apertura de la plantilla '.$fichero);
|
||||
$id = $_POST['id'] == null ? $_GET['id'] : $_POST['id'];
|
||||
$comando = "select * from Ubicaciones where id='".$id."';";
|
||||
$resultado = $this->bdd->ejecuta($comando);
|
||||
if (!$resultado) {
|
||||
return $this->bdd->mensajeError($comando);
|
||||
}
|
||||
$fila = $this->bdd->procesaResultado();
|
||||
$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);
|
||||
$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);
|
||||
switch ($salidaInforme) {
|
||||
case "pantalla":
|
||||
case 'pantalla':
|
||||
$informe = new InformePDF($this->bdd, $salida, true);
|
||||
$informe->crea($salida);
|
||||
$informe->cierraPDF();
|
||||
|
||||
return $this->devuelveInforme($informe);
|
||||
case "csv":
|
||||
case 'csv':
|
||||
//Genera una hoja de cálculo en formato csv
|
||||
$nombre = TMP."/Ubicacion" . strftime("%Y%m%d") . rand(100, 999) . ".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>';
|
||||
echo '<script type="text/javascript"> window.open( "'.$nombre.'" ) </script>';
|
||||
break;
|
||||
case "etiquetas":
|
||||
case 'etiquetas':
|
||||
$etiquetas = new EtiquetasPDF($this->bdd, $salida, true);
|
||||
$etiquetas->crea($salida);
|
||||
$etiquetas->cierraPDF();
|
||||
|
||||
return $this->devuelveInforme($etiquetas);
|
||||
}
|
||||
}
|
||||
@@ -117,50 +119,52 @@ class InformeInventario {
|
||||
{
|
||||
$salidaInforme = isset($_POST['salida']) ? $_POST['salida'] : 'pantalla';
|
||||
switch ($salidaInforme) {
|
||||
case "pantalla":
|
||||
$fichero = "xml/inventarioArticulo.xml";
|
||||
$salida = TMP."/inventarioArticulo.xml";
|
||||
case 'pantalla':
|
||||
$fichero = 'xml/inventarioArticulo.xml';
|
||||
$salida = TMP.'/inventarioArticulo.xml';
|
||||
break;
|
||||
case "csv":
|
||||
$fichero = "xml/inventarioArticuloCSV.xml";
|
||||
$salida = TMP."/inventarioArticuloCSV.xml";
|
||||
case 'csv':
|
||||
$fichero = 'xml/inventarioArticuloCSV.xml';
|
||||
$salida = TMP.'/inventarioArticuloCSV.xml';
|
||||
break;
|
||||
case "etiquetas":
|
||||
$fichero = "xml/inventarioArticuloEtiquetas.xml";
|
||||
$salida = TMP."/inventarioArticuloEtiquetas.xml";
|
||||
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'];
|
||||
$comando = "select * from Articulos where id='" . $id . "';";
|
||||
$plantilla = file_get_contents($fichero) or die('Fallo en la apertura de la plantilla '.$fichero);
|
||||
$id = $_POST['id'] == null ? $_GET['id'] : $_POST['id'];
|
||||
$comando = "select * from Articulos where id='".$id."';";
|
||||
$resultado = $this->bdd->ejecuta($comando);
|
||||
if (!$resultado) {
|
||||
return $this->bdd->mensajeError($comando);
|
||||
}
|
||||
$fila = $this->bdd->procesaResultado();
|
||||
$plantilla = str_replace("{id}", $id, $plantilla);
|
||||
$plantilla = str_replace("{Descripcion}", $fila['descripcion'], $plantilla);
|
||||
$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);
|
||||
$plantilla = str_replace('{id}', $id, $plantilla);
|
||||
$plantilla = str_replace('{Descripcion}', $fila['descripcion'], $plantilla);
|
||||
$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);
|
||||
switch ($salidaInforme) {
|
||||
case "pantalla":
|
||||
case 'pantalla':
|
||||
$informe = new InformePDF($this->bdd, $salida, true);
|
||||
$informe->crea($salida);
|
||||
$informe->cierraPDF();
|
||||
|
||||
return $this->devuelveInforme($informe);
|
||||
case "csv":
|
||||
case 'csv':
|
||||
//Genera una hoja de cálculo en formato csv
|
||||
$nombre = TMP."/Articulo" . strftime("%Y%m%d") . rand(100, 999) . ".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>';
|
||||
echo '<script type="text/javascript"> window.open( "'.$nombre.'" ) </script>';
|
||||
break;
|
||||
case "etiquetas":
|
||||
case 'etiquetas':
|
||||
$etiquetas = new EtiquetasPDF($this->bdd, $salida, true);
|
||||
$etiquetas->crea($salida);
|
||||
$etiquetas->cierraPDF();
|
||||
|
||||
return $this->devuelveInforme($etiquetas);
|
||||
}
|
||||
}
|
||||
@@ -168,63 +172,68 @@ class InformeInventario {
|
||||
private function listaUbicaciones()
|
||||
{
|
||||
$salida = "<select class=\"selectpicker show-tick\" name=\"id\" data-live-search=\"true\" data-width=\"auto\">\n";
|
||||
$comando = "select * from Ubicaciones order by Descripcion";
|
||||
$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 .= '<option value='.$fila['id'].'>'.$fila['Descripcion']."</option><br>\n";
|
||||
}
|
||||
$salida.="</select>\n";
|
||||
$salida .= "</select>\n";
|
||||
|
||||
return $salida;
|
||||
}
|
||||
|
||||
private function listaArticulos()
|
||||
{
|
||||
$salida = "<select class=\"selectpicker show-tick\" name=\"id\" data-live-search=\"true\" data-width=\"auto\">\n";
|
||||
$comando = "select * from Articulos order by descripcion, marca, modelo";
|
||||
$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 .= '<option value='.$fila['id'].'>'.$fila['descripcion'].'-'.$fila['marca'].'-'.$fila['modelo']."</option><br>\n";
|
||||
}
|
||||
$salida.="</select>\n";
|
||||
$salida .= "</select>\n";
|
||||
|
||||
return $salida;
|
||||
}
|
||||
|
||||
private function formulario($accion, $etiqueta, $lista)
|
||||
{
|
||||
$salida = '<div class="col-sm-6 col-md-6"><form name="informeInventario.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>
|
||||
$salida = '<div class="col-sm-6 col-md-6"><form name="informeInventario.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>
|
||||
<label for='salida'>Salida del informe por:</label>";
|
||||
$salida.='<div class="radio"><label><input type="radio" name="salida" value="pantalla" checked><span class="glyphicon glyphicon-list-alt"></span> Pantalla</label></div>';
|
||||
$salida.='<div class="radio"><label><input type="radio" name="salida" value="csv"><span class="glyphicon glyphicon-cloud-download"></span> Archivo CSV</label></div>';
|
||||
$salida.='<div class="radio"><label><input type="radio" name="salida" value="etiquetas"><span class="glyphicon glyphicon-qrcode"></span> Etiquetas (<a target="_new" href="http://www.apli.es/producto/ficha_producto.aspx?referencia=01275&stype=referencia&referenciaValue=01275&q=01275">Apli 1275</a>)</label></div>';
|
||||
$salida.="<br><br></fieldset><p>";
|
||||
$salida.='<p align="center"><button type=submit class="btn btn-primary"><span class="glyphicon glyphicon-ok"></span> Aceptar</button></p><br></div>' . "\n";
|
||||
$salida.="<script>$('.selectpicker').selectpicker();</script>";
|
||||
$salida .= '<div class="radio"><label><input type="radio" name="salida" value="pantalla" checked><span class="glyphicon glyphicon-list-alt"></span> Pantalla</label></div>';
|
||||
$salida .= '<div class="radio"><label><input type="radio" name="salida" value="csv"><span class="glyphicon glyphicon-cloud-download"></span> Archivo CSV</label></div>';
|
||||
$salida .= '<div class="radio"><label><input type="radio" name="salida" value="etiquetas"><span class="glyphicon glyphicon-qrcode"></span> Etiquetas (<a target="_new" href="http://www.apli.es/producto/ficha_producto.aspx?referencia=01275&stype=referencia&referenciaValue=01275&q=01275">Apli 1275</a>)</label></div>';
|
||||
$salida .= '<br><br></fieldset><p>';
|
||||
$salida .= '<p align="center"><button type=submit class="btn btn-primary"><span class="glyphicon glyphicon-ok"></span> Aceptar</button></p><br></div>'."\n";
|
||||
$salida .= "<script>$('.selectpicker').selectpicker();</script>";
|
||||
|
||||
return $salida;
|
||||
}
|
||||
|
||||
private function formularioUbicacion()
|
||||
{
|
||||
//Genera un formulario con las ubicaciones disponibles.
|
||||
$accion = "index.php?informeInventario&opc=listarUbicacion";
|
||||
$accion = 'index.php?informeInventario&opc=listarUbicacion';
|
||||
|
||||
return $this->formulario($accion, 'Ubicación', $this->listaUbicaciones());
|
||||
}
|
||||
|
||||
private function formularioArticulo()
|
||||
{
|
||||
$accion = "index.php?informeInventario&opc=listarArticulo";
|
||||
$accion = 'index.php?informeInventario&opc=listarArticulo';
|
||||
|
||||
return $this->formulario($accion, 'Artículo', $this->listaArticulos());
|
||||
}
|
||||
|
||||
|
||||
private function inventarioTotal()
|
||||
{
|
||||
return $this->dialogo();
|
||||
@@ -235,18 +244,19 @@ class InformeInventario {
|
||||
$dialogo = '<div class="container col-5"><div class="jumbotron">
|
||||
<h1>Inventario Total</h1>
|
||||
<p>¿Desea obtener el inventario de todo el centro?</p>
|
||||
<p><a class="btn btn-primary btn-lg" role="button" onClick="location.href=' . "'index.php'" . '"><span class="glyphicon glyphicon-arrow-left"></span> Volver</a>
|
||||
<a class="btn btn-success btn-lg" role="button" onClick="location.href=' . "'index.php?informeInventario&opc=listarTotal'" . '">
|
||||
<p><a class="btn btn-primary btn-lg" role="button" onClick="location.href='."'index.php'".'"><span class="glyphicon glyphicon-arrow-left"></span> Volver</a>
|
||||
<a class="btn btn-success btn-lg" role="button" onClick="location.href='."'index.php?informeInventario&opc=listarTotal'".'">
|
||||
<span class="glyphicon glyphicon-list-alt"></span> Continuar</a></p>
|
||||
</div></div>';
|
||||
|
||||
return $dialogo;
|
||||
}
|
||||
|
||||
|
||||
private function listarTotal()
|
||||
{
|
||||
$fichero = "xml/inventarioUbicacion.xml";
|
||||
$salida = TMP."/inventarioUbicacion.xml";
|
||||
$comando = "select * from Ubicaciones ;";
|
||||
$fichero = 'xml/inventarioUbicacion.xml';
|
||||
$salida = TMP.'/inventarioUbicacion.xml';
|
||||
$comando = 'select * from Ubicaciones ;';
|
||||
$resultado = $this->bdd->ejecuta($comando);
|
||||
if (!$resultado) {
|
||||
return $this->bdd->mensajeError($comando);
|
||||
@@ -255,10 +265,10 @@ class InformeInventario {
|
||||
$bdatos = new Sql(SERVIDOR, USUARIO, CLAVE, BASEDATOS);
|
||||
$primero = true;
|
||||
while ($fila = $this->bdd->procesaResultado()) {
|
||||
$plantilla = file_get_contents($fichero) or die('Fallo en la apertura de la plantilla ' . $fichero);
|
||||
$plantilla = str_replace("{id}", $fila['id'], $plantilla);
|
||||
$plantilla = str_replace("{Descripcion}", $fila['Descripcion'], $plantilla);
|
||||
file_put_contents($salida, $plantilla) or die('Fallo en la escritura de la plantilla ' . $salida);
|
||||
$plantilla = file_get_contents($fichero) or die('Fallo en la apertura de la plantilla '.$fichero);
|
||||
$plantilla = str_replace('{id}', $fila['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 ($primero) {
|
||||
$primero = false;
|
||||
$informe = new InformePDF($bdatos, $salida, true);
|
||||
@@ -266,9 +276,7 @@ class InformeInventario {
|
||||
$informe->crea($salida);
|
||||
}
|
||||
$informe->cierraPDF();
|
||||
|
||||
return $this->devuelveInforme($informe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
Reference in New Issue
Block a user