11 Commits
1.11b ... tests

Author SHA1 Message Date
d4b4429232 #9 Corregido el problema de detectar http y https en el enlace de la url de llamada. 2014-03-17 23:39:28 +01:00
rmontanana
5c403c5313 Caducidad de la cookie a 24h 2014-03-17 14:17:24 +01:00
rmontanana
8d0fffb04b El menú ahora funciona colapsado en resoluciones pequeñas. Corrección en el tamaño de la barra de búsqueda del mantenimiento en resoluciones pequeñas 2014-03-17 13:47:50 +01:00
rmontanana
d78333ae6a 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. 2014-03-15 03:36:28 +01:00
e1d50a74dc 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.
2014-03-14 01:14:06 +01:00
rmontanana
c33a6edaa1 Arreglado que salía mantenimiento de Artículos cuando se solicitaba Matenimiento de Elementos. 2014-03-12 09:13:53 +01:00
rmontanana
78bd313fd3 Terminado el mantenimiento con:
-Control de la url de vuelta
-funcionamiento correcto de la cadena de búsqueda con la ordenación, edición, etc.
-funcionamiento correcto de la paginación y el orden con la edición, borrado, etc.
-mensaje de inserción de registros con nuevo formato y redirección con tiempo.
2014-03-12 09:09:58 +01:00
bd2f0ed4b8 En mantenimiento puesta la gestión de URL para que vuelva siempre a donde estaba tanto desde altas, modificaciones o bajas
Reformateado de ficheros
2014-03-11 23:58:20 +01:00
rmontanana
5444378aa4 Pequeños cambios en el mantenimiento para lo de la cadena de búsqueda 2014-03-10 16:49:26 +01:00
a266e85d39 Añadido que mantenga la cadena de búsqueda en su cuadro una vez pulsada la opción de buscar. Quedan cosas por hacer 2014-03-10 00:27:08 +01:00
8647d08d51 Primera aproximación para realizar los tests con phpunit
Configuración cambiada totalmente para optimizar el código y prepararlo para los tests.
Quitada la clave APLICACION del fichero de configuración y de las clases que lo utilizaban (Aportacontenido, InformePDF y PDF_mysql_table)
Creados los esqueletos de test para: Configuración, Menu y Sql
Casi terminado el conjunto de pruebas de Configuración. Pendiente en @todo
2014-03-10 00:17:05 +01:00
56 changed files with 15124 additions and 6965 deletions

View File

