URL_BASE = getCookie('URL_BASE'); VERIFY_PASS = true; let aClickMenu = 1; $(document).ready(() => { // verifica se vai configurar email if (localStorage.getItem('configEmail')) { $('#nav-email-tab').click(); localStorage.removeItem('configEmail'); } // corrige bug scroll menu $('#LeftMenu').mouseout(() => { $('#LeftMenu').css({ 'overflow-y': 'hidden' }) $('#LeftMenu').mouseover(() => { $('#LeftMenu').css({ 'overflow-y': 'scroll' }); }) }) // verifica se manu esta aberto ou fechado const width = window.innerWidth; if (width >= 1260) { aClickMenu = 1; if (localStorage.getItem('statusMenu') == null || localStorage.getItem('statusMenu') == 0) { $('#LeftMenu > ul').css({ 'display': 'block', 'z-index': 1 }); $('.a-container').css({ 'margin-left': '310px', 'transition': '0.5s' }) $('.dataTables_info').css({ 'width': '70%' }) // tira evento hover $('.icon-menu').off('hover'); $('#LeftMenu').off('mouseleave'); } else { // padrão menu fechado $('#LeftMenu').css({ 'display': 'none' }); $('.a-container').css({ 'margin-left': '30px', 'transition': 'none' }) $('.dataTables_info').css({ 'width': '90%' }) aClickMenu++; } } else { aClickMenu = 0; $('.icon-menu').hover(() => $('#LeftMenu > ul').css({ 'display': 'block', 'z-index': 1 })); $('#LeftMenu ').mouseleave(() => $('#LeftMenu > ul').css({ 'display': 'none' })); } // hover menu funciona quando o menu estiver fechado if (localStorage.getItem('statusMenu') == 1) { $('.icon-menu').hover(() => $('#LeftMenu').css({ 'display': 'block', 'z-index': 1 })); $('#LeftMenu').mouseleave(() => $('#LeftMenu').css({ 'display': 'none' })); } // resize $(window).resize(() => { const width = window.innerWidth; $('.dataTables_scrollHeadInner').css({ 'width': '100%' }) if (width >= 1260) { if (localStorage.getItem('statusMenu') == 0) { $('#LeftMenu > ul').css({ 'display': 'block', 'z-index': 1 }); $('.a-container').css({ 'margin-left': '310px', 'transition': 'none' }) } } else { localStorage.setItem('statusMenu', 1); $('#LeftMenu').css({ 'display': 'none' }); $('.a-container').css({ 'margin-left': '30px', 'transition': 'none' }) $('.icon-menu').hover(() => $('#LeftMenu').css({ 'display': 'block', 'z-index': 1 })); $('#LeftMenu').mouseleave(() => $('#LeftMenu').css({ 'display': 'none' })); } }) // form background em todos os cadastros if (window.location.href.includes('/cadastro')) { $('form').css({ 'background': '#ffffff', 'border-radius': '15px', 'border': '1px solid #ddd', 'margin': '25px', }) $('.card-header').css({ 'margin-top': '-35px', }) } if (window.location.href.includes('Empresa/cadastro')) { $('form').css({ 'margin-top': '0px' }) } setTimeout(() => { if (window.location.href.includes('Colaboradores/cadastro')) { if ($('#inputID').val() != "") VERIFY_PASS = true; else VERIFY_PASS = false; } }, 500); }); 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, ''); } /**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)); } /**SIDEBAR */ function openLeftMenu() { $('#LeftMenu').css('width', '280px'); $('#LeftMenu ul').fadeIn('fast'); } function closeLeftMenu() { $('#LeftMenu').css('width', '0px'); $('#LeftMenu ul').fadeOut('fast'); } function troggleLeftMenu() { var wd = document.getElementById("LeftMenu").style.width; const width = window.innerWidth; if (width >= 1260) { if (aClickMenu % 2 == 0) { $('#LeftMenu > ul').css({ 'display': 'block', 'z-index': 1 }); $('.a-container').css({ 'margin-left': '310px', 'transition': '0.5s' }) $('.dataTables_info').css({ 'width': '70%' }) localStorage.setItem('statusMenu', 0); // menu aberto $('.dataTables_scrollHeadInner').css({ 'width': '100%' }) // tira evento hover $('.icon-menu').off('hover'); $('#LeftMenu').off('mouseleave'); } else { $('#LeftMenu').css({ 'display': 'none' }); $('.a-container').css({ 'margin-left': '30px', 'transition': '0.5s' }) $('.dataTables_info').css({ 'width': '90%' }) localStorage.setItem('statusMenu', 1) // menu fechado $('.dataTables_scrollHeadInner').css({ 'width': '100%' }) $('.icon-menu').hover(() => $('#LeftMenu').css({ 'display': 'block', 'z-index': 1 })); $('#LeftMenu').mouseleave(() => $('#LeftMenu').css({ 'display': 'none' })); } aClickMenu++; } else { // if (aClickMenu % 2 == 0) { // $('#LeftMenu > ul').css({ 'display': 'block', 'z-index': 1 }); // $('.a-container').css({ 'margin-left': '310px', 'transition': '0.5s' }) // $('.dataTables_info').css({ 'width': '40%' }) // localStorage.setItem('statusMenu', 0); // menu aberto // } else { // $('#LeftMenu > ul').css({ 'display': 'none' }); // $('.a-container').css({ 'margin-left': '30px', 'transition': '0.5s' }) // $('.dataTables_info').css({ 'width': '35%' }) // localStorage.setItem('statusMenu', 1) // menu fechado // } // aClickMenu++; } } /**LOAD*/ function ShowLoad() { $('#aLoad').fadeIn(); } function HideLoad() { $('#aLoad').fadeOut(); } /*MODAL*/ function OpenModal(aText) { let LocalModal = GetSS('modal'); if (LocalModal) { execModal(aText); } 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); }, 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) { $("body").append(GetSS('modal')); $("#aBodyModal").html(aText); } 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() { $('#aPageModal').remove(); } /*TOAST*/ function OpenToast(aText, aError = false) { let html = ''; SetSS('toast', html); execToast(aText); } function execToast(aText) { let refToast = 'toast_' + Math.floor(Math.random() * 99999); $("body").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 = ''; // console.log(aForm); // $("#" + 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; } } $(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); }) }); /**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(); } } function Deleta(table, id, id_usuario = null) { 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, contas a receber e NFSe ligados ao faturamento 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 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) { /* cria formulário pra enviar no _EXEC */ form += `
`; form += ` `; form += (table != 'controle_versao') ? ` ` : ''; 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 != 'ponto_justificativa_falta') $('#btnList').click(); $(`#tr-${id}`).remove(); if (table == "empresa_contato") atualizaTabelaContato(); if (table == "departamento_empresa") { removeObrigacoesDoDepartamento(id); removeProcessoDaEmpresa(id); atualizaTabelaDepartamentoEmpresa(); } if (table == "faturamento") { removeItensDoFaturamento(id, id_usuario); removeContasReceber(id, id_usuario); removeNFSe(id, id_usuario); } 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); document.title = 'Apontamentos - Ares Dots'; $('.tempoValue').html('00:00:00'); $('#btnAbreApontamento').removeClass('icon-nav-status-started'); $('#timeApontamentoLeftMenu').css({ 'display': 'none' }); $('#timeApontamentoLeftMenu').html('00:00:00'); } if (table == 'conta_corrente_cobranca') $(`#row_cobranca_${id}`).remove(); if (table == 'vencimentos') $(`#row_vencimento_${id}`).remove(); }, 300); }); } } }); } 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; } } function PageModal(aURL, aTitle, aModalLarger = true) { let response = false; $.ajax({ url: aURL, cache: false, async: false, success: function (data) { let md = ''; md += '