1 | <?php |
---|
2 | // ************************************************************************************************************************************************* |
---|
3 | // Aplicación WEB: ogAdmWebCon |
---|
4 | // Autor: José Manuel Alonso (E.T.S.I.I.) Universidad de Sevilla |
---|
5 | // Fecha Creación: Año 2009-2010 |
---|
6 | // Fecha Última modificación: Agosto-2010 |
---|
7 | // Nombre del fichero: gestor_tipohardwares.php |
---|
8 | // Descripción : |
---|
9 | // Gestiona el mantenimiento de la tabla de tipohardwares |
---|
10 | // ************************************************************************************************************************************************* |
---|
11 | include_once("../includes/ctrlacc.php"); |
---|
12 | include_once("../clases/AdoPhp.php"); |
---|
13 | include_once("../clases/XmlPhp.php"); |
---|
14 | include_once("../clases/ArbolVistaXML.php"); |
---|
15 | include_once("../includes/CreaComando.php"); |
---|
16 | include_once("../includes/constantes.php"); |
---|
17 | include_once("../includes/opciones.php"); |
---|
18 | //________________________________________________________________________________________________________ |
---|
19 | $opcion=0; // Inicializa parametros |
---|
20 | |
---|
21 | $idtipohardware=0; |
---|
22 | $descripcion=""; |
---|
23 | $urlimg=""; |
---|
24 | $urlicono=""; |
---|
25 | |
---|
26 | if (isset($_POST["opcion"])) $opcion=$_POST["opcion"]; // Recoge parametros |
---|
27 | |
---|
28 | if (isset($_POST["idtipohardware"])) $idtipohardware=$_POST["idtipohardware"]; |
---|
29 | if (isset($_POST["descripcion"])) $descripcion=$_POST["descripcion"]; |
---|
30 | if (isset($_POST["urlicono"])) $urlicono=$_POST["urlicono"]; |
---|
31 | |
---|
32 | if(empty($urlicono)) |
---|
33 | $urlimg="../images/iconos/confihard.gif"; |
---|
34 | else |
---|
35 | $urlimg="../images/iconos/".$urlicono; |
---|
36 | |
---|
37 | $tablanodo=""; // Arbol para nodos insertados |
---|
38 | $cmd=CreaComando($cadenaconexion); // Crea objeto comando |
---|
39 | $resul=false; |
---|
40 | if ($cmd){ |
---|
41 | $resul=Gestiona(); |
---|
42 | $cmd->Conexion->Cerrar(); |
---|
43 | } |
---|
44 | if($opcion!=$op_movida){ |
---|
45 | echo '<HTML>'; |
---|
46 | echo '<HEAD>'; |
---|
47 | echo ' <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">'; |
---|
48 | echo '<BODY>'; |
---|
49 | echo '<P><SPAN style="visibility:hidden" id="arbol_nodo">'.$tablanodo.'</SPAN></P>'; |
---|
50 | echo ' <SCRIPT language="javascript" src="../jscripts/propiedades_tipohardwares.js"></SCRIPT>'; |
---|
51 | echo '<SCRIPT language="javascript">'.chr(13); |
---|
52 | if ($resul){ |
---|
53 | echo 'var oHTML'.chr(13); |
---|
54 | echo 'var cTBODY=document.getElementsByTagName("TBODY");'.chr(13); |
---|
55 | echo 'o=cTBODY.item(1);'.chr(13); |
---|
56 | } |
---|
57 | } |
---|
58 | $literal=""; |
---|
59 | switch($opcion){ |
---|
60 | case $op_alta : |
---|
61 | $literal="resultado_insertar_tipohardwares"; |
---|
62 | break; |
---|
63 | case $op_modificacion: |
---|
64 | $literal="resultado_modificar_tipohardwares"; |
---|
65 | break; |
---|
66 | case $op_eliminacion : |
---|
67 | $literal="resultado_eliminar_tipohardwares"; |
---|
68 | break; |
---|
69 | default: |
---|
70 | break; |
---|
71 | } |
---|
72 | if ($resul){ |
---|
73 | if ($opcion==$op_alta ) |
---|
74 | echo $literal."(1,'".$cmd->DescripUltimoError()." ',".$idtipohardware.",o.innerHTML);".chr(13); |
---|
75 | else |
---|
76 | echo $literal."(1,'".$cmd->DescripUltimoError()." ','".$descripcion."');".chr(13); |
---|
77 | } |
---|
78 | else |
---|
79 | echo $literal."(0,'".$cmd->DescripUltimoError()."',".$idtipohardware.")"; |
---|
80 | |
---|
81 | if($opcion!=$op_movida){ |
---|
82 | echo ' </SCRIPT>'; |
---|
83 | echo '</BODY> '; |
---|
84 | echo '</HTML>'; |
---|
85 | } |
---|
86 | /************************************************************************************************************************************************** |
---|
87 | Inserta, modifica o elimina datos en la tabla tipohardwares |
---|
88 | ________________________________________________________________________________________________________*/ |
---|
89 | function Gestiona(){ |
---|
90 | global $cmd; |
---|
91 | global $opcion; |
---|
92 | |
---|
93 | global $idtipohardware; |
---|
94 | global $descripcion; |
---|
95 | global $urlimg; |
---|
96 | |
---|
97 | global $op_alta; |
---|
98 | global $op_modificacion; |
---|
99 | global $op_eliminacion; |
---|
100 | global $tablanodo; |
---|
101 | |
---|
102 | $cmd->CreaParametro("@idtipohardware",$idtipohardware,1); |
---|
103 | $cmd->CreaParametro("@descripcion",$descripcion,0); |
---|
104 | $cmd->CreaParametro("@urlimg",$urlimg,0); |
---|
105 | |
---|
106 | switch($opcion){ |
---|
107 | case $op_alta : |
---|
108 | $cmd->texto="INSERT INTO tipohardwares(descripcion,urlimg) VALUES (@descripcion,@urlimg)"; |
---|
109 | $resul=$cmd->Ejecutar(); |
---|
110 | if ($resul){ // Crea una tabla nodo para devolver a la página que llamó ésta |
---|
111 | $idtipohardware=$cmd->Autonumerico(); |
---|
112 | $arbolXML=SubarbolXML_tipohardwares($idtipohardware,$descripcion,$urlimg); |
---|
113 | $baseurlimg="../images/signos"; // Url de las imagenes de signo |
---|
114 | $clasedefault="texto_arbol"; // Hoja de estilo (Clase por defecto) del árbol |
---|
115 | $arbol=new ArbolVistaXML($arbolXML,0,$baseurlimg,$clasedefault); |
---|
116 | $tablanodo=$arbol->CreaArbolVistaXML(); |
---|
117 | } |
---|
118 | break; |
---|
119 | case $op_modificacion: |
---|
120 | $cmd->texto="UPDATE tipohardwares SET descripcion=@descripcion,urlimg=@urlimg WHERE idtipohardware=@idtipohardware"; |
---|
121 | $resul=$cmd->Ejecutar(); |
---|
122 | break; |
---|
123 | case $op_eliminacion : |
---|
124 | $cmd->texto="DELETE FROM tipohardwares WHERE idtipohardware=".$idtipohardware; |
---|
125 | $resul=$cmd->Ejecutar(); |
---|
126 | break; |
---|
127 | default: |
---|
128 | break; |
---|
129 | } |
---|
130 | return($resul); |
---|
131 | } |
---|
132 | /*________________________________________________________________________________________________________ |
---|
133 | Crea un arbol XML para el nuevo nodo insertado |
---|
134 | ________________________________________________________________________________________________________*/ |
---|
135 | function SubarbolXML_tipohardwares($idtipohardware,$descripcion,$urlimg){ |
---|
136 | global $LITAMBITO_TIPOHARDWARES; |
---|
137 | $cadenaXML.='<TIPOHARDWARES'; |
---|
138 | // Atributos |
---|
139 | if ($urlimg) |
---|
140 | $cadenaXML.=' imagenodo='.$urlimg; |
---|
141 | else |
---|
142 | $cadenaXML.=' imagenodo="../images/iconos/confihard.gif"'; |
---|
143 | $cadenaXML.=' infonodo="'.$descripcion.'"'; |
---|
144 | $cadenaXML.=' clickcontextualnodo="menu_contextual(this,' ."'flo_".$LITAMBITO_TIPOHARDWARES."'" .')"'; |
---|
145 | $cadenaXML.=' nodoid='.$LITAMBITO_TIPOHARDWARES.'-'.$idtipohardware; |
---|
146 | $cadenaXML.='>'; |
---|
147 | $cadenaXML.='</TIPOHARDWARES>'; |
---|
148 | return($cadenaXML); |
---|
149 | } |
---|
150 | |
---|