/********************************************************* Set of JavaScript functions used throughout the database JavaScript Validation 2.0, 19/Mar/2001 Jake Howlett, http://www.codestore.org/ **********************************************************/ /*********************************************************** errorHandler() Used by Netscape to return the error message to the user. Best used only when debuggind in development. Turn on by adding the following line to a form: if (navigator.appName=="Netscape") window.onerror = errorHandler; ***********************************************************/ function errorHandler( e, f, l ) { alert("Error\nFile: " + f + "\nLine: " + l + "\nError:" + e); return true; } /*********************************************************** doDelete is used to delete the from the server The user is first asked to confirm that this is what they want to do. Giving them the chance to cancel the action. This works SIMPLY by changing the end of the URL from "?OpenDocument" to "?DeleteDocument" ************************************************************/ function doDelete() { if ( confirm('Are you sure you want to delete this document?') ){ location.search = "?DeleteDocument"; } } /*********************************************************** trim is a simple function to remove leading/trailing spaces ************************************************************/ function trim(aStr) { return aStr.replace(/^\s{1,}/, "").replace(/\s{1,}$/, "") } /*********************************************************** following two functions call the date picking dialog box ************************************************************/ function myDateDialog(){ var retDay; var retMonth; var retYear; } /************************************************************* Funciones Maggie **************************************************************/ function isLeapYear (Year) { if (((Year % 4)==0) && ((Year % 100)!=0) || ((Year % 400)==0)) { return true; } else { return false; } } function ajusta_fechas(fecha, dias_agregar) { var AddDays = Number(dias_agregar); // How many days ahead of the current date TDate = new Date(fecha); MonthDays = new Array('31', '28', '31', '30', '31', '30', '31', '31', '30', '31', '30', '31'); CurYear = TDate.getYear(); if (CurYear < 2000) CurYear = CurYear + 1900; CurMonth = TDate.getMonth(); CurDayOw = TDate.getDay(); CurDay = TDate.getDate(); if(AddDays>0) { if (CurMonth == 1) { if (((CurYear % 4)==0) && ((CurYear % 100)!=0) || ((CurYear % 400)==0)) { MonthDays[1] = 29; } else { MonthDays[1] = 28; } } days = MonthDays[CurMonth]; CurDay += AddDays; if (CurDay > days) { if (CurMonth == 11) { CurMonth = 0; CurYear = CurYear + 1 } else { CurMonth+=1 // month = TMonth[CurMonth+1]; } CurDay = CurDay - days; } fecha= (CurMonth+1) + "/" + CurDay+ "/" + CurYear } else { if (CurMonth == 2) { if (((CurYear % 4)==0) && ((CurYear % 100)!=0) || ((CurYear % 400)==0)) { MonthDays[1] = 29; } else { MonthDays[1] = 28; } } if(CurMonth==0) days = MonthDays[11]; else days = MonthDays[CurMonth-1]; CurDay += AddDays; if (CurDay < 1) { if (CurMonth == 0) { CurMonth = 11; CurYear = CurYear - 1 } else { CurMonth-=1 } CurDay = Number(CurDay) + Number(days); } fecha= (CurMonth+1) + "/" + CurDay+ "/" + CurYear } return fecha } function formatea_fecha(fecha) { fecha_aux=new Date(fecha); d=fecha_aux.getDate(); m=fecha_aux.getMonth()+1; a=fecha_aux.getYear(); if(d<10) d="0"+d if(m<10) m="0"+m if(a<1000) a=1900+a fecha=m+"/"+d+"/"+a return fecha } /************************************************************* Fin de Funciones Maggie **************************************************************/ function openDatePickerDialog(wnd, field, dateFormat, campo) { var dias_inter = Number(14); var dias_recor = Number(9); var dias_otro = Number(11); var dias_limite = Number(-6); var dias_junta = Number(-6); var dias_tecnico = Number(1); var dias_visitas = Number(-1); var dias_economica = Number(1) myDateDialog.retDay=""; myDateDialog.retMonth=""; myDateDialog.retYear=""; var aux_fecha; var pathname = window.location.pathname; var dlgURL = pathname.substring(0,(pathname.lastIndexOf(".nsf") + 5))+'dlgDatePicker?OpenForm'; if(wnd.showModalDialog(dlgURL,myDateDialog, "dialogHeight:380px;dialogWidth:280px;center")==true){ /* field_value=dateFormat.replace(/yyyy/, myDateDialog.retYear).replace(/mm/, myDateDialog.retMonth).replace(/dd/, myDateDialog.retDay); */ field_value = myDateDialog.retMonth+"/"+myDateDialog.retDay + "/" +myDateDialog.retYear; if(campo==1) { //fecha recepcion de propuesta y apertura tecnica if(window.document.forms[0].lic_recortado.checked) dias=dias_recor else { if(window.document.forms[0].lic_caracter.value=="INTERNACIONAL") dias=dias_inter else dias=dias_otro } aux_fecha=ajusta_fechas(field_value,dias) aux_fecha=formatea_fecha(aux_fecha) window.document.forms[0].lic_tecnica.value=aux_fecha; //fecha limite para confirmar dias=dias_limite; aux_fecha=ajusta_fechas(window.document.forms[0].lic_tecnica.value,dias) aux_fecha=formatea_fecha(aux_fecha) window.document.forms[0].lic_limite.value=aux_fecha //fecha junta de aclaraciones dias=dias_junta; aux_fecha=ajusta_fechas(window.document.forms[0].lic_tecnica.value,dias) aux_fecha=formatea_fecha(aux_fecha) window.document.forms[0].lic_junta.value=aux_fecha //fecha fallo tecnico y apertura economica dias=dias_tecnico aux_fecha=ajusta_fechas(window.document.forms[0].lic_tecnica.value,dias) aux_fecha=formatea_fecha(aux_fecha) window.document.forms[0].lic_economica.value=aux_fecha //fecha visitas dias=dias_visitas aux_fecha=ajusta_fechas(window.document.forms[0].lic_junta.value,dias) aux_fecha=formatea_fecha(aux_fecha) window.document.forms[0].lic_visfec.value=aux_fecha } if(campo==2) { //validaciones campo LIC_LIMITE aux1 = new Date(field_value); dias = dias_limite; aux = ajusta_fechas(window.document.forms[0].lic_tecnica.value, dias) aux2 = new Date(aux) aux3 = new Date(window.document.forms[0].lic_publicacion.value) if(aux1>aux2) { alert("Fecha Limite de Pago de Bases Debe ser al menos 6 Dias antes de la Apertura Tecnica"); return(window.document.forms[0].lic_limite.value); } if(aux1aux2) { alert("Fecha de Junta de Aclaraciones Debe ser al menos 6 Dias antes de la Apertura Tecnica"); return(window.document.forms[0].lic_junta.value); } if(aux1aux2) { alert("Fecha de Visitas debe ser Anterior a la fecha de Aclaraciones"); return(window.document.forms[0].lic_visfec.value); } if(aux1aux2) { alert("Fecha Invalida. No puede ser anterior a la Fecha de Publicacion"); return(field.value); } } field_value=formatea_fecha(field_value); field.value=field_value; }else{ return; } }