✏️ 正在编辑: jquery.js
路径:
/srv/systems_dir/oakberry/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 = "banco"; $.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]['nome']); // 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: "empresa_id=" + $("#empresa_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() { $('#cep').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; } $('#endereco').val(json.logradouro.toUpperCase()); $('#bairro').val(json.bairro.toUpperCase()); $('#cidade').val(json.localidade.toUpperCase()); $('#uf').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 sinalizaAgenda() { $.ajax({ type: "POST", dataType: "json", url: baseUrl + "/agenda/sinaliza-badge", success: function (result) { if (result) { var element = $(".agenda_menu"); element.prepend("<span class=\"badge\">" + result.badge + "</span>"); elTitle = $(document); var txTitle = elTitle.attr('title'); elTitle.attr('title', '(' + result.badge + ') ' + txTitle ); } }, error: function (msg) { console.log(msg); } }); } $('form#form_leadadd').submit(function(e) { e.preventDefault(); $("#save").attr("disabled", true); $.ajax({ type: "POST", dataType: "json", url: baseUrl + "/lead/add", data: $('form#form_leadadd').serializeArray(), beforeSend: function () { $('#loadingDiv').show(); }, success: function (result) { if (result.msg) { $('main.container > div.row > div.panel > div.panel-body').empty().html(result.msg); } if (result.alert) { Swal.fire('Atenção!', result.alert, 'warning'); $("#save").removeAttr("disabled"); } }, error: function (msg) { console.log(msg); $("#save").removeAttr("disabled"); }, complete: function () { $('#loadingDiv').hide(); }, }); }); function desAtivarDelivery(idDelivery, ativar) { $.ajax({ type: "POST", dataType: "json", url: baseUrl + "/empresa/des-ativar-delivery", data: { delivery_id: idDelivery, active: ativar }, success: function (result) { if (result.success) { Swal.fire('Sucesso!', result.success, 'success'); bool = ativar == 1 ? 0 : 1; $('.plataforma-' + idDelivery).removeAttr('style').attr('style', ativar == 1 ? 'color: green' : 'color: firebrick'); $('.plataforma-' + idDelivery).removeAttr('onclick').attr('onclick', 'desAtivarDelivery(' + idDelivery + ', ' + bool + ')'); if (ativar == 1) { $('.plataforma-' + idDelivery).removeClass('glyphicon-ok-circle').addClass('glyphicon-ok-sign') } else { $('.plataforma-' + idDelivery).removeClass('glyphicon-ok-sign').addClass('glyphicon-ok-circle') } } if (result.error) { Swal.fire('Atenção!', result.error, 'warning'); } }, error: function (msg) { console.log(msg); Swal.fire('Erro!', 'Verifique o console.', 'error'); } }); } function vincularClientePedido(idPedido) { $('#order_id').val(idPedido); ativarModal('modalVincularCliente'); } function ativarModal(idModal) { $('#' + idModal).modal({ keyboard: false, show: true, backdrop: 'static' }); } $('.btn-vincular').on('click', function() { var leadId = $('#lead_id').val(); var orderId = $('#order_id').val(); if (leadId > 0) { vincularLeadExecutar(orderId, leadId); return false; } Swal.fire('Atenção!', 'Selecione um cliente para vincular ao pedido.', 'warning'); }); function vincularLeadExecutar(orderId, leadId) { $.ajax({ type: "POST", dataType: "json", url: baseUrl + "/pedido/vincular-lead", data: { order_id: orderId, lead_id: leadId }, success: function (result) { if (result.success) { Swal.fire('Sucesso!', result.msg, 'success'); window.location.reload(); return false; } if (result.error) { Swal.fire('Atenção!', result.msg, 'warning'); return false; } }, error: function (msg) { console.log(msg); Swal.fire('Erro!', 'Verifique o console.', 'error'); } }); } function lancarPedidoCliente(idCliente) { $('form#lancar-pontos #cliente_id').val(idCliente); ativarModal('form-lancar-pedido'); } function alterarGrupoCliente(idCliente) { $('form#alterar-grupo #cliente_id').val(idCliente); ativarModal('form-alterar-grupo'); } function fecharModal(modal) { $('#cliente_id').val(''); $('#valor').val(''); $('#' + modal).modal("hide"); } function lancarPontos() { var valorPedido = $('#valor').val(); if (isNaN(parseFloat(valorPedido)) || valorPedido == '0') { Swal.fire('Atenção!', 'Informe o valor da nota.', 'warning'); return; } var dados = $('#lancar-pontos').serialize(); $.ajax({ type: "POST", dataType: "json", url: baseUrl + "/pedido/lancar", data: dados, beforeSend: function () { $('#loadingDiv').show(); }, success: function (result) { if (result.status == 1) { Swal.fire({ title: "Sucesso!", text: result.alert, showDenyButton: false, showCancelButton: false, confirmButtonText: 'OK', icon: "success", }).then(function (result) { window.location.reload(); fecharModal('form-lancar-pedido'); }); return false; } if (result.status == 0) { Swal.fire({ title: 'Atenção!', text : result.alert, icon: 'warning', timer: 1500 }); fecharModal('form-lancar-pedido'); return false; } }, error: function (result) { $('#loadingDiv').hide(); console.log(result); Swal.fire('Erro!', 'Verifique o console.', 'error'); }, complete: function () { $('#loadingDiv').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 notificarBoasVindas(leadId) { if (isNaN(parseFloat(leadId)) || leadId == '0') { Swal.fire('Atenção!', 'Cliente não informado.', 'warning'); return; } $.ajax({ type: "GET", dataType: "json", url: baseUrl + "/lead/notificar-boas-vindas", data: { id : leadId }, beforeSend: function () { $('#loadingDiv').show(); }, success: function (result) { if (result.status == 1) { Swal.fire({ title: "Sucesso!", text: result.alert, showDenyButton: false, showCancelButton: false, confirmButtonText: 'OK', icon: "success", }); return false; } if (result.status == 0) { Swal.fire({ title: 'Atenção!', text : result.alert, icon: 'warning', timer: 2000 }); return false; } }, error: function (result) { $('#loadingDiv').hide(); console.log(result); Swal.fire('Erro!', 'Verifique o console.', 'error'); }, complete: function () { $('#loadingDiv').hide(); }, }); } function showGraphQuest(idPergunta) { $.ajax({ type: "GET", dataType: "json", url: baseUrl + "/posvenda-pergunta/show-quest-chart", data: { pergunta_id : idPergunta }, beforeSend: function () { $('#loadingDiv').show(); }, success: function (result) { if (result.status == 1) { $('#modalShowGraph .modal-body').html(result.html); // var element = $("#modalShowGraph"); // element.prepend(result.html); ativarModal('modalShowGraph'); } if (result.status == 0) { Swal.fire({ title: 'Atenção!', text : result.alert, icon: 'warning', timer: 2000 }); } }, error: function (result) { $('#loadingDiv').hide(); console.log(result); Swal.fire('Erro!', 'Verifique o console.', 'error'); }, complete: function () { $('#loadingDiv').hide(); }, }); } function alterarGrupo() { var grupoId = $('form#alterar-grupo #grupo_id').val(); if (isNaN(grupoId) || grupoId == '') { Swal.fire('Atenção!', 'Informe o grupo do cliente.', 'warning'); return; } var dados = $('#alterar-grupo').serialize(); $.ajax({ type: "POST", dataType: "json", url: baseUrl + "/lead/alterar-grupo", data: dados, beforeSend: function () { $('#loadingDiv').show(); }, success: function (result) { if (result.status == 1) { Swal.fire({ title: "Sucesso!", text: result.alert, showDenyButton: false, showCancelButton: false, confirmButtonText: 'OK', icon: "success", }).then(function (result) { window.location.reload(); fecharModal('form-alterar-grupo'); }); return false; } if (result.status == 0) { Swal.fire({ title: 'Atenção!', text : result.alert, icon: 'warning', timer: 1500 }); fecharModal('form-alterar-grupo'); return false; } }, error: function (result) { $('#loadingDiv').hide(); console.log(result); Swal.fire('Erro!', 'Verifique o console.', 'error'); }, complete: function () { $('#loadingDiv').hide(); }, }); }
💾 保存文件
← 返回文件管理器