//URL var LINK_COTIZACION = 'https://www.facturacion.cl/desis/documento/?online='; var LINK_CEDULA = 'https://www.facturacion.cl/compralinea/cedulaimg.php?hash='; var rutRepresentantel = ''; var nombreRepresentantel = ''; var emailRepresentantel = ''; if (document.getElementById("cedulaidentidad") != null) { var canvas = document.getElementById("cedulaidentidad"); var ctx = canvas.getContext("2d"); } var nombreArchivo = ""; var extensionArchivo = ""; var arrayCedula = new Array(); var contador = 0; var contadorheight = 0; codigoIngresado = false; function replaceArray(e){var t=[" Y "," E "," De "," Del "," En "],n=[" y "," e "," de "," del "," en "];for(var r=0;r= 48 && key <= 57) || key == 8 ; } function codigopromocional(coddescuento){ debugger; if(coddescuento == 'RRSS03' || coddescuento == 'WSP03'){ var rut = document.getElementById('rut').value; var razonsocial = document.getElementById('razonsocial').value; var giro = document.getElementById('giro').value; var direccion = document.getElementById('direccion').value; var region = document.getElementById('region').value; var comuna = document.getElementById('comuna').value; var contactocl = document.getElementById('contactocl').value; var correocl = document.getElementById('correocl').value; var telefonocl = '+'+ititelefonocl.getSelectedCountryData().dialCode+document.getElementById('telefonocl').value ; if((rut != '' && razonsocial != '' && giro != '' && direccion != '' && coddescuento != '' && region != '' && comuna != '' && contactocl != '' && correocl != '' && telefonocl != '') && (coddescuento == 'RRSS03' || coddescuento == 'WSP03')){ document.getElementById('validacodrrss03').value = 1; var width = window.innerWidth > 600 ? 600 : window.innerWidth-10; var height = (width*6/7); height = height > 540 ? 540 : height; height = height < 350 ? 350 : height; if(height > window.innerHeight) { height = window.innerHeight > 600 ? 600 : window.innerHeight-50; width = (width*7/6); } $("#codrrss03").dialog({ autoOpen: true, height: height+(width*6/7)*0.15, width: width, modal: true }); $('.ui-dialog').css('position','fixed'); if(window.innerHeight>=900){ midH = (window.innerHeight - $("#codrrss03").outerHeight())/2 $('.ui-dialog').css('top', midH); $('.ui-dialog').css('z-index', 3000); }else{ midH = (window.innerHeight - $("#codrrss03").outerHeight())/2 $('.ui-dialog').css('top', midH); $('.ui-dialog').css('z-index', 3000); $('.ui-dialog').css('overflow-y', "hidden"); $('.ui-dialog').css('overflow-x', "hidden"); $('.ui-dialog-content').css('overflow-y', "hidden"); $('.ui-dialog-content').css('overflow-x', "hidden"); } $(".ui-dialog-titlebar").hide(); try { document.querySelector("#codrrss03 iframe").contentWindow.cambiarCodigoEnModal(); } catch (ex) {} } } if(coddescuento == 'LINK22' || coddescuento == 'IG2022'){ mostrarAlertaDescuento(coddescuento, compraLineaP1.rutsii); } } function soloLetras(e) { key = e.keyCode || e.which; tecla = String.fromCharCode(key).toLowerCase(); letras = 'abcdefghijklmnopqrstuvwxyz'; if (letras.indexOf(tecla) !== -1) { return true; } especiales = [8, 32, 37, 39, 46, 209, 241, 193, 201, 205, 211, 218, 225, 233, 237, 243, 250]; if (especiales.indexOf(key) !== -1) { return true; } return false; } function limpiarInput_onpaste(elemento, event) { var textoPegado = ''; if (window.clipboardData && window.clipboardData.getData) { textoPegado = window.clipboardData.getData('Text'); } else if (event.clipboardData && event.clipboardData.getData) { textoPegado = event.clipboardData.getData('text/plain'); } var numeros = textoPegado.replace(/[^\d]/g, ''); elemento.value = numeros; if (event.preventDefault) { event.preventDefault(); } else { event.returnValue = false; } } function soloLetrasBlur(that) { var aux = ''; var char; var value = that.value; var letras = 'abcdefghijklmnopqrstuvwxyz'; var especiales = [8, 32, 37, 39, 46, 209, 241, 193, 201, 205, 211, 218, 225, 233, 237, 243, 250]; for (var i = 0, j = value.length; i < j; i++) { char = value[i]; if ((letras.indexOf(char.toLowerCase()) !== -1) || (especiales.indexOf(char.charCodeAt(0)) !== -1)) { aux += char; continue; } } that.value = aux; } function quitarEspacios(elemento){ correoRep = elemento.value; for (var i = 0; i < correoRep.length; i++){ correoRep = correoRep.replace(" ",""); } elemento.value = correoRep; } function confirmarCorreo(correo){ var getBrowserInfo = function() { var ua= navigator.userAgent, tem, M= ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || []; if(/trident/i.test(M[1])){ tem= /\brv[ :]+(\d+)/g.exec(ua) || []; return 'IE '+(tem[1] || ''); } if(M[1]=== 'Chrome'){ tem= ua.match(/\b(OPR|Edge)\/(\d+)/); if(tem!= null) return tem.slice(1).join(' ').replace('OPR', 'Opera'); } M= M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?']; if((tem= ua.match(/version\/(\d+)/i))!= null) M.splice(1, 1, tem[1]); return M.join(' '); }; if(correo.value.length < 1){ this.correoRle_e.style.display = 'none'; return 'sincorreo'; } else { var correoRep = ""; var correoCom = ""; if(getBrowserInfo().substr(0,2) == "IE"){ correoRep = document.getElementById("correoRle").value; correoCom = correo.value; correoCom = correoCom.trim(); }else{ correoRep = this.correoRle.value; correoCom = correo.value; correoRep = correoRep.trim() } correoRep = correoRep.trim(); correoCom = correoCom.trim(); for (var i = 0; i < correoRep.length; i++){ correoRep = correoRep.replace(" ",""); } for (var i = 0; i < correoCom.length; i++){ correoCom = correoCom.replace(" ",""); } document.getElementById("correoRle").value = correoRep; document.getElementById("confircorreoRle").value = correoCom; if(correoCom == correoRep){ document.getElementById("correoRle_e").style.display = 'none'; return true; }else{ this.correoRle_e.style.display = ''; return false; } } } function limpiar(accion) { if(accion == 'R') { var elemento = $("#valida_datarut")[0]; var nodos = elemento.parentElement.childNodes[0].childNodes[1]; nodos.removeAttribute("onclick"); $("#runRle")[0].value = ""; $("#valida_datarut").dialog("close"); } else { var elemento = $("#valida_datanombre")[0]; var nodos = elemento.parentElement.childNodes[0].childNodes[1]; nodos.removeAttribute("onclick"); $("#nomRle")[0].value = ""; try { $("#nombresRle")[0].value = ""; $("#primerApellidoRle")[0].value = ""; $("#segundoApellidoRle")[0].value = ""; } catch (ex){console.log(ex)} $("#valida_datanombre").dialog("close"); } } var compraLineaP2 = { idformulario: null, integrado: null, formOK: null, init: function(){ this.empresa = $("#empresaFI"); this.nombreCont = $("#nombreCont"); this.correoCont = $("#correoCont"); this.NombresRle = $('#nombresRle'); this.primerApellidoRle = $('#primerApellidoRle'); this.segundoApellidoRle = $('#segundoApellidoRle'); this.fechapasoproduccion = $("#calendariopasoproduccion"); //TIPOS DOCUMENTO this.dteDefecto = $("#dte336156"); this.dte52 = $("#dte52"); this.dte34 = $("#dte34"); this.dte39 = $("#dte39"); this.dte46 = $("#dte46"); this.dte110 = $("#dte110"); this.dte43 = $("#dte43"); this.sRango = $("#sRango"); this.rutTribu = $("#rutTribu"); this.rsTribu = $("#rsTribu"); this.acteco = $("#acteco"); this.nomRle = $("#nomRle"); this.runRle = $("#runRle"); this.correoRle = $("#correoRle"); this.confircorreoRle = $('#confircorreoRle'); this.confirmarC = $('#confirmarC'); this.correoRle_e = $('#correoRle_e'); this.telefonoCont = $('#telefonoCont'); this.acepta = $("#acepta"); this.verTC = $("#verTC"); this.aceptaFI = $("#aceptaFI"); this.btnCerrarContrato = $("#verContrato_cerrar"); this.dataEmpresaFI = $("#dataEmpresaFI"); this.cedulatemporal = $("#cedulatemporal"); this.IntContacto = $("#IntContacto"); this.IntCorreo = $("#IntCorreo"); this.IntTelefonoContacto = $('#IntTelefonoContacto'); this.IntNombreERP = $('#IntNombreERP'); this.webcontacto = $("#WebContacto"); this.webcorreo = $("#WebCorreo"); this.webtelefono = $("#WebTelefono"); this.validar = $("#validar"); this.webpay = $("#webpay"); this.modifdatostribu = $("#btnModalDatosTributarios"); this.nroserie = $("#nroserie"); this.NombresRle.keypress(function(e){ tecla = (document.all)? e.keycode : e.which; if(tecla == 8 || tecla == 32){ return true; } patron = /^[a-zñ A-ZÑ]*$/; tecla_final = String.fromCharCode(tecla); return patron.test(tecla_final); }); this.primerApellidoRle.keypress(function(e){ tecla = (document.all)? e.keycode : e.which; if(tecla == 8 || tecla == 32){ return true; } patron = /^[a-zñ A-ZÑ]*$/; tecla_final = String.fromCharCode(tecla); return patron.test(tecla_final); }); this.segundoApellidoRle.keypress(function(e){ tecla = (document.all)? e.keycode : e.which; if(tecla == 8 || tecla == 32){ return true; } patron = /^[a-zñ A-ZÑ]*$/; tecla_final = String.fromCharCode(tecla); return patron.test(tecla_final); }); this.cerrar_valida_datarut = $("#cerrar_valida_datarut"); this.cerrar_valida_datanombre = $("#cerrar_valida_datanombre"); $("#valida_datarut").dialog({ autoOpen: false, modal: true }); $(".ui-dialog-titlebar").hide(); $("#valida_datanombre").dialog({ autoOpen: false, modal: true }); $(".ui-dialog-titlebar").hide(); this.cerrar_valida_datarut.click(function() { this.runRle = ""; $("#runRle")[0].value = ""; $("#nomRle")[0].value = ""; $("#valida_datarut").dialog("close"); }); this.cerrar_valida_datanombre.click(function() { $("#nomRle")[0].value = ""; $("#valida_datanombre").dialog("close"); $("#nombresRle")[0].value = ""; $("#primerApellidoRle")[0].value = ""; $("#segundoApellidoRle")[0].value = ""; }); this.runRle.blur(function(){ if($("#runRle")[0].value == $("#rutTribu")[0].value) { if($("#rutTribu")[0].value != '') { var datarut = ($("#runRle")[0].value).split('-'); datarut = parseInt(datarut[0]); if(datarut > 50000000) { $("#valida_datarut").dialog('open'); titulo = "Importante"; $(".ui-dialog-title").css('text-align', 'left'); $(".ui-dialog-title").css('width', '100%'); $(".ui-dialog-title").css('padding-left', '20px'); $(".ui-dialog-title").html(titulo); $('.ui-dialog .ui-widget-header').css('background', '#178419'); $('.ui-dialog').css('width', '55%'); $('.ui-dialog').css('height', 'auto'); $('.ui-dialog').css('top', '30%'); $('.ui-dialog').css('left', '23%'); $('.ui-dialog').css('text-align', 'center'); $('.ui-dialog .ui-widget-header').css('display', 'flex'); var elemento = $("#valida_datarut")[0]; var nodos = elemento.parentElement.childNodes[0].childNodes[1]; nodos.setAttribute("onclick",'limpiar("R")'); } } } }); this.NombresRle.blur(function(){ compraLineaP2.NombresRle.val(eliminarDiacriticos(compraLineaP2.NombresRle.val())); compraLineaP2.NombresRle.val(compraLineaP2.NombresRle.val().toUpperCase()); compraLineaP2.NombresRle.val(compraLineaP2.NombresRle.val().replace(/\Ñ/g,'N')); compraLineaP2.juntarNomRle(compraLineaP2.NombresRle.val()); }); this.primerApellidoRle.blur(function(){ compraLineaP2.primerApellidoRle.val(eliminarDiacriticos(compraLineaP2.primerApellidoRle.val())); compraLineaP2.primerApellidoRle.val(compraLineaP2.primerApellidoRle.val().toUpperCase()); compraLineaP2.primerApellidoRle.val(compraLineaP2.primerApellidoRle.val().replace(/\Ñ/g,'N')); compraLineaP2.juntarNomRle(compraLineaP2.primerApellidoRle.val()); }); this.segundoApellidoRle.blur(function(){ compraLineaP2.segundoApellidoRle.val(eliminarDiacriticos(compraLineaP2.segundoApellidoRle.val())); compraLineaP2.segundoApellidoRle.val(compraLineaP2.segundoApellidoRle.val().toUpperCase()); compraLineaP2.segundoApellidoRle.val(compraLineaP2.segundoApellidoRle.val().replace(/\Ñ/g,'N')); compraLineaP2.juntarNomRle(compraLineaP2.segundoApellidoRle.val()); }); this.nomRle.blur(function(){ var nomrepl = limpiarcadena($("#nomRle")[0].value); var rstrib = limpiarcadena($("#rsTribu")[0].value); if( nomrepl == rstrib) { if($("#rsTribu")[0].value != '') { var datarut = ($("#runRle")[0].value).split('-'); datarut = parseInt(datarut[0]); if(datarut > 50000000) { $("#valida_datanombre").dialog('open'); titulo = "Importante"; $(".ui-dialog-title").css('text-align', 'left'); $(".ui-dialog-title").css('width', '100%'); $(".ui-dialog-title").css('padding-left', '20px'); $(".ui-dialog-title").html(titulo); $('.ui-dialog .ui-widget-header').css('background', '#178419'); $('.ui-dialog').css('width', '55%'); $('.ui-dialog').css('height', 'auto'); $('.ui-dialog').css('top', '30%'); $('.ui-dialog').css('left', '23%'); $('.ui-dialog').css('text-align', 'center'); $('.ui-dialog .ui-widget-header').css('display', 'flex'); var elemento = $("#valida_datanombre")[0]; var nodos = elemento.parentElement.childNodes[0].childNodes[1]; nodos.setAttribute("onclick",'limpiar("N")'); } } } }); this.mdt_razonsocial = $("#mdt_Tribu"); this.mdt_giro = $("#mdt_giro"); this.mdt_direccion = $("#mdt_direccion"); this.mdt_region = $("#mdt_region"); this.mdt_comuna = $("#mdt_comuna"); this.mdt_rut = $("#mdt_rut"); $("#modalDatosTributarios").dialog({ autoOpen:false, height:359, width:557, modal: true, show:{effect:"fade", duration:800}, hide:{effect:"fade", duration:800} }); this.modifdatostribu.click(function(){ console.log("Abrir Modal"); document.getElementById("mdt_rut").value = ''; document.getElementById("mdt_Tribu").value = ''; document.getElementById("mdt_giro").value = ''; document.getElementById("mdt_direccion").value = ''; document.getElementById("mdt_region").value = ''; document.getElementById("mdt_comuna").value = ''; $("#modalDatosTributarios").dialog("open"); $('.ui-dialog .ui-widget-header').css('display', 'flex'); $(".ui-dialog-title").html('Cambiar datos tributarios'); $('.ui-dialog .ui-widget-header').css('background', '#178419'); var ancho = window.innerWidth; var alto = window.innerHeight; var titlecss = 20; var newtop; var newalto; var newaltomodal = ancho < alto ? "350px" : "310px"; var count = document.getElementsByClassName("inputTribu").length; if((ancho < (alto/2)) || (alto < (ancho/2))){ //Configuracion del modal inicial en vistas moviles document.getElementById("labelrs").style.width = ""; if(ancho < alto){ newaltomodal = "450px"; document.getElementsByClassName("selectTribu")[0].style.width = '100%'; document.getElementsByClassName("selectTribu")[1].style.width = '100%'; } var anchoinput = document.getElementsByClassName("selectTribu")[0].clientWidth - 4; for(var i = 0 ; i < count ; i++){ document.getElementsByClassName("inputTribu")[i].style.width = anchoinput+'px'; } } //VISTA MOVIL if((ancho < 600 && alto < 898) || (ancho < 898 && alto < 600)){ //console.log("es movil"); document.getElementById("labelrs").style.width = ""; titlecss=0; //PAISADA if(alto < 420 && alto < ancho){ newtop = (alto/4)/4/5; newalto = 'auto'; newaltomodal = 270+"px"; }else{ newtop = (alto/4)/4/2.6; newalto = alto > 600 ? 470 : 450; newalto = newalto+"px"; newaltomodal = newalto; } //VISTA IPHONE 4 O INFERIOR if(alto < 321 && (alto < ancho)){ newaltomodal = 200+"px"; } if((ancho < 321 && alto < 481) || (ancho < 481 && alto < 321)){ if(ancho < 321 && alto < 481){ newtop = 2; }else{ newaltomodal = 200+"px"; } } document.getElementsByClassName("selectTribu")[0].style.width = '100%'; document.getElementsByClassName("selectTribu")[1].style.width = '100%'; var anchoinput = document.getElementsByClassName("selectTribu")[0].clientWidth - 3; for(var i = 0 ; i < count ; i++){ document.getElementsByClassName("inputTribu")[i].style.width = anchoinput+'px'; } document.getElementsByClassName("ui-dialog")[2].style.height = newalto; document.getElementsByClassName("ui-dialog")[2].style.top = newtop+"%"; } //Dispositivos grandes y pantallas if((ancho >= 600 && alto > 897) || (ancho > 897 && alto >= 600)){ newaltomodal = "100%"; if(alto > 1000 && ancho < 900){ newaltomodal = "100%"; } } document.getElementById("modalDatosTributarios").style.height = newaltomodal; document.getElementsByClassName("ui-button")[2].onclick = function(){ $(".ui-dialog-title").html(' '); $('.ui-dialog .ui-widget-header').css('background', ''); } compraLineaP2.LoadRegion(); //$("#mdt_comuna").disabled = true; $("#mdt_comuna").html(''); }); compraLineaP2.mdt_region.change(function(){ compraLineaP2.LoadComuna(); compraLineaP2.mdt_comuna.prop('disabled',false); }); $('#mdt_rut').change(function(){ compraLineaP2.LoadRut(compraLineaP2.mdt_rut.val()); }); $("#mdt_btnguardar").click(function(){ compraLineaP2.guardarDatosTrubutarios(); }); $("#loadingScreen").dialog({ autoOpen: false, height: 50, width: 250, modal: true, show: { effect: "fade", duration: 800 }, hide: { effect: "fade", duration: 800 } }); $(".ui-dialog-titlebar").hide(); $('.ui-dialog').css({ 'position': 'fixed', 'top': '5%' }); $("#loadingContrato").dialog({ //create dialog, but keep it closed autoOpen: false, height: 700, width: 900, modal: true }); $(".ui-dialog-titlebar").hide(); /*this.runRle.blur(function(){ compraLineaP2.LoadRutRL(); });*/ this.empresa.keyup(function(){ if(this.value.length > 1){ compraLineaP2.getEmpresa(); } }); this.nroserie.blur(function(){ $("#nroserie")[0].value = $("#nroserie")[0].value.replaceAll('.','').toUpperCase(); compraLineaP2.saveCampo( 'bnJvc2VyaWU=', compraLineaP2.nroserie.val().toUpperCase() ); }); this.empresa.blur(function(){ compraLineaP2.getEmpresa(); compraLineaP2.saveCampo( 'c3lzX25hbWU=', compraLineaP2.empresa.val().toLowerCase().replace(/\s+/g, '') ); compraLineaP2.empresa.val(compraLineaP2.empresa.val().toLowerCase().replace(/\s+/g, '')); }); this.nombreCont.blur(function(){ if(compraLineaP2.nombreCont.val().length > 1){ compraLineaP2.saveCampo( 'Y29udGFjdG9fbm9tYnJl', compraLineaP2.nombreCont.val() ); }else{ alert("Debe indicar el Nombre de Contacto."); return; } }); this.correoCont.blur(function(){ if(compraLineaP2.correoCont.val().length > 1){ compraLineaP2.saveCampo( 'Y29udGFjdG9fZW1haWw=', compraLineaP2.correoCont.val() ); }else{ alert("Debe indicar el Correo de Contacto."); return; } }); this.NombresRle.change(function(){ if(compraLineaP2.NombresRle.val().length>1){ compraLineaP2.NombresRle.val(eliminarDiacriticos(compraLineaP2.NombresRle.val())); compraLineaP2.NombresRle.val(compraLineaP2.NombresRle.val().toUpperCase()); compraLineaP2.NombresRle.val(compraLineaP2.NombresRle.val().replace(/\Ñ/g,'N')); compraLineaP2.NombresRle.val(cleanString(compraLineaP2.NombresRle.val())); compraLineaP2.saveCampo('bm9tYnJlc1JsZQ==',compraLineaP2.NombresRle.val()); }else{ alert("Debe indicar el Nombre del Representante Legal."); return; } }); this.primerApellidoRle.change(function(){ if(compraLineaP2.primerApellidoRle.val().length>1){ compraLineaP2.primerApellidoRle.val(cleanString(compraLineaP2.primerApellidoRle.val())); compraLineaP2.primerApellidoRle.val(eliminarDiacriticos(compraLineaP2.primerApellidoRle.val())); compraLineaP2.primerApellidoRle.val(compraLineaP2.primerApellidoRle.val().toUpperCase()); compraLineaP2.primerApellidoRle.val(compraLineaP2.primerApellidoRle.val().replace(/\Ñ/g,'N')); compraLineaP2.saveCampo('cHJpbWVyYXBlbGxpZG9ybGU=',compraLineaP2.primerApellidoRle.val()); }else{ alert("Debe indicar el Primer Apellido del Representante Legal."); return; } }); this.segundoApellidoRle.change(function(){ if( $('#chkSegApellido').prop('checked') == false && compraLineaP2.segundoApellidoRle.val().length>0){ compraLineaP2.segundoApellidoRle.val(cleanString(compraLineaP2.segundoApellidoRle.val())); compraLineaP2.segundoApellidoRle.val(eliminarDiacriticos(compraLineaP2.segundoApellidoRle.val())); compraLineaP2.segundoApellidoRle.val(compraLineaP2.segundoApellidoRle.val().toUpperCase()); compraLineaP2.segundoApellidoRle.val(compraLineaP2.segundoApellidoRle.val().replace(/\Ñ/g,'N')); compraLineaP2.saveCampo('c2VndW5kb0FwZWxsaWRvUmxl',compraLineaP2.segundoApellidoRle.val()); }else{ alert("Debe completar el Segundo Apellido o de lo contrario active la opcion No Posee"); return; } }); this.sRango.change(function(){ compraLineaP2.loadRango(); compraLineaP2.saveCampo( 'aWRyYW5nbw==', compraLineaP2.sRango.prop("selectedIndex") ); }); this.rutTribu.change(function(){ compraLineaP2.rutTribu.val(compraLineaP2.rutTribu.val().toUpperCase()); compraLineaP2.LoadRutTribu(); compraLineaP2.saveCampo( 'cnV0', compraLineaP2.rutTribu.val().toUpperCase() ); }); this.rsTribu.change(function(){ compraLineaP2.saveCampo( 'cmF6b25zb2NpYWw=', compraLineaP2.rsTribu.val() ); }); $("#ciudadD").change(function(){ compraLineaP1.LoadComunaCiudad(); }); this.nomRle.keypress(function(e) { tecla = (document.all) ? e.keyCode : e.which; if (tecla == 8 || tecla == 32) { return true; } patron = /^[a-zñ A-ZÑ]*$/; tecla_final = String.fromCharCode(tecla); return patron.test(tecla_final); }); function eliminarDiacriticos(texto) { var chars={ "á":"a", "é":"e", "í":"i", "ó":"o", "ú":"u", "à":"a", "è":"e", "ì":"i", "ò":"o", "ù":"u", "ñ":"n", "Á":"A", "É":"E", "Í":"I", "Ó":"O", "Ú":"U", "À":"A", "È":"E", "Ì":"I", "Ò":"O", "Ù":"U", "Ñ":"N"} var expr=/[áàéèíìóòúù]/ig; var res=texto.replace(expr,function(e){return chars[e]}); return res; } this.nomRle.blur(function () { compraLineaP2.nomRle.val(eliminarDiacriticos(compraLineaP2.nomRle.val())); compraLineaP2.nomRle.val(compraLineaP2.nomRle.val().toUpperCase()); compraLineaP2.nomRle.val(compraLineaP2.nomRle.val().replace(/\Ñ/g,'N')); }); function cleanString(cadena) { var specialChars = "!@#$^&%*()+=-_[]\/{}\"|:<>?,°.¡¨\\;¬´´''´"; var numers = "1234567890"; for (var i = 0; i < specialChars.length; i++) { cadena= cadena.replace(new RegExp("\\" + specialChars[i], 'gi'), ''); } for (var i = 0; i < numers.length; i++) { cadena = cadena.replace(numers.charAt(2), ""); } cadena = cadena.toUpperCase(); cadena = eliminarDiacriticos(cadena); cadena = cadena.replace (/[0-9]+/g, ''); return cadena; } this.nomRle.change(function(){ if(compraLineaP2.nomRle.val().length > 1){ compraLineaP2.nomRle.val(cleanString(compraLineaP2.nomRle.val())); compraLineaP2.saveCampo( 'cmVwcmVzZW50YW50ZV9ub21icmU=', compraLineaP2.nomRle.val() ); }else{ alert("Debe indicar el Nombre del Representante Legal."); return; } }); this.runRle.change(function(){ compraLineaP2.LoadRutRL(); }); this.correoRle.change(function(){ if(compraLineaP2.correoRle.val().length > 1){ compraLineaP2.saveCampo( 'cmVwcmVzZW50YW50ZV9lbWFpbA==', compraLineaP2.correoRle.val() ); }else{ alert("Debe indicar el Correo del Representante Legal."); return; } }); this.IntContacto.change(function(){ compraLineaP2.saveCampo( 'aW50dGVjbmljbw==', compraLineaP2.IntContacto.val() ); }); this.IntCorreo.change(function(){ compraLineaP2.saveCampo( 'aW50Y29ycmVv', compraLineaP2.IntCorreo.val() ); }); this.IntTelefonoContacto.change(function() { compraLineaP2.saveCampo('aW50Zm9ubw==', compraLineaP2.IntTelefonoContacto.val()); }); this.IntNombreERP.change(function() { compraLineaP2.saveCampo('aW50bm9tYnJlZXJw', compraLineaP2.IntNombreERP.val()); }); this.verTC.click(function(){ $("#loadingContrato").dialog('open'); }); this.aceptaFI.click(function(){ compraLineaP2.guardarFormulario(); }); /* Ya no se muestra Carga Cedula $("#cargarimg").click(function(){ modalCargarCedula(); agregarArchivo(); }); */ /* $("#cedulaimg").change(function(event){ if (event.target.files.length > 0) { nombreArchivo = event.target.files[0].name; } else { return; } var ext = "", arr = nombreArchivo.split("."); if (arr.length > 1) { ext = arr[arr.length - 1].toLowerCase(); } if ("pdf|doc|docx|jpg|odt|jpeg|png|".indexOf (ext + "|") == -1) { validaCargaAdjunto("Solo puede subir el archivo en formato PDF, Word (doc, docx, odt) o imagen (jpg, jpeg, png)",3); return; } if (arrayCedula.length >= 1 && "pdf|doc|docx|odt|".indexOf (ext + "|") >= 0) { validaCargaAdjunto("Solo puede subir el segundo archivo en formato imagen (jpg, jpeg, png)",2); return; } if(event.target.files[0].size / 1048576 > 2 && "pdf|doc|docx|odt|".indexOf (ext + "|") >= 0){ validaCargaAdjunto("El peso del archivo supera los 2 MB permitidos",1); } extensionArchivo = ext; if ("pdf|doc|docx|odt|".indexOf (ext + "|") == -1) { if (arrayCedula.length >= 2) { alert("Puede adjuntar máximo dos archivos"); return; } } var files = event.target.files; for (var i = 0, f; f = files[i]; i++) { var reader = new FileReader(); reader.onload = (function(theFile) { return function(e) { arrayCedula.push({nombre: nombreArchivo, src: e.target.result, ext: extensionArchivo}); agregarArchivo(); $("#cedulaimg").val(""); }; })(f); reader.readAsDataURL(f); } }); */ this.btnCerrarContrato.click(function(){ $("#loadingContrato").dialog("close"); }); }, juntarNomRle:function(v){ let nomRleinp = this.nomRle.val(); let nomRleinptemp = ""; nomRleinptemp += nomRleinp+v+" "; this.nomRle.val(nomRleinptemp); compraLineaP2.nomRle.val(cleanString(compraLineaP2.nomRle.val())); compraLineaP2.saveCampo( 'cmVwcmVzZW50YW50ZV9ub21icmU=', compraLineaP2.nomRle.val() ); }, guardarDatosTrubutarios:function(){ let mdt_rut = compraLineaP2.mdt_rut.val(); let mdt_razonsocial = compraLineaP2.mdt_razonsocial.val(); let mdt_giro = compraLineaP2.mdt_giro.val(); let mdt_dire = $("#mdt_direccion").val(); let mdt_region = $('#mdt_region option:selected').html(); let mdt_comuna = compraLineaP2.mdt_comuna.val(); let mdt_idempresa = compraLineaP2.idformulario; if(mdt_rut == ""){ alert("El campo rut es obligatorio"); return; } else if( !/^[0-9]+[-|-]{1}[0-9kK]{1}$/.test(mdt_rut)){ alert("RUT NO VALIDO."); return false; } if(mdt_razonsocial == ""){ alert("El campo razón social es obligatorio"); return; }else if(mdt_razonsocial.length>100){ alert("El campo razón social sobrepasa los 100 caracteres"); return; } if(mdt_giro == ""){ alert("El campo giro es obligatorio"); return; }else if(mdt_giro.length>40){ alert("El campo giro sobrepasa los 40 caracteres"); return; } if(mdt_dire == ""){ alert("El campo dirección es obligatorio"); return; }else if(mdt_dire.length>70){ alert("El campo giro dirección los 70 caracteres"); return; } if(mdt_region == ""){ alert("El campo región es obligatorio"); return false; } if( mdt_comuna == "-- COMUNA --" || mdt_comuna == "comuna" || mdt_comuna == ''){ alert("El campo comuna es obligatorio"); return false; } $.ajax({ url:"compralinea/cmd.php", datatype: 'json', async:false, type:'POST', data:{ cmd: 'actualizarDatosTributarios', hash: hash, rut: mdt_rut, razonsocial: escape(mdt_razonsocial), giro: escape(mdt_giro), direccion: escape(mdt_dire), region: escape(mdt_region), comuna: escape(mdt_comuna), idempresa: escape(mdt_idempresa) }, success: function(valida){ if(valida == 'OK'){ parent.compraLineaP2.rsTribu.val(mdt_razonsocial); parent.compraLineaP2.rutTribu.val(mdt_rut); $("#modalDatosTributarios").dialog('close'); }else{ alert(valida); } } }); }, LoadComuna: function(){ var _comuna = this.mdt_comuna; var _region = this.mdt_region.val(); $.ajax({ url: "compralinea/cmd.php", dataType: 'json', async: false, data: {cmd: 'comuna', hash: hash, region: _region}, success: function(j){ var options = ''; for (var i = 0; i < j.length; i++) { options += ''; } _comuna.html(options); } }); }, LoadRegion: function(){ var _region = this.mdt_region; $.getJSON("compralinea/cmd.php",{cmd: 'region', hash: hash}, function(j){ var options = ''; for (var i = 0; i < j.length; i++) { options += ''; } _region.html(options); }); }, LoadRut: function(){ var x = formateaRUT(this.mdt_rut.get(0)); var _rut = this.mdt_rut.val().replace(/\.| /g, "").toUpperCase(); if (!validaRUT (_rut)) { setTimeout('document.getElementById("mdt_rut").focus()',1); alert ("RUT NO VALIDO."); return; } $("#loadingScreen").dialog('open'); $("#loadingScreen").dialog({ autoOpen: false, height: 110, width: 300, modal: true }); this.mdt_rut.val(_rut); $.getJSON("compralinea/cmd.php",{cmd: 'gteByRut', hash: hash, rut: _rut}) .done(function( json ) { if(json.error == undefined){ compraLineaP2.mdt_rut.val(json.rut); compraLineaP2.mdt_razonsocial.val(json.razonSocial); compraLineaP2.mdt_giro.val(json.giro); compraLineaP2.mdt_direccion.val(json.direccion); } else { alert (json.error); } $("#loadingScreen").dialog('close'); }) .fail(function() { $("#loadingScreen").dialog('close'); }); }, guardarFormulario: function(isguardar){ isguardar = isguardar || false _idformulario_ = compraLineaP2.idformulario; if(compraLineaP2.acepta.prop("checked") == false){ alert("Debe aceptar terminos y condiciones de contrato."); return; } // NOMBRE EMPRESA compraLineaP2.getEmpresa(); if(compraLineaP2.formOK == false){ alert("Debe indicar un Nombre de Sistema correcto."); return; } if(compraLineaP2.empresa.val().length > 1){ compraLineaP2.saveCampo( 'c3lzX25hbWU=', compraLineaP2.empresa.val().toLowerCase().replace(/\s+/g, '') ); }else{ alert("Debe indicar el Nombre de Sistema."); return; } // NOMBRE CONTACTO if(compraLineaP2.nombreCont.val().length > 1){ compraLineaP2.saveCampo( 'Y29udGFjdG9fbm9tYnJl', compraLineaP2.nombreCont.val() ); }else{ alert("Debe indicar el Nombre de Contacto."); return; } if(compraLineaP2.NombresRle.val().length>1) { compraLineaP2.saveCampo('bm9tYnJlc1JsZQ==',compraLineaP2.NombresRle.val()); }else{ alert("Debe indicar el Nombre de Contacto."); return; } if(compraLineaP2.primerApellidoRle.val().length>1) { compraLineaP2.saveCampo('cHJpbWVyYXBlbGxpZG9ybGU=',compraLineaP2.primerApellidoRle.val()); }else{ alert("Debe indicar el Primer Apellido del Representante Legal."); return; } var chkSegApellido = $('#chkSegApellido').prop('checked'); if(chkSegApellido==true){ if(compraLineaP2.segundoApellidoRle.val().length<1){ compraLineaP2.saveCampo('c2VndW5kb0FwZWxsaWRvUmxl',''); } }else{ if(compraLineaP2.segundoApellidoRle.val().length>1){ compraLineaP2.saveCampo('c2VndW5kb0FwZWxsaWRvUmxl',compraLineaP2.segundoApellidoRle.val()); }else{ alert("Debe completar el Segundo Apellido o de lo contrario active la opcion No Posee"); return; } } compraLineaP2.nomRle.val(compraLineaP2.NombresRle.val() + " " + compraLineaP2.primerApellidoRle.val() + " " + compraLineaP2.segundoApellidoRle.val()); console.log(compraLineaP2.nomRle.val()); // CORREO CONTACTO if(compraLineaP2.correoCont.val().length > 1){ compraLineaP2.saveCampo( 'Y29udGFjdG9fZW1haWw=', compraLineaP2.correoCont.val() ); }else{ alert("Debe indicar el Correo de Contacto."); return; } // RANGO var validarRango = true; if (compraLineaP2.dte39.prop("checked") == true && compraLineaP2.dteDefecto.prop("checked") == false && compraLineaP2.dte110.prop("checked") == false && compraLineaP2.dte34.prop("checked") == false && compraLineaP2.dte43.prop("checked") == false && compraLineaP2.dte46.prop("checked") == false && compraLineaP2.dte52.prop("checked") == false) { validarRango = false; } if (validarRango) { if(compraLineaP2.sRango.prop("selectedIndex") > 0){ compraLineaP2.saveCampo( 'aWRyYW5nbw==', compraLineaP2.sRango.prop("selectedIndex") ); }else{ alert("Debe indicar el Rango."); return; } } else { compraLineaP2.saveCampo( 'aWRyYW5nbw==', 1 ); } if ($("#isdespacho").val() == "true" && $("#datosdespacho").css('display') != "none") { if ($("#nombrecontactoD").val().trim().length == 0) { alert("Debe indicar el Nombre de Contacto."); return; } if ($("#telefonocontactoD").val().trim().length == 0) { alert("Debe ingresar un Teléfono de Contacto."); document.getElementById('infoadicionalD').scrollIntoView(false); $("#telefonocontactoD").focus(); return; } if ($("#correocontactoD").val().trim().length == 0){ alert("Debe ingresar un Correo Electrónico."); document.getElementById('infoadicionalD').scrollIntoView(false); //window.scrollTo(0, 100); $("#correocontactoD").focus(); return; } if(validar_email($("#correocontactoD").val().trim()) == false){ alert("Debe ingresar un Correo Electrónico V\xe1lido."); document.getElementById('infoadicionalD').scrollIntoView(false); $("#correocontactoD").focus(); return false; } if ($("#direccionD").val().trim().length == 0) { alert("Debe indicar la dirección de Despacho."); return; } if ($("#ciudadD")[0].selectedIndex == 0) { alert("Debe indicar la Ciudad de Despacho."); return; } if ($("#comunaD")[0].selectedIndex == 0) { alert("Debe indicar la Comuna de Despacho."); return; } if(!validar_telefono($("#telefonocontactoD").val())) { alert("Formato del tel\u00E9fono inv\u00E1lido. Ej: +56912345678"); document.getElementById('infoadicionalD').scrollIntoView(false); $("#telefonocontactoD").focus(); return false; } } // RUT EMPRESA if(compraLineaP2.rutTribu.val().length > 1){ compraLineaP2.saveCampo( 'cnV0', compraLineaP2.rutTribu.val() ); }else{ alert("Debe indicar el RUT de la empresa."); return; } // RAZON SOCIAL if(compraLineaP2.rsTribu.val().length > 1){ compraLineaP2.saveCampo( 'cmF6b25zb2NpYWw=', compraLineaP2.rsTribu.val() ); }else{ alert("Debe indicar la Razon Social de la empresa."); return; } // N° SERIE if(!compraLineaP2.cedulatemporal[0].checked){ if(/^([Aa]{1})?[0-9]{9}$/.test(compraLineaP2.nroserie.val()) != true){ modalValidaCedula(); return false; } else { compraLineaP2.saveCampo( 'bnJvc2VyaWU=', compraLineaP2.nroserie.val()); } } // REPRESENTANTE LEGAL if(compraLineaP2.nomRle.val().length > 1){ compraLineaP2.saveCampo( 'cmVwcmVzZW50YW50ZV9ub21icmU=', compraLineaP2.nomRle.val() ); }else{ alert("Debe indicar el Nombre del Representante Legal."); return; } // RUT REPRESENTANTE LEGAL if(compraLineaP2.runRle.val().length > 1){ compraLineaP2.saveCampo( 'cmVwcmVzZW50YW50ZV9jbmk=', compraLineaP2.runRle.val() ); }else{ alert("Debe indicar el RUT del Representante Legal."); return; } // CORREO REPRESENTANTE LEGAL if(compraLineaP2.correoRle.val().length > 1){ compraLineaP2.saveCampo( 'cmVwcmVzZW50YW50ZV9lbWFpbA==', compraLineaP2.correoRle.val() ); }else{ alert("Debe indicar el Correo del Representante Legal."); return; } var resul = confirmarCorreo(document.getElementById("confircorreoRle")); if(resul == 'sincorreo'){ alert("Debe ingresar el campo 'Confirme Correo Electrónico'"); return false; }else if(!resul){ alert("Deben coincidir los correos indicados en el campo Correo Representante Legal"); return false; } integrado = compraLineaP2.integrado; if (integrado || $('#FIntegrado').css('display') != 'none') { if (compraLineaP2.IntContacto.val().length > 1) { compraLineaP2.saveCampo( 'aW50dGVjbmljbw==', compraLineaP2.IntCorreo.val() ); } else { alert("Debe indicar el Contacto de Integraci\u00F3n."); return; } if (! (compraLineaP2.IntCorreo.val().length > 1) ) { alert("Debe indicar el Correo de Integraci\u00F3n."); return; } if (validar_email(compraLineaP2.IntCorreo.val())) { compraLineaP2.saveCampo( 'aW50Y29ycmVv', compraLineaP2.IntCorreo.val() ); } else { alert("Correo de Integraci\u00F3n no v\u00E1lido."); return; } var largoTelefono = compraLineaP2.IntTelefonoContacto.val().trim().length; if (largoTelefono == 0) { alert("Debe indicar el Tel\u00E9fono de Integraci\u00F3n."); return; } if(!validar_telefono(compraLineaP2.IntTelefonoContacto.val())) { alert("Formato del tel\u00E9fono inv\u00E1lido. Ej: +56912345678"); return false; } else { compraLineaP2.saveCampo('aW50Zm9ubw==', compraLineaP2.IntTelefonoContacto.val()); } if (compraLineaP2.IntNombreERP.val().trim().length > 1) { if ( compraLineaP2.IntNombreERP.val().trim().length > 50 ) { alert("El Nombre del sistema ERP de Integraci\u00F3n no debe superar los 50 caracteres."); return; } compraLineaP2.saveCampo('aW50bm9tYnJlZXJw', compraLineaP2.IntNombreERP.val()); } else { alert("Debe indicar el Nombre del sistema ERP de Integraci\u00F3n."); return; } } try { if(document.getElementById("programarPasoProduc").display != "none"){ if(compraLineaP2.fechapasoproduccion.val() == "" && document.getElementById("aceptaResolucionPasoProduccion").checked == false ){ alert("Debe indicar una opci\u00F3n para el paso a producci\u00F3n.") return; } } else { compraLineaP2.fechapasoproduccion.val(""); } } catch (ex) {} var Twebpat=compraLineaP2.webtelefono.val().length; if(compraLineaP2.validar.val()==1){ if(compraLineaP2.webcorreo.val()==""){ alert("Debe indicar el Correo del Proceso Administrativo Transbank - Webpay."); return false; } var ValCorreo=validar_email(compraLineaP2.webcorreo.val()); if(ValCorreo==false){ alert("Formato de correo invalido"); return false; } if(compraLineaP2.webcontacto.val()==""){ alert("Debe indicar el Nombre del contacto del Proceso Administrativo Transbank - Webpay."); return false; } if(Twebpat==0){ alert("El Tel\u00E9fono del contacto es obligatorio"); return false; } if((Twebpat<9) || (Twebpat>11)){ alert("Formato del tel\u00E9fono invalido. Ej: 56912345678"); return false; } } if (isguardar == false) { modalAlertaNombreEmpresa(); return; } if(compraLineaP2.acepta.prop("checked") == true){ document.getElementById("aceptaFI").disabled = true; $.getJSON("compralinea/cmd.php",{ cmd: 'saveFI' , empresa: compraLineaP2.empresa.val() , nombrecont: compraLineaP2.nombreCont.val() , correocont: compraLineaP2.correoCont.val() , ruttribu: compraLineaP2.rutTribu.val() , rstribu: compraLineaP2.rsTribu.val() , nombrerle: compraLineaP2.nomRle.val() , runrle: compraLineaP2.runRle.val() , correorle: compraLineaP2.correoRle.val() , idformulario: _idformulario_ , webcontacto: compraLineaP2.webcontacto.val() , webcorreo: compraLineaP2.webcorreo.val() , webtelefono: compraLineaP2.webtelefono.val() , validar: compraLineaP2.validar.val() , ser_webpay: $('#webpay:checked').val() , intcontacto : compraLineaP2.IntContacto.val() , intcorreo: compraLineaP2.IntCorreo.val() , inttelefonocontacto : compraLineaP2.IntTelefonoContacto.val() , intnombreerp : compraLineaP2.IntNombreERP.val() , integrado : integrado , cedulatemporal : compraLineaP2.cedulatemporal[0].checked ,nombrecontactoD : $("#nombrecontactoD").val() ,telefonocontactoD : $("#telefonocontactoD").val() ,correocontactoD : $("#correocontactoD").val() ,direccionD : $("#direccionD").val() ,ciudadD : $("#ciudadD").val() ,comunaD : $("#comunaD").val() ,infoadicionalD : $("#infoadicionalD").val() ,nroserie : $("#nroserie").val() ,nombresRle : compraLineaP2.NombresRle.val() ,primerApellidoRle : compraLineaP2.primerApellidoRle.val() ,segundoApellidoRle : compraLineaP2.segundoApellidoRle.val() ,res_solicitada_cliente: compraLineaP2.fechapasoproduccion.val() }) .done(function( json ) { if( json.error == undefined ){ if(json.respuesta == 'ERROR'){ alert("Nombre de sistema ya existe.\nPor favor seleccione otro."); document.getElementById("aceptaFI").disabled = false; }else{ if(json.respuesta == 'OK'){ alert("Formulario ingresado correctamente."); window.location.reload(); } document.getElementById("aceptaFI").disabled = false; } } else { alert(json.error); document.getElementById("aceptaFI").disabled = false; } }); } }, LoadContacto: function () { $.getJSON("compralinea/cmd.php", { cmd: 'cargaData', hash: hash }) .done(function (json) { compraLineaP2.correoCont.val(json.correo); compraLineaP2.nombreCont.val(json.contacto); compraLineaP2.IntTelefonoContacto.val(json.telefono_contacto); compraLineaP2.telefonoCont.val(json.telefono_contacto); compraLineaP2.correoCont.attr("readonly","readonly"); compraLineaP2.runRle.val(json.representante_rut); rutRepresentantel = json.representante_rut; nombreRepresentantel = json.representante_name; emailRepresentantel = json.representante_email; compraLineaP2.nomRle.val(json.representante_name); compraLineaP2.correoRle.val(json.representante_email); compraLineaP2.confircorreoRle.val(json.representante_email); if (json.empresaref != "") { $("#checkRle").css("display", ""); $("#datosRle").prop("checked", true); habilitarRle(json); $("#tituloformulario").prop("innerHTML", "Registra Tu Nueva Empresa"); } compraLineaP2.saveCampo('Y29udGFjdG9fbm9tYnJl', compraLineaP2.nombreCont.val()); compraLineaP2.saveCampo('Y29udGFjdG9fZW1haWw=', compraLineaP2.correoCont.val()); compraLineaP2.saveCampo('aW50Zm9ubw==', compraLineaP2.IntTelefonoContacto.val()); }); }, getEmpresa: function(){ _idformulario_ = compraLineaP2.idformulario; $.getJSON("compralinea/cmd.php",{ cmd: 'getEmpresaName' , empresa: compraLineaP2.empresa.val() , idformulario: _idformulario_ }) .done(function( json ) { if(json.msg == undefined){ if(json.respuesta == 'ERROR'){ alert("Nombre de sistema ya existe.\nPor favor seleccione otro."); }else{ //compraLineaP2.empresa.val(json.respuesta); compraLineaP2.dataEmpresaFI.html('

