var total = 0; var docs = 0; function pagarMall(iddocumento,monto,tipo){ var tipomov = arguments[3].charAt(0); var descripcion = tipo; var porPagar = Array(); if (monto == 0){ var total = VerTotal(); if (total == 0){ alert('Debe seleccionar al menos un documento'); return false; } }else { var total = monto; } var sistema = "ariex1"; var rutreceptor = document.getElementById('txtrut') != null ? document.getElementById('txtrut').value : document.getElementById('rutreceptor').value ; if (tipo == "tud"){ var tipomov = arguments[3].charAt(0); var tipodte = arguments[3].slice(-2); if (tipomov == 'C'){ porPagar.push([iddocumento]); }else { porPagar.push([iddocumento,tipomov,tipodte]); } }else { var monto = total; var cls = document.getElementsByClassName('documentosChk'); for (var i = 0; i < cls.length; i++) { if (cls [i].checked) { var iddocumento = cls [i].name; var tipomov = cls[i].dataset['log'].charAt(0); var tipodte = cls[i].dataset['log'].slice(-2); porPagar.push([iddocumento,tipomov,tipodte]); } } } abrirLightbox(porPagar,descripcion,sistema,rutreceptor,monto,tipomov); return; } function VerTotal () { var cls = document.getElementsByClassName('documentosChk'); var total = 0; for (var i = 0; i < cls.length; i++) { if (cls [i].checked) { total += cls[i].value * 1; } } return total; } function abrirLightbox(iddocumento,descripcion,sistema,rutreceptor,monto,tipomov){ if (tipomov == "C"){ var arrStr = iddocumento; }else { var arrStr = encodeURIComponent(JSON.stringify(iddocumento)); } window.open("http://www.facturacion.cl/ariex1/panel/pagar.php?iddocumento="+arrStr+"&descripcion="+descripcion+"&sistema="+sistema+"&rutreceptor="+rutreceptor+"&monto="+monto+"&tipomov="+tipomov, '_blank'); }