let removedIdPurchase = null; let urlTokenParameters = null; initializeCountriesLang(idioma); $(document).foundation({ reveal: { close_on_background_click: true, close_on_esc: true } }); dayjs.extend(dayjs_plugin_localeData); dayjs.extend(dayjs_plugin_timezone); dayjs.extend(dayjs_plugin_updateLocale); dayjs.extend(dayjs_plugin_localizedFormat); dayjs.extend(dayjs_plugin_utc); dayjs.extend(dayjs_plugin_weekOfYear); dayjs.extend(dayjs_plugin_weekYear); dayjs.extend(dayjs_plugin_customParseFormat); dayjs.extend(dayjs_plugin_duration); dayjs.extend(dayjs_plugin_isoWeek); if (idioma == 'in_ID') { dayjs.locale('id'); } else if(idioma == 'da_DK') { dayjs.locale('da'); } else { dayjs.locale(idioma.replace("_", "-").toLowerCase()); } //Funciones para redimendionar cuerpo y establecer pie $(document).ready(function() { try { // Textos legales $("#divContenidoPoliticaCookies").html(PoliticaCookies); $("#divContenidoCondicionesLegales").html(CondicionesLegales); $("#divContenidoPoliticaPrivacidad").html(PoliticaPrivacidad); } catch (err) { } let p4Timezone = localStorage.getItem('timezone'); if (p4Timezone == null) { p4Timezone = Intl.DateTimeFormat().resolvedOptions().timeZone; } if (userTimezone == null || userTimezone == "" || userTimezone != p4Timezone) { EntradasAjax.changeUserTimezone(p4Timezone, (storedTimezone) => localStorage.setItem('timezone', storedTimezone) ); } asignarAltura(); inicializarCarrito(); let defaultGAaccount = CONFIG_GA4[0]; if (defaultGAaccount.value != null && defaultGAaccount.value != "") { gtag('get', defaultGAaccount.value, 'client_id', function(clientId){dataLayerP4.guestId = clientId}) } if( typeof customCompanyScript === 'function' ) { customCompanyScript(); } initializeLanguageSelector(); initializeCurrencySelector(); $('.alert-box a.close').on("click", function(){ $(this).parent().hide(); }); buildTokenParametersForUrl(); }); $(window).on("resize", function() { //asignarAltura(); }); function asignarAltura() { asignarAlturaCuerpo(0); } var diffTimeClientServer = new Date().getTime() - tServer; if (Math.abs(diffTimeClientServer) < 60000) { diffTimeClientServer = 0; } function getDateCorrectedServer() { if (diffTimeClientServer == 0) { return new Date(); } return new Date(new Date().getTime() - diffTimeClientServer); } /** * Establece el evento en los cambios de idioma, para componer la url con el nuevo idioma y recargar la página */ function initializeLanguageSelector() { //footer $(".ctrl-change-lng").each(function() { var url = window.location.href; var str_url_post = url.substring(url.lastIndexOf("/")+1, url.length); if (dataLayerP4.action == "purchase" || dataLayerP4.action == "checkout") { var bookingNumberSetted = $("#localizador").val(); if(bookingNumberSetted && bookingNumberSetted != "" && str_url_post.indexOf("localizador=") < 0) { if(str_url_post.indexOf("?") >= 0) { str_url_post = str_url_post.replace("?", "?localizador="+bookingNumberSetted+"&"); } else { str_url_post += "?localizador=" + bookingNumberSetted; } } } //data-value para el onChange $(this).parent().attr('data-value', $(this).attr('href')+""+str_url_post); $(this).attr('href', $(this).attr('href')+""+str_url_post); }); $('#language-selector').dropdown({ on: 'click', onChange: function(val) { window.location.href = val; } }); } var first_load_currency = false; function initializeCurrencySelector() { $('#currency-selector').dropdown({ on: 'click', onChange: function(val) { if(finalCurrency != null && finalCurrency != val && first_load_currency == false){ changeCurrency(val); setTimeout(function(){ var title = $("#tooltip-currency-info.tooltip").html(); swal({ title: '', type: 'info', html:title, showCloseButton: true, showCancelButton: false, focusConfirm: true, confirmButtonText: polyglot.t("OK"), confirmButtonAriaLabel: 'Ok', }); }, 500); } if(first_load_currency) { first_load_currency = false; } } }); if (localStorage.currency && localStorage.currency != baseCurrency) { first_load_currency = true; $('#currency-selector').dropdown('set selected', localStorage.currency); changeCurrency(localStorage.currency); } } function asignarAlturaCuerpo(indiceNegativo) { var h_window = $(window).height(); var h_footer = $("footer").outerHeight(); var h_header_dummy = $("#header-dummy").outerHeight(); var h_header = 0; if($("#header-desktop").is(':visible')) { h_header = $("#header-desktop").outerHeight(); } else if($("#header-mobile").is(':visible')) { h_header = $("#header-mobile").outerHeight(); } var h_rest = h_header + h_footer; var h_final = h_window - h_rest; if(iframeMode == false){ $("#cont-body-element-global").css("min-height", h_final + "px"); } } function asignarAlturaContenido(indiceNegativo) { var alturaPantalla = $(window).height(); var alturaPie = $(".footer").height(); var alturaCabecera = $("#cabecera").height(); var alturaContenedor = 0; var alturaRestable = alturaCabecera + alturaPie; alturaContenedor = (alturaPantalla - alturaRestable); $(".cuerpoSeccion").css("min-height", (alturaContenedor + em(1.8)) + "px"); } function px(input) { var emSize = parseFloat($("body").css("font-size")); return (input / emSize); } function em(input) { var emSize = parseFloat($("body").css("font-size")); return (emSize * input); } $(function() { if(iframeSeamless == null || iframeSeamless == false) { /*funcionalidad carrito movil*/ if( $(".barra-carrito-tiempo").length ) { var top = $('.barra-carrito-tiempo').offset().top - parseFloat($('.barra-carrito-tiempo').css('marginTop').replace(/auto/, 0)); if($('.footer-mobile').length > 0 ) { var footTop = $('.footer-mobile').offset().top - parseFloat($('.footer-mobile').css('marginTop').replace(/auto/, 0)); } else { var footTop = 0; } var maxY = footTop - $('.barra-carrito-tiempo').outerHeight(); $(window).scroll(function(evt){ if(arrayVentasEnCarrito != null && arrayVentasEnCarrito.length > 0){ var y = $(this).scrollTop(); if(y > top) { if(y < maxY) { $('.barra-carrito-tiempo').addClass('fixed').removeAttr('style'); } else { $('.barra-carrito-tiempo').removeClass('fixed').css({ position: 'absolute', top: (maxY - top) + 'px' }); } } else { $('.barra-carrito-tiempo').removeClass('fixed'); } } }); /*FIN funcionalidad carrito movil*/ } } }); function objTiempoArray(id, fecha){ this.id = id; this.fecha = fecha; } var arrayTiemposVenta = new Array(); var salesInTimeCounter = new Array(); function inicializarCarrito() { //clearing $("#dropdownCarrito").hide(); $("#icono-carrito-movil").hide(); $("#listaVentasCarritoWidget").html(""); //Si hay numVentaFinalizadaCompra ==> el flujo está en la página de confirmacion de venta o reserva y por tanto no debera aparecer el carrito si tiene ese producto. //en ese caso se reescribe el array arrayVentasEncarrito sustituyendo el anterior sin la venta que acaba de ser confirmada. if(numVentaFinalizadaCompra != null) { var arrayVentasEnCarritoTemp = new Array(); for(let u in arrayVentasEnCarrito) { var objVenta = arrayVentasEnCarrito[u]; if(objVenta.idVenta != numVentaFinalizadaCompra) { arrayVentasEnCarritoTemp.push(objVenta); } } arrayVentasEnCarrito = arrayVentasEnCarritoTemp; } var enPago = false; if ((typeof selecionandoPago !== "undefined") && selecionandoPago) { enPago = true; } arrayTiemposVenta = new Array(); var codigoCarrito = ""; var codigoPagarTodo = ""; var filteredCart = []; if(arrayVentasEnCarrito != null && arrayVentasEnCarrito.length > 0) { for(let i = 0; i < arrayVentasEnCarrito.length; i++) { let venta = arrayVentasEnCarrito[i]; if(venta.importePagado == 0) { filteredCart.push(venta); } } } if(filteredCart != null && filteredCart.length > 0) { codigoCarrito += ''; //Se añade el codigo al widget carrito desktop $("#listaVentasCarritoWidget").html(codigoCarrito); if (enPago && salesInTimeCounter != null && salesInTimeCounter.length >= 2) { $("#listaVentasCarritoWidget").html(codigoPagarTodo); $("#alternativePaymentButton").html(codigoPagarTodo); } //BUSQUEDA DE RELOJ PARA WIDGET DESKTOP var tiempoBuscado = null; //Si se encuentra en un flujo de compra se muestra ese. if(numVentaProcesoDeCompra != null) { if(arrayTiemposVenta != null && arrayTiemposVenta.length > 1) { for(var i = 0; i < arrayTiemposVenta.length; i++) { if(numVentaProcesoDeCompra == arrayTiemposVenta[i].id) { tiempoBuscado = arrayTiemposVenta[i]; } } } else { tiempoBuscado = arrayTiemposVenta[0]; } } else { //Si no se encuentra en ningun flujo de compra se busca el que caducará antes if(arrayTiemposVenta != null && arrayTiemposVenta.length > 1) { arrayTiemposVenta.sort(function(a,b){ return new Date(a.fecha) - new Date(b.fecha); }); } tiempoBuscado = arrayTiemposVenta[0]; } //Se establece la cuenta atrás en el reloj del widget desktop if(tiempoBuscado != null) { CountDownTimer(tiempoBuscado.fecha, null); } //mostramos carrito desktop setTimeout(function(){$("#dropdownCarrito").show()}, 100); ///////////////////// // movil /// ///////////////////// //Si estamos en el flujo de compra mostramos el contador, //y en todo caso mostraremos el icono de carrito con el número de productos y acceso a la página carrito if(arrayVentasEnCarrito!= null && arrayVentasEnCarrito.length > 0) { $("#icono-carrito-movil").show(); } else { $("#icono-carrito-movil").hide(); } //Si estamos en flujo de compra mostramos barra con contador y establecemos id a objeto reloj movil if(numVentaProcesoDeCompra != null){ $(".contador-carrito-mobile").attr("id","contador-info-desplegable-movil-"+numVentaProcesoDeCompra); //mostramos reloj movil setTimeout(function(){$("#carrito-contenedor-movil").show()}, 100); } ///////////////////// /// fin movil /// ///////////////////// } else { var codigo = '
'+ '
'+polyglot.t("No_products_in_the_cart")+'
'+ '
'; $("#listaProductosCarrito").html(codigo); } } var countItemsArray = new Array(); function addCountItem(item) { countItemsArray.push(item); } function clearCountItemsArray() { for(var t= 0; t < countItemsArray.length; t++) { clearInterval(countItemsArray[t]); } countItemsArray = new Array(); } function generarCabeceraProductoCarrito(idventa, idEmpresa, idRecinto, idEvento, litEvento){ var urlImagen = "img_web/"+ idEmpresa +"/"+ idRecinto +"/"+ idEvento +"/s_banner.jpg"; var codigo = "
  • "+ ""+ "
    "+ "
    "+litEvento+"
    "+ "
    "+ "
  • "; return codigo; } function generarProductoCarrito(objventa, objDetalle) { var urlImagen = ""; if(objDetalle.esEntrada){ urlImagen = "img_web/"+ objventa.idEmpresa +"/"+ objDetalle.idRecinto +"/"+ objDetalle.idEvento +"/m_banner.jpg"; }else{ urlImagen = "recinto/" + objDetalle.idRecinto + "/productos/m_producto_" + objDetalle.idProducto + ".png"; } var codigo = ""; if(objDetalle.esEntrada) { codigo = "
    "; } else { codigo = "
    "; } if(!objDetalle.esEntrada) { codigo += ""; } if(objDetalle.esEntrada) { codigo += "
    "; } else { codigo += "
    "; } if(objDetalle.esEntrada) { codigo += '
    '; if(objDetalle.litFila !== undefined && objDetalle.litButaca !== undefined) { codigo += '' + polyglot.t("Row_Seat", { row: objDetalle.litFila, seat: objDetalle.litButaca }) + ''; codigo += ''; } else { codigo += ''+objDetalle.litProducto+''; } if (!objDetalle.esAbono && !objDetalle.esEntradaAbono) { codigo += ''+getHtmlFormattedCurrency(objDetalle.importeTotal)+''; } codigo += '
    '; } else { codigo += '
    '+objDetalle.litProducto+(objDetalle.variant != null ? " " + objDetalle.variant : "")+'
    '; } if(!objDetalle.esEntrada) { codigo += "
    "+objDetalle.cantidad+"x"+getHtmlFormattedCurrency(objDetalle.importeTotal)+"
    "; } codigo += "
    "; return codigo; } var mostrarDialogoTiempo = true; function CountDownTimer(end, id_elem) { var _second = 1000; var _minute = _second * 60; var _hour = _minute * 60; var _day = _hour * 24; var timer; function showRemaining(id_elem) { var now = getDateCorrectedServer(); var distance = end - now.getTime(); if (distance < 120000 && distance > 0) { protoAnimarVibracion(id_elem, false); } else if (distance < 0) { protoAnimarVibracion(id_elem, true); // si está en la página de pago mostrar mensaje de error y redireccionar a la página de compra o definir lógica. // si está en otro proceso de compra de otra compra mostrar mensaje de información de perdida de la reserva y ocultar carrito. protoTiempoAgotado(id_elem); return; } var days = Math.floor(distance / _day); var hours = Math.floor((distance % _day) / _hour); var minutes = Math.floor((distance % _hour) / _minute); var seconds = Math.floor((distance % _minute) / _second); if (seconds < 10) { seconds = "0" + seconds; } if (id_elem != null) { // desktop $('#contador-info-desplegable-' + id_elem).html(minutes + ':' + seconds); // movil $('#contador-info-desplegable-movil-' + id_elem).html(minutes + ':' + seconds); // cart page $('#timeleft-cart-page-' + id_elem).html(minutes + ':' + seconds); } else { // contador del widget desktop $('#temporizador-compra').html(minutes + ':' + seconds); } } timer = setInterval(function() { showRemaining(id_elem) }, 1000); addCountItem(timer); } var vibracionesIniciadas = new Array(); var vibracionesParadas = new Array(); function protoAnimarVibracion(id, acabado) { if(id != null) { if(acabado == false) { var existe = false; //Si no se ha iniciado if(vibracionesIniciadas.length > 0) { for(var a = 0; a < vibracionesIniciadas.length; a++) { if(vibracionesIniciadas[a] == id) { existe = true; } } } if(existe == false) { vibracionesIniciadas.push(id); $("#obj-carrito-cabecera").addClass("animated pulse infinite"); } } else { //quitamos animacion $("#obj-carrito-cabecera").removeClass("pulse infinite"); //buscamos si ya ha vibrado el aviso var animacionEjecutada = localStorage.getItem('venta_caducada_aviso-'+id); if(animacionEjecutada != null && animacionEjecutada != true) { localStorage.setItem('venta_caducada_aviso-'+id, true); //Si está en flujo de compra no vibrar si no es la compra actual if(numVentaProcesoDeCompra != null) { if(numVentaProcesoDeCompra == id) { $("#obj-carrito-cabecera").addClass("shake animated").one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function() { setTimeout(function(){ $("#obj-carrito-cabecera").removeClass("shake animated"); }, 1000) }); } } } } } } var alarmasParadas = new Array(); var alarmaParadaMovil = false; function protoTiempoAgotado(id) { if (id != null) { var existe = false; if (alarmasParadas.length > 0) { for(var a = 0; a < alarmasParadas.length; a++) { if(alarmasParadas[a] == id) { existe = true; } } } if(!existe) { alarmasParadas.push(id); tiempoAgotado(id); } } else { //movil if(!alarmaParadaMovil) { alarmaParadaMovil = true; tiempoAgotado(null); } } } function tiempoAgotado(id) { if(id != null) { //evaluamos si tiene mas de un proceso de compra en el carrito //si es que sí ==> evaluamos si se encuentra en pleno proceso de compra o ha iniciado otro //si es que no ==> mostramos mensaje bloqueante para que empieze el proceso de compra desde el principio //Evaluamos si se encuentra en el proceso de compra caducado //Si es así bloqueamos y enviamos al usuario al inicio del proceso de compra //Si la variable numVentaProcesoCompra el usuario se encuentra en la página de compra de productos, en la de login/registro o en el pago if(numVentaProcesoDeCompra != null) { //evaluamos que el contador que ha terminado tiene el mismo id_venta que el del proceso de compra en el cual nos encontramos //en cuyo caso lanzamos a la pagina de compra al usuario if(numVentaProcesoDeCompra == id) { lanzarDialogoCompraCaducada(id, true); } else { //Se ha caducado una venta del carrito diferente al proceso de compra en el que nos encontramos //mostrar mensaje en pantalla y desactivar los productos del carrito //Cart header $(".lista-productos-venta-"+id).css("opacity","0.5"); $("#precio-total-productos-venta-"+id).css("opacity","0.5"); $("#acciones-productos-venta-"+id).html(polyglot.t("Booking_expired")); $("#btn-venta-carrito-"+id).html(polyglot.t("Start")); $("#contenedor-contador-productos-"+id).css("opacity","0.5"); $("#btn-venta-carrito-"+id).attr('onclick', "relanzarProcesoCompra('" +id + "')"); //Cart page $("#total-price-cart-"+id).css("opacity","0.5"); $("#btn-call-action-cart-"+id).html(polyglot.t("Start")); $("#timeleft-sale-cart-"+id).html(polyglot.t("Booking_expired")); //remove this SaleId of the array "salesInTimeCounter" decrementSaleForPayAll(id); } } else { //El usuario no se encuentra en una pagina del proceso de compra desde la que debamos expulsarle //Evaluamos si hay mas de un proceso de compra y si es así avisamos y desactivamos en el carrito esa venta if(arrayVentasEnCarrito != null && arrayVentasEnCarrito.length >= 1) { //Se ha caducado una venta del carrito diferente al proceso de compra en el que nos encontramos //mostrar mensaje en pantalla y desactivar los productos del carrito if (arrayVentasEnCarrito.length > 1) { removeOfCart(id); $("#lista-separador-venta-"+id).hide(); $(".lista-productos-venta-"+id).hide(); $("#precio-total-productos-venta-"+id).hide(); $("#btns-action-venta-"+id).hide(); $("#contenedor-contador-productos-"+id).hide(); $("#lista-cabecera-venta-"+id).hide(); } else { //Cart header $(".lista-productos-venta-"+id).css("opacity","0.5"); $("#precio-total-productos-venta-"+id).css("opacity","0.5"); $("#acciones-productos-venta-"+id).html(polyglot.t("Booking_expired")); $("#btn-venta-carrito-"+id).html(polyglot.t("Start")); $("#contenedor-contador-productos-"+id).css("opacity","0.5"); $("#btn-venta-carrito-"+id).attr('onclick', "relanzarProcesoCompra('" +id + "')"); //Cart page $("#total-price-cart-"+id).css("opacity","0.5"); $("#btn-call-action-cart-"+id).html(polyglot.t("Start")); $("#timeleft-sale-cart-"+id).html(polyglot.t("Booking_expired")); lanzarDialogoCompraCaducada(id, false); //remove this SaleId of the array "salesInTimeCounter" decrementSaleForPayAll(id); } } } //inicializamos un nuevo contador principal, para ello obtenenos la siguiente compra cuya caducidad sea la mas proxima var arrayTiemposVentaTemp = new Array(); for(var e=0; e= 1){ arrayTiemposVenta.sort(function(a,b){ return new Date(a.fecha) - new Date(b.fecha); }); var tiempoMenor = arrayTiemposVenta[0]; var horaFin = tiempoMenor.fecha; if(minHiddenInTimePurchase != null && minHiddenInTimePurchase != "") { var minutesSubstract = parseInt(minHiddenInTimePurchase) * 60000; horaFin = horaFin - minutesSubstract; } //establecemos el contador de la barra menu con la siguiente venta CountDownTimer(horaFin, null); } } else //movil { //Si se encuentra en flujo de compra movil ==> mostrar alert para volver a iniciar la compra //si no, mostrar alert informando de que la compra del carrito ha caducado lanzarDialogoCompraCaducada(id, numVentaProcesoDeCompra != null); } } function decrementSaleForPayAll(id) { if(salesInTimeCounter.indexOf(id) > -1) { //remove var index = salesInTimeCounter.indexOf(id); if (index > -1) { salesInTimeCounter.splice(index, 1); } //have 2 or more elements? if(salesInTimeCounter.length < 2) { $("#button-pay-all-wrapper").hide(); } } } function lanzarDialogoCompraCaducada(idCompra, bloquear) { var avisar = true; //si no hay idCompra porque se trata del contador movil: lo buscamos según lógica if(idCompra == undefined || idCompra == null) { //Si hay numVentaProcesoDeCompra y idCompra es null ==> se encuentra en el proceso de compra movil if(numVentaProcesoDeCompra != null) { var objventa = arrayVentasEnCarrito[0]; idCompra = objventa.idVenta; avisar = true; } else { //Si se encuentra fuera del flujo de compra no avisamos al usuario. avisar = false; //TODO si hay solo una venta en el carrito lo ocultamos } } if(avisar) { var seLanzoMsg = localStorage.getItem('msgCompraCaducada'+idCompra); if(seLanzoMsg != undefined && seLanzoMsg != null && seLanzoMsg == "true") { } else { localStorage.setItem('msgCompraCaducada'+idCompra, 'true'); //TODO cambiar y mejorar el comportamiento. Estamos evitando mostrar el mensaje si hay una pasarela de pago en ventana modal if(modalSaleInitiated != null && modalSaleInitiated) { // verificar si se ha completado el pago ya y si no mostrar alert de tiempo caducado } else { if(bloquear) { swal({ title: polyglot.t("cart.Time_out"), text: polyglot.t("cart.Exceeded_max_time_description"), type: 'info', showCancelButton: false, confirmButtonColor: '#3085d6', allowOutsideClick: false, confirmButtonText: polyglot.t("Accept") }).then(function(isConfirm) { if (isConfirm) { //TODO borrar idVenta de las ventas temporales del usuario relanzarProcesoCompra(idCompra); } }); gtmTrackEvent("popup_time_out"); } else { swal(polyglot.t("cart.One_items_has_expired")); } } } } } function relanzarProcesoCompra(id) { var idEvento = null; //Si id == null es un contador movil, en ese caso obtenemos el primero según lógica if(id == null) { var objVenta = arrayVentasEnCarrito[0]; var detalle = objVenta.detalle[0]; idEvento = detalle.idEvento; } else { //obtengo el id evento de la venta for(let a in arrayVentasEnCarrito){ var objVenta = arrayVentasEnCarrito[a]; var detalle = objVenta.detalle[0]; if(objVenta.idVenta == id){ idEvento = detalle.idEvento break; } } } var formAction = $("#formProcesoCompra").attr('action'); //$('#formProcesoCompra').attr('action', formAction+"?idEvento="+idEvento); //$("#idEventoForm").val(idEvento); //$("#formProcesoCompra").submit(); var strIframeParams = ""; //Iframe? if(iframeMode != null && iframeMode == true) { strIframeParams += "&iframe_mode=true"; if(iframeAutoHeight != null) { strIframeParams += "&auto_height=" + iframeAutoHeight; } if(iframeMaxHeight != null) { strIframeParams += "&max_height=" + iframeMaxHeight; } if(iframeSeamless != null) { strIframeParams += "&seamless=" + iframeSeamless; } if(iframeSelectTicketMode != undefined) { strIframeParams += "&only_buy=" + iframeSelectTicketMode; } if(iframeTargetBlankCTA != undefined) { strIframeParams += "&target_blank_cta=" + iframeTargetBlankCTA; } if(iframeVisualMode != null) { strIframeParams += "&iframe_visual_mode=" + iframeVisualMode; } if(iframeHeightParent != undefined) { strIframeParams += "&height_parent=" + iframeHeightParent; } strIframeParams += "&childId=palco_widget_iframe_tag"; strIframeParams += "&parentUrl=" + formAction+"?idEvento="+idEvento; } var strUrlFormer = "?" if(formAction.indexOf("?") !== -1) { strUrlFormer = "&"; } window.location = formAction+""+strUrlFormer+"idEvento="+idEvento + strIframeParams; } function payPurchase(localizador) { if (localizador != null) { $.cookie("purchase_id", localizador, { expires: 1/144, path: pathCookies, domain: dominioCookies }); $("#localizador").val(localizador); $("#pay_booking_reference").val(localizador); EntradasAjax.getPrepaymentSurveyIdFromPurchaseRef(localizador, paySaleRedirection); } } function paySaleRedirection(surveyId) { if(originalRequest != null && originalRequest.length > 0) { $('#checkoutForm').attr('action', decodeURI(originalRequest.replace(/&/g, "&"))); } else { if (surveyId != null) { $('#checkoutForm').attr('action', 'survey?surveyId=' + surveyId + "&whereIsShown=1"); } } $("#checkoutForm").submit(); } function pagarCompraRedirection(surveyId) { if (surveyId != null) { $('#formAddToCart').attr('action', 'survey?surveyId=' + surveyId + "&whereIsShown=1"); } $("#formAddToCart").submit(); } /** * Genera el html del formulario para pedir datos extra de la transacción. * @param detalle Lista de detalles de la compra * @param recogerTitularNif Indica si hay que recoger el NIF del titular de cada entrada * @param recogerTitularNombre Indica si hay que recoger en nombre y apellidos del titular de cada entrada * @param preguntaDato1 * @param preguntaDato2 * @returns Código html */ function generaFormularioDatosExtra(detalle, recogerTitularNif, recogerTitularNombre, preguntaDato1, preguntaDato2, questionDataType1, questionDataType2) { var htmlDatosAdicionales = ""; var p = 1; for (var i=0; i 1) htmlDatosAdicionales += "
    "; htmlDatosAdicionales += "
    " + polyglot.t("Ticket") + " " + p + ""; if (dv.litFila && dv.litButaca) { htmlDatosAdicionales += "   " + polyglot.t("Row_Seat", { row: dv.litFila, seat: dv.litButaca }) + ""; } htmlDatosAdicionales += " - " + dv.litProducto + "
    "; if (recogerTitularNif || recogerTitularNombre) { //if ( (recogerTitularNif && !recogerTitularNombre) || (!recogerTitularNif && recogerTitularNombre) ) htmlDatosAdicionales += "
    "; if((!recogerTitularNif && recogerTitularNombre) || (recogerTitularNif && !recogerTitularNombre)) { if (recogerTitularNombre) { htmlDatosAdicionales += "
    "; htmlDatosAdicionales += "
    "; htmlDatosAdicionales += "
    "; } else if (recogerTitularNif) { htmlDatosAdicionales += "
    "; htmlDatosAdicionales += "
    "; htmlDatosAdicionales += "
    "; var stringSelected = ""; var idSesected = -1; htmlDatosAdicionales+="
    "; htmlDatosAdicionales+="
    "; htmlDatosAdicionales+=""; htmlDatosAdicionales+="
    "; htmlDatosAdicionales+="
    "; htmlDatosAdicionales+=""; htmlDatosAdicionales+="
    "; htmlDatosAdicionales+=getHtmlCovidPassportIntegration(); htmlDatosAdicionales+="
    "; htmlDatosAdicionales+="
    "; } } else { if (recogerTitularNombre) { htmlDatosAdicionales += "
    "; htmlDatosAdicionales += "" + polyglot.t("Mandatory") + "
    "; } htmlDatosAdicionales += "
    "; } if (recogerTitularNif) { htmlDatosAdicionales += "
    "; var stringSelected = ""; var idSesected = -1; htmlDatosAdicionales+="
    "; htmlDatosAdicionales+="
    "; htmlDatosAdicionales+=""; htmlDatosAdicionales+="
    "; htmlDatosAdicionales+="
    "; htmlDatosAdicionales+=""; htmlDatosAdicionales+="
    "; htmlDatosAdicionales+=getHtmlCovidPassportIntegration(); htmlDatosAdicionales+="
    "; htmlDatosAdicionales+="
    "; } } // if (recogerTitularNif) // htmlDatosAdicionales += ""; htmlDatosAdicionales += "" + polyglot.t("Mandatory") + "
    "; } if (preguntaDato1 != null) { /*htmlDatosAdicionales += "
    " + polyglot.t("Mandatory") + "
    ";*/ htmlDatosAdicionales += getHtmlDivQuestions(i, 1, preguntaDato1, questionDataType1, dv.dato1); } if(preguntaDato2 != null) { /*htmlDatosAdicionales += "
    " + polyglot.t("Mandatory") + "
    ";*/ htmlDatosAdicionales += getHtmlDivQuestions(i, 2, preguntaDato2, questionDataType2, dv.dato2); } p++; } return htmlDatosAdicionales; } function getHtmlCovidPassportIntegration() { let html = ""; if (idCovidPassportIntegration != null) { if (idCovidPassportIntegration == 1) // PT integration { html += '' } } return html; } function uploadCovidPassport() { $('#popup_covid_passport').addClass("show"); } function getHtmlDivQuestions(indexDetail, questionId, question, questionDataType, purchaseDetailData) { var questionDivHtml = "
    " + polyglot.t("Mandatory") + "
    "; return questionDivHtml; } /** * Valida el formulario de datos extra. * @param detalle Lista de detalles de la compra * @param recogerTitularNif Indica si hay que recoger el NIF del titular de cada entrada * @param recogerTitularNombre Indica si hay que recoger en nombre y apellidos del titular de cada entrada * @param preguntaDato1 * @param preguntaDato2 * @returns Indica si es correcto */ function validaFormularioDatosExtra(detalle, recogerTitularNif, recogerTitularNombre, preguntaDato1, preguntaDato2) { var hayError = false; // Prevent identification numbers to be repeated in the same form let sessions = []; if (typeof(venta) != "undefined") { sessions = venta.detalle.map(d => d.idSesion); } else { sessions = detalle.map(d => d.idSesion); } let selectedSessions = sessions.filter((s, index) => sessions.indexOf(s) === index); if(selectedSessions.length == 1 && detalle.length > 1) { let identificationNumbers = []; let documentInputs = document.querySelectorAll("input[id^='titularNif']"); documentInputs.forEach(el => identificationNumbers.push(el.value)); let uniqueNumbers = identificationNumbers.every((e, i, a) => a.indexOf(e) === i); if (!uniqueNumbers && typeof uniqueNif != "undefined" && uniqueNif) { setTimeout(function(){ alertaExcepcion(polyglot.t("ERROR_CODE.ERR_TI_TICKET_DATA_ID_CARD_DUPLICATED_IN_SALE")); }, 200); return false; } } for (var i=0; i= 0; i--) { format = rut.substring(i, i + 1) + format; cont++; if (cont == 3 && i != 0) { format = "." + format; cont = 0; } } return format.toUpperCase(); } function marcarError(elemento, tieneError) { if (tieneError) { elemento.parent().parent().addClass("error").find("small.error").show(); } else { elemento.parent().parent().removeClass("error").find("small.error").hide(); } } function scrollToError(elemento, tieneError, container) { if (tieneError) { elemento.parent().parent().addClass("error").find("small.error").show(); if (container) { container.animate({ scrollTop: elemento.offset().top} , 500); } else { $('html, body').animate({ scrollTop: elemento.offset().top} , 500); } } else { elemento.parent().parent().removeClass("error").find("small.error").hide(); } } //FIXME Eliminar pasado el Sonar. Cambio de idioma de textos. function sonar2018() { if (typeof(dataLayerP4) == 'undefined') return; var idEvent = dataLayerP4.eventId; if(idEvent == null || idEvent == undefined || idEvent == "") { if(dataLayerP4 != null && dataLayerP4.products != null) { var arrayProducts = dataLayerP4.products; if(arrayProducts.length > 0) { var obj = arrayProducts[0]; idEvent = obj.eventId; } } } if (dataLayerP4 && (idEvent == "50102" || idEvent == "50119" || idEvent == "50120" || idEvent == "50139") && (idioma == 'ca_ES' || idioma == 'en_GB' || idioma == 'en_US' || idioma == 'es_ES') || (dataLayerP4.action == null && dataLayerP4.promoterId == "10011")) { var litEventoS = "Sónar 2018"; var litZonaS = "Abono VIP Sónar 2018"; //"Abono Sónar 2018" var litProductS = "Abono VIP Sónar 2018"; //"Abono Sónar 2018" var litTickets = "Tickets"; var litSesionS = ""; if(idEvent == "50139") { litEventoS = "Sónar+D 2018"; litZonaS = "Acreditaciones Sónar+D 2018"; litProductS = "Acreditaciones Sónar+D 2018"; litTickets = "Acreditaciones"; litSesionS = "Junio"; } // Lit -> productos: var productos = new Array(); var litProd_100193_100204 = "Abono Sónar 2018"; var litProd_100321_100343 = "Abono VIP Sónar 2018"; var litProd_100337_100335 = "Entrada 2 Noches"; var litProd_100338_100344 = "Entrada 2 Noches VIP"; var litProd_100330_100336 = "Sónar de Día: Jueves 14"; var litProd_100339_100337 = "Sónar de Día: Viernes 15"; var litProd_100331_100337 = "Sónar de Día: Viernes 15"; var litProd_100332_100338 = "Sónar de Día: Sábado 16"; var litProd_100335_100345 = "Sónar de Noche: Viernes 15"; var litProd_100336_100346 = "Sónar de Noche: Sábado 16"; //var litProd_1007_1008 = "Acreditación Sónar+D 2018"; //var litProd_1008_1009 = "Acreditación DÍA Sónar+D 2018"; var litProd_100453_100415 = "Acreditación"; var litProd_100612_100720 = "Acreditación de Día"; if (idioma == 'ca_ES') { litEventoS = "Sónar 2018"; litZonaS = "Abonament VIP 2018"; //"Abonament Sónar 2018"; litProductS = "Abonament VIP 2018"; //"Abonament Sónar 2018"; litSesionS = ""; if(idEvent == "50139") { litEventoS = "Sónar+D 2018"; litZonaS = "Acreditació Sónar+D 2018"; litProductS = "Acreditació Sónar+D 2018"; litTickets = "Acreditació"; litSesionS = "Juni"; } litProd_100193_100204 = "Abonament 2018"; litProd_100321_100343 = "Abonament VIP 2018"; litProd_100337_100335 = "Entrada 2 Nits"; litProd_100338_100344 = "Entrada 2 Nits VIP"; litProd_100330_100336 = "Sónar de Dia: Dijous 14"; litProd_100339_100337 = "Sónar de Dia: Divendres 15"; litProd_100331_100337 = "Sónar de Dia: Divendres 15"; litProd_100332_100338 = "Sónar de Dia: Dissabte 16"; litProd_100335_100345 = "Sónar de Nit: Divendres 15"; litProd_100336_100346 = "Sónar de Nit: Dissabte 16"; //litProd_1007_1008 = "Acreditació Sónar+D 2018"; //litProd_1008_1009 = "Acreditació DIA Sónar+D 2018"; litProd_100453_100415 = "Acreditació"; litProd_100612_100720 = "Acreditació de Día"; } else if (idioma == 'en_GB' || idioma == 'en_US') { litEventoS = "Sónar 2018"; litZonaS = "SonarPass VIP 2018"; //"SonarPass 2018"; litProductS = "SonarPass VIP 2018"; //"SonarPass 2018"; litSesionS = ""; if(idEvent == "50139") { litEventoS = "Sónar+D 2018"; litZonaS = "Delegate Pass Sónar+D 2018"; litProductS = "Delegate Pass Sónar+D 2018"; litTickets = "Delegate Pass"; litSesionS = "June"; } litProd_100193_100204 = "SonarPass 2018"; litProd_100321_100343 = "SonarPass VIP 2018"; litProd_100337_100335 = "2-Night Ticket"; litProd_100338_100344 = "2-Night Ticket VIP"; litProd_100330_100336 = "Sónar by Day: Thursday 14"; litProd_100339_100337 = "Sónar by Day: Friday 15"; litProd_100331_100337 = "Sónar by Day: Friday 15"; litProd_100332_100338 = "Sónar by Day: Saturday 16"; litProd_100335_100345 = "Sónar by Night: Friday 15"; litProd_100336_100346 = "Sónar by Night: Saturday 16"; //litProd_1007_1008 = "Sónar+D Delegate Pass 2018"; //litProd_1008_1009 = "Sónar+D DAY Delegate Pass 2018"; litProd_100453_100415 = "Full Delegate Pass"; litProd_100612_100720 = "Day Delegate Pass"; } if (dataLayerP4.action == "purchase") { $(".colDchaLitEvento").html(litEventoS); } else if (dataLayerP4.action == "checkout") { $("div.title > p").html(litEventoS); $(".payment-col-lit-event").html(litEventoS); $(".checkout-lit-product").html(litTickets); $(".payment-col-lit-zone-100204").html(litProd_100193_100204); $(".payment-col-lit-zone-100343").html(litProd_100321_100343); $(".payment-col-lit-zone-100336").html(litProd_100330_100336); // $(".payment-col-lit-zone-100337").html(litProd_100339_100337); $(".payment-col-lit-zone-100337").html(litProd_100331_100337); $(".payment-col-lit-zone-100338").html(litProd_100332_100338); $(".payment-col-lit-zone-100335").html(litProd_100337_100335); $(".payment-col-lit-zone-100344").html(litProd_100338_100344); $(".payment-col-lit-zone-100345").html(litProd_100335_100345); $(".payment-col-lit-zone-100346").html(litProd_100336_100346); // Sonar i+d //$(".payment-col-lit-zone-1008").html(litProd_1007_1008); //$(".payment-col-lit-zone-1009").html(litProd_1008_1009); $(".payment-col-lit-zone-100415").html(litProd_100453_100415); $(".payment-col-lit-zone-100720").html(litProd_100612_100720); if(idEvent == "50139") { $(".date").html(litSesionS); }else{ $(".date").html(""); } } else if (dataLayerP4.action == "transaction_complete") { $(".tEntradasProducto").html(litProductS); $("#printAtHome-wrapper").hide(); $("#passbook-wrapper").hide(); $("#row-info-wrapper").addClass("lastRow"); $("#complete-zone-100204").html(litProd_100193_100204); $("#complete-zone-100343").html(litProd_100321_100343); $("#complete-zone-100336").html(litProd_100330_100336); // $("#complete-zone-100337").html(litProd_100339_100337); $("#complete-zone-100337").html(litProd_100331_100337); $("#complete-zone-100338").html(litProd_100332_100338); $("#complete-zone-100335").html(litProd_100337_100335); $("#complete-zone-100344").html(litProd_100338_100344); $("#complete-zone-100345").html(litProd_100335_100345); $("#complete-zone-100346").html(litProd_100336_100346); // Sonar i+d //$("#complete-zone-1008").html(litProd_1007_1008); //$("#complete-zone-1009").html(litProd_1008_1009); $("#complete-zone-100415").html(litProd_100453_100415); $("#complete-zone-100720").html(litProd_100612_100720); $(".tEntradasProducto").html(litTickets); $("#lit-event-thankYouPage").html(litEventoS); // Ocultar litEvento y litSesion en thank you page $('#tablaPrecioEntradas table tbody tr td strong').each(function(){ $(this).parent().parent().hide(); }); if(idEvent == "50139") { $("#litSesionDescription").html(litSesionS); }else{ $("#litSesionDescription").html(""); } } $(".cart-lit-evento").html(litEventoS); $(".price_row_lit_prod-100193-100204").html(litProd_100193_100204); $(".price_row_lit_prod-100321-100343").html(litProd_100321_100343); $(".price_row_lit_prod-100330-100336").html(litProd_100330_100336); $(".price_row_lit_prod-100339-100337").html(litProd_100339_100337); $(".price_row_lit_prod-100331-100337").html(litProd_100331_100337); $(".price_row_lit_prod-100332-100338").html(litProd_100332_100338); $(".price_row_lit_prod-100337-100335").html(litProd_100337_100335); $(".price_row_lit_prod-100338-100344").html(litProd_100338_100344); $(".price_row_lit_prod-100335-100345").html(litProd_100335_100345); $(".price_row_lit_prod-100336-100346").html(litProd_100336_100346); // Sonar i+d //$(".price_row_lit_prod-1007-1008").html(litProd_1007_1008); //$(".price_row_lit_prod-1008-1009").html(litProd_1008_1009); $(".price_row_lit_prod-100453-100415").html(litProd_100453_100415); $(".price_row_lit_prod-100612-100720").html(litProd_100612_100720); //print tickets secction in detail $("#entradas").hide(); // $(".tEntradasZona").html(litZonaS); return true; } return false; } //FIXME Eliminar pasado el Sonar. Cambio de idioma de textos. function sonar2019() { if (typeof(dataLayerP4) == 'undefined') return; var idEvent = dataLayerP4.eventId; if(idEvent == null || idEvent == undefined || idEvent == "") { if(dataLayerP4 != null && dataLayerP4.products != null) { var arrayProducts = dataLayerP4.products; if(arrayProducts.length > 0) { var obj = arrayProducts[0]; idEvent = obj.eventId; } } } if (dataLayerP4 && idEvent == "50201" && (idioma == 'ca_ES' || idioma == 'en_GB' || idioma == 'en_US' || idioma == 'es_ES') || (dataLayerP4.action == null && dataLayerP4.promoterId == "10039")) { var litEventoS = "Sónar 2019"; var litZonaS = "Abono VIP Sónar 2019"; //"Abono Sónar 2018" var litProductS = "Abono VIP Sónar 2019"; //"Abono Sónar 2018" var litTickets = "Tickets"; var litSesionS = ""; // Lit -> productos: var productos = new Array(); var litProd_101096_100915 = "Abono Sónar 2019"; var litProd_101097_100916 = "Abono VIP"; if (idioma == 'ca_ES') { litEventoS = "Sónar 2019"; litZonaS = "Abonament VIP 2019"; //"Abonament Sónar 2018"; litProductS = "Abonament VIP 2019"; //"Abonament Sónar 2018"; litSesionS = ""; litProd_101096_100915 = "Abonament"; litProd_101097_100916 = "Abonament VIP"; } else if (idioma == 'en_GB' || idioma == 'en_US') { litEventoS = "Sónar 2019"; litZonaS = "SonarPass VIP 2019"; //"SonarPass 2018"; litProductS = "SonarPass VIP 2019"; //"SonarPass 2018"; litSesionS = ""; litProd_101096_100915 = "SonarPass"; litProd_101097_100916 = "SonarPass VIP"; } if (dataLayerP4.action == "purchase") { $(".colDchaLitEvento").html(litEventoS); } else if (dataLayerP4.action == "checkout") { $("div.title > p").html(litEventoS); $(".payment-col-lit-event").html(litEventoS); $(".checkout-lit-product").html(litTickets); $(".payment-col-lit-zone-101096").html(litProd_101096_100915); $(".payment-col-lit-zone-101097").html(litProd_101097_100916); } else if (dataLayerP4.action == "transaction_complete") { $(".tEntradasProducto").html(litProductS); $("#printAtHome-wrapper").hide(); $("#passbook-wrapper").hide(); $("#row-info-wrapper").addClass("lastRow"); $("#complete-zone-101096").html(litProd_101096_100915); $("#complete-zone-101097").html(litProd_101097_100916); $(".tEntradasProducto").html(litTickets); $("#lit-event-thankYouPage").html(litEventoS); // Ocultar litEvento y litSesion en thank you page $('#tablaPrecioEntradas table tbody tr td strong').each(function(){ $(this).parent().parent().hide(); }); if(idEvent == "50139") { $("#litSesionDescription").html(litSesionS); }else{ $("#litSesionDescription").html(""); } } $(".cart-lit-evento").html(litEventoS); $(".price_row_lit_prod-101096-100915").html(litProd_101096_100915); $(".price_row_lit_prod-101097-100916").html(litProd_101097_100916); //print tickets secction in detail $("#entradas").hide(); $(".tEntradasZona").html(litZonaS); return true; } return false; } function removeOfCart(idPurchase) { var arrayBookings = new Array(); arrayBookings.push(idPurchase); CompraAjax.removeBookingsCustomer(arrayBookings, bookingsRemoved); } function bookingsRemoved(bookings) { clearCountItemsArray(); //TODO llevar esta función al archivo .vm de cada cabecera como función generica, para evitar que si borramos la ultima reserva del carrito se //quede la capa de sombreado setTimeout(function(){ $(".header-layer-bg").hide(); }, 50); arrayVentasEnCarrito = JSON.parse(bookings); inicializarCarrito(); // Redirect to homepage if is in the buying process if(removedIdPurchase == idVenta || dataLayerP4.action == 'cart' && arrayVentasEnCarrito == null) { window.location.href = urlBase; } else if (dataLayerP4.action == 'cart' && arrayVentasEnCarrito != null) { location.reload(); } } function changeTypeIdCard(num) { var typeCard = $("#idCardType" + num).val(); document.getElementsByName("titularNif" + num)[0].placeholder = getPlaceHolderCardType(typeCard); } function changeTypeIdCardInputId(idTypeSelect, documentInput) { var typeCard = $("#"+idTypeSelect).val(); document.getElementById(documentInput).placeholder = getPlaceHolderCardType(typeCard); } function getPlaceHolderCardType(idCardType) { if (idCardType == IdCardType.RUT_CL) { return '99.999.999-X'; } else if (idCardType == IdCardType.DNI_ES) { return '12345678X'; } else if (idCardType == IdCardType.CPF_BR) { return '999.999.999-99'; } else if (idCardType == IdCardType.CNPJ_BR) { return '99.999.999/9999-99'; } else { return ''; } } function includes(container, value) { var returnValue = false; var pos = container.indexOf(value); if (pos >= 0) { returnValue = true; } return returnValue; } function getTextMultilanguage(multiLangArray) { if(multiLangArray != null) { var languagesArray = multiLangArray.idiomas; var textsArray = multiLangArray.textos; for(var i = 0; i < languagesArray.length; i++) { if(languagesArray[i] == idioma) { return textsArray[i]; } } return multiLangArray.textoDefault; } } function refreshSimpleCaptcha(captchaImgId, captchaInputId) { $(captchaImgId).attr('src', urlBaseWithoutLang + 'captcha/' + (new Date()).getTime() + '.png'); if (captchaInputId) { $(captchaInputId).val(""); } } function isInternalUrl(url) { if (url == null || url == "" || url.startsWith("#")) { return false; } if (url.startsWith("http:") || url.startsWith("https:")) { if (url.startsWith(urlBaseWithoutLang)) { return true; } return false; } return true; } function appendCommonUrlParameters(url, parameters) { if (parameters == null || parameters == "") { return url; } if (url.indexOf("?") > 0) { return url + "&" + parameters; } return url + "?" + parameters; } function buildTokenParametersForUrl() { // Include session cookie value in URLs for Safari if (iframeMode && urlTokenParameters == null) { let tkn_x = $.cookie("tkn_x"); tkn_x = escape(tkn_x); let tkn_c = $.cookie("tkn_c"); tkn_c = escape(tkn_c); if (tkn_x == null || tkn_x == "" || tkn_x == "null" || tkn_x == "undefined") { tkn_x = tknX; } if (tkn_c == null || tkn_c == "" || tkn_c == "null" || tkn_c == "undefined") { tkn_c = tknC; } urlTokenParameters = ""; if (tkn_x != null && tkn_x != "" && tkn_x != "null" && tkn_x != "undefined") { urlTokenParameters += "tkn_x=" + tkn_x; } if (tkn_c != null && tkn_c != "" && tkn_c != "null" && tkn_c != "undefined") { if (urlTokenParameters != "") { urlTokenParameters += "&"; } urlTokenParameters += "tkn_c=" + tkn_c; } if (urlTokenParameters != "") { let links = document.querySelectorAll("a"); for (let i in links) { let link = links[i]; if (isInternalUrl(link.href)) { link.href = appendCommonUrlParameters(link.href, urlTokenParameters); } } let forms = document.querySelectorAll("form"); for (var j in forms) { let form = forms[j]; if (isInternalUrl(form.action)) { form.action = appendCommonUrlParameters(form.action, urlTokenParameters); } } } } }