1 | <? |
---|
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_grupos.php |
---|
8 | // Descripción : |
---|
9 | // Gestiona el mantenimiento de la tabla de grupos |
---|
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("./relaciones/aulas_eliminacion.php"); |
---|
18 | include_once("./relaciones/ordenadores_eliminacion.php"); |
---|
19 | include_once("./relaciones/gruposordenadores_eliminacion.php"); |
---|
20 | include_once("./relaciones/procedimientos_eliminacion.php"); |
---|
21 | include_once("./relaciones/tareas_eliminacion.php"); |
---|
22 | include_once("./relaciones/trabajos_eliminacion.php"); |
---|
23 | include_once("./relaciones/imagenes_eliminacion.php"); |
---|
24 | include_once("./relaciones/hardwares_eliminacion.php"); |
---|
25 | include_once("./relaciones/perfileshard_eliminacion.php"); |
---|
26 | include_once("./relaciones/softwares_eliminacion.php"); |
---|
27 | include_once("./relaciones/perfilessoft_eliminacion.php"); |
---|
28 | include_once("./relaciones/incrementales_eliminacion.php"); |
---|
29 | include_once("./relaciones/repositorios_eliminacion.php"); |
---|
30 | include_once("./relaciones/menus_eliminacion.php"); |
---|
31 | include_once("./relaciones/reservas_eliminacion.php"); |
---|
32 | include_once("./relaciones/entidades_eliminacion.php"); |
---|
33 | include_once("./relaciones/centros_eliminacion.php"); |
---|
34 | include_once("../includes/opciones.php"); |
---|
35 | //________________________________________________________________________________________________________ |
---|
36 | $opcion=0; // Inicializa parametros |
---|
37 | |
---|
38 | $nombregrupo=""; |
---|
39 | $grupoid=0; |
---|
40 | $idgrupo=0; |
---|
41 | $tipo=0; |
---|
42 | $literaltipo=""; |
---|
43 | $iduniversidad=0; |
---|
44 | $comentarios=""; |
---|
45 | |
---|
46 | if (isset($_POST["opcion"])) $opcion=$_POST["opcion"]; // Recoge parametros |
---|
47 | if (isset($_POST["nombregrupo"])) $nombregrupo=$_POST["nombregrupo"]; |
---|
48 | if (isset($_POST["grupoid"])) $grupoid=$_POST["grupoid"]; |
---|
49 | if (isset($_POST["idgrupo"])) $idgrupo=$_POST["idgrupo"]; |
---|
50 | if (isset($_POST["tipo"])) $tipo=$_POST["tipo"]; |
---|
51 | if (isset($_POST["literaltipo"])) $literaltipo=$_POST["literaltipo"]; |
---|
52 | if (isset($_POST["iduniversidad"])) $iduniversidad=$_POST["iduniversidad"]; |
---|
53 | if (isset($_POST["comentarios"])) $comentarios=$_POST["comentarios"]; |
---|
54 | |
---|
55 | $tablanodo=""; // Arbol para nodos insertados |
---|
56 | |
---|
57 | $cmd=CreaComando($cadenaconexion); // Crea objeto comando |
---|
58 | $resul=false; |
---|
59 | if ($cmd){ |
---|
60 | $resul=Gestiona(); |
---|
61 | $cmd->Conexion->Cerrar(); |
---|
62 | } |
---|
63 | // ************************************************************************************************************************************************* |
---|
64 | ?> |
---|
65 | <HTML> |
---|
66 | <HEAD> |
---|
67 | <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> |
---|
68 | <BODY> |
---|
69 | <SCRIPT language="javascript" src="../jscripts/propiedades_grupos.js"></SCRIPT> |
---|
70 | <? |
---|
71 | $literal=""; |
---|
72 | switch($opcion){ |
---|
73 | case $op_alta : |
---|
74 | $literal="resultado_insertar_grupos"; |
---|
75 | break; |
---|
76 | case $op_modificacion: |
---|
77 | $literal="resultado_modificar_grupos"; |
---|
78 | break; |
---|
79 | case $op_eliminacion : |
---|
80 | $literal="resultado_eliminar_grupos"; |
---|
81 | break; |
---|
82 | default: |
---|
83 | break; |
---|
84 | } |
---|
85 | echo '<p><span id="arbol_nodo">'.$tablanodo.'</span></p>'; |
---|
86 | if ($resul){ |
---|
87 | echo '<SCRIPT language="javascript">'.chr(13); |
---|
88 | echo 'var o=document.getElementById("arbol_nodo");'.chr(13); |
---|
89 | if ($opcion==$op_alta ) |
---|
90 | echo $literal."(1,'".$cmd->DescripUltimoError()." ',".$idgrupo.",o.innerHTML);"; |
---|
91 | else |
---|
92 | echo $literal."(1,'".$cmd->DescripUltimoError()." ','".$nombregrupo."');"; |
---|
93 | echo '</SCRIPT>'; |
---|
94 | } |
---|
95 | else{ |
---|
96 | echo '<SCRIPT language="javascript">'; |
---|
97 | echo $literal."(0,'".$cmd->DescripUltimoError()."',".$idgrupo.")"; |
---|
98 | echo '</SCRIPT>'; |
---|
99 | } |
---|
100 | ?> |
---|
101 | </BODY> |
---|
102 | </HTML> |
---|
103 | <? |
---|
104 | /************************************************************************************************************************************************** |
---|
105 | Inserta, modifica o elimina datos en la tabla grupos |
---|
106 | ________________________________________________________________________________________________________*/ |
---|
107 | function Gestiona(){ |
---|
108 | global $cmd; |
---|
109 | global $opcion; |
---|
110 | global $idcentro; |
---|
111 | global $nombregrupo; |
---|
112 | global $grupoid; |
---|
113 | global $idgrupo; |
---|
114 | global $tipo; |
---|
115 | global $literaltipo; |
---|
116 | global $iduniversidad; |
---|
117 | global $comentarios; |
---|
118 | global $op_alta; |
---|
119 | global $op_modificacion; |
---|
120 | global $op_eliminacion; |
---|
121 | global $tablanodo; |
---|
122 | |
---|
123 | if($iduniversidad) $idcentro=0; // Administración |
---|
124 | |
---|
125 | $cmd->CreaParametro("@nombregrupo",$nombregrupo,0); |
---|
126 | $cmd->CreaParametro("@grupoid",$grupoid,1); |
---|
127 | $cmd->CreaParametro("@idcentro",$idcentro,1); |
---|
128 | $cmd->CreaParametro("@idgrupo",$idgrupo,1); |
---|
129 | $cmd->CreaParametro("@tipo",$tipo,1); |
---|
130 | $cmd->CreaParametro("@iduniversidad",$iduniversidad,1); |
---|
131 | $cmd->CreaParametro("@comentarios",$comentarios,0); |
---|
132 | |
---|
133 | switch($opcion){ |
---|
134 | case $op_alta : |
---|
135 | $cmd->texto="INSERT INTO grupos(nombregrupo,idcentro,grupoid,tipo,iduniversidad,comentarios) VALUES (@nombregrupo,@idcentro,@grupoid,@tipo,@iduniversidad,@comentarios)"; |
---|
136 | $resul=$cmd->Ejecutar(); |
---|
137 | |
---|
138 | if ($resul){ // Crea una tabla nodo para devolver a la página que llamó ésta |
---|
139 | $idgrupo=$cmd->Autonumerico(); |
---|
140 | $arbolXML=SubarbolXML_grupos($idgrupo,$nombregrupo,$literaltipo); |
---|
141 | $baseurlimg="../images/signos"; |
---|
142 | $clasedefault="texto_arbol"; // Hoja de estilo (Clase por defecto) del árbol |
---|
143 | $arbol=new ArbolVistaXML($arbolXML,0,$baseurlimg,$clasedefault); |
---|
144 | $tablanodo=$arbol->CreaNodo(0); |
---|
145 | } |
---|
146 | break; |
---|
147 | case $op_modificacion: |
---|
148 | $cmd->texto="UPDATE grupos SET nombregrupo=@nombregrupo,comentarios=@comentarios WHERE idgrupo=@idgrupo"; |
---|
149 | $resul=$cmd->Ejecutar(); |
---|
150 | break; |
---|
151 | case $op_eliminacion : |
---|
152 | $resul=EliminaGrupos($cmd,$idgrupo,"idgrupo",$literaltipo);// Eliminación en cascada |
---|
153 | break; |
---|
154 | default: |
---|
155 | break; |
---|
156 | } |
---|
157 | return($resul); |
---|
158 | } |
---|
159 | /*________________________________________________________________________________________________________ |
---|
160 | Crea un arbol XML para el nuevo nodo insertado |
---|
161 | ________________________________________________________________________________________________________*/ |
---|
162 | function SubarbolXML_grupos($idgrupo,$nombregrupo,$literaltipo){ |
---|
163 | |
---|
164 | $cadenaXML='<GRUPOS'; |
---|
165 | // Atributos |
---|
166 | $cadenaXML.=' clickcontextualnodo="menu_contextual(this,' ."'flo_".$literaltipo."'" .')"'; |
---|
167 | $cadenaXML.=' imagenodo="../images/iconos/carpeta.gif"'; |
---|
168 | $cadenaXML.=' infonodo="'.$nombregrupo.'"'; |
---|
169 | $cadenaXML.=' nodoid='.$literaltipo.'-'.$idgrupo; |
---|
170 | $cadenaXML.='>'; |
---|
171 | $cadenaXML.='</GRUPOS>'; |
---|
172 | return($cadenaXML); |
---|
173 | } |
---|
174 | /*________________________________________________________________________________________________________ |
---|
175 | Elimina en cascada grupos |
---|
176 | Parametros: |
---|
177 | - cmd: Un comando ya operativo (con conexión abierta) |
---|
178 | - idgrupo: El identificador del grupo |
---|
179 | - literaltipo: El literal del grupo |
---|
180 | - literaltipo: El literal del grupo |
---|
181 | - swid: Indica 0= El identificador es tipo alfanumérico 1= EI identificador es tipo numérico ( valor por defecto) |
---|
182 | ________________________________________________________________________________________________________*/ |
---|
183 | function EliminaGrupos($cmd,$identificador,$nombreid,$literaltipo,$swid=1){ |
---|
184 | if (empty($identificador)) return(true); |
---|
185 | |
---|
186 | global $LITAMBITO_GRUPOSAULAS ; |
---|
187 | global $LITAMBITO_GRUPOSIMAGENES ; |
---|
188 | global $LITAMBITO_GRUPOSPROCEDIMIENTOS ; |
---|
189 | global $LITAMBITO_GRUPOSTAREAS ; |
---|
190 | global $LITAMBITO_GRUPOSTRABAJOS ; |
---|
191 | global $LITAMBITO_GRUPOSCOMPONENTESHARD ; |
---|
192 | global $LITAMBITO_GRUPOSCOMPONENTESSOFT ; |
---|
193 | global $LITAMBITO_GRUPOSPERFILESHARD ; |
---|
194 | global $LITAMBITO_GRUPOSPERFILESSOFT ; |
---|
195 | global $LITAMBITO_GRUPOSSOFTINCREMENTAL ; |
---|
196 | global $LITAMBITO_GRUPOSMENUS ; |
---|
197 | global $LITAMBITO_GRUPOSREPOSITORIOS ; |
---|
198 | global $LITAMBITO_GRUPOSRESERVAS ; |
---|
199 | global $LITAMBITO_GRUPOSENTIDADES ; |
---|
200 | |
---|
201 | if($swid==0) |
---|
202 | $cmd->texto="SELECT idgrupo FROM grupos WHERE ".$nombreid."='".$identificador."'"; |
---|
203 | else |
---|
204 | $cmd->texto='SELECT idgrupo FROM grupos WHERE '.$nombreid.'='.$identificador; |
---|
205 | $rs=new Recordset; |
---|
206 | $rs->Comando=&$cmd; |
---|
207 | if (!$rs->Abrir()) return(false); // Error al abrir recordset |
---|
208 | if ($rs->numeroderegistros==0) return(true); |
---|
209 | $rs->Primero(); |
---|
210 | while (!$rs->EOF){ |
---|
211 | $resul=EliminaGrupos($cmd,$rs->campos["idgrupo"],"grupoid",$literaltipo); |
---|
212 | if ($resul){ |
---|
213 | switch($literaltipo){ |
---|
214 | case $LITAMBITO_GRUPOSAULAS : |
---|
215 | $resul=EliminaAulas($cmd,$rs->campos["idgrupo"],"grupoid"); |
---|
216 | break; |
---|
217 | case $LITAMBITO_GRUPOSPROCEDIMIENTOS : |
---|
218 | $resul=EliminaProcedimientos($cmd,$rs->campos["idgrupo"],"grupoid"); |
---|
219 | break; |
---|
220 | case $LITAMBITO_GRUPOSTAREAS : |
---|
221 | $resul=EliminaTareas($cmd,$rs->campos["idgrupo"],"grupoid"); |
---|
222 | break; |
---|
223 | case $LITAMBITO_GRUPOSTRABAJOS : |
---|
224 | $resul=EliminaTrabajos($cmd,$rs->campos["idgrupo"],"grupoid"); |
---|
225 | break; |
---|
226 | case $LITAMBITO_GRUPOSIMAGENES : |
---|
227 | $resul=EliminaImagenes($cmd,$rs->campos["idgrupo"],"grupoid"); |
---|
228 | break; |
---|
229 | case $LITAMBITO_GRUPOSCOMPONENTESHARD : |
---|
230 | $resul=EliminaHardwares($cmd,$rs->campos["idgrupo"],"grupoid"); |
---|
231 | break; |
---|
232 | case $LITAMBITO_GRUPOSCOMPONENTESSOFT : |
---|
233 | $resul=EliminaSoftwares($cmd,$rs->campos["idgrupo"],"grupoid"); |
---|
234 | break; |
---|
235 | case $LITAMBITO_GRUPOSPERFILESHARD : |
---|
236 | $resul=EliminaPerfileshard($cmd,$rs->campos["idgrupo"],"grupoid"); |
---|
237 | break; |
---|
238 | case $LITAMBITO_GRUPOSPERFILESSOFT : |
---|
239 | $resul=EliminaPerfilessoft($cmd,$rs->campos["idgrupo"],"grupoid"); |
---|
240 | break; |
---|
241 | case $LITAMBITO_GRUPOSSOFTINCREMENTAL : |
---|
242 | $resul=EliminaSoftincremental($cmd,$rs->campos["idgrupo"],"grupoid"); |
---|
243 | break; |
---|
244 | case $LITAMBITO_GRUPOSREPOSITORIOS : |
---|
245 | $resul=Eliminarepositorios($cmd,$rs->campos["idgrupo"],"grupoid"); |
---|
246 | break; |
---|
247 | case $LITAMBITO_GRUPOSMENUS : |
---|
248 | $resul=EliminaMenus($cmd,$rs->campos["idgrupo"],"grupoid"); |
---|
249 | break; |
---|
250 | case $LITAMBITO_GRUPOSRESERVAS : |
---|
251 | $resul=EliminaReservas($cmd,$rs->campos["idgrupo"],"grupoid"); |
---|
252 | break; |
---|
253 | case $LITAMBITO_GRUPOSENTIDADES : |
---|
254 | $resul=EliminaEntidad($cmd,$rs->campos["idgrupo"],"grupoid"); |
---|
255 | break; |
---|
256 | default: |
---|
257 | $resul=false; |
---|
258 | } |
---|
259 | } |
---|
260 | if (!$resul){ |
---|
261 | $rs->Cerrar(); |
---|
262 | return(false); |
---|
263 | } |
---|
264 | $rs->Siguiente(); |
---|
265 | } |
---|
266 | if($swid==0) |
---|
267 | $cmd->texto="DELETE FROM grupos WHERE ".$nombreid."='".$identificador."'"; |
---|
268 | else |
---|
269 | $cmd->texto='DELETE FROM grupos WHERE '.$nombreid.'='.$identificador; |
---|
270 | $resul=$cmd->Ejecutar(); |
---|
271 | return($resul); |
---|
272 | } |
---|
273 | ?> |
---|