diff --git a/Mantenimiento.php b/Mantenimiento.php index cc5a558..a0e9d80 100644 --- a/Mantenimiento.php +++ b/Mantenimiento.php @@ -142,15 +142,15 @@ class Mantenimiento { } // Comprueba si tiene que añadir el enlace de inventario if (strstr($this->campos[$clave]['Comment'], "link")) { - $comen = explode(",", $this->campos[$clave]['Comment']); - foreach ($comen as $co) { - if (strstr($co, "link")) { - $tmpco = explode("/", $co); - $datoEnlace = $tmpco[1]; - } - } - $this->campoBusca = $dato[1]; - $valor = '' . $valor; + $comen = explode(",", $this->campos[$clave]['Comment']); + foreach ($comen as $co) { + if (strstr($co, "link")) { + $tmpco = explode("/", $co); + $datoEnlace = $tmpco[1]; + } + } + $this->campoBusca = $dato[1]; + $valor = '' . $valor; } $salida.="$valor\n"; } @@ -243,7 +243,8 @@ class Mantenimiento { } else { $coma = ","; } - $comando.="$coma \"$_POST[$campo]\""; + $valor = $_POST[$campo] == "" ? "null" : '"' . $_POST[$campo] . '"'; + $comando.="$coma " . $valor; } $comando.=")"; if (!$this->bdd->ejecuta($comando)) { @@ -360,7 +361,7 @@ class Mantenimiento { $def = simplexml_load_file($nombre); foreach ($def->Campos->Col as $columna) { $this->campos[(string) $columna['Nombre']] = array("Field" => (string) $columna['Titulo'], "Comment" => (string) $columna['Varios'], - "Type" => (string) $columna['Tipo']."(".$columna['Ancho'].")", "Editable" => (string) $columna['Editable'], "Campo" => (string) $columna['Campo']); + "Type" => (string) $columna['Tipo'] . "(" . $columna['Ancho'] . ")", "Editable" => (string) $columna['Editable'], "Campo" => (string) $columna['Campo']); } $this->comandoConsulta = $def->Consulta; } else { @@ -409,7 +410,7 @@ class Mantenimiento { * @return array lista de campos y formulario de entrada */ private function formularioCampos($accion, $tipo, $datos) { - $modo = $tipo == BORRAR ? "readonly" : ""; + $modo = $tipo == BORRADO ? "readonly" : ""; $salida.='
' . "\n"; $salida.="

$tipo\n"; foreach ($this->campos as $clave => $valor) { @@ -422,6 +423,9 @@ class Mantenimiento { //Se asegura que el id no se pueda modificar. $modoEfectivo = $clave == 'id' ? "readonly" : $modo; $valorDato = $datos == null ? "" : $datos[$campo]; + if ($clave == 'id' && $tipo == ANADIR) { + $valorDato = null; + } if (!isset($this->foraneas[$valor['Campo']])) { $tipoCampo = $valor['Type']; //Si es un campo fecha u hora y está insertando pone la fecha actual o la hora actual @@ -443,7 +447,7 @@ class Mantenimiento { $tipo_campo = "text"; //Si no es una clave foránea añade un campo de texto normal $salida.='

\n"; + '" maxlength="' . $tamano . '" size="' . (string) (intval($tamano) + 5) . '" ' . $modoEfectivo . " >

\n"; } else { $salida.=$this->generaLista($this->foraneas[$campo], $campo, $valorDato, $modoEfectivo); } diff --git a/sql/inv2.sql b/sql/inv2.sql index da7bc07..b99181b 100644 --- a/sql/inv2.sql +++ b/sql/inv2.sql @@ -24,7 +24,7 @@ SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; CREATE TABLE `Articulos` ( `id` smallint(6) NOT NULL auto_increment, - `descripcion` varchar(60) NOT NULL 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', @@ -84,7 +84,7 @@ SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; CREATE TABLE `Ubicaciones` ( `id` smallint(5) unsigned NOT NULL auto_increment, - `Descripcion` varchar(30) NOT NULL COMMENT 'ordenable', + `Descripcion` varchar(30) NOT NULL COMMENT 'ordenable,link/Ubicacion', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=184 DEFAULT CHARSET=latin1; SET character_set_client = @saved_cs_client; diff --git a/xml/mantenimientoUsuarios.xml b/xml/mantenimientoUsuarios.xml index c57635c..e924f41 100644 --- a/xml/mantenimientoUsuarios.xml +++ b/xml/mantenimientoUsuarios.xml @@ -9,7 +9,7 @@ - +