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_componentehardwares.php |
---|
8 | // Descripción : |
---|
9 | // Gestiona el mantenimiento de la tabla de hardwares |
---|
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/TomaDato.php"); |
---|
17 | include_once("../includes/constantes.php"); |
---|
18 | include_once("../includes/opciones.php"); |
---|
19 | include_once("./relaciones/hardwares_eliminacion.php"); |
---|
20 | //________________________________________________________________________________________________________ |
---|
21 | $opcion=0; // Inicializa parametros |
---|
22 | |
---|
23 | $idhardware=0; |
---|
24 | $descripcion=""; |
---|
25 | $idtipohardware=0; |
---|
26 | $grupoid=0; |
---|
27 | |
---|
28 | $urlimgth=""; // Url de la imagen del tipo de hardware al que pertenece el componente |
---|
29 | |
---|
30 | if (isset($_POST["opcion"])) $opcion=$_POST["opcion"]; // Recoge parametros |
---|
31 | |
---|
32 | if (isset($_POST["idhardware"])) $idhardware=$_POST["idhardware"]; |
---|
33 | if (isset($_POST["descripcion"])) $descripcion=$_POST["descripcion"]; |
---|
34 | if (isset($_POST["idtipohardware"])) $idtipohardware=$_POST["idtipohardware"]; |
---|
35 | if (isset($_POST["grupoid"])) $grupoid=$_POST["grupoid"]; |
---|
36 | if (isset($_POST["identificador"])) $idhardware=$_POST["identificador"]; |
---|
37 | |
---|
38 | $tablanodo=""; // Arbol para nodos insertados |
---|
39 | |
---|
40 | $cmd=CreaComando($cadenaconexion); // Crea objeto comando |
---|
41 | $resul=false; |
---|
42 | if ($cmd){ |
---|
43 | $resul=Gestiona(); |
---|
44 | $cmd->Conexion->Cerrar(); |
---|
45 | } |
---|
46 | if($opcion!=$op_movida){ |
---|
47 | echo '<HTML>'; |
---|
48 | echo '<HEAD>'; |
---|
49 | echo ' <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">'; |
---|
50 | echo '<BODY>'; |
---|
51 | echo '<P><SPAN style="visibility:hidden" id="arbol_nodo">'.$tablanodo.'</SPAN></P>'; |
---|
52 | echo ' <SCRIPT language="javascript" src="../jscripts/propiedades_componentehardwares.js"></SCRIPT>'; |
---|
53 | echo '<SCRIPT language="javascript">'.chr(13); |
---|
54 | if ($resul){ |
---|
55 | echo 'var oHTML'.chr(13); |
---|
56 | echo 'var cTBODY=document.getElementsByTagName("TBODY");'.chr(13); |
---|
57 | echo 'o=cTBODY.item(1);'.chr(13); |
---|
58 | } |
---|
59 | } |
---|
60 | $literal=""; |
---|
61 | switch($opcion){ |
---|
62 | case $op_alta : |
---|
63 | $literal="resultado_insertar_componentehardwares"; |
---|
64 | break; |
---|
65 | case $op_modificacion: |
---|
66 | $literal="resultado_modificar_componentehardwares"; |
---|
67 | break; |
---|
68 | case $op_eliminacion : |
---|
69 | $literal="resultado_eliminar_componentehardwares"; |
---|
70 | break; |
---|
71 | case $op_movida : |
---|
72 | $literal="resultado_mover"; |
---|
73 | break; |
---|
74 | default: |
---|
75 | break; |
---|
76 | } |
---|
77 | if ($resul){ |
---|
78 | if ($opcion==$op_alta ) |
---|
79 | echo $literal."(1,'".$cmd->DescripUltimoError()." ',".$idhardware.",o.innerHTML);".chr(13); |
---|
80 | else |
---|
81 | echo $literal."(1,'".$cmd->DescripUltimoError()." ','".$descripcion."');".chr(13); |
---|
82 | } |
---|
83 | else |
---|
84 | echo $literal."(0,'".$cmd->DescripUltimoError()."',".$idhardware.")"; |
---|
85 | |
---|
86 | if($opcion!=$op_movida){ |
---|
87 | echo ' </SCRIPT>'; |
---|
88 | echo '</BODY> '; |
---|
89 | echo '</HTML>'; |
---|
90 | } |
---|
91 | /************************************************************************************************************************************************** |
---|
92 | Inserta, modifica o elimina datos en la tabla hardwares |
---|
93 | ________________________________________________________________________________________________________*/ |
---|
94 | function Gestiona(){ |
---|
95 | global $cmd; |
---|
96 | global $opcion; |
---|
97 | |
---|
98 | global $idcentro; |
---|
99 | global $idhardware; |
---|
100 | global $descripcion; |
---|
101 | global $idtipohardware; |
---|
102 | global $grupoid; |
---|
103 | |
---|
104 | global $urlimgth; |
---|
105 | |
---|
106 | global $op_alta; |
---|
107 | global $op_modificacion; |
---|
108 | global $op_eliminacion; |
---|
109 | global $op_movida; |
---|
110 | |
---|
111 | global $tablanodo; |
---|
112 | |
---|
113 | $cmd->CreaParametro("@idcentro",$idcentro,1); |
---|
114 | $cmd->CreaParametro("@idhardware",$idhardware,1); |
---|
115 | $cmd->CreaParametro("@descripcion",$descripcion,0); |
---|
116 | $cmd->CreaParametro("@idtipohardware",$idtipohardware,1); |
---|
117 | $cmd->CreaParametro("@grupoid",$grupoid,1); |
---|
118 | |
---|
119 | switch($opcion){ |
---|
120 | case $op_alta : |
---|
121 | $cmd->texto="INSERT INTO hardwares (descripcion,idtipohardware,idcentro,grupoid) VALUES (@descripcion,@idtipohardware,@idcentro,@grupoid)"; |
---|
122 | $resul=$cmd->Ejecutar(); |
---|
123 | if ($resul){ // Crea una tabla nodo para devolver a la página que llamó ésta |
---|
124 | $idhardware=$cmd->Autonumerico(); |
---|
125 | $arbolXML=SubarbolXML_ComponenteHardwares($cmd,$idhardware,$descripcion,$idtipohardware); |
---|
126 | $baseurlimg="../images/signos"; // Url de las imagenes de signo |
---|
127 | $clasedefault="texto_arbol"; // Hoja de estilo (Clase por defecto) del árbol |
---|
128 | $arbol=new ArbolVistaXML($arbolXML,0,$baseurlimg,$clasedefault); |
---|
129 | $tablanodo=$arbol->CreaArbolVistaXML(); |
---|
130 | } |
---|
131 | break; |
---|
132 | case $op_modificacion: |
---|
133 | $cmd->texto="UPDATE hardwares SET descripcion=@descripcion,idtipohardware=@idtipohardware WHERE idhardware=@idhardware"; |
---|
134 | $resul=$cmd->Ejecutar(); |
---|
135 | if ($resul) // Toma la imagen del tipo de componente hardware |
---|
136 | $urlimgth=TomaDato($cmd,0,'tipohardwares',$idtipohardware,'idtipohardware','urlimg'); |
---|
137 | break; |
---|
138 | case $op_eliminacion : |
---|
139 | $resul=EliminaHardwares($cmd,$idhardware,"idhardware"); |
---|
140 | break; |
---|
141 | case $op_movida : |
---|
142 | $cmd->texto="UPDATE hardwares SET grupoid=@grupoid WHERE idhardware=@idhardware"; |
---|
143 | $resul=$cmd->Ejecutar(); |
---|
144 | break; |
---|
145 | default: |
---|
146 | break; |
---|
147 | } |
---|
148 | return($resul); |
---|
149 | } |
---|
150 | /*________________________________________________________________________________________________________ |
---|
151 | Crea un arbol XML para el nuevo nodo insertado |
---|
152 | ________________________________________________________________________________________________________*/ |
---|
153 | function SubarbolXML_ComponenteHardwares($cmd,$idhardware,$descripcion,$idtipohardware){ |
---|
154 | global $LITAMBITO_COMPONENTESHARD; |
---|
155 | $urlimg=TomaDato($cmd,0,'tipohardwares',$idtipohardware,'idtipohardware','urlimg'); |
---|
156 | $cadenaXML='<COMPONENTEHARDWARES'; |
---|
157 | // Atributos |
---|
158 | if (!empty($urlimg)) |
---|
159 | $cadenaXML.=' imagenodo="'.$urlimg.'"'; |
---|
160 | else |
---|
161 | $cadenaXML.=' imagenodo="../images/iconos/confihard.gif"'; |
---|
162 | $cadenaXML.=' infonodo="'.$descripcion.'"'; |
---|
163 | $cadenaXML.=' nodoid='.$LITAMBITO_COMPONENTESHARD.'-'.$idhardware; |
---|
164 | $cadenaXML.=' clickcontextualnodo="menu_contextual(this,' ."'flo_".$LITAMBITO_COMPONENTESHARD."'" .')"'; |
---|
165 | $cadenaXML.='>'; |
---|
166 | $cadenaXML.='</COMPONENTEHARDWARES>'; |
---|
167 | return($cadenaXML); |
---|
168 | } |
---|
169 | |
---|