1 | // ************************************************************************************************************************************************* |
---|
2 | // Libreria de scripts de Javascript |
---|
3 | // Autor: José Manuel Alonso (E.T.S.I.I.) Universidad de Sevilla |
---|
4 | // Fecha Creación:2003-2004 |
---|
5 | // Fecha Última modificación: Marzo-2005 |
---|
6 | // Nombre del fichero: programaciones.js |
---|
7 | // Descripción : |
---|
8 | // Este fichero implementa las funciones javascript del fichero programaciones.php |
---|
9 | // ************************************************************************************************************************************************* |
---|
10 | var gris="#bbbcb9" |
---|
11 | var rojo="#cc3366" |
---|
12 | var negro="#000000" |
---|
13 | var azul= "#0000cc" |
---|
14 | var blanco="#eeeeee" |
---|
15 | var fondooriginal="#EEEECC"; |
---|
16 | var colororiginal="#003300"; |
---|
17 | var gmes=0; |
---|
18 | var ganno=0; |
---|
19 | var op_alta=1; |
---|
20 | var op_modificacion=2; |
---|
21 | var op_eliminacion=3; |
---|
22 | var op_suspension=4; |
---|
23 | var currenthoras=null; |
---|
24 | var currenthorasini=null; |
---|
25 | var currenthorasfin=null; |
---|
26 | var swpz=false |
---|
27 | //___________________________________________________________________________________________________________ |
---|
28 | function ItemSeleccionado(o){ |
---|
29 | if(o==null) return(false); |
---|
30 | if(o.getAttribute("selitem")==1) return(true); |
---|
31 | return(false); |
---|
32 | } |
---|
33 | //___________________________________________________________________________________________________________ |
---|
34 | function Marca(o){ |
---|
35 | o.style.color=blanco |
---|
36 | o.style.backgroundColor=rojo |
---|
37 | o.setAttribute("selitem",1); |
---|
38 | } |
---|
39 | //___________________________________________________________________________________________________________ |
---|
40 | function Resalta(o){ |
---|
41 | o.style.color=blanco |
---|
42 | o.style.backgroundColor=azul |
---|
43 | } |
---|
44 | //___________________________________________________________________________________________________________ |
---|
45 | function Desmarca(o){ |
---|
46 | o.style.color=colororiginal |
---|
47 | o.style.backgroundColor=fondooriginal |
---|
48 | o.setAttribute("selitem",0); |
---|
49 | } |
---|
50 | //___________________________________________________________________________________________________________ |
---|
51 | function TH_clic(o){ |
---|
52 | var tbobj=TBSource(o); // Busca la tabla donde se pulsó |
---|
53 | var oTD=tbobj.getElementsByTagName('TD') |
---|
54 | for(var i=0;i<oTD.length;i++){ |
---|
55 | if(oTD[i].getAttribute("id")!="") |
---|
56 | clic(oTD[i],true) |
---|
57 | } |
---|
58 | cuestionesclic(o) |
---|
59 | } |
---|
60 | //___________________________________________________________________________________________________________ |
---|
61 | function clic(o,sw){ |
---|
62 | if (!ItemSeleccionado(o)) |
---|
63 | Marca(o); |
---|
64 | else // Deselección |
---|
65 | Desmarca(o); |
---|
66 | if(document.fprogramaciones.tipoaccion.value==EJECUCION_RESERVA){ |
---|
67 | var idtb=Sourcetb(o); // Busca la tabla donde se pulsó |
---|
68 | if (idtb=="tabla_horas"){ |
---|
69 | if(currenthoras!=o &¤thoras!=null ) |
---|
70 | Desmarca(currenthoras); |
---|
71 | currenthoras=o; |
---|
72 | } |
---|
73 | if (idtb=="tabla_horasini" && currenthorasini !=null ){ |
---|
74 | if(currenthorasini!=o) |
---|
75 | Desmarca(currenthorasini); |
---|
76 | currenthorasini=o; |
---|
77 | } |
---|
78 | if (idtb=="tabla_horasfin" && currenthorasfin !=null ){ |
---|
79 | if(currenthorasfin!=o) |
---|
80 | Desmarca(currenthorasfin); |
---|
81 | currenthorasfin=o; |
---|
82 | } |
---|
83 | |
---|
84 | } |
---|
85 | |
---|
86 | if(!sw){ |
---|
87 | cuestionesclic(o) |
---|
88 | } |
---|
89 | } |
---|
90 | //___________________________________________________________________________________________________________ |
---|
91 | function cuestionesclic(o){ |
---|
92 | var idtb=Sourcetb(o); // Busca la tabla donde se pulsó |
---|
93 | if (idtb=="tabla_meses" || idtb=="tabla_annos") |
---|
94 | cuestion_opciones(); |
---|
95 | if (!swpz){ |
---|
96 | activa("bt_insertar"); |
---|
97 | activa("bt_cancelar"); |
---|
98 | swpz=!swpz; |
---|
99 | } |
---|
100 | } |
---|
101 | //___________________________________________________________________________________________________________- |
---|
102 | function Sourcetb(o){ |
---|
103 | while (o.tagName!="TABLE"){ |
---|
104 | o=o.parentNode; |
---|
105 | } |
---|
106 | return(o.getAttribute("id")); |
---|
107 | } |
---|
108 | //___________________________________________________________________________________________________________- |
---|
109 | function TBSource(o){ |
---|
110 | while (o.tagName!="TABLE"){ |
---|
111 | o=o.parentNode; |
---|
112 | } |
---|
113 | return(o); |
---|
114 | } |
---|
115 | //___________________________________________________________________________________________________________ |
---|
116 | function activa(idbt){ |
---|
117 | var bt=document.getElementById(idbt); |
---|
118 | bt.style.visibility="visible" |
---|
119 | bt.style.color=negro; |
---|
120 | } |
---|
121 | //___________________________________________________________________________________________________________ |
---|
122 | function desactiva(idbt){ |
---|
123 | var bt=document.getElementById(idbt); |
---|
124 | bt.style.visibility="hidden" |
---|
125 | bt.style.color=gris; |
---|
126 | } |
---|
127 | //___________________________________________________________________________________________________________ |
---|
128 | function habilitado(idbt){ |
---|
129 | var bt=document.getElementById(idbt); |
---|
130 | if (bt.style.visibility=="visible") return true; |
---|
131 | return false |
---|
132 | } |
---|
133 | //___________________________________________________________________________________________________________ |
---|
134 | function cuestion_opciones(){ |
---|
135 | swotbm=opcion_simple("tabla_meses"); |
---|
136 | swotba=opcion_simple("tabla_annos"); |
---|
137 | if (swotbm && swotba){ |
---|
138 | var vd=valor_HEX("tabla_mesanno"); |
---|
139 | if (!detecta_cambio(vd)) |
---|
140 | visible_simple(); |
---|
141 | } |
---|
142 | else{ // Conmutación a opción multiple |
---|
143 | visible_multiple(); |
---|
144 | } |
---|
145 | } |
---|
146 | //___________________________________________________________________________________________________________ |
---|
147 | function detecta_cambio(vitem){ // vitem es el valor hexdecimal a mostrar |
---|
148 | |
---|
149 | wmes=parseInt(valor_item("tabla_meses")); // Recupera mes |
---|
150 | wanno=parseInt(valor_item("tabla_annos")); // Recupera año |
---|
151 | if (wmes>0 && wanno>0){ // Si se ha elegido un año y un mes ... |
---|
152 | if (gmes!=wmes || ganno!=wanno){ // Cara de nuevo el mes en blanco |
---|
153 | gmes=wmes; |
---|
154 | ganno=wanno; |
---|
155 | ifr=document.getElementById("iframes_comodin"); // Toma objeto Iframe |
---|
156 | wurl="toma_mes.php?idmes="+wmes+"&idanno="+wanno+"&vitem="+vitem |
---|
157 | ifr.src=wurl; // LLama a la página |
---|
158 | return(true); |
---|
159 | } |
---|
160 | return(false); |
---|
161 | } |
---|
162 | } |
---|
163 | //___________________________________________________________________________________________________________ |
---|
164 | function cambia_mesanno(cadecalendario,vitem){ |
---|
165 | tbm=document.getElementById("tbmesanno"); |
---|
166 | tbm.innerHTML=cadecalendario; |
---|
167 | marca_item("tabla_mesanno",vitem); |
---|
168 | visible_simple(); |
---|
169 | } |
---|
170 | //___________________________________________________________________________________________________________ |
---|
171 | function visible_multiple(){ |
---|
172 | fm=document.getElementById("fechasmultiples"); |
---|
173 | fs=document.getElementById("fechassimples"); |
---|
174 | fm.style.visibility = "visible" |
---|
175 | fs.style.visibility = "hidden"; |
---|
176 | } |
---|
177 | //___________________________________________________________________________________________________________ |
---|
178 | function visible_simple(){ |
---|
179 | fm=document.getElementById("fechasmultiples"); |
---|
180 | fs=document.getElementById("fechassimples"); |
---|
181 | fm.style.visibility = "hidden" |
---|
182 | fs.style.visibility = "visible"; |
---|
183 | } |
---|
184 | //___________________________________________________________________________________________________________ |
---|
185 | function modifica_programacion(ida,tia){ |
---|
186 | if (habilitado("bt_modificar")){ |
---|
187 | idprogramacion=valor_programacion(); |
---|
188 | if (idprogramacion>0) |
---|
189 | gestor_programacion(ida,tia,idprogramacion,op_modificacion); |
---|
190 | } |
---|
191 | } |
---|
192 | //___________________________________________________________________________________________________________ |
---|
193 | function elimina_programacion(){ |
---|
194 | if (habilitado("bt_eliminar")){ |
---|
195 | idprogramacion=valor_programacion(); |
---|
196 | if (idprogramacion>0){ |
---|
197 | wurl="../gestores/gestor_programaciones.php?wswop="+op_eliminacion+"&widprogramacion="+idprogramacion |
---|
198 | ifr=document.getElementById("iframes_comodin") // Toma IFRAME |
---|
199 | ifr.src=wurl; |
---|
200 | } |
---|
201 | } |
---|
202 | } |
---|
203 | //___________________________________________________________________________________________________________ |
---|
204 | function alta_programacion(ida,tia){ |
---|
205 | |
---|
206 | if (habilitado("bt_insertar")){ |
---|
207 | gestor_programacion(ida,tia,0,op_alta) |
---|
208 | } |
---|
209 | } |
---|
210 | //___________________________________________________________________________________________________________ |
---|
211 | function duplicar_programacion(){ |
---|
212 | activa("bt_insertar") |
---|
213 | desactiva("bt_eliminar"); |
---|
214 | desactiva("bt_modificar"); |
---|
215 | desactiva("bt_duplicar"); |
---|
216 | activa("bt_cancelar"); |
---|
217 | nuevo_bloque(); |
---|
218 | } |
---|
219 | |
---|
220 | //___________________________________________________________________________________________________________ |
---|
221 | function gestor_programacion(ida,tia,idr,swop){ |
---|
222 | widentificador=ida; |
---|
223 | wtipoaccion=tia; |
---|
224 | widprogramacion=idr; |
---|
225 | wswop=swop; |
---|
226 | wannos=valor_HEX("tabla_annos"); |
---|
227 | if (wannos==0){ |
---|
228 | alert(TbMsg[0]); |
---|
229 | return |
---|
230 | } |
---|
231 | wmeses=valor_HEX("tabla_meses"); |
---|
232 | if (wmeses==0){ |
---|
233 | alert(TbMsg[1]); |
---|
234 | return |
---|
235 | } |
---|
236 | fm=document.getElementById("fechasmultiples"); |
---|
237 | if (fm.style.visibility == "visible"){ // Activada opciones múltiples |
---|
238 | |
---|
239 | wdiario=valor_HEX("tabla_diasmes"); |
---|
240 | wdias=valor_HEX("tabla_dias"); |
---|
241 | wsemanas=valor_HEX("tabla_semanas"); |
---|
242 | |
---|
243 | if (wdiario==0 && wdias==0 && wsemanas==0 ){ |
---|
244 | alert(TbMsg[2]); |
---|
245 | return |
---|
246 | } |
---|
247 | } |
---|
248 | else{ |
---|
249 | wdiario=valor_HEX("tabla_mesanno"); |
---|
250 | if (wdiario==0){ |
---|
251 | alert(TbMsg[3]); |
---|
252 | return |
---|
253 | } |
---|
254 | wdias=0 |
---|
255 | wsemanas=0 |
---|
256 | } |
---|
257 | |
---|
258 | whoras=valor_HEX("tabla_horas"); |
---|
259 | |
---|
260 | if (whoras==0){ |
---|
261 | if(wtipoaccion!=EJECUCION_RESERVA){ |
---|
262 | alert(TbMsg[4]); |
---|
263 | return |
---|
264 | } |
---|
265 | } |
---|
266 | |
---|
267 | if(wtipoaccion==EJECUCION_RESERVA){ |
---|
268 | whorasini=valor_HEX("tabla_horasini"); |
---|
269 | if (whorasini==0){ |
---|
270 | alert(TbMsg[4]); |
---|
271 | return |
---|
272 | } |
---|
273 | whorasfin=valor_HEX("tabla_horasfin"); |
---|
274 | if (whorasfin==0){ |
---|
275 | alert(TbMsg[4]); |
---|
276 | return |
---|
277 | } |
---|
278 | } |
---|
279 | |
---|
280 | inputprogramacion=document.getElementById("nombrebloque") |
---|
281 | wnombrebloque=inputprogramacion.value |
---|
282 | if (wnombrebloque==""){ |
---|
283 | alert(TbMsg[5]); |
---|
284 | return |
---|
285 | } |
---|
286 | wampm=document.getElementById("ampm").value; |
---|
287 | wminutos=document.getElementById("minutos").value; |
---|
288 | if (wminutos<0 || wminutos>59){ |
---|
289 | alert(TbMsg[6]); |
---|
290 | document.getElementById("minutos").focus() |
---|
291 | return |
---|
292 | } |
---|
293 | if(wtipoaccion==EJECUCION_RESERVA){ |
---|
294 | wampmini=document.getElementById("ampmini").value; |
---|
295 | wminutosini=document.getElementById("minutosini").value; |
---|
296 | if (wminutosini<0 || wminutosini>59){ |
---|
297 | alert(TbMsg[6]); |
---|
298 | document.getElementById("minutosini").focus() |
---|
299 | return; |
---|
300 | } |
---|
301 | wampmfin=document.getElementById("ampmfin").value; |
---|
302 | wminutosfin=document.getElementById("minutosfin").value; |
---|
303 | if (wminutosfin<0 || wminutosfin>59){ |
---|
304 | alert(TbMsg[6]); |
---|
305 | document.getElementById("minutosfin").focus() |
---|
306 | return; |
---|
307 | } |
---|
308 | } |
---|
309 | else{ |
---|
310 | whorasini=0; |
---|
311 | wampmini=0; |
---|
312 | wminutosini=0; |
---|
313 | whorasfin=0; |
---|
314 | wampmfin=0; |
---|
315 | wminutosfin=0; |
---|
316 | } |
---|
317 | |
---|
318 | wsegundos=0; |
---|
319 | |
---|
320 | wurl="../gestores/gestor_programaciones.php?wswop="+wswop+"&widprogramacion="+widprogramacion+"&widentificador="+widentificador+"&wtipoaccion="+wtipoaccion+"&wnombrebloque="+wnombrebloque+"&wannos="+wannos+"&wmeses="+wmeses+"&wdiario="+wdiario+"&wdias="+wdias+"&wsemanas="+wsemanas+"&whoras="+whoras+"&whorasini="+whorasini+"&whorasfin="+whorasfin |
---|
321 | wurl+="&wampm="+wampm+"&wminutos="+wminutos+"&wsegundos="+wsegundos |
---|
322 | wurl+="&wampmini="+wampmini+"&wminutosini="+wminutosini+"&wampmfin="+wampmfin+"&wminutosfin="+wminutosfin |
---|
323 | wsw_sus=document.getElementById("sw_sus").checked; |
---|
324 | wurl+="&wsw_sus="+wsw_sus |
---|
325 | ifr=document.getElementById("iframes_comodin") // Toma IFRAME |
---|
326 | ifr.src=wurl; |
---|
327 | return |
---|
328 | } |
---|
329 | //___________________________________________________________________________________________________________ |
---|
330 | function suspender_programacion(ida,tia){ |
---|
331 | var listalen=lista.options.length |
---|
332 | if(listalen==0){ |
---|
333 | alert(TbMsg[8]); |
---|
334 | wsw_sus=document.getElementById("sw_sus").checked=false; |
---|
335 | return |
---|
336 | } |
---|
337 | widentificador=ida; |
---|
338 | wtipoaccion=tia; |
---|
339 | wurl="../gestores/gestor_programaciones.php?wswop="+op_suspension+"&widentificador="+widentificador+"&wtipoaccion="+wtipoaccion |
---|
340 | wsw_sus=document.getElementById("sw_sus").checked; |
---|
341 | wurl+="&wsw_sus="+wsw_sus |
---|
342 | ifr=document.getElementById("iframes_comodin") // Toma IFRAME |
---|
343 | ifr.src=wurl; |
---|
344 | } |
---|
345 | //___________________________________________________________________________________________________________ |
---|
346 | function resultado_suspender_programacion(){ |
---|
347 | wsw_sus=document.getElementById("sw_sus").checked; |
---|
348 | if(wsw_sus) |
---|
349 | alert(TbMsg[9]); |
---|
350 | else |
---|
351 | alert(TbMsg[10]); |
---|
352 | } |
---|
353 | //___________________________________________________________________________________________________________ |
---|
354 | // Devualve el valor Hexadecimal que corresponde a los items |
---|
355 | //___________________________________________________________________________________________________________ |
---|
356 | function valor_HEX(idtb){ |
---|
357 | otb=document.getElementById(idtb); |
---|
358 | var aux=0x00000000; |
---|
359 | filas=otb.rows.length |
---|
360 | for (i=0;i<filas;i++){ |
---|
361 | columnas=otb.rows[i].cells.length |
---|
362 | for (j=0;j<columnas;j++){ |
---|
363 | if(otb.rows[i].cells[j].tagName=="TD" && otb.rows[i].cells[j].childNodes.length>0){ |
---|
364 | if(otb.rows[i].cells[j].childNodes[0].tagName=="A"){ |
---|
365 | var oSPAN=otb.rows[i].cells[j].childNodes[0].childNodes[0]; |
---|
366 | if (ItemSeleccionado(oSPAN)){ |
---|
367 | aux=aux | oSPAN.getAttribute("value") |
---|
368 | |
---|
369 | } |
---|
370 | } |
---|
371 | } |
---|
372 | } |
---|
373 | } |
---|
374 | return(aux) |
---|
375 | } |
---|
376 | //___________________________________________________________________________________________________________ |
---|
377 | // Devuelve el valor decimal de un item de la tabla (ID) |
---|
378 | // 0=no elección -1=más de un item n:valor del item |
---|
379 | //___________________________________________________________________________________________________________ |
---|
380 | function valor_item(idtb){ |
---|
381 | var valor=0,sw=0; |
---|
382 | otb=document.getElementById(idtb); |
---|
383 | filas=otb.rows.length |
---|
384 | for (i=0;i<filas;i++){ |
---|
385 | columnas=otb.rows[i].cells.length |
---|
386 | for (j=0;j<columnas;j++){ |
---|
387 | if(otb.rows[i].cells[j].tagName=="TD" && otb.rows[i].cells[j].childNodes.length>0){ |
---|
388 | if(otb.rows[i].cells[j].childNodes[0].tagName=="A"){ |
---|
389 | var oSPAN=otb.rows[i].cells[j].childNodes[0].childNodes[0]; |
---|
390 | if (ItemSeleccionado(oSPAN)){ |
---|
391 | if (sw==0){ |
---|
392 | valor=oSPAN.getAttribute("id"); |
---|
393 | sw++; |
---|
394 | } |
---|
395 | else |
---|
396 | return(-1); |
---|
397 | } |
---|
398 | } |
---|
399 | } |
---|
400 | } |
---|
401 | } |
---|
402 | return(valor) |
---|
403 | } |
---|
404 | //___________________________________________________________________________________________________________ |
---|
405 | // Devuelve true si existe uno ningún item seleccionado en la tabla |
---|
406 | // y false en caso contrario |
---|
407 | // El parametro de entrada es el identificador dela tabla |
---|
408 | //___________________________________________________________________________________________________________ |
---|
409 | function opcion_simple(idtb){ |
---|
410 | var conta=0; |
---|
411 | otb=document.getElementById(idtb); |
---|
412 | filas=otb.rows.length |
---|
413 | for (i=0;i<filas;i++){ |
---|
414 | columnas=otb.rows[i].cells.length |
---|
415 | for (j=0;j<columnas;j++){ |
---|
416 | if(otb.rows[i].cells[j].tagName=="TD" && otb.rows[i].cells[j].childNodes.length>0){ |
---|
417 | if(otb.rows[i].cells[j].childNodes[0].tagName=="A"){ |
---|
418 | var oSPAN=otb.rows[i].cells[j].childNodes[0].childNodes[0]; |
---|
419 | if (ItemSeleccionado(oSPAN)){ |
---|
420 | conta++; |
---|
421 | if (conta>1) return(false); |
---|
422 | } |
---|
423 | } |
---|
424 | } |
---|
425 | } |
---|
426 | } |
---|
427 | return(true); |
---|
428 | } |
---|
429 | //___________________________________________________________________________________________________________ |
---|
430 | function sobre(o){ |
---|
431 | if (!ItemSeleccionado(o)) |
---|
432 | Resalta(o); |
---|
433 | } |
---|
434 | //___________________________________________________________________________________________________________ |
---|
435 | function fuera(o){ |
---|
436 | if (!ItemSeleccionado(o)) |
---|
437 | Desmarca(o); |
---|
438 | } |
---|
439 | |
---|
440 | //___________________________________________________________________________________________________________ |
---|
441 | // Recibe una notificación(del IFRAME) de error al grabar programacion |
---|
442 | //___________________________________________________________________________________________________________ |
---|
443 | function error_programacion(swe,resultado){ |
---|
444 | desmarca_tablas(); |
---|
445 | inicializa_variables(); |
---|
446 | nuevo_bloque(); |
---|
447 | } |
---|
448 | //___________________________________________________________________________________________________________ |
---|
449 | // Recibe una notificación(del IFRAME) de la acción ejecutada |
---|
450 | //___________________________________________________________________________________________________________ |
---|
451 | function registro_programacion(idr,nombrere,swop){ |
---|
452 | wswop=parseInt(swop); // Toma la opción ALTA,MODIFICACION O ELIMINACION |
---|
453 | switch (wswop){ |
---|
454 | case op_alta: |
---|
455 | alert(TbMsg[11]); |
---|
456 | programacion_metelista(idr,nombrere); |
---|
457 | break; |
---|
458 | case op_modificacion: |
---|
459 | alert(TbMsg[12]); |
---|
460 | modifica_texto(nombrere); |
---|
461 | break; |
---|
462 | case op_eliminacion: |
---|
463 | alert(TbMsg[13]); |
---|
464 | elimina_item(); |
---|
465 | break; |
---|
466 | } |
---|
467 | desmarca_tablas(); |
---|
468 | inicializa_variables(); |
---|
469 | nuevo_bloque(); |
---|
470 | |
---|
471 | visible_simple(); |
---|
472 | activa("bt_insertar") |
---|
473 | desactiva("bt_eliminar"); |
---|
474 | desactiva("bt_modificar"); |
---|
475 | desactiva("bt_duplicar"); |
---|
476 | desactiva("bt_cancelar"); |
---|
477 | swpz=false; |
---|
478 | } |
---|
479 | //___________________________________________________________________________________________________________ |
---|
480 | // Devuelve el valor del item seleccionado |
---|
481 | //___________________________________________________________________________________________________________ |
---|
482 | function valor_programacion(){ |
---|
483 | var lista=document.getElementById("lista_programaciones"); |
---|
484 | p=lista.selectedIndex; |
---|
485 | if (p==-1){ |
---|
486 | alert(TbMsg[14]); |
---|
487 | return(-1); |
---|
488 | } |
---|
489 | else |
---|
490 | return(lista.options[p].value) |
---|
491 | } |
---|
492 | //___________________________________________________________________________________________________________ |
---|
493 | // Modifica el texto del item seleccionado |
---|
494 | //___________________________________________________________________________________________________________ |
---|
495 | function modifica_texto(nombrere){ |
---|
496 | var lista=document.getElementById("lista_programaciones"); |
---|
497 | p=lista.selectedIndex; |
---|
498 | lista.options[p].text=nombrere |
---|
499 | } |
---|
500 | //___________________________________________________________________________________________________________ |
---|
501 | // Elimina el item seleccionado |
---|
502 | //___________________________________________________________________________________________________________ |
---|
503 | function elimina_item(){ |
---|
504 | var lista=document.getElementById("lista_programaciones"); |
---|
505 | p=lista.selectedIndex; |
---|
506 | lista.remove(p); |
---|
507 | } |
---|
508 | //___________________________________________________________________________________________________________ |
---|
509 | // Recibe una notificación(del IFRAME) de grabación correcta programacion |
---|
510 | //___________________________________________________________________________________________________________ |
---|
511 | function inicializa_variables(){ |
---|
512 | gmes=0; |
---|
513 | ganno=0; |
---|
514 | } |
---|
515 | //___________________________________________________________________________________________________________ |
---|
516 | // Desmarca todos los items de todas las tablas |
---|
517 | //___________________________________________________________________________________________________________ |
---|
518 | function desmarca_tablas(){ |
---|
519 | desmarca_tabla("tabla_annos"); |
---|
520 | desmarca_tabla("tabla_meses"); |
---|
521 | desmarca_tabla("tabla_mesanno"); |
---|
522 | desmarca_tabla("tabla_dias"); |
---|
523 | desmarca_tabla("tabla_semanas"); |
---|
524 | desmarca_tabla("tabla_diasmes"); |
---|
525 | desmarca_tabla("tabla_horas"); |
---|
526 | |
---|
527 | document.getElementById("ampm").selectedIndex=1; |
---|
528 | document.getElementById("minutos").value=""; |
---|
529 | //document.getElementById("segundos").value=""; |
---|
530 | |
---|
531 | whorasini= document.getElementById("tabla_horasini") |
---|
532 | if(whorasini!=null){ |
---|
533 | desmarca_tabla("tabla_horasini"); |
---|
534 | wampmini= document.getElementById("ampmini") |
---|
535 | wminutosini= document.getElementById("minutosini") |
---|
536 | wampmini.selectedIndex=1; |
---|
537 | wminutosini.value=""; |
---|
538 | } |
---|
539 | whorasfin= document.getElementById("tabla_horasfin") |
---|
540 | if(whorasfin!=null){ |
---|
541 | desmarca_tabla("tabla_horasfin"); |
---|
542 | wampmfin= document.getElementById("ampmfin") |
---|
543 | wminutosfin= document.getElementById("minutosfin") |
---|
544 | wampmfin.selectedIndex=1; |
---|
545 | wminutosfin.value=""; |
---|
546 | } |
---|
547 | } |
---|
548 | //___________________________________________________________________________________________________________ |
---|
549 | // Averigua el nombre del bloque según lo que ya existe |
---|
550 | //___________________________________________________________________________________________________________ |
---|
551 | function nuevo_bloque(){ |
---|
552 | var lista=document.getElementById("lista_programaciones"); |
---|
553 | var listalen=lista.options.length |
---|
554 | var nb=1 |
---|
555 | var cbloque="bloque"; |
---|
556 | var nbloque=cbloque+nb |
---|
557 | var swb=false; |
---|
558 | while(true){ |
---|
559 | swb=false; |
---|
560 | for(var i=0;i<listalen;i++){ |
---|
561 | if(lista.options[i].text==nbloque){ |
---|
562 | swb=true |
---|
563 | break; |
---|
564 | } |
---|
565 | } |
---|
566 | if(swb){ |
---|
567 | nb++; |
---|
568 | nbloque=cbloque+nb |
---|
569 | } |
---|
570 | else |
---|
571 | break; |
---|
572 | } |
---|
573 | document.getElementById("nombrebloque").value=nbloque; |
---|
574 | var lista=document.getElementById("lista_programaciones"); |
---|
575 | lista.selectedIndex=-1; |
---|
576 | } |
---|
577 | //___________________________________________________________________________________________________________ |
---|
578 | // Desmarca todos los items de una tabla |
---|
579 | //___________________________________________________________________________________________________________ |
---|
580 | function desmarca_tabla(idtb){ |
---|
581 | otb=document.getElementById(idtb); |
---|
582 | if (!otb) return |
---|
583 | desmarcando_tabla(otb); |
---|
584 | } |
---|
585 | //___________________________________________________________________________________________________________ |
---|
586 | // Desmarca todos los items de una tabla ( parametro objeto tabla) |
---|
587 | //___________________________________________________________________________________________________________ |
---|
588 | function desmarcando_tabla(otb){ |
---|
589 | filas=otb.rows.length |
---|
590 | for (var i=0;i<filas;i++){ |
---|
591 | columnas=otb.rows[i].cells.length |
---|
592 | for (var j=0;j<columnas;j++){ |
---|
593 | if(otb.rows[i].cells[j].tagName=="TD" && otb.rows[i].cells[j].childNodes.length>0){ |
---|
594 | if(otb.rows[i].cells[j].childNodes[0].tagName=="A"){ |
---|
595 | var oSPAN=otb.rows[i].cells[j].childNodes[0].childNodes[0]; |
---|
596 | if (ItemSeleccionado(oSPAN)) |
---|
597 | Desmarca(oSPAN) |
---|
598 | } |
---|
599 | } |
---|
600 | } |
---|
601 | } |
---|
602 | } |
---|
603 | //___________________________________________________________________________________________________________ |
---|
604 | // Añade la programacion a la caja de lista |
---|
605 | //___________________________________________________________________________________________________________ |
---|
606 | function programacion_metelista(valor,texto){ |
---|
607 | var lista=document.getElementById("lista_programaciones"); |
---|
608 | var e=document.createElement("OPTION"); |
---|
609 | |
---|
610 | e.value=valor; |
---|
611 | e.text=texto; |
---|
612 | |
---|
613 | lista.appendChild(e); |
---|
614 | } |
---|
615 | //___________________________________________________________________________________________________________ |
---|
616 | // Llama a una página dentro del IFRAME que recupera una programacion |
---|
617 | //___________________________________________________________________________________________________________ |
---|
618 | function consulta_programacion(){ |
---|
619 | idprogramacion=valor_programacion(); |
---|
620 | if (idprogramacion>0){ |
---|
621 | desmarca_tablas(); |
---|
622 | wurl="consulta_programaciones.php?idprogramacion="+idprogramacion; |
---|
623 | ifr=document.getElementById("iframes_comodin") // Toma IFRAME |
---|
624 | ifr.src=wurl; |
---|
625 | desactiva("bt_insertar") |
---|
626 | activa("bt_eliminar"); |
---|
627 | activa("bt_modificar"); |
---|
628 | activa("bt_duplicar"); |
---|
629 | activa("bt_cancelar"); |
---|
630 | } |
---|
631 | } |
---|
632 | //___________________________________________________________________________________________________________ |
---|
633 | // Recibe una consulta de programacion (del IFRAME) y la visualiza |
---|
634 | //___________________________________________________________________________________________________________ |
---|
635 | function muestra_programacion(cadena_campos){ |
---|
636 | campos=cadena_campos.split(";"); |
---|
637 | var pnombrebloque=campos[3]; |
---|
638 | var pannos=campos[4]; |
---|
639 | var pmeses=campos[5]; |
---|
640 | var pdiario=campos[6]; |
---|
641 | var pdias=campos[7]; |
---|
642 | var psemanas=campos[8]; |
---|
643 | var phoras=campos[9]; |
---|
644 | var pampm=campos[10]; |
---|
645 | var pminutos=campos[11]; |
---|
646 | var psegundos=campos[12]; |
---|
647 | var phorasini=campos[13]; |
---|
648 | var pampmini=campos[14]; |
---|
649 | var pminutosini=campos[15]; |
---|
650 | var phorasfin=campos[16]; |
---|
651 | var pampmfin=campos[17]; |
---|
652 | var pminutosfin=campos[18]; |
---|
653 | |
---|
654 | document.getElementById("nombrebloque").value=pnombrebloque; |
---|
655 | marca_item("tabla_annos",pannos); |
---|
656 | marca_item("tabla_meses",pmeses); |
---|
657 | if (opcion_multiple(pannos) || opcion_multiple(pmeses)){ |
---|
658 | marca_item("tabla_diasmes",pdiario); |
---|
659 | marca_item("tabla_dias",pdias); |
---|
660 | marca_item("tabla_semanas",psemanas); |
---|
661 | visible_multiple(); |
---|
662 | } |
---|
663 | else{ |
---|
664 | gmes=pmeses; |
---|
665 | ganno=pannos; |
---|
666 | ifr=document.getElementById("iframes_comodin"); // Toma objeto Iframe |
---|
667 | wmes=parseInt(valor_item("tabla_meses")); // Recupera mes |
---|
668 | wanno=parseInt(valor_item("tabla_annos")); // Recupera año |
---|
669 | wurl="toma_mes.php?idmes="+wmes+"&idanno="+wanno+"&vitem="+pdiario |
---|
670 | ifr.src=wurl; // LLama a la página |
---|
671 | |
---|
672 | } |
---|
673 | marca_item("tabla_horas",phoras); |
---|
674 | document.getElementById("ampm").value=pampm; |
---|
675 | document.getElementById("minutos").value=pminutos; |
---|
676 | //document.getElementById("segundos").value=psegundos; |
---|
677 | |
---|
678 | wtabla_horasini= document.getElementById("tabla_horasini") |
---|
679 | if(wtabla_horasini!=null) |
---|
680 | marca_item("tabla_horasini",phorasini); |
---|
681 | wampmini= document.getElementById("ampmini") |
---|
682 | wminutosini= document.getElementById("minutosini") |
---|
683 | if(wampmini!=null){ |
---|
684 | wampmini.value=pampmini; |
---|
685 | wminutosini.value=pminutosini; |
---|
686 | } |
---|
687 | wtabla_horasfin= document.getElementById("tabla_horasfin") |
---|
688 | if(wtabla_horasfin!=null) |
---|
689 | marca_item("tabla_horasfin",phorasfin); |
---|
690 | wampmfin= document.getElementById("ampmfin") |
---|
691 | wminutosfin= document.getElementById("minutosfin") |
---|
692 | if(wampmfin!=null){ |
---|
693 | wampmfin.value=pampmfin; |
---|
694 | wminutosfin.value=pminutosfin; |
---|
695 | } |
---|
696 | } |
---|
697 | // ------------------------------------------------------------------ |
---|
698 | // Devuelve true si hay más de un item seleccionado, false al contrario |
---|
699 | // El parametro de entrada es el valor HEXadecimal |
---|
700 | //___________________________________________________________________________________________________________ |
---|
701 | function opcion_multiple(valor){ |
---|
702 | var conta=0; |
---|
703 | var auxhex=0x00000001; |
---|
704 | for (auxhex=0x00000001;auxhex!=0x00000000;auxhex=auxhex<<1){ |
---|
705 | if (valor & auxhex){ |
---|
706 | conta++; |
---|
707 | if (conta>1) return(true); |
---|
708 | } |
---|
709 | } |
---|
710 | return(false); |
---|
711 | } |
---|
712 | // ------------------------------------------------------------------ |
---|
713 | // Marca todos los items de una tabla según el valor HEX enviado |
---|
714 | //___________________________________________________________________________________________________________ |
---|
715 | function marca_item(idtabla,vhex){ |
---|
716 | otb=document.getElementById(idtabla); |
---|
717 | filas=otb.rows.length |
---|
718 | for (i=0;i<filas;i++){ |
---|
719 | columnas=otb.rows[i].cells.length |
---|
720 | for (j=0;j<columnas;j++){ |
---|
721 | if(otb.rows[i].cells[j].tagName=="TD" && otb.rows[i].cells[j].childNodes.length>0){ |
---|
722 | if(otb.rows[i].cells[j].childNodes[0].tagName=="A"){ |
---|
723 | var oSPAN=otb.rows[i].cells[j].childNodes[0].childNodes[0]; |
---|
724 | if (oSPAN.getAttribute("value") & vhex){ |
---|
725 | Marca(oSPAN); |
---|
726 | if (idtabla=="tabla_horas") |
---|
727 | currenthoras=oSPAN |
---|
728 | if (idtabla=="tabla_horasini") |
---|
729 | currenthorasini=oSPAN |
---|
730 | if (idtabla=="tabla_horasfin") |
---|
731 | currenthorasfin=oSPAN |
---|
732 | } |
---|
733 | } |
---|
734 | } |
---|
735 | } |
---|
736 | } |
---|
737 | } |
---|
738 | // ------------------------------------------------------------------ |
---|
739 | // Cancela todos los items de las tabalas e inicia variables |
---|
740 | //___________________________________________________________________________________________________________ |
---|
741 | function cancela_programacion(){ |
---|
742 | desmarca_tablas(); |
---|
743 | inicializa_variables(); |
---|
744 | nuevo_bloque(); |
---|
745 | visible_simple(); |
---|
746 | activa("bt_insertar") |
---|
747 | desactiva("bt_eliminar"); |
---|
748 | desactiva("bt_modificar"); |
---|
749 | desactiva("bt_duplicar"); |
---|
750 | desactiva("bt_cancelar"); |
---|
751 | swpz=false; |
---|
752 | |
---|
753 | } |
---|