1/* vim: set expandtab tabstop=4 shiftwidth=4: */ /* +----------------------------------------------------------------------+ * | PHP version 5.2.5 | * +----------------------------------------------------------------------+ * | Copyright (c) 2010 - Infodec S.A. | * +----------------------------------------------------------------------+ * | Authors: Fernando Rengifo < fernando.rengifo.ch@gmail.com > | * +----------------------------------------------------------------------+ * */ // // Especificación de funciones javascript // /** * * @package Funciones * @version 0.1 * @author Fernando Rengifo < fernando.rengifo.ch@gmail.com > , Jhon Freddy Marin < chino1719@hotmail.com > * @since PHP 5.2.5 */ // Javascript // Hace el llamado al formulario para crear un nuevo registro function nuevo_registro(obje_numero, parametros, operacion){ if ( movilidad == '1' ){ if ( operacion == '' ){ window.location = "phrame.php?action=transaccion&id_objeto="+obje_numero+"&operacion=Adicionar"+parametros; }else{ window.location = "phrame.php?action="+operacion+"&operacion=Adicionar"+parametros; } }else{ if ( operacion == '' ){ jQuery(".newModal").modalWindow ("phrame.php?action=transaccion&id_objeto="+obje_numero+"&operacion=Adicionar"+parametros); }else{ jQuery(".newModal").modalWindow ("phrame.php?action="+operacion+"&operacion=Adicionar"+parametros); } } } // Hace el llamado a una ventana modal que mostrara el calendario function calendarModal(Modal){ jQuery(".ModalCalendar").modalCalendar ("phrame.php?action="+Modal); } // Hace el llamado a una ventana modal que mostrara cualquier url que se le pase como parametro function modalWindows(Modal, id_object){ jQuery(".modalWindow").modalwindows ("phrame.php?action="+Modal+'&id_modul='+id_object); } // Hace el llamado al formulario para modificar un nuevo registro function modificar_registro(obje_numero, parametros, operacion){ if ( movilidad == '1' ){ if ( operacion == '' ){ window.location = "phrame.php?action=transaccion&id_objeto="+obje_numero+"&operacion=Modificar"+parametros; }else{ window.location = "phrame.php?action="+operacion+"&operacion=Modificar"+parametros; } }else{ if ( operacion == '' ){ jQuery(".ajax").modalWindow ("phrame.php?action=transaccion&id_objeto="+obje_numero+"&operacion=Modificar"+parametros); }else{ jQuery(".ajax").modalWindow ("phrame.php?action="+operacion+"&operacion=Modificar"+parametros); } } } // Hace el llamado al formulario para eliminar un registro function eliminar_registro(obje_numero, parametros){ if ( confirm('¿?') ) { jQuery.ajax({ type: 'post', url: 'phrame.php', data: "action=registrar&id_objeto="+obje_numero+"&operacion=Eliminar"+parametros, success: function(res){ window.parent.loading(); msj = res.split('*****'); if( msj[1] != "" ){ window.parent.location=msj[1]; } } }); } } //Realiza la validación de los campos que estan incluidos en los filtros function validarFiltro(tipo_dato, valor , campo, etiqueta){ var cab_error; cab_error = " '" + etiqueta + "' "; var error; var expresion; var tipo; switch(tipo_dato){ case 7: //Decimal case 6: //Numero case 9: //Moneda expresion = /^\d+$/; tipo = ""; break; case 4: //Fecha Corta expresion = /^(\d{4})-(0\d|\d|[0-1][0-2])-(0\d|\d|[0-2]\d|3[0-1])$/; tipo = ""; break; case 5: //Fecha Larga expresion = /^(\d{4})-(0\d|\d|[0-1][0-2])-(0\d|\d|[0-2]\d|3[0-1]) (0\d|\d|1\d|2[0-3])(:(0\d|\d|[0-5][0-9])){1}$/; tipo = ""; break; case 8: //Hora expresion = /^(0\d|\d|1\d|2[0-3])(:(0\d|\d|[0-5][0-9])){1}$/; tipo = ""; break; } if ( valor ){ if ( valor.match(expresion) ) error = ""; else error = cab_error + tipo; }else { error = ""; } if ( error != ""){ alert(error); document.getElementById(campo).value = ''; document.getElementById(campo).focus(); } } //Realiza la validación del tipo de dato en la pregunta de la encuesta function validaTipoPregunta(valor){ document.getElementById('RESPUESTA').value = ''; if (valor != 3){ document.getElementById('RESPUESTA').disabled = true; }else{ document.getElementById('RESPUESTA').disabled = false; } } //Realiza una operación sobre un reporte function operacion_reporte(obje_numero, id_reporte, operacion){ if (operacion == 'Eliminar'){ if ( confirm('¿?') ) { loading(); window.location = "phrame.php?action=registra_reporte&id_objeto="+obje_numero+"&operacion="+operacion+"&id_reporte="+id_reporte+"&go="+document.forma.action.value; } }else if(operacion == 'Visualiza'){ window.open('phrame.php?action=mostrar_reporte&id_objeto='+obje_numero+'&id_reporte='+id_reporte+'','','width=880,height=580,top=50,left=50,scrollbars=yes,resizable=yes'); // url = 'phrame.php?action=mostrar_reporte&id_objeto='+obje_numero+'&id_reporte='+id_reporte; // openDialog(window, '', '', url); }else{ loading(); window.location = "phrame.php?action=reportes&id_objeto="+obje_numero+"&operacion="+operacion+"&id_reporte="+id_reporte; } } // Carga dinamicamente un archivo js o css function loadjscssfile(filename, filetype){ if (filetype=="js"){ //if filename is a external JavaScript file var fileref=document.createElement('script') fileref.setAttribute("type","text/javascript") fileref.setAttribute("src", filename) } else if (filetype=="css"){ //if filename is an external CSS file var fileref=document.createElement("link") fileref.setAttribute("rel", "stylesheet") fileref.setAttribute("type", "text/css") fileref.setAttribute("href", filename) } if (typeof fileref!="undefined") document.getElementsByTagName("head")[0].appendChild(fileref) } /****************************************************/ /* La siguiente función activa todos los checkbox */ /* del arreglo enviado en la variable "arreglo" */ /* Parámetros: */ /* - campo: arreglo del checkbox */ /* - action: true o False */ /****************************************************/ function checkear_todas(campo, action) { len = campo.length; var i = 0; for(i = 0; i < len; i++) { campo[i].checked = action; } } // Permite seleccionar los campos que van dentro del reporte function seleccionarCampoReporte() { obj=document.getElementById('listaCampos'); if (obj.selectedIndex==-1) return; valor=obj.value; txt=obj.options[obj.selectedIndex].text; obj.options[obj.selectedIndex]=null; obj2=document.getElementById('listaSeleccion'); opc = new Option(txt,valor); eval(obj2.options[obj2.options.length]=opc); } //Recorre los pasos para la creación del reporte function swapIt(o, nomContenido, pordefecto, navigation, contenedor) { o.blur(); //Esto quita el foco de la pesta?a a la que le hicieron click if (o.className == pordefecto) return false; var list = document.getElementById(navigation).getElementsByTagName("li"); for (var i = 0; i < list.length; i++) { if (document.getElementById(list[i].id).className == pordefecto) { document.getElementById(list[i].id).className = ""; }else { if (document.getElementById(list[i].id).className.search(pordefecto) >= 0) { document.getElementById(list[i].id).className = document.getElementById(list[i].id).className.replace(pordefecto , ''); } } } document.getElementById(o.id).className = document.getElementById(o.id).className + ' ' + pordefecto; list = document.getElementById(contenedor).childNodes; for (var i = 0; i < list.length; i++) { if (list[i].tagName == "DIV") { list[i].style.display = "none"; } } if(document.getElementById(nomContenido)){ var top = document.getElementById(nomContenido); top.style.display = "block"; } return false; } //Valida los botones y permite seguir al próximo nivel function validarBotonReporte(paso, from1, from2){ if ( document.forma.operacion.value != 'Nuevo' && paso == 1 ) return; switch(paso){ case 1: if ((document.forma.TIPO_REPORTE[0].checked || document.forma.TIPO_REPORTE[2].checked) && from1.options.length != 0){ document.getElementById('Sig1').disabled = false; }else{ document.getElementById('Sig1').disabled = true; if (document.forma.TIPO_REPORTE[1].checked || document.forma.TIPO_REPORTE[3].checked){ document.getElementById('Sig1').disabled = false; //document.getElementById('selecc_campos').style.visibility='hidden'; }else{ document.getElementById('Sig1').disabled = true; //document.getElementById('selecc_campos').style.visibility='visible'; } } break; case 3: if ( from1.options.length != 0 && from2.options.length != 0 ){ document.getElementById('Sig22').disabled = false; }else{ document.getElementById('Sig22').disabled = true; } break; case 4: if ( from1.options.length != 0 ){ document.getElementById('Sig23').disabled = false; }else{ document.getElementById('Sig23').disabled = true; } break; case 5: if ( from1.options.length != 0 ){ document.getElementById('Sig24').disabled = false; }else{ document.getElementById('Sig24').disabled = true; } break; } } //Habilita o deshabilita las botones para pasar las coordenadas function deshabilitaBoton(from, btno1, btno2){ for (var i=0; i < from.options.length; i++) { var o = from.options[i]; if (o.selected) { document.getElementById(btno1).disabled = true; document.getElementById(btno2).disabled = false; } } } //Pasa el campo seleccionado a la formula function asociarFormula(from, to){ for (var i=0; i < from.options.length; i++) { var o = from.options[i]; var valor_campo = o.text; if (o.selected) { if ( valor_campo.indexOf('----') == -1 && valor_campo.indexOf('[') == -1) { document.getElementById(to).value = document.getElementById(to).value + o.value; } } } } //------------------------------------------------------------------------------------- var globalCursorPos; // global variabe to keep track of where the cursor was //sets the global variable to keep track of the cursor position function setCursorPos(campo) { globalCursorPos = getCursorPos(document.getElementById(campo)); } //This function returns the index of the cursor location in //the value of the input text element //It is important to make sure that the sWeirdString variable contains //a set of characters that will not be encountered normally in your //text function getCursorPos(textElement) { //save off the current value to restore it later, var sOldText = textElement.value; //create a range object and save off it's text var objRange = document.selection.createRange(); var sOldRange = objRange.text; //set this string to a small string that will not normally be encountered var sWeirdString = '#%~'; //insert the weirdstring where the cursor is at objRange.text = sOldRange + sWeirdString; objRange.moveStart('character', (0 - sOldRange.length - sWeirdString.length)); //save off the new string with the weirdstring in it var sNewText = textElement.value; //set the actual text value back to how it was objRange.text = sOldRange; //look through the new string we saved off and find the location of //the weirdstring that was inserted and return that value for (i=0; i <= sNewText.length; i++) { var sTemp = sNewText.substring(i, i + sWeirdString.length); if (sTemp == sWeirdString) { var cursorPos = (i - sOldRange.length); return cursorPos; } } } //----------------------------------------------------------------------------------------- //Realiza el calculo de los productos y agregados en el cotizador function sumarAgregado(operacion, valor){ var cantidad = 0; var total = 0; if ( valor != "") cantidad = valor; if ( document.getElementById('valor').value != "" ) total = document.getElementById('valor').value; switch(operacion){ case '-': total = eval(total) - eval(cantidad); break; case '+': total = eval(total) + eval(cantidad); break; default : total = eval(cantidad); break; } document.getElementById('valor').value = total; document.getElementById('total').innerHTML = document.getElementById('valor').value; } //Arma la lista de agregados de los productos function armar_lista_agregado(num_agrega){ var campo = ''; var lista = ''; for (i=0; i < num_agrega; i++){ campo = 'agregados' + i; if (document.getElementById(campo).checked == true) lista = lista + document.getElementById(campo).value + '-'; } document.getElementById('lista_agregado').value = lista; } //Habilita o Deshabilita los campos en la creacion de relacion dependencias function validar_dependencias(valor, campo){ //alert('entro'); if ( valor == '' ){ document.getElementById(campo).disabled = false; }else{ document.getElementById(campo).disabled = true; } if ( (document.getElementById('OBJE_NUMERO_P').value != '' || document.getElementById('LIST_NUMERO_P').value != '' ) && ( document.getElementById('OBJE_NUMERO_H').value != '' || document.getElementById('LIST_NUMERO_H').value != '') ){ document.getElementById('mySubmit').disabled = false; }else{ document.getElementById('mySubmit').disabled = true; } } //Habilita o Deshabilita el submit en los valores de referencia y en las dependencias function validar_referencia(){ if ( document.getElementById('VALOR_OBJETO').value != '' || document.getElementById('VALOR_LISTA').value != '' ){ document.getElementById('mySubmit').disabled = false; }else{ document.getElementById('mySubmit').disabled = true; } } //Habilita o Deshabilita los campos para definir los productos sugerencia function validar_tipo_sugerencia(valor){ if ( valor == '1' ){ document.getElementById('TIPO_CLIENTE').value =''; document.getElementById('TIPO_CLIENTE').disabled = true; document.getElementById('PRDO_SUGERENCIA').disabled = false; } else { if ( valor == '2' ){ document.getElementById('PRDO_SUGERENCIA').value =''; document.getElementById('PRDO_SUGERENCIA').disabled = true; document.getElementById('TIPO_CLIENTE').disabled = false; } else { document.getElementById('TIPO_CLIENTE').value =''; document.getElementById('TIPO_CLIENTE').disabled = false; document.getElementById('PRDO_SUGERENCIA').value =''; document.getElementById('PRDO_SUGERENCIA').disabled = false; } } } //Habilitar la lista de valores de actividades previas de la campaña function validar_act_previas_campa(valor){ if ( valor == '3' ){ return true; } else{ return false; } } //Habilitar la lista de valores de actividades previas de la campaña function validar_encuesta_campa(valor){ if ( valor == '2' ){ return true; } else{ return false; } } //Habilita o Deshabilita los campos para segun el tipo de actividad de la campaña function validar_fecha_referencia_campa(valor){ if ( valor != '3' ){ document.getElementById('ACTCMPA_NUMERO_DESC').value =''; document.getElementById('ACTCMPA_NUMERO').value =''; document.getElementById('ACTCMPA_NUMERO_DESC').disabled = true; } else { document.getElementById('ACTCMPA_NUMERO_DESC').disabled = false; } } //Habilita o Deshabilita los campos para segun el tipo de actividad de la campaña function validar_tipo_actividad_campa(valor){ if ( valor == '1' ){ document.getElementById('ENCU_NUMERO_DESC').value =''; document.getElementById('ENCU_NUMERO').value =''; document.getElementById('ENCU_NUMERO_DESC').disabled = true; document.getElementById('ARCHIVO_CORREO').disabled = false; document.getElementById('IMAGEN_CORREO').disabled = false; } else { if ( valor == '2' ){ document.getElementById('ARCHIVO_CORREO').value =''; document.getElementById('ARCHIVO_CORREO').disabled = true; document.getElementById('IMAGEN_CORREO').value =''; document.getElementById('IMAGEN_CORREO').disabled = true; document.getElementById('ENCU_NUMERO_DESC').disabled = false; } else { if ( valor == '3' ) { document.getElementById('ARCHIVO_CORREO').value =''; document.getElementById('ARCHIVO_CORREO').disabled = true; document.getElementById('IMAGEN_CORREO').value =''; document.getElementById('IMAGEN_CORREO').disabled = true; document.getElementById('ENCU_NUMERO').value =''; document.getElementById('ENCU_NUMERO_DESC').value =''; document.getElementById('ENCU_NUMERO_DESC').disabled = true; } else { document.getElementById('ARCHIVO_CORREO').value =''; document.getElementById('ARCHIVO_CORREO').disabled = false; document.getElementById('IMAGEN_CORREO').value =''; document.getElementById('IMAGEN_CORREO').disabled = false; document.getElementById('ENCU_NUMERO').value =''; document.getElementById('ENCU_NUMERO_DESC').value =''; document.getElementById('ENCU_NUMERO_DESC').disabled = false; } } } } //Validacion en la creacion de campos function validar_campos(tipo, valor, campo){ // Validacion para el tipo de dato if ( tipo == '1' ){ document.forma.LIST_NUMERO.disabled = false; document.forma.DECIMALES.disabled = false; document.forma.FORMULA.disabled = false; document.forma.CONDICION_LISTA.disabled = false; document.forma.SEGURIDAD.disabled = false; document.forma.VALOR_DEFECTO.disabled = false; document.forma.TIPO_LLAVE.disabled = false; // Valores por defecto if ( document.forma.ACTIVO.value == '' ) document.forma.ACTIVO.value = 1; if ( document.forma.OBLIGATORIO.value == '' ) document.forma.OBLIGATORIO.value = 2; if ( document.forma.TRANSACCION.value == '' ) document.forma.TRANSACCION.value = 1; if ( document.forma.LISTADO.value == '' ) document.forma.LISTADO.value = 2; if ( document.forma.CONSULTA.value == '' ) document.forma.CONSULTA.value = 2; if ( document.forma.REPORTE.value == '' ) document.forma.REPORTE.value = 1; if ( document.forma.EDITABLE.value == '' && document.forma.TIPO_LLAVE.value == '' ) document.forma.EDITABLE.value = 1; else if ( document.forma.EDITABLE.value == '' ) document.forma.EDITABLE.value = 2; if ( document.forma.VISIBLE.value == '' && document.forma.TIPO_LLAVE.value == '' ) document.forma.VISIBLE.value = 1; else if ( document.forma.VISIBLE.value == '' ) document.forma.VISIBLE.value = 2; if ( document.forma.BUSQUEDA.value == '' ) document.forma.BUSQUEDA.value = 2; if ( document.forma.SISTEMA.value == '' ) document.forma.SISTEMA.value = 2; switch( valor ){ case '1': //Texto if ( document.forma.LONGITUD.value == '' ) document.forma.LONGITUD.value = 30; case '2': //Texto Largo if ( document.forma.LONGITUD.value == '' ) document.forma.LONGITUD.value = 4000; case '11': //Correo if ( document.forma.LONGITUD.value == '' ) document.forma.LONGITUD.value = 100; case '12': //Archivo case '13': //Password //Limpia los campos document.forma.LIST_NUMERO.value = ''; document.forma.DECIMALES.value = ''; document.forma.CONDICION_LISTA.value = ''; document.forma.VALOR_DEFECTO.value = ''; document.forma.SEGURIDAD.value = ''; document.forma.FORMULA.value = ''; document.forma.TIPO_LLAVE.value = ''; document.forma.OBJE_REFERENCIA_DESC.value = ''; document.forma.OBJE_REFERENCIA.value = ''; document.forma.CAMP_DEPENDIENTE_DESC.value = ''; document.forma.CAMP_DEPENDIENTE.value = ''; //Deshabilita los campos document.forma.LIST_NUMERO.disabled = true; document.forma.DECIMALES.disabled = true; document.forma.CONDICION_LISTA.disabled = true; document.forma.VALOR_DEFECTO.disabled = true; document.forma.SEGURIDAD.disabled = true; document.forma.TIPO_LLAVE.disabled = true; break; case '3': //Lista Valores document.forma.DECIMALES.value = ''; document.forma.DECIMALES.disabled = true; document.forma.TIPO_LLAVE.value = ''; document.forma.TIPO_LLAVE.disabled = true; if ( document.forma.LONGITUD.value == '' ) document.forma.LONGITUD.value = 10; if ( document.forma.OBJE_REFERENCIA_DESC.value != '' ){ document.forma.LIST_NUMERO.value = ''; document.forma.LIST_NUMERO.disabled = true; } if ( document.forma.OBJE_REFERENCIA_DESC.value == '' && document.forma.LIST_NUMERO.value == '' ){ document.forma.CONDICION_LISTA.value = ''; document.forma.CONDICION_LISTA.disabled = true; } if ( document.forma.OBJE_REFERENCIA.value != 9 ){ document.forma.SEGURIDAD.value = ''; document.forma.SEGURIDAD.disabled = true; } //Solo me permite valor por defecto como usuario y cuenta unica if ( document.forma.OBJE_REFERENCIA.value != 18 && document.forma.OBJE_REFERENCIA.value != 9 ){ document.forma.VALOR_DEFECTO.value = ''; document.forma.VALOR_DEFECTO.disabled = true; } else { var p = document.forma.VALOR_DEFECTO.length; for ( var i = 0; i < p; ++i ){ document.forma.VALOR_DEFECTO.remove(document.forma.VALOR_DEFECTO.options[i]); } document.forma.VALOR_DEFECTO[0] = new Option("", '', true); if ( document.forma.OBJE_REFERENCIA.value == 9 ){ document.forma.VALOR_DEFECTO[1] = new Option("Usuario", 'Usuario'); }else{ document.forma.VALOR_DEFECTO[1] = new Option("Cuenta Única", 'CuentaUnic'); } } break; case '4': //Fecha Corta if ( document.forma.LONGITUD.value == '' ) document.forma.LONGITUD.value=0; case '5': //Fecha Larga if ( document.forma.LONGITUD.value == '' ) document.forma.LONGITUD.value=0; //Limpia los campos document.forma.LIST_NUMERO.value = ''; document.forma.DECIMALES.value = ''; document.forma.CONDICION_LISTA.value = ''; document.forma.SEGURIDAD.value = ''; document.forma.TIPO_LLAVE.value = ''; document.forma.OBJE_REFERENCIA_DESC.value = ''; document.forma.OBJE_REFERENCIA.value = ''; document.forma.CAMP_DEPENDIENTE_DESC.value = ''; document.forma.CAMP_DEPENDIENTE.value = ''; //Deshabilita los campos document.forma.LIST_NUMERO.disabled = true; document.forma.DECIMALES.disabled = true; document.forma.CONDICION_LISTA.disabled = true; document.forma.SEGURIDAD.disabled = true; document.forma.TIPO_LLAVE.disabled = true; //Solo me permite valor por defecto como fecha var p = document.forma.VALOR_DEFECTO.length; for ( var i = 0; i < p; ++i ){ document.forma.VALOR_DEFECTO.remove(document.forma.VALOR_DEFECTO.options[i]); } document.forma.VALOR_DEFECTO[0] = new Option("", '', true); document.forma.VALOR_DEFECTO[1] = new Option("Fecha", 'Fecha'); break; case '6': //Numero if ( document.forma.LONGITUD.value == '' ) document.forma.LONGITUD.value = 10; document.forma.LIST_NUMERO.value = ''; document.forma.DECIMALES.value = ''; if ( document.forma.OBJE_REFERENCIA_DESC.value != '' ){ document.forma.LIST_NUMERO.disabled = true; document.forma.DECIMALES.disabled = true; } if ( document.forma.OBJE_REFERENCIA_DESC.value == '' && document.forma.LIST_NUMERO.value == '' ){ document.forma.CONDICION_LISTA.value = ''; document.forma.CONDICION_LISTA.disabled = true; } if ( document.forma.OBJE_REFERENCIA_DESC.value != '' ){ document.forma.FORMULA.value = ''; } if ( document.forma.OBJE_REFERENCIA.value != 9 ){ document.forma.SEGURIDAD.value = ''; document.forma.SEGURIDAD.disabled = true; } //Solo me permite valor por defecto como usuario y cuenta unica if ( document.forma.OBJE_REFERENCIA.value != 18 && document.forma.OBJE_REFERENCIA.value != 9 ){ document.forma.VALOR_DEFECTO.value = ''; document.forma.VALOR_DEFECTO.disabled = true; } else { var p = document.forma.VALOR_DEFECTO.length; for ( var i = 0; i < p; ++i ){ document.forma.VALOR_DEFECTO.remove(document.forma.VALOR_DEFECTO.options[i]); } document.forma.VALOR_DEFECTO[0] = new Option("", '', true); if ( document.forma.OBJE_REFERENCIA.value == 9 ){ document.forma.VALOR_DEFECTO[1] = new Option("Usuario", 'Usuario'); }else{ document.forma.VALOR_DEFECTO[1] = new Option("Cuenta Única", 'CuentaUnic'); } } break; case '7': //Decimal document.forma.TIPO_LLAVE.value = ''; document.forma.TIPO_LLAVE.disabled = true; document.forma.SEGURIDAD.value = ''; document.forma.SEGURIDAD.disabled = true; if (document.forma.LONGITUD.value == '') document.forma.LONGITUD.value = 10; if (document.forma.DECIMALES.value=='') document.forma.DECIMALES.value = 2; case '8': //Hora document.forma.TIPO_LLAVE.value = ''; document.forma.TIPO_LLAVE.disabled = true; document.forma.SEGURIDAD.value = ''; document.forma.SEGURIDAD.disabled = true; if ( document.forma.LONGITUD.value == '' ) document.forma.LONGITUD.value = 0; case '9': //Moneda document.forma.TIPO_LLAVE.value = ''; document.forma.TIPO_LLAVE.disabled = true; document.forma.SEGURIDAD.value = ''; document.forma.SEGURIDAD.disabled = true; if ( document.forma.LONGITUD.value == '' ) document.forma.LONGITUD.value = 10; if ( document.forma.DECIMALES.value == '' ) document.forma.DECIMALES.value = 2; //Limpia los campos document.forma.LIST_NUMERO.value = ''; document.forma.CONDICION_LISTA.value = ''; document.forma.VALOR_DEFECTO.value = ''; document.forma.SEGURIDAD.value = ''; document.forma.TIPO_LLAVE.value = ''; document.forma.OBJE_REFERENCIA_DESC.value = ''; document.forma.OBJE_REFERENCIA.value = ''; document.forma.CAMP_DEPENDIENTE_DESC.value = ''; document.forma.CAMP_DEPENDIENTE.value = ''; //Deshabilita los campos document.forma.LIST_NUMERO.disabled = true; document.forma.CONDICION_LISTA.disabled = true; document.forma.VALOR_DEFECTO.disabled = true; document.forma.SEGURIDAD.disabled = true; document.forma.TIPO_LLAVE.disabled = true; break; default : var p = document.forma.VALOR_DEFECTO.length; for ( var i = 0; i < p; ++i ){ document.forma.VALOR_DEFECTO.remove(document.forma.VALOR_DEFECTO.options[i]); } document.forma.OBJE_REFERENCIA_DESC.value = ''; document.forma.OBJE_REFERENCIA.value = ''; document.forma.CAMP_DEPENDIENTE_DESC.value = ''; document.forma.CAMP_DEPENDIENTE.value = ''; document.forma.VALOR_DEFECTO[0] = new Option("", '', true); document.forma.VALOR_DEFECTO[1] = new Option("Usuario", 'Usuario'); document.forma.VALOR_DEFECTO[2] = new Option("Fecha", 'Fecha'); document.forma.VALOR_DEFECTO[3] = new Option("Cuenta Única", 'CuentaUnic'); break; } formValObj.__initiallyParseAForm(1); } else { switch( valor ){ case '1': //Texto case '2': //Texto Largo case '11': //Correo case '12': //Archivo case '13': //Password if ( campo != "GRUP_NUMERO" && campo != "CAMP_REFERENCIA" && campo != '' ) return false; break; case '4': //Fecha Corta case '5': //Fecha Larga if ( campo != "GRUP_NUMERO" && campo != "FORMULA" && campo != "CAMP_REFERENCIA" && campo != '' ) return false; break; case '3': //Lista Valores case '6': //Numero if ( campo == "OBJE_REFERENCIA" ){ if ( document.forma.OBJE_REFERENCIA_DESC.value == '' ){ if ( valor == 3){ document.forma.LIST_NUMERO.disabled = false; } if ( document.forma.LIST_NUMERO.value == '' ){ document.forma.CONDICION_LISTA.value = ''; document.forma.CONDICION_LISTA.disabled = true; } else { return false; } }else{ document.forma.LIST_NUMERO.value == ''; document.forma.LIST_NUMERO.disabled = true; document.forma.CONDICION_LISTA.disabled = false; document.forma.FORMULA.value = ''; } if ( document.forma.OBJE_REFERENCIA.value == 9 ){ document.forma.SEGURIDAD.disabled = false; }else{ document.forma.SEGURIDAD.disabled = true; document.forma.SEGURIDAD.value = ''; } //Solo me permite valor por defecto como usuario y cuenta unica if ( document.forma.OBJE_REFERENCIA.value != 18 && document.forma.OBJE_REFERENCIA.value != 9 ){ document.forma.VALOR_DEFECTO.value = ''; document.forma.VALOR_DEFECTO.disabled = true; } else { document.forma.VALOR_DEFECTO.disabled = false; var p = document.forma.VALOR_DEFECTO.length; for ( var i = 0; i < p; ++i ){ document.forma.VALOR_DEFECTO.remove(document.forma.VALOR_DEFECTO.options[i]); } document.forma.VALOR_DEFECTO[0] = new Option("", '', true); if ( document.forma.OBJE_REFERENCIA.value == 9 ){ document.forma.VALOR_DEFECTO[1] = new Option("Usuario", 'Usuario' ); }else{ document.forma.VALOR_DEFECTO[1] = new Option("Cuenta Única", 'CuentaUnic'); } } } else { if ( campo == ''){ if ( document.forma.LIST_NUMERO.value == '' ){ if ( document.forma.OBJE_REFERENCIA_DESC.value == '' ){ document.forma.CONDICION_LISTA.value = ''; document.forma.CONDICION_LISTA.disabled = true; } }else{ document.forma.CONDICION_LISTA.disabled = false; document.forma.OBJE_REFERENCIA.value = ''; document.forma.OBJE_REFERENCIA_DESC.value = ''; } if ( document.forma.OBJE_REFERENCIA_DESC.value == '' ){ document.forma.SEGURIDAD.disabled = true; document.forma.SEGURIDAD.value = ''; document.forma.VALOR_DEFECTO.disabled = true; document.forma.VALOR_DEFECTO.value = ''; } } } if ( campo == "CAMP_DEPENDIENTE" && document.forma.OBJE_REFERENCIA_DESC.value == '' && document.forma.LIST_NUMERO.value == '') return false; if ( campo == "FORMULA" && document.forma.OBJE_REFERENCIA_DESC.value != '') return false; break; case '7': //Decimal case '8': //Hora case '9': //Moneda if ( campo != "GRUP_NUMERO" && campo != "FORMULA" && campo != "CAMP_REFERENCIA" && campo != '' ) return false; break; default : break; } formValObj.__initiallyParseAForm(1); return true; } } function ie8SafePreventEvent(e){ if(e.preventDefault){ e.preventDefault()} //else{e.stop()}; e.returnValue = false; //e.stopPropagation(); } //Coloca visible o invisible los tabs del detalle function visible_tabs(obj_click, e){ //e.preventDefault(); ie8SafePreventEvent(e); var lista_ante = 'LIST_' + jQuery("#obje_tab_actual").val(); var objeto_ante = 'OBJ_' + jQuery("#obje_tab_actual").val(); var lista_actu = 'LIST_' + obj_click; var objeto_actu = 'OBJ_' + obj_click; jQuery("#"+lista_ante).removeClass("current"); jQuery("#"+lista_ante).addClass("vacio"); jQuery("#"+lista_actu).removeClass("vacio"); jQuery("#"+lista_actu).addClass("current"); jQuery("#"+objeto_ante).hide(); jQuery("#"+objeto_actu).show(); jQuery("#obje_tab_actual").val(obj_click); var cadTable = jQuery("#"+objeto_actu).find("div").eq(1).html(); jQuery("#nuevoayuda").html(cadTable); } //Manejo de las listas con seleccion multiple en los filtros (Adiciona) function adicionar( clave , descriptor, indice){ var lst_cadena = document.forma.cadena.value; var largos_array = lst_cadena.split(","); for( i = 0; i < largos_array.length; i++ ){ if( largos_array[i] == clave ){ eliminar(clave); break; } } if ( i == largos_array.length ){ if ( document.forma.cadena.value == '' ){ document.forma.cadena.value = clave + ","; document.forma.cadenaDesc.value = descriptor + ","; }else{ document.forma.cadena.value = document.forma.cadena.value + clave + ","; document.forma.cadenaDesc.value = document.forma.cadenaDesc.value + descriptor + ","; } } } //Manejo de las listas con seleccion multiple en los filtros (Elimina) function eliminar(clave){ var lst_cadena = document.forma.cadena.value; var lst_cadenaDesc = document.forma.cadenaDesc.value; var largos_array = lst_cadena.split(","); var largos_arrayDesc = lst_cadenaDesc.split(","); var Tempcadena=''; var TempcadenaDesc=''; for( ind = 0; ind < largos_array.length-1; ind++ ){ if( largos_array[ind] != clave ){ if ( Tempcadena == '' ){ Tempcadena = largos_array[ind] + ','; TempcadenaDesc = largos_arrayDesc[ind] + ','; }else{ Tempcadena = Tempcadena + largos_array[ind] + ','; TempcadenaDesc = TempcadenaDesc + largos_arrayDesc[ind] + ','; } } } document.forma.cadena.value = Tempcadena; document.forma.cadenaDesc.value = TempcadenaDesc; } //Funcion modal abre carga function loading(){ messageObj = new DHTML_modalMessage(); // messageObj.setSource('../vistas/loading.php'); messageObj.setHtmlContent("
...
"); messageObj.setSize(190, 24); messageObj.display(); } //Funcion modal cierra carga function unloading(){ messageObj.close(); } // Funcion que se encarga de mostrar las ventana con las alertas function openFocusAndGO(url){ window.focus(); window.location.href=url; } // Funcion que se encarga de colocar en una input hidden los campos del formulario function enviarParms( url ){ if ( jQuery("#formOperacion").length > 0 ){ var cadena = jQuery("#formOperacion").serialize(); var paramLista = ""; var ex = ""; msj = cadena.split('&'); for ( k=0; k < msj.length; k++ ) { msj2 = msj[k].split('='); ex = ex+','+msj2[0]; if ( url.indexOf('&'+msj2[0]+'=') < 0 && url.indexOf('?'+msj2[0]+'=') < 0 && msj2[1].indexOf('%2') < 0 ){ if ( msj2[1] != '' ){ paramLista = paramLista + '&' + msj[k]; }else{ paramLista = paramLista + '&' + msj2[0] + '=NULL'; } } } jQuery('#paramLista').val(paramLista); jQuery('#exter').val(ex); } } // Funcion que se encarga de tomar las teclas digitadas y realizar una busqueda // en un select, para luego seleccionar una opcion en él function busquedaTagSelect(obj, eve){ var lng = obj.length; var letra = ""; // Se toma la tecla de entrada if (eve.which == null) { letra = String.fromCharCode(eve.keyCode); // IE } else if (eve.which!=0 && eve.charCode!=0) { letra = String.fromCharCode(eve.which); // the rest } // Se arma una cadena con las teclas que se van ingresando cadena=cadena+letra; // Se convierte en minuscula la cadena opt2 = cadena.toLowerCase(); jQuery(obj).find("option").each(function(){ opt = jQuery(this).text().toLowerCase(); if (opt.indexOf(opt2) != -1 ){ jQuery(this).attr("selected", "selected"); } }); // Si se teclea 'enter' se inicializa la cadena de busqueda if (eve.keyCode == 13){ borrar_tclsSelect(); } } // Funcion para reinicializar la variable de busqueda el select function borrar_tclsSelect(){ //inicializa la cadena buscada cadena=""; } // Hace el llamado al formulario para mostrar un mapa function mostrar_mapa(obje_numero){ jQuery(".ajax").modalWindow ("phrame.php?action=mostrarmap&id_objeto="+obje_numero); } // Realiza la operacion sobre un filtro de compensacion function operacion_compensacion(obje_numero, id_filtro, transaccion, operacion){ if ( operacion != '' ){ window.location = "phrame.php?action="+operacion+"&operacion="+transaccion+parametros; }else{ if (transaccion == 'Eliminar'){ if ( confirm('¿?') ) { window.location = "phrame.php?action=registra_filtros&id_objeto="+obje_numero+"&operacion="+transaccion+"&id_filtro="+id_filtro; } }else{ window.location = "phrame.php?action=genera_filtro&id_objeto="+obje_numero+"&operacion="+transaccion+"&id_filtro="+id_filtro; } } } //Valida que un campo solo permita digitar numero function soloNumeros(evento) { var key; if(window.event){ // IE key = evento.keyCode; }else if(evento.which){ // Netscape/Firefox/Opera key = evento.which; } if(evento.shiftKey || evento.ctrlKey) { if ( ( (key >= 35 && key <= 39) ) ) { return true; } else { if(window.event) // IE { window.event.keyCode=0; } return false; } } else { if ( ( ( (key >= 48 && key <= 57) ) || key <= 31 || key == 46 ) && ( key+"" != "undefined" && key != null ) ) { return true; } else { if(window.event) // IE { window.event.keyCode=0; } return false; } } return true; } //Valida que un campo solo permita solo texto function soloLetras(evento) { var key; if(window.event){ // IE key = evento.keyCode; }else if(evento.which){ // Netscape/Firefox/Opera key = evento.which; } if(evento.shiftKey || evento.ctrlKey) { if ( ( (key >= 35 && key <= 39) ) ) { return true; } else { if(window.event) // IE { window.event.keyCode=0; } return false; } } else { if ( ( (key < 48 || key > 57) ) || key < 31 || key == 46 || (key >= 97 && key <= 122) ) { return true; } else { if(window.event) // IE { window.event.keyCode=0; } return false; } } return true; } //Valida que un campo solo permita digitar texto y caracteres function textoEspecial(evento) { var key; if(window.event){ // IE key = evento.keyCode; }else if(evento.which){ // Netscape/Firefox/Opera key = evento.which; } if ( ( (key < 48 || key > 57) || (key >= 35 && key <= 39) ) || key < 31 || key == 46 ) { return true; } else { if(window.event) // IE { window.event.keyCode=0; } return false; } return true; } function validaDecimal(dat){ var er_num1=/^([0-9])*[.][0-9]*$/; var er_num2=/^([0-9])*[,][0-9]*$/; if(dat.value != ""){ if( er_num1.test(dat.value) || er_num2.test(dat.value) ){ return false; } } return true; }