Arreglado nuevamente el mantenimiento para permitir altas y hacer que no sean editables los campos del formulario en las bajas

Arreglada la estructura de la base de datos para permitir enlaces a inventario de artículos y ubicaciones desde el mantenimiento
This commit is contained in:
2014-02-18 21:34:17 +01:00
parent 4cd5452d33
commit 682f875ebf
3 changed files with 20 additions and 16 deletions

View File

@@ -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 = '<a title="Inventario de '.$valor.'" $target="_blank" href="index.php?informeInventario&opc=listar' . $datoEnlace . '&id=' . $id . '">' . $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 = '<a title="Inventario de ' . $valor . '" $target="_blank" href="index.php?informeInventario&opc=listar' . $datoEnlace . '&id=' . $id . '">' . $valor;
}
$salida.="<td>$valor</td>\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.='<form name="mantenimiento.form" method="post" action="' . $accion . '">' . "\n";
$salida.="<fieldset style=\"width: 96%;\"><p><legend style=\"color: red;\"><b>$tipo</b></legend>\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.='<input type="' . $tipo_campo . '" name="' . $campo . '" value="' . $valorDato .
'" maxlength="' . $tamano . '" size="' . (string) (intval($tamano)+5) . '" ' . $modoEfectivo . " ><br><br>\n";
'" maxlength="' . $tamano . '" size="' . (string) (intval($tamano) + 5) . '" ' . $modoEfectivo . " ><br><br>\n";
} else {
$salida.=$this->generaLista($this->foraneas[$campo], $campo, $valorDato, $modoEfectivo);
}

View File

@@ -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;

View File

@@ -9,7 +9,7 @@
<Col Campo="id" Nombre="id" Ancho="5" Ajuste="D" Titulo="id" Tipo="int(6)"/>
<Col Campo="nombre" Nombre="nombre" Ancho="8" Ajuste="L" Titulo="Nombre" Varios="ordenable" Editable="si"/>
<Col Campo="clave" Nombre="clave" Ancho="16" Ajuste="L" Titulo="Clave" Tipo="Password" Editable="si"/>
<Col Nombre="idSesion" Ancho="32" Ajuste="L" Titulo="id Sesión" Editable="si"/>
<Col Campo="idSesion" Nombre="idSesion" Ancho="32" Ajuste="L" Titulo="id Sesión" Editable="si"/>
<Col Campo="alta" Nombre="Alta" Ancho="1" Ajuste="R" Titulo="Altas" Editable="si"/>
<Col Campo="modificacion" Nombre="modificacion" Ancho="1" Ajuste="R" Titulo="Modificaciones" Editable="si"/>
<Col Campo="borrado" Nombre="borrado" Ancho="1" Ajuste="R" Titulo="Borrados" Editable="si"/>