✏️ 正在编辑: jquery.js
路径:
/srv/systems_dir/koruspay/public/scripts/jquery.js
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
$('document').ready(function(){ initTreetable(); initStakeholders(); initMultiSelect(); initDashboard(); initConfirmaRemocao(); initAutoComplete(); initAgenda(); initPrevisaoOrcamentaria(); initScroll(); initBuscaEndereco(); initSistemas(); // countCharacteres($('#texto')); // Seleciona automaticamente o primeiro campo visivel do formulario da pagina $('form input, form textarea, form select').filter(':visible:enabled:first').focus().select(); $('.datepicker').datepicker({ dateFormat: "dd/mm/yy" }); // Marca e desmarca todos os checkboxes $('input:checkbox.toggle-checkboxes').click(function(){ var name = $(this).attr('role'); var checked = $(this).is(':checked'); $('input:checkbox[name="' + name + '[]"]').prop('checked', checked); }); // Adiciona tooltip $('[data-toggle="tooltip"], a[title="Editar"], a[title="Excluir"]').tooltip(); // Faz com que o menu do navbar abra ao passar o mouse $('.nav.navbar-nav > li').hover(function(){ $('.nav.navbar-nav li.dropdown.open').removeClass('open'); $(this).addClass('open'); }, function(){ $(this).removeClass('open'); }); $('a.dropdown-toggle').click(function(){ window.location = $(this).attr('data-access'); }); // Muda o visual do input file // @see http://plugins.krajee.com/file-input $('input[type="file"]').fileinput({ 'showUpload': false, 'browseLabel': 'Escolher', 'showPreview': false, 'showRemove': false, 'browseClass': 'btn btn-warning' }); $('#insert_placeholder').dblclick(function () { tinymce.activeEditor.execCommand('mceInsertContent', false, $(this).val()); $(this).val(''); }); $("fieldset#fieldset-filtros_avancados legend").click(function () { $("fieldset#fieldset-filtros_avancados > div").toggle(300); }); }); function initConfirmaRemocao() { $("a.glyphicon-remove").each(function() { var href = this.getAttribute("href"); this.setAttribute("data-access", href); this.setAttribute("href", "javascript:void()"); }); $("a.glyphicon-remove").click(function() { // alert(this.getAttribute("href")); // alert(this.getAttribute("data-access")); opcao = confirm("Tem certeza que deseja remover este item?"); if (opcao == true) { window.location = this.getAttribute('data-access'); } }); } function initTreetable() { $('table.treetable tr.parent a.glyphicon-chevron-down,' + 'table.treetable tr.parent a.glyphicon-chevron-right').click(function() { var resource = $(this).parents('tr').attr('id'); $('table.treetable .child-of-' + resource).toggle(); $(this).toggleClass('glyphicon-chevron-down'); $(this).toggleClass('glyphicon-chevron-right'); return false; }); } function expandirTudo() { $('table.treetable tr.parent a.glyphicon-chevron-right').click(); } function contrairTudo() { $('table.treetable tr.parent a.glyphicon-chevron-down').click(); } function initStakeholders() { $('body.default-prospeccao-save .table .form-control, body.default-cliente-save .table .form-control').change(function(){ var btn = $(this).parents('tr').find('.save-stakeholder'); btn.removeClass('hide'); btn.removeClass('glyphicon-reg-floppy_saved'); btn.removeClass('glyphicon-reg-floppy_removed'); btn.addClass('glyphicon-reg-floppy_disk'); btn.attr('title', 'Salvar'); btn.tooltip('destroy'); btn.tooltip({placement: 'top'}); }); $('a.save-stakeholder').click(function(){ var btn = $(this); var values = btn.parents('tr').find('.form-control').serialize(); $.ajax({ type: "POST", dataType: "JSON", data: values, url: btn.attr('href'), success: function(json) { console.log(json); if (json.result == 1) { btn.addClass('glyphicon-reg-floppy_saved'); btn.parents('tr').find('[name="cargo"]').val(json.dados.cargo); btn.parents('tr').find('[name="fone"]').val(json.dados.fone); btn.parents('tr').find('[name="email"]').val(json.dados.email); btn.parents('tr').find('[name="aniversario"]').val(json.dados.aniversario); btn.parents('tr').find('[name="posvenda"]').val(json.dados.posvenda); btn.parents('tr').find('[name="enviar_chamado"]').val(json.dados.enviar_chamado); } else { btn.addClass('glyphicon-reg-floppy_remove'); } btn.removeClass('glyphicon-reg-floppy_disk'); if (json.msg) { btn.attr('title', json.msg); btn.tooltip('destroy'); btn.tooltip({placement: 'left'}); btn.tooltip('show'); } if (json.alert) { alert(json.alert); } if (json.console) { console.log(json.console); } }, error: function() { btn.addClass('glyphicon-reg-floppy_removed'); alert('Ocorreu um erro ao tentar atualizar o registro!'); } }); return false; }); } function initMultiSelect(){ $('#status_prospeccao').not(":hidden, .not_multiple_select").multipleSelect({ // single: true, filter: true, placeholder: 'Selecione...', width: '100%', multipleWidth: 300 }); $('.multiselect').multipleSelect({ // single: true, filter: true, placeholder: 'Selecione...', width: '100%', multipleWidth: 300 }); // var nav = $('#top'); // $(window).scroll(function () { // if ($(this).scrollTop() > 136) { // nav.addClass("f-nav"); // } else { // nav.removeClass("f-nav"); // } // }); // $(".day").each(function() { // var href = this.getAttribute("href"); // this.setAttribute("data-access", href); // this.setAttribute("href", "#"); // // this.click(); // }); // // $(".day").click(function() { // openWin(this.getAttribute('data-access'), 950, 600, 1); // }); } function collapseRow(id) { $('#' + id).toggle('show'); valueButton = $('#' + id).val(); if( valueButton == '+' ){ $('#' + id).val('-'); }else{ $('#' + id).val('+'); } } function countCharacteres(inputText){ if( $(inputText).val() != undefined ){ var len = $(inputText).val().length; $('#charNum').val(len); } } $('#texto').keyup(function () { countCharacteres(this); }); //seta maisculo //$(document).ready(function(){ // $('form :text').keyup(function(){ // $(this).val($(this).val().toUpperCase()); // }); //}); function Dashboard() { this.load = function(){ this.loadRankingPedidos(); this.loadAniversariantes(); this.loadAtividadesRecentes(); this.loadNumeros(); this.loadScoreChart(); this.loadChargeCashbackChart(); this.loadQuestChart(); } this.loadRankingPedidos = function(){ $('#dashboard_ranking_pedidos').show(); $.ajax({ type: "POST", dataType: "HTML", url: baseUrl + '/dashboard/show-ranking-pedidos', success: function(content) { $('#dashboard_ranking_pedidos').html(content); }, error: function() { $('#dashboard_ranking_pedidos').html('Falha ao carregar dados'); } }); } this.loadAniversariantes = function(){ $('#dashboard_aniversariantes').show(); $.ajax({ type: "GET", dataType: "HTML", url: baseUrl + '/dashboard/show-aniversariantes-dia', success: function(content) { $('#dashboard_aniversariantes').html(content); }, error: function(response) { $('#dashboard_aniversariantes').html("Falha ao carregar dados"); } }); } this.loadAtividadesRecentes = function(){ $('#dashboard_timeline').show(); $.ajax({ type: "GET", dataType: "HTML", url: baseUrl + '/dashboard/show-atividades-recentes', success: function(content) { $('#dashboard_timeline').html(content); }, error: function(response) { $('#dashboard_timeline').html("Falha ao carregar dados"); } }); } this.loadNumeros = function(){ $('#dashboard_numeros').show(); $.ajax({ type: "GET", dataType: "HTML", url: baseUrl + '/dashboard/show-numeros-dia', success: function(content) { $('#dashboard_numeros').html(content); }, error: function(response) { $('#dashboard_numeros').html("Falha ao carregar dados"); } }); } this.loadScoreChart = function(){ $('#dashboard_score_chart').show(); $.ajax({ type: "GET", dataType: "HTML", url: baseUrl + '/dashboard/show-score-chart', success: function(content) { $('#dashboard_score_chart').html(content); }, error: function(response) { $('#dashboard_score_chart').html("Falha ao carregar dados"); } }); } this.loadChargeCashbackChart = function(){ $('#dashboard_charge_cashback_chart').show(); $.ajax({ type: "GET", dataType: "HTML", url: baseUrl + '/dashboard/show-charge-cashback-chart', success: function(content) { $('#dashboard_charge_cashback_chart').html(content); }, error: function(response) { $('#dashboard_charge_cashback_chart').html("Falha ao carregar dados"); } }); } this.loadQuestChart = function(){ $('#dashboard_quest_chart').show(); $.ajax({ type: "GET", dataType: "HTML", url: baseUrl + '/dashboard/show-quest-chart', success: function(content) { $('#dashboard_quest_chart').html(content); }, error: function(response) { $('#dashboard_quest_chart').html("Falha ao carregar dados"); } }); } } function initDashboard() { if ($('#dashboard').length) { var dashboard = new Dashboard(); dashboard.load(); console.log('Exibindo dashboard'); } } $(document).ready(function() { $("#sortedTable").tablesorter({ textExtraction: function(node) { var cell_value = $(node).text(); var sort_value = $(node).data('value'); return (sort_value != undefined) ? sort_value : cell_value; } }); }); function removeItem(objId, url) { opcao = confirm("Tem certeza que deseja realizar essa ação?"); if (opcao == true) { $.ajax({ type: "GET", dataType: "JSON", url: url, success: function(json) { console.log(json); $(document).trigger("clear-alerts"); $(document).trigger('add-alerts', [{ 'message': json.alert, 'priority': 'success' }]); $('#' + objId).animate({ 'backgroundColor': 'lightgreen' }, 300); $('#' + objId).remove(); }, error: function(msg) { console.log(msg); $(document).trigger("clear-alerts"); $(document).trigger('add-alerts', [{ 'message': 'Não foi possível executar a operação solicitada.', 'priority': 'error' }]); } }); } } function getUrl(url, objRemove) { $.ajax({ type: "GET", dataType: "JSON", url: url, success: function(json) { if (json.alert) { if (json.status == 1) { Swal.fire('Sucesso!', json.alert, 'success'); } else { Swal.fire('Atenção!', json.alert, 'warning'); } } if (objRemove) { $(objRemove).remove(); } }, error: function(msg) { console.log(msg); } }); } function getUrlConfirm(url) { opcao = confirm("Tem certeza que deseja executar essa operação?"); if (opcao != true) { return ; } $(document).on("click","a", function () { var objBtn = this; var clickValue = $(objBtn).off("click").attr('onclick'); $.ajax({ type: "GET", dataType: "JSON", url: url, beforeSend: function () { $(objBtn).addClass("ui-state-disabled"); $(objBtn).off("click").attr('onclick', "Swal.fire('Atenção!', 'Aguarde! Já tem um lançamento em andamento.', 'warning');"); }, success: function(json) { if (json.status == 1) { Swal.fire('Sucesso!', json.alert, 'success'); } else { Swal.fire('Atenção!', json.alert, 'warning'); } }, error: function(msg) { console.log(msg); }, complete: function () { $(objBtn).removeClass("ui-state-disabled"); $(objBtn).off("click").attr('onclick', clickValue); }, }); }); } function lancarPedido(url, obj) { // opcao = confirm("Tem certeza que deseja lançar pedido para esse cliente?"); // if (opcao != true) { // return; // } var pontos = window.prompt("Informe a quantidade de pontos para lançar!", 1); if (pontos === null) { return; } if (isNaN(parseInt(pontos)) ) { Swal.fire('Apenas número!', "Informe um número para a quantidade de pontos", 'error'); return; } var clickValue = $(obj).off("click").attr('onclick'); $.ajax({ type: "GET", dataType: "JSON", url: url + "/qtd/" + pontos, beforeSend: function () { $(obj).addClass("ui-state-disabled"); $(obj).off("click").attr('onclick', "Swal.fire('Atenção!', 'Aguarde! Já tem um lançamento em andamento.', 'warning');"); }, success: function(json) { if (json.status == 1) { Swal.fire('Sucesso!', json.alert, 'success'); } else { Swal.fire('Atenção!', json.alert, 'warning'); } }, error: function(msg) { console.log(msg); }, complete: function () { $(obj).removeClass("ui-state-disabled"); $(obj).off("click").attr('onclick', clickValue); }, }); } function lancarResgate(url, obj) { var resgate = window.prompt("Informe a quantidade de resgate para lançar!", 1); if (resgate === null) { return; } if (isNaN(parseInt(resgate)) ) { Swal.fire('Apenas número!', "Informe um número para a quantidade de resgate", 'error'); return; } var clickValue = $(obj).off("click").attr('onclick'); $.ajax({ type: "GET", dataType: "JSON", url: url + "/qtd/" + resgate, beforeSend: function () { $(obj).addClass("ui-state-disabled"); $(obj).off("click").attr('onclick', "Swal.fire('Atenção!', 'Aguarde! Já tem um lançamento em andamento.', 'warning');"); }, success: function(json) { if (json.status == 1) { Swal.fire('Sucesso!', json.alert, 'success'); window.location.reload(); } else { Swal.fire('Atenção!', json.alert, 'warning'); } }, error: function(msg) { console.log(msg); }, complete: function () { $(obj).removeClass("ui-state-disabled"); $(obj).off("click").attr('onclick', clickValue); }, }); } function populateBancoDados(){ var objDestino = "bank_code"; $.ajax({ type: "GET", dataType: "JSON", data: "sistema=" + $("#sistema").val(), url: baseUrl + '/banco-dados/get-bancos', success: function(response) { console.log(response); if (response.result) { $('#' + objDestino).empty(); // $('#' + objDestino).append(new Option('', '')); $.each(response.result, function(i) { // document.write(result[i]['name']); // document.write(this.id); $("#" + objDestino).append(new Option(this, this)); }); } }, error: function(response) { console.log(response); } }); } $('#myModal').on('shown.bs.modal', function () { // $('#myInput').focus() }); $(function(){ }).ajaxStart(function() { $('#loadingDiv').show(); }) .ajaxStop(function() { $('#loadingDiv').hide(); }); $('.header').click(function(){ $(this).find('span').text(function(_, value){return value=='-'?'+':'-'}); // $(this).nextUntil('tr.header').slideToggle(100); // or just use "toggle()" $(this).nextUntil(":not(.collapse)").toggle('slow'); // $(this).nextAll('.collapse').toggle('slow'); }); (function( $ ) { $.widget( "custom.combobox", { _create: function() { this.wrapper = $( "<span>" ) .addClass( "custom-combobox" ) .insertAfter( this.element ); this.element.hide(); this._createAutocomplete(); this._createShowAllButton(); }, _createAutocomplete: function() { var selected = this.element.children( ":selected" ), value = selected.val() ? selected.text() : ""; this.input = $( "<input>" ) .appendTo( this.wrapper ) .val( value ) .attr( "title", "" ) .addClass( "custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left" ) .autocomplete({ delay: 0, minLength: 0, source: $.proxy( this, "_source" ) }) .tooltip({ tooltipClass: "ui-state-highlight" }); this._on( this.input, { autocompleteselect: function( event, ui ) { ui.item.option.selected = true; this._trigger( "select", event, { item: ui.item.option }); }, autocompletechange: "_removeIfInvalid" }); }, _createShowAllButton: function() { var input = this.input, wasOpen = false; $( "<a>" ) .attr( "tabIndex", -1 ) .attr( "title", "Show All Items" ) .tooltip() .appendTo( this.wrapper ) .button({ icons: { primary: "ui-icon-triangle-1-s" }, text: false }) .removeClass( "ui-corner-all" ) .addClass( "custom-combobox-toggle ui-corner-right" ) .mousedown(function() { wasOpen = input.autocomplete( "widget" ).is( ":visible" ); }) .click(function() { input.focus(); // Close if already visible if ( wasOpen ) { return; } // Pass empty string as value to search for, displaying all results input.autocomplete( "search", "" ); }); }, _source: function( request, response ) { var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" ); response( this.element.children( "option" ).map(function() { var text = $( this ).text(); if ( this.value && ( !request.term || matcher.test(text) ) ) return { label: text, value: text, option: this }; }) ); }, _removeIfInvalid: function( event, ui ) { // Selected an item, nothing to do if ( ui.item ) { return; } // Search for a match (case-insensitive) var value = this.input.val(), valueLowerCase = value.toLowerCase(), valid = false; this.element.children( "option" ).each(function() { if ( $( this ).text().toLowerCase() === valueLowerCase ) { this.selected = valid = true; return false; } }); // Found a match, nothing to do if ( valid ) { return; } // Remove invalid value this.input .val( "" ) .attr( "title", value + " didn't match any item" ) .tooltip( "open" ); this.element.val( "" ); this._delay(function() { this.input.tooltip( "close" ).attr( "title", "" ); }, 2500 ); this.input.autocomplete( "instance" ).term = ""; }, _destroy: function() { this.wrapper.remove(); this.element.show(); } }); })( jQuery ); function initAutoComplete(){ $(".autocomplete-combobox").combobox(); $("#toggle").click(function () { $(".autocomplete-combobox").toggle(); }); } function initAgenda(){ if( $("#form_agenda").length > 0 ){ //Hide div w/id extra $("#titulo").parent().parent().css("clear", "both"); $("#assunto").parent().parent().css("display","none"); $("#titulo").parent().parent().css("display","none"); $("#descricao").parent().parent().css("display","none"); // Add onclick handler to checkbox w/id checkme $("#abrir_chamado").click(function(){ // If checked if ($("#abrir_chamado").is(":checked")) { //show the hidden div $("#titulo").parent().parent().show("fast"); $("#descricao").parent().parent().show("fast"); $("#assunto").parent().parent().show("fast"); } else { //otherwise, hide it $("#titulo").parent().parent().hide("fast"); $("#descricao").parent().parent().hide("fast"); $("#assunto").parent().parent().hide("fast"); } }); } } function initPrevisaoOrcamentaria() { $("#ano").focusout(function(){ $.ajax({ type: "GET", dataType: "JSON", data: "company_id=" + $("#company_id").val() + "&ano=" + $("#ano").val(), url: baseUrl + '/categoria/exibir-previsao-orcamentaria', success: function(response) { $('table tbody tr td input[type="text"]').val(''); totalJan = 0; totalFev = 0; totalMar = 0; totalAbr = 0; totalMai = 0; totalJun = 0; totalJul = 0; totalAgo = 0; totalSet = 0; totalOut = 0; totalNov = 0; totalDez = 0; if (response.result) { $.each(response.result, function(i) { // console.log(response.result[i]); $("#jan_" + response.result[i].categoria_id + "").val(response.result[i].jan > 0 ? number_format(response.result[i].jan, 2, ',', '.') : ""); $("#fev_" + response.result[i].categoria_id + "").val(response.result[i].fev > 0 ? number_format(response.result[i].fev, 2, ',', '.') : ""); $("#mar_" + response.result[i].categoria_id + "").val(response.result[i].mar > 0 ? number_format(response.result[i].mar, 2, ',', '.') : ""); $("#abr_" + response.result[i].categoria_id + "").val(response.result[i].abr > 0 ? number_format(response.result[i].abr, 2, ',', '.') : ""); $("#mai_" + response.result[i].categoria_id + "").val(response.result[i].mai > 0 ? number_format(response.result[i].mai, 2, ',', '.') : ""); $("#jun_" + response.result[i].categoria_id + "").val(response.result[i].jun > 0 ? number_format(response.result[i].jun, 2, ',', '.') : ""); $("#jul_" + response.result[i].categoria_id + "").val(response.result[i].jul > 0 ? number_format(response.result[i].jul, 2, ',', '.') : ""); $("#ago_" + response.result[i].categoria_id + "").val(response.result[i].ago > 0 ? number_format(response.result[i].ago, 2, ',', '.') : ""); $("#set_" + response.result[i].categoria_id + "").val(response.result[i].set > 0 ? number_format(response.result[i].set, 2, ',', '.') : ""); $("#out_" + response.result[i].categoria_id + "").val(response.result[i].out > 0 ? number_format(response.result[i].out, 2, ',', '.') : ""); $("#nov_" + response.result[i].categoria_id + "").val(response.result[i].nov > 0 ? number_format(response.result[i].nov, 2, ',', '.') : ""); $("#dez_" + response.result[i].categoria_id + "").val(response.result[i].dez > 0 ? number_format(response.result[i].dez, 2, ',', '.') : ""); totalJan += parseFloat(response.result[i].jan); totalFev += parseFloat(response.result[i].fev); totalMar += parseFloat(response.result[i].mar); totalAbr += parseFloat(response.result[i].abr); totalMai += parseFloat(response.result[i].mai); totalJun += parseFloat(response.result[i].jun); totalJul += parseFloat(response.result[i].jul); totalAgo += parseFloat(response.result[i].ago); totalSet += parseFloat(response.result[i].set); totalOut += parseFloat(response.result[i].out); totalNov += parseFloat(response.result[i].nov); totalDez += parseFloat(response.result[i].dez); }); } $("#tot_jan").text(totalJan > 0 ? number_format(totalJan, 2, ',', '.') : ""); $("#tot_fev").text(totalFev > 0 ? number_format(totalFev, 2, ',', '.') : ""); $("#tot_mar").text(totalMar > 0 ? number_format(totalMar, 2, ',', '.') : ""); $("#tot_abr").text(totalAbr > 0 ? number_format(totalAbr, 2, ',', '.') : ""); $("#tot_mai").text(totalMai > 0 ? number_format(totalMai, 2, ',', '.') : ""); $("#tot_jun").text(totalJun > 0 ? number_format(totalJun, 2, ',', '.') : ""); $("#tot_jul").text(totalJul > 0 ? number_format(totalJul, 2, ',', '.') : ""); $("#tot_ago").text(totalAgo > 0 ? number_format(totalAgo, 2, ',', '.') : ""); $("#tot_set").text(totalSet > 0 ? number_format(totalSet, 2, ',', '.') : ""); $("#tot_out").text(totalOut > 0 ? number_format(totalOut, 2, ',', '.') : ""); $("#tot_nov").text(totalNov > 0 ? number_format(totalNov, 2, ',', '.') : ""); $("#tot_dez").text(totalDez > 0 ? number_format(totalDez, 2, ',', '.') : ""); }, error: function(response) { console.log(response); } }); }); } function initScroll(){ $(window).scroll(function () { if ($(this).scrollTop() > 50) { $('#back-to-top').fadeIn(); } else { $('#back-to-top').fadeOut(); } }); // scroll body to 0px on click $('#back-to-top').click(function () { $('#back-to-top').tooltip('hide'); $('body,html').animate({ scrollTop: 0 }, 500); return false; }); $('#back-to-top').tooltip('show'); } function initBuscaEndereco() { $('#zip_code').change(function () { var cep = $(this).val(); $.ajax({ type: "GET", dataType: "JSON", url: '//viacep.com.br/ws/' + cep + '/json/', success: function (json) { if (json.erro) { alert('CEP não encontrado!'); return false; } $('#street').val(json.logradouro.toUpperCase()); $('#neighborhood').val(json.bairro.toUpperCase()); $('#city').val(json.localidade.toUpperCase()); $('#state').val(json.uf.toUpperCase()); $('#codigo_municipio').val(json.ibge); }, error: function (response) { console.log(response); alert('Ocorreu um erro ao buscar endereco!'); } }); }); } function initSistemas() { $('body.default-cliente-save .table .form-control').change(function(){ var btn = $(this).parents('tr').find('.save-sistema'); btn.removeClass('hide'); btn.removeClass('glyphicon-reg-floppy_saved'); btn.removeClass('glyphicon-reg-floppy_removed'); btn.addClass('glyphicon-reg-floppy_disk'); btn.attr('title', 'Salvar'); btn.tooltip('destroy'); btn.tooltip({placement: 'top'}); }); $('a.save-sistema').click(function(){ var btn = $(this); var values = btn.parents('tr').find('.form-control').serialize(); $.ajax({ type: "POST", dataType: "JSON", data: values, url: btn.attr('href'), success: function(json) { console.log(json); if (json.result == 1) { btn.addClass('glyphicon-reg-floppy_saved'); btn.parents('tr').find('[name="app_status"]').val(json.dados.app_status); } else { btn.addClass('glyphicon-reg-floppy_remove'); } btn.removeClass('glyphicon-reg-floppy_disk'); if (json.msg) { btn.attr('title', json.msg); btn.tooltip('destroy'); btn.tooltip({placement: 'left'}); btn.tooltip('show'); } if (json.alert) { alert(json.alert); } if (json.console) { console.log(json.console); } }, error: function() { btn.addClass('glyphicon-reg-floppy_removed'); alert('Ocorreu um erro ao tentar atualizar o registro!'); } }); return false; }); } function toogleObj(obj) { $(obj).toggle(); } function ativarModal(idModal) { $('#' + idModal).modal({ keyboard: false, show: true, backdrop: 'static' }); } function fecharModal(modal) { $('#cliente_id').val(''); $('#valor').val(''); $('#' + modal).modal("hide"); } function execCopy(value) { navigator.clipboard.writeText(value).then(() => { console.log(value); Swal.fire({ icon: 'success', title: 'Copiado com sucesso.', showConfirmButton: false, timer: 1500 }); }); } function copyUrl(url) { if (url) { execCopy(url); } } function getFileName(str) { return str.substring(str.lastIndexOf('/') + 1) } function downloadFile(linkId) { var a = document.createElement("a"); a.href = linkId.attr('src'); a.download = "qrcode-fidelize.png"; a.click(); } function deletedSplitItem() { var itens = []; $('#form_remover_itens input').each(function (index, element) { if ($(element).prop('checked')) { itens.push($(element).val()); } }); if (itens.length == 0) { Swal.fire('Erro!', 'Nenhum item selecionado.', 'error'); return false; } $.ajax({ type: "POST", dataType: "json", url: baseUrl + "/split/deleted-itens", data: { itens : itens }, beforeSend: function () { $('#loadingDiv').show(); }, success: function (result) { if (result.success) { Swal.fire({ title: 'Sucesso!', text : result.message, icon: 'success', timer: 4000 }); window.location.reload(); } if (result.error) { Swal.fire({ title: 'Atenção!', text : result.message, icon: 'warning', timer: 4000 }); } }, error: function (result) { $('#loadingDiv').hide(); console.log(result); Swal.fire('Erro!', 'Verifique o console.', 'error'); }, complete: function () { $('#loadingDiv').hide(); }, }); } function deletedSplit(id) { if (id.length == 0) { Swal.fire('Erro!', 'Erro na exclusão do lote.', 'error'); return false; } $.ajax({ type: "POST", dataType: "json", url: baseUrl + "/split/deleted", data: { id : id }, beforeSend: function () { $('#loadingDiv').show(); }, success: function (result) { if (result.success) { Swal.fire({ title: 'Sucesso!', text : result.message, icon: 'success', timer: 4000 }); window.location.reload(); } if (result.error) { Swal.fire({ title: 'Atenção!', text : result.message, icon: 'warning', timer: 4000 }); } }, error: function (result) { $('#loadingDiv').hide(); console.log(result); Swal.fire('Erro!', 'Verifique o console.', 'error'); }, complete: function () { $('#loadingDiv').hide(); }, }); } function createCharge(idSplit) { if (idSplit.length == 0) { Swal.fire('Erro!', 'Lote inválido.', 'error'); return false; } $.ajax({ type: "POST", dataType: "json", url: baseUrl + "/split/create-charge", data: { split_id : idSplit, }, beforeSend: function () { $('#loadingDiv').show(); }, success: function (result) { if (result.success) { var element = document.createElement("div"); element.className = 'qrcode-modal' element.innerHTML = result.qrCode_image; Swal.fire({ icon: "success", title: "Scaneie o QR Code para realizar o pagamento!", html: element, text : result.payer + ' - CNPJ: ' + result.cnpj, showCancelButton: false, showConfirmButton: true, confirmButtonText: 'Fechar', }).then(function (result) { if (result.isConfirmed) { window.location.reload(); } }); } if (result.error) { Swal.fire({ title: 'Atenção!', text : result.message, icon: 'warning', timer: 4000 }); } }, error: function (result) { $('#loadingDiv').hide(); console.log(result); Swal.fire('Erro!', 'Verifique o console.', 'error'); }, complete: function () { $('#loadingDiv').hide(); }, }); } function authentication2fa(loteId = null, secret = null, token = null, reprocessar = null) { if (reprocessar) { var itens = []; var count = 0; $('table tr').each(function() { if ($(this).find(".item-check").is(':checked')) { count++; var dadosLinha = {}; $(this).find('input, select').each(function() { var nomeCampo = $(this).attr('name'); var valorCampo = $(this).val(); if (nomeCampo) { dadosLinha[nomeCampo] = valorCampo; } }); itens.push(dadosLinha); } }); if (count === 0) { Swal.fire({ title: 'Atenção!', text : 'Nenhuma transferência selecionada', icon: 'warning' }); return; } } $.ajax({ type: "POST", dataType: "json", url: baseUrl + "/authentication/auth", data: { secret: secret, token: token, split_id: loteId, itens: itens, }, async: true, beforeSend: function () { $('#loadingDiv').show(); }, success: function (response) { if (response.redirect) { window.location.href = baseUrl + response.redirect; return; } if (response.qrcode) { var element = document.createElement("div"); element.className = 'qrcode-modal' element.innerHTML = response.qrCode_image; Swal.fire({ icon: "warning", title: "Scaneie o QR Code no Google Authentication!", html: element, showCancelButton: true, cancelButtonText: 'CANCELAR', showConfirmButton: true, confirmButtonText: 'PROCESSAR', }).then(function (result) { if (result.isConfirmed) { $('#loadingDiv').hide(); authentication2fa(loteId, response.secret, null, reprocessar); } }); return false; } if (response.secret) { var element = document.createElement("div"); element.className = 'qrcode-modal' element.innerHTML = response.input_token; Swal.fire({ icon: "warning", title: "Digite seu código do Google Authentication!", html: element, showCancelButton: true, cancelButtonText: 'CANCELAR', showConfirmButton: true, confirmButtonText: 'CONTINUAR', }).then(function (result) { if (result.isConfirmed) { $('#loadingDiv').hide(); authentication2fa(loteId, response.key, $('#token').val(), reprocessar); } }); return false; } if (response.token_error) { Swal.fire({ title: 'Atenção!', text : response.message, icon: 'warning', timer: 3000 }); authentication2fa(loteId, secret, null, reprocessar); } if (response.success) { Swal.fire({ title: 'Sucesso!', text : response.message, icon: 'success', timer: 5000 }); return false; } if (response.error) { Swal.fire({ title: 'Atenção!', text : response.message, icon: 'warning', timer: 4000 }); } }, error: function (result) { $('#loadingDiv').hide(); console.log(result); Swal.fire('Erro!', 'Verifique o console.', 'error'); }, complete: function () { $('#loadingDiv').hide(); }, }); } $(document).on('click', '#pix_copy_paste', function() { this.select(); document.execCommand("copy"); alert("Pix Copiado!"); return false; }); function requestWithdraw(token) { $.ajax({ type: "POST", dataType: "json", url: baseUrl + "/transactions/withdraw", data: {token: token}, beforeSend: function () { $('#loadingDiv').show(); }, success: function (result) { if (result.success) { Swal.fire({ title: 'Saque Solicitado!', text : result.message, icon: 'success', }); } if (result.error) { Swal.fire({ title: 'Atenção!', text : result.error, icon: 'warning', }); } }, error: function (result) { $('#loadingDiv').hide(); console.log(result); Swal.fire('Erro!', 'Verifique o console.', 'error'); }, complete: function () { $('#loadingDiv').hide(); setTimeout( function () { window.location.reload(true) }, 7000 ); }, }); } function validRelease(idSplit) { $.ajax({ type: "POST", dataType: "json", url: baseUrl + "/transactions/check-tax-debited", data: {split_id: idSplit}, beforeSend: function () { $('#loadingDiv').show(); }, success: function (result) { if (result.success) { Swal.fire({ title: 'Validação!', text : result.message, icon: 'success', }); } if (result.error) { Swal.fire({ title: 'Atenção!', text : result.error, icon: 'warning', }); } }, error: function (result) { $('#loadingDiv').hide(); console.log(result); Swal.fire('Erro!', 'Verifique o console.', 'error'); }, complete: function () { $('#loadingDiv').hide(); setTimeout( function () { window.location.reload(true) }, 5000 ); }, }); } function checkPayment(idSplit) { $.ajax({ type: "POST", dataType: "json", url: baseUrl + "/split/check-payment", data: {split_id: idSplit}, beforeSend: function () { $('#loadingDiv').show(); }, success: function (result) { if (result.success) { Swal.fire({ title: 'Validação!', text : result.message, icon: 'success', }); } if (result.error) { Swal.fire({ title: 'Atenção!', text : result.error, icon: 'warning', }); } }, error: function (result) { $('#loadingDiv').hide(); console.log(result); Swal.fire('Erro!', 'Verifique o console.', 'error'); }, complete: function () { $('#loadingDiv').hide(); setTimeout( function () { window.location.reload(true) }, 5000 ); }, }); }
💾 保存文件
← 返回文件管理器