From 33d8648effa91cc731dd413d7aacb73cdbcd82b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Montan=CC=83ana?= Date: Tue, 1 Apr 2014 01:54:58 +0200 Subject: [PATCH 1/6] =?UTF-8?q?Primer=20paso=20del=20programa=20de=20insta?= =?UTF-8?q?laci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG | 5 +- Instalar.php | 248 ++++++++++++++++++++++++++++++++++++++++++ inc/configuracion.inc | 1 + 3 files changed, 253 insertions(+), 1 deletion(-) create mode 100644 Instalar.php diff --git a/CHANGELOG b/CHANGELOG index 056cca8..f0c8459 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,7 @@ -Versión 1.07 +-creado el programa instalar.php que permitirá configurar el acceso a la base de datos, comprobar la configuración del servidor y la creación del usuario administrador +-Añadido un parámetro en el archivo configuracion.inc que permite o no ejecutar el programa instalar.php + +Versión 1.07 31-03-2014 -Añadido bootstrap-select a la solicitud de informes de inventario de esta forma se pueden buscar artículos o ubicaciones en el select -Añadido bootstrap-select al mantenimiento para que en el alta de elementos se puedan buscar artículos o ubicaciones en el el select -Corregido un problema que permitía cambiar fechas en el formulario de bajas diff --git a/Instalar.php b/Instalar.php new file mode 100644 index 0000000..5822bff --- /dev/null +++ b/Instalar.php @@ -0,0 +1,248 @@ +. + * + */ +//Se incluyen los módulos necesarios +function __autoload($class_name) { + require_once $class_name . '.php'; +} +include 'inc/configuracion.inc'; +define('NUMPASOS', 3); +define('MINBYTES', 4096000); // post_max_size y max_upload van con esto +define('CADENAMINBYTES', '4M'); + +// Si ya se ha ejecutado con anterioridad esta script no continúa. +if (INSTALADO != 'no') { + echo "El programa ya está instalado"; + return 1; +} + +$instalar = new Instalar(); +echo $instalar->ejecuta(); + +class Instalar { + private $resultados; + private $contenido; + private $plant; + + public function __construct() + { + //Selecciona la plantilla a utilizar + $this->plant='plant/'; + $this->plant.=PLANTILLA; + $this->plant.='.html';; + } + + public function ejecuta() + { + $paso = isset($_GET['paso']) ? $_GET['paso'] : 0; + $paso = $paso > NUMPASOS ? '0' : $paso; + //Si quiere ir a un determinado paso se asegura que estén completos los anteriores + for ($i = 0; $i < $paso; $i++) { + if (!$this->resultado[$i]) { + //$funcion = "paso" . $i; + //$this->contenido = $this->$funcion(); + break; + } + } + if ($paso == NUMPASOS) { + $this->contenido = $this->pasoFinal(); + } else { + $funcion = "paso" . $i; + $this->contenido = $this->$funcion(); + } + $salida = new Distribucion($this->plant, $this); + return $salida->procesaPlantilla(); + } + + private function inicializa() + { + for ($i = 0; $i < NUMPASOS; $i++) { + $funcion = "validaPaso" . $i; + $resultado[] = $funcion(); + } + } + + // Resumen de cuestiones realizadas + private function pasoFinal() + { + + } + + // Cuestiones relacionadas con el servidor + private function paso0() + { + $displayErr = ini_get('display_errors'); + $info = ''; + if ($this->validaPaso0()) { + $boton = ''; + } else { + $boton = ''; + } + $info .= $boton; + $panel = $this->panelMensaje($info, 'info', 'PASO 1: Configuración del servidor'); + return $panel; + } + + private function retornaLabel($error, $mensaje, $tipo = "danger") + { + if ($error) { + $nombre1 = $tipo; $nombre2 = "remove"; + } else { + $nombre1 = "success"; $nombre2 = "ok"; + } + $mensaje = ''; + $mensaje .=''; + return $mensaje; + } + + private function retornaBytes($val) + { + $val = trim($val); + $last = strtolower($val[strlen($val)-1]); + switch($last) { + // El modificador 'G' está disponble desde PHP 5.1.0 + case 'g': + $val *= 1024; + case 'm': + $val *= 1024; + case 'k': + $val *= 1024; + } + return $val; + } + + private function validaPaso0() + { + $validar = true; + $postMax = ini_get('post_max_size'); + $uploadMax = ini_get('upload_max_filesize'); + $mysql = extension_loaded('mysqli'); + if ($this->retornaBytes($postMax) < MINBYTES) + $validar = false; + if ($this->retornaBytes($uploadMax) < MINBYTES) + $validar = false; + if (!$mysql) + $validar = false; + return $validar; + } + + // Cuestiones de la base de datos + private function paso2() + { + + } + + private function validaPaso2() + { + return false; + } + + // Usuario administrador + private function paso3() + { + + } + + private function validaPaso3() + { + return false; + } + + private function panelMensaje($info, $tipo = "info", $cabecera = "¡Atención!") { + $mensaje = '
'; + $mensaje .= '

' . $cabecera . '

