var terms = false; var listTerms = []; var searchTerm = false; var resultsProducts = ""; var resultsServices = ""; var resultsNews = ""; var resultsContacts = ""; var resultsHDI = ""; var countProducts = ""; var countServices = ""; var countNews = ""; var countContacts = ""; var countHDI = ""; var i = 0; var x = 0; var route = location.href; routeA = route.split("/"); var idioma = routeA[3]; var font = localStorage.getItem("font"); var color = localStorage.getItem("color"); var fcUser = null; var fcArea = null; var fcSubj = null; let apiLanguage = ""; //$.inArray('en', routeA) == -1 ? '' : '/' + routeA[3]; var wsterms = apiLanguage + "/contato/terms"; //var wslogin = '/'+idioma+'https://login.hdi.com.br/corporativo/autenticacao/oauth/token'; var wsprotocolGet = apiLanguage + "/contato/protocol"; var wsprotocolPost = apiLanguage + "/contato/protocol-create"; var wscidades = apiLanguage + "/contato/cidades"; var wssinistros = apiLanguage + "/contato/sinistros"; var wsapolices = apiLanguage + "/contato/apolices"; var addressAPI = apiLanguage + "/contato/endereco"; var hash = "MzI5OTRjMzItOGM4NC00ZmZjLWEyOWYtNzA1MDkyMzdjOTczOmMwMjA3NWQxLTc2YmMtNGVmOS05NTMzLWU1ODUzNmM3ZDQyYg=="; $(document).ready(function () { searchTerm = $("article .search-console input").val(); clickMenu(); $("#accessibility span.text").click(function () { var val = $(this).attr("data-val"); if (val == "minus") { $("body").css({ "font-size": "18px" }); } else { $("body").css({ "font-size": "20px" }); } $("#accessibility span.text").removeClass("selected"); $(this).addClass("selected"); localStorage.setItem( "font", $("#accessibility span.text.selected").attr("data-val") ); }); $("#accessibility span.contrast").click(function () { var val = $(this).attr("data-val"); $("body").removeClass(); $("body").addClass(val); $("#accessibility span.contrast").removeClass("selected"); $(this).addClass("selected"); localStorage.setItem( "color", $("#accessibility span.contrast.selected").attr("data-val") ); }); if (font) { $("#accessibility span.text[data-val=" + font + "]").click(); } else { $("#accessibility span.text[data-val=minus]").click(); $("#accessibility span.contrast[data-val=none]").click(); } if (color) { $("#accessibility span.contrast[data-val=" + color + "]").click(); } else { $("#accessibility span.text[data-val=minus]").click(); $("#accessibility span.contrast[data-val=none]").click(); } $("header .menu").click(function () { $(this).toggleClass("open").toggleClass("close"); $("header").removeClass("min"); $("body").toggleClass("lock"); $("nav").stop(true, true).fadeToggle(400); }); $("a[data-sofia=true]").click(function (e) { e.preventDefault(); openSofia(); }); $("#slider-products").slick({ infinite: true, arrows: true, slidesToShow: 4, slidesToScroll: 2, responsive: [ { breakpoint: 1200, settings: { slidesToShow: 4, slidesToScroll: 2, }, }, { breakpoint: 992, settings: { slidesToShow: 3, slidesToScroll: 2, }, }, { breakpoint: 768, settings: { slidesToShow: 1, slidesToScroll: 1, }, }, { breakpoint: 480, settings: { slidesToShow: 1, slidesToScroll: 1, }, }, ], }); $(".list-places").on("click", "a.button-more", function (e) { e.preventDefault(); var altText = $(this).attr("data-altext"); var defText = $(this).attr("data-deftext"); var curText = $(this).text(); $(this).prev(".info").slideToggle(); if (curText == defText) { $(this).text(altText); } else { $(this).text(defText); } }); $(".open-terms").click(function () { var carteira = $(this).attr("data-carteiras"); var carteiraX = ""; carteira = carteira.split(","); $(this).html(" Carregando..."); $(this).unbind(); i = 0; $.each(carteira, function (index, value) { if (i < carteira.length - 1) { carteiraX += '\n\t\t\t{\n\t\t\t\t"cod_carteira": "' + value + '"\n\t\t\t},'; } else if (i == carteira.length - 1) { carteiraX += '\n\t\t\t{\n\t\t\t\t"cod_carteira": "' + value + '"\n\t\t\t}'; } i++; }); var settings = { url: wsterms + "?codCarteira=" + carteira, method: "GET", processData: false, }; $.ajax(settings).done(function (response) { if (!terms) { $(".panel-terms").fadeIn(300); terms = true; } configTerms(sortObjectDesc(response["current"])); configTerms(sortObjectDesc(response["years"])); $(".open-terms").hide(); }); }); let configTerms = function (element) { $.each(element, function (Index, values) { let parentIndex = values[0]; let parentValues = values[1]; if (parentValues != "") { configHeaderTerms(parentIndex); $.each(parentValues, function (childIndex, value) { configChildrenTerms(parentIndex, value); }); } }); }; let configHeaderTerms = function (element) { $(".list-terms").append( "" + "
  • " + '

    ' + element + "

    " + '' + "
  • " ); }; let configChildrenTerms = function (parentIndex, element) { const baseUrl = window.location.href.includes("https://netd.") || window.location.href.includes("https://net.") || window.location.href.includes("localhost") ? "" : "https://www.hdi.com.br"; $(".list-terms li[data-year=" + parentIndex + "] ul").append( "" + '
  • ' + '' + '' + "
    " + element["tituloDoc"] + ": " + element["nomeCarteira"] + "
    " + "

    Vigência: " + element["inicioVigencia"] + " " + element["fimVigencia"] + "

    " + "
    " + "
  • " ); }; let sortObjectDesc = function (elements) { return Object.entries(elements).sort(function (a, b) { return b[0] - a[0]; }); }; $(".list-terms").on("click", "h3", function () { var isopen = $(this).attr("data-open"); if (isopen == "false") { $(".list-terms li h3").attr("data-open", "false"); $(".list-terms li").removeClass("open"); $(this).parent("li").addClass("open"); $(".list-terms ul").stop(true, true).slideUp(300); $(this).siblings("ul").stop(true, true).slideDown(300); } $(this).attr("data-open", "true"); }); $(".select select") .on("change", function () { var str = ""; str = $(this).find(":selected").text(); $(this).siblings("span").text(str); $(this).parent(".select").removeClass("error"); }) .trigger("change"); $(".accordion h5").click(function () { $(".accordion .desc").stop(true, true).slideUp(300); $(this).next(".desc").stop(true, true).slideDown(300); }); $("#form-identification").on("change", function () { var user = $(this).find(":selected").val(); fcUser = user; getArea(user); }); $("#form-area").on("change", function () { var who = $("#form-identification").find(":selected").val(); var val = $(this).find(":selected").val(); $(".optional-form").stop(true, true).slideUp(300); $(".reveal button").removeClass("disable"); $(".alert blockquote div[data-who]").hide(); $(".alert blockquote div[data-who=" + who + "]").show(); if (val != "0") { $(".alert blockquote div").hide(); $(".alert blockquote div[data-who=" + who + "]").show(); $( ".alert blockquote div[data-who=" + who + "] div[data-alert=" + val + "]" ).show(); $(".alert").stop(true, true).slideDown(300); } else { $(".alert").hide(); } if (val == "7") { $(".alert").hide(); $(".optional-form").stop(true, true).slideDown(300); } if (who == "4") { $(".alert blockquote div").hide(); $(".alert blockquote div[data-who=4]").show(); $(".alert blockquote div[data-who=4] div[data-alert=0]").show(); $(".alert").stop(true, true).slideDown(300); } fcArea = val; getSubject(val, fcUser); }); $("#form-subject").on("change", function () { var val = $(this).find(":selected").val().split("|")[0]; var area = $("#form-area").find(":selected").val(); var user = $("#form-identification").find(":selected").val(); fcSubj = val; fcArea = area; fcUser = user; getFields(fcUser, fcArea, fcSubj); }); $(".reveal").on("click", "button", function (e) { e.preventDefault(); var val = $(this).val(); $(".reveal button").addClass("disable"); $(this).removeClass("disable"); if (val == "no") { $(this) .parent(".reveal") .parent(".alert") .next(".optional-form") .stop(true, true) .slideDown(300); } else { $(this) .parent(".reveal") .parent(".alert") .next(".optional-form") .stop(true, true) .slideUp(300); window.location.href = window.location.origin; } setTimeout(function () { $(".formularioOuvidoriaFaleConosco").parsley().refresh(); }, 500); }); // search if (searchTerm) { route = route.split("/"); route = $.inArray("en", route) == -1 ? /busca/ : "/" + route[3] + "/search/"; var settings = { async: true, crossDomain: true, url: route + "api?q=" + searchTerm + "&skip=0&filter=all", method: "GET", headers: { "content-type": "application/x-www-form-urlencoded", }, }; $.ajax(settings).done(function (response) { resultsProducts = response["products"]["items"]; nameProducts = response["products"]["menu_name"]; resultsServices = response["services"]["items"]; nameServices = response["services"]["menu_name"]; resultsNews = response["news"]["items"]; nameNews = response["news"]["menu_name"]; resultsContacts = response["contacts"]["items"]; nameContacts = response["contacts"]["menu_name"]; resultsHDI = response["group-hdi"]["items"]; nameHDI = response["group-hdi"]["menu_name"]; countProducts = parseInt(response["products"]["count"]); countServices = parseInt(response["services"]["count"]); countNews = parseInt(response["news"]["count"]); countContacts = parseInt(response["contacts"]["count"]); countHDI = parseInt(response["group-hdi"]["count"]); var totalResults = countProducts + countServices + countNews + countContacts + countHDI; $("#searchTotal").text(totalResults); if (resultsProducts) { $("#filterSearch").append( '" ); i = 0; $.each(resultsProducts, function () { var html = "
  • " + '' + resultsProducts[i]["title"] + "" + "

    " + resultsProducts[i]["text"] + "

    " + "
  • "; $("div[data-tab=products] .list-results").append(html); if (i <= 2) { $(".list-results.short[data-list=products]").append( html ); } i++; }); if (resultsProducts.length < 10) { $("*[data-tab=products] .button").hide(); } } else { $(".list-results[data-list=products]").remove(); $("*[data-tab=products]").remove(); } if (resultsServices) { $("#filterSearch").append( '" ); i = 0; $.each(resultsServices, function () { var html = "
  • " + '' + resultsServices[i]["title"] + "" + "

    " + resultsServices[i]["text"] + "

    " + "
  • "; $("div[data-tab=services] .list-results").append(html); if (i <= 2) { $(".list-results.short[data-list=services]").append( html ); } i++; }); if (resultsServices.length < 10) { $("*[data-tab=services] .button").hide(); } } else { $(".list-results[data-list=services]").remove(); $("*[data-tab=services]").remove(); } if (resultsHDI) { $("#filterSearch").append( '" ); i = 0; $.each(resultsHDI, function () { var html = "
  • " + '' + resultsHDI[i]["title"] + "" + "

    " + resultsHDI[i]["text"] + "

    " + "
  • "; $("div[data-tab=group-hdi] .list-results").append(html); if (i <= 2) { $(".list-results.short[data-list=group-hdi]").append( html ); } i++; }); if (resultsHDI.length < 10) { $("*[data-tab=group-hdi] .button").hide(); } } else { $(".list-results[data-list=group-hdi]").remove(); $("*[data-tab=group-hdi]").remove(); } if (resultsNews) { $("#filterSearch").append( '" ); i = 0; $.each(resultsNews, function () { var html = "
  • " + '' + resultsNews[i]["title"] + "" + "

    " + resultsNews[i]["text"] + "

    " + "
  • "; $("div[data-tab=news] .list-results").append(html); if (i <= 2) { $(".list-results.short[data-list=news]").append(html); } i++; }); if (resultsNews.length < 10) { $("*[data-tab=news] .button").hide(); } } else { $(".list-results[data-list=news]").remove(); $("*[data-tab=news]").remove(); } if (resultsContacts) { $("#filterSearch").append( '" ); i = 0; $.each(resultsContacts, function () { var html = "
  • " + '' + resultsContacts[i]["title"] + "" + "

    " + resultsContacts[i]["text"] + "

    " + "
  • "; $("div[data-tab=contacts] .list-results").append(html); if (i <= 2) { $(".list-results.short[data-list=contacts]").append( html ); } i++; }); if (resultsContacts.length < 10) { $("*[data-tab=contacts] .button").hide(); } } else { $(".list-results.short[data-list=contacts]").remove(); $("*[data-tab=contacts]").remove(); } }); } $(".search-filter select").on("change", function () { var val = $(this).find(":selected").val(); $(".tab").fadeOut(300, function () { $(".tab[data-tab=" + val + "]") .stop(true, true) .fadeIn(500); }); }); $(".search-results .tab .load-more").click(function (e) { e.preventDefault(); var tab = $(this).data("tab"); $(".search-filter select").val(tab).trigger("change"); }); $(".tab .load-more-full").click(function (e) { e.preventDefault(); route = location.href; route = route.split("/"); route = $.inArray("en", route) == -1 ? /busca/ : "/" + route[3] + "/search/"; var area = $(this).data("area"); var page = $(this).attr("data-page"); page = parseInt(page); page = page + 1; $(this).attr("data-page", page); var settings = { async: true, crossDomain: true, url: route + "api?q=" + searchTerm + "&skip=" + page + "&filter=" + area + "", method: "GET", headers: { "content-type": "application/x-www-form-urlencoded", }, }; $.ajax(settings, area).done(function (response) { i = 0; response = response[area]["items"]; if (response) { $.each(response, function () { var html = "
  • " + '' + response[i]["title"] + "" + "

    " + response[i]["text"] + "

    " + "
  • "; $("div[data-tab=" + area + "] .list-results").append(html); i++; }); } else { $(".tab .load-more-full[data-area=" + area + "]").hide(); } }); }); $("#loadNews").click(function () { route = location.href; route = route.split("/"); route = $.inArray("en", route) == -1 ? "/" + route[3] + "/" + route[4] + "/" : "/" + route[3] + "/" + route[4] + "/" + route[5] + "/"; var page = $(this).attr("data-page"); page = parseInt(page); page = page + 1; $(this).attr("data-page", page); var settings = { async: true, crossDomain: true, url: route + "carregar/" + page, method: "GET", headers: { "content-type": "application/x-www-form-urlencoded", }, }; $.ajax(settings).done(function (response) { if (response.length > 0) { i = 0; var html = ""; $.each(response, function (index, item) { if (i == 2) { $(".list-news .row.row-main").append(html); html = ""; i = 0; } html += '
    ' + '
    ' + '' +
                        item[' + '' + item["date"].replace("00:00:00", "").trim().split('-').reverse().join('/') + "" + "
    " + "
    " + item["title"] + "
    " + "

    " + item["short_description"] + "

    " + 'Ler artigo' + "
    "; if (response[response.length - 1]["id"] == item["id"]) { $(".list-news .row.row-main").append(html); html = ""; } i++; }); } else { $("#loadNews").hide(); } }); }); $("input, select, textarea").focus(function () { $(this).removeClass("error"); }); $("input.phone-mask") .inputmask("(99) 9999-99999", { placeholder: " " }) .focusout(function (event) { var target, phone, element; target = event.currentTarget ? event.currentTarget : event.srcElement; phone = target.value.replace(/\D/g, ""); element = $(target); //element.unmask(); if (phone.length > 10) { element.inputmask("(99) 99999-9999", { placeholder: " " }); } else { element.inputmask("(99) 9999-9999", { placeholder: " " }); } }); //$('input.cpf-mask').inputmask("99999999999999", {placeholder: " "}) $("input.cpf-mask") .keyup(function (key) { cpfCnpjMask($(this)); }) .blur(function () { var length = $(this).val().trim().length; /* if ($(this).attr('name') == 'm_num_cpf') { popularCampoApolice(this); mostrarCamposPessoaFisica(2); }*/ //popularCampoApolice(this); mostrarCamposPessoaFisica(2, $(this).attr("name")); if (length == 14) { mostrarCamposPessoaFisica(1, $(this).attr("name")); // if ($(this).attr('name') == 'm_num_cpf') { // mostrarCamposPessoaFisica(1); // } } }); $("input.data_nascimento-mask").inputmask("99/99/9999", { placeholder: " ", }); $("input.cep-mask").inputmask("99999-999", { placeholder: " " }); $("input.cpf-mask").keypress(function (e) { //if the letter is not digit then display error and don't type anything if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) { //display error message $("#errmsg").html("Digits Only").show().fadeOut("slow"); return false; } }); /*$('input.cpf-mask').focus(function () { $('input.cpf-mask').unmask(); })*/ function mostrarCamposPessoaFisica(type, name) { var index = null; if ( ($("#m_identificacao").val() == "002" || $("#m_identificacao").val() == "010" || $("#m_identificacao").val() == "006") && name == "reclamante_cpf" ) { index = 0; $(".camposPessoaFisica").hide(); } else if ( ($("#m_identificacao").val() == "001" || $("#m_identificacao").val() == "") && name == "m_num_cpf" ) { index = 1; $(".camposPessoaFisica").hide(); } if (index != null) { var camposPessoaFisica = $(".camposPessoaFisica").eq(index); var data = camposPessoaFisica.find(".m_data_nascimento"); var sexo = camposPessoaFisica.find(".m_sexo"); if (data.val() != undefined && sexo.val() != undefined) { if (type == 1) { camposPessoaFisica.show(); } else { resetCamposPessoaFisica(camposPessoaFisica); } data.parsley().reset(); sexo.parsley().reset(); sexo.parents(".input-container.select").css({ border: "1px solid #ccc", "margin-bottom": "1rem", }); } } } function resetCamposPessoaFisica(camposPessoaFisica) { var data = camposPessoaFisica.find(".m_data_nascimento"); var sexo = camposPessoaFisica.find(".m_sexo"); data.val(""); sexo.val(""); sexo.change(); camposPessoaFisica.hide(); data.parsley().reset(); sexo.parsley().reset(); sexo.parents(".input-container.select").css({ border: "1px solid #ccc", "margin-bottom": "1rem", }); } $("#m_identificacao").change(function () { if ( $(this).val() == "002" || $(this).val() == "010" || $(this).val() == "006" ) { $(".reclamante_cpf").show(); $(".reclamante_cpf").find(".required").eq(1).hide(); $(".reclamante_cpf").find("input[name=reclamante_nome]").hide(); resetCamposPessoaFisica($(".camposPessoaFisica").eq(1)); //$('.nome_declarante').hide(); //$('.nome_declarante').find('input').val(''); } else { $(".reclamante_cpf").hide(); $("input[name=reclamante_cpf]").val(""); $("input[name=reclamante_nome]").val(""); $(".nome_declarante").show(); resetCamposPessoaFisica($(".camposPessoaFisica").eq(0)); if ($("input[name=m_num_cpf]").val().trim().length == 14) { $(".camposPessoaFisica").eq(1).show(); } } if ($(this).val() == "010") { $(".m_identificacao_outro").show(); } else { $(".m_identificacao_outro").hide(); $(".m_identificacao_outro input").val(""); } $("input[name=reclamante_cpf]").parsley().reset(); $(".m_identificacao_outro input").parsley().reset(); }); $("#m_cep").blur(function () { if ($(this).parsley().isValid()) { /*let settings = { "url": "https://viacep.com.br/ws/" + $('#m_cep').val().replace(/\D/g, '') + "/json", "method": "get" };*/ let settings = { url: addressAPI, method: "get", data: { cep: $("#m_cep").val().replace(/\D/g, ""), }, }; $.ajax(settings).done(function (response) { if (response.results.address_components) { $("#m_endereco") .val(response.results.address_components.nomLogradouro) .parsley() .reset(); $("#m_bairro") .val(response.results.address_components.nomBairro) .parsley() .reset(); $("#m_estado") .val(response.results.address_components.uf) .parsley() .reset(); $("#m_estado").change(); $("#m_municipio").val( response.results.address_components.municipio ); // municipioAPI = response.results.address_components.municipio; } }); } }); $(document).on("change", "select:not(:hidden)", function () { checkSelect($(this)); }); $(".formularioOuvidoriaFaleConosco").parsley({ excluded: "" + "input:disabled, " + ":disabled, " + "input[type=hidden], " + "input:hidden, " + "textarea:disabled, " + "textarea[type=hidden] " + "select:disabled, " + "select:hidden", }); $("#submitForm").click(function (e) { e.preventDefault(); if ( $(".formularioOuvidoriaFaleConosco").parsley().validate() && grecaptcha !== undefined && grecaptcha.getResponse() ) { $(".g-recaptcha").removeClass("parsley-error"); $(".g-recaptcha-error").hide(); sendFormOuvidoriaFaleConosco(); } else { grecaptcha.reset(); $(".g-recaptcha").addClass("parsley-error"); $(".g-recaptcha-error").show(); $("select:not(:hidden)").each(function () { checkSelect($(this)); }); } }); $('input[name="protocol"], input[name="m_num_cpf"]').focus(function () { $(".error-protocol").hide(); $(".error-insured-cpf").hide(); $('input[name="protocol"], input[name="m_num_cpf"]').removeClass( "error" ); }); $("#checkProtocol").click(function (e) { e.preventDefault(); $(".error-protocol").hide(); $(".error-insured-cpf").hide(); $("#confirmProt").hide(); var protocol = $("form input[name=protocol]").val(); if (protocol != "") { $(".loading__container:not(.loading__search)").show(); var settings = { async: true, crossDomain: true, url: wsprotocolGet + "?protocol=" + protocol, data: { language: location.pathname.split("/")[1], }, method: "GET", headers: { "Content-Type": "application/json", }, }; $.ajax(settings) .done(function (response) { var expired = response.data.expired; if (expired) { $(".loading__container:not(.loading__search)").hide(); $("#formularioOuvidoria").show(); $("#confirmProt").stop(true, true).fadeOut(300); setTimeout(function () { $(".formularioOuvidoriaFaleConosco") .parsley() .refresh(); }, 500); } }) .fail(function (response) { $(".loading__container:not(.loading__search)").hide(); var erro = response.responseJSON; erro = erro.message; $("#confirmProt").html(erro).stop(true, true).fadeIn(300); $("#formularioOuvidoria").hide(); }); /*$.ajax(settings).fail(function (response) { var erro = $.parseJSON(response.responseText); erro = erro.erros.mensagem; $('#confirmProt').html(erro).stop(true, true).fadeIn(300); $('#formularioOuvidoria').hide(); });*/ } else { let protocolInput = $("form input[name=protocol]"); let insuredInput = $("form input[name=m_num_cpf]"); if (protocolInput.val().replace(/\D/g, "") == "") { protocolInput.addClass("error"); $(".error-protocol").show(); } } }); }); $(window).scroll(function () { var scrolled = $(this).scrollTop(); var heightW = $(window).height(); var heightW = 300; if (scrolled >= heightW) { $("header").addClass("min"); } else { $("header").removeClass("min"); } }); function openSofia() { $("body").addClass("lock"); $("#modalSofia").stop(true, true).fadeIn(300); } function getArea(user) { route = location.href; route = route.split("/"); idioma = route[3]; if (idioma != "en") { var text_escolha_area = "Escolha a área"; var text_assistencia = "Assistência 24 horas"; var text_sinistro = "Sinistro"; var text_endosso = "Renovações e alterações na apólice (endossos)"; var text_cancel = "Cancelamento"; var text_kit = "Não recebi minha apólice / kit"; var text_portal_segurado = "Não consigo acesso ao portal do segurado"; var text_institucional = "Institucional"; var text_cotacao = "Cotação"; } else { var text_escolha_area = "Select a department"; var text_assistencia = "24 hour assistance"; var text_sinistro = "Claims Service"; var text_endosso = "Policy renovation or alteration"; var text_cancel = "Cancel policy"; var text_kit = "I haven't received my policy kit"; var text_portal_segurado = "I can't access the Policyholder's Portal"; var text_institucional = "Institutional"; var text_cotacao = "Online quote"; } $(".alert").hide(); $(".optional-form").stop(true, true).slideUp(300); if (user == 1) { var options = '" + '" + '" + '" + '" + '" + '"; } else if (user == 7) { var options = '" + '" + '" + ''; } else if (user == 2 || user == 4) { var options = '" + '"; } else if (user == 3) { var options = '" + '"; } else { var options = '" + '"; } if (user == 8) { $(".area").hide(); $(".group.reveal").hide(); $(".alert div").hide(); $(".alert div[data-who=8], .alert div[data-alert=0]").show(); $(".alert").slideDown(300); } else if (user == 4) { $("#form-area").html(options); $("#form-area>option:eq(0)").prop("selected", true); $(".area .select span").html(text_escolha_area); $(".area").show(); $(".alert div").hide(); $(".group.reveal").show(); $(".alert div[data-who=4], .alert div[data-alert=0]").show(); $(".alert").slideDown(300); } else if (user == 5) { $(".area").hide(); $(".group.reveal").hide(); $("#form-area").html(options); $("#form-area>option:eq(0)").prop("selected", true); $(".area .select span").html(text_escolha_area); $(".alert div").hide(); $(".alert div[data-who=5], .alert div[data-alert=0]").show(); $(".alert").slideDown(300); } else { $("#form-area").html(options); $("#form-area>option:eq(0)").prop("selected", true); $(".area .select span").html(text_escolha_area); $(".group.reveal").show(); $(".area").show(); } } function getSubject(val, fcUser) { route = location.href; route = route.split("/"); idioma = route[3]; if (idioma != "en") { var text_escolha_assunto = "Escolha o assunto"; var text_institucional = "Institucional"; var text_automovel = "Automóvel"; var text_residencia = "Residencial"; var text_vidros = "Vidros"; var text_sinistro_auto = "Sinistro Auto"; var text_sinistro_residencia = "Sinistro Residencial"; } else { var text_escolha_assunto = "Select a subject"; var text_institucional = "Institucional"; var text_automovel = "Auto"; var text_residencia = "Residence"; var text_vidros = "Glass"; var text_sinistro = "Claims Service"; var text_sinistro_auto = "Auto Claims"; var text_sinistro_residencia = "Residence Claims"; } if (val == 1) { var options = '" + '" + '" + '"; } else if (val == 2) { var options = '" + '" + '"; if (fcUser == "2") { var options = '" + '"; } } else if (val == 3 || val == 5 || val == 8) { var options = '" + '" + '"; } else if (val == 4 || val == 6 || val == 7) { var options = '" + '"; } $("#form-subject").html(options); $("#form-subject>option:eq(0)").prop("selected", true); $(".subject span").html(text_escolha_assunto); } function getFields(fcUser, fcArea, fcSubj) { $(".license").hide(); $(".apolice").hide(); $(".sinistro").hide(); $(".sinistro-drop").hide(); $(".apolice-drop").hide(); if (fcUser == 1) { if (fcArea == 1) { if (fcSubj == 34 || fcSubj == 18) { $(".license").show(); $(".apolice-drop").show(); } else if (fcSubj == 38 || fcSubj == 19) { $(".apolice-drop").show(); } else if (fcSubj == 45) { $(".license").show(); $(".apolice-drop").show(); } } else if (fcArea == 2) { if (fcSubj == 28) { $(".license").show(); $(".sinistro-drop").show(); } else if (fcSubj == 26) { $(".apolice-drop").show(); $(".sinistro").show(); } } else if (fcArea == 3) { if (fcSubj == 34 || fcSubj == 18) { $(".license").show(); $(".apolice-drop").show(); } else if (fcSubj == 38 || fcSubj == 19) { $(".apolice-drop").show(); } } else if (fcArea == 4) { if (fcSubj == 34 || fcSubj == 18) { $(".license").show(); $(".apolice-drop").show(); } else if (fcSubj == 38 || fcSubj == 19) { $(".apolice-drop").show(); } else if (fcSubj == 17) { $(".license").show(); $(".apolice-drop").show(); } } else if (fcArea == 5) { if (fcSubj == 34 || fcSubj == 18) { $(".license").show(); $(".apolice-drop").show(); } else if (fcSubj == 38 || fcSubj == 19) { $(".apolice-drop").show(); } } else if (fcArea == 6) { if (fcSubj == 34 || fcSubj == 18) { $(".license").show(); $(".apolice-drop").show(); } else if (fcSubj == 38 || fcSubj == 19) { $(".apolice-drop").show(); } } } else if (fcUser == 7) { if (fcArea == 1) { if (fcSubj == 34 || fcSubj == 18) { $(".license").show(); $(".apolice-drop").show(); } else if (fcSubj == 38 || fcSubj == 19) { $(".apolice-drop").show(); } else if (fcSubj == 45) { $(".license").show(); $(".apolice-drop").show(); } } else if (fcArea == 2) { if (fcSubj == 28) { $(".license").show(); $(".sinistro-drop").show(); } else if (fcSubj == 26) { $(".apolice-drop").show(); $(".sinistro").show(); } } else if (fcArea == 4) { if (fcSubj == 34 || fcSubj == 18) { $(".license").show(); $(".apolice-drop").show(); } else if (fcSubj == 38 || fcSubj == 19) { $(".apolice-drop").show(); } else if (fcSubj == 4) { $(".license").show(); $(".apolice-drop").show(); } } } else if (fcUser == 3) { $(".license").hide(); $(".apolice").hide(); $(".sinistro").hide(); $(".sinistro-drop").hide(); } else if (fcUser == 4) { $(".license").show(); $(".apolice").show(); $(".sinistro-drop").show(); } else if (fcUser == 5) { $(".license").hide(); $(".apolice").hide(); $(".sinistro").hide(); $(".sinistro-drop").hide(); } else if (fcUser == 2) { if (fcArea == 2) { if (fcSubj == 28) { $(".license").show(); $(".sinistro-drop").show(); } else if (fcSubj == 26) { $(".apolice").show(); $(".sinistro").show(); } } } else if (fcUser == 8) { $(".license").hide(); $(".apolice").hide(); $(".sinistro").hide(); $(".sinistro-drop").hide(); } } function popularCampoCidade(obj, municipio) { var param = $(obj).val(); $.ajax({ async: true, crossDomain: true, type: "GET", url: wscidades + "?cidade=" + param, success: function (data) { xmlTag = "cidades"; cidades = data.substring( data.indexOf("<" + xmlTag) + xmlTag.length + 2, data.indexOf("Selecione' ); $.each(sinistros, function (index, value) { $(".sinistro-drop select").append( '" ); i++; }); $(".sinistro-drop").show(); $(".sinistro").hide(); } else { if ( $("#form-identification").val() == "1" || $("#form-identification").val() == "7" ) { $(".sinistro-drop").hide(); $(".sinistro").show(); } } } }); } function popularCampoApolice(obj, municipio) { var param = $(obj).val(); var settings = { async: true, crossDomain: true, url: wsapolices + "?cpf=" + param, method: "GET", }; $.ajax(settings).done(function (response) { $(".apolice-drop select option").remove(); if (response["dados"]) { var cod = response["dados"]["mensagem"][0]["errorCode"]; $(".apolice-drop select").html(""); if (cod == 0) { var apolices = response["dados"]["apolice"]; i = 0; $(".apolice-drop select").append( '' ); $.each(apolices, function (index, value) { var valueApolice = apolices[i]["cod_empresa"] + "." + apolices[i]["cod_sucursal"] + "." + apolices[i]["cod_carteira"] + "." + apolices[i]["tip_docum"] + "." + apolices[i]["seq_docum"] + "." + "000000"; $(".apolice-drop select").append( '" ); i++; }); if (fcSubj != 5) { $(".apolice-drop").show(); $(".apolice").hide(); } } else { if ( $("#form-identification").val() == "1" || $("#form-identification").val() == "7" ) { if (fcSubj != 5) { $(".apolice-drop").hide(); $(".apolice").show(); } } } } }); } let clickMenu = function () { $(".menu-category").click(function () { let content = $(this).next(".list-areas"); if ($(this).hasClass("open")) { $(this).removeClass("open"); } else { $(this).addClass("open"); } let index = $(".menu-category").index($(this)); let allMenu = $(".menu-category:not(:eq(" + index + "))"); allMenu.removeClass("open"); allMenu.next(".list-areas").slideUp(300); content.slideToggle(300); }); }; let cpfCnpjMask = function (element, key) { if (element.val() != undefined) { let elementValue = element.val().replace(/\D/g, ""); let length = element.val().replace(/\D/g, "").length; if (length <= 11 && element.attr("cpf") != "") { element.attr("data-cpf", ""); element.removeAttr("data-cnpj"); element.inputmask("999.999.999-999", { placeholder: " " }); } else if (length > 11 && element.attr("cnpj") != "") { element.attr("data-cnpj", ""); element.removeAttr("data-cpf"); element.inputmask("99.999.999/9999-99", { placeholder: " " }); } } }; $(document).keyup(function (e) { if (e.key === "Escape") { $("header .menu").addClass("open").removeClass("close"); $("header").removeClass("min"); $("body").removeClass("lock"); $("nav").stop(true, true).fadeOut(400); } }); let sendFormOuvidoriaFaleConosco = function () { var ajax = new XMLHttpRequest(); ajax.onreadystatechange = function () { if (this.readyState === 4) { if (this.status === 200) { alert(this.responseText); } } }; $.ajaxSetup({ headers: { "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"), }, }); $("#submitForm").text("Enviando...").attr("disabled", "disabled"); $.post( "/captcha", { recaptcha: grecaptcha.getResponse() }, function (data) { if (data == "Recaptcha Validated") { let birthday = $( ":input[name=m_data_nascimento]:visible" ).val(); if (birthday != undefined) { birthday = birthday.split("/"); birthday = birthday[2] + "-" + birthday[1] + "-" + birthday[0]; } else { birthday = ""; } var settings = { async: true, //"crossDomain": true, url: wsprotocolPost, method: "POST", //"processData": false, data: { language: location.pathname.split("/")[1], protocolo: $("input[name=protocol]").val(), chamado_externo: true, idioma: "P", operacao: { id: $("select[name=identificacao] :selected").val(), text: $( "select[name=identificacao] :selected" ).text(), }, identifica: { id: $("select[name=m_area] :selected").val(), text: $("select[name=m_area] :selected").text(), }, grupo_area: "", cod_assunto: { id: $("select[name=cod_assunto] :selected").val(), text: $( "select[name=cod_assunto] :selected" ).text(), }, funcao: { id: $("select[name=m_funcao] :selected").val(), text: $("select[name=m_funcao] :selected").text(), }, cpf_cnpj: $("input[name=m_num_cpf]").val(), nom_declarante: $("input[name=m_declarante]").val(), comentario: $("article form textarea").val(), cod_origem: $("#submitForm").attr("data-origem"), apolice: $('input[name="m_sinistro"]').val(), sinistro: $("input[name=m_sinistro]").val(), placa: $("input[name=m_placa]").val(), user_id: "", situacao: "9", telefone: $("input[name=m_tel_contato]").val(), celular: "", email: $("input[name=m_email]").val(), estado: { id: $("#m_estado :selected").val(), text: $("#m_estado :selected").text(), }, cidade: { id: $("#m_cidade :selected").val(), text: $("#m_cidade :selected").text(), }, cod_empresa: $("input[name=m_cod_empresa]").val(), cod_sucursal: $("input[name=m_cod_sucursal]").val(), cod_carteira: $("input[name=m_cod_carteira]").val(), tip_docum: "A", seq_docum: $("input[name=m_seq_docum]").val(), version: $("input[name=version]").val(), reclamante_tipo: $("#m_identificacao").val() ? $("#m_identificacao").val() : "", reclamante_outro: $( "input[name=m_identificacao_outro]" ).val() ? $("input[name=m_identificacao_outro]").val() : "", reclamante_sexo: $(".m_sexo:visible").val() ? $(".m_sexo:visible").val() : "", reclamante_data_nascto: birthday, reclamante_cep: $("#m_cep").val() ? $("#m_cep").val() : "", reclamante_ender: $("#m_endereco").val() ? $("#m_endereco").val() : "", reclamante_bairr: $("#m_bairro").val() ? $("#m_bairro").val() : "", reclamante_cpf: $("input[name=reclamante_cpf]").val() ? $("input[name=reclamante_cpf]").val() : "", reclamante_nome: $("input[name=reclamante_nome]").val(), channelId: $("#channelId").val(), }, }; $(".g-recaptcha").removeClass("parsley-error"); $(".g-recaptcha-error").hide(); $(".formularioOuvidoriaFaleConosco").hide(); $(".formularioProtocolo").hide(); $(".loading__container:not(.loading__search)").show(); $([document.documentElement, document.body]).animate( { scrollTop: $(".loading__container").offset().top - 300, }, 500 ); $.ajax(settings) .done(function (response) { route = location.href; route = route.split("/"); idioma = location.pathname.split("/")[1]; var mensagem = response.message; if (idioma != "en") { var html = "

    Formulário enviado com sucesso

    " + mensagem + "

    "; } else { var html = "

    Form sent successfully

    " + mensagem + "

    "; } $(".loading__container").hide(); $("#confirm").html(html).stop(true, true).fadeIn(300); $("#submitForm").text("Enviar").removeAttr("disabled"); }) .fail(function (response) { var erro = response.responseJSON; erro = erro.message; $(".loading__container").hide(); $("#confirm").html(erro).stop(true, true).fadeIn(300); }); } else { $("#submitForm").text("Enviar").removeAttr("disabled"); grecaptcha.reset(); $(".g-recaptcha").addClass("parsley-error"); $(".g-recaptcha-error").show(); } } ); }; $(function () { window.Parsley.addValidator("checkcpfcnpj", checkCpfCnpj) .addValidator("checkdate", checkDate) .addValidator("checkcep", checkCep) .addValidator("checkpolicy", checkPolicy); }); let checkCpfCnpj = function (element) { let elementValue = element.trim().replace(/\D/g, ""); let length = elementValue.length; /*if (element.is(':visible') && (elementValue == '' || (length != 11 && length != 14))) { element.addClass("error"); return false; }*/ return length == 11 || length == 14; }; let checkPolicy = function (element) { let elementValue = element.trim().replace(/\D/g, ""); let length = elementValue.length; /*if (element.is(':visible') && (elementValue == '' || (length != 11 && length != 14))) { element.addClass("error"); return false; }*/ return length == 20; }; let checkDate = function (element) { let dateString = element.trim(); let length = dateString.replace(/\D/g, "").length; let dateSplit = dateString.split("/"); let dateConfigured = dateSplit[2] + "/" + dateSplit[1] + "/" + dateSplit[0]; let dateTyped = new Date(dateConfigured); dateTyped.setHours(0, 0, 0, 0); let now = new Date(); now.setHours(0, 0, 0, 0); now.setYear(now.getFullYear() - 10); return length == 8 && dateTyped < now; }; let checkCep = function (element) { let cep = element.replace(/\D/g, ""); if (cep.length < 8) { return false; } switch (cep) { case "": case "00000000": case "11111111": case "22222222": case "33333333": case "44444444": case "55555555": case "66666666": case "77777777": case "88888888": case "99999999": return false; default: return true; } }; let checkSelect = function (element) { let parents = element.parents(".input-container.select"); if (!element.parsley().isValid()) { parents.css({ border: "1px solid #f9afae", "margin-bottom": "5px", }); } else { parents.css({ border: "1px solid #ccc", "margin-bottom": "1rem", }); } };