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