' + json.msg2 + '

'); compraLineaP2.dataEmpresaFI.css('color', 'green'); compraLineaP2.formOK = true; } }else{ compraLineaP2.dataEmpresaFI.html('

' + json.msg + '

'); compraLineaP2.dataEmpresaFI.css('color', 'red'); compraLineaP2.formOK = false; } }); }, saveCampo: function(_campo_, _valor_){ _idformulario_ = compraLineaP2.idformulario; $.getJSON("compralinea/cmd.php",{cmd: 'saveCampo', idformulario: _idformulario_, campo: _campo_, valor: _valor_}) .done(function( json ) { }); }, LoadRutRL: function(){ formateaRUT(this.runRle.get(0)); var _rut = this.runRle.val().replace(/\.| /g, "").toUpperCase(); if (!validaRUT (_rut)) { this.runRle.val(""); compraLineaP2.nomRle[0].readOnly = false; compraLineaP2.nomRle[0].value = ""; // POR ALEJANDRO MARTINEZ EN FECHA 24-04-2017. MOTIVO: REQUERIMIENTO 2101 --> setTimeout('this.runRle.focus()',1); //FIN REQUERIMIENTO 2101 --> alert ("RUT NO VALIDO."); return; } $(".ui-loadingScreen-titlebar").hide(); $("#loadingScreen").dialog('open'); $.getJSON("compralinea/cmd.php",{cmd: 'gteByRut', hash: hash, rut: _rut}) .done(function( json ) { compraLineaP2.runRle.val(json.rut); compraLineaP2.nomRle.val(json.razonSocial); if (json.razonSocial != "") { compraLineaP2.nomRle[0].readOnly = true; } else { compraLineaP2.nomRle[0].readOnly = false; } compraLineaP2.saveCampo( 'cmVwcmVzZW50YW50ZV9jbmk=', json.rut ); $.getJSON("compralinea/cmd.php",{cmd: 'separaNombres', razonSocial: compraLineaP2.nomRle.val()}) .done(function (json1){ debugger; compraLineaP2.NombresRle.val(json1.nombresRle); compraLineaP2.primerApellidoRle.val(json1.primerApellidoRle); compraLineaP2.segundoApellidoRle.val(json1.segundoApellidoRle); compraLineaP2.NombresRle[0].readOnly = false; compraLineaP2.primerApellidoRle[0].readOnly = false; compraLineaP2.segundoApellidoRle[0].readOnly = false; if(compraLineaP2.segundoApellidoRle.val() == "" && compraLineaP2.primerApellidoRle.val()!=""){ $('#chkSegApellido').prop('checked',true); }else if(compraLineaP2.segundoApellidoRle.val() != "" && compraLineaP2.primerApellidoRle.val()!="" && $('#chkSegApellido').prop('checked')==true){ $('#chkSegApellido').prop('checked',false); }else if(compraLineaP2.segundoApellidoRle.val() == "" && compraLineaP2.primerApellidoRle.val() == "" && $('#chkSegApellido').prop('checked')==true){ $('#chkSegApellido').prop('checked',false); } modstyle(); compraLineaP2.saveCampo('bm9tYnJlc1JsZQ==',json1.nombresRle); compraLineaP2.saveCampo('cHJpbWVyYXBlbGxpZG9ybGU=',json1.primerApellidoRle); compraLineaP2.saveCampo('c2VndW5kb0FwZWxsaWRvUmxl',json1.segundoApellidoRle); compraLineaP2.saveCampo( 'cmVwcmVzZW50YW50ZV9ub21icmU=', json1.nombresRle + ' ' + json1.primerApellidoRle + ' ' + json1.segundoApellidoRle); }); }); $("#loadingScreen").dialog('close'); }, LoadRutTribu: function(){ var x = formateaRUT(this.rutTribu.get(0)); var _rut = this.rutTribu.val().replace(/\.| /g, "").toUpperCase(); if (!validaRUT (_rut)) { // POR ALEJANDRO MARTINEZ EN FECHA 24-04-2017. MOTIVO: REQUERIMIENTO 2101 --> setTimeout('this.rutTribu.focus()',1); // FIN MOTIVO: REQUERIMIENTO 2101 --> alert ("RUT NO VALIDO."); return; } $("#loadingScreen").dialog('open'); $.getJSON("compralinea/cmd.php",{cmd: 'gteByRut', hash: hash, rut: _rut}) .done(function( json ) { compraLineaP2.rutTribu.val(json.rut); if(json.razonSocial != undefined){ compraLineaP2.rsTribu.val(json.razonSocial);} try{ compraLineaP2.acteco.val(json.acteco[0].codigo); compraLineaP2.saveCampo( 'YWN0ZWNv', json.acteco[0].codigo ); }catch(e){ } }); $("#loadingScreen").dialog('close'); }, cargaData: function( _hash_ ){ $("#FIntegrado").hide(); $.ajax({ method: "post", dataType: "json", url: "compralinea/cmd.php", data: { cmd: 'cargaDataFI', hash: _hash_ } }) .done(function( contacto ) { compraLineaP2.empresa.val(contacto.empresa); compraLineaP2.rutTribu.val(contacto.rutempresa); compraLineaP2.rsTribu.val(contacto.razonsocial); compraLineaP2.nombreCont.val(contacto.contacto); compraLineaP2.correoCont.val(contacto.correo); compraLineaP2.telefonoCont.val(contacto.telefonos); compraLineaP2.acteco.val(contacto.acteco); compraLineaP2.runRle.val(contacto.representante_rut); compraLineaP2.nomRle.val(contacto.representante_name); compraLineaP2.NombresRle.val(contacto.nombresRle); compraLineaP2.primerApellidoRle.val(contacto.primerApellidoRle); compraLineaP2.segundoApellidoRle.val(contacto.segundoApellidoRle); if(compraLineaP2.segundoApellidoRle.value == ""){ $('#chkSegApellido').checked==true; } compraLineaP2.correoRle.val(contacto.representante_email); compraLineaP2.confircorreoRle.val(contacto.representante_email); if (contacto.empresaref != "") { $("#checkRle").css("display", ""); $("#datosRle").prop("checked", true); habilitarRle(contacto); $("#tituloformulario").prop("innerHTML", "Registra Tu Nueva Empresa"); } else { compraLineaP2.nomRle.val(contacto.contacto); compraLineaP2.correoRle.val(contacto.correo); } compraLineaP2.IntContacto.val(contacto.inttecnico); compraLineaP2.IntCorreo.val(contacto.intcorreo); compraLineaP2.IntTelefonoContacto.val(contacto.intfono); compraLineaP2.IntNombreERP.val(contacto.intnombreerp); compraLineaP2.dteDefecto.prop("checked", contacto.dte33); compraLineaP2.dte34.prop("checked", contacto.dte34); compraLineaP2.dte52.prop('checked', contacto.dte52); compraLineaP2.dte39.prop("checked", contacto.dte39); compraLineaP2.dte46.prop("checked", contacto.dte46); compraLineaP2.dte110.prop("checked", contacto.dte110); compraLineaP2.dte43.prop("checked", contacto.dte43); compraLineaP2.nroserie.val(contacto.nroserie); compraLineaP2.idformulario = contacto.idempresa; compraLineaP2.integrado = contacto.integrado; if(contacto.integrado == true){ $("#FIntegrado").show(); } if (contacto.adicional == true) { $("#datosdespacho").css('display', ""); $("#nombrecontactoD").val(contacto.contacto); /*$("#telefonocontactoD").val(contacto.intfono);*/ $("#telefonocontactoD").val(contacto.formulario_telefono); $("#correocontactoD").val(contacto.formulario_email); $("#direccionD").val(contacto.direccion) $("#isdespacho").val(true); compraLineaP1.LoadCiudad(contacto.comuna); compraLineaP1.LoadComunaCiudad(contacto.comuna); } var correovalido = contacto.casillaintercambio.split('@'); if (contacto.casillaintercambio != '' && (correovalido[1] == 'sii.cl')) { if(!($("#dte39").prop("checked") == true && $("#dte336156").prop("checked") == false && $("#dte110").prop("checked") == false && $("#dte52").prop("checked") == false && $("#dte46").prop("checked") == false && $("#dte43").prop("checked") == false && $("#dte34").prop("checked") == false)){ $("#divrespaldardatossii").css("display", ""); } } if(contacto.webpay=='t'){ $("#FIwebpay").show(); $("#validar").val("1"); $("#WebContacto").val(contacto.contacto); $("#WebCorreo").val(contacto.correo); } try { if (contacto.isResolucion == "1" && contacto.integrado == false) { document.getElementById("programarPasoProduc").setAttribute("style", "display:block !important;") var calendariopasoproduccion2 = document.getElementById("calendariopasoproduccion"); var aceptapasoproduccion = document.getElementById("aceptaResolucionPasoProduccion"); var btnBorrarCalendario = document.getElementById("btn-borrar-calendariopasoproduccion"); var inputotrafecha = document.getElementById("inputotrafecha"); if(contacto.res_solicitada_cliente != ""){ aceptapasoproduccion.checked = false; calendariopasoproduccion2.value = contacto.res_solicitada_cliente; calendariopasoproduccion2.disabled = false; btnBorrarCalendario.disabled = false; btnBorrarCalendario.setAttribute("style", "cursor:pointer;border:0px;background:transparent;"); calendariopasoproduccion2.setAttribute("style", "background-color: #FFFFFF;cursor:pointer;width:125px;height:13px;border:1px solid black;text-align:center;") inputotrafecha.checked = true; }else{ inputotrafecha.checked = false; aceptapasoproduccion.checked = true; calendariopasoproduccion2.disabled = true; btnBorrarCalendario.disabled = true; btnBorrarCalendario.setAttribute("style", "cursor:default;border:0px;background:transparent;"); } } } catch (ex1) {} cargarSelecRango(); }); }, loadRango:function(){ if (this.sRango.prop("selectedIndex") == 1) { $("#vfMensual").val('0.25'); $("#DTEextra").val('0.02'); }else if (this.sRango.prop("selectedIndex") == 2) { $("#vfMensual").val('0.5'); $("#DTEextra").val('0.02'); }else if (this.sRango.prop("selectedIndex") == 3) { $("#vfMensual").val('0.75'); $("#DTEextra").val('0.012'); }else if (this.sRango.prop("selectedIndex") == 0) { $("#vfMensual").val(''); $("#DTEextra").val(''); } else if (this.sRango.prop("selectedIndex") == 4) { $("#vfMensual").val('1'); $("#DTEextra").val('0.012'); } else if (this.sRango.prop("selectedIndex") == 5) { $("#vfMensual").val('1.1'); $("#DTEextra").val('0.012'); } else if (this.sRango.prop("selectedIndex") == 6) { $("#vfMensual").val('1.2'); $("#DTEextra").val('0.010'); } else if (this.sRango.prop("selectedIndex") == 7) { $("#vfMensual").val('1.5'); $("#DTEextra").val('0.010'); } else if (this.sRango.prop("selectedIndex") == 8) { $("#vfMensual").val('1.8'); $("#DTEextra").val('0.010'); } else if (this.sRango.prop("selectedIndex") == 9) { $("#vfMensual").val('2'); $("#DTEextra").val('0.005'); } else if (this.sRango.prop("selectedIndex") == 10) { $("#vfMensual").val('2.5'); $("#DTEextra").val('0.005'); } else if (this.sRango.prop("selectedIndex") == 11) { $("#vfMensual").val('3'); $("#DTEextra").val('0.005'); } else if (this.sRango.prop("selectedIndex") == 12) { $("#vfMensual").val('3.5'); $("#DTEextra").val('0.002'); } else if (this.sRango.prop("selectedIndex") == 13) { $("#vfMensual").val('4'); $("#DTEextra").val('0.002'); } else if (this.sRango.prop("selectedIndex") == 14) { $("#vfMensual").val('4.5'); $("#DTEextra").val('0.002'); } else if (this.sRango.prop("selectedIndex") == 15) { $("#vfMensual").val('5.5'); $("#DTEextra").val('0.002'); } else if (this.sRango.prop("selectedIndex") == 16) { $("#vfMensual").val('6'); $("#DTEextra").val('0.002'); } else if (this.sRango.prop("selectedIndex") == 17) { $("#vfMensual").val('6.5'); $("#DTEextra").val('0.002'); } else if (this.sRango.prop("selectedIndex") == 18) { $("#vfMensual").val('6.8'); $("#DTEextra").val('0.002'); } else if (this.sRango.prop("selectedIndex") == 19) { $("#vfMensual").val('7'); $("#DTEextra").val('0.002'); } else if (this.sRango.prop("selectedIndex") == 20) { $("#vfMensual").val('7.5'); $("#DTEextra").val('0.002'); } else if (this.sRango.prop("selectedIndex") == 21) { $("#vfMensual").val('8'); $("#DTEextra").val('0.002'); } }, Load: function(){ this.init(); } } var compraLineaP1 = { idcontacto: null, idcotiza: null, contador: 0, rutsii : false, init: function(){ // console.log("DECLARAMOS LOS COMPONENTES"); // DATOS EMPRESA this.rut = $("#rut"); this.razonsocial = $("#razonsocial"); this.giro = $("#giro"); this.direccion = $("#direccion"); this.region = $("#region"); this.comuna = $("#comuna"); //DATOS CONTACTO this.contacto = $("#contactocl"); this.correo = $("#correocl"); // POR ALEJANDRO MARTINEZ EN FECHA 05-04-2017. MOTIVO: REQUERIMIENTO 2101 --> this.telefono = $("#telefonocl"); // FIN REQUERIMIENTO 2101 --> //TIPOS DOCUMENTO this.dteDefecto = $("#dte336156"); this.dte52 = $("#dte52"); this.dte34 = $("#dte34"); this.dte39 = $("#dte39"); this.dte41 = $("#dte41"); this.dte46 = $("#dte46"); this.dte110 = $("#dte110"); this.dte43 = $("#dte43"); this.dte33 = $('#dte33'); // MODULOS this.dteCOM = $("#dteCOM"); // COMERCIAL this.dteCTB = $("#dteCTB"); // CONTABILIDAD this.dteCC = $("#dteCC"); // CTA CTES this.dteEX = $("#dteEX"); // EXISTENCIAS this.dteCO = $("#dteCO"); // CONTRATOS this.dteRE = $("#dteRE"); // REMUNERACIONES this.dteCV = $("#dteCV"); // IMPORTACION COMPRAS Y VENTAS this.dteOC = $("#dteOC"); // ORDEN DE COMPRA this.dteCCS = $("#dteCCS"); //CENTRO DE COSTOS this.dteCOMI = $("#dteCOMI"); //COMISIONES this.tiendaweb = $("#creartiendaweb"); this.codVerifica = $("#codigoverificacion"); this.btnValidaOk = $("#ValidaOk"); this.btnValidaNo = $("#ValidaNo"); this.btnCerrarFicha = $("#cargaFicha_cerrar"); this.btnPromoSII = $("#OKmipyme"); this.vtnValida = $("#validaScreen"); this.Integrado = $("#Integrado"); this.IntContacto = $("#IntContacto"); this.IntCorreo = $("#IntCorreo"); this.IntTelefonoContacto = $("#IntTelefonoContacto"); this.IntNombreERP = $("#IntNombreERP"); this.CodigoDescuento = $("#codigodescuento"); this.btnMsgalerta = $("#cerrarmsgalerta"); this.btnMsgAlertaReenvio = $("#cerrarmsgalertareenviocodigo"); //this.btn_cerrar_codigoasociado = $("#cerrar_codigoasociado"); //VARIABLES DE SISTEMA //this.idcontacto = 0; //this.idcotiza = 0; this.cerrarcontrato = $("#btncerrarcontrato"); this.modalcontrato = $("#modalcontrato"); $("#lightbox_contrato").dialog({ height: 550, width: "60rem", autoOpen: false, modal: true }); //$('.ui-dialog').css('z-index','2001'); $(".ui-dialog-titlebar").hide(); this.cerrarcontrato.click(function() { $("#lightbox_contrato").dialog("close"); }); this.modalcontrato.click(function() { $("#lightbox_contrato").dialog('open'); }); // FUNCIONALIDADES this.rut.blur(function(){Capitalizar(this);}); this.razonsocial.blur(function(){MAYUSCULA(this);}); this.giro.blur(function(){MAYUSCULA(this);}); this.direccion.blur(function(){MAYUSCULA(this);}); this.contacto.blur(function(){Capitalizar(this);}); this.CodigoDescuento.blur(function(){MAYUSCULA(this);codigopromocional(this.value);}); this.LoadRegion(); this.region.change(function(){ compraLineaP1.LoadComuna(); }); this.rut.change(function(){ compraLineaP1.LoadRut(compraLineaP1.rut.val()); }); $("#dialog").dialog({ //create dialog, but keep it closed autoOpen: false, height: 700, width: 900, modal: true }); $(".ui-dialog-titlebar").hide(); $("#loadingScreen").dialog({ autoOpen: false, height: 50, width: 250, modal: true, show: { effect: "fade", duration: 800 }, hide: { effect: "fade", duration: 800 } }); $(".ui-dialog-titlebar").hide(); $("#msgalerta").dialog({ autoOpen: false, height: 130, width: 500, modal: true, }); $(".ui-dialog-titlebar").hide(); this.btnMsgalerta.click(function(){ $("#msgalerta").dialog("close"); }); $("#msgalertacodigo").dialog({ autoOpen: false, height: 170, width: 380, modal: true }); this.btnMsgAlertaReenvio.click(function() { $("#msgalertacodigo").dialog("close"); }); $("#msgRevisarSpam").dialog({ //create dialog, but keep it closed autoOpen: false, height: 350, width: 400, modal: true }); $("#validaScreen").dialog({ //create dialog, but keep it closed autoOpen: false, height: 450, width: 550, modal: true }); $(".ui-dialog-titlebar").hide(); // DIALOG INFO MODULOS $("#cargaFicha").dialog({ autoOpen: false, height: 440, width: 750, modal: true }); $(".ui-dialog-titlebar").hide(); // DIALOG MIPYME altoventana = document.getElementById('bannerpromosii').clientHeight + 42; if (altoventana > 660) { altoventana = 660; } if (altoventana <= 210) { altoventana = 660; } $("#bannerpromosii").dialog({ autoOpen: false, height: altoventana, width: 730, position: { my: "bottom-0%", at: "bottom" }, open: function(event, ui) { $( this ).css( "padding", "0" ); }, modal: true }); $(".ui-dialog-titlebar").hide(); /* $("#error_codigoasociado").dialog({ autoOpen: false, height: 160, width: 500, modal: true }); $('.ui-dialog').css({ 'position': 'fixed', 'top': '0' }); $(".ui-dialog-titlebar").hide(); this.btn_cerrar_codigoasociado.click(function(){ $("#error_codigoasociado").dialog("close"); document.getElementById("flag_codigoasociado").value="1"; }); */ document.getElementById("codigodescuento").addEventListener("change", function(){ document.getElementById("flag_codigoasociado").value="0"; }); this.btnValidaNo.click(function(){ $("#validaScreen").dialog('close'); }); this.btnValidaOk.click(function(){ compraLineaP1.btnValidaCotiza(); }); this.btnCerrarFicha.click(function(){ $("#cargaFicha").dialog("close"); }); this.btnPromoSII.click(function(){ //$("#codigodescuento").val('FULL17'); $("#codigodescuento").val('FULL20'); $("#bannerpromosii").dialog("close"); }); this.btnBoletaModal = $('.btn-boletafacil-modal'); this.btnBoletaModalAceptar = $('.btn-aceptar-boleta'); this.btnBoletaModalAceptar.click(function () { $('.span-adicionales-boleta').css('display', 'none'); $('#Boleta-adicionales').val(''); var canMovil1 = document.getElementById('CantidadMovil').value; var canImpresion2 = document.getElementById('CantidadImpresion').value; var canImpresora3 = document.getElementById('CantidadImpresora').value; var canPunto4 = document.getElementById('CantidadPunto').value; var productos = { FE_OPER_POS_MOVIL : canMovil1, FE_OPER_IMPRESORA_MOVIL: canImpresion2, FE_OPER_IMPRESORA: canImpresora3, FE_OPER_KIT_VENTA: canPunto4 }; var nuevoValor = ''; for (var i = 0; i < Object.keys(productos).length; i++) { switch (Object.keys(productos)[i]) { case 'FE_OPER_POS_MOVIL': if ($("#adPOS").prop("checked") == true) { if (canMovil1 > 0) { $('.span-pm').css('display','inline-block'); nuevoValor += canMovil1+'-FE_OPER_POS_MOVIL | '; $(".span-pm").html(canMovil1); } else { $('#CantidadMovil').val("1"); $('.span-pm').css('display','none'); nuevoValor += ""; $("#adPOS").prop("checked", false); } } else { $('#CantidadMovil').val("1"); $('.span-pm').css('display','none'); nuevoValor += ""; $("#adPOS").prop("checked", false); } break; case 'FE_OPER_IMPRESORA_MOVIL': if ($("#adIB").prop("checked") == true) { if (canImpresion2 > 0) { $('.span-if').css('display','inline-block'); nuevoValor += canImpresion2+'-FE_OPER_IMPRESORA_MOVIL | '; $(".span-if").html(canImpresion2); } else { $('#CantidadImpresion').val("1"); $('.span-if').css('display','none'); nuevoValor += ""; $("#adIB").prop("checked", false); } } else { $('#CantidadImpresion').val("1"); $('.span-if').css('display','none'); nuevoValor += ""; $("#adIB").prop("checked", false); } break; case 'FE_OPER_IMPRESORA': if ($("#adIF").prop("checked") == true) { if (canImpresora3 > 0) { $('.span-iof').css('display','inline-block'); nuevoValor += canImpresora3+'-FE_OPER_IMPRESORA | '; $(".span-iof").html(canImpresora3); } else { $('#CantidadImpresora').val("1"); $('.span-iof').css('display','none'); nuevoValor += ""; $("#adIF").prop("checked", false); } } else { $('#CantidadImpresora').val("1"); $('.span-iof').css('display','none'); nuevoValor += ""; $("#adIF").prop("checked", false); } break; case 'FE_OPER_KIT_VENTA': if ($("#adPV").prop("checked") == true) { if (canPunto4 > 0) { $('.span-pv').css('display','inline-block'); nuevoValor += canPunto4+'-FE_OPER_KIT_VENTA | '; $(".span-pv").html(canPunto4); } else { $('#CantidadPunto').val("1"); $('.span-pv').css('display','none'); nuevoValor += ""; $("#adPV").prop("checked", false); } } else { $('#CantidadPunto').val("1"); $('.span-pv').css('display','none'); nuevoValor += ""; $("#adPV").prop("checked", false); } break; default: break; } } $('#Boleta-adicionales').val(nuevoValor); $("#boletaFacilContenedor").dialog('close'); return false; }); $("#boletaFacilContenedor").dialog({ autoOpen: false, resizable:true, height: 480, minWidth: (($("body").width() <= 350) ? ($("body").width() / 2.1) : 350), dialogClass: 'no-close', modal: true }); }, innumerabilidad: function (id, name) { var txt = document.getElementById(name); var contador = parseInt(((txt || {}).value || 0)); if (id.indexOf('mas')!=-1) { if (contador==9) { document.getElementById(id).disabled="true"; } else { if(contador<9){ document.getElementById(id.replace('mas','menos')).disabled=null; } txt.value= contador+1; } } else { if (id.indexOf('menos')!=-1) { if (contador == 0) { document.getElementById(id).disabled="true"; } else { if(contador>0){ document.getElementById(id.replace('menos','mas')).disabled=null; } txt.value= contador-1; } } } }, getFicha: function(ficha){ $("#cargaFicha_Comercial").hide(); $("#cargaFicha_Contabilidad").hide(); $("#cargaFicha_CtasCtes").hide(); $("#cargaFicha_Existencias").hide(); $("#cargaFicha_Contratos").hide(); $("#cargaFicha_Remuneraciones").hide(); $("#cargaFicha_Integraciones").hide(); $("#cargaFicha_webpay").hide(); switch(ficha){ case 'cargaFicha_Comercial': $("#cargaFicha_Comercial").show(); break; case 'cargaFicha_Contabilidad': $("#cargaFicha_Contabilidad").show(); break; case 'cargaFicha_CtasCtes': $("#cargaFicha_CtasCtes").show(); break; case 'cargaFicha_Existencias': $("#cargaFicha_Existencias").show(); break; case 'cargaFicha_Contratos': $("#cargaFicha_Contratos").show(); break; case 'cargaFicha_Remuneraciones': $("#cargaFicha_Remuneraciones").show(); break; case 'cargaFicha_Integraciones': $("#cargaFicha_Integraciones").show(); break; case 'cargaFicha_webpay': $("#cargaFicha_webpay").show(); break; } $("#cargaFicha").dialog("open"); }, LoadComuna: function(){ var _comuna = this.comuna; var _region = this.region.val(); $.ajax({ url: "compralinea/cmd.php", dataType: 'json', async: false, data: {cmd: 'comuna', hash: hash, region: _region}, success: function(j){ var options = ''; for (var i = 0; i < j.length; i++) { options += ''; } _comuna.html(options); } }); /*$.getJSON("compralinea/cmd.php",{cmd: 'comuna', hash: hash, region: _region}, function(j){ var options = ''; for (var i = 0; i < j.length; i++) { options += ''; } _comuna.html(options); })*/ }, LoadRegion: function(){ var _region = this.region; $.ajax({ url: "compralinea/cmd.php", dataType: 'json', async: false, data: { cmd: 'region', hash: hash }, success: function(j) { var options = ''; for (var i = 0; i < j.length; i++) { options += ''; } _region.html(options); } }); }, LoadCiudad: function(comunaD){ $.getJSON("compralinea/cmd.php",{cmd: 'getCiudad', comuna : comunaD}, function(j){ var options = ''; for (var i = 0; i < j.length; i++) { selected = ""; if (j[i].selected == true) { selected = "selected"; } options += ''; } $("#ciudadD").html(options); }) }, LoadComunaCiudad: function(comunaD){ var ciudad = $("#ciudadD").val(); $.getJSON("compralinea/cmd.php",{cmd: 'getcomunaCiudad', nombreCiudad : ciudad , nombreComuna : comunaD}, function(j){ var options = ''; for (var i = 0; i < j.length; i++) { selected = ""; if (j[i].selected == true) { selected = "selected"; } options += ''; } $("#comunaD").html(options); }) }, LoadRut: function(){ try { closepopyacotizado(); } catch (ex1) {} var x = formateaRUT(this.rut.get(0)); var _rut = this.rut.val().replace(/\.| /g, "").toUpperCase(); if (!validaRUT (_rut) || this.rut.val().length < 5 || this.rut.val().length > 10) { setTimeout('this.rut.focus()',1); this.rut.val(""); mensajeDialogoConTitulo("Debe ingresar un RUT de Empresa válido, con formato 11.111.111-1.","RUT de Empresa Incorrecto"); return; } try { verificarCotizacionAnterior(_rut); } catch (ex2) {} $("#loadingScreen").dialog('open'); this.rut.val(_rut); $.getJSON("compralinea/cmd.php",{cmd: 'gteByRut', hash: hash, rut: _rut}) .done(function( json ) { if(json.error == undefined){ compraLineaP1.rut.val(json.rut); compraLineaP1.razonsocial.val(json.razonSocial); compraLineaP1.giro.val(json.giro); compraLineaP1.direccion.val(json.direccion); try { getObtenerResolucion(json.rut); } catch (ex) {} if(json.MiPyme != undefined || json.EmpresaNueva != undefined) { $("#bannerpromosii").dialog('open'); var altoventana1 = document.getElementById('bannerpromosii-content').clientHeight + 42; if (altoventana1 > 660) { altoventana1 = 660; } if (altoventana1 <= 210) { altoventana1 = 660; } if (document.getElementById('bannerpromosii').clientHeight != altoventana1) { $("#bannerpromosii").dialog({ autoOpen: false, height: altoventana1, width: 730, position: { my: "bottom-0%", at: "bottom" }, open: function(event, ui) { $( this ).css( "padding", "0" ); }, modal: true }); } } try { compraLineaP1.rutsii = json.MiPyme != undefined ? true : false; } catch (ex) {} if (json.EmpresaNueva != undefined) { document.getElementById("dte39").setAttribute("onchange","activarBoleta()"); if (document.getElementById("dte39").checked == true && document.getElementById("dte336156").checked == false) { activarBoleta(); } document.getElementById("clientenuevo").value = "true"; if ( document.getElementById("dte39").checked == false && document.getElementById("dte336156").checked == false ){ document.getElementById("dte336156").checked = true; seleccionFactura(document.getElementById("dte336156")); } document.getElementById("dte33").setAttribute("onchange","activarFactura(this)"); document.getElementById("dte34").setAttribute("onchange","activarFactura(this)"); } else { document.getElementById("dte39").setAttribute("onchange",""); document.getElementById("clientenuevo").value = "false"; document.getElementById("dte336156").setAttribute("onchange","seleccionFactura(this)"); } } else { alert (json.error); } $("#loadingScreen").dialog('close'); }) .fail(function() { $("#loadingScreen").dialog('close'); }); $.ajax({ method: "post", url: "compralinea/cmd.php", data: {cmd:'dtehabilitadosii', rut: _rut } }) .done(function(json) { try { data = JSON.parse(json); var dteautorizados = data.dteautorizadosii.split(','); seleccioneFactura = false; seleccioneBoleta = false; document.getElementById("dte336156").checked = false; document.getElementById("dte39").checked = false; document.getElementById("dte33").checked = false; document.getElementById("dte34").checked = false; document.getElementById("dte52").checked = false; document.getElementById("dte110").checked = false; document.getElementById("dte46").checked = false; document.getElementById("dte43").checked = false; seleccionFactura(document.getElementById("dte336156")); for(var x=0; x < dteautorizados.length; x++){ var dteautorizado = dteautorizados[x]; var activarfactura = false; if(dteautorizado == 110 || dteautorizado == 111 || dteautorizado == 112){ document.getElementById("dte110").checked = true; activarfactura = true; } if(dteautorizado == 43){ document.getElementById("dte43").checked = true; activarfactura = true; } if(dteautorizado == 34){ document.getElementById("dte34").checked = true; activarfactura = true; } if(dteautorizado == 46){ document.getElementById("dte46").checked = true; activarfactura = true; } if(dteautorizado == 52){ document.getElementById("dte52").checked = true; activarfactura = true; } if((dteautorizado == 33 || activarfactura == true) && seleccioneFactura == false){ document.getElementById("dte336156").checked = true; seleccionFactura(document.getElementById("dte336156")); seleccioneFactura = true; } if((dteautorizado == 39 || dteautorizado == 41) && seleccioneBoleta == false ){ document.getElementById("dte39").checked = true; if (activarfactura == false) { activarBoleta(); } seleccioneBoleta = true; } if ( dteautorizado == 33 ){ document.getElementById("dte33").checked = true; activarfactura = true; } } } catch (ex) {} }); }, validar : function(){ $('#errorcodigodescuento').html(""); var espacio_blanco = /[A-Za-z0-9_]/; if (!espacio_blanco.test(this.rut.val())) { this.rut.focus(); mensajeDialogo("El campo RUT es obligatorio."); return false; } if (!espacio_blanco.test(this.razonsocial.val())){ this.razonsocial.focus(); mensajeDialogo("El campo Razón social es obligatorio."); return false; } if (!espacio_blanco.test($("#giro").val())){ this.giro.focus(); mensajeDialogo("El campo Giro es obligatorio."); return false; } if (!espacio_blanco.test(this.direccion.val())){ this.direccion.focus(); mensajeDialogo("El campo Dirección es obligatorio."); return false; } if (this.region[0].selectedIndex == 0) { this.region.focus(); mensajeDialogo("El campo Región es obligatorio."); return false; } if (this.comuna[0].selectedIndex == 0){ this.comuna.focus(); mensajeDialogo("El campo Comuna es obligatorio."); return false; } if (!espacio_blanco.test(this.contacto.val())){ this.contacto.focus(); mensajeDialogo("El campo Nombre de Contacto es obligatorio."); return false; } if (!espacio_blanco.test(this.correo.val())){ this.correo.focus(); mensajeDialogoConTitulo("Debe ingresar un Correo Electrónico válido, con formato
ejemplo@ejemplo.cl.","Correo Electrónico Obligatorio"); return false; } // POR ALEJANDRO MARTINEZ EN FECHA 05-04-2017. MOTIVO: REQUERIMIENTO 2101 --> if (!espacio_blanco.test(this.telefono.val())){ this.telefono.focus(); mensajeDialogo("Ingrese Tel\u00E9fono de Contacto."); return false; } var regex = /[a-zA-Z]/; if (regex.test(document.getElementById('telefonocl').value.trim())) { this.telefono.focus(); mensajeDialogo("Ingrese Tel\u00E9fono de Contacto válido"); return false; } // FIN REQUERIMIENTO 2101 --> if(validar_email(this.correo.val()) == false){ this.correo.focus(); mensajeDialogoConTitulo("Debe ingresar un Correo Electrónico válido, con formato
ejemplo@ejemplo.cl.","Correo Electrónico Incorrecto"); return false; } if(ititelefonocl.getSelectedCountryData().dialCode == '56' && document.getElementById('telefonocl').value.replaceAll(' ','').length != 9){ this.telefono.focus(); mensajeDialogo("Debe ingresar un teléfono valido, con formato de 9 digitos numéricos."); return false; } if(ititelefonocl.getSelectedCountryData().dialCode != '56' && document.getElementById('telefonocl').value.replaceAll(' ','').length > 15){ this.telefono.focus(); mensajeDialogo("Debe ingresar un teléfono valido, con formato de máximo de 15 dígitos numéricos."); return false; } if ($('#FIntegrado').css('display') != 'none') { if (!espacio_blanco.test(this.IntContacto.val())){ this.IntContacto.focus(); alert('Ingrese Nombre de Contacto de Integraci\xf3n.'); return false; } if (!espacio_blanco.test(this.IntCorreo.val())){ this.IntCorreo.focus(); alert('Ingrese Correo de Contacto de Integraci\xf3n.'); return false; } if (!espacio_blanco.test(this.IntTelefonoContacto.val())){ this.IntTelefonoContacto.focus(); alert('Ingrese Tel\u00E9fono de Contacto'); return false; } if (!espacio_blanco.test(this.IntNombreERP.val())){ this.IntNombreERP.focus(); alert('Ingrese Nombre ERP'); return false; } } if (this.dte39.prop("checked") == false && this.dteDefecto.prop("checked") == false){ mensajeDialogo("Debe seleccionar al menos un tipo de documento a emitir."); return; } if (this.dteDefecto.prop("checked") == true && this.dte33.prop("checked") == false && this.dte34.prop("checked") == false ) { this.dteDefecto.focus(); mensajeDialogo("Debe seleccionar al menos uno de los siguientes documentos: Factura Afecta o Factura Exenta"); return; } if ($("#codigodescuento").val() != '' && document.getElementById("flag_codigoasociado").value == "0"){ $.ajax({ method: "post", dataType: "json", url: "compralinea/cmd.php", async: false, data: { cmd: 'consultaproductoasociado' , codigodescuento: $("#codigodescuento").val() } }).done(function(json) { try { console.log("p"); if(json.error == undefined){ var codigopromocionallista = json.codigoproducto; codigopromocionallista = codigopromocionallista.split(";"); var codigopromocional = ""; for(aux = 0; aux < codigopromocionallista.length; aux++) { codigopromocional = codigopromocionallista[aux]; switch(codigopromocional){ case "FE_OPER_POS_MOVIL": if($('#Boleta-adicionales').val().indexOf("FE_OPER_POS_MOVIL") < 0){ document.getElementById('adPOS').checked = true; document.getElementById('btn-Adicionales').click(); } break; case "FE_OPER_IMPRESORA_MOVIL": if($('#Boleta-adicionales').val().indexOf("FE_OPER_IMPRESORA_MOVIL") < 0){ document.getElementById('adIB').checked = true; document.getElementById('btn-Adicionales').click(); } break; case "FE_OPER_KIT_VENTA": if($('#Boleta-adicionales').val().indexOf("FE_OPER_KIT_VENTA") < 0){ document.getElementById('adPV').checked = true; document.getElementById('btn-Adicionales').click(); } break; case "FE_OPER_IMPRESORA": if($('#Boleta-adicionales').val().indexOf("FE_OPER_IMPRESORA") < 0){ document.getElementById('adIF').checked = true; document.getElementById('btn-Adicionales').click(); } break; case "FE_INT_PROM": if(document.getElementById("Integrado").checked == false){ document.getElementById("Integrado").checked = true; } break; case "FE_MOD_REMUNE": if(document.getElementById("dteRE").checked == false){ compraLineaP1.dteRE.prop("checked", true); } break; case "FE_MOD_CTACTE": if(document.getElementById("dteCC").checked == false){ compraLineaP1.dteCC.prop("checked", true); } break; case "FE_MOD_CC": if(document.getElementById("dteCCS").checked == false){ compraLineaP1.dteCCS.prop("checked", true); } break; case "FE_MOD_COM": if(document.getElementById("dteCOM").checked == false){ compraLineaP1.dteCOM.prop("checked", true); } break; case "FE_MOD_IMPCV": if (document.getElementById("dteCV").checked == false) { compraLineaP1.dteCV.prop("checked", true); } break; case "FE_MOD_OCCLI": if (document.getElementById("dteOC").checked == false) { compraLineaP1.dteOC.prop("checked", true); } break; case "FE_MOD_INVT": if(document.getElementById("dteEX").checked == false){ compraLineaP1.dteEX.prop("checked", true); } break; case "FE_MOD_CONT": if(document.getElementById("dteCO").checked == false){ compraLineaP1.dteCO.prop("checked", true); } break; case "FE_MOD_CONTAB": if(document.getElementById("dteCTB").checked == false){ compraLineaP1.dteCTB.prop("checked", true); } break; case "FE_MOD_COMISI": if (document.getElementById("dteCOMI").checked == false) { compraLineaP1.dteCOMI.prop("checked", true); } break; case "FE_MOD_TIENDA": if (document.getElementById("creartiendaweb").checked == false) { compraLineaP1.tiendaweb.prop("checked", true); } break; case "FE_OPER_WEB": if(document.getElementById("webpay").checked == false){ document.getElementById("webpay").checked = true; } break; case "FE_MOD_TBK": if(document.getElementById("webpay").checked == false){ document.getElementById("webpay").checked = true; } break; } } } } catch (ex) {} }) .fail( function(jqXHR) { alert(jqXHR.responseText); return; }); } compraLineaP1.insert(); //return true; }, insert : function(){ $.ajax({ method: "post", dataType: "json", url: "compralinea/cmd.php", data: { cmd: 'GuardaContacto' , hash: hash , modificacotizacion: modificacotizacion , rut: this.rut.val() , razonsocial: this.razonsocial.val() , giro: this.giro.val() , direccion: this.direccion.val() , contacto: this.contacto.val() , email: this.correo.val() // POR ALEJANDRO MARTINEZ EN FECHA 05-04-2017. MOTIVO: REQUERIMIENTO 2101 --> , telefono: '+'+ititelefonocl.getSelectedCountryData().dialCode+document.getElementById('telefonocl').value // FIN REQUERIMIENTO 2101 --> , comuna: this.comuna.val() , region: this.region.val() , dte33: this.dte33.prop("checked") , dte34: this.dte34.prop("checked") , dte61: true , dte52: this.dte52.prop("checked") , dte56: true , dte39: (this.dte39.prop('checked') || this.dte41.prop('checked')) , dte46: this.dte46.prop("checked") , dte110: this.dte110.prop("checked") , dte43: this.dte43.prop("checked") , comercial: this.dteCOM.prop("checked") , contabilidad: this.dteCTB.prop("checked") , ctastes: this.dteCC.prop("checked") , existencias: this.dteEX.prop("checked") , contratos: this.dteCO.prop("checked") , comisiones: this.dteCOMI.prop("checked") , remuneraciones: this.dteRE.prop("checked") ,compraventa: this.dteCV.prop("checked") ,ordencompra: this.dteOC.prop("checked") , centrocostos: this.dteCCS.prop('checked') , integrado: $('input[name=Integrado]:checked').val() , codigodescuento: this.CodigoDescuento.val() , webpay: $('input[name=webpay]:checked').val() , respaldarxml: $('input[name=respaldarxml]:checked').val() , adicionales: $('#Boleta-adicionales').val() ,empresaref: $('#empresaref').val() ,country_id: ititelefonocl.getSelectedCountryData().iso2 //, flagcodigoasociado: document.getElementById("flag_codigoasociado").value ,origenredireccion: logCotizacionDemo , tiendaweb: $('input[name=creartiendaweb]:checked').val() } }) .done(function( json ) { if(json.error == undefined){ //OK compraLineaP1.idcontacto = json.idcontacto; compraLineaP1.validaCotiza(); }else{ /* if(json.error.indexOf("error codigoasociado") != -1){ $("#error_codigoasociado").dialog('open'); return false; } */ if( json.error.search(/PROMOCION/i) > 0 || json.error.search(/iguales/i) > 0 || json.error.search(/Finalizada/i) > 0){ $('#errorcodigodescuento').html( json.error ); }else{ if( json.error.search(/ABCDEFG/i) > 0 ){ //OK -- ES CODIGO DE VALIDACION compraLineaP1.CodigoDescuento.val(''); compraLineaP1.idcontacto = json.idcontacto; compraLineaP1.validaCotiza(); }else{ alert(json.error); } } } }); }, validaCotiza: function(){ $.ajax({ method: "post", url: "compralinea/cmd.php", data: { cmd: 'ValidaMail', hash: hash } }) .done(function( Valida ) { if(Valida == 'OK'){ compraLineaP1.cotizar(); }else{ $("#HTMLCorreo").html(compraLineaP1.correo.val()); $("#validaScreen").dialog('open'); codigoIngresado = false; setTimeout(function() { if (!codigoIngresado) { compraLineaP1.msgspam_mostrar(true); } }, 120000); } }); }, btnValidaCotiza: function(){ _codigo = compraLineaP1.codVerifica.val(); $.ajax({ method: "post", url: "compralinea/cmd.php", data: { cmd: 'ValidaCodigo', hash: hash, codigo: _codigo } }) .done(function( Valida ) { if(Valida == 'OK'){ codigoIngresado = true; $("#validaScreen").dialog('close'); compraLineaP1.cotizar(); }else{ alert(Valida); } }); }, cotizar : function(){ $("#loadingScreen").dialog('open'); _idcontacto = compraLineaP1.idcontacto; _hash_ = hash; try { document.getElementById("flag_codigoasociado").value="1"; } catch (ex) {} $.ajax({ method: "post", dataType: "json", url: "compralinea/cmd.php", data: { cmd: 'Cotizar', hash: hash, idcontacto: _idcontacto } }) .done(function( Cotiza ) { compraLineaP1.idcotiza = Cotiza.idcabecera; var url = LINK_COTIZACION + _hash_ + "&tt=" + compraLineaP1.contador + "&i=" + compraLineaP1.idcotiza + "&chk=" + Cotiza.chk + "&correo=" + Cotiza.correo +"&d=false&txtrut="+compraLineaP1.rut.val(); modificacotizacion = 'true'; $('.ui-dialog').css('z-index','2002'); $("#iCotiza").attr('src', url); $('#iCotiza').load(function(){ $("#dialog").dialog("open"); $(".ui-dialog-titlebar").hide(); $('.ui-dialog').css('position','fixed'); if(window.innerHeight>=900){ console.log("aqui2"); $('.ui-dialog').css('top', '95px'); }else{ $('.ui-dialog').css('top', '32px'); $('.ui-dialog').css('height', (window.innerHeight-64)+"px"); $('.ui-dialog').css('overflow-y', "scroll"); $('.ui-dialog-content').css('overflow-y', "hidden"); console.log("aqui"); } document.getElementById('iCotiza').height="99%"; $("#loadingScreen").dialog('close'); compraLineaP1.rut.attr('readonly', true); compraLineaP1.contador++; }); }); }, cargaData: function( _hash_ ){ $.ajax({ method: "post", dataType: "json", url: "compralinea/cmd.php", data: { cmd: 'cargaData', hash: _hash_ } }) .done(function( contacto ) { compraLineaP1.rut.val(contacto.rutempresa); compraLineaP1.razonsocial.val(contacto.razonsocial); compraLineaP1.giro.val(contacto.giro); compraLineaP1.direccion.val(contacto.direccion); compraLineaP1.region.val(contacto.region); compraLineaP1.LoadComuna(); compraLineaP1.comuna.val(contacto.comuna); compraLineaP1.contacto.val(contacto.contacto); compraLineaP1.correo.val(contacto.correo); // POR ALEJANDRO MARTINEZ EN FECHA 05-04-2017. MOTIVO: REQUERIMIENTO 2101 --> compraLineaP1.telefono.val(contacto.telefono_contacto); try { ititelefonocl.setNumber(contacto.telefono_contacto); if (contacto.codpaistelefono.trim() != "") { ititelefonocl.setCountry(contacto.codpaistelefono); } } catch (extel) { } // FIN REQUERIMIENTO 2101 --> compraLineaP1.CodigoDescuento.val(contacto.codigodescuento); compraLineaP1.dteDefecto.prop("checked", contacto.dte33); if (contacto.dte33 == true || contacto.dte34 == true) { var $el = $('#vermas-documentos-wrapper'); $el.show(); } compraLineaP1.dte34.prop("checked", contacto.dte34); compraLineaP1.dte52.prop('checked', contacto.dte52); compraLineaP1.dte39.prop("checked", contacto.dte39); compraLineaP1.dte46.prop("checked", contacto.dte46); compraLineaP1.dte110.prop("checked", contacto.dte110); compraLineaP1.dte43.prop("checked", contacto.dte43); compraLineaP1.dteCOM.prop("checked", contacto.comercial); compraLineaP1.dteCTB.prop("checked", contacto.contabilidad); compraLineaP1.dteCC.prop("checked", contacto.ctastes); compraLineaP1.dteCCS.prop("checked", contacto.centrocostos); compraLineaP1.dteEX.prop("checked", contacto.existencias); compraLineaP1.dteCO.prop("checked", contacto.contratos); compraLineaP1.dteRE.prop("checked", contacto.remuneraciones); compraLineaP1.dteCV.prop("checked", contacto.compraventa); compraLineaP1.dteOC.prop("checked", contacto.ordencompra); compraLineaP1.dteCOMI.prop("checked", contacto.comisiones); compraLineaP1.dte33.prop("checked", contacto.dte33); if( compraLineaP1.dte33.prop("checked") == true || compraLineaP1.dte34.prop("checked") == true ){ compraLineaP1.dteDefecto.prop("checked", true) ; } if (contacto.adicionales != "" && contacto.adicionales != null) { var arrayadicional = contacto.adicionales.split("|"); for (var i=0; i
"; $("#body-dialog-compra-linea").html(mensaje); $("#dialog-compra-linea").dialog({ width: 500, modal: true, title: "Campo Obligatorio" }); $("#dialog-compra-linea").prev(".ui-dialog-titlebar").css("background","#519131"); $("#dialog-compra-linea").prev(".ui-dialog-titlebar").find(".ui-button").css("display","none"); /*$(".ui-button").css("display", "none"); $(".ui-dialog-titlebar").css("background", "#519131"); $(".ui-widget-header").css("backgroud", "#519131");*/ $("#close-dialog-compra-linea").on("click", function() { $("#dialog-compra-linea").dialog("close"); }); } function mensajeDialogoConTitulo(mensaje, titulo) { mensaje = "
" + mensaje + "

