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