URL_BASE = getCookie("URL_BASE"); const URL_ARQUIVOS = "https://files.dots.app.br?path="; const ESTADOS = { AC: "Acre", AL: "Alagoas", AP: "Amap\u00e1", AM: "Amazonas", BA: "Bahia", CE: "Cear\u00e1", DF: "Distrito Federal", ES: "Esp\u00edrito Santo", GO: "Goi\u00e1s", MA: "Maranh\u00e3o", MT: "Mato Grosso", MS: "Mato Grosso do Sul", MG: "Minas Gerais", PA: "Par\u00e1", PB: "Para\u00edba", PR: "Paran\u00e1", PE: "Pernambuco", PI: "Piau\u00ed", RJ: "Rio de Janeiro", RN: "Rio Grande do Norte", RS: "Rio Grande do Sul", RO: "Rond\u00f4nia", RR: "Roraima", SC: "Santa Catarina", SP: "S\u00e3o Paulo", SE: "Sergipe", TO: "Tocantins", }; VERIFY_PASS = true; let aClickMenu = 1; let arquivosEmail = new DataTransfer(); const session = getDataSession(); const urlSplit = URL_BASE.split("/client"); const URL_API_SERPRO = window.location.href.includes("local") ? `http://localhost/${urlSplit[0]}/API/Serpro/api` : "https://dots.app.br/API/Serpro/api"; const URL_API_AUTOTASK = window.location.href.includes("local") ? `http://localhost/${urlSplit[0]}/API/autotask` : "https://dots.app.br/API/autotask"; const TYPE_ACCOUNT_OF = Object.freeze({ BANK: "BANK", CREDIT: "CREDIT", }); const SUBTYPE_ACCOUNT_OF = Object.freeze({ SAVINGS_ACCOUNT: "SAVINGS_ACCOUNT", CHECKING_ACCOUNT: "CHECKING_ACCOUNT", CREDIT_CARD: "CREDIT_CARD", }); const TYPE_ACCOUNT_LABEL_OF = Object.freeze({ [TYPE_ACCOUNT_OF.BANK]: "Conta Bancária", [TYPE_ACCOUNT_OF.CREDIT]: "Cartão de Crédito", }); const SUBTYPE_ACCOUNT_LABEL_OF = Object.freeze({ [SUBTYPE_ACCOUNT_OF.SAVINGS_ACCOUNT]: "Conta Poupança", [SUBTYPE_ACCOUNT_OF.CHECKING_ACCOUNT]: "Conta Corrente", [SUBTYPE_ACCOUNT_OF.CREDIT_CARD]: "Cartão de Crédito", }); const CONNECTION_STATUS_APIOF = { UPDATING: { label: "Atualizando...", class: "cstatus-info" }, UPDATED: { label: "Atualizado", class: "cstatus-success" }, LOGIN_ERROR: { label: "Erro de Login", class: "cstatus-error" }, OUTDATED: { label: "Desatualizado", class: "cstatus-warning" }, WAITING_USER_INPUT: { label: "Aguardando Ação Usuário", class: "cstatus-warning" }, }; function maskPhone(value) { value = value.replace(/\D/g, ""); value = value.replace(/(\d{2})(\d)/, "($1) $2"); value = value.replace(/(\d)(\d{4})$/, "$1-$2"); return value; } function OpenPage(aLink) { window.open(aLink, "_self"); } /**LOCAL STORAGE */ function SetLS(nome, valor) { localStorage.setItem(nome, valor); } function GetLS(nome) { var LS; LS = localStorage.getItem(nome); if (LS == null) { return ""; } else { return LS; } } function ClearLS(nome) { localStorage.setItem(nome, ""); } function RemoveLS(nome) { localStorage.removeItem(nome); } /**SESSION STORAGE */ function SetSS(nome, valor) { sessionStorage.setItem(nome, valor); } function GetSS(nome) { var SS; SS = sessionStorage.getItem(nome); if (SS == null) { return ""; } else { return SS; } } function ClearSS(nome) { sessionStorage.removeItem(nome); } /**COOKIES*/ function setCookie(aName, aValue) { document.cookie = aName + "=" + aValue; } function getCookie(name) { var cookies = document.cookie; var prefix = name + "="; var begin = cookies.indexOf("; " + prefix); if (begin == -1) { begin = cookies.indexOf(prefix); if (begin != 0) { return null; } } else { begin += 2; } var end = cookies.indexOf(";", begin); if (end == -1) { end = cookies.length; } return unescape(cookies.substring(begin + prefix.length, end)); } /**LOAD*/ function ShowLoad() { $("#aLoad").fadeIn(); } function HideLoad() { $("#aLoad").fadeOut(); } /*MODAL*/ function OpenModal(aText, aTitle = "") { let LocalModal = GetSS("modal"); if (LocalModal) { execModal(aText, aTitle); } else { $.ajax({ url: "/" + URL_BASE + "App/View/Pages/Launcher/modal.php", contentType: "application/html; charset=utf-8", success: function (data) { SetSS("modal", data); execModal(aText, aTitle); }, error: function () { // }, }); } return false; } function OpenModalTags() { $.ajax({ url: "/" + URL_BASE + "App/View/Pages/RegistroMetricas/include/modal_tags.php", contentType: "application/html; charset=utf-8", success: function (data) { $("body").append(data); }, error: function () { // }, }); } function execModal(aText, aTitle = "") { $("body").append(GetSS("modal")); $("#aBodyModal").html(aText); if (aTitle) { $("#exampleModalLabel").html(aTitle); } } function ModalPropagarHorarios(id) { $.ajax({ url: "/" + URL_BASE + "App/View/Pages/Colaboradores/include/modal_propagar_horarios.php", contentType: "application/html; charset=utf-8", success: function (data) { $("body").append(data); if (!id) $("#aCloseModal").attr("onclick", `selecionaDiaParaPropagarHoras()`); else $("#aCloseModal").attr( "onclick", `selecionaDiaParaPropagarHoras('${id}')`, ); }, error: function () { // }, }); return false; } function CloseModal() { $("#aModal").remove(); } function ClosePageModal() { const divs = $(".a_modal"); const lastDiv = divs.last(); lastDiv.remove(); } function CloseFileModal() { $("#aFileModal").remove(); } /*TOAST*/ function OpenToast(aText, aError = false) { let html = ''; SetSS("toast", html); execToast(aText); // $.ajax({ // url: '/' + URL_BASE + 'App/View/Pages/Launcher/toast.php', // contentType: "application/html; charset=utf-8", // success: function (data) { // SetSS('toast', data); // execToast(aText); // }, // error: function () { // // // } // }); // let LocalToast = GetSS('toast'); // if (LocalToast) { // execToast(aText); // } else { // $.ajax({ // url: '/' + URL_BASE + 'App/View/Pages/Launcher/toast.php', // contentType: "application/html; charset=utf-8", // success: function (data) { // SetSS('toast', data); // execToast(aText); // }, // error: function () { // // // } // }); // } } function execToast(aText) { let refToast = "toast_" + Math.floor(Math.random() * 99999); $("#toast-container").append(GetSS("toast")); $("#liveToast").attr("id", refToast); $("*[id=" + refToast + "]") .html(aText) .slideDown(); setTimeout(function () { $("*[id=" + refToast + "]").slideUp(); setTimeout(function () { $("*[id=" + refToast + "]").slideUp(); CloseToast(refToast); }, 1000); }, 5000); } function CloseToast(refToast) { $("*[id=" + refToast + "]").remove(); } /**VALIDATE */ function ValidaForm(aForm) { var Campos = ""; // $("#" + aForm).find("input[valida='true']").each(function (index) { $("#" + aForm + " input[valida='true']").each(function (index) { if ($(this).closest("form").attr("id") == aForm) { if ($.trim($(this).val()) == "") { if (!$(this).attr("disabled") && !$(this).attr("readonly")) { $(this).addClass("invalid"); // Campos += '
* ' + $(this).attr("id"); Campos += "
" + $(this) .closest("div") .html() .split("")[0] .replace("form-label", "form-label text-secondary") .trim(); } else { $(this).removeClass("invalid"); } } else { $(this).removeClass("invalid"); } } }); $("#" + aForm + " select[valida='true']").each(function (index) { if ($(this).closest("form").attr("id") == aForm) { if (!$(this).val()) { if (!$(this).attr("disabled") && !$(this).attr("readonly")) { $(this).addClass("invalid"); // Campos += '
* ' + $(this).attr("id"); Campos += "
" + $(this) .closest("div") .html() .split("")[0] .replace("form-label", "form-label text-secondary") .trim(); } } else { $(this).removeClass("invalid"); } } }); $("#" + aForm + " input[doc='cpfcnpj']").each(function (index) { if ($(this).closest("form").attr("id") == aForm) { if ($(this).val()) { if (!$(this).attr("disabled") && !$(this).attr("readonly")) { if (!validaCpfCnpj(apenasNumeros($(this).val()))) { $(this).addClass("invalid"); Campos += "
* Informar CPF ou CNPJ Válido"; } else { $(this).removeClass("invalid"); } } else { $(this).removeClass("invalid"); } } else { $(this).addClass("invalid"); } } }); $("#" + aForm + " input[tp='mail']").each(function (index) { if ($(this).closest("form").attr("id") == aForm) { if ($.trim($(this).val()) !== "") { if (!$(this).attr("disabled") && !$(this).attr("readonly")) { if (!IsEmail($.trim($(this).val()))) { $(this).addClass("invalid"); Campos += "
* Informar E-mail Válido"; } } else { $(this).removeClass("invalid"); } } else { $(this).removeClass("invalid"); } } }); if (!VERIFY_PASS) { $("#msgSenhaFraca").css({ display: "block" }); OpenToast("Informe uma senha forte", true); return; } else { $("#msgSenhaFraca").css({ display: "none" }); } $("#" + aForm + " input[tp='data']").each(function (index) { if ($(this).closest("form").attr("id") == aForm) { if ($.trim($(this).val()) !== "") { if (!$(this).attr("disabled") && !$(this).attr("readonly")) { if ($.trim($(this).val()) !== "00/00/0000") { if (!validateDate($.trim($(this).val()))) { var legenda = $( "label[for='" + $(this).attr("name") + "']", ).html(); if (legenda !== "") Campos += "
* Informe uma " + legenda + " válida"; else Campos += "
* Data Válida"; } } } } else { $(this).removeClass("invalid"); } } }); if (Campos !== "") { OpenToast( ' Os campos abaixo devem ser preenchidos !!!' + Campos.replaceAll("form-label", "m-0") + "", true, ); // OpenToast('Preencha os campos obrigatórios !!'); // OpenModal(' Os campos abaixo devem ser preenchidos !!!
' + Campos); return false; } else { return true; } } /**AJAX LOAD*/ // $(document).ajaxStart(function () { // ShowLoad(); // }); // $(document).ajaxComplete(function () { // HideLoad(); // }); // $(document).ajaxError(function () { // HideLoad(); // }); $(document).ready(function () { // Whenever the key is pressed, apply condition checks. $("input[tp='password']").keyup(function () { var m = $(this).val(); var n = m.length; // Function for checking check(n, m); }); $("input[tp='password']").blur(function () { var m = $(this).val(); var n = m.length; // Function for checking check(n, m); }); }); function check(n, m) { if (n == 0) { $(".progress-bar").attr("aria-valuenow", "33%"); $(".progress").addClass("bg-danger"); VERIFY_PASS = false; } if (n < 8 && n > 0) { VERIFY_PASS = false; } if ( n >= 8 && m.match(/[a-z]/) != null && m.match(/[A-Z]/) != null && m.match(/0|1|2|3|4|5|6|7|8|9/) != null ) { VERIFY_PASS = false; } if ( n >= 8 && m.match(/\W/) != null && m.match(/[a-z]/) != null && m.match(/[A-Z]/) != null && m.match(/0|1|2|3|4|5|6|7|8|9/) != null && m.match(/\D/) != null ) { VERIFY_PASS = true; } // Check for the character-set constraints // and update percentage variable as needed. // Lowercase Words only // (m.match(/[a-z]/) != null)) // Uppercase Words only // m.match(/[A-Z]/) != null)) // Digits only // ((m.match(/0|1|2|3|4|5|6|7|8|9/) != null)) // Special characters // ((m.match(/\W/) != null) && (m.match(/\D/) != null)) } /**MISCELANEAS */ function isUndefined(aVal) { return typeof aVal === "undefined"; } function SetTitle(NamePage) { if (NamePage.trim() !== "" || !isUndefined(NamePage)) document.title = NamePage + " - " + document.title; else document.title = "Ares Dots"; } function apenasNumeros(string) { var numsStr = string.replace(/[^0-9]/g, ""); return numsStr; } function MoedaPrint(aValor) { aValor = aValor.toLocaleString("pt-br", { minimumFractionDigits: 2, }); return aValor; } function FormataValorMoeda(aValor) { if (typeof aValor === "number") { aValor = aValor.toString(); } aValor = aValor?.replaceAll(",", "."); aValor = parseFloat(aValor); return aValor.toLocaleString("pt-br", { minimumFractionDigits: 2, }); } function MoedaCalculo(aValor) { aValor = aValor.replaceAll(".", ""); aValor = aValor.replace(",", "."); return parseFloat(aValor); } function onlynumber(evt) { var theEvent = evt || window.event; var key = theEvent.keyCode || theEvent.which; key = String.fromCharCode(key); var regex = /^[0-9]+$/; if (!regex.test(key)) { theEvent.returnValue = false; if (theEvent.preventDefault) theEvent.preventDefault(); } } // idChildren é utilizado quando vc tem uma tabela pai, mas precisa deletar um item da tabela filha tbm; // Exemplo: tabela de arquivos do projeto/tarefa oq precisa ser enviado para api é o idChildren, que é o id da tabela arquivos. function Deleta(table, id, id_usuario, idLine = "", idChildren = 0) { let message; if (table == "departamento_empresa") { message = "Atenção, ao excluir um departamento, os processos e obrigações ligados ao departamento também serão excluídos da empresa. Deseja prosseguir?"; } else if (table == "faturamento") { message = "Atenção, ao excluir um faturamento os serviços e contas a receber em aberto também serão excluídos. Deseja prosseguir ?"; } else if (table == "contrato") { message = "Atenção, ao excluir um contrato, os itens ligados a esse contrato também serão excluídos. Deseja prosseguir?"; } else if (table == "projetos") { message = "Atenção, a exclusão do projeto implica na exclusão de todas as suas dependências. (Tarefas, Comentários e Arquivos)"; } else if (table == 'openfinance_clients') { message = "Atenção, ao remover um cliente do serviço OpenFinance, todos os consentimentos dos itens vinculados a ele serão revogados automaticamente. Deseja prosseguir?"; } else message = "Deseja realmente excluir esta informação"; bootbox.confirm({ title: "Exclusão", message: message, closeButton: false, buttons: { cancel: { label: ' Cancelar', }, confirm: { label: ' Confirmar', }, }, callback: (result) => { let form = ""; if (result) { if (table == "documento_texto") { // console.log(id); } /* cria formulário pra enviar no _EXEC */ form += `
`; form += ` `; form += ` `; form += ` `; form += "
"; /* adiciona form no html e envia */ $("body").append(form); _EXEC("formExclusao", "Item removido com sucesso").done((data) => { /* remove form e atualiza tabela */ $("#formExclusao").remove(); setTimeout(() => { if (table == "tarefa_agenda") { reRender(); } if ( table != "ponto_justificativa_falta" && table != "vencimentos" && table != "empresa_contato" ) $("#btnList").click(); if ( table == "titulo_modelo_projeto_tarefas" || table == "projeto_tarefas" ) { $(`#${idLine}`).remove(); } else { $(`#tr-${id}`).remove(); } if (table == "empresa_contato") atualizarListaContatos(); if (table == "departamento_empresa") { removeObrigacoesDoDepartamento(id); removeProcessoDaEmpresa(id); atualizaTabelaDepartamentoEmpresa(); } if (table == "openfinance_clients") { handleRevokeAllItemsOpenFinance(id); handleSoftDeleteChartOfAccounts(id); $(`#tr-${id}`).remove(); } if (table == "projeto_tarefas") { const totalUnchecked = $( ".checkbox-select-finish-controller:not(:checked)", ).length; $("#tarefas_total").html(totalUnchecked); } if (table == "faturamento") { removeItensDoFaturamento(id, id_usuario); removeContasReceber(id, id_usuario); removerIdFaturamentoDoProjeto(id); } if (table == "projetos") { removerTarefasDoProjeto(id); removerComentariosProjetoTarefas(id); removerArquivosProjetoTarefa(id); } if (table == "arquivos_projeto_tarefas") { deleteFiles(idChildren.toString()); } if (table == "tarefas") { removerTarefasTituloProjeto(id); // remover a tarefa dos títulos de projeto. removerTarefasDoProjeto(0, id); // remover a tarefa dos projetos removerComentariosProjetoTarefas(0, id); // remover os comentário da tarefa. removerArquivosProjetoTarefa(0, id); // remover os arquivos da tarefa } if (table == "empresa") { removerProjeto(id); // deletar o projeto ao excluir a empresa/cliente } if (table == "contrato") removeItensDoContrato(id, id_usuario); if (table == "empresa_processo_tempo_padrao") atualizaTabelaProcesso(); if (table == "apontamento") { localStorage.removeItem("empresaApontamento"); localStorage.removeItem("dadosApontamento"); $(".btnApontamentoProcesso").html(''); $(".btnApontamentoProcesso").removeClass("bg-danger"); $(".btnApontamentoProcesso").addClass("bg-success"); clearInterval(contextTimer); $(`.tempoValue`).attr("timer", "stopped"); document.title = "Apontamentos - Ares Dots"; $(".tempoValue").html("00:00:00"); $("#btnAbreApontamento").removeClass("icon-nav-status-started"); $("#timeApontamentoLeftMenuMask").css({ display: "none" }); $("#timeApontamentoLeftMenu").css({ display: "none" }); $("#timeApontamentoLeftMenu").html( '00:00:00', ); $("#tempo-dashboard").html("00:00:00"); } // if (table == 'conta_corrente_cobranca') // $(`#row_cobranca_${id}`).remove(); // else if (table == "vencimentos") $(`#row_vencimento_${id}`).remove(); else if (table == "nfse_itens") $(`#${idLine}`).remove(); }, 300); }); } }, }); } function removeObrigacoesDoDepartamento(id) { let idEdicao; _GET("App/Controller/Query/get.controller.php", { table_name: "departamento_empresa", condition: `AND id = ${id}`, }).done((data) => { const response = JSON.parse(data); const idDepartamento = response[0].id_departamento; const idEmpresa = response[0].id_empresa; _GET("App/Controller/Query/get.controller.php", { table_name: "aux_empresa_obrigacao", condition: `AND id_empresa = ${idEmpresa}`, }).done((data) => { const obrigacaoEmpresa = JSON.parse(data); _GET("App/Controller/Query/get.controller.php", { table_name: "obrigacao_fiscal", condition: `AND id_departamento = ${idDepartamento} AND data_exclusao IS NULL`, }).done((data) => { const response = JSON.parse(data); obrigacaoEmpresa.forEach((obrigacao, keyE) => { response.forEach((item, keyO) => { if ( obrigacao.id_obrigacao == item.id && item.id_departamento == idDepartamento ) { const { year, month, date } = fnCurrentTime(); let form = `
`; form += ``; form += ``; form += "
"; $("body").append(form); _EXEC(`form_${keyE}-${keyO}`, null, null).done((data) => { $(`#form_${keyE}-${keyO}`).remove(); }); } }); }); setTimeout(() => { atualizaTabelaObrigacoes($("#inputID").val()); }, 2000); }); }); }); } function removeProcessoDaEmpresa(id) { const idEmpresa = $("#inputID").val(); // pega tempo padrao da empresa _GET("App/Controller/Query/get.controller.php", { table_name: "empresa_processo_tempo_padrao", condition: `AND id_empresa = ${idEmpresa} AND data_exclusao IS NULL`, }).done((data) => { const processosEmpresa = JSON.parse(data); // pega todos os processos _GET("App/Controller/Query/get.controller.php", { table_name: "processo", condition: `AND data_exclusao IS NULL`, }).done((data) => { const processos = JSON.parse(data); // pega departamento do processo _GET("App/Controller/Query/get.controller.php", { table_name: "departamento_empresa", condition: `AND id = ${id}`, }).done((data) => { const response = JSON.parse(data); const idDepartamento = response[0].id_departamento; processosEmpresa.forEach((el, key) => { processos.forEach((item) => { if ( el.id_processo == item.id && item.id_departamento == idDepartamento ) { let form = ""; form += `
`; form += ``; form += ``; form += "
"; $("body").append(form); _EXEC(`formProcessoEmpresa-${key}`, null, false).done((data) => { $(`#formProcessoEmpresa-${key}`).remove(); }); } }); }); $("#table-processo").html(""); setTimeout(() => atualizaTabelaProcesso(), 500); }); }); }); } function removeItensDoFaturamento(id, id_usuario) { // pega todos os processos _GET("App/Controller/Query/get.controller.php", { table_name: "faturamento_itens", condition: `AND id_faturamento = ${id}`, }).done((data) => { const itens = JSON.parse(data); itens.forEach((item, key) => { let form = ""; form += `
`; form += ``; form += ``; form += ``; form += "
"; $("body").append(form); _EXEC(`formItensFaturamento-${key}`, null, false).done((data) => { $(`#formItensFaturamento-${key}`).remove(); }); }); }); } function removeContasReceber(id, id_usuario) { // pega todos os processos _GET("App/Controller/Query/get.controller.php", { table_name: "contas_receber", condition: `AND id_faturamento = ${id} AND data_pagamento IS NULL;`, }).done((data) => { const obj = JSON.parse(data); obj.forEach((item, key) => { let form = ""; form += `
`; form += ``; form += ``; form += ``; form += "
"; $("body").append(form); _EXEC(`formContasReceber-${key}`, null, false).done((data) => { $(`#formContasReceber-${key}`).remove(); }); }); }); } // function removeNFSe(id, id_usuario) { // // pega todos os processos // _GET('App/Controller/Query/get.controller.php', { // table_name: 'nfse', // condition: `AND id_faturamento = ${id}` // }) // .done(data => { // const obj = JSON.parse(data); // obj.forEach((item, key) => { // let form = ""; // form += `
`; // form += ``; // form += ``; // form += ``; // form += "
"; // $('body').append(form); // _EXEC(`formNFSe-${key}`, null, false) // .done(data => { // $(`#formNFSe-${key}`).remove(); // }) // }); // }) // } function removeItensDoContrato(id, id_usuario) { // pega todos os processos _GET("App/Controller/Query/get.controller.php", { table_name: "contrato_itens", condition: `AND id_contrato = ${id}`, }).done((data) => { const itens = JSON.parse(data); itens.forEach((item, key) => { let form = ""; form += `
`; form += ``; form += ``; form += ``; form += "
"; $("body").append(form); _EXEC(`formItensContrato-${key}`, null, false).done((data) => { $(`#formItensContrato-${key}`).remove(); }); }); }); } function LimpaForm(aForm) { if (aForm == "") aForm = "ajax_form"; $("#" + aForm).each(function () { this.reset(); }); } /**VALIDA SE É UM CPF/CNPJ VÁLIDO */ function validaCpfCnpj(val) { if (val.length == 11) { var cpf = val.trim(); cpf = cpf.replace(/\./g, ""); cpf = cpf.replace("-", ""); cpf = cpf.split(""); var v1 = 0; var v2 = 0; var aux = false; for (var i = 1; cpf.length > i; i++) { if (cpf[i - 1] != cpf[i]) { aux = true; } } if (aux == false) { return false; } for (var i = 0, p = 10; cpf.length - 2 > i; i++, p--) { v1 += cpf[i] * p; } v1 = (v1 * 10) % 11; if (v1 == 10) { v1 = 0; } if (v1 != cpf[9]) { return false; } for (var i = 0, p = 11; cpf.length - 1 > i; i++, p--) { v2 += cpf[i] * p; } v2 = (v2 * 10) % 11; if (v2 == 10) { v2 = 0; } if (v2 != cpf[10]) { return false; } else { return true; } } else if (val.length == 14) { var cnpj = val.trim(); cnpj = cnpj.replace(/\./g, ""); cnpj = cnpj.replace("-", ""); cnpj = cnpj.replace("/", ""); cnpj = cnpj.split(""); var v1 = 0; var v2 = 0; var aux = false; for (var i = 1; cnpj.length > i; i++) { if (cnpj[i - 1] != cnpj[i]) { aux = true; } } if (aux == false) { return false; } for (var i = 0, p1 = 5, p2 = 13; cnpj.length - 2 > i; i++, p1--, p2--) { if (p1 >= 2) { v1 += cnpj[i] * p1; } else { v1 += cnpj[i] * p2; } } v1 = v1 % 11; if (v1 < 2) { v1 = 0; } else { v1 = 11 - v1; } if (v1 != cnpj[12]) { return false; } for (var i = 0, p1 = 6, p2 = 14; cnpj.length - 1 > i; i++, p1--, p2--) { if (p1 >= 2) { v2 += cnpj[i] * p1; } else { v2 += cnpj[i] * p2; } } v2 = v2 % 11; if (v2 < 2) { v2 = 0; } else { v2 = 11 - v2; } if (v2 != cnpj[13]) { return false; } else { return true; } } else { return false; } } //para usar a closeFunction crie uma função e mande o nome dela; //para usar a aModalCustomWidth basta passar o valor que deseja (é porcentagem), ou seja 75% => 75 (inteiro) como parâmetro da função PageModal; // Caso queira adicionar um botão de "+" na modal no lugar no close (x), basta passar o parâmetro hasAddButton como true e informar a função a ser executada pelo addFunction function PageModal( aURL, aTitle, aModalLarger = true, closeFunction = null, aModalCustomWidth = null, paddingInterno = true, overflowHidden = true, hasAddButton = false, addFunction = null, btnNovoCadastroModal = "btnNovoCadastroModal", ) { $("body").append( '
', ); let response = false; let md = ""; let randID = `aBodyPageModal_${Math.floor(Math.random() * 9999) + 1}`; $.ajax({ url: aURL, cache: false, async: false, success: function (data) { const key = (Math.random() + 1).toString(36).substring(2); md += `