'; + $mensaje .= '
'; + $mensaje .= $info; + $mensaje .= '
'; + $mensaje .= '
'; + return $mensaje; + } + + public function contenido() + { + return $this->contenido; + } + + public function menu() + { + return ''; + } + + public function opcion() + { + return 'INSTALACIÓN'; + } + + public function control() + { + return ''; + } + + public function aplicacion() + { + return PROGRAMA . ' v' . VERSION; + } + + public function usuario() + { + return ''; + } + + public function fecha() + { + $idioma = 'es_ES'; + if ($formato == '') + $formato = "%d-%b-%y"; + setlocale(LC_TIME, $idioma); + return strftime($formato); + } +} + +?> diff --git a/inc/configuracion.inc b/inc/configuracion.inc index be4f162..0e9a2e9 100644 --- a/inc/configuracion.inc +++ b/inc/configuracion.inc @@ -40,4 +40,5 @@ define('COLORFON', '#ffb878'); //Color del fondo de la pantalla define('MYSQLDUMP', '/usr/local/bin/mysqldump'); //camino a mysqldump define('GZIP', '/usr/bin/gzip'); //Camino a gzip define('IMAGEDATA', 'img.data'); //Directorio donde se almacenarán las imágenes +define('INSTALADO', 'no'); //no = permite la ejecución de instalar.php ?> From ce08900d136a495a252167f8b9bc0d5566b7e021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Montan=CC=83ana?= Date: Sat, 5 Apr 2014 04:33:06 +0200 Subject: [PATCH 2/6] =?UTF-8?q?Programa=20de=20instalaci=C3=B3n=20casi=20t?= =?UTF-8?q?erminado.=20Incluido=20validador=20de=20formularios=20javascrip?= =?UTF-8?q?t.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG | 3 +- Instalar.php | 411 +++++++++++++++++++++++++++++++++++-------- css/validator.min.js | 9 + sql/setup.sql | 8 - 4 files changed, 351 insertions(+), 80 deletions(-) create mode 100755 css/validator.min.js diff --git a/CHANGELOG b/CHANGELOG index f0c8459..6d8ea7d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ --creado el programa instalar.php que permitirá configurar el acceso a la base de datos, comprobar la configuración del servidor y la creación del usuario administrador +-Quitados los usuarios de ejemplo en el archivo setup.sql +-Creado el programa instalar.php que permitirá configurar el acceso a la base de datos, comprobar la configuración del servidor y la creación del usuario administrador -Añadido un parámetro en el archivo configuracion.inc que permite o no ejecutar el programa instalar.php Versión 1.07 31-03-2014 diff --git a/Instalar.php b/Instalar.php index 5822bff..72269b6 100644 --- a/Instalar.php +++ b/Instalar.php @@ -26,107 +26,152 @@ function __autoload($class_name) { } include 'inc/configuracion.inc'; define('NUMPASOS', 3); +//Para el Paso 1 define('MINBYTES', 4096000); // post_max_size y max_upload van con esto define('CADENAMINBYTES', '4M'); - -// Si ya se ha ejecutado con anterioridad esta script no continúa. -if (INSTALADO != 'no') { - echo "El programa ya está instalado"; - return 1; -} +define('CONFIGURACION', 'inc/configuracion.inc'); +define('CONFIGTMP', 'tmp/config.tmp'); +define('TMP', './tmp'); +define('INC', './inc'); $instalar = new Instalar(); -echo $instalar->ejecuta(); +if (!$instalar->error) { + echo $instalar->ejecuta(); +} else { + echo $instalar->cabecera(); + echo $instalar->panelMensaje($instalar->error_msj, "danger", "¡ERROR!"); + echo ""; +} class Instalar { - private $resultados; private $contenido; private $plant; + public $error; + public $error_msj; public function __construct() { //Selecciona la plantilla a utilizar $this->plant='plant/'; $this->plant.=PLANTILLA; - $this->plant.='.html';; + $this->plant.='.html'; + $this->error = false; + $this->eror_msj = ''; + if (INSTALADO != 'no') { + $this->error = true; + $this->error_msj = 'El programa ya está instalado'; + } + /*if ($this->existenDatos()) { + $this->error = true; + $this->error_msj = "El indicador de instalación tiene 'no' pero la base de datos " . BASEDATOS . " contiene la tabla Articulos."; + }*/ + } + + private function existenDatos() + { + //Comprueba si existe la tabla Articulos + $sql = new Sql(SERVIDOR, USUARIO, CLAVE, BASEDATOS); + if ($sql->error()) + return false; + $sql->ejecuta('select * from Articulos;'); + if ($sql->error()) + return false; + return true; } public function ejecuta() { $paso = isset($_GET['paso']) ? $_GET['paso'] : 0; $paso = $paso > NUMPASOS ? '0' : $paso; + $i=0; //Si quiere ir a un determinado paso se asegura que estén completos los anteriores for ($i = 0; $i < $paso; $i++) { - if (!$this->resultado[$i]) { - //$funcion = "paso" . $i; - //$this->contenido = $this->$funcion(); + $funcion = "validaPaso" . $i; + if (!$this->$funcion()) { break; } } - if ($paso == NUMPASOS) { - $this->contenido = $this->pasoFinal(); - } else { - $funcion = "paso" . $i; - $this->contenido = $this->$funcion(); - } + $funcion = "paso" . $i; + $this->contenido = $this->$funcion(); $salida = new Distribucion($this->plant, $this); return $salida->procesaPlantilla(); } - - private function inicializa() - { - for ($i = 0; $i < NUMPASOS; $i++) { - $funcion = "validaPaso" . $i; - $resultado[] = $funcion(); - } - } - - // Resumen de cuestiones realizadas - private function pasoFinal() - { - - } - + // Cuestiones relacionadas con el servidor private function paso0() { - $displayErr = ini_get('display_errors'); $info = ''; - if ($this->validaPaso0()) { - $boton = ''; - } else { - $boton = ''; - } - $info .= $boton; - $panel = $this->panelMensaje($info, 'info', 'PASO 1: Configuración del servidor'); + $info .= $this->retornaElemento($mensaje, 'extensión MySQLi', $mysql); + $info .= '
  • Configuración de la Aplicación
  • '; + // img.dat + $mensaje = is_writable(IMAGEDATA) ? $this->retornaLabel(false, "Se debe poder escribir en el directorio " . IMAGEDATA) : + $this->retornaLabel(true, "Se debe poder escribir en el directorio " . IMAGEDATA); + $valor = is_writable(IMAGEDATA) ? "Sí" : "No"; + $info .= $this->retornaElemento($mensaje, 'Se puede escribir en ' . IMAGEDATA, $valor); + + // tmp + $mensaje = is_writable(TMP) ? $this->retornaLabel(false, "Se debe poder escribir en el directorio " . TMP) : + $this->retornaLabel(true, "Se debe poder escribir en el directorio " . TMP); + $valor = is_writable(TMP) ? "Sí" : "No"; + $info .= $this->retornaElemento($mensaje, 'Se puede escribir en ' . TMP, $valor); + + // inc + $mensaje = is_writable(INC) ? $this->retornaLabel(false, "Se debe poder escribir en el directorio " . INC) : + $this->retornaLabel(true, "Se debe poder escribir en el directorio " . INC); + $valor = is_writable(INC) ? "Sí" : "No"; + $info .= $this->retornaElemento($mensaje, 'Se puede escribir en ' . INC, $valor); + + // configuracion.inc + $mensaje = is_writable(CONFIGURACION) ? $this->retornaLabel(false, "Se debe poder escribir en el fichero de configuración ". CONFIGURACION) : + $this->retornaLabel(true, "Se debe poder escribir en el fichero de configuración ". CONFIGURACION); + $valor = is_writable(CONFIGURACION) ? "Sí" : "No"; + $info .= $this->retornaElemento($mensaje, 'Se puede escribir en ' . CONFIGURACION, $valor); + + // Final del paso + $info .=''; + $info .= $this->validaPaso0() ? $this->retornaBoton(false, "instalar.php?paso=1") : $this->retornaBoton(true, "instalar.php"); + $panel = $this->panelMensaje($info, 'primary', 'PASO 1: Configuración del servidor y la aplicación'); return $panel; } + private function retornaElemento($validacion, $mensaje, $valor) + { + $info = '
  • '; + $info .= $validacion . ' ' . $mensaje . ': ' . $valor . ''; + $info .= '
  • '; + return $info; + } + + private function retornaBoton($error, $paso, $javascript = true) + { + $anadido = $javascript ? 'onclick="location.href=' . "'" . $paso . "'". '"' : ''; + if (!$error) { + return ''; + } else { + return ''; + } + } private function retornaLabel($error, $mensaje, $tipo = "danger") { @@ -164,38 +209,228 @@ class Instalar { $postMax = ini_get('post_max_size'); $uploadMax = ini_get('upload_max_filesize'); $mysql = extension_loaded('mysqli'); + $escConfig = is_writable(CONFIGURACION); + $escInc = is_writable(INC); + $escTMP = is_writable(TMP); + $escIMG = is_writable(IMAGEDATA); if ($this->retornaBytes($postMax) < MINBYTES) $validar = false; if ($this->retornaBytes($uploadMax) < MINBYTES) $validar = false; if (!$mysql) $validar = false; + if (!$escConfig) + $validar = false; + if (!$escTMP) + $validar = false; + if (!$escIMG) + $validar = false; + if (!$escInc) + $validar = false; return $validar; } // Cuestiones de la base de datos + private function paso1() + { + $grabar = isset($_POST['SERVIDOR']); + //Lee y si hace falta actualiza los datos del formulario en el fichero de configuración + $conf = new Configuracion(); + $fichero = $conf->obtieneFichero(); + $datos = explode("\n", $fichero); + if ($grabar) { + $fsalida = @fopen(CONFIGTMP, "wb"); + } + $campos = 'SERVIDOR,PUERTO,BASEDATOS,USUARIO,CLAVE'; + foreach ($datos as $linea) { + if (stripos($linea, "DEFINE") !== false) { + $conf->obtieneDatos($linea, $clave, $valor); + if (stripos($campos, $clave) !== false) { + if ($grabar) { + $linea = str_replace($valor, $_POST[$clave], $linea); + $valor = $_POST[$clave]; + } + } + $datos[$clave] = $valor; + } + $registro = substr($linea, 0, 2) == "?>" ? $linea : $linea . "\n"; + if ($grabar) { + fwrite($fsalida, $registro); + } + } + if ($grabar) { + fclose($fsalida); + unlink(CONFIGURACION); + rename(CONFIGTMP, CONFIGURACION); + if ($this->validaPaso1()) { + //Pasa al paso siguiente + return $this->paso2(); + } + } + + $info = '
    '; + $info .= '
      '; + $info .= '
    • Datos de configuración
    • '; + $info .= '
    • Servidor
    • '; + $info .= '
    • Puerto
    • '; + $info .= '
    • Base de Datos
    • '; + $info .= '
    • Usuario
    • '; + $info .= '
    • Contraseña
    • '; + $info .= '
    '; + $info .= $this->validaPaso1() ? $this->retornaBoton(false, "instalar.php?paso=1", false) : $this->retornaBoton(true, "instalar.php?paso=1", false); + $info .= '
    '; + $panel = $this->panelMensaje($info, 'primary', 'PASO 2: Configuración de la Base de Datos.'); + return $panel; + } + + private function validaPaso1() + { + $sql = new Sql(SERVIDOR, USUARIO, CLAVE, ''); + if ($sql->error()) + return false; + $sql = new Sql(SERVIDOR, USUARIO, CLAVE, BASEDATOS); + if ($sql->error()) { + return false; + } + $comando = 'create table test2 (id int(10));'; + $sql->ejecuta($comando); + if ($sql->error()) { + return false; + } + $comando = 'drop table test2;'; + $sql->ejecuta($comando); + if ($sql->error()) { + return false; + } + return true; + } + + // Usuario administrador private function paso2() { + if (isset($_POST['usuario'])) { + //ha enviado el formulario. + //Crea la base de datos + $borra_database = "DROP DATABASE IF EXISTS " . BASEDATOS . ";"; + $database = "CREATE DATABASE " . BASEDATOS . " DEFAULT CHARACTER SET utf8;"; + $articulos = "CREATE TABLE `Articulos` ( + `id` smallint(6) NOT NULL auto_increment COMMENT 'ordenable', + `descripcion` varchar(60) NOT NULL COMMENT 'ordenable,link/Articulo', + `marca` varchar(20) default NULL COMMENT 'ordenable', + `modelo` varchar(20) default NULL COMMENT 'ordenable', + `cantidad` int(11) default NULL COMMENT 'ordenable', + `imagen` varchar(45) default NULL COMMENT 'imagen', + PRIMARY KEY (`id`) + ) ENGINE=InnoDB AUTO_INCREMENT=769 DEFAULT CHARSET=utf8; + "; + $ubicaciones = "CREATE TABLE `Ubicaciones` ( + `id` smallint(5) unsigned NOT NULL auto_increment COMMENT 'ordenable', + `Descripcion` varchar(50) NOT NULL COMMENT 'ordenable,link/Ubicacion', + `imagen` varchar(45) DEFAULT NULL COMMENT 'imagen', + PRIMARY KEY (`id`) + ) ENGINE=InnoDB AUTO_INCREMENT=179 DEFAULT CHARSET=utf8; + "; + $elementos = "CREATE TABLE `Elementos` ( + `id` int(10) unsigned NOT NULL auto_increment COMMENT 'ordenable', + `id_Articulo` smallint(6) NOT NULL COMMENT 'foreign(Articulos;id),ordenable', + `id_Ubicacion` smallint(5) unsigned NOT NULL COMMENT 'foreign(Ubicaciones;id),ordenable', + `numserie` varchar(30) default NULL COMMENT 'ordenable', + `cantidad` int(10) unsigned default NULL COMMENT 'ordenable', + `fechaCompra` date NOT NULL COMMENT 'ordenable', + `imagen` varchar(45) default NULL COMMENT 'imagen', + PRIMARY KEY (`id`), + KEY `id` (`id`), + KEY `id_Articulo` (`id_Articulo`), + KEY `id_Ubicacion` (`id_Ubicacion`), + CONSTRAINT `Elementos_ibfk_1` FOREIGN KEY (`id_Articulo`) REFERENCES `Articulos` (`id`) ON DELETE CASCADE, + CONSTRAINT `Elementos_ibfk_2` FOREIGN KEY (`id_Ubicacion`) REFERENCES `Ubicaciones` (`id`) ON UPDATE CASCADE + ) ENGINE=InnoDB AUTO_INCREMENT=1789 DEFAULT CHARSET=utf8; + "; + $usuarios = "CREATE TABLE `Usuarios` ( + `id` int(10) unsigned NOT NULL auto_increment COMMENT 'ordenable', + `nombre` varchar(16) NOT NULL default '', + `clave` varchar(32) NOT NULL default '', + `idSesion` varchar(20) NOT NULL default '', + `alta` tinyint(1) NOT NULL default '0', + `modificacion` tinyint(1) NOT NULL default '0', + `borrado` tinyint(1) NOT NULL default '0', + `consulta` tinyint(1) NOT NULL default '1', + `informe` tinyint(1) NOT NULL default '1', + `usuarios` tinyint(1) NOT NULL default '0', + `config` tinyint(1) NOT NULL default '0', + PRIMARY KEY (`id`), + KEY `nombre` (`nombre`) + ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8; + "; + $letras = "abcefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; + $sesion = substr(str_shuffle($letras), 0, 8); + $usuario = $_POST['usuario']; + $clave = $_POST['clave']; + $administrador = "insert into Usuarios values (null,'$usuario','$clave','$sesion','1','1','1','1','1','1','1');"; + + @mysqli_query($borra_database); + @mysqli_query($database); + $sql = new Sql(SERVIDOR, USUARIO, CLAVE, BASEDATOS); + $sql->ejecuta($ubicaciones); + if ($sql->error()) { + return $this->panelMensaje($sql->mensajeError(), "danger", "ERROR"); + } + $sql->ejecuta($articulos); + if ($sql->error()) { + return $this->panelMensaje($sql->mensajeError(), "danger", "ERROR"); + } + $sql->ejecuta($elementos); + if ($sql->error()) { + return $this->panelMensaje($sql->mensajeError(), "danger", "ERROR"); + } + $sql->ejecuta($usuarios); + if ($sql->error()) { + return $this->panelMensaje($sql->mensajeError(), "danger", "ERROR"); + } + $sql->ejecuta($administrador); + if ($sql->error()) { + return $this->panelMensaje($sql->mensajeError(), "danger", "ERROR"); + } + return $this->resumen(); + } + $info = ' +
    +
    + +
    + +
    Mínimo 5 caracteres
    +
    +
    + +
    + +
    + + Mínimo 6 caracteres + +
    Mínimo 6 caracteres
    +
    +
    + +
    + +
    + +
    + '; + $panel = $this->panelMensaje($info, 'primary', 'PASO 3: Creación de la base de datos y el usuario administrador.'); + return $panel; } private function validaPaso2() { - return false; + //La validación de este paso se hace con la del formulario en javascript + return true; } - // Usuario administrador - private function paso3() - { - - } - - private function validaPaso3() - { - return false; - } - - private function panelMensaje($info, $tipo = "info", $cabecera = "¡Atención!") { + public function panelMensaje($info, $tipo = "info", $cabecera = "¡Atención!") { $mensaje = '
    '; $mensaje .= '

    ' . $cabecera . '

    '; $mensaje .= '
    '; @@ -238,11 +473,45 @@ class Instalar { public function fecha() { $idioma = 'es_ES'; - if ($formato == '') - $formato = "%d-%b-%y"; + $formato = "%d-%b-%y"; setlocale(LC_TIME, $idioma); return strftime($formato); } + public function cabecera() + { + return ' + + + + + + + + + + Inventario + + + + + + + + + + + + + + + '; + } + + private function resumen() + { + return 'Todo se ha hecho correctamente'; + + } } -?> +?> \ No newline at end of file diff --git a/css/validator.min.js b/css/validator.min.js new file mode 100755 index 0000000..591c37b --- /dev/null +++ b/css/validator.min.js @@ -0,0 +1,9 @@ +/*! + * Validator v0.2.1 for Bootstrap 3, by @1000hz + * Copyright 2014 Spiceworks, Inc. + * Licensed under http://opensource.org/licenses/MIT + * + * https://github.com/1000hz/bootstrap-validator + */ + ++function(a){"use strict";var b=function(b,c){this.$element=a(b),this.options=c,this.toggleSubmit(),this.$element.on("input.bs.validator blur.bs.validator",":input",a.proxy(this.validateInput,this)),this.$element.find("[data-match]").each(function(){var b=a(this),c=b.data("match");a(c).on("input.bs.validator",function(){b.val()&&b.trigger("input")})})};b.DEFAULTS={delay:500,errors:{match:"Does not match",minlength:"Not long enough"}},b.VALIDATORS={"native":function(a){var b=a[0];return b.checkValidity?b.checkValidity():!0},match:function(b){var c=b.data("match");return!b.val()||b.val()===a(c).val()},minlength:function(a){var b=a.data("minlength");return!a.val()||a.val().length>=b}},b.prototype.validateInput=function(b){var c,d=a(b.target),e=d.data("bs.errors");this.$element.trigger(b=a.Event("validate.bs.validator",{relatedTarget:d[0]})),b.isDefaultPrevented()||(d.data("bs.errors",c=this.runValidators(d)),c.length?this.showErrors(d):this.clearErrors(d),e&&c.toString()===e.toString()||(b=c.length?a.Event("invalid.bs.validator",{relatedTarget:d[0],detail:c}):a.Event("valid.bs.validator",{relatedTarget:d[0],detail:e}),this.$element.trigger(b)),this.toggleSubmit(),this.$element.trigger(a.Event("validated.bs.validator",{relatedTarget:d[0]})))},b.prototype.runValidators=function(c){{var d=[];[b.VALIDATORS.native]}return a.each(b.VALIDATORS,a.proxy(function(a,b){if((c.data(a)||"native"==a)&&!b.call(this,c)){var e=c.data(a+"-error")||c.data("error")||"native"==a&&c[0].validationMessage||this.options.errors[a];!~d.indexOf(e)&&d.push(e)}},this)),d},b.prototype.validate=function(){var a=this.options.delay;return this.options.delay=0,this.$element.find(":input").trigger("input"),this.options.delay=a,this},b.prototype.showErrors=function(b){function c(){var c=b.closest(".form-group"),d=c.find(".help-block.with-errors"),e=b.data("bs.errors");e.length&&(e=a("
      ").addClass("list-unstyled").append(a.map(e,function(b){return a("
    • ").text(b)})),void 0===d.data("bs.originalContent")&&d.data("bs.originalContent",d.html()),d.empty().append(e),c.addClass("has-error"))}this.options.delay?(window.clearTimeout(b.data("bs.timeout")),b.data("bs.timeout",window.setTimeout(c,this.options.delay))):c()},b.prototype.clearErrors=function(a){var b=a.closest(".form-group"),c=b.find(".help-block.with-errors");c.html(c.data("bs.originalContent")),b.removeClass("has-error")},b.prototype.hasErrors=function(){function b(){return!!(a(this).data("bs.errors")||[]).length}return!!this.$element.find(":input").filter(b).length},b.prototype.isIncomplete=function(){function b(){return""===a.trim(this.value)}return!!this.$element.find("[required]").filter(b).length},b.prototype.toggleSubmit=function(){var a=this.$element.find(":submit");a.attr("disabled",this.isIncomplete()||this.hasErrors())};var c=a.fn.validator;a.fn.validator=function(c){return this.each(function(){var d=a(this),e=a.extend({},b.DEFAULTS,d.data(),"object"==typeof c&&c),f=d.data("bs.validator");f||d.data("bs.validator",f=new b(this,e)),"string"==typeof c&&f[c]()})},a.fn.validator.Constructor=b,a.fn.validator.noConflict=function(){return a.fn.validator=c,this},a(window).on("load",function(){a('form[data-toggle="validator"]').each(function(){var b=a(this);b.validator(b.data())})})}(jQuery); \ No newline at end of file diff --git a/sql/setup.sql b/sql/setup.sql index 01fcf86..7bcefb8 100644 --- a/sql/setup.sql +++ b/sql/setup.sql @@ -98,15 +98,7 @@ CREATE TABLE `Usuarios` ( ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; SET character_set_client = @saved_cs_client; --- --- Usuarios iniciales --- -LOCK TABLES `Usuarios` WRITE; -/*!40000 ALTER TABLE `Usuarios` DISABLE KEYS */; -INSERT INTO `Usuarios` VALUES (1,'admin','pruebas','s3LUSqxg{s',1,1,1,1,1,1,1),(2,'demo','pruebas','NogP_U0Byi',0,0,0,1,1,0,0); -/*!40000 ALTER TABLE `Usuarios` ENABLE KEYS */; -UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; From 1a5266d20175bbb9904247ca8de0ba0b4c86971a Mon Sep 17 00:00:00 2001 From: rmontanana Date: Sun, 6 Apr 2014 04:15:32 +0200 Subject: [PATCH 3/6] =?UTF-8?q?solve=20#23=20Arreglado=20a=C3=B1adiendo=20?= =?UTF-8?q?en=20insertar=20un=20valor=20null=20en=20el=20caso=20de=20"NOHA?= =?UTF-8?q?CERNADA"=20Arreglado=20peque=C3=B1o=20problema=20de=20formato?= =?UTF-8?q?=20del=20grid=20bootstrap=20en=20resoluciones=20peque=C3=B1as.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AportaContenido.php | 24 +++++++++- CHANGELOG | 2 + Instalar.php | 103 ++++++++++++++++++++++++++++++++++++------ Inventario.php | 5 ++ Sql.php | 2 +- inc/configuracion.inc | 4 +- 6 files changed, 120 insertions(+), 20 deletions(-) diff --git a/AportaContenido.php b/AportaContenido.php index 27cbb57..325daf1 100644 --- a/AportaContenido.php +++ b/AportaContenido.php @@ -28,6 +28,25 @@ define('FORMULARIO_ACCESO', '
      Iniciar
      '); define('MENSAJE_DEMO', 'Puede Iniciar sesión con
      usuario demo
      contraseña demo
      '); define('USUARIO_INCORRECTO', '

      '); +define('CREDITOS', ''); // Esta clase aportará el contenido a la plantilla class AportaContenido { @@ -181,8 +200,9 @@ class AportaContenido { list($opcion, $parametro) = explode("&", $this->opcionActual); switch ($opcion) { case 'principal': // contenido inicial - return '

      ' . PROGRAMA . '' . - '


      ' . PIE; + $creditos = "$('#creditos').modal({keyboard: false});"; + return '

      ' . PROGRAMA . '' . + '


      ' . PIE . CREDITOS; case 'articulos': case 'ubicaciones': case 'test': diff --git a/CHANGELOG b/CHANGELOG index 6d8ea7d..c6da419 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +-Inventario.php llama al instalador si la aplicación no está instalada +-Añadido dialogo modal de Créditos cuando se pulsa sobre el gráfico de código de barras de la aplicación -Quitados los usuarios de ejemplo en el archivo setup.sql -Creado el programa instalar.php que permitirá configurar el acceso a la base de datos, comprobar la configuración del servidor y la creación del usuario administrador -Añadido un parámetro en el archivo configuracion.inc que permite o no ejecutar el programa instalar.php diff --git a/Instalar.php b/Instalar.php index 72269b6..d031f7d 100644 --- a/Instalar.php +++ b/Instalar.php @@ -24,7 +24,8 @@ function __autoload($class_name) { require_once $class_name . '.php'; } -include 'inc/configuracion.inc'; + +require_once 'inc/configuracion.inc'; define('NUMPASOS', 3); //Para el Paso 1 define('MINBYTES', 4096000); // post_max_size y max_upload van con esto @@ -35,13 +36,11 @@ define('TMP', './tmp'); define('INC', './inc'); $instalar = new Instalar(); -if (!$instalar->error) { - echo $instalar->ejecuta(); -} else { - echo $instalar->cabecera(); - echo $instalar->panelMensaje($instalar->error_msj, "danger", "¡ERROR!"); - echo ""; +if ($instalar->error) { + echo $instalar->panelError(); + return; } +echo $instalar->ejecuta(); class Instalar { private $contenido; @@ -173,6 +172,12 @@ class Instalar { } } + private function botonVolver($enlace) + { + $boton = ''; + return $boton; + } + private function retornaLabel($error, $mensaje, $tipo = "danger") { if ($error) { @@ -230,18 +235,61 @@ class Instalar { return $validar; } + private function actualizaConfiguracion($grabar, $campos, &$datos) + { + $conf = new Configuracion(); + $fichero = $conf->obtieneFichero(); + $datosFichero = explode("\n", $fichero); + if ($grabar) { + $fsalida = @fopen(CONFIGTMP, "wb"); + } + foreach ($datosFichero as $linea) { + if (stripos($linea, "DEFINE") !== false) { + $conf->obtieneDatos($linea, $clave, $valor); + if (stripos($campos, $clave) !== false) { + if ($grabar) { + $linea = str_replace($valor, $datos[$clave], $linea); + $valor = $datos[$clave]; + } + } + $datos[$clave] = $valor; + } + $registro = substr($linea, 0, 2) == "?>" ? $linea : $linea . "\n"; + if ($grabar) { + fwrite($fsalida, $registro); + } + } + if ($grabar) { + fclose($fsalida); + unlink(CONFIGURACION); + rename(CONFIGTMP, CONFIGURACION); + } + } + // Cuestiones de la base de datos private function paso1() { - $grabar = isset($_POST['SERVIDOR']); - //Lee y si hace falta actualiza los datos del formulario en el fichero de configuración - $conf = new Configuracion(); + $grabar = isset($_POST['SERVIDOR']); + $campos = 'SERVIDOR,PUERTO,BASEDATOS,USUARIO,CLAVE'; + //Lee y si hace falta actualiza los datos del formulario en el fichero de configuración + if ($grabar) { + foreach ($_POST as $clave => $valor) { + $datos[$clave] = $valor; + } + } else { + $datos = array(); + } + $this->actualizaConfiguracion($grabar, $campos, $datos); + if ($grabar && $this->validaPaso1()) { + //Pasa al paso siguiente + return $this->paso2(); + } + /*$conf = new Configuracion(); $fichero = $conf->obtieneFichero(); $datos = explode("\n", $fichero); if ($grabar) { $fsalida = @fopen(CONFIGTMP, "wb"); } - $campos = 'SERVIDOR,PUERTO,BASEDATOS,USUARIO,CLAVE'; foreach ($datos as $linea) { if (stripos($linea, "DEFINE") !== false) { $conf->obtieneDatos($linea, $clave, $valor); @@ -266,7 +314,7 @@ class Instalar { //Pasa al paso siguiente return $this->paso2(); } - } + }*/ $info = '
      '; $info .= '
        '; @@ -277,6 +325,7 @@ class Instalar { $info .= '
      • Usuario
      • '; $info .= '
      • Contraseña
      • '; $info .= '
      '; + $info .= $this->botonVolver("instalar.php"); $info .= $this->validaPaso1() ? $this->retornaBoton(false, "instalar.php?paso=1", false) : $this->retornaBoton(true, "instalar.php?paso=1", false); $info .= '
      '; $panel = $this->panelMensaje($info, 'primary', 'PASO 2: Configuración de la Base de Datos.'); @@ -311,7 +360,7 @@ class Instalar { if (isset($_POST['usuario'])) { //ha enviado el formulario. //Crea la base de datos - $borra_database = "DROP DATABASE IF EXISTS " . BASEDATOS . ";"; + $borra_database = "DROP DATABASE " . BASEDATOS . " ;"; $database = "CREATE DATABASE " . BASEDATOS . " DEFAULT CHARACTER SET utf8;"; $articulos = "CREATE TABLE `Articulos` ( `id` smallint(6) NOT NULL auto_increment COMMENT 'ordenable', @@ -391,6 +440,9 @@ class Instalar { if ($sql->error()) { return $this->panelMensaje($sql->mensajeError(), "danger", "ERROR"); } + $campos="INSTALADO"; + $datos['INSTALADO'] = "sí"; + $this->actualizaConfiguracion(true, $campos, $datos); return $this->resumen(); } @@ -415,7 +467,8 @@ class Instalar {
    - + ' . $this->botonVolver("instalar.php?paso=1") . ' +
    @@ -507,9 +560,29 @@ class Instalar { '; } + public function panelError() + { + $mensaje = $this->cabecera(); + $mensaje .= $this->panelMensaje($this->error_msj, "danger", "¡ERROR!"); + $mensaje .= ""; + return $mensaje; + } + private function resumen() { - return 'Todo se ha hecho correctamente'; + $info = ''; + $info .= $this->retornaBoton(false, "index.php", true); + $panel = $this->panelMensaje($info, 'success', 'Instalación finalizada.'); + return $panel; } } diff --git a/Inventario.php b/Inventario.php index 2e94ec3..7fb52d9 100644 --- a/Inventario.php +++ b/Inventario.php @@ -40,6 +40,11 @@ class Inventario { // Analizamos la cadena de solicitud para saber // qué opción es la actual $this->opcActual = $_SERVER['QUERY_STRING'] == '' ? 'principal' : $_SERVER['QUERY_STRING']; + //Si el programa no está instalado, llama al instalador. + if (INSTALADO == "no") { + header('location: instalar.php'); + return; + } // Iniciamos una sesión session_start(); //Conexión con la base de datos. diff --git a/Sql.php b/Sql.php index 65a1f14..12aa9b3 100644 --- a/Sql.php +++ b/Sql.php @@ -63,7 +63,7 @@ class Sql { */ public function __construct($servidor,$usuario,$clave,$baseDatos) { - $this->bdd=new mysqli($servidor,$usuario,$clave,$baseDatos); + $this->bdd = @new mysqli($servidor,$usuario,$clave,$baseDatos); if (mysqli_connect_errno()) { $this->mensajeError='

    Fallo al conectar con el servidor MySQL.

    '; $this->mensajeError.="Servidor [".$servidor ."] usuario=[".$usuario."] clave [".$clave."] base [".$baseDatos."]"; diff --git a/inc/configuracion.inc b/inc/configuracion.inc index 0e9a2e9..e075ade 100644 --- a/inc/configuracion.inc +++ b/inc/configuracion.inc @@ -25,7 +25,7 @@ require_once 'version.inc'; define('SERVIDOR', 'localhost'); //Ubicación del servidor MySQL define('PUERTO', '3306'); //Puerto donde se conecta a MySQL -define('BASEDATOS', 'Inventario2'); //Nombre de la base de datos. +define('BASEDATOS', 'Inventario'); //Nombre de la base de datos. define('BASEDATOSTEST', 'Inventario_test'); //Base de datos para los tests. define('USUARIO', 'test'); //Usuario con permisos de lectura/escritura en la base de datos define('CLAVE', 'tset'); //contraseña del usuario. @@ -40,5 +40,5 @@ define('COLORFON', '#ffb878'); //Color del fondo de la pantalla define('MYSQLDUMP', '/usr/local/bin/mysqldump'); //camino a mysqldump define('GZIP', '/usr/bin/gzip'); //Camino a gzip define('IMAGEDATA', 'img.data'); //Directorio donde se almacenarán las imágenes -define('INSTALADO', 'no'); //no = permite la ejecución de instalar.php +define('INSTALADO', 'sí') //Indicador que permite ejecutar instalar.php ?> From 911af4825fefe50066d76243f6b035745914e77c Mon Sep 17 00:00:00 2001 From: rmontanana Date: Mon, 7 Apr 2014 22:56:09 +0200 Subject: [PATCH 4/6] =?UTF-8?q?-Los=20informes=20aparecen=20ahora=20en=20l?= =?UTF-8?q?a=20pantalla=20de=20la=20aplicaci=C3=B3n=20embebidos.=20-A?= =?UTF-8?q?=C3=B1adido=20un=20calendario=20al=20pulsar=20sobre=20la=20fech?= =?UTF-8?q?a=20en=20la=20cabecera=20de=20la=20aplicaci=C3=B3n.=20-Corregid?= =?UTF-8?q?o=20peque=C3=B1o=20problema=20de=20margen=20en=20resoluciones?= =?UTF-8?q?=20peque=C3=B1as=20donde=20se=20solapaba=20parte=20del=20men?= =?UTF-8?q?=C3=BA.=20-Quitados=20los=20logos=20de=20GPLv3,=20MySQL=20y=20A?= =?UTF-8?q?pache=20-Inventario.php=20llama=20al=20instalador=20si=20la=20a?= =?UTF-8?q?plicaci=C3=B3n=20no=20est=C3=A1=20instalada?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AportaContenido.php | 50 ++++++++++++++++----------- CHANGELOG | 7 +++- InformeInventario.php | 80 +++++++++++++++++++++++++++++++------------ Instalar.php | 31 ----------------- Inventario.php | 5 ++- css/dashboard.php | 2 +- inc/configuracion.inc | 2 +- inc/inventario.menu | 4 +-- 8 files changed, 100 insertions(+), 81 deletions(-) diff --git a/AportaContenido.php b/AportaContenido.php index 325daf1..6e7a4da 100644 --- a/AportaContenido.php +++ b/AportaContenido.php @@ -149,7 +149,19 @@ class AportaContenido { return "Usuario=$this->usuario"; else return ''; - case 'fecha': return $this->fechaActual(); + case 'fecha': + $script = '"; + $campo = ''; + $etiqueta = ''; + return $etiqueta . $campo . $script; case 'aplicacion': return PROGRAMA." v".VERSION; case 'menu': // el menú if ($this->registrado) { @@ -199,10 +211,14 @@ class AportaContenido { // } list($opcion, $parametro) = explode("&", $this->opcionActual); switch ($opcion) { + case 'bienvenido': + $mensaje = '
    '; + $mensaje .= 'Bienvenid@ ' . $this->usuario . '
    '; case 'principal': // contenido inicial + $creditos = "$('#creditos').modal({keyboard: false});"; - return '

    ' . PROGRAMA . '' . - '


    ' . PIE . CREDITOS; + return $mensaje . '

    ' . PROGRAMA . '' . + '



    ' . CREDITOS; case 'articulos': case 'ubicaciones': case 'test': @@ -266,12 +282,6 @@ class AportaContenido { } else { return $this->mensajePermisos('Usuarios'); } - - case 'bienvenido': // El usuario quiere iniciar sesión - $mensaje = '
    '; - $mensaje .= 'Bienvenid@ ' . $this->usuario . '


    ' . PROGRAMA . '' . - '


    ' . PIE;; - return $mensaje; case 'configuracion': if ($this->perfil['Config']) { $conf = new Configuracion(); @@ -286,17 +296,17 @@ class AportaContenido { } else { return $this->mensajePermisos('Informes'); } - case 'descuadres': - if ($this->perfil['Informe']) { - $enlace = 'xml/informe' . ucfirst($opcion) . '.xml'; - $informe = new InformePDF($this->bdd, $enlace, $this->registrado); - $informe->crea($enlace); - $informe->cierraPDF(); - $informe->imprimeInforme(); - return; - } else { - return $this->mensajePermisos('Informes'); - } +// case 'descuadres': +// if ($this->perfil['Informe']) { +// $enlace = 'xml/informe' . ucfirst($opcion) . '.xml'; +// $informe = new InformePDF($this->bdd, $enlace, $this->registrado); +// $informe->crea($enlace); +// $informe->cierraPDF(); +// $informe->imprimeInforme(); +// return; +// } else { +// return $this->mensajePermisos('Informes'); +// } case 'importacion': if ($this->perfil['Modificacion'] && $this->perfil['Borrado']) { $import = new Importacion($this->bdd, $this->registrado); diff --git a/CHANGELOG b/CHANGELOG index c6da419..6f49fa8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,10 @@ +Versión 1.08 07-04-2014 +-Los informes aparecen ahora en la pantalla de la aplicación embebidos. +-Añadido un calendario al pulsar sobre la fecha en la cabecera de la aplicación. +-Corregido pequeño problema de margen en resoluciones pequeñas donde se solapaba parte del menú. +-Quitados los logos de GPLv3, MySQL y Apache -Inventario.php llama al instalador si la aplicación no está instalada --Añadido dialogo modal de Créditos cuando se pulsa sobre el gráfico de código de barras de la aplicación +-Añadido dialogo modal de Créditos cuando se pulsa sobre el gráfico de código de barras de la aplicación o sobre el nombre del centro -Quitados los usuarios de ejemplo en el archivo setup.sql -Creado el programa instalar.php que permitirá configurar el acceso a la base de datos, comprobar la configuración del servidor y la creación del usuario administrador -Añadido un parámetro en el archivo configuracion.inc que permite o no ejecutar el programa instalar.php diff --git a/InformeInventario.php b/InformeInventario.php index 03c493c..f3d9d02 100644 --- a/InformeInventario.php +++ b/InformeInventario.php @@ -23,11 +23,13 @@ class InformeInventario { private $bdd; - public function __construct($baseDatos) { + public function __construct($baseDatos) + { $this->bdd = $baseDatos; } - public function ejecuta() { + public function ejecuta() + { $opc = $_GET['opc']; switch ($opc) { case 'Ubicacion':return $this->formularioUbicacion(); @@ -35,10 +37,33 @@ class InformeInventario { case 'listarArticulo':return $this->listarArticulo(); case 'Articulo':return $this->formularioArticulo(); case 'Total':return $this->inventarioTotal(); + case 'descuadres': return $this->inventarioDescuadres(); } } - private function listarUbicacion() { + private function inventarioDescuadres() + { + $enlace = 'xml/informeDescuadres.xml'; + $informe = new InformePDF($this->bdd, $enlace, true); + $informe->crea($enlace); + $informe->cierraPDF(); + return $this->devuelveInforme($informe); + } + + private function devuelveInforme($informe) + { + $letras = "abcefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; + $nombre = "tmp/informe" . substr(str_shuffle($letras), 0, 10) . ".pdf"; + $informe->guardaArchivo($nombre); + return '
    + + + +
    '; + } + + private function listarUbicacion() + { $salidaInforme = isset($_POST['salida']) ? $_POST['salida'] : 'pantalla'; switch ($salidaInforme) { case "pantalla": @@ -70,8 +95,9 @@ class InformeInventario { $informe = new InformePDF($this->bdd, $salida, true); $informe->crea($salida); $informe->cierraPDF(); - $informe->guardaArchivo("tmp/Informe.pdf"); - echo ''; + return $this->devuelveInforme($informe); +// $informe->guardaArchivo("tmp/Informe.pdf"); +// echo ''; break; case "csv": //Genera una hoja de cálculo en formato csv @@ -85,13 +111,15 @@ class InformeInventario { $etiquetas = new EtiquetasPDF($this->bdd, $salida, true); $etiquetas->crea($salida); $etiquetas->cierraPDF(); - $etiquetas->guardaArchivo("tmp/EtiquetasUbicacion.pdf"); - echo ''; + return $this->devuelveInforme($etiquetas); +// $etiquetas->guardaArchivo("tmp/EtiquetasUbicacion.pdf"); +// echo ''; break; } } - private function listarArticulo() { + private function listarArticulo() + { $salidaInforme = isset($_POST['salida']) ? $_POST['salida'] : 'pantalla'; switch ($salidaInforme) { case "pantalla": @@ -125,9 +153,9 @@ class InformeInventario { $informe = new InformePDF($this->bdd, $salida, true); $informe->crea($salida); $informe->cierraPDF(); - $informe->guardaArchivo("tmp/Informe.pdf"); - echo ''; - break; + return $this->devuelveInforme($informe); +// $informe->guardaArchivo("tmp/Informe.pdf"); +// echo ''; case "csv": //Genera una hoja de cálculo en formato csv $nombre = "tmp/Articulo" . strftime("%Y%m%d") . rand(100, 999) . ".csv"; @@ -140,13 +168,14 @@ class InformeInventario { $etiquetas = new EtiquetasPDF($this->bdd, $salida, true); $etiquetas->crea($salida); $etiquetas->cierraPDF(); - $etiquetas->guardaArchivo("tmp/EtiquetasArticulo.pdf"); - echo ''; - break; + return $this->devuelveInforme($etiquetas); +// $etiquetas->guardaArchivo("tmp/EtiquetasArticulo.pdf"); +// echo ''; } } - private function listaUbicaciones() { + private function listaUbicaciones() + { $salida = "\n"; $comando = "select * from Articulos order by descripcion, marca, modelo"; $resultado = $this->bdd->ejecuta($comando); @@ -174,8 +204,9 @@ class InformeInventario { return $salida; } - private function formulario($accion, $etiqueta, $lista) { - $salida ='
    ' . "\n"; + private function formulario($accion, $etiqueta, $lista) + { + $salida = '
    ' . "\n"; $salida.="

    Elige $etiqueta\n"; $salida.="

    "; $salida.=$lista; @@ -190,18 +221,21 @@ class InformeInventario { return $salida; } - private function formularioUbicacion() { + private function formularioUbicacion() + { //Genera un formulario con las ubicaciones disponibles. $accion = "index.php?informeInventario&opc=listarUbicacion"; return $this->formulario($accion, 'Ubicación', $this->listaUbicaciones()); } - private function formularioArticulo() { + private function formularioArticulo() + { $accion = "index.php?informeInventario&opc=listarArticulo"; return $this->formulario($accion, 'Artículo', $this->listaArticulos()); } - private function inventarioTotal() { + private function inventarioTotal() + { $fichero = "xml/inventarioUbicacion.xml"; $salida = "tmp/inventarioUbicacion.xml"; $comando = "select * from Ubicaciones ;"; @@ -226,8 +260,10 @@ class InformeInventario { } $nombre = "tmp/total.pdf"; $informe->cierraPDF(); - $informe->imprimeInforme(); + return $this->devuelveInforme($informe); + //$informe->imprimeInforme(); } + } ?> diff --git a/Instalar.php b/Instalar.php index d031f7d..757848b 100644 --- a/Instalar.php +++ b/Instalar.php @@ -284,37 +284,6 @@ class Instalar { //Pasa al paso siguiente return $this->paso2(); } - /*$conf = new Configuracion(); - $fichero = $conf->obtieneFichero(); - $datos = explode("\n", $fichero); - if ($grabar) { - $fsalida = @fopen(CONFIGTMP, "wb"); - } - foreach ($datos as $linea) { - if (stripos($linea, "DEFINE") !== false) { - $conf->obtieneDatos($linea, $clave, $valor); - if (stripos($campos, $clave) !== false) { - if ($grabar) { - $linea = str_replace($valor, $_POST[$clave], $linea); - $valor = $_POST[$clave]; - } - } - $datos[$clave] = $valor; - } - $registro = substr($linea, 0, 2) == "?>" ? $linea : $linea . "\n"; - if ($grabar) { - fwrite($fsalida, $registro); - } - } - if ($grabar) { - fclose($fsalida); - unlink(CONFIGURACION); - rename(CONFIGTMP, CONFIGURACION); - if ($this->validaPaso1()) { - //Pasa al paso siguiente - return $this->paso2(); - } - }*/ $info = ''; $info .= '

      '; diff --git a/Inventario.php b/Inventario.php index 7fb52d9..2c9f78e 100644 --- a/Inventario.php +++ b/Inventario.php @@ -50,9 +50,9 @@ class Inventario { //Conexión con la base de datos. $this->bdd = new Sql(SERVIDOR, USUARIO, CLAVE, BASEDATOS); if ($this->bdd->error()) { + echo '

      Fallo al conectar con el servidor MySQL.

      '; - echo SERVIDOR; - echo "Servidor [ " . SERVIDOR . " ] usuario [" . USUARIO . "] clave [" . CLAVE . "] base [" . BASEDATOS . "]"; + echo "Servidor [ " . SERVIDOR . " ] base de datos [" . BASEDATOS . "]"; $this->estado = false; return; } else { @@ -203,7 +203,6 @@ class Inventario { $_SESSION['Perfil'] = $this->perfil; } } - } ?> diff --git a/css/dashboard.php b/css/dashboard.php index 280dc6c..c88a8f5 100644 --- a/css/dashboard.php +++ b/css/dashboard.php @@ -33,7 +33,7 @@ display: none; } @media (max-width: 767px) { .sidebar { -top: 50px; +top: 60px; bottom: 150px; background-color: } diff --git a/inc/configuracion.inc b/inc/configuracion.inc index e075ade..8660140 100644 --- a/inc/configuracion.inc +++ b/inc/configuracion.inc @@ -25,7 +25,7 @@ require_once 'version.inc'; define('SERVIDOR', 'localhost'); //Ubicación del servidor MySQL define('PUERTO', '3306'); //Puerto donde se conecta a MySQL -define('BASEDATOS', 'Inventario'); //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('CLAVE', 'tset'); //contraseña del usuario. diff --git a/inc/inventario.menu b/inc/inventario.menu index b0e2562..8db5877 100644 --- a/inc/inventario.menu +++ b/inc/inventario.menu @@ -6,8 +6,8 @@ 1|Inventario||| 2|Ubicación|index.php?informeInventario&opc=Ubicacion|_self|Inventario de una ubicación 2|Artículo|index.php?informeInventario&opc=Articulo|_self|Inventario de un Artículo -2|Total|index.php?informeInventario&opc=Total|_blank|Inventario de todas las ubicaciones -2|Descuadres|index.php?descuadres|_blank|Diferencias entre artículos y elementos +2|Total|index.php?informeInventario&opc=Total|_self|Inventario de todas las ubicaciones +2|Descuadres|index.php?informeInventario&opc=descuadres|_self|Diferencias entre artículos y elementos 1|Varios||| 2|Configuración|index.php?configuracion|_self|Opciones configurables de la aplicación 2|Importación|index.php?importacion&opc=form|_self|Importa datos de una hoja de cálculo From aa84cabf839a6370442e6811b68603f5f5585660 Mon Sep 17 00:00:00 2001 From: rmontanana Date: Mon, 7 Apr 2014 23:01:25 +0200 Subject: [PATCH 5/6] =?UTF-8?q?Quitados=20los=20comentarios=20y=20el=20c?= =?UTF-8?q?=C3=B3digo=20anteriormente=20utilizado?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- InformeInventario.php | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/InformeInventario.php b/InformeInventario.php index f3d9d02..47953a4 100644 --- a/InformeInventario.php +++ b/InformeInventario.php @@ -96,9 +96,6 @@ class InformeInventario { $informe->crea($salida); $informe->cierraPDF(); return $this->devuelveInforme($informe); -// $informe->guardaArchivo("tmp/Informe.pdf"); -// echo ''; - break; case "csv": //Genera una hoja de cálculo en formato csv $nombre = "tmp/Ubicacion" . strftime("%Y%m%d") . rand(100, 999) . ".csv"; @@ -112,9 +109,6 @@ class InformeInventario { $etiquetas->crea($salida); $etiquetas->cierraPDF(); return $this->devuelveInforme($etiquetas); -// $etiquetas->guardaArchivo("tmp/EtiquetasUbicacion.pdf"); -// echo ''; - break; } } @@ -154,8 +148,6 @@ class InformeInventario { $informe->crea($salida); $informe->cierraPDF(); return $this->devuelveInforme($informe); -// $informe->guardaArchivo("tmp/Informe.pdf"); -// echo ''; case "csv": //Genera una hoja de cálculo en formato csv $nombre = "tmp/Articulo" . strftime("%Y%m%d") . rand(100, 999) . ".csv"; @@ -169,8 +161,6 @@ class InformeInventario { $etiquetas->crea($salida); $etiquetas->cierraPDF(); return $this->devuelveInforme($etiquetas); -// $etiquetas->guardaArchivo("tmp/EtiquetasArticulo.pdf"); -// echo ''; } } @@ -247,7 +237,6 @@ class InformeInventario { $bdatos = new Sql(SERVIDOR, USUARIO, CLAVE, BASEDATOS); $primero = true; while ($fila = $this->bdd->procesaResultado()) { - //$fila=$this->bdd->procesaResultado(); $plantilla = file_get_contents($fichero) or die('Fallo en la apertura de la plantilla ' . $fichero); $plantilla = str_replace("{id}", $fila['id'], $plantilla); $plantilla = str_replace("{Descripcion}", $fila['Descripcion'], $plantilla); @@ -258,10 +247,8 @@ class InformeInventario { } $informe->crea($salida); } - $nombre = "tmp/total.pdf"; $informe->cierraPDF(); return $this->devuelveInforme($informe); - //$informe->imprimeInforme(); } } From 4b5c9270817efa245ba71dd93bf193935d65e1e8 Mon Sep 17 00:00:00 2001 From: rmontanana Date: Mon, 7 Apr 2014 23:10:23 +0200 Subject: [PATCH 6/6] =?UTF-8?q?Actualizada=20la=20versi=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/version.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/version.inc b/inc/version.inc index b8dab66..f2f00f6 100644 --- a/inc/version.inc +++ b/inc/version.inc @@ -23,5 +23,5 @@ */ define('AUTOR', 'Ricardo Montañana Gómez'); -define('VERSION', '1.07'); +define('VERSION', '1.08'); ?>