"; $("#body-dialog-compra-linea").html(mensaje); $("#dialog-compra-linea").dialog({ width: 500, modal: true, title: titulo ? titulo : "Campo Obligatorio" }); $("#dialog-compra-linea").prev(".ui-dialog-titlebar").css("background","#519131"); $("#dialog-compra-linea").prev(".ui-dialog-titlebar").find(".ui-button").css("display","none"); /*$(".ui-button").css("display", "none"); $(".ui-dialog-titlebar").css("background", "#519131"); $(".ui-widget-header").css("backgroud", "#519131");*/ $("#close-dialog-compra-linea").on("click", function() { $("#dialog-compra-linea").dialog("close"); }); } function closeCotiza(){ //alert('TEST'); //alert(compraLineaP1.idcontacto); //compraLineaP1.vtnValida.dialog('close'); document.getElementById("validaScreen").style.visibility = "hidden"; } function habilitarRle(datos) { datos = datos || ''; if(datos == '') { $.ajax({ method: "post", dataType: "json", url: "compralinea/cmd.php", data: { cmd: 'cargaDataFI', hash: hash } }) .done(function( contacto ) { habilitarRle(contacto); }) return; } if ($("#datosRle").prop("checked") == true) { $("#runRle").prop("disabled", true); $("#nomRle").prop("disabled", true); $("#correoRle").prop("disabled", true); $("#confircorreoRle").prop("disabled", true); $("#runRle").val(datos.representante_rut); $("#nomRle").val(datos.representante_name); $("#correoRle").val(datos.representante_email); $("#confircorreoRle").val(datos.representante_email); } else { $("#runRle").val(""); $("#nomRle").val(""); $("#correoRle").val(""); $("#confircorreoRle").val(""); $("#runRle").prop("disabled", false); $("#nomRle").prop("disabled", false); $("#correoRle").prop("disabled", false); $("#confircorreoRle").prop("disabled", false); } } function cerrarVentana(){ compraLineaP2.clickAceptar = false; compraLineaP2.formValidado = false; $('#dialog1').dialog('close'); } function cancelarNombreEmpresa(){ compraLineaP2.clickAceptar = false; compraLineaP2.formValidado = false; $('#dialog1').dialog('close'); $('html, body').animate({scrollTop:0}, 'fast'); $("#empresaFI").focus(); } function aceptarNombreEmpresa(){ $('#dialog1').dialog('close'); compraLineaP2.guardarFormulario(true); } function uploadIMG () { return; if (arrayCedula.length <= 0) { alert("Debe subir al menos un archivo."); return; } var frm = new FormData(); if (arrayCedula.length >= 2) { var imagennueva = canvas.toDataURL(); frm.append("base64", encodeURIComponent(imagennueva.split("base64,")[1])); } else { frm.append("base64", encodeURIComponent(arrayCedula[0].src.split("base64,")[1])); } frm.append("ext", arrayCedula[0].ext); frm.append("hash", hash); $.ajax ({ url: "compralinea/uploadcedula.php" ,type: "POST" ,processData: false ,contentType: false ,dataType : "json" ,data: frm ,success: function(data) { if (data == "OK") { $("#checkSubido").css("display", ""); $('#dialog1').dialog('close'); } else { alert (data); } } ,error: function () { //alert ("Error no controlado por la aplicaci\xf3n."); } }); } function removerArchivo(posicionelemento) { return; arrayCedula.splice(posicionelemento, 1); $("#contenido_"+posicionelemento).remove(); $("#seleccionArchivo").prop("disabled", false); agregarArchivo(); } function vistaPreviaArchivo(tipo) { switch (tipo) { case "pdf": if (navigator.userAgent.indexOf("Trident") > -1) { var byteCharacters = atob(arrayCedula[0].src.split("base64,")[1]); var byteNumbers = new Array(byteCharacters.length); for (var i = 0; i < byteCharacters.length; i++) { byteNumbers[i] = byteCharacters.charCodeAt(i); } var byteArray = new Uint8Array(byteNumbers); var blob = new Blob([byteArray], { type: 'application/'+arrayCedula[0].ext }); window.navigator.msSaveOrOpenBlob(blob, arrayCedula[0].nombre); } else { var screenWidth = window.screen.width; var screenHeight = window.screen.height; $("#vistapreviaframe").dialog({ autoOpen: false, height: screenHeight / 2, width: screenWidth / 2, modal: true }); $("#framecedula").prop("src", arrayCedula[0].src); $("#framecedula").prop("height", screenHeight / 2); $("#framecedula").prop("width", screenWidth / 2); $("#vistapreviaframe").dialog('open'); } break; case "doc": case "docx": case "odt": if (navigator.userAgent.indexOf("Trident") > -1) { var byteCharacters = atob(arrayCedula[0].src.split("base64,")[1]); var byteNumbers = new Array(byteCharacters.length); for (var i = 0; i < byteCharacters.length; i++) { byteNumbers[i] = byteCharacters.charCodeAt(i); } var byteArray = new Uint8Array(byteNumbers); var blob = new Blob([byteArray], { type: 'application/'+arrayCedula[0].ext }); window.navigator.msSaveOrOpenBlob(blob, arrayCedula[0].nombre); } else { var href = document.createElement("a"); href.href = arrayCedula[0].src; href.download = arrayCedula[0].nombre; href.click(); } break; default: var screenWidth = window.screen.width; var screenHeight = window.screen.height; $("#vistapreviaframe").dialog({ autoOpen: false, height: screenHeight / 2, width: screenWidth / 2, modal: true }); $("#framecedula").prop("src", "compralinea/msg_vistapreviacedula.php"); $("#framecedula").prop("height", screenHeight / 2); $("#framecedula").prop("width", screenWidth / 2); $("#vistapreviaframe").dialog('open'); break; } } function agregarArchivo() { return; canvas.height = 0; ctx.clearRect(0,0, canvas.width, canvas.height); var contenido = ""; contador = 0; contadorheight = 0; for (let i = 0; i < arrayCedula.length; i++) { var nombreresumido = arrayCedula[i].nombre.length <= 15 ? arrayCedula[i].nombre : arrayCedula[i].nombre.substring(0, 15)+"..."; contenido += "
  "+ ""+ "
