✏️ 正在编辑: global.js
路径:
/srv/systems_dir/yuppiecred/public/scripts/global.js
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
// =================================================================== // Author: Matt Kruse <matt@mattkruse.com> // WWW: http://www.mattkruse.com/ // // NOTICE: You may use this code for any purpose, commercial or // private, without any further permission from the author. You may // remove this notice from your final code if you wish, however it is // appreciated by the author if at least my web site address is kept. // // You may *NOT* re-distribute this code in any way except through its // use. That means, you can include it in your product, or your web // site, or any other form where the code is actually being used. You // may not put the plain javascript up on your site for download or // include it in your javascript libraries for download. // If you wish to share this code with others, please just point them // to the URL instead. // Please DO NOT link directly to my .js files from your site. Copy // the files to your server and use them there. Thank you. // =================================================================== // HISTORY // ------------------------------------------------------------------ // February 29, 2004: Fixed bug caused by LAST update, when control // checkbox is the first on checked. I hate when that happens. // January 28, 2004: Fixed bug that occurred when checkbox was CHECKED // by default. // December 16, 2002: Created /* Original coding done by David Rogers - http://www.MrDaveR.com/ DESCRIPTION: This library lets you quickly and easily make multiple checkboxes behave as a group by limiting the total number of boxes that can be checked and/or have a master control checkbox. COMPATABILITY: Should work on all Javascript-compliant browsers. USAGE: // Create a new CheckBoxGroup object var myOptions = new CheckBoxGroup(); // Tell the object which checkboxes exist in your group. You may make multiple // calls to this function, and/or pass multiple arguments. You may specify // field names exactly, or use a wildcard at the beginning or end of the // name. myOptions.addToGroup("cb1","cb2","optionset*"); myOptions.addToGroup("*checkbox"); // Optionally set a "control" box which will effect all other boxes. myOptions.setControlBox("masterCheckboxName"); // Specify how your control box will interact with the group. Options are // either "some" or "all" ("all" is default). // all: Checking the box will select all the other boxes. Unchecking it will // uncheck all the group checkboxes. Selecting all the checkboxes in // the group will automatically check the control box. // some: Checking any checkbox in the group will check the control box. The // control box may not be unchecked if any option in the group is // still checked. If no boxes in the group are checked, you may still // check the control box. myOptions.setMasterBehavior("some"); // Optionally set the maximum number of boxes in the group which are allowed // to be checked. You may pass a second argument which is an alert message to // be displayed to the user if they exceed this limit. myOptions.setMaxAllowed(3); myOptions.setMaxAllowed(3,"You may only select 3 choices!"); // IMPORTANT: After defining the group and behavior, you must insert an action // into EVERY checkbox's onClick event-handler. Just specify the name of the // group object that the checkbox belongs to, and pass it 'this' as the argument. <INPUT TYPE="checkbox" NAME="cb1" onClick="myOptions.check(this)"> // That's it! Your checkboxes will now behave as a group! */ function CheckBoxGroup() { this.controlBox = null; this.controlBoxChecked = null; this.maxAllowed = null; this.maxAllowedMessage = null; this.masterBehavior = null; this.formRef = null; this.checkboxWildcardNames = new Array(); this.checkboxNames = new Array(); this.totalBoxes = 0; this.totalSelected = 0; // Public methods this.setControlBox = CBG_setControlBox; this.setMaxAllowed = CBG_setMaxAllowed; this.setMasterBehavior = CBG_setMasterBehavior; // all, some this.addToGroup = CBG_addToGroup; // Private methods this.expandWildcards = CBG_expandWildcards; this.addWildcardCheckboxes = CBG_addWildcardCheckboxes; this.addArrayCheckboxes = CBG_addArrayCheckboxes; this.addSingleCheckbox = CBG_addSingleCheckbox; this.check = CBG_check; } // Set the master control checkbox name function CBG_setControlBox(name) { this.controlBox = name; } // Set the maximum number of checked boxes in the set, and optionally // the message to popup when the max is reached. function CBG_setMaxAllowed(num, msg) { this.maxAllowed = num; if (msg != null && msg != "") { this.maxAllowedMessage = msg; } } // Set the behavior for the checkbox group master checkbox // All: all boxes must be checked for the master to be checked // Some: one or more of the boxes can be checked for the master to be checked function CBG_setMasterBehavior(b) { this.masterBehavior = b.toLowerCase(); } // Add checkbox wildcards to the checkboxes array function CBG_addToGroup() { if (arguments.length > 0) { for (var i = 0; i < arguments.length; i++) { this.checkboxWildcardNames[this.checkboxWildcardNames.length] = arguments[i]; } } } // Expand the wildcard checkbox names given in the addToGroup method function CBG_expandWildcards() { if (this.formRef == null) { alert("ERROR: No form element has been passed. Cannot extract form name!"); return false; } for (var i = 0; i < this.checkboxWildcardNames.length; i++) { var n = this.checkboxWildcardNames[i]; var el = this.formRef[n]; if (n.indexOf("*") != -1) { this.addWildcardCheckboxes(n); } else if (CBG_nameIsArray(el)) { this.addArrayCheckboxes(n); } else { this.addSingleCheckbox(el); } } } // Add checkboxes to the group which match a pattern function CBG_addWildcardCheckboxes(name) { var i = name.indexOf("*"); if ((i == 0) || (i == name.length - 1)) { searchString = (i) ? name.substring(0, name.length - 1) : name.substring(1, name.length); for (var j = 0; j < this.formRef.length; j++) { currentElement = this.formRef.elements[j]; currentElementName = currentElement.name; var partialName = (i) ? currentElementName.substring(0, searchString.length) : currentElementName.substring(currentElementName.length - searchString.length, currentElementName.length); if (partialName == searchString) { if (CBG_nameIsArray(currentElement)) this.addArrayCheckboxes(currentElement); else this.addSingleCheckbox(currentElement); } } } } // Add checkboxes to the group which all have the same name function CBG_addArrayCheckboxes(name) { if ((CBG_nameIsArray(this.formRef[name])) && (this.formRef[name].length > 0)) { for (var i = 0; i < this.formRef[name].length; i++) { this.addSingleCheckbox(this.formRef[name][i]); } } } function CBG_addSingleCheckbox(obj) { if (obj != this.formRef[this.controlBox]) { this.checkboxNames[this.checkboxNames.length] = obj; this.totalBoxes++; if (obj.checked) { this.totalSelected++; } } } // Runs whenever a checkbox in the group is clicked function CBG_check(obj) { var checked = obj.checked; if (this.formRef == null) { this.formRef = obj.form; this.expandWildcards(); if (this.controlBox == null || obj.name != this.controlBox) { this.totalSelected += (checked) ? -1 : 1; } } if (this.controlBox != null && obj.name == this.controlBox) { if (this.masterBehavior == "all") { for (i = 0; i < this.checkboxNames.length; i++) { this.checkboxNames[i].checked = checked; } this.totalSelected = (checked) ? this.checkboxNames.length : 0; } else { if (!checked) { obj.checked = (this.totalSelected > 0) ? true : false; obj.blur(); } } } else { if (this.masterBehavior == "all") { if (!checked) { this.formRef[this.controlBox].checked = false; this.totalSelected--; } else { this.totalSelected++; } if (this.controlBox != null) { this.formRef[this.controlBox].checked = (this.totalSelected == this.totalBoxes) ? true : false; } } else { if (!obj.checked) { this.totalSelected--; } else { this.totalSelected++; } if (this.controlBox != null) { this.formRef[this.controlBox].checked = (this.totalSelected > 0) ? true : false; } if (this.maxAllowed != null) { if (this.totalSelected > this.maxAllowed) { obj.checked = false; this.totalSelected--; if (this.maxAllowedMessage != null) { alert(this.maxAllowedMessage); } return false; } } } } } function CBG_nameIsArray(obj) { return ((typeof obj.type != "string") && (obj.length > 0) && (obj[0] != null) && (obj[0].type == "checkbox")); } /*Menu Drop-down*/ function getElementsByClassName(oElm, strTagName, strClassName) { var arrElements = (strTagName == "*" && oElm.all) ? oElm.all : oElm.getElementsByTagName(strTagName); var arrReturnElements = new Array(); strClassName = strClassName.replace(/\-/g, "\\-"); var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)"); var oElement; for (var i = 0; i < arrElements.length; i++) { oElement = arrElements[i]; if (oRegExp.test(oElement.className)) { arrReturnElements.push(oElement); } } return (arrReturnElements) } startList = function () { nodes = getElementsByClassName(document, 'ul', 'navigation'); navRoot = nodes[0]; if(navRoot != null){ for (i = 0; i < navRoot.childNodes.length; i++) { node = navRoot.childNodes[i]; if (node.nodeName == "LI") { node.onmouseover = function () { this.className += " over"; } node.onmouseout = function () { this.className = this.className.replace(" over", ""); } } } } } window.onload = startList; /*FIM DO MENU DROP-DOWN*/ //Abrir caixa de dialogo modal function openDialog(obj, url) { $("#" + obj).load(url).dialog({ height: 600, width: 980, modal: true, close: function (event, ui) { $(obj).dialog('destroy'); } }); } function openDivDialog(obj) { $(obj).dialog({ width: 800, height: 600, modal: true, resizable: false, close: function (event, ui) { $(obj).dialog('destroy'); } }); } /** * Mascaras */ function mascara(o, f) { v_obj = o v_fun = f setTimeout("execmascara()", 1) } function execmascara() { v_obj.value = v_fun(v_obj.value) } function leech(v) { v = v.replace(/o/gi, "0") v = v.replace(/i/gi, "1") v = v.replace(/z/gi, "2") v = v.replace(/e/gi, "3") v = v.replace(/a/gi, "4") v = v.replace(/s/gi, "5") v = v.replace(/t/gi, "7") return v } function soNumeros(v) { return v.replace(/[^0-9-]/g, "") } function cpfCnpj(v) { //Remove tudo o que não é dígito v = v.replace(/\D/g, "") if (v.length < 14) { //CPF //Coloca um ponto entre o terceiro e o quarto dígitos v = v.replace(/(\d{3})(\d)/, "$1.$2") //Coloca um ponto entre o terceiro e o quarto dígitos //de novo (para o segundo bloco de números) v = v.replace(/(\d{3})(\d)/, "$1.$2") //Coloca um hífen entre o terceiro e o quarto dígitos v = v.replace(/(\d{3})(\d{1,2})$/, "$1-$2") } else { //CNPJ v = v.replace(/^(\d{2})(\d{3})?(\d{3})?(\d{4})?(\d{2})?/, "$1.$2.$3/$4-$5"); } return v; } function telefone(v) { v = v.replace(/\D/g, "") //Remove tudo o que não é dígito v = v.replace(/^(\d\d)(\d)/g, "($1) $2") //Coloca parênteses em volta dos dois primeiros dígitos v = v.replace(/(\d)(\d{4})$/, "$1-$2") //Coloca hífen antes dos últimos 4 dígitos return v } function fcpf(v) { v = v.replace(/\D/g, "") //Remove tudo o que não é dígito v = v.replace(/(\d{3})(\d)/, "$1.$2") //Coloca um ponto entre o terceiro e o quarto dígitos v = v.replace(/(\d{3})(\d)/, "$1.$2") //Coloca um ponto entre o terceiro e o quarto dígitos //de novo (para o segundo bloco de números) v = v.replace(/(\d{3})(\d{1,2})$/, "$1-$2") //Coloca um hífen entre o terceiro e o quarto dígitos return v } function data(v) { v = v.replace(/\D/g, "") v = v.replace(/(\d{2})(\d)/, "$1/$2") v = v.replace(/(\d{2})(\d)/, "$1/$2") return v } function mesAno(v) { v = v.replace(/\D/g, "") v = v.replace(/(\d{2})(\d)/, "$1/$2") return v } function fcep(v) { v = v.replace(/\D/g, "") //Remove tudo o que não é dígito v = v.replace(/^(\d{5})(\d)/, "$1-$2") //Esse é tão fácil que não merece explicações return v } function fcnpj(v) { v = v.replace(/\D/g, "") //Remove tudo o que não é dígito v = v.replace(/^(\d{2})(\d)/, "$1.$2") //Coloca ponto entre o segundo e o terceiro dígitos v = v.replace(/^(\d{2})\.(\d{3})(\d)/, "$1.$2.$3") //Coloca ponto entre o quinto e o sexto dígitos v = v.replace(/\.(\d{3})(\d)/, ".$1/$2") //Coloca uma barra entre o oitavo e o nono dígitos v = v.replace(/(\d{4})(\d)/, "$1-$2") //Coloca um hífen depois do bloco de quatro dígitos return v } function romanos(v) { v = v.toUpperCase() //Maiúsculas v = v.replace(/[^IVXLCDM]/g, "") //Remove tudo o que não for I, V, X, L, C, D ou M //Essa é complicada! Copiei daqui: http://www.diveintopython.org/refactoring/refactoring.html while (v.replace(/^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/, "") != "") v = v.replace(/.$/, "") return v } function site(v) { v = v.replace(/^http:\/\/?/, "") dominio = v caminho = "" if (v.indexOf("/") > -1) dominio = v.split("/")[0] caminho = v.replace(/[^\/]*/, "") dominio = dominio.replace(/[^\w\.\+-:@]/g, "") caminho = caminho.replace(/[^\w\d\+-@:\?&=%\(\)\.]/g, "") caminho = caminho.replace(/([\?&])=/, "$1") if (caminho != "") dominio = dominio.replace(/\.+$/, "") v = "http://" + dominio + caminho return v } function hora(v) { v = v.replace(/\D/g, "") //Remove tudo o que não é dígito v = v.replace(/(\d{2})(\d)/, "$1:$2") //Coloca um ponto entre o segundo e o terceiro dígitos return v } function horMinSeg(v) { v = v.replace(/\D/g, "") //Remove tudo o que não é dígito v = v.replace(/(\d{2})(\d)/, "$1:$2") //Coloca dois pontos entre o segundo e o terceiro dígito v = v.replace(/(\d{2})(\d)/, "$1:$2") //Coloca dois pontos entre o quarto e o quito dígito return v } function maiusculo(v) { v.value = v.value.toUpperCase(); } function mvalor(v) { v = v.replace(/\D/g, ""); //Remove tudo o que não é dígito v = v.replace(/(\d)(\d{8})$/, "$1.$2"); //coloca o ponto dos milhões v = v.replace(/(\d)(\d{5})$/, "$1.$2"); //coloca o ponto dos milhares v = v.replace(/(\d)(\d{2})$/, "$1,$2"); //coloca a virgula antes dos 2 últimos dígitos return v.toLocaleString('pt-br',{style: 'currency', currency: 'BRL'}); } function mvalor3(v) { v = v.replace(/\D/g, ""); //Remove tudo o que não é dígito v = v.replace(/(\d)(\d{9})$/, "$1.$2"); //coloca o ponto dos milhões v = v.replace(/(\d)(\d{6})$/, "$1.$2"); //coloca o ponto dos milhares v = v.replace(/(\d)(\d{1,3}$)/, "$1,$2") //coloca a virgula antes dos 3 últimos dígitos return v; } function mfator(v) { v = v.replace(/\D/g, ""); //Remove tudo o que não é dígito v = v.replace(/(\d)(\d{1,6}$)/, "$1,$2") //coloca a virgula antes dos 6 últimos dígitos return v; } /*Fim das mascaras*/ function relogio() { momentoAtual = new Date() hora = momentoAtual.getHours() minuto = momentoAtual.getMinutes() segundo = momentoAtual.getSeconds() horaImprimivel = hora + " : " + minuto + " : " + segundo document.getElementById("relogio").value = horaImprimivel setTimeout("relogio()", 1000) } function openWin(url, width, height, scrollbar) { //pega a resolucao do visitante w = screen.width; h = screen.height; //divide a resolucao por 2, obtendo o centro do monitor meio_w = w / 2; meio_h = h / 2; //diminui o valor da metade da resolucao pelo tamanho da janela, fazendo com q ela fique centralizada altura2 = height / 2; largura2 = width / 2; meio1 = meio_h - altura2; meio2 = meio_w - largura2; return window.open(url, "", "menubar=1,resizable=0,location=0,status=1,scrollbars=" + scrollbar + ", width=" + width + ",height=" + height + ", top=" + meio1 + ", left=" + meio2); } function confirmaLink(url) { if (confirm('Tem certeza que deseja executar essa operação?', url)) { window.location = url; } return false; } function validarForm(form) { var f = form; var cont = 0; for (i = 0; i < f.elements.length; i++) { if (f.elements[i].className == "require" && f.elements[i].value == "") { alert('Atenção! Preencha todos os campos corretamente.'); f.elements[i].focus(); f.elements[i].style.borderColor = "#DF1B1B"; return false; break; } else { f.elements[i].style.borderColor = ""; } } return true; } function validarChecks(form, noFeedback) { var cont = 0; noFeedback = noFeedback || 0 ; for (i = 0; i < form.elements.length; i++) { if (form.elements[i].type == "checkbox" && form.elements[i].checked == true) { cont++; } } if (cont <= 0) { if(!noFeedback) { alert("Marque pelo menos um item."); } return false; } return true; } function number_format(number, decimals, dec_point, thousands_sep) { var n = number, prec = decimals; n = !isFinite(+n) ? 0 : +n; prec = !isFinite(+prec) ? 0 : Math.abs(prec); var sep = (typeof thousands_sep == "undefined") ? ',' : thousands_sep; var dec = (typeof dec_point == "undefined") ? '.' : dec_point; var s = (prec > 0) ? n.toFixed(prec) : Math.round(n).toFixed(prec); //fix for IE parseFloat(0.55).toFixed(0) = 0; var abs = Math.abs(n).toFixed(prec); var _, i; if (abs >= 1000) { _ = abs.split(/\D/); i = _[0].length % 3 || 3; _[0] = s.slice(0, i + (n < 0)) + _[0].slice(i).replace(/(\d{3})/g, sep + '$1'); s = _.join(dec); } else { s = s.replace('.', dec); } return s; } function floatToString(number) { return number_format(number, 2, ',', '.'); } function stringToFloat(number) { return parseFloat(number.replace(" ", "").replace(/\./g, '').replace(',', '.') ); } function getTotalSum(selector){ var values = $(selector).map(function (){ if(this.getAttribute("data-estornado") == 1){ console.log(-stringToFloat($(this).html())); return -(stringToFloat($(this).html())); } return stringToFloat($(this).html()); }).get(); return values.reduce(function(a, b) { return a + b; }, 0); } //setar cor de linha e modificar totalizador function selecionarLinha(seletor) { $(seletor).click(function (event) { if (event.target.type !== 'checkbox' && $(':checkbox', $(this).parents('tr:first')).length) { $(':checkbox', $(this).parents('tr:first')).trigger('click'); } }); } $(document).ready(function () { $('table.selecionar tbody tr') .filter(':has(:checkbox:checked)') .addClass('selected') .end() .click(function (event) { if (event.target.type !== 'checkbox') { $(':checkbox', this).trigger('click'); } }) .find(':checkbox') .click(function (event) { $(this).parents('tr:first').toggleClass('linha_selecionada'); }); $('table tbody tr td.selecionar').parent() .filter(':has(:checkbox:checked)') .addClass('selected') .end() .click(function (event) { if (event.target.type !== 'checkbox') { $(':checkbox', this).trigger('click'); } }) .find(':checkbox') .click(function (event) { $(this).parents('tr:first').toggleClass('linha_selecionada'); }); $('.adicionar_fisico') .filter(':has(:checkbox:checked)') .addClass('selected') .end() .click(function (event) { if (event.target.type !== 'checkbox') { $(':checkbox', this).trigger('click'); } }) .find(':checkbox') .click(function (event) { $(this).parents('tr:first').toggleClass('linha_selecionada'); }); }); var myOptions = new CheckBoxGroup(); myOptions.setControlBox("control"); myOptions.addToGroup("checks[]"); myOptions.setMasterBehavior("all"); function bloqueio() { jQuery.fn.extend({ disableSelection: function () { return this.each(function () { this.onselectstart = function () { return false; }; this.unselectable = "on"; jQuery(this).css('user-select', 'none'); jQuery(this).css('-o-user-select', 'none'); jQuery(this).css('-moz-user-select', 'none'); jQuery(this).css('-khtml-user-select', 'none'); jQuery(this).css('-webkit-user-select', 'none'); }); }, disableSelectedAll: function () { return this.each(function () { this.onkeydown = function (event) { if (event.ctrlKey && (event.keyCode == 65 || event.keyCode == 97)) { event.preventDefault(); } }; }); } }); $(document).disableSelection(); $(document).disableSelectedAll(); $(document).bind('contextmenu', function (event) { event.preventDefault(); }); } //window.onload = bloqueio(); function hideShowTableColumn(element) { var theTable = $("#sortedTable"); cols = $(element).val(); colspan = theTable.find('thead tr:eq(0) td:eq(0)').attr('colspan'); if (colspan > 0) { theTable.find('thead tr:eq(1) *:nth-child(' + cols + ')').toggle(); } else { theTable.find('thead tr:eq(0) *:nth-child(' + cols + ')').toggle(); } theTable.find('tbody tr *:nth-child(' + cols + ')').toggle(); theTable.find('tfoot tr *:nth-child(' + cols + ')').toggle(); theTable.find("tfoot td").attr('colspan', cols.length); } function soLetras(e) { var expressao; expressao = /[a-zA-Z]/; if (expressao.test(String.fromCharCode(e.keyCode))) { return true; } else { return false; } } function toArray(arrLike) { return [].slice.call(arrLike); } function resetElements(form) { var frm_elements = form.elements; for (i = 0; i < frm_elements.length; i++) { field_type = frm_elements[i].type.toLowerCase(); switch (field_type) { case "text": case "date": case "password": case "textarea": case "hidden": form.elements[i].value = ""; break; case "radio": case "checkbox": if (frm_elements[i].checked) { frm_elements[i].checked = false; } break; case "select-one": case "select-multi": frm_elements[i].selectedIndex = -1; break; case "select-multiple": $(frm_elements[i]).multipleSelect(); $(frm_elements[i]).val([]); if($(frm_elements[i]).hasClass('status')){ $(frm_elements[i]).val(['43']); } $(frm_elements[i]).multipleSelect('refresh'); break; default: break; } } } $('.ponto-tipo').on('change', function () { if ($(this).val() == 2) { tipoHoraResolve(); return false; } tipoDataResolve(); }); $('#data_inicial').on('change', function () { if ($('#tipo').val() == 2) { copyDataInicialFinal(); } }); function copyDataInicialFinal() { var data = $('#data_inicial').val(); $('#data_final').val(data); $('#data_hidden').val(data); } function tipoHoraResolve() { copyDataInicialFinal(); var horas = $('.ponto-horas'); $('#data_final').hide(); $('#data_hidden').show() horas.css('background-color', '#FFF'); horas.removeAttr('readOnly'); horas.show(); } function tipoDataResolve() { var horas = $('.ponto-horas'); var dataFinal = $('#data_final'); horas.attr('readOnly', 'readOnly'); horas.css('background-color', '#C0C0C0'); dataFinal.css('background-color', '#FFF'); dataFinal.show(); dataFinal.removeAttr('readOnly'); $('#data_hidden').hide() } function sincronizarBanco(banco) { $('#loadingDiv').show(); if (banco === null || banco === '') { $('#loadingDiv').hide(); alert('Não configurado.'); return false; } $.ajax({ url: baseUrl + '/sincronizacao/sincronizar-banco', data: { banco: banco }, dataType: 'json', success: function(result) { if (result.alert) { $('#loadingDiv').hide(); alert(result.alert); return false; } if (result.erro) { $('#loadingDiv').hide(); alert(result.erro); return false; } $('#loadingDiv').hide(); alert('Sincronização realizada com sucesso!'); }, error: function() { $('#loadingDiv').hide(); alert('Ocorreu um erro durante a sincronização.'); } }); } $(document).on('ready', function () { $('#send_termo').on('click', function () { $("#loadingDiv").show(); var corretor = $('#corretor_id').val(); var termoId = $('#termo_id').val(); var acesso = $('#grupo_acesso').val(); $.ajax({ type: "POST", dataType: "JSON", url: baseUrl + '/ajax/checar-termo-enviado', data: { corretor: corretor, termo_id: termoId, tipo_acesso: acesso }, success: function (result) { if (!result.resend) { $("#loadingDiv").hide(); enviarTermo(corretor, termoId, acesso); return false; } if (result.resend) { $("#loadingDiv").hide(); Swal.fire('Documento já enviado', 'Verifique na listagem de termos enviados.', 'error') return false; } }, error: function () { $("#loadingDiv").hide(); Swal.fire('Falha na solicitação', '', 'error') } }) }); }); function enviarTermo(corretorId, termoId, acesso) { swal.fire({ title: 'Deseja enviar o termo de autenticidade para este corretor?', showDenyButton: true, showCancelButton: true, confirmButtonText: 'sim', denyButtonText: 'cancelar', }).then(function (result) { if (result.isConfirmed) { $("#loadingDiv").show(); $.ajax({ type: "POST", dataType: "JSON", url: baseUrl + '/termo-responsabilidade/enviar-termo-corretor', data: { corretor: corretorId, termo_id: termoId, tipo_acesso: acesso }, success: function (result) { if (result.alert) { $("#loadingDiv").hide(); Swal.fire('Falha na solicitação', result.alert, 'error') return false; } $("#loadingDiv").hide(); Swal.fire('Sucesso', result.success, 'success'); window.location.reload(); }, error: function () { $("#loadingDiv").hide(); Swal.fire('Falha na solicitação', '', 'error') } }) return false; } }); } function reenviarTermo(corretorId, termoId, acesso) { $("#loadingDiv").hide(); Swal.fire({ title: "Existe uma assinatura pendente para este corretor. Deseja Reenviar?", showDenyButton: true, showCancelButton: true, confirmButtonText: 'sim', denyButtonText: 'cancelar', }).then(function (result) { if (result.isConfirmed) { $("#loadingDiv").show(); $.ajax({ type: "POST", dataType: "JSON", url: baseUrl + '/termo-responsabilidade/reenviar-termo-corretor', data: { corretor: corretorId, termo_id: termoId, tipo_acesso: acesso }, success: function (result) { if (result.alert) { $("#loadingDiv").hide(); Swal.fire('Falha na solicitação', result.alert, 'error') return false; } $("#loadingDiv").hide(); Swal.fire('Sucesso', result.success, 'success'); }, error: function () { $("#loadingDiv").hide(); Swal.fire('Falha na solicitação', '', 'error') } }) } }); } function excluirTermoEnviado(termoId, corretorId) { $("#loadingDiv").hide(); if ($('.data_assinatura_' + termoId).html() !== '') { Swal.fire({ title: "O documento já foi assinado. Deseja realmente excluir?", showDenyButton: true, showCancelButton: true, confirmButtonText: 'sim', denyButtonText: 'cancelar', icon: "warning", }).then(function (result) { if (result.isConfirmed) { excluirTermoExecutar(termoId, corretorId); } }); return false; } excluirTermoExecutar(termoId, corretorId); } function excluirTermoExecutar(termoId, corretorId) { $("#loadingDiv").show(); $.ajax({ type: "POST", dataType: "JSON", url: baseUrl + '/termo-responsabilidade/delete-termo-enviado', data: { termo_id: termoId, corretor_id: corretorId }, success: function (result) { if (result.alert) { $("#loadingDiv").hide(); Swal.fire('Falha na solicitação', result.alert, 'error') return false; } $($('.data_assinatura_' + termoId).parents("tr")).remove() $("#loadingDiv").hide(); Swal.fire('Sucesso', result.success, 'success'); }, error: function () { $("#loadingDiv").hide(); Swal.fire('Falha na solicitação', '', 'error') } }) } function incluirDocTermo(docId) { if (!(docId > 0)) { return false; } var obj = $('#documento_' + docId); var checked = obj.is(":checked"); $("#loadingDiv").show(); $.ajax({ type: "POST", dataType: "JSON", data: { id: docId, incluir_termo: checked, }, url: baseUrl + "/termo-responsabilidade/incluir-doc-termo", success: function (result) { $("#loadingDiv").hide(); if (result.success) { Swal.fire('Sucesso', result.success, 'success'); } if (result.alert) { Swal.fire('Atenção', result.alert, 'error'); } }, error: function (msg) { $("#loadingDiv").hide(); Swal.fire('Falha na solicitação', msg, 'error'); console.log(msg); } }); } function validarCPF(cpf) { cpf = cpf.replace(/[^\d]+/g,''); if (cpf == '') return false; // Elimina CPFs invalidos conhecidos if (cpf.length != 11 || cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999") return false; // Valida 1o digito add = 0; for (i=0; i < 9; i ++) add += parseInt(cpf.charAt(i)) * (10 - i); rev = 11 - (add % 11); if (rev == 10 || rev == 11) rev = 0; if (rev != parseInt(cpf.charAt(9))) return false; // Valida 2o digito add = 0; for (i = 0; i < 10; i ++) add += parseInt(cpf.charAt(i)) * (11 - i); rev = 11 - (add % 11); if (rev == 10 || rev == 11) rev = 0; if (rev != parseInt(cpf.charAt(10))) return false; return true; } function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } function selectAll(textareaFieldId) { var textVal = document.getElementById(textareaFieldId); textVal.focus(); // Focus on textarea textVal.select();// Select all text document.execCommand("Copy"); alert('Dados copiados. Use ctrl + V para fazer a colagem no local desejado!'); } function isValidDate(stringDate) { if (stringDate.length == 8) { var day = stringDate.substring(0, 2); var month = stringDate.substring(2, 4); var year = stringDate.substring(4, 8); var newDate = month + "/" + day + "/" + year; let dateParse = Date.parse(newDate); if (isNaN(dateParse)) { return false; } return true; } if (stringDate.length < 10) { return false; } let dateParts = stringDate.split('/'); //spected format dd/MM/yyyy let newDateString = dateParts[1] + "/" + dateParts[0] + "/" + dateParts[2]; let dateParse = Date.parse(newDateString); //format to test MM/dd/yyyy if (isNaN(dateParse)) { return false; } return true; } $('#btn_generico').on('click', function() { window.location.href = 'https://yuppie-cred.s3.sa-east-1.amazonaws.com/ANALISE_PENDENCIAS_GENERICO.xls'; });
💾 保存文件
← 返回文件管理器