@@ -118,14 +118,14 @@ class AportaContenido {
public function __call($metodo, $parametros) { public function __call($metodo, $parametros) {
switch ($metodo) { // Dependiendo del método invocado switch ($metodo) { // Dependiendo del método invocado
case 'titulo': // devolvemos el título case 'titulo': // devolvemos el título
return APLICACION; return PROGRAMA.VERSION;
case 'usuario': case 'usuario':
if ($this->registrado) if ($this->registrado)
return "Usuario=$this->usuario"; return "Usuario=$this->usuario";
else else
return ''; return '';
case 'fecha': return $this->fechaActual(); case 'fecha': return $this->fechaActual();
case 'aplicacion': return APLICACION; case 'aplicacion': return PROGRAMA.VERSION;
case 'menu': // el menú case 'menu': // el menú
if ($this->registrado) { if ($this->registrado) {
return $this->miMenu->insertaMenu(); return $this->miMenu->insertaMenu();
@@ -144,8 +144,8 @@ class AportaContenido {
return "Menú Principal"; return "Menú Principal";
case 'principal': case 'principal':
return "Pantalla Inicial"; return "Pantalla Inicial";
case 'elementos':
case 'articulos': $opcion = "artículos"; case 'articulos': $opcion = "artículos";
case 'elementos':
case 'ubicaciones': case 'ubicaciones':
case 'usuarios': case 'usuarios':
case 'test': case 'test':

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* @package Inventario * @package Inventario
* @copyright Copyright (c) 2008, Ricardo Montañana Gómez * @copyright Copyright (c) 2008, Ricardo Montañana Gómez
@@ -19,127 +20,58 @@
* *
*/ */
class Configuracion { class Configuracion {
private $nombreCentro;
private $numFilas;
private $estilo;
private $servidor;
private $baseDatos;
private $usuario;
private $clave;
private $configuracion = "inc/configuracion.inc"; private $configuracion = "inc/configuracion.inc";
private $confNueva = "inc/configuracion.new"; private $confNueva = "inc/configuracion.new";
private $confAnterior = "inc/configuracion.ant"; private $confAnterior = "inc/configuracion.ant";
private $plantilla; private $datosConf;
private $colorLateral; //Campos del fichero de configuración que se van a editar.
private $colorFondo; private $lista = array('SERVIDOR', 'BASEDATOS', 'BASEDATOSTEST', 'USUARIO', 'CLAVE', 'CENTRO', 'NUMFILAS', 'ESTILO', 'PLANTILLA', 'COLORLAT', 'COLORFON', 'MYSQLDUMP', 'GZIP');
private $mysqldump; //comando mysqldump para la copia de seguridad private $campos;
private $gzip; //comando gzip para comprimir la copia de seguridad
public function ejecuta() public function __construct()
{ {
$fichero=file_get_contents($this->configuracion,FILE_TEXT); $this->campos = implode(",", $this->lista);
}
//Hecho público para poder efectuar los tests correspondientes.
public function obtieneFichero()
{
return file_get_contents($this->configuracion, FILE_TEXT);
}
public function obtieneLista()
{
return $this->lista;
}
public function obtieneDatos($linea, &$clave, &$valor)
{
$filtro = str_replace("'", "", $linea);
list($clave, $valor) = explode(",", $filtro);
list($resto, $campo) = explode("(", $clave);
list($valor, $resto) = explode(")", $valor);
list($resto, $clave) = explode("(", $clave);
$valor = trim($valor);
}
public function ejecuta() {
$fichero = $this->obtieneFichero();
$datos = explode("\n", $fichero); $datos = explode("\n", $fichero);
$grabar=isset($_POST['servidor']); $grabar = isset($_POST['SERVIDOR']);
if ($grabar) { if ($grabar) {
$fsalida = @fopen($this->confNueva, "wb"); $fsalida = @fopen($this->confNueva, "wb");
} }
foreach ($datos as $linea) { foreach ($datos as $linea) {
if (stripos($linea, "DEFINE") !== false) { if (stripos($linea, "DEFINE") !== false) {
$filtro=str_replace("'","",$linea); //Comprueba que tenga una definición correcta
list($clave,$valor)=explode(",",$filtro); $this->obtieneDatos($linea, $clave, $valor);
list($resto,$campo)=explode("(",$clave); $this->datosConf[$clave] = $valor;
list($valor,$resto)=explode(")",$valor); if ($grabar && stripos($this->campos, $clave) !== false) {
//$salida.="[$campo]=[$valor]<br>\n"; $linea = str_replace($valor, $_POST[$clave], $linea);
switch ($campo) { $this->datosConf[$clave] = $_POST[$clave];
case 'CENTRO':
$this->nombreCentro=$valor;
if ($grabar) {
$linea=str_replace($valor, $_POST['centro'],$linea);
$this->nombreCentro=$_POST['centro'];
}
break;
case 'NUMFILAS':
$this->numFilas=$valor;
if ($grabar) {
$linea=str_replace($valor, $_POST['filas'],$linea);
$this->numFilas=$_POST['filas'];
}
break;
case 'ESTILO':
$this->estilo=$valor;
if ($grabar) {
$linea=str_replace($valor, $_POST['estilo'],$linea);
$this->estilo=$_POST['estilo'];
}
break;
case 'PLANTILLA':
$this->plantilla=$valor;
if ($grabar) {
$linea=str_replace($valor, $_POST['plantilla'],$linea);
$this->plantilla=$_POST['plantilla'];
}
break;
case 'SERVIDOR':
$this->servidor=$valor;
if ($grabar) {
$linea=str_replace($valor, $_POST['servidor'],$linea);
$this->servidor=$_POST['servidor'];
}
break;
case 'BASEDATOS':
$this->baseDatos=$valor;
if ($grabar) {
$linea=str_replace($valor, $_POST['baseDatos'],$linea);
$this->baseDatos=$_POST['baseDatos'];
}
break;
case 'USUARIO':
$this->usuario=$valor;
if ($grabar) {
$linea=str_replace($valor, $_POST['usuario'],$linea);
$this->usuario=$_POST['usuario'];
}
break;
case 'CLAVE':
$this->clave=$valor;
if ($grabar) {
$linea=str_replace($valor, $_POST['clave'],$linea);
$this->clave=$_POST['clave'];
}
break;
case 'COLORLAT':
$valor = trim($valor);
$this->colorLateral = $valor;
if ($grabar) {
$linea=str_replace($valor,$_POST['colorLat'],$linea);
$this->colorLateral=$_POST['colorLat'];
}
break;
case 'COLORFON':
$valor = trim($valor);
$this->colorFondo = $valor;
if ($grabar) {
$linea=str_replace($valor,$_POST['colorFon'],$linea);
$this->colorFondo=$_POST['colorFon'];
}
break;
case 'MYSQLDUMP':
$valor = trim($valor);
$this->mysqldump = $valor;
if ($grabar) {
$linea=str_replace($valor,$_POST['mysqldump'],$linea);
$this->mysqldump=$_POST['mysqldump'];
}
break;
case 'GZIP':
$valor = trim($valor);
$this->gzip = $valor;
if ($grabar) {
$linea=str_replace($valor,$_POST['gzip'],$linea);
$this->gzip=$_POST['gzip'];
}
break;
} }
//$salida = "DatosConf=".var_export($this->datosConf, true) . "stripos = " . stripos($campos, "GZIP");
//$salida .= "Post=" . var_export($_POST, true);
} }
if ($grabar) { if ($grabar) {
$registro = substr($linea, 0, 2) == "?>" ? $linea : $linea . "\n"; $registro = substr($linea, 0, 2) == "?>" ? $linea : $linea . "\n";
@@ -148,7 +80,6 @@
} }
$salida.=$this->formulario(); $salida.=$this->formulario();
if ($grabar) { if ($grabar) {
//$salida.='<label class="warn">Configuraci&oacute;n guardada correctamente</label>';
$salida.='<p class="bg-primary">Configuraci&oacute;n guardada correctamente</p>'; $salida.='<p class="bg-primary">Configuraci&oacute;n guardada correctamente</p>';
fclose($fsalida); fclose($fsalida);
//unlink($this->confAnterior); //unlink($this->confAnterior);
@@ -158,74 +89,76 @@
} }
return $salida; return $salida;
} }
private function formulario()
{ private function formulario() {
$coloresLateral = array("Original" => "#C4FAEC", "Verde" => "#7bd148", "Azul marino" => "#5484ed", "Azul" => "#a4bdfc", "Turquesa" => "#46d6db", $coloresLateral = array("Original" => "#C4FAEC", "Verde" => "#7bd148", "Azul marino" => "#5484ed", "Azul" => "#a4bdfc", "Turquesa" => "#46d6db",
"Verde claro" => "#7ae7bf", "Verde oscuro" => "#51b749", "Amarillo" => "#fbd75b", "Naranja" => "#ffb878", "Morado" => "#6633FF", "Verde claro" => "#7ae7bf", "Verde oscuro" => "#51b749", "Amarillo" => "#fbd75b", "Naranja" => "#ffb878", "Morado" => "#6633FF",
"Rojo oscuro" => "#dc2127", "P&uacute;rpura" => "#dbadff", "Gris" => "#e1e1e1"); "Rojo oscuro" => "#dc2127", "P&uacute;rpura" => "#dbadff", "Gris" => "#e1e1e1");
$coloresFondo = array("Verde" => "#7bd148", "Azul marino" => "#5484ed", "Azul" => "#a4bdfc", "Turquesa" => "#46d6db", $coloresFondo = array("Verde" => "#7bd148", "Azul marino" => "#5484ed", "Azul" => "#a4bdfc", "Turquesa" => "#46d6db",
"Verde claro" => "#7ae7bf", "Verde oscuro" => "#51b749", "Amarillo" => "#fbd75b", "Naranja" => "#ffb878", "Rojo" => "#ff887c", "Verde claro" => "#7ae7bf", "Verde oscuro" => "#51b749", "Amarillo" => "#fbd75b", "Naranja" => "#ffb878", "Rojo" => "#ff887c",
"Rojo oscuro" => "#dc2127", "P&uacute;rpura" => "#dbadff", "Gris" => "#e1e1e1", "Original" => '#F3FEC8'); "Rojo oscuro" => "#dc2127", "P&uacute;rpura" => "#dbadff", "Gris" => "#e1e1e1", "Original" => '#F3FEC8');
$personal=$this->estilo=="personal"?'selected':' '; $personal = $this->datosConf['ESTILO'] == "personal" ? 'selected' : ' ';
$bluecurve=$this->estilo=="bluecurve"?'selected':' '; $bluecurve = $this->datosConf['ESTILO'] == "bluecurve" ? 'selected' : ' ';
$cristal=$this->estilo=="cristal"?'selected':' '; $cristal = $this->datosConf['ESTILO'] == "cristal" ? 'selected' : ' ';
$normal=$this->plantilla=="normal"? 'selected':' '; $normal = $this->datosConf['PLANTILLA'] == "normal" ? 'selected' : ' ';
$bootstrap=$this->plantilla=="bootstrap" ? 'selected':' '; $bootstrap = $this->datosConf['PLANTILLA'] == "bootstrap" ? 'selected' : ' ';
$salida = '<center><div class="col-sm-4 col-md-6"><form name="configura" method="post">'; $salida = '<center><div class="col-sm-4 col-md-6"><form name="configura" method="post">';
//$salida.='<p align="center"><table border=1 class="tablaDatos"><tbody>'; //$salida.='<p align="center"><table border=1 class="tablaDatos"><tbody>';
$salida.='<p align="center"><table border=2 class="table table-hover"><tbody>'; $salida.='<p align="center"><table border=2 class="table table-hover"><tbody>';
$salida.='<th colspan=2 class="info"><center><b>Preferencias</b></center></th>'; $salida.='<th colspan=2 class="info"><center><b>Preferencias</b></center></th>';
$salida.='<tr><td>Nombre del Centro</td><td><input type="text" name="centro" value="'.$this->nombreCentro.'" size="30" /></td></tr>'; $salida.='<tr><td>Nombre del Centro</td><td><input type="text" name="CENTRO" value="' . $this->datosConf['CENTRO'] . '" size="30" /></td></tr>';
$salida.='<tr><td>N&uacute;mero de filas</td><td><input type="text" name="filas" value="'.$this->numFilas.'" size="3" /></td></tr>'; $salida.='<tr><td>N&uacute;mero de filas</td><td><input type="text" name="NUMFILAS" value="' . $this->datosConf['NUMFILAS'] . '" size="3" /></td></tr>';
$salida.='<tr><td style="vertical-align:middle">Plantilla</td><td><select name="plantilla" class="form-control">'; $salida.='<tr><td style="vertical-align:middle">Plantilla</td><td><select name="PLANTILLA" class="form-control">';
$salida.='<option value="normal" ' . $normal . '>normal</option>'; $salida.='<option value="normal" ' . $normal . '>normal</option>';
$salida.='<option ' . $bootstrap . '>bootstrap</option></select></td></tr>'; $salida.='<option ' . $bootstrap . '>bootstrap</option></select></td></tr>';
$salida.='<tr><td style="vertical-align:middle">Estilo</td><td><select name="estilo" class="form-control">'; $salida.='<tr><td style="vertical-align:middle">Estilo</td><td><select name="ESTILO" class="form-control">';
$salida.='<option value="personal" ' . $personal . '>personal</option>'; $salida.='<option value="personal" ' . $personal . '>personal</option>';
$salida.='<option ' . $bluecurve . '>bluecurve</option>'; $salida.='<option ' . $bluecurve . '>bluecurve</option>';
$salida.='<option ' . $cristal . '>cristal</option></select></td></tr>'; $salida.='<option ' . $cristal . '>cristal</option></select></td></tr>';
$salida.='<tr><td style="vertical-align:middle">Color Lateral (bootstrap)</td><td style="vertical-align:middle"><select name="colorLat" id="colorLat" class="form-control">'; $salida.='<tr><td style="vertical-align:middle">Color Lateral (bootstrap)</td><td style="vertical-align:middle"><select name="COLORLAT" id="COLORLAT" class="form-control">';
foreach ($coloresLateral as $color => $codigo) { foreach ($coloresLateral as $color => $codigo) {
$selec = ""; $selec = "";
if ($this->colorLateral == $codigo) { if (trim($this->datosConf['COLORLAT']) == $codigo) {
$selec = "selected"; $selec = "selected";
} }
$salida.='<option value="' . $codigo . '" ' . $selec . ' >' . $color . '</option>'; $salida.='<option value="' . $codigo . '" ' . $selec . ' >' . $color . '</option>';
} }
$salida.='</select></td></tr>'; $salida.='</select></td></tr>';
$salida.='<tr><td style="vertical-align:middle">Color Fondo (bootstrap)</td><td style="vertical-align:middle"><select name="colorFon" id="colorFon" class="form-control">'; $salida.='<tr><td style="vertical-align:middle">Color Fondo (bootstrap)</td><td style="vertical-align:middle"><select name="COLORFON" id="COLORFON" class="form-control">';
foreach ($coloresFondo as $color => $codigo) { foreach ($coloresFondo as $color => $codigo) {
$selec = ""; $selec = "";
if ($this->colorFondo == $codigo) { if (trim($this->datosConf['COLORFON']) == $codigo) {
$selec = "selected"; $selec = "selected";
} }
$salida.='<option value="' . $codigo . '" ' . $selec . ' >' . $color . '</option>'; $salida.='<option value="' . $codigo . '" ' . $selec . ' >' . $color . '</option>';
} }
$salida.='</select></td></tr>'; $salida.='</select></td></tr>';
$salida.='<th colspan=2 class="danger"><center><b>Base de datos</b></center></th>'; $salida.='<th colspan=2 class="danger"><center><b>Base de datos</b></center></th>';
$salida.='<tr><td>Servidor</td><td><input type="text" name="servidor" value="'.$this->servidor.'" size="30" /></td></tr>'; $salida.='<tr><td>Servidor</td><td><input type="text" name="SERVIDOR" value="' . $this->datosConf['SERVIDOR'] . '" size="30" /></td></tr>';
$salida.='<tr><td>Base de datos</td><td><input type="text" name="baseDatos" value="'.$this->baseDatos.'" size="30" /></td></tr>'; $salida.='<tr><td>Base de datos</td><td><input type="text" name="BASEDATOS" value="' . $this->datosConf['BASEDATOS'] . '" size="30" /></td></tr>';
$salida.='<tr><td>Usuario</td><td><input type="text" name="usuario" value="'.$this->usuario.'" size="30" /></td></tr>'; $salida.='<tr><td>Base de datos Tests</td><td><input type="text" name="BASEDATOSTEST" value="' . $this->datosConf['BASEDATOSTEST'] . '" size="30" /></td></tr>';
$salida.='<tr><td>Clave</td><td><input type="text" name="clave" value="'.$this->clave.'" size="30" /></td></tr>'; $salida.='<tr><td>Usuario</td><td><input type="text" name="USUARIO" value="' . $this->datosConf['USUARIO'] . '" size="30" /></td></tr>';
$salida.='<tr><td>mysqldump</td><td><input type="text" name="mysqldump" value="'.$this->mysqldump.'" size="30" /></td></tr>'; $salida.='<tr><td>Clave</td><td><input type="text" name="CLAVE" value="' . $this->datosConf['CLAVE'] . '" size="30" /></td></tr>';
$salida.='<tr><td>gzip</td><td><input type="text" name="gzip" value="'.$this->gzip.'" size="30" /></td></tr>'; $salida.='<tr><td>mysqldump</td><td><input type="text" name="MYSQLDUMP" value="' . $this->datosConf['MYSQLDUMP'] . '" size="30" /></td></tr>';
$salida.='<tr><td>gzip</td><td><input type="text" name="GZIP" value="' . $this->datosConf['GZIP'] . '" size="30" /></td></tr>';
$salida.='<tr align=center><td colspan=2><input type="submit" class="btn btn-primary" align="center" value="Aceptar" name="aceptar" /></td></tr></p>'; $salida.='<tr align=center><td colspan=2><input type="submit" class="btn btn-primary" align="center" value="Aceptar" name="aceptar" /></td></tr></p>';
$salida.='</form></div></center>'; $salida.='</form></div></center>';
$salida.="<script> $salida.="<script>
$(document).ready(function() { $(document).ready(function() {
$('select[name=" .'"colorFon"'. "]').on('change', function() { $('select[name=" . '"COLORFON"' . "]').on('change', function() {
$(document.body).css('background-color', $('select[name=" .'"colorFon"'. "]').val()); $(document.body).css('background-color', $('select[name=" . '"COLORFON"' . "]').val());
$('.main').css('background-color', $('select[name=" .'"colorFon"'. "]').val()); $('.main').css('background-color', $('select[name=" . '"COLORFON"' . "]').val());
}); });
$('select[name=" .'"colorLat"'. "]').on('change', function() { $('select[name=" . '"COLORLAT"' . "]').on('change', function() {
$('.sidebar').css('background-color', $('select[name=" .'"colorLat"'. "]').val()); $('.sidebar').css('background-color', $('select[name=" . '"COLORLAT"' . "]').val());
}); });
$('select[name=". '"colorLat"' ."]').simplecolorpicker({theme: 'glyphicons'}); $('select[name=" . '"COLORLAT"' . "]').simplecolorpicker({theme: 'glyphicons'});
$('select[name=" .'"colorFon"' ."]').simplecolorpicker({theme: 'glyphicons'}); $('select[name=" . '"COLORFON"' . "]').simplecolorpicker({theme: 'glyphicons'});
}); });
</script>"; </script>";
//$salida.="<br>fondo=[$this->colorFondo] lateral=[$this->colorLateral]<br>";
return $salida; return $salida;
} }
} }
?> ?>

179
EtiquetasPDF.php Normal file
View File

@@ -0,0 +1,179 @@
<?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;
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
* @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);
$this->pdf->setAutoPageBreak(false);
//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);
//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 = explode("/", $_SERVER['SCRIPT_NAME']);
$aplicacion = $url[1];
$protocolo = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://";
$enlace = $protocolo . $_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 + 41 * $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['articulo']));
$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-1;
$this->pdf->setxy($etiq2, $py);
$this->pdf->Cell(30, 10, utf8_decode($tupla['ubicacion']));
$py+=$tamLinea-1;
$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=" . $this->nombreFichero;
return $cabecera;
}
public function guardaArchivo($nombre = "tmp/Informe.pdf")
{
$fichero = fopen($nombre, "w");
fwrite($fichero, $this->getCabecera());
fwrite($fichero, $this->getContenido(), strlen($this->getContenido()));
$this->nombreFichero = $nombre;
fclose($fichero);
}
public function enviaCabecera()
{
header("Content-type: application/pdf");
$longitud = strlen($this->docu);
header("Content-length: $longitud");
header("Content-Disposition: inline; filename=" . $this->nombreFichero);
}
public function imprimeInforme()
{
$this->enviaCabecera();
echo $this->docu;
}
}
?>

View File

@@ -40,12 +40,19 @@ class InformeInventario {
private function listarUbicacion() { private function listarUbicacion() {
$salidaInforme = isset($_POST['salida']) ? $_POST['salida'] : 'pantalla'; $salidaInforme = isset($_POST['salida']) ? $_POST['salida'] : 'pantalla';
if ($salidaInforme == "pantalla") { switch ($salidaInforme) {
case "pantalla":
$fichero = "xml/inventarioUbicacion.xml"; $fichero = "xml/inventarioUbicacion.xml";
$salida = "tmp/inventarioUbicacion.xml"; $salida = "tmp/inventarioUbicacion.xml";
} else { break;
case "csv":
$fichero = "xml/inventarioUbicacionCSV.xml"; $fichero = "xml/inventarioUbicacionCSV.xml";
$salida = "tmp/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); $plantilla = file_get_contents($fichero) or die('Fallo en la apertura de la plantilla ' . $fichero);
$id = $_POST['id'] == NULL ? $_GET['id'] : $_POST['id']; $id = $_POST['id'] == NULL ? $_GET['id'] : $_POST['id'];
@@ -58,30 +65,47 @@ class InformeInventario {
$plantilla = str_replace("{id}", $id, $plantilla); $plantilla = str_replace("{id}", $id, $plantilla);
$plantilla = str_replace("{Descripcion}", $fila['Descripcion'], $plantilla); $plantilla = str_replace("{Descripcion}", $fila['Descripcion'], $plantilla);
file_put_contents($salida, $plantilla) or die('Fallo en la escritura de la plantilla ' . $salida); file_put_contents($salida, $plantilla) or die('Fallo en la escritura de la plantilla ' . $salida);
if ($salidaInforme == "pantalla") { switch ($salidaInforme) {
case "pantalla":
$informe = new InformePDF($this->bdd, $salida, true); $informe = new InformePDF($this->bdd, $salida, true);
$informe->crea($salida); $informe->crea($salida);
$informe->cierraPDF(); $informe->cierraPDF();
$informe->guardaArchivo("tmp/Informe.pdf"); $informe->guardaArchivo("tmp/Informe.pdf");
echo '<script type="text/javascript"> window.open( "tmp/Informe.pdf" ) </script>'; echo '<script type="text/javascript"> window.open( "tmp/Informe.pdf" ) </script>';
} else { break;
case "csv":
//Genera una hoja de cálculo en formato 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 = new Csv($this->bdd);
$hoja->crea($nombre); $hoja->crea($nombre);
$hoja->ejecutaConsulta($salida); $hoja->ejecutaConsulta($salida);
echo '<script type="text/javascript"> window.open( "' . $nombre . '" ) </script>'; 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() { private function listarArticulo() {
$salidaInforme = isset($_POST['salida']) ? $_POST['salida'] : 'pantalla'; $salidaInforme = isset($_POST['salida']) ? $_POST['salida'] : 'pantalla';
if ($salidaInforme == "pantalla") { switch ($salidaInforme) {
case "pantalla":
$fichero = "xml/inventarioArticulo.xml"; $fichero = "xml/inventarioArticulo.xml";
$salida = "tmp/inventarioArticulo.xml"; $salida = "tmp/inventarioArticulo.xml";
} else { break;
case "csv":
$fichero = "xml/inventarioArticuloCSV.xml"; $fichero = "xml/inventarioArticuloCSV.xml";
$salida = "tmp/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); $plantilla = file_get_contents($fichero) or die('Fallo en la apertura de la plantilla ' . $fichero);
$id = $_POST['id'] == NULL ? $_GET['id'] : $_POST['id']; $id = $_POST['id'] == NULL ? $_GET['id'] : $_POST['id'];
@@ -96,21 +120,30 @@ class InformeInventario {
$plantilla = str_replace("{Marca}", $fila['marca'], $plantilla); $plantilla = str_replace("{Marca}", $fila['marca'], $plantilla);
$plantilla = str_replace("{Modelo}", $fila['modelo'], $plantilla); $plantilla = str_replace("{Modelo}", $fila['modelo'], $plantilla);
file_put_contents($salida, $plantilla) or die('Fallo en la escritura de la plantilla ' . $salida); file_put_contents($salida, $plantilla) or die('Fallo en la escritura de la plantilla ' . $salida);
if ($salidaInforme == "pantalla") { switch ($salidaInforme) {
case "pantalla":
$informe = new InformePDF($this->bdd, $salida, true); $informe = new InformePDF($this->bdd, $salida, true);
$informe->crea($salida); $informe->crea($salida);
$informe->cierraPDF(); $informe->cierraPDF();
$informe->guardaArchivo("tmp/Informe.pdf"); $informe->guardaArchivo("tmp/Informe.pdf");
echo '<script type="text/javascript"> window.open( "tmp/Informe.pdf" ) </script>'; echo '<script type="text/javascript"> window.open( "tmp/Informe.pdf" ) </script>';
} else { break;
case "csv":
//Genera una hoja de cálculo en formato 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 = new Csv($this->bdd);
$hoja->crea($nombre); $hoja->crea($nombre);
$hoja->ejecutaConsulta($salida); $hoja->ejecutaConsulta($salida);
echo '<script type="text/javascript"> window.open( "' . $nombre . '" ) </script>'; 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() { private function listaUbicaciones() {
@@ -149,6 +182,7 @@ class InformeInventario {
$salida.="<br><br><label for='salida'>Salida del informe por:</label>"; $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="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="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.="<br><br></fieldset><p>";
$salida.='<p align="center"><button type=submit class="btn btn-primary">Aceptar</button></p><br></div>' . "\n"; $salida.='<p align="center"><button type=submit class="btn btn-primary">Aceptar</button></p><br></div>' . "\n";
return $salida; return $salida;
@@ -192,7 +226,6 @@ class InformeInventario {
$informe->cierraPDF(); $informe->cierraPDF();
$informe->imprimeInforme(); $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

@@ -55,7 +55,7 @@ class InformePDF {
//echo $def->Titulo.$def->Cabecera; //echo $def->Titulo.$def->Cabecera;
$this->pdf->Open(); $this->pdf->Open();
$this->pdf->setAuthor(AUTOR,true); $this->pdf->setAuthor(AUTOR,true);
$creador = CENTRO . " " . APLICACION; $creador = CENTRO . " " . PROGRAMA.VERSION;
$this->pdf->setCreator(html_entity_decode($creador),true); $this->pdf->setCreator(html_entity_decode($creador),true);
$this->pdf->setSubject($this->def->Titulo,true); $this->pdf->setSubject($this->def->Titulo,true);
$this->pdf->setAutoPageBreak(true, 10); $this->pdf->setAutoPageBreak(true, 10);

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

@@ -104,7 +104,7 @@ class Inventario {
$_SESSION['Usuario'] = $this->usuario; $_SESSION['Usuario'] = $this->usuario;
$_SESSION['Perfil'] = $this->perfil; $_SESSION['Perfil'] = $this->perfil;
// y enviamos la cookie para reconocerlo la próxima vez // y enviamos la cookie para reconocerlo la próxima vez
setcookie('InventarioId', $resultado, time() + 3600 * 24 * 365); setcookie('InventarioId', $resultado, time() + 3600 * 24);
// Lo enviamos a la página de bienvenida // Lo enviamos a la página de bienvenida
header('Location: index.php?bienvenido'); header('Location: index.php?bienvenido');
exit; exit;

View File

@@ -29,7 +29,6 @@ class Mantenimiento {
private $descripcion; private $descripcion;
protected $bdd; protected $bdd;
protected $url; protected $url;
protected $cabecera;
protected $tabla; protected $tabla;
protected $cadenaBusqueda; protected $cadenaBusqueda;
protected $campos = array(); protected $campos = array();
@@ -37,39 +36,85 @@ class Mantenimiento {
protected $campoBusca = "Descripcion"; protected $campoBusca = "Descripcion";
protected $comandoConsulta = ""; protected $comandoConsulta = "";
protected $perfil; protected $perfil;
protected $datosURL = array();
protected $datosURLb = array(); //para hacer una copia
public function __construct($baseDatos, $perfil, $nombre) { public function __construct($baseDatos, $perfil, $nombre)
{
$this->bdd = $baseDatos; $this->bdd = $baseDatos;
$this->url = "index.php?$nombre&opc=inicial"; $this->url = "index.php?$nombre";
$this->cabecera = 'Location: ' . $this->url; //$this->datosURL['']
$this->tabla = ucfirst($nombre); $this->tabla = ucfirst($nombre);
$this->perfil = $perfil; $this->perfil = $perfil;
$this->cargaDatosURL();
} }
public function ejecuta() { /**
$opc = $_GET['opc']; * Carga en los atributos de la clase los datos de la URL
$id = $_GET['id']; * Los datos constantes en la URL son:
$orden = isset($_GET['orden']) ? $_GET['orden'] : ''; * - opc = {inicial, editar, eliminar, nuevo, insertar, modificar, borrar}
$sentido = isset($_GET['sentido']) ? $_GET['sentido'] : 'asc'; * - orden = {id, ... } nombre del campo por el que se ordena la visualización
//Sólo tiene sentido para las modificaciones. * - sentido = {asc, desc}
//Es la página donde estaba el registro * - pag = nº página 0, 1, 2, ...
$pag = isset($_GET['pag']) ? $_GET['pag'] : '0'; * Los datos opcionales de la URL son:
$this->cadenaBusqueda = $_GET['buscar']; * - buscar = cadena de búsqueda
* - id = nº de la clave necesario para la edición o el borrado
*/
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->cadenaBusqueda = isset($_GET['buscar']) ? $_GET['buscar'] : null;
$this->cadenaBusqueda = isset($_POST['buscar']) ? $_POST['buscar'] : $this->cadenaBusqueda;
$this->datosURL['buscar'] = $this->cadenaBusqueda;
$this->datosURL['id'] = isset($_GET['id']) ? $_GET['id'] : null;
}
public function backupURL()
{
$this->datosURLb = $this->datosURL;
}
public function restoreURL()
{
$this->datosURL = $this->datosURLb;
}
//Monta una URL con los datos cargados en los atributos de la clase
private function montaURL()
{
//Primero los datos obligatorios
$opc = "&opc=" . $this->datosURL['opc'];
$orden = "&orden=" . $this->datosURL['orden'];
$sentido = "&sentido=" . $this->datosURL['sentido'];
$pag = "&pag=" . $this->datosURL['pag'];
//Ahora los datos opcionales
$buscar = isset($this->cadenaBusqueda) ? "&buscar=$this->cadenaBusqueda" : null;
$id = isset($this->datosURL['id']) ? "&id=" . $this->datosURL['id'] : null;
$enlace = $this->url . $opc . $orden . $sentido . $pag . $buscar . $id;
return $enlace;
}
public function ejecuta()
{
$this->obtenerCampos(); $this->obtenerCampos();
$this->obtieneClavesForaneas(); $this->obtieneClavesForaneas();
switch ($opc) { switch ($this->datosURL['opc']) {
case 'inicial':return $this->consulta($id, $orden, $sentido); case 'inicial':return $this->consulta();
case 'editar':return $this->muestra($id, EDICION, $pag, $orden, $sentido); case 'editar':return $this->muestra(EDICION);
case 'eliminar':return $this->muestra($id, BORRADO); case 'eliminar':return $this->muestra(BORRADO);
case 'nuevo':return $this->muestra(null, ANADIR); case 'nuevo':return $this->muestra(ANADIR);
case 'insertar':return $this->insertar(); case 'insertar':return $this->insertar();
case 'modificar':return $this->modificar($id, $pag, $orden, $sentido); case 'modificar':return $this->modificar();
case 'borrar':return $this->borrar($id); case 'borrar':return $this->borrar();
default:return 'La clase Mantenimiento No entiende lo solicitado.'; default: return "La clase Mantenimiento No entiende lo solicitado [" . $this->datosURL['opc'] . "]";
} }
} }
protected function obtieneClavesForaneas() { protected function obtieneClavesForaneas()
{
$salida = null; $salida = null;
foreach ($this->campos as $clave => $valor) { foreach ($this->campos as $clave => $valor) {
$trozos = explode(",", $valor["Comment"]); $trozos = explode(",", $valor["Comment"]);
@@ -87,20 +132,21 @@ class Mantenimiento {
$this->foraneas = $salida; $this->foraneas = $salida;
} }
private function consulta($pagina, $orden, $sentido) { private function consulta()
{
$orden = $this->datosURL['orden'];
$sentido = $this->datosURL['sentido'];
//Calcula los números de página anterior y siguiente. //Calcula los números de página anterior y siguiente.
$pagina = $pagina + 0; $pagina = $this->datosURL['pag'];
$pagSigte = $pagina <= 0 ? 1 : $pagina + 1; $pagSigte = $pagina <= 0 ? 1 : $pagina + 1;
$pagAnt = $pagSigte - 2; $pagAnt = $pagSigte - 2 < 0 ? 0 : $pagSigte -2;
$pagFwd = $pagSigte + 3; $pagFwd = $pagSigte + 3;
$pagRew = $pagAnt - 3 < 0 ? $pagAnt : $pagAnt - 3; $pagRew = $pagAnt - 3 < 0 ? 0 : $pagAnt - 3;
//Tengo que procesar la cabecera antes de lo de la cadena de búsqueda por el tema de las búsquedas //Tengo que procesar la cabecera antes de lo de la cadena de búsqueda por el tema de las búsquedas
$cabecera = $this->cabeceraTabla(); $cabecera = $this->cabeceraTabla();
//Trata con la cadena de búsqueda //Trata con la cadena de búsqueda si viene del post debe quedarse con ella sino con la del get y si no está definida => vacía
$this->cadenaBusqueda = isset($_POST['buscar']) ? $_POST['buscar'] : $this->cadenaBusqueda;
if (isset($this->cadenaBusqueda) && strlen($this->cadenaBusqueda)) { if (isset($this->cadenaBusqueda) && strlen($this->cadenaBusqueda)) {
$sufijo = " where $this->campoBusca like '%" . $this->bdd->filtra($this->cadenaBusqueda) . "%'"; $sufijo = " where $this->campoBusca like '%" . $this->bdd->filtra($this->cadenaBusqueda) . "%'";
$sufijoEnlace = "&buscar=" . $this->cadenaBusqueda;
$comando = str_replace('{buscar}', $sufijo, $this->comandoConsulta); $comando = str_replace('{buscar}', $sufijo, $this->comandoConsulta);
} else { } else {
$comando = str_replace('{buscar}', '', $this->comandoConsulta); $comando = str_replace('{buscar}', '', $this->comandoConsulta);
@@ -114,35 +160,34 @@ class Mantenimiento {
} }
//Introduce un botón para hacer búsquedas y el número de la página //Introduce un botón para hacer búsquedas y el número de la página
$salida = $this->enlaceBusqueda($pagSigte); $salida = $this->enlaceBusqueda($pagSigte);
//Esta orden de centrado se cierra en el pie de la tabla
//$salida.='<center><h4>P&aacute;gina ' . $pagSigte . '</h4>';
// $salida .='<div class="nav-bar navbar-fixed"><ul class="nav nav-pills nav-stacked">
// <li class="active">
// <a href="#">
// <span class="badge pull-right">' . $pagSigte . '</span>
// P&aacute;gina
// </a>
// </li>
// </ul></div>';
$salida.= $cabecera; $salida.= $cabecera;
//Consulta paginada de todas las tuplas //Consulta paginada de todas las tuplas
$comando = str_replace('{inferior}', ($pagAnt + 1) * NUMFILAS, $comando); $comando = str_replace('{inferior}', $pagina * NUMFILAS, $comando);
$comando = str_replace('{superior}', NUMFILAS, $comando); $comando = str_replace('{superior}', NUMFILAS, $comando);
//$salida.=$comando;
$tabla = strtolower($this->tabla); $tabla = strtolower($this->tabla);
$this->bdd->ejecuta($comando); $this->bdd->ejecuta($comando);
$numRegistros = $this->bdd->numeroTotalTuplas();
//Si el número de la página fwd es mayor que el total de páginas lo establece a éste
if (NUMFILAS > 0) {
$totalPags = (int) ($numRegistros / NUMFILAS) - 1;
if ($numRegistros % NUMFILAS) {
$totalPags++;
}
} else {
$totalPags = 0;
}
$pagFwd = $pagFwd > $totalPags ? $totalPags : $pagFwd;
if ($this->bdd->numeroTuplas() == 0) { if ($this->bdd->numeroTuplas() == 0) {
if ($pagSigte > 1) { if ($pagSigte > 1) {
// Si no hay datos en la consulta y no es la primera página, // Si no hay datos en la consulta y no es la primera página,
// carga la página inicial // carga la página final
header('Location: ' . $this->url); $this->datosURL['pag'] = $totalPags;
header('Location: ' . $this->montaURL());
} else { } else {
$salida = "<p align=\"center\"><center><h2>No hay registros</h2></center></p><br>"; $salida = "<p align=\"center\"><center><h2>No hay registros</h2></center></p><br>";
} }
} }
//$salida.=print_r($this->perfil);
//$salida.=$comando; //$salida.=$comando;
//var_dump($this->campos);
while ($fila = $this->bdd->procesaResultado()) { while ($fila = $this->bdd->procesaResultado()) {
$salida.='<tr align="center" bottom="middle">'; $salida.='<tr align="center" bottom="middle">';
foreach ($fila as $clave => $valor) { foreach ($fila as $clave => $valor) {
@@ -169,37 +214,56 @@ class Mantenimiento {
} }
//Añade el icono de editar //Añade el icono de editar
if ($this->perfil['Modificacion']) { if ($this->perfil['Modificacion']) {
$salida.='<td><a href="index.php?' . $tabla . '&opc=editar&id=' . $id . "&pag=" . $pagina . $sufijoOrden . //$salida.='<td><a href="index.php?' . $tabla . '&opc=editar&id=' . $id . "&pag=" . $pagina . $sufijoOrden . $sufijoEnlace .
$this->backupURL(); $this->datosURL['opc'] = "editar"; $this->datosURL['id'] = $id;
$salida.='<td><a href="' . $this->montaURL() .
'"><img title="Editar" src="img/' . ESTILO . '/editar.png" alt="editar"></a>'; '"><img title="Editar" src="img/' . ESTILO . '/editar.png" alt="editar"></a>';
$this->restoreURL();
} }
//Añade el icono de eliminar //Añade el icono de eliminar
if ($this->perfil['Borrado']) { if ($this->perfil['Borrado']) {
$salida.='&nbsp;&nbsp;<a href="index.php?' . $tabla . '&opc=eliminar&id=' . $id . //$salida.='&nbsp;&nbsp;<a href="index.php?' . $tabla . '&opc=eliminar&id=' . $id . $sufijoEnlace .
$this->backupURL(); $this->datosURL['opc'] = "eliminar"; $this->datosURL['id'] = $id;
$salida.='&nbsp;&nbsp;<a href="' . $this->montaURL() .
'"><img title="Eliminar" src="img/' . ESTILO . '/eliminar.png" alt="eliminar"></a></td></tr>' . "\n"; '"><img title="Eliminar" src="img/' . ESTILO . '/eliminar.png" alt="eliminar"></a></td></tr>' . "\n";
$this->restoreURL();
} }
} }
$salida.="</tbody></table></center></p>"; $salida.="</tbody></table></center></p>";
//Añade botones de comandos //Añade botones de comandos
$enlace = '<a href="' . $this->url . $sufijoOrden . '&id=';
if ($this->bdd->numeroTuplas()) { if ($numRegistros) {
$anterior = $enlace . $pagAnt . $sufijoEnlace . "\"><img title=\"Pag. Anterior\" alt=\"anterior\" src=\"img/" . ESTILO . "/anterior.png\"></a>\n"; $this->backupURL();
$siguiente = $enlace . $pagSigte . $sufijoEnlace . "\"><img title=\"Pag. Siguiente\" alt=\"siguiente\" src=\"img/" . ESTILO . "/siguiente.png\"></a>\n"; $this->datosURL['pag'] = $pagAnt;
$fwd = $enlace . $pagFwd . $sufijoEnlace . "\"><img title=\"+5 Pags.\" alt=\"mas5p\" src=\"img/" . ESTILO . "/fwd.png\"></a>\n"; $anterior = $this->montaURL();
$rew = $enlace . $pagRew . $sufijoEnlace . "\"><img title=\"-5 Pags.\" alt=\"menos5p\" src=\"img/" . ESTILO . "/rew.png\"></a>\n"; $this->datosURL['pag'] = $pagSigte;
if (strlen($orden) > 0) { $siguiente = $this->montaURL();
$az = '<a href="' . $this->url . '&orden=' . $orden . '&sentido=asc"><img alt="asc" title="Orden ascendente" src="img/' . ESTILO . '/ascendente.png"></a>'; $this->datosURL['pag'] = $pagFwd;
$za = '<a href="' . $this->url . '&orden=' . $orden . '&sentido=desc"><img alt="desc" title="Orden descendente" src="img/' . ESTILO . '/descendente.png"></a>'; $fwd = $this->montaURL();
} else { $this->datosURL['pag'] = $pagRew;
$az = $za = ''; $rew = $this->montaURL();
} $anterior = '<a href="' . $anterior . "\"><img title=\"Pag. Anterior\" alt=\"anterior\" src=\"img/" . ESTILO . "/anterior.png\"></a>\n";
$siguiente = '<a href="' . $siguiente . "\"><img title=\"Pag. Siguiente\" alt=\"siguiente\" src=\"img/" . ESTILO . "/siguiente.png\"></a>\n";
$fwd = '<a href="' . $fwd . "\"><img title=\"+4 Pags.\" alt=\"mas4pags\" src=\"img/" . ESTILO . "/fwd.png\"></a>\n";
$rew = '<a href="' . $rew . "\"><img title=\"-4 Pags.\" alt=\"menos4pags\" src=\"img/" . ESTILO . "/rew.png\"></a>\n";
$this->restoreURL();
$this->datosURL['sentido'] = "asc";
$az = $this->montaURL();
$az = '<a href="' . $az . '"><img alt="asc" title="Orden ascendente" src="img/' . ESTILO . '/ascendente.png"></a>';
$this->datosURL['sentido'] = "desc";
$za = $this->montaURL();
$za = '<a href="' . $za . '"><img alt="desc" title="Orden descendente" src="img/' . ESTILO . '/descendente.png"></a>';
$this->restoreURL();
if ($this->perfil['Informe']) { 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>'; $informe = '<a href="index.php?' . $tabla . '&opc=informe" target="_blank"><img src="img/' . ESTILO . '/informe.png" alt="informe" title="Informe pdf"></a>';
} else { } else {
$informe = ""; $informe = "";
} }
$this->restoreURL();
} }
if ($this->perfil['Alta']) { if ($this->perfil['Alta']) {
$anadir = '<a href="index.php?' . $tabla . '&opc=nuevo">' . $this->datosURL['opc'] = 'nuevo';
$anadir = '<a href="' . $this->montaURL() . '">' .
'<img title="A&ntilde;adir registro" alt="nuevo" src="img/' . ESTILO . '/nuevo.png"></a>'; '<img title="A&ntilde;adir registro" alt="nuevo" src="img/' . ESTILO . '/nuevo.png"></a>';
} else { } else {
$anadir = ""; $anadir = "";
@@ -209,39 +273,35 @@ class Mantenimiento {
return $salida; return $salida;
} }
private function enlaceBusqueda($pagina) { private function enlaceBusqueda($pagina)
//$salida = '<p align="center">'; {
//$salida .='<center><form name="busqueda" method="POST"><input type="text" class="form-control" name="buscar"'; $valor = isset($this->cadenaBusqueda) ? 'value="' . $this->cadenaBusqueda . '"' : '';
//$salida .='value="' . $this->cadenaBusqueda . '" size="40" /><input type="submit" class="btn btn-primary" value="Buscar" name='; $salida = '<form name="busqueda" method="POST"><div class="col-xs-6 col-sm-4 col-md-6 col-lg-6"><div class="input-group">
//$salida .='"Buscar" />'; <input type="text" name="buscar" placeholder="Descripci&oacute;n" class="form-control" ' . $valor . '>
//$salida .= '</form></center>';
//$salida.='</p>';
$salida = '<form name="busqueda" method="POST"><div class="col-sm-4 col-lg-6"><div class="input-group">
<input type="text" name="buscar" placeholder="Descripci&oacute;n" class="form-control">
<span class="input-group-btn"><button class="btn btn-primary" type="button">Buscar</button> <span class="input-group-btn"><button class="btn btn-primary" type="button">Buscar</button>
</span></div></div></form>'; </span></div></div></form>';
//$salida .= '<div class="col-lg-1 pull-right"><ul class="nav nav-pills nav-stacked "><li class="active">
// <a href="#"><span class="badge pull-right">'.$pagina.'</span>P&aacute;gina</a></li></ul></div>';
$salida .= '<button class="btn btn-info pull-right" type="button">P&aacute;gina <span class="badge">' $salida .= '<button class="btn btn-info pull-right" type="button">P&aacute;gina <span class="badge">'
. $pagina . '</span></button>'; . $pagina . '</span></button>';
// $salida .= '<div class="progress progress-striped">
// <div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100" style="width: 20%">
// P&aacute;gina 5 de 6<span class="sr-only">20% Complete</span>
// </div>
//</div>';
return $salida; return $salida;
} }
protected function borrar($id) { protected function borrar()
{
//@todo hay que tener en cuenta aquí la cadena de búsqueda y la página en la url
$id = $this->datosURL['id'];
$comando = "delete from " . $this->tabla . " where id=\"$id\""; $comando = "delete from " . $this->tabla . " where id=\"$id\"";
if (!$this->bdd->ejecuta($comando)) { if (!$this->bdd->ejecuta($comando)) {
return $this->errorBD($comando); return $this->errorBD($comando);
} }
header('Location: ' . $this->url); $this->datosURL['opc'] = 'inicial';
$this->datosURL['id'] = null;
$url = $this->montaURL();
header('Location: ' . $url);
return; return;
} }
protected function insertar() { protected function insertar()
{
$comando = "insert into " . $this->tabla . " ("; $comando = "insert into " . $this->tabla . " (";
$lista = explode("&", $_POST['listacampos']); $lista = explode("&", $_POST['listacampos']);
$primero = true; $primero = true;
@@ -285,19 +345,23 @@ class Mantenimiento {
if (!$this->bdd->ejecuta($comando)) { if (!$this->bdd->ejecuta($comando)) {
return $this->errorBD($comando); return $this->errorBD($comando);
} }
list($enlace, $resto) = explode("&", $this->url); $this->datosURL['opc'] = 'inicial';
$enlace.="&opc=inicial"; $this->datosURL['id'] = null;
return "<h1><a href=\"$enlace\">Se ha insertado el registro con la clave " . $this->bdd->ultimoId() . "</a></h1>"; $cabecera = "refresh:".PAUSA.";url=".$this->montaURL();
header($cabecera);
return $this->panelMensaje("Se ha insertado el registro con la clave " . $this->bdd->ultimoId(), "info", "Informaci&oacute;n");
//return "<h1><a href=\"".$this->montaURL()."\">Se ha insertado el registro con la clave " . $this->bdd->ultimoId() . "</a></h1>";
} }
protected function modificar($id, $pag, $orden, $sentido) { protected function modificar()
{
//Los datos a utilizar para actualizar la tupla vienen en $_POST. //Los datos a utilizar para actualizar la tupla vienen en $_POST.
//La lista de atributos de la tupla viene en el campo oculto listacampos //La lista de atributos de la tupla viene en el campo oculto listacampos
//print_r($_GET); //print_r($_GET);
//echo "id=$id pag=$pag orden=$orden sentido=$sentido";die(); //echo "id=$id pag=$pag orden=$orden sentido=$sentido";die();
//@todo hay que tener en cuenta aquí la página en la que se encuentra y la cadena de búsqueda
$comando = "update " . $this->tabla . " set "; $comando = "update " . $this->tabla . " set ";
$lista = explode("&", $_POST['listacampos']); $lista = explode("&", $_POST['listacampos']);
//var_dump($lista);
$primero = true; $primero = true;
foreach ($lista as $campo) { foreach ($lista as $campo) {
if ($campo == "id" || $campo == "") if ($campo == "id" || $campo == "")
@@ -323,20 +387,20 @@ class Mantenimiento {
} }
} }
} }
$comando.=" where id=\"$id\""; $comando.=" where id=\"" . $this->datosURL['id'] . "\"";
if (!$this->bdd->ejecuta($comando)) { if (!$this->bdd->ejecuta($comando)) {
return $this->errorBD($comando); return $this->errorBD($comando);
} }
$this->datosURL['id'] = null;
list($enlace, $resto) = explode("&", $this->url); $this->datosURL['opc'] = inicial;
$enlace.="&opc=inicial&orden=" . $orden . "&sentido=" . $sentido . "&id=" . $pag; header('Location: ' . $this->montaURL());
//echo $comando;
header('Location: ' . $enlace);
return; return;
} }
protected function muestra($id, $tipoAccion, $pag = "", $orden = "", $sentido = "") { protected function muestra($tipoAccion)
if (isset($id)) { {
$id = $this->datosURL['id'];
if ($tipoAccion != ANADIR) {
$comando = "select * from " . $this->tabla . " where id='$id'"; $comando = "select * from " . $this->tabla . " where id='$id'";
$resultado = $this->bdd->ejecuta($comando); $resultado = $this->bdd->ejecuta($comando);
if (!$resultado) { if (!$resultado) {
@@ -346,29 +410,14 @@ class Mantenimiento {
} else { } else {
$fila = null; $fila = null;
} }
//list($tipo,$valor)=explode($columna["Type"]);
$accion = "index.php?" . strtolower($this->tabla) . "&id=$id&opc=";
switch ($tipoAccion) {
case EDICION:
$accion.="modificar";
$accion.=isset($pag) ? "&pag=$pag" : '';
$accion.=isset($orden) ? "&orden=$orden" : '';
$accion.=isset($sentido) ? "&sentido=$sentido" : '';
break;
case BORRADO:
$accion.="borrar";
break;
case ANADIR:
$accion.="insertar";
break;
}
//Genera un formulario con los datos de la tupla seleccionada. //Genera un formulario con los datos de la tupla seleccionada.
return $this->formularioCampos($accion, $tipoAccion, $fila); return $this->formularioCampos($tipoAccion, $fila);
} }
//Función que genera un campo de lista con los valores de descripción de la //Función que genera un campo de lista con los valores de descripción de la
//tabla a la cual pertenece la clave foránea. //tabla a la cual pertenece la clave foránea.
protected function generaLista($datos, $campo, $valorInicial, $modo) { protected function generaLista($datos, $campo, $valorInicial, $modo)
{
$salida = "<select class=\"form-control\" name=\"$campo\">\n"; $salida = "<select class=\"form-control\" name=\"$campo\">\n";
list($tabla, $atributos) = explode(",", $datos); list($tabla, $atributos) = explode(",", $datos);
$atributos = str_replace("/", ",", $atributos); $atributos = str_replace("/", ",", $atributos);
@@ -401,7 +450,8 @@ class Mantenimiento {
return $salida; return $salida;
} }
private function obtenerCampos() { private function obtenerCampos()
{
//Si hay un fichero de descripción xml lo utiliza. //Si hay un fichero de descripción xml lo utiliza.
$nombre = "xml/mantenimiento" . $this->tabla . ".xml"; $nombre = "xml/mantenimiento" . $this->tabla . ".xml";
if (file_exists($nombre)) { if (file_exists($nombre)) {
@@ -420,11 +470,12 @@ class Mantenimiento {
$this->campos[$datos[$i]["Field"]]["Campo"] = $datos[$i]["Field"]; $this->campos[$datos[$i]["Field"]]["Campo"] = $datos[$i]["Field"];
$this->campos[$datos[$i]["Field"]]["Editable"] = "si"; $this->campos[$datos[$i]["Field"]]["Editable"] = "si";
} }
$this->comandoConsulta = "select * from " . $this->tabla . " {buscar} {orden} limit {inferior},{superior}"; $this->comandoConsulta = "select SQL_CALC_FOUND_ROWS * from " . $this->tabla . " {buscar} {orden} limit {inferior},{superior}";
} }
} }
private function cabeceraTabla() { private function cabeceraTabla()
{
//$salida = '<p align="center"><table border=1 class="tablaDatos"><tbody>'; //$salida = '<p align="center"><table border=1 class="tablaDatos"><tbody>';
$salida = '<p align="center"><table border=1 class="table table-striped table-bordered table-condensed table-hover"><tbody>'; $salida = '<p align="center"><table border=1 class="table table-striped table-bordered table-condensed table-hover"><tbody>';
foreach ($this->campos as $clave => $datos) { foreach ($this->campos as $clave => $datos) {
@@ -444,7 +495,10 @@ class Mantenimiento {
$clave = str_ireplace("ubicacion", "Ubicaci&oacute;n", $clave); $clave = str_ireplace("ubicacion", "Ubicaci&oacute;n", $clave);
$clave = str_ireplace("articulo", "Art&iacute;culo", $clave); $clave = str_ireplace("articulo", "Art&iacute;culo", $clave);
if ($ordenable) { if ($ordenable) {
$salida.="<th><b><a title=\"Establece orden por $clave \" href=\"$this->url&orden=" . strtolower($clave2) . "\"> " . ucfirst($clave) . " </a></b></th>\n"; $this->backupURL();
$this->datosURL['orden'] = $clave2;
$salida.="<th><b><a title=\"Establece orden por $clave \" href=\"". $this->montaURL() . "\"> " . ucfirst($clave) . " </a></b></th>\n";
$this->restoreURL();
} else { } else {
$salida.='<th><b>' . ucfirst($clave) . '</b></th>' . "\n"; $salida.='<th><b>' . ucfirst($clave) . '</b></th>' . "\n";
} }
@@ -456,14 +510,26 @@ class Mantenimiento {
/** /**
* *
* @param string $accion URL de la acción del POST * @param string $tipo ANADIR,EDICION,BORRADO
* @param string $tipo ANADIR,EDITAR,BORRADO
* @param array $datos Vector con los datos del registro * @param array $datos Vector con los datos del registro
* @return array lista de campos y formulario de entrada * @return array lista de campos y formulario de entrada
*/ */
private function formularioCampos($accion, $tipo, $datos) { private function formularioCampos($tipo, $datos)
{
$modo = $tipo == BORRADO ? "readonly" : ""; $modo = $tipo == BORRADO ? "readonly" : "";
$nfechas = 0; $nfechas = 0;
switch ($tipo) {
case ANADIR:
$this->datosURL['opc'] = "insertar"; $this->datosURL['id'] = null;
break;
case EDICION:
$this->datosURL['opc'] = "modificar";
break;
case BORRADO:
$this->datosURL['opc'] = "borrar";
break;
}
$accion = $this->montaURL();
$salida.='<div class="col-sm-8"><form name="mantenimiento.form" class="form-horizontal" role="form" method="post" action="' . $accion . '">' . "\n"; $salida.='<div class="col-sm-8"><form name="mantenimiento.form" class="form-horizontal" role="form" method="post" action="' . $accion . '">' . "\n";
$salida.="<fieldset style=\"width: 96%;\"><p><legend style=\"color: red;\"><b>$tipo</b></legend>\n"; $salida.="<fieldset style=\"width: 96%;\"><p><legend style=\"color: red;\"><b>$tipo</b></legend>\n";
foreach ($this->campos as $clave => $valor) { foreach ($this->campos as $clave => $valor) {
@@ -497,9 +563,6 @@ class Mantenimiento {
$tamano = "19"; $tamano = "19";
$tipo_campo = "datetime"; $tipo_campo = "datetime";
$nfechas++; $nfechas++;
//
//Prueba
//
$salida .= '<div class="input-group date" id="datetimepicker' . $nfechas . '"> $salida .= '<div class="input-group date" id="datetimepicker' . $nfechas . '">
<input type="text" name="' . $campo . '" data-format="YYYY/MM/DD" value="' . $valorDato . '" ' . $modoEfectivo . ' class="form-control" /> <input type="text" name="' . $campo . '" data-format="YYYY/MM/DD" value="' . $valorDato . '" ' . $modoEfectivo . ' class="form-control" />
<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span> <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
@@ -524,7 +587,6 @@ class Mantenimiento {
} }
if ($tipoCampo == "Boolean(1)") { if ($tipoCampo == "Boolean(1)") {
$checked = $valorDato == '1' ? 'checked' : ''; $checked = $valorDato == '1' ? 'checked' : '';
//$salida .= '<div class="checkbox">';
$modocheck = $modoEfectivo == "readonly" ? 'onclick="javascript: return false;" readonly ' : ''; $modocheck = $modoEfectivo == "readonly" ? 'onclick="javascript: return false;" readonly ' : '';
$salida .= '<input type="checkbox" name="' . $campo . '" ' . $checked . ' ' . $modocheck . ' class="form-control">'; $salida .= '<input type="checkbox" name="' . $campo . '" ' . $checked . ' ' . $modocheck . ' class="form-control">';
$salida .= '</div></div>'; $salida .= '</div></div>';
@@ -543,21 +605,33 @@ class Mantenimiento {
$salida .= '<input name="listacampos" type="hidden" value="' . $campos . "\">\n"; $salida .= '<input name="listacampos" type="hidden" value="' . $campos . "\">\n";
$salida .= "</fieldset><p>"; $salida .= "</fieldset><p>";
$salida .= '<center>'; $salida .= '<center>';
$salida .= '<button type="button" onClick="location.href=' . "'$this->url'" . '" class="btn btn-info">Volver</button>'; $this->datosURL['opc'] = 'inicial';
$salida .= '<button type="button" onClick="location.href=' . "'" . $this->montaURL() . "'" . '" class="btn btn-info">Volver</button>';
$salida .= '&nbsp;&nbsp;<button type="reset" class="btn btn-danger">Cancelar</button>'; $salida .= '&nbsp;&nbsp;<button type="reset" class="btn btn-danger">Cancelar</button>';
$salida .= '&nbsp;&nbsp;<button type=submit class="btn btn-primary">Aceptar</button>'; $salida .= '&nbsp;&nbsp;<button type=submit class="btn btn-primary">Aceptar</button>';
$salida .= '<br></center></div>'; $salida .= '<br></center></div>';
return $salida; return $salida;
} }
protected function errorBD($comando, $mensaje = "") { protected function errorBD($comando, $texto = "", $tipo = "danger", $cabecera = "&iexcl;Atenci&oacute;n!")
if (!$mensaje) { {
return "<h1>No pudo ejecutar correctamente el comando $comando error=" . $this->bdd->mensajeError() . " </h1>"; if (!$texto) {
$texto = "No pudo ejecutar correctamente el comando $comando error=" . $this->bdd->mensajeError();
} else { } else {
return "<h1>$mensaje error=" . $this->bdd->mensajeError() . "</h1>"; $texto = "$texto error=" . $this->bdd->mensajeError();
} }
return $this->panelMensaje($texto, "danger", $cabecera="&iexcl;Error!");
} }
private function panelMensaje($info, $tipo = "danger", $cabecera = "&iexcl;Atenci&oacute;n!") {
$mensaje = '<div class="panel panel-' . $tipo . '"><div class="panel-heading">';
$mensaje .= '<h3 class="panel-title">' . $cabecera . '</h3></div>';
$mensaje .= '<div class="panel-body">';
$mensaje .= $info;
$mensaje .= '</div>';
$mensaje .= '</div>';
return $mensaje;
}
} }
?> ?>

View File

@@ -61,7 +61,7 @@ class Pdf_mysql_table extends Fpdf
//Titulo //Titulo
$fecha=strftime("%d-%b-%Y %H:%M"); $fecha=strftime("%d-%b-%Y %H:%M");
$this->SetFont('Arial','',8); $this->SetFont('Arial','',8);
$this->Cell(0,4,html_entity_decode(CENTRO . " " . APLICACION,ENT_COMPAT | ENT_HTML401,'ISO-8859-1'),0,1,'L'); $this->Cell(0,4,html_entity_decode(CENTRO . " " . PROGRAMA . VERSION,ENT_COMPAT | ENT_HTML401,'ISO-8859-1'),0,1,'L');
$this->SetFont('Arial','',18); $this->SetFont('Arial','',18);
$this->Cell(0,6,utf8_decode($this->titulo),0,1,'C'); $this->Cell(0,6,utf8_decode($this->titulo),0,1,'C');
$this->SetFont('Arial','',8); $this->SetFont('Arial','',8);

16
Sql.php
View File

@@ -152,6 +152,22 @@ class Sql {
public function numeroTuplas() { public function numeroTuplas() {
return $this->numero; return $this->numero;
} }
/**
* Devuelve el número de tuplas total si se ha hecho una consulta select
* con SELECT SQL_CALC_FOUND_ROWS * ...
* @return integer Número de tuplas.
*/
public function numeroTotalTuplas()
{
$comando = "select found_rows();";
if (!$peticion=$this->bdd->query($comando)) {
$this->error=true;
$this->mensajeError='No pudo ejecutar la petici&oacute;n: '.$comando;
return false;
}
$numero = $peticion->fetch_row();
return $numero[0] ;
}
/** /**
* Devuelve la condición de error de la última petición * Devuelve la condición de error de la última petición
* @return boolean condición de error. * @return boolean condición de error.

File diff suppressed because one or more lines are too long

View File

@@ -226,4 +226,5 @@
<glyph unicode="&#xe199;" d="M100 200h400v-155l-75 -45h350l-75 45v155h400l-270 300h170l-270 300h170l-300 333l-300 -333h170l-270 -300h170z" /> <glyph unicode="&#xe199;" d="M100 200h400v-155l-75 -45h350l-75 45v155h400l-270 300h170l-270 300h170l-300 333l-300 -333h170l-270 -300h170z" />
<glyph unicode="&#xe200;" d="M121 700q0 -53 28.5 -97t75.5 -65q-4 -16 -4 -38q0 -74 52.5 -126.5t126.5 -52.5q56 0 100 30v-306l-75 -45h350l-75 45v306q46 -30 100 -30q74 0 126.5 52.5t52.5 126.5q0 24 -9 55q50 32 79.5 83t29.5 112q0 90 -61.5 155.5t-150.5 71.5q-26 89 -99.5 145.5 t-167.5 56.5q-116 0 -197.5 -81.5t-81.5 -197.5q0 -4 1 -11.5t1 -11.5q-14 2 -23 2q-74 0 -126.5 -52.5t-52.5 -126.5z" /> <glyph unicode="&#xe200;" d="M121 700q0 -53 28.5 -97t75.5 -65q-4 -16 -4 -38q0 -74 52.5 -126.5t126.5 -52.5q56 0 100 30v-306l-75 -45h350l-75 45v306q46 -30 100 -30q74 0 126.5 52.5t52.5 126.5q0 24 -9 55q50 32 79.5 83t29.5 112q0 90 -61.5 155.5t-150.5 71.5q-26 89 -99.5 145.5 t-167.5 56.5q-116 0 -197.5 -81.5t-81.5 -197.5q0 -4 1 -11.5t1 -11.5q-14 2 -23 2q-74 0 -126.5 -52.5t-52.5 -126.5z" />
</font> </font>
</defs></svg> </defs>
</svg>

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 64 KiB

View File

@@ -4,7 +4,9 @@
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/ */
if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript requires jQuery') } if (typeof jQuery === 'undefined') {
throw new Error('Bootstrap\'s JavaScript requires jQuery')
}
/* ======================================================================== /* ========================================================================
* Bootstrap: transition.js v3.1.1 * Bootstrap: transition.js v3.1.1
@@ -43,8 +45,13 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
// http://blog.alexmaccaw.com/css-transitions // http://blog.alexmaccaw.com/css-transitions
$.fn.emulateTransitionEnd = function(duration) { $.fn.emulateTransitionEnd = function(duration) {
var called = false, $el = this var called = false, $el = this
$(this).one($.support.transition.end, function () { called = true }) $(this).one($.support.transition.end, function() {
var callback = function () { if (!called) $($el).trigger($.support.transition.end) } called = true
})
var callback = function() {
if (!called)
$($el).trigger($.support.transition.end)
}
setTimeout(callback, duration) setTimeout(callback, duration)
return this return this
} }
@@ -86,7 +93,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
var $parent = $(selector) var $parent = $(selector)
if (e) e.preventDefault() if (e)
e.preventDefault()
if (!$parent.length) { if (!$parent.length) {
$parent = $this.hasClass('alert') ? $this : $this.parent() $parent = $this.hasClass('alert') ? $this : $this.parent()
@@ -94,7 +102,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
$parent.trigger(e = $.Event('close.bs.alert')) $parent.trigger(e = $.Event('close.bs.alert'))
if (e.isDefaultPrevented()) return if (e.isDefaultPrevented())
return
$parent.removeClass('in') $parent.removeClass('in')
@@ -120,8 +129,10 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
var $this = $(this) var $this = $(this)
var data = $this.data('bs.alert') var data = $this.data('bs.alert')
if (!data) $this.data('bs.alert', (data = new Alert(this))) if (!data)
if (typeof option == 'string') data[option].call($this) $this.data('bs.alert', (data = new Alert(this)))
if (typeof option == 'string')
data[option].call($this)
}) })
} }
@@ -177,7 +188,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
state = state + 'Text' state = state + 'Text'
if (!data.resetText) $el.data('resetText', $el[val]()) if (!data.resetText)
$el.data('resetText', $el[val]())
$el[val](data[state] || this.options[state]) $el[val](data[state] || this.options[state])
@@ -200,13 +212,17 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
if ($parent.length) { if ($parent.length) {
var $input = this.$element.find('input') var $input = this.$element.find('input')
if ($input.prop('type') == 'radio') { if ($input.prop('type') == 'radio') {
if ($input.prop('checked') && this.$element.hasClass('active')) changed = false if ($input.prop('checked') && this.$element.hasClass('active'))
else $parent.find('.active').removeClass('active') changed = false
else
$parent.find('.active').removeClass('active')
} }
if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change') if (changed)
$input.prop('checked', !this.$element.hasClass('active')).trigger('change')
} }
if (changed) this.$element.toggleClass('active') if (changed)
this.$element.toggleClass('active')
} }
@@ -221,10 +237,13 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
var data = $this.data('bs.button') var data = $this.data('bs.button')
var options = typeof option == 'object' && option var options = typeof option == 'object' && option
if (!data) $this.data('bs.button', (data = new Button(this, options))) if (!data)
$this.data('bs.button', (data = new Button(this, options)))
if (option == 'toggle') data.toggle() if (option == 'toggle')
else if (option) data.setState(option) data.toggle()
else if (option)
data.setState(option)
}) })
} }
@@ -245,7 +264,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
$(document).on('click.bs.button.data-api', '[data-toggle^=button]', function(e) { $(document).on('click.bs.button.data-api', '[data-toggle^=button]', function(e) {
var $btn = $(e.target) var $btn = $(e.target)
if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') if (!$btn.hasClass('btn'))
$btn = $btn.closest('.btn')
$btn.button('toggle') $btn.button('toggle')
e.preventDefault() e.preventDefault()
}) })
@@ -311,10 +331,15 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
var that = this var that = this
var activeIndex = this.getActiveIndex() var activeIndex = this.getActiveIndex()
if (pos > (this.$items.length - 1) || pos < 0) return if (pos > (this.$items.length - 1) || pos < 0)
return
if (this.sliding) return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) if (this.sliding)
if (activeIndex == pos) return this.pause().cycle() return this.$element.one('slid.bs.carousel', function() {
that.to(pos)
})
if (activeIndex == pos)
return this.pause().cycle()
return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos])) return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos]))
} }
@@ -333,12 +358,14 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
} }
Carousel.prototype.next = function() { Carousel.prototype.next = function() {
if (this.sliding) return if (this.sliding)
return
return this.slide('next') return this.slide('next')
} }
Carousel.prototype.prev = function() { Carousel.prototype.prev = function() {
if (this.sliding) return if (this.sliding)
return
return this.slide('prev') return this.slide('prev')
} }
@@ -351,15 +378,18 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
var that = this var that = this
if (!$next.length) { if (!$next.length) {
if (!this.options.wrap) return if (!this.options.wrap)
return
$next = this.$element.find('.item')[fallback]() $next = this.$element.find('.item')[fallback]()
} }
if ($next.hasClass('active')) return this.sliding = false if ($next.hasClass('active'))
return this.sliding = false
var e = $.Event('slide.bs.carousel', {relatedTarget: $next[0], direction: direction}) var e = $.Event('slide.bs.carousel', {relatedTarget: $next[0], direction: direction})
this.$element.trigger(e) this.$element.trigger(e)
if (e.isDefaultPrevented()) return if (e.isDefaultPrevented())
return
this.sliding = true this.sliding = true
@@ -383,7 +413,9 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
$next.removeClass([type, direction].join(' ')).addClass('active') $next.removeClass([type, direction].join(' ')).addClass('active')
$active.removeClass(['active', direction].join(' ')) $active.removeClass(['active', direction].join(' '))
that.sliding = false that.sliding = false
setTimeout(function () { that.$element.trigger('slid.bs.carousel') }, 0) setTimeout(function() {
that.$element.trigger('slid.bs.carousel')
}, 0)
}) })
.emulateTransitionEnd($active.css('transition-duration').slice(0, -1) * 1000) .emulateTransitionEnd($active.css('transition-duration').slice(0, -1) * 1000)
} else { } else {
@@ -411,10 +443,14 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option) var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option)
var action = typeof option == 'string' ? option : options.slide var action = typeof option == 'string' ? option : options.slide
if (!data) $this.data('bs.carousel', (data = new Carousel(this, options))) if (!data)
if (typeof option == 'number') data.to(option) $this.data('bs.carousel', (data = new Carousel(this, options)))
else if (action) data[action]() if (typeof option == 'number')
else if (options.interval) data.pause().cycle() data.to(option)
else if (action)
data[action]()
else if (options.interval)
data.pause().cycle()
}) })
} }
@@ -438,7 +474,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
var options = $.extend({}, $target.data(), $this.data()) var options = $.extend({}, $target.data(), $this.data())
var slideIndex = $this.attr('data-slide-to') var slideIndex = $this.attr('data-slide-to')
if (slideIndex) options.interval = false if (slideIndex)
options.interval = false
$target.carousel(options) $target.carousel(options)
@@ -478,8 +515,10 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
this.options = $.extend({}, Collapse.DEFAULTS, options) this.options = $.extend({}, Collapse.DEFAULTS, options)
this.transitioning = null this.transitioning = null
if (this.options.parent) this.$parent = $(this.options.parent) if (this.options.parent)
if (this.options.toggle) this.toggle() this.$parent = $(this.options.parent)
if (this.options.toggle)
this.toggle()
} }
Collapse.DEFAULTS = { Collapse.DEFAULTS = {
@@ -492,17 +531,20 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
} }
Collapse.prototype.show = function() { Collapse.prototype.show = function() {
if (this.transitioning || this.$element.hasClass('in')) return if (this.transitioning || this.$element.hasClass('in'))
return
var startEvent = $.Event('show.bs.collapse') var startEvent = $.Event('show.bs.collapse')
this.$element.trigger(startEvent) this.$element.trigger(startEvent)
if (startEvent.isDefaultPrevented()) return if (startEvent.isDefaultPrevented())
return
var actives = this.$parent && this.$parent.find('> .panel > .in') var actives = this.$parent && this.$parent.find('> .panel > .in')
if (actives && actives.length) { if (actives && actives.length) {
var hasData = actives.data('bs.collapse') var hasData = actives.data('bs.collapse')
if (hasData && hasData.transitioning) return if (hasData && hasData.transitioning)
return
actives.collapse('hide') actives.collapse('hide')
hasData || actives.data('bs.collapse', null) hasData || actives.data('bs.collapse', null)
} }
@@ -525,7 +567,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
this.$element.trigger('shown.bs.collapse') this.$element.trigger('shown.bs.collapse')
} }
if (!$.support.transition) return complete.call(this) if (!$.support.transition)
return complete.call(this)
var scrollSize = $.camelCase(['scroll', dimension].join('-')) var scrollSize = $.camelCase(['scroll', dimension].join('-'))
@@ -536,11 +579,13 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
} }
Collapse.prototype.hide = function() { Collapse.prototype.hide = function() {
if (this.transitioning || !this.$element.hasClass('in')) return if (this.transitioning || !this.$element.hasClass('in'))
return
var startEvent = $.Event('hide.bs.collapse') var startEvent = $.Event('hide.bs.collapse')
this.$element.trigger(startEvent) this.$element.trigger(startEvent)
if (startEvent.isDefaultPrevented()) return if (startEvent.isDefaultPrevented())
return
var dimension = this.dimension() var dimension = this.dimension()
@@ -563,7 +608,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
.addClass('collapse') .addClass('collapse')
} }
if (!$.support.transition) return complete.call(this) if (!$.support.transition)
return complete.call(this)
this.$element this.$element
[dimension](0) [dimension](0)
@@ -587,9 +633,12 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
var data = $this.data('bs.collapse') var data = $this.data('bs.collapse')
var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option) var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)
if (!data && options.toggle && option == 'show') option = !option if (!data && options.toggle && option == 'show')
if (!data) $this.data('bs.collapse', (data = new Collapse(this, options))) option = !option
if (typeof option == 'string') data[option]() if (!data)
$this.data('bs.collapse', (data = new Collapse(this, options)))
if (typeof option == 'string')
data[option]()
}) })
} }
@@ -620,7 +669,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
var $parent = parent && $(parent) var $parent = parent && $(parent)
if (!data || !data.transitioning) { if (!data || !data.transitioning) {
if ($parent) $parent.find('[data-toggle=collapse][data-parent="' + parent + '"]').not($this).addClass('collapsed') if ($parent)
$parent.find('[data-toggle=collapse][data-parent="' + parent + '"]').not($this).addClass('collapsed')
$this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed') $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
} }
@@ -653,7 +703,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
Dropdown.prototype.toggle = function(e) { Dropdown.prototype.toggle = function(e) {
var $this = $(this) var $this = $(this)
if ($this.is('.disabled, :disabled')) return if ($this.is('.disabled, :disabled'))
return
var $parent = getParent($this) var $parent = getParent($this)
var isActive = $parent.hasClass('open') var isActive = $parent.hasClass('open')
@@ -669,7 +720,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
var relatedTarget = {relatedTarget: this} var relatedTarget = {relatedTarget: this}
$parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget)) $parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget))
if (e.isDefaultPrevented()) return if (e.isDefaultPrevented())
return
$parent $parent
.toggleClass('open') .toggleClass('open')
@@ -682,33 +734,40 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
} }
Dropdown.prototype.keydown = function(e) { Dropdown.prototype.keydown = function(e) {
if (!/(38|40|27)/.test(e.keyCode)) return if (!/(38|40|27)/.test(e.keyCode))
return
var $this = $(this) var $this = $(this)
e.preventDefault() e.preventDefault()
e.stopPropagation() e.stopPropagation()
if ($this.is('.disabled, :disabled')) return if ($this.is('.disabled, :disabled'))
return
var $parent = getParent($this) var $parent = getParent($this)
var isActive = $parent.hasClass('open') var isActive = $parent.hasClass('open')
if (!isActive || (isActive && e.keyCode == 27)) { if (!isActive || (isActive && e.keyCode == 27)) {
if (e.which == 27) $parent.find(toggle).focus() if (e.which == 27)
$parent.find(toggle).focus()
return $this.click() return $this.click()
} }
var desc = ' li:not(.divider):visible a' var desc = ' li:not(.divider):visible a'
var $items = $parent.find('[role=menu]' + desc + ', [role=listbox]' + desc) var $items = $parent.find('[role=menu]' + desc + ', [role=listbox]' + desc)
if (!$items.length) return if (!$items.length)
return
var index = $items.index($items.filter(':focus')) var index = $items.index($items.filter(':focus'))
if (e.keyCode == 38 && index > 0) index-- // up if (e.keyCode == 38 && index > 0)
if (e.keyCode == 40 && index < $items.length - 1) index++ // down index-- // up
if (!~index) index = 0 if (e.keyCode == 40 && index < $items.length - 1)
index++ // down
if (!~index)
index = 0
$items.eq(index).focus() $items.eq(index).focus()
} }
@@ -718,9 +777,11 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
$(toggle).each(function() { $(toggle).each(function() {
var $parent = getParent($(this)) var $parent = getParent($(this))
var relatedTarget = {relatedTarget: this} var relatedTarget = {relatedTarget: this}
if (!$parent.hasClass('open')) return if (!$parent.hasClass('open'))
return
$parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget)) $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
if (e.isDefaultPrevented()) return if (e.isDefaultPrevented())
return
$parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget) $parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
}) })
} }
@@ -749,8 +810,10 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
var $this = $(this) var $this = $(this)
var data = $this.data('bs.dropdown') var data = $this.data('bs.dropdown')
if (!data) $this.data('bs.dropdown', (data = new Dropdown(this))) if (!data)
if (typeof option == 'string') data[option].call($this) $this.data('bs.dropdown', (data = new Dropdown(this)))
if (typeof option == 'string')
data[option].call($this)
}) })
} }
@@ -771,7 +834,9 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
$(document) $(document)
.on('click.bs.dropdown.data-api', clearMenus) .on('click.bs.dropdown.data-api', clearMenus)
.on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() }) .on('click.bs.dropdown.data-api', '.dropdown form', function(e) {
e.stopPropagation()
})
.on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle) .on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)
.on('keydown.bs.dropdown.data-api', toggle + ', [role=menu], [role=listbox]', Dropdown.prototype.keydown) .on('keydown.bs.dropdown.data-api', toggle + ', [role=menu], [role=listbox]', Dropdown.prototype.keydown)
@@ -823,7 +888,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
this.$element.trigger(e) this.$element.trigger(e)
if (this.isShown || e.isDefaultPrevented()) return if (this.isShown || e.isDefaultPrevented())
return
this.isShown = true this.isShown = true
@@ -865,13 +931,15 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
} }
Modal.prototype.hide = function(e) { Modal.prototype.hide = function(e) {
if (e) e.preventDefault() if (e)
e.preventDefault()
e = $.Event('hide.bs.modal') e = $.Event('hide.bs.modal')
this.$element.trigger(e) this.$element.trigger(e)
if (!this.isShown || e.isDefaultPrevented()) return if (!this.isShown || e.isDefaultPrevented())
return
this.isShown = false this.isShown = false
@@ -935,17 +1003,20 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
.appendTo(document.body) .appendTo(document.body)
this.$element.on('click.dismiss.bs.modal', $.proxy(function(e) { this.$element.on('click.dismiss.bs.modal', $.proxy(function(e) {
if (e.target !== e.currentTarget) return if (e.target !== e.currentTarget)
return
this.options.backdrop == 'static' this.options.backdrop == 'static'
? this.$element[0].focus.call(this.$element[0]) ? this.$element[0].focus.call(this.$element[0])
: this.hide.call(this) : this.hide.call(this)
}, this)) }, this))
if (doAnimate) this.$backdrop[0].offsetWidth // force reflow if (doAnimate)
this.$backdrop[0].offsetWidth // force reflow
this.$backdrop.addClass('in') this.$backdrop.addClass('in')
if (!callback) return if (!callback)
return
doAnimate ? doAnimate ?
this.$backdrop this.$backdrop
@@ -979,9 +1050,12 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
var data = $this.data('bs.modal') var data = $this.data('bs.modal')
var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option) var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
if (!data) $this.data('bs.modal', (data = new Modal(this, options))) if (!data)
if (typeof option == 'string') data[option](_relatedTarget) $this.data('bs.modal', (data = new Modal(this, options)))
else if (options.show) data.show(_relatedTarget) if (typeof option == 'string')
data[option](_relatedTarget)
else if (options.show)
data.show(_relatedTarget)
}) })
} }
@@ -1006,7 +1080,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7 var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
var option = $target.data('bs.modal') ? 'toggle' : $.extend({remote: !/#/.test(href) && href}, $target.data(), $this.data()) var option = $target.data('bs.modal') ? 'toggle' : $.extend({remote: !/#/.test(href) && href}, $target.data(), $this.data())
if ($this.is('a')) e.preventDefault() if ($this.is('a'))
e.preventDefault()
$target $target
.modal(option, this) .modal(option, this)
@@ -1016,8 +1091,12 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
}) })
$(document) $(document)
.on('show.bs.modal', '.modal', function () { $(document.body).addClass('modal-open') }) .on('show.bs.modal', '.modal', function() {
.on('hidden.bs.modal', '.modal', function () { $(document.body).removeClass('modal-open') }) $(document.body).addClass('modal-open')
})
.on('hidden.bs.modal', '.modal', function() {
$(document.body).removeClass('modal-open')
})
}(jQuery); }(jQuery);
@@ -1109,7 +1188,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
var defaults = this.getDefaults() var defaults = this.getDefaults()
this._options && $.each(this._options, function(key, value) { this._options && $.each(this._options, function(key, value) {
if (defaults[key] != value) options[key] = value if (defaults[key] != value)
options[key] = value
}) })
return options return options
@@ -1123,10 +1203,12 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
self.hoverState = 'in' self.hoverState = 'in'
if (!self.options.delay || !self.options.delay.show) return self.show() if (!self.options.delay || !self.options.delay.show)
return self.show()
self.timeout = setTimeout(function() { self.timeout = setTimeout(function() {
if (self.hoverState == 'in') self.show() if (self.hoverState == 'in')
self.show()
}, self.options.delay.show) }, self.options.delay.show)
} }
@@ -1138,10 +1220,12 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
self.hoverState = 'out' self.hoverState = 'out'
if (!self.options.delay || !self.options.delay.hide) return self.hide() if (!self.options.delay || !self.options.delay.hide)
return self.hide()
self.timeout = setTimeout(function() { self.timeout = setTimeout(function() {
if (self.hoverState == 'out') self.hide() if (self.hoverState == 'out')
self.hide()
}, self.options.delay.hide) }, self.options.delay.hide)
} }
@@ -1151,14 +1235,16 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
if (this.hasContent() && this.enabled) { if (this.hasContent() && this.enabled) {
this.$element.trigger(e) this.$element.trigger(e)
if (e.isDefaultPrevented()) return if (e.isDefaultPrevented())
return
var that = this; var that = this;
var $tip = this.tip() var $tip = this.tip()
this.setContent() this.setContent()
if (this.options.animation) $tip.addClass('fade') if (this.options.animation)
$tip.addClass('fade')
var placement = typeof this.options.placement == 'function' ? var placement = typeof this.options.placement == 'function' ?
this.options.placement.call(this, $tip[0], this.$element[0]) : this.options.placement.call(this, $tip[0], this.$element[0]) :
@@ -1166,7 +1252,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
var autoToken = /\s?auto?\s?/i var autoToken = /\s?auto?\s?/i
var autoPlace = autoToken.test(placement) var autoPlace = autoToken.test(placement)
if (autoPlace) placement = placement.replace(autoToken, '') || 'top' if (autoPlace)
placement = placement.replace(autoToken, '') || 'top'
$tip $tip
.detach() .detach()
@@ -1227,8 +1314,10 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
var marginLeft = parseInt($tip.css('margin-left'), 10) var marginLeft = parseInt($tip.css('margin-left'), 10)
// we must check for NaN for ie 8/9 // we must check for NaN for ie 8/9
if (isNaN(marginTop)) marginTop = 0 if (isNaN(marginTop))
if (isNaN(marginLeft)) marginLeft = 0 marginTop = 0
if (isNaN(marginLeft))
marginLeft = 0
offset.top = offset.top + marginTop offset.top = offset.top + marginTop
offset.left = offset.left + marginLeft offset.left = offset.left + marginLeft
@@ -1273,7 +1362,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
this.replaceArrow(actualHeight - height, actualHeight, 'top') this.replaceArrow(actualHeight - height, actualHeight, 'top')
} }
if (replace) $tip.offset(offset) if (replace)
$tip.offset(offset)
} }
Tooltip.prototype.replaceArrow = function(delta, dimension, position) { Tooltip.prototype.replaceArrow = function(delta, dimension, position) {
@@ -1294,13 +1384,15 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
var e = $.Event('hide.bs.' + this.type) var e = $.Event('hide.bs.' + this.type)
function complete() { function complete() {
if (that.hoverState != 'in') $tip.detach() if (that.hoverState != 'in')
$tip.detach()
that.$element.trigger('hidden.bs.' + that.type) that.$element.trigger('hidden.bs.' + that.type)
} }
this.$element.trigger(e) this.$element.trigger(e)
if (e.isDefaultPrevented()) return if (e.isDefaultPrevented())
return
$tip.removeClass('in') $tip.removeClass('in')
@@ -1402,9 +1494,12 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
var data = $this.data('bs.tooltip') var data = $this.data('bs.tooltip')
var options = typeof option == 'object' && option var options = typeof option == 'object' && option
if (!data && option == 'destroy') return if (!data && option == 'destroy')
if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options))) return
if (typeof option == 'string') data[option]() if (!data)
$this.data('bs.tooltip', (data = new Tooltip(this, options)))
if (typeof option == 'string')
data[option]()
}) })
} }
@@ -1440,7 +1535,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
this.init('popover', element, options) this.init('popover', element, options)
} }
if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js') if (!$.fn.tooltip)
throw new Error('Popover requires tooltip.js')
Popover.DEFAULTS = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, { Popover.DEFAULTS = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, {
placement: 'right', placement: 'right',
@@ -1475,7 +1571,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
// IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
// this manually by checking the contents. // this manually by checking the contents.
if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide() if (!$tip.find('.popover-title').html())
$tip.find('.popover-title').hide()
} }
Popover.prototype.hasContent = function() { Popover.prototype.hasContent = function() {
@@ -1497,7 +1594,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
} }
Popover.prototype.tip = function() { Popover.prototype.tip = function() {
if (!this.$tip) this.$tip = $(this.options.template) if (!this.$tip)
this.$tip = $(this.options.template)
return this.$tip return this.$tip
} }
@@ -1513,9 +1611,12 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
var data = $this.data('bs.popover') var data = $this.data('bs.popover')
var options = typeof option == 'object' && option var options = typeof option == 'object' && option
if (!data && option == 'destroy') return if (!data && option == 'destroy')
if (!data) $this.data('bs.popover', (data = new Popover(this, options))) return
if (typeof option == 'string') data[option]() if (!data)
$this.data('bs.popover', (data = new Popover(this, options)))
if (typeof option == 'string')
data[option]()
}) })
} }
@@ -1589,7 +1690,9 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
&& $href.is(':visible') && $href.is(':visible')
&& [[$href[offsetMethod]().top + (!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()), href]]) || null && [[$href[offsetMethod]().top + (!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()), href]]) || null
}) })
.sort(function (a, b) { return a[0] - b[0] }) .sort(function(a, b) {
return a[0] - b[0]
})
.each(function() { .each(function() {
self.offsets.push(this[0]) self.offsets.push(this[0])
self.targets.push(this[1]) self.targets.push(this[1])
@@ -1657,8 +1760,10 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
var data = $this.data('bs.scrollspy') var data = $this.data('bs.scrollspy')
var options = typeof option == 'object' && option var options = typeof option == 'object' && option
if (!data) $this.data('bs.scrollspy', (data = new ScrollSpy(this, options))) if (!data)
if (typeof option == 'string') data[option]() $this.data('bs.scrollspy', (data = new ScrollSpy(this, options)))
if (typeof option == 'string')
data[option]()
}) })
} }
@@ -1715,7 +1820,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
} }
if ($this.parent('li').hasClass('active')) return if ($this.parent('li').hasClass('active'))
return
var previous = $ul.find('.active:last a')[0] var previous = $ul.find('.active:last a')[0]
var e = $.Event('show.bs.tab', { var e = $.Event('show.bs.tab', {
@@ -1724,7 +1830,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
$this.trigger(e) $this.trigger(e)
if (e.isDefaultPrevented()) return if (e.isDefaultPrevented())
return
var $target = $(selector) var $target = $(selector)
@@ -1785,8 +1892,10 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
var $this = $(this) var $this = $(this)
var data = $this.data('bs.tab') var data = $this.data('bs.tab')
if (!data) $this.data('bs.tab', (data = new Tab(this))) if (!data)
if (typeof option == 'string') data[option]() $this.data('bs.tab', (data = new Tab(this)))
if (typeof option == 'string')
data[option]()
}) })
} }
@@ -1848,7 +1957,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
} }
Affix.prototype.getPinnedOffset = function() { Affix.prototype.getPinnedOffset = function() {
if (this.pinnedOffset) return this.pinnedOffset if (this.pinnedOffset)
return this.pinnedOffset
this.$element.removeClass(Affix.RESET).addClass('affix') this.$element.removeClass(Affix.RESET).addClass('affix')
var scrollTop = this.$window.scrollTop() var scrollTop = this.$window.scrollTop()
var position = this.$element.offset() var position = this.$element.offset()
@@ -1860,7 +1970,8 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
} }
Affix.prototype.checkPosition = function() { Affix.prototype.checkPosition = function() {
if (!this.$element.is(':visible')) return if (!this.$element.is(':visible'))
return
var scrollHeight = $(document).height() var scrollHeight = $(document).height()
var scrollTop = this.$window.scrollTop() var scrollTop = this.$window.scrollTop()
@@ -1869,25 +1980,32 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
var offsetTop = offset.top var offsetTop = offset.top
var offsetBottom = offset.bottom var offsetBottom = offset.bottom
if (this.affixed == 'top') position.top += scrollTop if (this.affixed == 'top')
position.top += scrollTop
if (typeof offset != 'object') offsetBottom = offsetTop = offset if (typeof offset != 'object')
if (typeof offsetTop == 'function') offsetTop = offset.top(this.$element) offsetBottom = offsetTop = offset
if (typeof offsetBottom == 'function') offsetBottom = offset.bottom(this.$element) if (typeof offsetTop == 'function')
offsetTop = offset.top(this.$element)
if (typeof offsetBottom == 'function')
offsetBottom = offset.bottom(this.$element)
var affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ? false : var affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ? false :
offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ? 'bottom' : offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ? 'bottom' :
offsetTop != null && (scrollTop <= offsetTop) ? 'top' : false offsetTop != null && (scrollTop <= offsetTop) ? 'top' : false
if (this.affixed === affix) return if (this.affixed === affix)
if (this.unpin) this.$element.css('top', '') return
if (this.unpin)
this.$element.css('top', '')
var affixType = 'affix' + (affix ? '-' + affix : '') var affixType = 'affix' + (affix ? '-' + affix : '')
var e = $.Event(affixType + '.bs.affix') var e = $.Event(affixType + '.bs.affix')
this.$element.trigger(e) this.$element.trigger(e)
if (e.isDefaultPrevented()) return if (e.isDefaultPrevented())
return
this.affixed = affix this.affixed = affix
this.unpin = affix == 'bottom' ? this.getPinnedOffset() : null this.unpin = affix == 'bottom' ? this.getPinnedOffset() : null
@@ -1914,8 +2032,10 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
var data = $this.data('bs.affix') var data = $this.data('bs.affix')
var options = typeof option == 'object' && option var options = typeof option == 'object' && option
if (!data) $this.data('bs.affix', (data = new Affix(this, options))) if (!data)
if (typeof option == 'string') data[option]() $this.data('bs.affix', (data = new Affix(this, options)))
if (typeof option == 'string')
data[option]()
}) })
} }
@@ -1941,8 +2061,10 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re
data.offset = data.offset || {} data.offset = data.offset || {}
if (data.offsetBottom) data.offset.bottom = data.offsetBottom if (data.offsetBottom)
if (data.offsetTop) data.offset.top = data.offsetTop data.offset.bottom = data.offsetBottom
if (data.offsetTop)
data.offset.top = data.offsetTop
$spy.affix(data) $spy.affix(data)
}) })

File diff suppressed because one or more lines are too long

View File

@@ -31,6 +31,13 @@ body {
.sidebar { .sidebar {
display: none; display: none;
} }
@media (max-width: 767px) {
.sidebar {
top: 50px;
bottom: 150px;
background-color: <?php echo COLORLAT; ?>
}
}
@media (min-width: 768px) { @media (min-width: 768px) {
.sidebar { .sidebar {
position: fixed; position: fixed;
@@ -71,6 +78,11 @@ body {
.main { .main {
padding: 10px; padding: 10px;
} }
@media (max-width: 767px) {
.main{
margin-top: 50px;
}
}
@media (min-width: 768px) { @media (min-width: 768px) {
.main { .main {
padding-right: 20px; padding-right: 20px;

2309
css/jquery.min.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -22,7 +22,6 @@
*/ */
SimpleColorPicker.prototype = { SimpleColorPicker.prototype = {
constructor: SimpleColorPicker, constructor: SimpleColorPicker,
init: function(type, select, options) { init: function(type, select, options) {
var self = this; var self = this;
@@ -103,7 +102,6 @@
} }
}); });
}, },
/** /**
* Changes the selected color. * Changes the selected color.
* *
@@ -122,7 +120,6 @@
console.error("The given color '" + color + "' could not be found"); console.error("The given color '" + color + "' could not be found");
} }
}, },
showPicker: function() { showPicker: function() {
var pos = this.$icon.offset(); var pos = this.$icon.offset();
this.$picker.css({ this.$picker.css({
@@ -133,11 +130,9 @@
this.$picker.show(this.options.pickerDelay); this.$picker.show(this.options.pickerDelay);
}, },
hidePicker: function() { hidePicker: function() {
this.$picker.hide(this.options.pickerDelay); this.$picker.hide(this.options.pickerDelay);
}, },
/** /**
* Selects the given span inside $colorList. * Selects the given span inside $colorList.
* *
@@ -161,7 +156,6 @@
// Change HTML select value // Change HTML select value
this.$select.val(color); this.$select.val(color);
}, },
/** /**
* The user clicked on a color inside $colorList. * The user clicked on a color inside $colorList.
*/ */
@@ -172,7 +166,6 @@
this.$select.trigger('change'); this.$select.trigger('change');
} }
}, },
/** /**
* Prevents the mousedown event from "eating" the click event. * Prevents the mousedown event from "eating" the click event.
*/ */
@@ -180,7 +173,6 @@
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
}, },
destroy: function() { destroy: function() {
if (this.options.picker === true) { if (this.options.picker === true) {
this.$icon.off('.' + this.type); this.$icon.off('.' + this.type);
@@ -224,10 +216,8 @@
$.fn.simplecolorpicker.defaults = { $.fn.simplecolorpicker.defaults = {
// No theme by default // No theme by default
theme: '', theme: '',
// Show the picker or make it inline // Show the picker or make it inline
picker: false, picker: false,
// Animation delay in milliseconds // Animation delay in milliseconds
pickerDelay: 0 pickerDelay: 0
}; };

794
css/moment.min.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -1,4 +1,5 @@
<?php <?php
$type = 'Core'; $type = 'Core';
$name = 'Courier'; $name = 'Courier';
$up = -100; $up = -100;

View File

@@ -1,4 +1,5 @@
<?php <?php
$type = 'Core'; $type = 'Core';
$name = 'Courier-Bold'; $name = 'Courier-Bold';
$up = -100; $up = -100;

View File

@@ -1,4 +1,5 @@
<?php <?php
$type = 'Core'; $type = 'Core';
$name = 'Courier-BoldOblique'; $name = 'Courier-BoldOblique';
$up = -100; $up = -100;

View File

@@ -1,4 +1,5 @@
<?php <?php
$type = 'Core'; $type = 'Core';
$name = 'Courier-Oblique'; $name = 'Courier-Oblique';
$up = -100; $up = -100;

View File

@@ -1,4 +1,5 @@
<?php <?php
$type = 'Core'; $type = 'Core';
$name = 'Helvetica'; $name = 'Helvetica';
$up = -100; $up = -100;

View File

@@ -1,4 +1,5 @@
<?php <?php
$type = 'Core'; $type = 'Core';
$name = 'Helvetica-Bold'; $name = 'Helvetica-Bold';
$up = -100; $up = -100;

View File

@@ -1,4 +1,5 @@
<?php <?php
$type = 'Core'; $type = 'Core';
$name = 'Helvetica-BoldOblique'; $name = 'Helvetica-BoldOblique';
$up = -100; $up = -100;

View File

@@ -1,4 +1,5 @@
<?php <?php
$type = 'Core'; $type = 'Core';
$name = 'Helvetica-Oblique'; $name = 'Helvetica-Oblique';
$up = -100; $up = -100;

View File

@@ -1,4 +1,5 @@
<?php <?php
/* * ***************************************************************************** /* * *****************************************************************************
* Utility to generate font definition files * * Utility to generate font definition files *
* * * *
@@ -15,18 +16,15 @@ function ReadMap($enc)
if (empty($a)) if (empty($a))
die('<b>Error:</b> encoding not found: ' . $enc); die('<b>Error:</b> encoding not found: ' . $enc);
$cc2gn = array(); $cc2gn = array();
foreach($a as $l) foreach ($a as $l) {
{ if ($l[0] == '!') {
if($l[0]=='!')
{
$e = preg_split('/[ \\t]+/', rtrim($l)); $e = preg_split('/[ \\t]+/', rtrim($l));
$cc = hexdec(substr($e[0], 1)); $cc = hexdec(substr($e[0], 1));
$gn = $e[2]; $gn = $e[2];
$cc2gn[$cc] = $gn; $cc2gn[$cc] = $gn;
} }
} }
for($i=0;$i<=255;$i++) for ($i = 0; $i <= 255; $i++) {
{
if (!isset($cc2gn[$i])) if (!isset($cc2gn[$i]))
$cc2gn[$i] = '.notdef'; $cc2gn[$i] = '.notdef';
} }
@@ -49,37 +47,30 @@ function ReadAFM($file, &$map)
'Tcedilla' => 'Tcommaaccent', 'tcedilla' => 'tcommaaccent', 'Dslash' => 'Dcroat', 'dslash' => 'dcroat', 'Dmacron' => 'Dcroat', 'dmacron' => 'dcroat', 'Tcedilla' => 'Tcommaaccent', 'tcedilla' => 'tcommaaccent', 'Dslash' => 'Dcroat', 'dslash' => 'dcroat', 'Dmacron' => 'Dcroat', 'dmacron' => 'dcroat',
'combininggraveaccent' => 'gravecomb', 'combininghookabove' => 'hookabovecomb', 'combiningtildeaccent' => 'tildecomb', 'combininggraveaccent' => 'gravecomb', 'combininghookabove' => 'hookabovecomb', 'combiningtildeaccent' => 'tildecomb',
'combiningacuteaccent' => 'acutecomb', 'combiningdotbelow' => 'dotbelowcomb', 'dongsign' => 'dong'); 'combiningacuteaccent' => 'acutecomb', 'combiningdotbelow' => 'dotbelowcomb', 'dongsign' => 'dong');
foreach($a as $l) foreach ($a as $l) {
{
$e = explode(' ', rtrim($l)); $e = explode(' ', rtrim($l));
if (count($e) < 2) if (count($e) < 2)
continue; continue;
$code = $e[0]; $code = $e[0];
$param = $e[1]; $param = $e[1];
if($code=='C') if ($code == 'C') {
{
//Character metrics //Character metrics
$cc = (int) $e[1]; $cc = (int) $e[1];
$w = $e[4]; $w = $e[4];
$gn = $e[7]; $gn = $e[7];
if (substr($gn, -4) == '20AC') if (substr($gn, -4) == '20AC')
$gn = 'Euro'; $gn = 'Euro';
if(isset($fix[$gn])) if (isset($fix[$gn])) {
{
//Fix incorrect glyph name //Fix incorrect glyph name
foreach($map as $c=>$n) foreach ($map as $c => $n) {
{
if ($n == $fix[$gn]) if ($n == $fix[$gn])
$map[$c] = $gn; $map[$c] = $gn;
} }
} }
if(empty($map)) if (empty($map)) {
{
//Symbolic font: use built-in encoding //Symbolic font: use built-in encoding
$widths[$cc] = $w; $widths[$cc] = $w;
} } else {
else
{
$widths[$gn] = $w; $widths[$gn] = $w;
if ($gn == 'X') if ($gn == 'X')
$fm['CapXHeight'] = $e[13]; $fm['CapXHeight'] = $e[13];
@@ -112,17 +103,14 @@ function ReadAFM($file, &$map)
} }
if (!isset($fm['FontName'])) if (!isset($fm['FontName']))
die('FontName not found'); die('FontName not found');
if(!empty($map)) if (!empty($map)) {
{
if (!isset($widths['.notdef'])) if (!isset($widths['.notdef']))
$widths['.notdef'] = 600; $widths['.notdef'] = 600;
if (!isset($widths['Delta']) && isset($widths['increment'])) if (!isset($widths['Delta']) && isset($widths['increment']))
$widths['Delta'] = $widths['increment']; $widths['Delta'] = $widths['increment'];
//Order widths according to map //Order widths according to map
for($i=0;$i<=255;$i++) for ($i = 0; $i <= 255; $i++) {
{ if (!isset($widths[$map[$i]])) {
if(!isset($widths[$map[$i]]))
{
echo '<b>Warning:</b> character ' . $map[$i] . ' is missing<br>'; echo '<b>Warning:</b> character ' . $map[$i] . ' is missing<br>';
$widths[$i] = $widths['.notdef']; $widths[$i] = $widths['.notdef'];
} }
@@ -190,8 +178,7 @@ function MakeWidthArray($fm)
//Make character width array //Make character width array
$s = "array(\n\t"; $s = "array(\n\t";
$cw = $fm['Widths']; $cw = $fm['Widths'];
for($i=0;$i<=255;$i++) for ($i = 0; $i <= 255; $i++) {
{
if (chr($i) == "'") if (chr($i) == "'")
$s.="'\\''"; $s.="'\\''";
elseif (chr($i) == "\\") elseif (chr($i) == "\\")
@@ -216,10 +203,8 @@ function MakeFontEncoding($map)
$ref = ReadMap('cp1252'); $ref = ReadMap('cp1252');
$s = ''; $s = '';
$last = 0; $last = 0;
for($i=32;$i<=255;$i++) for ($i = 32; $i <= 255; $i++) {
{ if ($map[$i] != $ref[$i]) {
if($map[$i]!=$ref[$i])
{
if ($i != $last + 1) if ($i != $last + 1)
$s.=$i . ' '; $s.=$i . ' ';
$last = $i; $last = $i;
@@ -262,17 +247,14 @@ function CheckTTF($file)
fseek($f, 6, SEEK_CUR); fseek($f, 6, SEEK_CUR);
//Seek OS/2 table //Seek OS/2 table
$found = false; $found = false;
for($i=0;$i<$nb;$i++) for ($i = 0; $i < $nb; $i++) {
{ if (fread($f, 4) == 'OS/2') {
if(fread($f,4)=='OS/2')
{
$found = true; $found = true;
break; break;
} }
fseek($f, 12, SEEK_CUR); fseek($f, 12, SEEK_CUR);
} }
if(!$found) if (!$found) {
{
fclose($f); fclose($f);
return; return;
} }
@@ -297,14 +279,14 @@ function CheckTTF($file)
* patch: optional patch for encoding * * patch: optional patch for encoding *
* type: font type if fontfile is empty * * type: font type if fontfile is empty *
* ***************************************************************************** */ * ***************************************************************************** */
function MakeFont($fontfile, $afmfile, $enc = 'cp1252', $patch = array(), $type = 'TrueType') function MakeFont($fontfile, $afmfile, $enc = 'cp1252', $patch = array(), $type = 'TrueType')
{ {
//Generate a font definition file //Generate a font definition file
if (get_magic_quotes_runtime()) if (get_magic_quotes_runtime())
@set_magic_quotes_runtime(0); @set_magic_quotes_runtime(0);
ini_set('auto_detect_line_endings', '1'); ini_set('auto_detect_line_endings', '1');
if($enc) if ($enc) {
{
$map = ReadMap($enc); $map = ReadMap($enc);
foreach ($patch as $cc => $gn) foreach ($patch as $cc => $gn)
$map[$cc] = $gn; $map[$cc] = $gn;
@@ -320,8 +302,7 @@ function MakeFont($fontfile, $afmfile, $enc='cp1252', $patch=array(), $type='Tru
$diff = ''; $diff = '';
$fd = MakeFontDescriptor($fm, empty($map)); $fd = MakeFontDescriptor($fm, empty($map));
//Find font type //Find font type
if($fontfile) if ($fontfile) {
{
$ext = strtolower(substr($fontfile, -3)); $ext = strtolower(substr($fontfile, -3));
if ($ext == 'ttf') if ($ext == 'ttf')
$type = 'TrueType'; $type = 'TrueType';
@@ -330,8 +311,7 @@ function MakeFont($fontfile, $afmfile, $enc='cp1252', $patch=array(), $type='Tru
else else
die('<b>Error:</b> unrecognized font file extension: ' . $ext); die('<b>Error:</b> unrecognized font file extension: ' . $ext);
} }
else else {
{
if ($type != 'TrueType' && $type != 'Type1') if ($type != 'TrueType' && $type != 'Type1')
die('<b>Error:</b> incorrect font type: ' . $type); die('<b>Error:</b> incorrect font type: ' . $type);
} }
@@ -351,8 +331,7 @@ function MakeFont($fontfile, $afmfile, $enc='cp1252', $patch=array(), $type='Tru
$s.='$enc=\'' . $enc . "';\n"; $s.='$enc=\'' . $enc . "';\n";
$s.='$diff=\'' . $diff . "';\n"; $s.='$diff=\'' . $diff . "';\n";
$basename = substr(basename($afmfile), 0, -4); $basename = substr(basename($afmfile), 0, -4);
if($fontfile) if ($fontfile) {
{
//Embedded font //Embedded font
if (!file_exists($fontfile)) if (!file_exists($fontfile))
die('<b>Error:</b> font file not found: ' . $fontfile); die('<b>Error:</b> font file not found: ' . $fontfile);
@@ -363,12 +342,10 @@ function MakeFont($fontfile, $afmfile, $enc='cp1252', $patch=array(), $type='Tru
die('<b>Error:</b> Can\'t open ' . $fontfile); die('<b>Error:</b> Can\'t open ' . $fontfile);
$file = fread($f, filesize($fontfile)); $file = fread($f, filesize($fontfile));
fclose($f); fclose($f);
if($type=='Type1') if ($type == 'Type1') {
{
//Find first two sections and discard third one //Find first two sections and discard third one
$header = (ord($file[0]) == 128); $header = (ord($file[0]) == 128);
if($header) if ($header) {
{
//Strip first binary header //Strip first binary header
$file = substr($file, 6); $file = substr($file, 6);
} }
@@ -376,8 +353,7 @@ function MakeFont($fontfile, $afmfile, $enc='cp1252', $patch=array(), $type='Tru
if (!$pos) if (!$pos)
die('<b>Error:</b> font file does not seem to be valid Type1'); die('<b>Error:</b> font file does not seem to be valid Type1');
$size1 = $pos + 6; $size1 = $pos + 6;
if($header && ord($file[$size1])==128) if ($header && ord($file[$size1]) == 128) {
{
//Strip second binary header //Strip second binary header
$file = substr($file, 0, $size1) . substr($file, $size1 + 6); $file = substr($file, 0, $size1) . substr($file, $size1 + 6);
} }
@@ -387,28 +363,23 @@ function MakeFont($fontfile, $afmfile, $enc='cp1252', $patch=array(), $type='Tru
$size2 = $pos - $size1; $size2 = $pos - $size1;
$file = substr($file, 0, $size1 + $size2); $file = substr($file, 0, $size1 + $size2);
} }
if(function_exists('gzcompress')) if (function_exists('gzcompress')) {
{
$cmp = $basename . '.z'; $cmp = $basename . '.z';
SaveToFile($cmp, gzcompress($file), 'b'); SaveToFile($cmp, gzcompress($file), 'b');
$s.='$file=\'' . $cmp . "';\n"; $s.='$file=\'' . $cmp . "';\n";
echo 'Font file compressed (' . $cmp . ')<br>'; echo 'Font file compressed (' . $cmp . ')<br>';
} } else {
else
{
$s.='$file=\'' . basename($fontfile) . "';\n"; $s.='$file=\'' . basename($fontfile) . "';\n";
echo '<b>Notice:</b> font file could not be compressed (zlib extension not available)<br>'; echo '<b>Notice:</b> font file could not be compressed (zlib extension not available)<br>';
} }
if($type=='Type1') if ($type == 'Type1') {
{
$s.='$size1=' . $size1 . ";\n"; $s.='$size1=' . $size1 . ";\n";
$s.='$size2=' . $size2 . ";\n"; $s.='$size2=' . $size2 . ";\n";
} }
else else
$s.='$originalsize=' . filesize($fontfile) . ";\n"; $s.='$originalsize=' . filesize($fontfile) . ";\n";
} }
else else {
{
//Not embedded font //Not embedded font
$s.='$file=' . "'';\n"; $s.='$file=' . "'';\n";
} }
@@ -416,4 +387,5 @@ function MakeFont($fontfile, $afmfile, $enc='cp1252', $patch=array(), $type='Tru
SaveToFile($basename . '.php', $s, 't'); SaveToFile($basename . '.php', $s, 't');
echo 'Font definition file generated (' . $basename . '.php' . ')<br>'; echo 'Font definition file generated (' . $basename . '.php' . ')<br>';
} }
?> ?>

View File

@@ -1,4 +1,5 @@
<?php <?php
$type = 'Core'; $type = 'Core';
$name = 'Symbol'; $name = 'Symbol';
$up = -100; $up = -100;

View File

@@ -1,4 +1,5 @@
<?php <?php
$type = 'Core'; $type = 'Core';
$name = 'Times-Roman'; $name = 'Times-Roman';
$up = -100; $up = -100;

View File

@@ -1,4 +1,5 @@
<?php <?php
$type = 'Core'; $type = 'Core';
$name = 'Times-Bold'; $name = 'Times-Bold';
$up = -100; $up = -100;

View File

@@ -1,4 +1,5 @@
<?php <?php
$type = 'Core'; $type = 'Core';
$name = 'Times-BoldItalic'; $name = 'Times-BoldItalic';
$up = -100; $up = -100;

View File

@@ -1,4 +1,5 @@
<?php <?php
$type = 'Core'; $type = 'Core';
$name = 'Times-Italic'; $name = 'Times-Italic';
$up = -100; $up = -100;

View File

@@ -1,4 +1,5 @@
<?php <?php
$type = 'Core'; $type = 'Core';
$name = 'ZapfDingbats'; $name = 'ZapfDingbats';
$up = -100; $up = -100;

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* Fichero de configuración donde se introducirán los valores para * Fichero de configuración donde se introducirán los valores para
* la conexión con el servidor MySQL y otros para personalizar la aplicación. * la conexión con el servidor MySQL y otros para personalizar la aplicación.
@@ -20,20 +21,20 @@
* along with Inventario. If not, see <http://www.gnu.org/licenses/>. * 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('SERVIDOR', 'localhost'); //Ubicación del servidor MySQL
define('BASEDATOS','Inventario4'); //Nombre de la base de datos. 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('USUARIO', 'test'); //Usuario con permisos de lectura/escritura en la base de datos
define('CLAVE', 'tset'); //contraseña del usuario. define('CLAVE', 'tset'); //contraseña del usuario.
define('VERSION','1.02');
define('PROGRAMA', 'Gesti&oacute;n de Inventario.'); define('PROGRAMA', 'Gesti&oacute;n de Inventario.');
define('CENTRO', 'I.E.S.O. Pascual Serrano'); define('CENTRO', 'I.E.S.O. Pascual Serrano');
define('APLICACION',PROGRAMA.VERSION); define('NUMFILAS', '17'); // Número de registros a mostrar en las pantallas de consulta iniciales
define('NUMFILAS',17); // Número de registros a mostrar en las pantallas de consulta iniciales define('PAUSA', '2'); //Nº segundos de pausa para mostrar mensaje id insertado
define('PAUSA',2);//Nº segundos de pausa para mostrar mensaje id insertado
define('ESTILO', 'personal'); //Estilo de los iconos de edición (personal, personal, personal) define('ESTILO', 'personal'); //Estilo de los iconos de edición (personal, personal, personal)
define('PLANTILLA', 'bootstrap'); //Estilo de la plantilla y recursos a utilizar define('PLANTILLA', 'bootstrap'); //Estilo de la plantilla y recursos a utilizar
define('COLORLAT', '#7ae7bf'); //Color de la barra de menú lateral define('COLORLAT', '#46d6db'); //Color de la barra de menú lateral
define('COLORFON', '#a4bdfc'); //Color del fondo de la pantalla define('COLORFON', '#a4bdfc'); //Color del fondo de la pantalla
define('MYSQLDUMP', '/usr/local/bin/mysqldump'); //camino a mysqldump define('MYSQLDUMP', '/usr/local/bin/mysqldump'); //camino a mysqldump
define('GZIP', '/usr/bin/gzip'); //Camino a gzip define('GZIP', '/usr/bin/gzip'); //Camino a gzip

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

@@ -24,7 +24,7 @@
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation"> <div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container-fluid"> <div class="container-fluid">
<div class="navbar-header"> <div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar">
<span class="sr-only">Toggle navigation</span> <span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
@@ -38,7 +38,7 @@
</div> </div>
<div class="navbar-collapse collapse"> <div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
<li><a href="#">{usuario}</a></li> <!--<li><a href="#">{usuario}</a></li>-->
<li><a href="#">{fecha}</a></li> <li><a href="#">{fecha}</a></li>
<li>{control}</li> <li>{control}</li>
</ul> </ul>

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

@@ -0,0 +1,75 @@
<?php
require_once 'Configuracion.php';
/**
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-03-07 at 23:58:14.
*/
class ConfiguracionTest extends PHPUnit_Framework_TestCase {
/**
* @var Configuracion
*/
protected $config;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->config = new Configuracion;
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown()
{
}
/**
* @covers Configuracion::ejecuta
*/
public function testEjecuta()
{
$this->assertFileExists('inc/Configuracion.inc', "El fichero de configuración no existe");
$permisos = fileperms('inc/Configuracion.inc');
//Comprueba que el propietario o el grupo tengan derecho de escritura
$test = $permisos & 0x0080 || $permisos & 0x0010;
$this->assertTrue($test, "El fichero de configuración no tiene los permisos adecuados");
//Comprueba que existan todas las claves editables en el fichero de configuración.
$fichero = $this->config->obtieneFichero();
$this->assertNotNull($fichero, "El fichero de configuración no se ha leído o no tiene contenido");
$lineas = explode("\n", $fichero);
$campos = $this->config->obtieneLista();
$numero = 0;
$lista = implode(",", $campos);
//var_dump($campos);
//var_dump($lista);
foreach ($lineas as $linea) {
if (stripos($linea, "DEFINE") !== false) {
$this->assertStringMatchesFormat("define('%s', '%s');%S", $linea, "La línea [" . $linea . "] del fichero de configuración no tiene el formato correcto");
$this->config->obtieneDatos($linea, $clave, $valor);
if (stripos($lista, $clave) !== false) {
$this->assertContains($clave, $campos, "El fichero de configuración no tiene la clave [" . $clave . "]");
$numero++;
$verificados[] = $clave;
}
}
}
$this->assertCount($numero, $campos, "No se han verificado todas las claves");
if ($numero != count($campos)) {
echo "Las claves verificadas han sido: \n";
var_export($verificados);
}
// @todo comprobar que la salida incluye una tabla con todos los campos editables.
// @todo comprobar que los valores seleccionados se corresponden co los del fichero
$salida = $this->config->ejecuta();
}
}
?>

47
tests/MenuTest.php Normal file
View File

@@ -0,0 +1,47 @@
<?php
require_once('Menu.php');
/**
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-03-08 at 17:47:42.
*/
class MenuTest extends PHPUnit_Framework_TestCase {
/**
* @var Menu
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->object = new Menu('inc/inventario.menu');
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown()
{
}
/**
* @covers Menu::insertaMenu
* @todo Implement testInsertaMenu().
*/
public function testInsertaMenu()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
}
?>

204
tests/SqlTest.php Normal file
View File

@@ -0,0 +1,204 @@
<?php
require_once('inc/configuracion.inc');
require_once('Sql.php');
/**
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-03-08 at 01:19:34.
*/
class SqlTest extends PHPUnit_Framework_TestCase {
/**
* @var Sql
*/
protected $bd;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
* @covers Sql::__construct
* @uses Sql
*/
protected function setUp()
{
$this->bd = new Sql(SERVIDOR, USUARIO, CLAVE, BASEDATOSTEST);
$this->assertFalse($this->bd->error(), "No se ha conectado a la base de datos de pruebas [" . BASEDATOSTEST . "]");
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown()
{
}
/**
* @covers Sql::__destruct
* @todo Implement test__destruct().
*/
public function test__destruct()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers Sql::filtra
* @todo Implement testFiltra().
*/
public function testFiltra()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers Sql::ejecuta
* @todo Implement testEjecuta().
*/
public function testEjecuta()
{
}
/**
* @covers Sql::procesaResultado
* @todo Implement testProcesaResultado().
*/
public function testProcesaResultado()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers Sql::camposResultado
* @todo Implement testCamposResultado().
*/
public function testCamposResultado()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers Sql::numeroTuplas
* @todo Implement testNumeroTuplas().
*/
public function testNumeroTuplas()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers Sql::error
* @todo Implement testError().
*/
public function testError()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers Sql::mensajeError
* @todo Implement testMensajeError().
*/
public function testMensajeError()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers Sql::estructura
* @todo Implement testEstructura().
*/
public function testEstructura()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers Sql::ultimoId
* @todo Implement testUltimoId().
*/
public function testUltimoId()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers Sql::obtieneManejador
* @todo Implement testObtieneManejador().
*/
public function testObtieneManejador()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers Sql::comienzaTransaccion
* @todo Implement testComienzaTransaccion().
*/
public function testComienzaTransaccion()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers Sql::abortaTransaccion
* @todo Implement testAbortaTransaccion().
*/
public function testAbortaTransaccion()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers Sql::confirmaTransaccion
* @todo Implement testConfirmaTransaccion().
*/
public function testConfirmaTransaccion()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
}
?>

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,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>

View File

@@ -0,0 +1,29 @@
<?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,U.Descripcion as ubicacion,A.Marca as marca,A.Modelo as modelo,E.numSerie as numserie,
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
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="ubicacion" Titulo="Ubicacion"/>
<Col Nombre="articulo" 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>

View File

@@ -2,7 +2,7 @@
<Mantenimiento> <Mantenimiento>
<Titulo>Mantenimiento de Elementos</Titulo> <Titulo>Mantenimiento de Elementos</Titulo>
<Consulta> <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, SELECT SQL_CALC_FOUND_ROWS E.id as id,U.Descripcion as ubicacion,A.Descripcion as articulo,A.Marca as marca,A.Modelo as modelo,E.numserie as numserie,
DATE_FORMAT(E.fechacompra, '%d/%m/%Y') as fechaCompra,E.cantidad as cantidad DATE_FORMAT(E.fechacompra, '%d/%m/%Y') as fechaCompra,E.cantidad as cantidad
FROM Elementos E inner join Articulos A on E.id_articulo=A.id inner join FROM Elementos E inner join Articulos A on E.id_articulo=A.id inner join
Ubicaciones U on E.id_ubicacion=U.id {buscar} {orden} limit {inferior},{superior}; Ubicaciones U on E.id_ubicacion=U.id {buscar} {orden} limit {inferior},{superior};

View File

@@ -2,7 +2,7 @@
<Mantenimiento> <Mantenimiento>
<Titulo>Mantenimiento de Usuarios</Titulo> <Titulo>Mantenimiento de Usuarios</Titulo>
<Consulta> <Consulta>
SELECT id, nombre, clave, idSesion, alta, modificacion, borrado, consulta, informe, usuarios, config SELECT SQL_CALC_FOUND_ROWS id, nombre, clave, idSesion, alta, modificacion, borrado, consulta, informe, usuarios, config
FROM Usuarios {buscar} {orden} limit {inferior}, {superior}; FROM Usuarios {buscar} {orden} limit {inferior}, {superior};
</Consulta> </Consulta>
<Campos> <Campos>