"; if ("pdf|doc|docx|odt|".indexOf (arrayCedula[i].ext + "|") == -1) { if (arrayCedula.length >= 2) { $("#seleccionArchivo").prop("disabled", true); } setHeightCanvas(arrayCedula[i].src); } else { $("#seleccionArchivo").prop("disabled", true); } } $("#contenidoCedula").prop("innerHTML", contenido); } function setHeightCanvas(imagen) { var img = new Image(); img.onload = function() { if (img.width > canvas.width) { contadornuevo = 0.99; do { var widthnuevo = img.width * contadornuevo; var heightnuevo = img.height * contadornuevo; contadornuevo -= 0.01; } while (widthnuevo > canvas.width); canvas.height += heightnuevo + contadorheight; for (i = 0; i < arrayCedula.length; i++) { generarImagen(arrayCedula[i].src); } contadorheight += 25; } else { canvas.height += img.height + contadorheight; for (i = 0; i < arrayCedula.length; i++) { generarImagen(arrayCedula[i].src); } contadorheight += 25; } } img.src = imagen; } function generarImagen(imagen) { var img = new Image(); img.onload = function() { if (img.width > canvas.width) { contadornuevo = 0.99; do { var widthnuevo = img.width * contadornuevo; var heightnuevo = img.height * contadornuevo; contadornuevo -= 0.01; } while (widthnuevo > canvas.width); ctx.drawImage(img, 0, contador, widthnuevo, heightnuevo); contador += heightnuevo+20; } else { ctx.drawImage(img, 0, contador); contador += img.height+20; } } img.src = imagen; } function seleccionFactura(elemento){ var $el = $('#vermas-documentos-wrapper'); if(elemento.checked == true){ $el.show(); } else { if(elemento.id == "dte336156"){ if(document.getElementById("dte39").checked == true && (document.getElementById("dte33").checked == true || document.getElementById("dte34").checked == true)){ document.getElementById("dte336156").checked = true; $("#alertaboleta").dialog({ autoOpen: false, height: 350, width: 700, modal: true, title: 'Importante', }); $('.ui-dialog .ui-widget-header').css('background', '#178419'); document.getElementById('btnboleta_si').setAttribute('onclick', 'document.getElementById("dte336156").checked = false;ocultarCheckFactura();$("#alertaboleta").dialog("close");') $("#alertaboleta").dialog("open"); }else{ ocultarCheckFactura(); } }else{ ocultarCheckFactura(); } } } function ocultarCheckFactura (){ var $el = $('#vermas-documentos-wrapper'); if ($el.is(':visible')) { $el.hide(); } var requiereFactura = $(".requiereFactura"); for (let i = 0; i < requiereFactura.length; i++) { requiereFactura[i].checked = false; } } function limpiarcadena(cadena){ cadena = cadena.trim(); cadena = cadena.toUpperCase(); cadena = cadena.replace(/\./g," "); cadena = cadena.replace(/Á/g,"A"); cadena = cadena.replace(/É/g,"E"); cadena = cadena.replace(/Í/g,"I"); cadena = cadena.replace(/Ó/g,"O"); cadena = cadena.replace(/Ú/g,"U"); return cadena; } function abrirModalAdicionalBoton(elemento){ try { let idelementobotonpadre = elemento.getAttribute('data-id'); let elementobotonpadre = document.getElementById(idelementobotonpadre); abrirModalAdicional(elementobotonpadre); } catch(ex){} } function abrirModalAdicional(elemento) { if (elemento.checked == true) { var adicionalClass = $(".content-item-producto"); for (let i = 0; i < adicionalClass.length; i++) { if (adicionalClass[i].id == "div_"+elemento.value) { adicionalClass[i].style.display = ""; } else { adicionalClass[i].style.display = "none"; } } $("#boletaFacilContenedor").dialog("open"); } else { var canMovil1 = (elemento.value == "FE_OPER_POS_MOVIL" ? 0 : document.getElementById('CantidadMovil').value); var canImpresion2 = (elemento.value == "FE_OPER_IMPRESORA_MOVIL" ? 0 : document.getElementById('CantidadImpresion').value); var canImpresora3 = (elemento.value == "FE_OPER_IMPRESORA" ? 0 : document.getElementById('CantidadImpresora').value); var canPunto4 = (elemento.value == "FE_OPER_KIT_VENTA" ? 0 : document.getElementById('CantidadPunto').value); var productos = { FE_OPER_POS_MOVIL: canMovil1, FE_OPER_IMPRESORA_MOVIL: canImpresion2, FE_OPER_IMPRESORA: canImpresora3, FE_OPER_KIT_VENTA: canPunto4 }; var nuevoValor = ''; for (var i = 0; i < Object.keys(productos).length; i++) { switch (Object.keys(productos)[i]) { case 'FE_OPER_POS_MOVIL': if ($("#adPOS").prop("checked") == true) { if (canMovil1 > 0) { $('.span-pm').css('display','inline-block'); nuevoValor += canMovil1+'-FE_OPER_POS_MOVIL | '; $(".span-pm").html(canMovil1); } else { $('#CantidadMovil').val("1"); $('.span-pm').css('display','none'); nuevoValor += ""; $("#adPOS").prop("checked", false); } } else { $('#CantidadMovil').val("1"); $('.span-pm').css('display','none'); nuevoValor += ""; $("#adPOS").prop("checked", false); } break; case 'FE_OPER_IMPRESORA_MOVIL': if ($("#adIB").prop("checked") == true) { if (canImpresion2 > 0) { $('.span-if').css('display','inline-block'); nuevoValor += canImpresion2+'-FE_OPER_IMPRESORA_MOVIL | '; $(".span-if").html(canImpresion2); } else { $('#CantidadImpresion').val("1"); $('.span-if').css('display','none'); nuevoValor += ""; $("#adIB").prop("checked", false); } } else { $('#CantidadImpresion').val("1"); $('.span-if').css('display','none'); nuevoValor += ""; $("#adIB").prop("checked", false); } break; case 'FE_OPER_IMPRESORA': if ($("#adIF").prop("checked") == true) { if (canImpresora3 > 0) { $('.span-iof').css('display','inline-block'); nuevoValor += canImpresora3+'-FE_OPER_IMPRESORA | '; $(".span-iof").html(canImpresora3); } else { $('#CantidadImpresora').val("1"); $('.span-iof').css('display','none'); nuevoValor += ""; $("#adIF").prop("checked", false); } } else { $('#CantidadImpresora').val("1"); $('.span-iof').css('display','none'); nuevoValor += ""; $("#adIF").prop("checked", false); } break; case 'FE_OPER_KIT_VENTA': if ($("#adPV").prop("checked") == true) { if (canPunto4 > 0) { $('.span-pv').css('display','inline-block'); nuevoValor += canPunto4+'-FE_OPER_KIT_VENTA | '; $(".span-pv").html(canPunto4); } else { $('#CantidadPunto').val("1"); $('.span-pv').css('display','none'); nuevoValor += ""; $("#adPV").prop("checked", false); } } else { $('#CantidadPunto').val("1"); $('.span-pv').css('display','none'); nuevoValor += ""; $("#adPV").prop("checked", false); } break; default: break; } } $('#Boleta-adicionales').val(nuevoValor); } } function validacertificado(e) { tecla = (document.all) ? e.keyCode : e.which; //Tecla de retroceso para borrar, siempre la permite if (tecla == 8) { return true; } // Patron de entrada, en este caso solo acepta numeros y letras patron = /[Aa.0-9]/; tecla_final = String.fromCharCode(tecla); return patron.test(tecla_final); } function validaEspacio(){ correoRep = document.getElementById("correoRle").value; for (var i = 0; i < correoRep.length; i++){ correoRep = correoRep.replace(" ",""); } document.getElementById("correoRle").value = correoRep; } function cargarAdicional() { $('.span-adicionales-boleta').css('display', 'none'); $('#Boleta-adicionales').val(''); var canMovil1 = document.getElementById('CantidadMovil').value; var canImpresion2 = document.getElementById('CantidadImpresion').value; var canImpresora3 = document.getElementById('CantidadImpresora').value; var canPunto4 = document.getElementById('CantidadPunto').value; var productos = { FE_OPER_POS_MOVIL : canMovil1, FE_OPER_IMPRESORA_MOVIL: canImpresion2, FE_OPER_IMPRESORA: canImpresora3, FE_OPER_KIT_VENTA: canPunto4 }; var nuevoValor = ''; for (var i = 0; i < Object.keys(productos).length; i++) { switch (Object.keys(productos)[i]) { case 'FE_OPER_POS_MOVIL': if ($("#adPOS").prop("checked") == true) { if (canMovil1 > 0) { $('.span-pm').css('display','inline-block'); nuevoValor += canMovil1+'-FE_OPER_POS_MOVIL | '; $(".span-pm").html(canMovil1); } else { $('#CantidadMovil').val("1"); $('.span-pm').css('display','none'); nuevoValor += ""; $("#adPOS").prop("checked", false); } } else { $('#CantidadMovil').val("1"); $('.span-pm').css('display','none'); nuevoValor += ""; $("#adPOS").prop("checked", false); } break; case 'FE_OPER_IMPRESORA_MOVIL': if ($("#adIB").prop("checked") == true) { if (canImpresion2 > 0) { $('.span-if').css('display','inline-block'); nuevoValor += canImpresion2+'-FE_OPER_IMPRESORA_MOVIL | '; $(".span-if").html(canImpresion2); } else { $('#CantidadImpresion').val("1"); $('.span-if').css('display','none'); nuevoValor += ""; $("#adIB").prop("checked", false); } } else { $('#CantidadImpresion').val("1"); $('.span-if').css('display','none'); nuevoValor += ""; $("#adIB").prop("checked", false); } break; case 'FE_OPER_IMPRESORA': if ($("#adIF").prop("checked") == true) { if (canImpresora3 > 0) { $('.span-iof').css('display','inline-block'); nuevoValor += canImpresora3+'-FE_OPER_IMPRESORA | '; $(".span-iof").html(canImpresora3); } else { $('#CantidadImpresora').val("1"); $('.span-iof').css('display','none'); nuevoValor += ""; $("#adIF").prop("checked", false); } } else { $('#CantidadImpresora').val("1"); $('.span-iof').css('display','none'); nuevoValor += ""; $("#adIF").prop("checked", false); } break; case 'FE_OPER_KIT_VENTA': if ($("#adPV").prop("checked") == true) { if (canPunto4 > 0) { $('.span-pv').css('display','inline-block'); nuevoValor += canPunto4+'-FE_OPER_KIT_VENTA | '; $(".span-pv").html(canPunto4); } else { $('#CantidadPunto').val("1"); $('.span-pv').css('display','none'); nuevoValor += ""; $("#adPV").prop("checked", false); } } else { $('#CantidadPunto').val("1"); $('.span-pv').css('display','none'); nuevoValor += ""; $("#adPV").prop("checked", false); } break; default: break; } } $('#Boleta-adicionales').val(nuevoValor); $("#boletaFacilContenedor").dialog('close'); return false; } function getObtenerResolucion(rutvalue) { $.getJSON("compralinea/cmd.php", { cmd: 'getNroResolucion', rut: rutvalue }) .done(function(json) { console.log(json); if (json.nroresolucion === undefined) { json.nroresolucion = "sinresol"; } $("#framerespaldarxml").attr('data-resol', json.nroresolucion) if (json.nroresolucion == '99') { $("#respaldarxml").prop('checked', true); if ($("#btnservicios").attr('abierto') == 'false') { mostrarocultar(); } } else { $("#respaldarxml").prop('checked', false); } }); } function verificarCotizacionAnterior(rutempresa){ $.getJSON("compralinea/cmd.php", { cmd: 'verificaCotizacion', rut: rutempresa }) .done(function(json) { var resp = json; if(resp.hash != null ){ document.getElementById("pop-ya-cotizado").style.display = ""; var correo = resp.correo; document.getElementById("correoToolCotizacion").innerHTML = correo; document.getElementById("linkreenviacotiza").setAttribute("onclick", "javascript:reenviarCotizacion('" +resp.hash+"')"); } }); } function reenviarCotizacion(hash){ $.getJSON("compralinea/cmd.php", { cmd: 'ReenvioCotizacion', hash: hash }) .done(function(json) { if(json == "OK"){ $("#msgcotizacionenviada").dialog({ autoOpen: false, height: 230, width: 590, modal: true, title : 'Cotización Enviada', }); $('.ui-dialog .ui-widget-header').css('background','#519131'); $(".ui-dialog-title").css('text-align', 'center'); $(".ui-dialog-title").css('width', '100%'); $("#msgcotizacionenviada").dialog('open'); $("#msgcotizacionenviada").on('dialogclose', function(event){ $('#pop-ya-cotizado').hide(); }); } }); }