/* vim: set expandtab tabstop=4 shiftwidth=4: */ /* +----------------------------------------------------------------------+ * | PHP version 5.2.5 | * +----------------------------------------------------------------------+ * | Productor (c) 2010 - Infodec S.A. | * +----------------------------------------------------------------------+ * | Authors: Jhon Fredy Marin Cortazar | * | Juan Fernando Eraso | * +----------------------------------------------------------------------+ * * * Especificación de funciones javascript * * @package Funciones * @version 1 * @author Jhon Fredy Marin , Juan Fernando Eraso * @since PHP 5.2.5 */ //Realiza la peticion GET a microsoft para obtener el token function loginMicrosoftPorURL( host, otherParams, close = false , typeRedirect = "popup", time = 1000 ){ let url = host + "?" + otherParams; if(typeRedirect == "popup"){ window.open(url, typeRedirect ,'width=600,height=600'); }else{ window.open(url); } if(close){ setTimeout(function() { window.close(); }, time); } } // Hace el llamado al formulario para crear un nuevo registro function nuevo_registro(obje_numero, parametros, operacion){ //esta url se almacenara en una variable de sesion para tenerla las veces que se almacene un registro y //no se necesite salir de la pantalla modal var url_modal = ""; if ( movilidad == '1' ){ if ( operacion == '' ){ url_modal = encodeURIComponent("phrame.php?action=transaccion&id_objeto="+obje_numero+"&operacion=Adicionar"+parametros); window.location = "phrame.php?action=transaccion&id_objeto="+obje_numero+"&operacion=Adicionar"+parametros+"&url_modal="+url_modal; }else{ url_modal = encodeURIComponent("phrame.php?action="+operacion+"&operacion=Adicionar"+parametros); window.location = "phrame.php?action="+operacion+"&operacion=Adicionar"+parametros+"&url_modal="+url_modal; } }else{ if ( operacion == '' ){ url_modal = encodeURIComponent("phrame.php?action=transaccion&id_objeto="+obje_numero+"&operacion=Adicionar"+parametros); //jQuery(".newModal").modalWindow("phrame.php?action=transaccion&id_objeto="+obje_numero+"&operacion=Adicionar"+parametros+"&url_modal="+url_modal); $('#remoteModal').on('shown.bs.modal', function () { $('#remoteModal iframe').attr("src","phrame.php?action=transaccion&id_objeto="+obje_numero+"&operacion=Adicionar"+parametros+"&url_modal="+url_modal); }); $('#remoteModal').modal({show:true}); }else{ url_modal = encodeURIComponent("phrame.php?action="+operacion+"&operacion=Adicionar"+parametros); //jQuery(".newModal").modalWindow("phrame.php?action="+operacion+"&operacion=Adicionar"+parametros+"&url_modal="+url_modal); $('#remoteModal').on('shown.bs.modal', function () { $('#remoteModal iframe').attr("src","phrame.php?action="+operacion+"&operacion=Adicionar"+parametros+"&url_modal="+url_modal); }); $('#remoteModal').modal({show:true}); } } } // Hace el llamado al formulario para crear un nuevo registro desde una lista function lista_registro(obje_numero, parametros){ //esta url se almacenara en una variable de sesion para tenerla las veces que se almacene un registro y //no se necesite salir de la pantalla modal var url_modal = ""; url_modal = encodeURIComponent("https://www.maxgp.com.co/phrame.php?action=transaccion"+parametros+"&id_objeto="+obje_numero+"&operacion=Adicionar&valor_llave="); location.replace("https://www.maxgp.com.co/phrame.php?action=transaccion"+parametros+"&id_objeto="+obje_numero+"&operacion=Adicionar&valor_llave=&url_modal="+url_modal); } // Hace el llamado a una ventana modal que mostrara el calendario function calendarModal(Modal){ //jQuery(".ModalCalendar").modalCalendar ("phrame.php?action="+Modal); //alert('phrame.php?action='+Modal); //console.log("epa"); $('#remoteModal').on('shown.bs.modal', function () { $('#remoteModal iframe').attr("src","phrame.php?action="+Modal); console.log($('iframe')); }); $('#remoteModal').modal({show:true}); /*$("#remoteModal").modal({ //remote: 'phrame.php?action='+Modal remote: 'test1.html' });*/ } // 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); $('#remoteModal').on('shown.bs.modal', function () { $('#remoteModal iframe').attr("src","phrame.php?action="+Modal+"&id_modul="+id_object); }); $('#remoteModal').modal({show:true}); } // Hace el llamado al formulario para modificar un nuevo registro function modificar_registro(obje_numero, parametros, operacion){ var url_modal = ""; if ( movilidad == '1' ){ if ( operacion == '' ){ url_modal = encodeURIComponent("phrame.php?action=transaccion&id_objeto="+obje_numero+"&operacion=Modificar"+parametros); window.location = "phrame.php?action=transaccion&id_objeto="+obje_numero+"&operacion=Modificar"+parametros+"&url_modal="+url_modal; }else{ url_modal = encodeURIComponent("phrame.php?action="+operacion+"&operacion=Modificar"+parametros); window.location = "phrame.php?action="+operacion+"&operacion=Modificar"+parametros+"&url_modal="+url_modal; } }else{ if ( operacion == '' ){ url_modal = encodeURIComponent("phrame.php?action=transaccion&id_objeto="+obje_numero+"&operacion=Modificar"+parametros); //jQuery(".ajax").modalWindow ("phrame.php?action=transaccion&id_objeto="+obje_numero+"&operacion=Modificar"+parametros+"&url_modal="+url_modal); $('#remoteModal').on('shown.bs.modal', function () { $('#remoteModal iframe').attr("src","phrame.php?action=transaccion&id_objeto="+obje_numero+"&operacion=Modificar"+parametros+"&url_modal="+url_modal); console.log($('iframe')); }); $('#remoteModal').modal({show:true}); }else{ url_modal = encodeURIComponent("phrame.php?action="+operacion+"&operacion=Modificar"+parametros); //jQuery(".ajax").modalWindow ("phrame.php?action="+operacion+"&operacion=Modificar"+parametros+"&url_modal="+url_modal); $('#remoteModal').on('shown.bs.modal', function () { $('#remoteModal iframe').attr("src","phrame.php?action="+operacion+"&operacion=Modificar"+parametros+"&url_modal="+url_modal); console.log($('iframe')); }); $('#remoteModal').modal({show:true}); } } } // Hace el llamado al formulario para eliminar un registro function eliminar_registro(obje_numero, parametros){ showConfirm("¿?", function(){ jQuery.ajax({ type: 'post', url: 'phrame.php', data: "action=registrar&id_objeto="+obje_numero+"&operacion=Eliminar"+parametros, success: function(res){ var dev = 0; if (res.indexOf("----") != -1 ){ showAlert(res, '', '#4B69C3', 'fa fa-file-code-o', function(){ window.parent.loading(); msj = res.split('*****'); if( msj[1] != "" ){ window.parent.location=msj[1]; } }); }else{ 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 != ""){ showAlert(error, '', '#FF0000', 'fa fa-exclamation-triangle'); 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'){ showConfirm("¿?", function(){ 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'); $('#remoteModal').on('shown.bs.modal', function () { $('#remoteModal iframe').attr("src","phrame.php?action=mostrar_reporte&id_objeto="+obje_numero+"&id_reporte="+id_reporte); }); $('.modal-header').append(''); $('#remoteModal').on('hidden.bs.modal', function () { $('#icono_ventana').remove(); }); $('#remoteModal').modal({show:true}); // url = 'phrame.php?action=mostrar_reporte&id_objeto='+obje_numero+'&id_reporte='+id_reporte; // openDialog(window, '', '', url); }else if(operacion == 'visualizaInicio'){ $('#remoteModal', window.parent.document).on('shown.bs.modal', function () { $('#remoteModal iframe', window.parent.document).attr("src","phrame.php?action=mostrar_reporte&id_objeto="+obje_numero+"&id_reporte="+id_reporte); }); $('.modal-header', window.parent.document).append(''); $('#remoteModal', window.parent.document).on('hidden.bs.modal', function () { $('#icono_ventana', window.parent.document).remove(); }); $('#remoteModal', window.parent.document).modal({show:true}); }else{ loading(); //$('#remoteModal').on('shown.bs.modal', function () { //$('#remoteModal iframe').attr("src","phrame.php?action=reportes&id_objeto="+obje_numero+"&operacion="+operacion+"&id_reporte="+id_reporte); //}); //$('#remoteModal').modal({show:true}); 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){ //alert(paso); 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 || document.forma.TIPO_REPORTE[3].checked) && from1.options.length != 0){ document.getElementById('Sig1').disabled = false; }else{ document.getElementById('Sig1').disabled = true; if (document.forma.TIPO_REPORTE[1].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){ 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; if ( document.getElementById('operacion').value == 'Adicionar' && document.getElementById('id_objeto').value != 5031 ) { document.getElementById('mypreSubmit').disabled = false; } }else{ document.getElementById('mySubmit').disabled = true; if ( document.getElementById('operacion').value == 'Adicionar' && document.getElementById('id_objeto').value != 5031 ) { document.getElementById('mypreSubmit').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; if ( document.getElementById('operacion').value == 'Adicionar' && document.getElementById('id_objeto').value != 5031 ) { document.getElementById('mypreSubmit').disabled = false; } }else{ document.getElementById('mySubmit').disabled = true; if ( document.getElementById('operacion').value == 'Adicionar' && document.getElementById('id_objeto').value != 5031 ) { document.getElementById('mypreSubmit').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' ){ jQuery('#LIST_NUMERO').removeAttr('disabled'); jQuery('#DECIMALES').removeAttr('disabled'); jQuery('#FORMULA').removeAttr('disabled'); jQuery('#CONDICION_LISTA').removeAttr('disabled'); jQuery('#SEGURIDAD').removeAttr('disabled'); jQuery('#VALOR_DEFECTO').removeAttr('disabled'); jQuery('#TIPO_LLAVE').removeAttr('disabled'); jQuery('#OBLIG_DEPENDIENTE').removeAttr('disabled'); // Valores por defecto if ( jQuery('#ACTIVO').val() == '' ) jQuery('#ACTIVO').val(1); if ( jQuery('#OBLIGATORIO').val() == '' ) jQuery('#OBLIGATORIO').val(2); if ( jQuery('#OBLIGATORIO').val() == '' ) jQuery('#OBLIGATORIO').val(2); if ( jQuery('#TRANSACCION').val() == '' ) jQuery('#TRANSACCION').val(1); if ( jQuery('#LISTADO').val() == '' ) jQuery('#LISTADO').val(2); if ( jQuery('#CONSULTA').val() == '' ) jQuery('#CONSULTA').val(2); if ( jQuery('#REPORTE').val() == '' ) jQuery('#REPORTE').val(1); if ( jQuery('#EDITABLE').val() == '' && jQuery('#TIPO_LLAVE').val() == '' ) jQuery('#EDITABLE').val(1); else if( jQuery('#EDITABLE').val() == '' ) jQuery('#EDITABLE').val(2); if ( jQuery('#VISIBLE').val() == '' && jQuery('#TIPO_LLAVE').val() == '' ) jQuery('#VISIBLE').val(1); else if( jQuery('#VISIBLE').val() == '' ) jQuery('#VISIBLE').val(2); if ( jQuery('#BUSQUEDA').val() == '' ) jQuery('#BUSQUEDA').val(2); if ( jQuery('#SISTEMA').val() == '' ) jQuery('#SISTEMA').val(2); jQuery('#REPORTE').removeAttr('disabled'); jQuery('#BUSQUEDA').removeAttr('disabled'); switch( valor ){ case '15': //Captura case '16': //Firma jQuery('#REPORTE').val(2); jQuery('#REPORTE').attr('disabled', 'disabled'); jQuery('#BUSQUEDA').val(2); jQuery('#BUSQUEDA').attr('disabled', 'disabled'); case '1': //Texto if ( jQuery('#LONGITUD').val() == '' ) jQuery('#LONGITUD').val(30); case '2': //Texto Largo if ( jQuery('#LONGITUD').val() == '' ) jQuery('#LONGITUD').val(4000); case '11': //Correo if ( jQuery('#LONGITUD').val() == '' ) jQuery('#LONGITUD').val(100); case '12': //Archivo case '13': //Password //Limpia los campos jQuery('#LIST_NUMERO').val(''); jQuery('#DECIMALES').val(0); jQuery('#CONDICION_LISTA').val(''); jQuery('#VALOR_DEFECTO').val(''); jQuery('#SEGURIDAD').val(''); jQuery('#FORMULA').val(''); jQuery('#TIPO_LLAVE').val(''); jQuery('#OBJE_REFERENCIA_DESC').val(''); jQuery('#OBJE_REFERENCIA').val(''); jQuery('#CAMP_DEPENDIENTE_DESC').val(''); jQuery('#CAMP_DEPENDIENTE').val(''); jQuery('#OBLIG_DEPENDIENTE').val(''); //Deshabilita los campos jQuery('#LIST_NUMERO').attr('disabled', 'disabled'); jQuery('#DECIMALES').attr('disabled', 'disabled'); jQuery('#CONDICION_LISTA').attr('disabled', 'disabled'); jQuery('#VALOR_DEFECTO').attr('disabled', 'disabled'); jQuery('#SEGURIDAD').attr('disabled', 'disabled'); jQuery('#TIPO_LLAVE').attr('disabled', 'disabled'); jQuery('#OBLIG_DEPENDIENTE').attr('disabled', 'disabled'); break; case '3': //Lista Valores case '14': //Lista Autocompletar jQuery('#DECIMALES').val(0); jQuery('#DECIMALES').attr('disabled', 'disabled'); jQuery('#TIPO_LLAVE').val(''); jQuery('#TIPO_LLAVE').attr('disabled', 'disabled'); if ( jQuery('#LONGITUD').val() == '' ) jQuery('#LONGITUD').val(10); if ( jQuery('#OBJE_REFERENCIA_DESC').val() != '' ){ jQuery('#LIST_NUMERO').val(''); jQuery('#LIST_NUMERO').attr('disabled', 'disabled'); } if ( jQuery('#OBJE_REFERENCIA_DESC').val() == '' && jQuery('#LIST_NUMERO').val() == '' ){ jQuery('#CONDICION_LISTA').val(''); jQuery('#CONDICION_LISTA').attr('disabled', 'disabled'); jQuery('#OBLIG_DEPENDIENTE').val(''); jQuery('#OBLIG_DEPENDIENTE').attr('disabled', 'disabled'); } if ( jQuery('#OBJE_REFERENCIA').val() != 9 && jQuery('#OBJE_REFERENCIA').val() != 10 ){ jQuery('#SEGURIDAD').val(''); jQuery('#SEGURIDAD').attr('disabled', 'disabled'); } //Solo me permite valor por defecto como usuario y cuenta unica if ( jQuery('#OBJE_REFERENCIA').val() != 5004 && jQuery('#OBJE_REFERENCIA').val() != 9 && jQuery('#OBJE_REFERENCIA').val() != 10 ){ jQuery('#VALOR_DEFECTO').val(''); jQuery('#VALOR_DEFECTO').attr('disabled', 'disabled'); }else{ jQuery('#VALOR_DEFECTO option').remove(); jQuery('#VALOR_DEFECTO').append(''); if ( jQuery('#OBJE_REFERENCIA').val() == 9 || jQuery('#OBJE_REFERENCIA').val() == 10 ){ jQuery('#VALOR_DEFECTO').append(''); }else{ jQuery('#VALOR_DEFECTO').append(''); } } break; case '4': //Fecha Corta if ( jQuery('#LONGITUD').val() == '' ) jQuery('#LONGITUD').val(0); case '5': //Fecha Larga if ( jQuery('#LONGITUD').val() == '' ) jQuery('#LONGITUD').val(0); //Limpia los campos jQuery('#LIST_NUMERO').val(''); jQuery('#DECIMALES').val(0); jQuery('#CONDICION_LISTA').val(''); jQuery('#SEGURIDAD').val(''); jQuery('#TIPO_LLAVE').val(''); jQuery('#OBJE_REFERENCIA_DESC').val(''); jQuery('#OBJE_REFERENCIA').val(''); jQuery('#CAMP_DEPENDIENTE_DESC').val(''); jQuery('#CAMP_DEPENDIENTE').val(''); jQuery('#OBLIG_DEPENDIENTE').val(''); //Deshabilita los campos jQuery('#LIST_NUMERO').attr('disabled', 'disabled'); jQuery('#DECIMALES').attr('disabled', 'disabled'); jQuery('#CONDICION_LISTA').attr('disabled', 'disabled'); jQuery('#SEGURIDAD').attr('disabled', 'disabled'); jQuery('#TIPO_LLAVE').attr('disabled', 'disabled'); jQuery('#OBLIG_DEPENDIENTE').attr('disabled', 'disabled'); //Solo me permite valor por defecto como fecha jQuery('#VALOR_DEFECTO option').remove(); jQuery('#VALOR_DEFECTO').append(''); jQuery('#VALOR_DEFECTO').append(''); break; case '6': //Numero if ( jQuery('#LONGITUD').val() == '' ) jQuery('#LONGITUD').val(10); jQuery('#DECIMALES').val(0); if ( jQuery('#OBJE_REFERENCIA_DESC').val() != '' ){ jQuery('#LIST_NUMERO').val(''); jQuery('#LIST_NUMERO').attr('disabled', 'disabled'); jQuery('#DECIMALES').val(0); jQuery('#DECIMALES').attr('disabled', 'disabled'); jQuery('#FORMULA').val(''); jQuery('#FORMULA').attr('disabled', 'disabled'); } if ( jQuery('#OBJE_REFERENCIA_DESC').val() == '' && jQuery('#LIST_NUMERO').val() == '' ){ jQuery('#CONDICION_LISTA').val(''); jQuery('#CONDICION_LISTA').attr('disabled', 'disabled'); jQuery('#OBLIG_DEPENDIENTE').val(''); jQuery('#OBLIG_DEPENDIENTE').attr('disabled', 'disabled'); } if ( jQuery('#OBJE_REFERENCIA').val() != 9 && jQuery('#OBJE_REFERENCIA').val() != 10 ){ jQuery('#SEGURIDAD').val(''); jQuery('#SEGURIDAD').attr('disabled', 'disabled'); } //Solo me permite valor por defecto como usuario y cuenta unica if ( jQuery('#OBJE_REFERENCIA').val() != 5004 && jQuery('#OBJE_REFERENCIA').val() != 9 && jQuery('#OBJE_REFERENCIA').val() != 10 ){ jQuery('#VALOR_DEFECTO').val(''); jQuery('#VALOR_DEFECTO').attr('disabled', 'disabled'); }else{ jQuery('#VALOR_DEFECTO option').remove(); jQuery('#VALOR_DEFECTO').append(''); if ( jQuery('#OBJE_REFERENCIA').val() == 9 || jQuery('#OBJE_REFERENCIA').val() == 10 ){ jQuery('#VALOR_DEFECTO').append(''); }else{ jQuery('#VALOR_DEFECTO').append(''); } } break; case '7': //Decimal jQuery('#TIPO_LLAVE').val(''); jQuery('#TIPO_LLAVE').attr('disabled', 'disabled'); jQuery('#SEGURIDAD').val(''); jQuery('#SEGURIDAD').attr('disabled', 'disabled'); if ( jQuery('#LONGITUD').val() == '' ) jQuery('#LONGITUD').val(10); if ( jQuery('#DECIMALES').val() == '' ) jQuery('#DECIMALES').val(2); case '8': //Hora jQuery('#TIPO_LLAVE').val(''); jQuery('#TIPO_LLAVE').attr('disabled', 'disabled'); jQuery('#SEGURIDAD').val(''); jQuery('#SEGURIDAD').attr('disabled', 'disabled'); if ( jQuery('#LONGITUD').val() == '' ) jQuery('#LONGITUD').val(10); if ( jQuery('#DECIMALES').val() == '' ) jQuery('#DECIMALES').val(0); case '9': //Moneda jQuery('#TIPO_LLAVE').val(''); jQuery('#TIPO_LLAVE').attr('disabled', 'disabled'); jQuery('#SEGURIDAD').val(''); jQuery('#SEGURIDAD').attr('disabled', 'disabled'); if ( jQuery('#LONGITUD').val() == '' ) jQuery('#LONGITUD').val(10); if ( jQuery('#DECIMALES').val() == '' ) jQuery('#DECIMALES').val(2); //Limpia los campos jQuery('#LIST_NUMERO').val(''); jQuery('#CONDICION_LISTA').val(''); jQuery('#VALOR_DEFECTO').val(''); jQuery('#SEGURIDAD').val(''); jQuery('#TIPO_LLAVE').val(''); jQuery('#OBJE_REFERENCIA_DESC').val(''); jQuery('#OBJE_REFERENCIA').val(''); jQuery('#CAMP_DEPENDIENTE_DESC').val(''); jQuery('#CAMP_DEPENDIENTE').val(''); jQuery('#OBLIG_DEPENDIENTE').val(''); //Deshabilita los campos jQuery('#LIST_NUMERO').attr('disabled', 'disabled'); jQuery('#CONDICION_LISTA').attr('disabled', 'disabled'); jQuery('#VALOR_DEFECTO').attr('disabled', 'disabled'); jQuery('#SEGURIDAD').attr('disabled', 'disabled'); jQuery('#TIPO_LLAVE').attr('disabled', 'disabled'); jQuery('#OBLIG_DEPENDIENTE').attr('disabled', 'disabled'); break; default : jQuery('#VALOR_DEFECTO option').remove(); jQuery('#VALOR_DEFECTO').append(''); jQuery('#VALOR_DEFECTO').append(''); jQuery('#VALOR_DEFECTO').append(''); jQuery('#VALOR_DEFECTO').append(''); jQuery('#OBJE_REFERENCIA_DESC').val(''); jQuery('#OBJE_REFERENCIA').val(''); jQuery('#CAMP_DEPENDIENTE_DESC').val(''); jQuery('#CAMP_DEPENDIENTE').val(''); jQuery('#OBLIG_DEPENDIENTE').val(''); break; } formValObj.__initiallyParseAForm(1); }else if ( tipo == '2' ){ switch( valor ){ case '1': //Texto case '2': //Texto Largo case '11': //Correo case '12': //Archivo case '13': //Password case '15': //Captura case '16': //Firma if ( campo != "GRUP_NUMERO" && campo != "CAMP_REFERENCIA" && campo != "FORMULA" && 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 '14': //Lista Autocompletar case '6': //Numero if ( campo == "OBJE_REFERENCIA" ){ if ( jQuery('#OBJE_REFERENCIA_DESC').val() == '' ){ jQuery('#LIST_NUMERO').removeAttr('disabled'); if ( jQuery('#LIST_NUMERO').val() == '' ){ jQuery('#CONDICION_LISTA').val(''); jQuery('#CONDICION_LISTA').attr('disabled', 'disabled'); jQuery('#OBLIG_DEPENDIENTE').val(''); jQuery('#OBLIG_DEPENDIENTE').attr('disabled', 'disabled'); } else { return false; } }else{ jQuery('#LIST_NUMERO').val(''); jQuery('#LIST_NUMERO').attr('disabled', 'disabled'); jQuery('#CONDICION_LISTA').removeAttr('disabled'); jQuery('#OBLIG_DEPENDIENTE').removeAttr('disabled'); jQuery('#FORMULA').val(''); jQuery('#FORMULA').attr('disabled', 'disabled'); } if ( jQuery('#OBJE_REFERENCIA').val() == 9 || jQuery('#OBJE_REFERENCIA').val() == 10 ){ jQuery('#SEGURIDAD').removeAttr('disabled'); }else{ jQuery('#SEGURIDAD').val(''); jQuery('#SEGURIDAD').attr('disabled', 'disabled'); } //Solo me permite valor por defecto como usuario y cuenta unica if ( jQuery('#OBJE_REFERENCIA').val() != 5004 && jQuery('#OBJE_REFERENCIA').val() != 9 && jQuery('#OBJE_REFERENCIA').val() != 10 ){ jQuery('#VALOR_DEFECTO').val(''); jQuery('#VALOR_DEFECTO').attr('disabled', 'disabled'); }else{ jQuery('#VALOR_DEFECTO').removeAttr('disabled'); jQuery('#VALOR_DEFECTO option').remove(); jQuery('#VALOR_DEFECTO').append(''); if ( jQuery('#OBJE_REFERENCIA').val() == 9 || jQuery('#OBJE_REFERENCIA').val() == 10 ){ jQuery('#VALOR_DEFECTO').append(''); }else{ jQuery('#VALOR_DEFECTO').append(''); } } } else { if ( campo == ''){ if ( jQuery('#LIST_NUMERO').val() == '' ){ if ( jQuery('#OBJE_REFERENCIA_DESC').val() == '' ){ jQuery('#CONDICION_LISTA').val(''); jQuery('#CONDICION_LISTA').attr('disabled', 'disabled'); jQuery('#OBLIG_DEPENDIENTE').val(''); jQuery('#OBLIG_DEPENDIENTE').attr('disabled', 'disabled'); } }else{ jQuery('#CONDICION_LISTA').removeAttr('disabled'); jQuery('#OBLIG_DEPENDIENTE').removeAttr('disabled'); jQuery('#OBJE_REFERENCIA').val(''); jQuery('#OBJE_REFERENCIA_DESC').val(''); } if ( jQuery('#OBJE_REFERENCIA_DESC').val() == '' ){ jQuery('#SEGURIDAD').attr('disabled', 'disabled'); jQuery('#SEGURIDAD').val(''); jQuery('#VALOR_DEFECTO').attr('disabled', 'disabled'); jQuery('#VALOR_DEFECTO').val(''); } } } if ( campo == "CAMP_DEPENDIENTE" && jQuery('#OBJE_REFERENCIA_DESC').val() == '' && jQuery('#LIST_NUMERO').val() == '' ) return false; if ( campo == "FORMULA" && jQuery('#OBJE_REFERENCIA_DESC').val() != '') 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; }else{ switch( valor ){ case '1': //Texto case '2': //Texto Largo case '11': //Correo case '12': //Archivo case '13': //Password case '15': //Captura case '16': //Firma 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 '14': //Lista Autocompletar case '6': //Numero if ( campo == "OBJE_REFERENCIA" ){ if ( jQuery('#OBJE_REFERENCIA_DESC', window.opener.document).val() == '' ){ jQuery('LIST_NUMERO', window.opener.document).removeAttr('disabled'); if ( jQuery('#LIST_NUMERO', window.opener.document).val() == '' ){ jQuery('#CONDICION_LISTA', window.opener.document).val(''); jQuery('#CONDICION_LISTA', window.opener.document).attr('disabled', 'disabled'); jQuery('#OBLIG_DEPENDIENTE', window.opener.document).val(''); jQuery('#OBLIG_DEPENDIENTE', window.opener.document).attr('disabled', 'disabled'); } else { return false; } }else{ jQuery('#LIST_NUMERO', window.opener.document).val(''); jQuery('#LIST_NUMERO', window.opener.document).attr('disabled', 'disabled'); jQuery('#CONDICION_LISTA', window.opener.document).removeAttr('disabled'); jQuery('#OBLIG_DEPENDIENTE', window.opener.document).removeAttr('disabled'); jQuery('#FORMULA', window.opener.document).val(''); jQuery('#FORMULA', window.opener.document).attr('disabled', 'disabled'); } if ( jQuery('#OBJE_REFERENCIA', window.opener.document).val() == 9 || jQuery('#OBJE_REFERENCIA', window.opener.document).val() == 10 ){ jQuery('#SEGURIDAD', window.opener.document).removeAttr('disabled'); }else{ jQuery('#SEGURIDAD', window.opener.document).val(''); jQuery('#SEGURIDAD', window.opener.document).attr('disabled', 'disabled'); } //Solo me permite valor por defecto como usuario y cuenta unica if ( jQuery('#OBJE_REFERENCIA', window.opener.document).val() != 5004 && jQuery('#OBJE_REFERENCIA', window.opener.document).val() != 9 && jQuery('#OBJE_REFERENCIA', window.opener.document).val() != 10 ){ jQuery('#VALOR_DEFECTO', window.opener.document).val(''); jQuery('#VALOR_DEFECTO', window.opener.document).attr('disabled', 'disabled'); }else{ jQuery('#VALOR_DEFECTO', window.opener.document).removeAttr('disabled'); jQuery('#VALOR_DEFECTO option', window.opener.document).remove(); jQuery('#VALOR_DEFECTO', window.opener.document).append(''); if ( jQuery('#OBJE_REFERENCIA', window.opener.document).val() == 9 || jQuery('#OBJE_REFERENCIA', window.opener.document).val() == 10 ){ jQuery('#VALOR_DEFECTO', window.opener.document).append(''); }else{ jQuery('#VALOR_DEFECTO', window.opener.document).append(''); } } } else { if ( campo == ''){ if ( jQuery('#LIST_NUMERO', window.opener.document).val() == '' ){ if ( jQuery('#OBJE_REFERENCIA_DESC', window.opener.document).val() == '' ){ jQuery('#CONDICION_LISTA', window.opener.document).val(''); jQuery('#CONDICION_LISTA', window.opener.document).attr('disabled', 'disabled'); jQuery('#OBLIG_DEPENDIENTE', window.opener.document).val(''); jQuery('#OBLIG_DEPENDIENTE', window.opener.document).attr('disabled', 'disabled'); } }else{ jQuery('#CONDICION_LISTA', window.opener.document).removeAttr('disabled'); jQuery('#OBLIG_DEPENDIENTE', window.opener.document).removeAttr('disabled'); jQuery('#OBJE_REFERENCIA', window.opener.document).val(''); jQuery('#OBJE_REFERENCIA_DESC', window.opener.document).val(''); } if ( jQuery('#OBJE_REFERENCIA_DESC', window.opener.document).val() == '' ){ jQuery('#SEGURIDAD', window.opener.document).attr('disabled', 'disabled'); jQuery('#SEGURIDAD', window.opener.document).val(''); jQuery('#VALOR_DEFECTO', window.opener.document).attr('disabled', 'disabled'); jQuery('#VALOR_DEFECTO', window.opener.document).val(''); } } } if ( campo == "CAMP_DEPENDIENTE" && jQuery('#OBJE_REFERENCIA_DESC', window.opener.document).val() == '' && jQuery('#LIST_NUMERO', window.opener.document).val() == '' ) return false; if ( campo == "FORMULA" && jQuery('#OBJE_REFERENCIA_DESC', window.opener.document).val() != '') 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; } window.opener.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_' + $("#obje_tab_actual").val(); var objeto_ante = 'OBJ_' + $("#obje_tab_actual").val(); var lista_actu = 'LIST_' + obj_click; var objeto_actu = 'OBJ_' + obj_click; $("#"+lista_ante).removeClass("current"); $("#"+lista_ante).addClass("vacio"); $("#"+lista_actu).removeClass("vacio"); $("#"+lista_actu).addClass("current"); $("#"+objeto_ante).hide(); $("#"+objeto_actu).show(); $("#obje_tab_actual").val(obj_click); $("#configurar_detalle").attr('href','phrame.php?action=detalle&id_objeto=1&campo_llave=OBJE_NUMERO&valor_llave='+obj_click+'&operacion=Detalle&obje_tab_actual='+obj_click); var cadTable = $("#"+objeto_actu).find("div").eq(1).html(); $("#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(){ //console.log(messageObj); //messageObj.close(); if( typeof messageObj != 'undefined' ){ messageObj.close(); } else{ console.log($(".modalDialog_transparentDivs")); $(".modalDialog_transparentDivs").remove(); } } // 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 cade = jQuery("#formOperacion").serialize(); var paramLista = ""; var ex = ""; var cadena = cade.replace(/%0D%0A/gi, ""); var cadena = cadena.replace(/'/gi, ""); 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=""; } function validar_vacio(mixed_var) { // http://jsphp.co/jsphp/fn/view/empty let key; if (mixed_var === '' || mixed_var === 0 || mixed_var === '0' || mixed_var === null || mixed_var === false || typeof mixed_var === 'undefined' || mixed_var === 'null' || mixed_var === 'null') { return true; } if (typeof mixed_var == 'object') { for (key in mixed_var) { return false; } return true; } return false; } // Hace el llamado al formulario para mostrar un mapa function mostrar_mapa(obje_numero){ let inputs = []; inputs = $('#filterDetail table input'); selects = $('#filterDetail table select'); camposFiltro = selects; for (let i = 0; i <= inputs.length; i++ ){ if(!this.validar_vacio(inputs[i])){ if(inputs[i].type != 'button'){ camposFiltro.push(inputs[i]); } } } validador = false; parametros = "{"; for (let i = 0; i < camposFiltro.length; i++ ){ if(!this.validar_vacio(camposFiltro[i].value)){ //parametros += '"'+camposFiltro[i].id.replace("F"+obje_numero+"_","")+'" : "'+camposFiltro[i].value+'",'; parametros += '"' + camposFiltro[i].id + '" : "' + camposFiltro[i].value + '",'; validador = true; } } if (parametros.charAt(parametros.length - 1) == ","){ parametros = parametros.substr(0, parametros.length - 1 ); } parametros += "}"; if(!validador){ parametros = null; } if ( movilidad == '1' ){ url_modal = encodeURIComponent("phrame.php?action=mostrarmap&id_objeto="+obje_numero); window.location = "phrame.php?action=mostrarmap&id_objeto="+obje_numero+"&url_modal="+url_modal+"&filtros="+parametros; }else{ //jQuery(".ajax").modalWindow("phrame.php?action=mostrarmap&id_objeto="+obje_numero); $('#remoteModal').on('shown.bs.modal', function () { $('#remoteModal iframe').attr("src","phrame.php?action=mostrarmap&id_objeto="+obje_numero+"&filtros="+parametros); }); $('#remoteModal').modal({show:true}); } } // 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'){ showConfirm("¿?", function(){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.altKey ) { return false; } else { if ( ( ( (key >= 48 && key <= 57) || (key >= 96 && key <= 105) ) || key <= 31 || key == 46 || ( evento.ctrlKey && ( key == 67 || key == 86 || key == 88 ) ) ) && ( 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; } /* *Funcion que se encarga de remover los valores del multiple grupo y de generar las dependencias de la *familia y los grupos en caso de que se z */ function validarpedido(){ var oportunidad = jQuery('input[name=valor_llave]').val(); var accion = "validar"; /* * Inicialmente se debe de saber el rol del usuario y el estado de la oportunidad */ $.ajax({ type: 'post', url: 'phrame.php', data: "action=ValidarPedidoAction&oportunidad="+oportunidad+"&accion="+accion, success: function(res){ /* *se carga la informaci�n de la dependencia retornada en el select de la cuenta */ if (res.indexOf(":::") != -1 ){ msj = res.split(':::'); showAlert(msj[0], '', '#EDE615', 'fa fa-weixin', function(){ window.parent.location = msj[1]; }); }else{ showAlert(res, '', '#EDE615', 'fa fa-weixin'); } } }); } /* *Funcion que se encarga de consultar el estado de la oportunidad para que se pueda realizar el cambio *de estado. */ function consulteEstado(){ var oportunidad = jQuery('input[name=valor_llave]').val(); var accion = "consultarestado"; $.ajax({ async:true, type: 'post', url: 'phrame.php', data: "action=ValidarPedidoAction&oportunidad="+oportunidad+"&accion="+accion, success: function(res){ if (res.indexOf("----") != -1 ){ showAlert(res, '', '#4B69C3', 'fa fa-file-code-o'); } jQuery('input[name=estadoPedido]').val(res); } }); } /* *Funcion que se encarga de cambiar el estado de la oportunidad teniendo en cuenta lo siguiente * 1) si el cambio de estado es realizado por el ejecutivo este valida el pedido y de acuerdo a esa validacion * se realiza el cambio del estado a cerrado o pendiente. * 2) si el cambio de estado es realizado por el admin del sistema se debe consultar que el estado del pedido * pueda ser cerrado o de lo contrario se necesite llevar a una ventana para que apruebe o anule el pedido. */ function cambiarEstado(rol){ var oportunidad = jQuery('input[name=valor_llave]').val(); var estado = jQuery('#estadoPedido').val(); var accion = "consultarestado"; var respuesta = ""; showConfirm("¿?", function(){ if(estado == 1){ var accion = "validarcambioestado"; $.ajax({ type: 'post', url: 'phrame.php', data: "action=ValidarPedidoAction&oportunidad="+oportunidad+"&accion="+accion, success: function(res){ if (res.indexOf("----") != -1 ){ showAlert(res, '', '#4B69C3', 'fa fa-file-code-o'); } if( res != 1){ showAlert(res, '', '#EDE615', 'fa fa-weixin'); }else{ cambiarPendiente(estado, oportunidad ); } } }); } if( estado == 3 && rol == 1 ){ aprobarPedido(oportunidad); } }); } /* *Funcion que se encarga de cambiar el estado de la oportunidad a pendiente o cerrada dependiendo la validacion */ function cambiarPendiente(estado, oportunidad){ var accion = "cambiarestado"; //var objeto_id = jQuery("#id_objeto").val(); var objeto_id = 5013; var valorllave = ""; $.ajax({ type: 'post', url: 'phrame.php', data: "action=ValidarPedidoAction&oportunidad="+oportunidad+"&accion="+accion+"&valorllave="+valorllave+"&id_objeto="+objeto_id, success: function(res){ if (res.indexOf("----") != -1 ){ showAlert(res, '', '#4B69C3', 'fa fa-file-code-o', function(){ msj = res.split('*****'); if( msj[1] != "" ){ window.parent.location=msj[1]; } }); }else{ msj = res.split('*****'); if( msj[1] != "" ){ window.parent.location=msj[1]; } } } }); } /* *Funcion que se encarga de desplegar la ventana de cambio de estado para el administrador del sistema. */ function aprobarPedido(oportunidad){ //nuevo_registro('5027', '&valor_llave='+oportunidad, 'observacionAction'); //jQuery("#cambiaEstado").modalWindow ("phrame.php?action=observacionAction&operacion=Adicionar&valor_llave='+oportunidad"); $('#remoteModal').on('shown.bs.modal', function () { $('#remoteModal iframe').attr("src","phrame.php?action=observacionAction&operacion=Adicionar&valor_llave='+oportunidad"); }); $('#remoteModal').modal({show:true}); } /* *Funcion que se encarga de volver no editables los campos calculados del detalle del pedido */ function bloquearCamposPedido(){ $('#UNIDAD_EMPAQUE').attr('readonly', true); $('#CANTIDAD').attr('readonly', true); $('#VALOR').attr('readonly', true); $('#VALOR_DESCTO_UNITARIO').attr('readonly', true); $('#VALOR_NETO').attr('readonly', true); $('#PORCENTAJE_DESCTO').attr('readonly', true); $('#VALOR_DESCTO').attr('readonly', true); } /* *Funcion que cambia un texto segun el tipo especificado como parametro */ function cambiarEntradaDeTexto( campo, evento, tipo ){ var charCode = (evento.which) ? evento.which : evento.keyCode; if ( (charCode >= 97 && charCode <= 122) || (charCode >= 65 && charCode <= 90) ){ // store current positions in variables var start = campo.selectionStart, end = campo.selectionEnd; campo.value = campo.value.trim(); if( tipo == 'MAYUS' || tipo == 'NOESPMAY'){ if ( tipo == 'NOESPMAY' ){ campo.value = campo.value.replace(" ","_"); } $(campo).css('text-transform','uppercase'); campo.value = campo.value.toUpperCase(); // restore from variables... campo.setSelectionRange(start, end); }else if( tipo == 'MINUS' || tipo == 'NOESPMIN' ){ if ( tipo == 'NOESPMIN' ){ campo.value = campo.value.replace(" ","_"); } $(campo).css('text-transform','lowercase'); campo.value = campo.value.toLowerCase(); // restore from variables... campo.setSelectionRange(start, end); }else if( tipo == 'NOESP' ){ campo.value = campo.value.replace(" ","_"); }else if( tipo == 'NOM' ){ campo.value = campo.value.toLowerCase(); var sp = campo.value.split(' '); var f ,r; var letra = new Array(); for (i = 0 ; i < sp.length ; i ++ ) { f = sp[i].substring(0,1).toUpperCase(); r = sp[i].substring(1); letra[i] = f+r; } nuevoTexto = letra.join(' '); campo.value = nuevoTexto; } }else{ return false; } } /* *Funcion que descarga un archivo */ function descargaArchivo( params ){ $.ajax({ async: true, url: 'phrame.php', data: params, type: 'get', success: function(res){ var cadena = res.split(":::"); if ( cadena[0] == "Err" ) { showAlert(cadena[1], '', '#FF0000', 'fa fa-exclamation-triangle'); }else{ $('#descarga').attr('src','phrame.php?'+params); } }, error: function(XMLHttpRequest, textStatus, errorThrown) { showAlert('textStatuss: ' + textStatus + '\nerrorThrown: ' + errorThrown, '', '#FF0000', 'fa fa-exclamation-triangle'); } }); } /* *Funcion que posiciona la camara */ function iniciarCamara( obj, width, height, dest_width, dest_height, type, videosrc, fps ){ Webcam.set({ width: width, height: height, dest_width: dest_width, dest_height: dest_height, image_format: type, videosrc: videosrc, fps: fps }); Webcam.attach( $(obj).attr('id') ); } /* *Funcion que muestra la vista previa de una captura */ function capturaImagen( obj, dest ){ // take snapshot and get image data Webcam.snap( function(data_uri) { // display results in page $('#'+obj).attr('src', data_uri); var raw_image_data = data_uri.replace(/^data\:image\/\w+\;base64\,/, ''); $('#'+dest).val(raw_image_data); } ); } /* *Funcion que obtiene las camaras */ function gotSources(sourceInfos, camara) { audioSelect = document.querySelector('select#'+$('#nombre_campo').val()+'_MIC'); videoSelect = document.querySelector('select#'+$('#nombre_campo').val()+'_CAM'); for (var i = 0; i !== sourceInfos.length; ++i) { var sourceInfo = sourceInfos[i]; var option = document.createElement('option'); option.value = sourceInfo.id; //if (sourceInfo.kind === 'audio') { // option.text = sourceInfo.label || 'microphone ' + // (audioSelect.length + 1); // audioSelect.appendChild(option); // } else if (sourceInfo.kind === 'video') { option.text = sourceInfo.label || 'camera ' + (videoSelect.length); videoSelect.appendChild(option); } else { console.log('Some other kind of source: ', sourceInfo); } } } /* * Funcion que abre una ventana emergente de un reporte */ function ventana_emergente(obje_numero, id_reporte){ $('.close').trigger( 'click' ); //obje_numero = $('input:hidden[name=id_objeto]').val(); //id_reporte = $('#LISTA_REPORTES').val(); 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'); } /* *Funcion que obtiene la pregunta siguiente del guion */ function preguntaSiguienteGuion(pregunta){ // Si no contiene campos tipo archivo, captura la información de cada campo var cadena = $("#formOperacion").serialize(); var cadena2 = $("#formOperacion").serializeDisabled(); cadena = cadena.replace(/\%2B/g,"[[mas]]"); cadena = cadena.replace(/\%26/g,"[[amp]]"); cadena2 = cadena2.replace(/\%2B/g,"[[mas]]"); cadena2 = cadena2.replace(/\%26/g,"[[amp]]"); cadena = decodeURIComponent(cadena+"&"+cadena2); var resultado; var valor; var asign; var html_tmp; var pregunta_siguente; if( pregunta == 2 ){ pregunta_siguente = "&preg_final=1"; } else{ pregunta_siguente = "&preg_siguiente=1"; } $.ajax({ type: 'post', url: 'phrame.php', data: "action=metodo_ajax&metodo=clienteAjax&clase=Guiones&metodo_ejec=crearGuionEncuesta&"+cadena+pregunta_siguente, success: function(res){ resultado = res; resultado = res.replace(/\t/g, ''); if ( resultado != "" && pregunta != 2 ){ valor = resultado.split(":::"); for ( i=0; i < valor.length; i++ ){ if ( valor[i] != "" ){ asign = valor[i].split("|||"); $("#"+asign[0]).val(asign[1]); } } html_tmp = $("#bloque_preguntas_tmp").val(); html_coment = $("#encuesta_comentarios").val(); html_archiv = $("#encuesta_archivos").val(); if( html_tmp != "" ){ $("#bloque_preguntas").html(html_tmp); $("#encuesta_comentarios").html(html_coment); if( html_archiv != '' ){ //$("#iframe_archivo_encuesta") $("#iframe_archivo_encuesta").attr('src', html_archiv); $("#div_archivo_encuesta").show(); }else{ $("#div_archivo_encuesta").hide(); } addClassStyle(); } if( $("#cont_guiones").val() == 0 ){ if( $("#guion_preguntas").val() == "" ){ $("#bloque_preguntas").html(''); } $("#pregSig").hide(); $("#pregGua").show(); } $("#pregAnt").show(); formValObj.__initiallyParseAForm(1); //$('#formOperacion').delay(10000).fadeIn(1000); }else{ $('#cboxClose', window.parent.document).trigger('click'); window.parent.loading(); msj = res.split('*****'); if( msj[1] != "" ){ window.parent.location=msj[1]; } } } }); } /* *Funcion que muestra la alerta con el campo invalido */ function alertaCampoInvalido(invalidFieldId){ var msgCampoInvalido = ''; var invalidFieldLabel = $("label[for='"+invalidFieldId+"']").text(); msgCampoInvalido = msgCampoInvalido.replace("#NOMBRE#", invalidFieldLabel); showAlert(msgCampoInvalido, 'Formulario Incompleto', '#FF0000', 'fa fa-exclamation-triangle', function(){ $("#"+invalidFieldId).focus(); $("#"+invalidFieldId).select(); }); } /* * Validación de numeros de tarejtas de crédito */ function validaTarjeta(){ if ( $('#NUMERO_TARJETA').val() != '' ){ //Validacion de Luhn var valida = function(a,b,c,d,e) { for(d = +a[b = a.length-1], e=0; b--;) c = +a[b], d += ++e % 2 ? 2 * c % 10 + (c > 4) : c; return !(d%10) }; $('#NUMERO_TARJETA').addClass('personalFormValidator'); $.validator.addMethod('cValidTarj', function(value, element){ if ( valida($('#NUMERO_TARJETA').val()) ){ if ( $( 'input:checked' ).val() == 'AMEX' ){ return (/^(3[47]\d{13})$/.test(value)) }else if( $( 'input:checked' ).val() == 'VISA' ){ return (/^(4)(\d{12}|\d{15})$|^(606374\d{10}$)/.test(value)) }else if( $( 'input:checked' ).val() == 'MASTERCARD' ){ return (/^(5[1-5]\d{14}$)|^(2(?:2(?:2[1-9]|[3-9]\d)|[3-6]\d\d|7(?:[01]\d|20))\d{12}$)/.test(value)) }else if( $( 'input:checked' ).val() == 'DINERS' ){ return (/(^[35](?:0[0-5]|[68][0-9])[0-9]{11}$)|(^30[0-5]{11}$)|(^3095(\d{10})$)|(^36{12}$)|(^3[89](\d{12})$)/.test(value)); }else{ return true; } }else{ return false; } }, 'Número de tarjeta no valida.'); $.validator.addClassRules( 'personalFormValidator', {cValidTarj: true} ); } return true; } function validarFechaVencim(){ $('#FECHA_VENC_MES').addClass('personalFormValidator'); $.validator.addMethod('cValidVenci', function(value, element){ var fecha = new Date(); var anno = fecha.getFullYear(); var mes = fecha.getMonth()+1; var result; result = ''; if ( $('#FECHA_VENC_ANNO').val() != 'AAAA' && $('#FECHA_VENC_ANNO').val() == anno ){ if ( $('#FECHA_VENC_MES').val() != 'MM' && $('#FECHA_VENC_MES').val() < mes ){ result = 'Error'; } } if ( $('#FECHA_VENC_MES').val() != 'MM' && $('#FECHA_VENC_ANNO').val() != 'AAAA' ){ if ( result == 'Error' ){ return false; }else{ return true; } }else{ return true; } }, 'Mes no valido para fecha de vencimiento'); $.validator.addClassRules( 'personalFormValidator', {cValidVenci: true} ); } /* * */ function validar_actualiza_campos(nombreTabla){ obje_numero = $('input:hidden[name=id_objeto]').val(); $('#FIL'+obje_numero+'_ACTUALIZA_CAMPOS').val(''); $.each( $('#'+nombreTabla + ' span'), function( index, value ) { nombre = value.id.replace('_DESC_DIVEXT',''); nombre = nombre.replace('_DIVEXT',''); if( $('#'+nombre).val() != '' ){ $('#FIL'+obje_numero+'_ACTUALIZA_CAMPOS').val(1); //alert( nombre+' - '+value.id + ' : ' +$('#'+nombre).val()); return false; } }); } function valida_formulario() { var operacion = $("#operacion").val(); var camposInput = $("#formOperacion :input:visible"); if (operacion == 'Modificar' ){ $.each( camposInput, function( index, value ) { var evento = value.onfocus + ''; if ( !(evento.indexOf("clienteAjax") != -1 || evento.indexOf("window.opener.document") != -1 ) ){ $('#'+value.id).trigger('onfocus'); } }); } formValObj.__initiallyParseAForm(1); } function obligaAutocompletar(name, oblig){ if ( $('#'+name+'_DESC').val() == '' ){ $('#'+name).val(''); } if ( $('#'+name).val() == '' && oblig == '1' ){ $('#'+name+'_DESC').val(''); $('#'+name+'_DESC').attr('required', 'required'); }else{ $('#'+name+'_DESC').removeAttr('required'); } formValObj.__initiallyParseAForm(1); } function establecerPredeterminada( nombre, RUTA_API ){ let impresora = new Impresora(RUTA_API); Impresora.setImpresora( nombre ).then(( datos_impre )=>{ console.log( datos_impre ); }).catch((Err)=>{ showAlert( cadena_alerta , 'La impresora no se pudo establecer correctamente, comunicarse con el equipo de Soporte Infodec', '#EDE615', 'fa fa-exclamation-triangle'); }); }