// ----- CONSTANTES ----- var FIDELIZACION_OPERACION_REDIMIR = "R"; var FIDELIZACION_OPERACION_ACUMULAR = "A"; var FIDELIZACION_OPERACION_CADUCAR = "C"; var FIDELIZACION_OPERACION_CODIGO_DESCUENTO = "D"; var FIDELIZACION_TIPO_TARJETA_FIDELIZACION = "F"; var FIDELIZACION_TIPO_TARJETA_CODIGO_DESCUENTO = "D"; let LOYALTY_CARD_TYPE_GIFT_CARD = "G"; var MAX_ID_SYSTEM_PROFILES = 1; var modalSaleInitiated = false; /** * Formas de pago */ var FormasPago = { "Efectivo": 1, "Datafono": 2, "PinPadBanorte": 3, "Transferencia": 4, "Puntos": 5, "Cupón": 6, "TarjetaRedsys": 7, "Paypal": 8, "Fidelizacion": 9, "TarjetaBanorte": 10, "TarjetaDummy": 11, "PinPadRedsys": 12, "PinPadDummy": 13, "TiendaOpenpayPaynet": 14, "PinpadElavon": 16, "TarjetaMercadoPago": 17, "TarjetaAllegra": 19, "TiendaMercadoPago": 20, "Otros": 21, "Refund": 22, "PinpadAdyen":32, "ECI":33, "PinpadHSBC":34, "OpenpayTarjeta":35, "AdyenV41Version":36, "AuthorizedNet":37, "GiftCard":38, "Stripe":39, "CardConnect":40, "Bancomer":42, "VisaNetWeb":45, "Payphone":46, "VisaNetButton":47, "PixelPay":48, "PayphoneExpress":49, "AthMovilButton":50, "PagandoCheck":51, "MercadoPagoV2":52, "MercadoPagoV2Efecty":53, "MercadoPagoV2PSE":54, "PayU":55, "TicketPagoTuEnlace":56, "Cybersource":58, "Datafast":59, "Serfinsa":61, "Fiserv":62, "Yappy": 63, "TravelPay":64, "TransBank":66, "Bancard":67, "GetnetSantander":68, "Aplazo":69, "PaypalV2": 71, "GetnetSantanderChile": 75, "Line": 78, "MercadoPAgoV2Wallet": 79, "Powertranz": 82, "Deuna": 83, "InstapagoQR": 84 }; var PaymentMethodsThatStoreCards = [ {idPaymentMethod: FormasPago.OpenpayTarjeta, requiresCVV: false, usesDefaultCardForm: false}, {idPaymentMethod: FormasPago.Stripe, requiresCVV: false, usesDefaultCardForm: true}, {idPaymentMethod: FormasPago.MercadoPagoV2, requiresCVV: false, usesDefaultCardForm: true}, {idPaymentMethod: FormasPago.Cybersource, requiresCVV: true, usesDefaultCardForm: false} ]; var paymentMethodsThatSupportInvoicesAndAutoSelect = [FormasPago.Fiserv]; var ModoSeleccionAsiento = { "MODO_SELECCION_ASIENTO_NORMAL": 'N', "MODO_SELECCION_ASIENTO_MANUAL": 'M', "MODO_SELECCION_ASIENTO_PLANO": 'P', "MODO_SELECCION_ASIENTO_AUTOMATICO": 'A', "MODO_SELECCION_ASIENTO_AUTOMATICO_SEGURO": 'S', "MODO_SELECCION_ASIENTO_AUTOMATICO_SIN_SEPARADOS": 'X' }; /** * Tipos de evento */ var EventTypes = { 'Normal': 0, 'AbonoTemporada': 1, 'AbonoALaCarta': 2, 'ContenedorGira': 3, 'ContenedorCombinado': 4, 'Accreditation': 5, 'Streaming': 6 } /** * Tipos de precio */ var TiposPrecio = { "General": 1, "Reducido": 2, "Invitacion": 3, "Oferta": 4, "CodigoDescuento": 5, "Grupos": 6, "Fidelización": 7, "Promo": 8, "SesionAbono": 9, "ProdGeneral": 11, "ProdInvitacion": 12, "ProdOferta": 13, "ProdCodDescuento": 14, "ProdFidelizacion": 15, "IncludedWithTicket":29, "Donation": 50, "DonationOpenAmount": 51, "FeeTransaction": 60, "FeePaymentMethod": 61, "Insurance": 70, "ProtectGroupProtection": 71, "ProtechtProtection": 72, "RealeProtection": 74, "PlanoutProtection": 75, "GiftCards": 73, "DomesticShipping": 100, "InternationalShipping": 101 // , // "FeeDelivery": 62 }; var ProductType = { "TICKET": 1, "PRODUCT": 2, "BUNDLE": 3, "MULTIPASS": 4, "DONATION": 5, "FEE": 6, "INSURANCE": 7, "FANID": 8, "GIFTCARD": 9, "SHIPPING": 10, "ACCREDITATION": 11 }; var IdCardType = { "NOT_DEFINED": 0, "RUT_CL": 1, "DNI_ES": 2, "CPF_BR": 3, "CNPJ_BR": 4, "PASSPORT": 5, "NIE_ES": 6, "CIF_ES": 7, "DNI_PE": 8, "RUC_PE": 9, "INE_MX": 10, "RFC_MX": 11, "PESEL_PL": 12, "DNI_AR": 13, "CUIL_AR": 14, "CUIT_AR": 15, "RNC_DO": 16, "CEDULA_DO": 17, "NIT_GT": 18, "CUI_GT": 19, "DNI_CL": 20, "CEDULA_PY": 21, "NIT_CO": 22, "CEDULACIUDADANIA_CO": 23, "TARJETAIDENTIDAD_CO": 24, "CEDULAEXTRANJERIA_CO": 25, "PA_CEDULA": 26, "EC_CEDULA": 27, "PE_CEDULA": 28, "PE_RIF": 29, "VE_CEDULA": 30, "VE_RIF": 31, "BR_CEDULA": 32, "PY_RUC": 33, "EC_RUC": 34, "PA_RUC": 35, "SV_DUI": 36, "SV_NIT": 37, "PR_REALID": 38, "PR_TI": 39, "BO_CEDULA": 40, "BO_NIT": 41, "CR_CEDULA": 42, "CR_NITE": 43, "NI_CEDULA": 44, "NI_RUC": 45, "UY_CEDULA": 46, "UY_RUT": 47, "UY_NIE": 48 }; var IdCardValidationResultStatus = { "VALID": 1, "NOT_VALID": 0, "IN_VALIDATION": -1 }; /** * Sales place */ var SalePlaces = { "TicketPurchase": 0, "ProductPurchase": 1, "Checkout": 2 }; var StreamingPlatforms = { "ENETRES": {id: "ENETRES", displayName: "Enetres", requiredFields: "url#id", icon:"enetres"}, "VIMEO": {id: "VIMEO", displayName: "Vimeo", requiredFields: "url", icon:"vimeo"}, "ZOOM": {id: "ZOOM", displayName: "Zoom", requiredFields: "url#id#password", icon:"zoom"}, /*{id: "DALETICKET", displayName: "Daleticket", requiredFields: "url"},*/ "YOUTUBE": {id: "YOUTUBE", displayName: "YouTube", requiredFields: "url", icon:"youtube"}, "FACEBOOK": {id: "FACEBOOK", displayName: "Facebook", requiredFields: "url", icon:"facebook"}, "LINKEDIN": {id: "LINKEDIN", displayName: "LinkedIn", requiredFields: "url", icon:"linkedin"}, "INSTAGRAM": {id: "INSTAGRAM", displayName: "Instagram", requiredFields: "url", icon:"instagram"}, "TEAMS": {id: "TEAMS", displayName: "Microsoft Teams", requiredFields: "url", icon:"microsoft_teams"}, "MEET": {id: "MEET", displayName: "Google Meet", requiredFields: "url", icon:"meet"}, }; function getLiteralEmpresaFormaPago(idEmpresaFormaPago, idFormaPago) { for (var i in FormasPago) { var formaPago = FormasPago[i]; if (idEmpresaFormaPago == formaPago.idEmpresaFormaPago) { return formaPago.formaPago; } } return getPaymentMethodLiteral(idFormaPago); } //============================== MATH UTILS ================================== /** * Round an amount to cents. */ function roundAmount(amount) { return (Math.round(amount * 100) / 100); } // ---------------- UTILIDADES UI ---------------- //is this a small screen? function isSmall() { //Foundation 5 return Foundation.utils.is_small_only(); } //is this a medium screen? function isMedium() { //Foundation 5 return Foundation.utils.is_medium_only(); } //rem to pixel size function convertRemToPixels(rem) { return rem * parseFloat(getComputedStyle(document.documentElement).fontSize); } // ------------------ UTILIDADES ----------------- function getSesionFromLista(idSesion, listaSesiones) { if (listaSesiones != null && listaSesiones.length > 0) { for (var i in listaSesiones) { if (listaSesiones[i].idSesion == idSesion) return listaSesiones[i]; } } return null; } if (typeof String.prototype.startsWith !== 'function') { String.prototype.startsWith = function(prefix) { return this.indexOf(prefix) == 0; }; } if (typeof String.prototype.endsWith !== 'function') { String.prototype.endsWith = function(suffix) { return this.indexOf(suffix, this.length - suffix.length) !== -1; }; } /** * Obtiene el objeto de una lista por su ID */ function getObjetoPorId(id, lista, campoId) { if (campoId == null) campoId = 'id'; for (var i in lista) { var valorCampoId = lista[i][campoId]; if (id == valorCampoId) return lista[i]; } return null; } function clearEventListeners(selector) { var old_element = document.querySelector(selector); var new_element = old_element.cloneNode(true); old_element.parentNode.replaceChild(new_element, old_element); } // ============================== VENTANA ESPERA ================================== /** * Estilo de las ventanas de espera */ $.blockUI.defaults.css = { padding: 0, margin: 0, color: '#2779AA', border: '1px solid #D7EBF9', backgroundColor:'#FFFFFF', cursor: 'wait' }; var ventanaEsperaAjaxOn = false; var idVentanaSupEspera = null; var inicioEsperaVentana = null; /** * Muestra la ventana de espera mientras se realiza una llamada AJAX, para bloquear al usuario. */ function crearVentanaEspera(idVentanaSuperior) { if (ventanaEsperaAjaxOn) return; idVentanaSupEspera = idVentanaSuperior; $("#divEsperaOk").hide(); $("#divEsperaError").hide(); //TODO revisar el funcionamiento o remplazar jquery.blockui.js try { $.blockUI( { message: $('#divEspera'), showOverlay: true, overlayCSS: { backgroundColor: '#fff', opacity: 0.5 }, css: { top: ($(window).height() - 128) /2 + 'px', left: ($(window).width() - 128) /2 + 'px', width: '128px', border: 'none', backgroundColor: 'none' }, baseZ: 99999 }); inicioEsperaVentana = new Date(); ventanaEsperaAjaxOn = true; } catch(err) { cerrarVentanaEspera(); console.log(err.message); } } /** * Cambia la venta de espera a OK. */ function cambiarVentanaEsperaOK(cerrarVentanaSup) { if (ventanaEsperaAjaxOn) { var tiempoEspera = 0; if (inicioEsperaVentana != null) { tiempoEspera = (new Date()).getTime() - inicioEsperaVentana.getTime(); } // Si tarda muy poco (menos de 1 seg) no se muestra el OK if (tiempoEspera > 1000) { $("#divEsperaOk").show(); setTimeout("cerrarVentanaEspera(" + cerrarVentanaSup + ")", 250); } else { cerrarVentanaEspera(cerrarVentanaSup); } } } /** * Cambia la venta de espera a KO. */ function cambiarVentanaEsperaKO(cerrarVentanaSup) { if (ventanaEsperaAjaxOn) { $("#divEsperaError").show(); setTimeout("cerrarVentanaEspera(" + cerrarVentanaSup + ")", 2000); } } /** * Cierra la venta de espera. */ function cerrarVentanaEspera(cerrarVentanaSup) { if (ventanaEsperaAjaxOn) { $.unblockUI(); if (cerrarVentanaSup) $("#"+idVentanaSupEspera).foundation('reveal','close'); setTimeout("ventanaEsperaAjaxOn = false", 1000); ventanaSupEspera = null; } } // ============================ AJAX =========================== var lastAjaxException = null; var TYPE_MSG_EXCEPTION = { ERROR : 0, WARNING : 1, INFO : 2 }; /** * Tratamiento genérico de los errores AJAX. */ function tratamientoErrores(msg, exception) { lastAjaxException = exception; if (ventanaEsperaAjaxOn) cambiarVentanaEsperaKO(false); if (exception != null) { var typeMsg = exception.type; var msgError = ""; if (exception.javaClassName == "es.ticketing.exceptions.TicketingException" || exception.javaClassName == "es.ticketing.exceptions.VentaException" || exception.javaClassName == "es.ticketing.exceptions.PagoException" ) { msgError = polyglot.t("ERROR_CODE." + exception.errorCode.code); var titleMsgError = polyglot.t("ERROR_CODE." + exception.errorCode.code + "__TITLE"); if(titleMsgError == "ERROR_CODE." + exception.errorCode.code + "__TITLE") { titleMsgError = null; } if(typeMsg != null) { if(typeMsg == TYPE_MSG_EXCEPTION.ERROR) { alertaExcepcion(titleMsgError, msgError, "error"); } else if(typeMsg == TYPE_MSG_EXCEPTION.WARNING) { alertaExcepcion(titleMsgError, msgError, "warning"); } else //if(typeMsg == TYPE_MSG_EXCEPTION.INFO) { alertaExcepcion(titleMsgError, msgError, "info"); } } else { alertaExcepcion(msgError); } } else if (exception.javaClassName == "es.ticketing.util.jdbc.DbException") { alertaExcepcion (polyglot.t("Error_database")); } else if (exception.javaClassName == "es.ticketing.util.SeguridadException") { alertaExcepcion (polyglot.t("Error_do_not_have_permission")); } else if (exception.javaClassName == "es.ticketing.exceptions.VentaException" && exception.message == "Error max tickets email") { // TODO Arreglar en un futuro con la unificación de excepciones en web alertaExcepcion(polyglot.t("Error_max_tickets_email_exceeded")); } else { alertaExcepcion(exception.message); } } else { alertaExcepcion(msg); } } dwr.engine.setErrorHandler(tratamientoErrores); if (typeof(tknX) != "undefined" && tknX != null && tknX != "") { let dwrHeaders = {}; dwrHeaders.tkn_x = escape(tknX); if (typeof(tknC) != "undefined" && tknC != null && tknC != "") { dwrHeaders.tkn_c = escape(tknC); } dwr.engine.setHeaders(dwrHeaders); } $.fn.clearForm = function() { return this.each(function() { var type = this.type, tag = this.tagName.toLowerCase(); if (tag == 'form') return $(':input',this).clearForm(); if (type == 'text' || type == 'password' || tag == 'textarea') this.value = ''; else if (type == 'checkbox' || type == 'radio') this.checked = false; else if (tag == 'select') this.selectedIndex = 0; }); }; function textoBuscar(str) { var res = ''; var c; for ( var i = 0; i < str.length; i++) { c = str.charAt(i); res += mapTextoBuscar[c] || c; } return res.toUpperCase(); } var mapTextoBuscar = { 'À':'A', 'Á':'A', 'Â':'A', 'Ã':'A', 'Ä':'A', 'Å':'A', 'Æ':'AE', 'Ç':'C', 'È':'E', 'É':'E', 'Ê':'E', 'Ë':'E', 'Ì':'I', 'Í':'I', 'Î':'I', 'Ï':'I', 'Ð':'D', 'Ñ':'N', 'Ò':'O', 'Ó':'O', 'Ô':'O', 'Õ':'O', 'Ö':'O', 'Ø':'O', 'Ù':'U', 'Ú':'U', 'Û':'U', 'Ü':'U', 'Ý':'Y', 'ß':'s', 'à':'a', 'á':'a', 'â':'a', 'ã':'a', 'ä':'a', 'å':'a', 'æ':'ae', 'ç':'c', 'è':'e', 'é':'e', 'ê':'e', 'ë':'e', 'ì':'i', 'í':'i', 'î':'i', 'ï':'i', 'ñ':'n', 'ò':'o', 'ó':'o', 'ô':'o', 'õ':'o', 'ö':'o', 'ø':'o', 'ù':'u', 'ú':'u', 'û':'u', 'ü':'u', 'ý':'y', 'ÿ':'y', 'Ā':'A', 'ā':'a', 'Ă':'A', 'ă':'a', 'Ą':'A', 'ą':'a', 'Ć':'C', 'ć':'c', 'Ĉ':'C', 'ĉ':'c', 'Ċ':'C', 'ċ':'c', 'Č':'C', 'č':'c', 'Ď':'D', 'ď':'d', 'Đ':'D', 'đ':'d', 'Ē':'E', 'ē':'e', 'Ĕ':'E', 'ĕ':'e', 'Ė':'E', 'ė':'e', 'Ę':'E', 'ę':'e', 'Ě':'E', 'ě':'e', 'Ĝ':'G', 'ĝ':'g', 'Ğ':'G', 'ğ':'g', 'Ġ':'G', 'ġ':'g', 'Ģ':'G', 'ģ':'g', 'Ĥ':'H', 'ĥ':'h', 'Ħ':'H', 'ħ':'h', 'Ĩ':'I', 'ĩ':'i', 'Ī':'I', 'ī':'i', 'Ĭ':'I', 'ĭ':'i', 'Į':'I', 'į':'i', 'İ':'I', 'ı':'i', 'IJ':'IJ', 'ij':'ij', 'Ĵ':'J', 'ĵ':'j', 'Ķ':'K', 'ķ':'k', 'Ĺ':'L', 'ĺ':'l', 'Ļ':'L', 'ļ':'l', 'Ľ':'L', 'ľ':'l', 'Ŀ':'L', 'ŀ':'l', 'Ł':'L', 'ł':'l', 'Ń':'N', 'ń':'n', 'Ņ':'N', 'ņ':'n', 'Ň':'N', 'ň':'n', 'ʼn':'n', 'Ō':'O', 'ō':'o', 'Ŏ':'O', 'ŏ':'o', 'Ő':'O', 'ő':'o', 'Œ':'OE', 'œ':'oe', 'Ŕ':'R', 'ŕ':'r', 'Ŗ':'R', 'ŗ':'r', 'Ř':'R', 'ř':'r', 'Ś':'S', 'ś':'s', 'Ŝ':'S', 'ŝ':'s', 'Ş':'S', 'ş':'s', 'Š':'S', 'š':'s', 'Ţ':'T', 'ţ':'t', 'Ť':'T', 'ť':'t', 'Ŧ':'T', 'ŧ':'t', 'Ũ':'U', 'ũ':'u', 'Ū':'U', 'ū':'u', 'Ŭ':'U', 'ŭ':'u', 'Ů':'U', 'ů':'u', 'Ű':'U', 'ű':'u', 'Ų':'U', 'ų':'u', 'Ŵ':'W', 'ŵ':'w', 'Ŷ':'Y', 'ŷ':'y', 'Ÿ':'Y', 'Ź':'Z', 'ź':'z', 'Ż':'Z', 'ż':'z', 'Ž':'Z', 'ž':'z', 'ſ':'s', 'ƒ':'f', 'Ơ':'O', 'ơ':'o', 'Ư':'U', 'ư':'u', 'Ǎ':'A', 'ǎ':'a', 'Ǐ':'I', 'ǐ':'i', 'Ǒ':'O', 'ǒ':'o', 'Ǔ':'U', 'ǔ':'u', 'Ǖ':'U', 'ǖ':'u', 'Ǘ':'U', 'ǘ':'u', 'Ǚ':'U', 'ǚ':'u', 'Ǜ':'U', 'ǜ':'u', 'Ǻ':'A', 'ǻ':'a', 'Ǽ':'AE', 'ǽ':'ae', 'Ǿ':'O', 'ǿ':'o' }; //==================================== Funciones para alert y confirm ========================================= function alertPalco(pTitle, pText, pType, pTimer, pClassName, callbackFunction) { var params = {}; if(pTitle != null) params.title = pTitle; if(pText != null) params.text = pText; if(pType != null) params.type = pType; if(pTimer != null) params.timer = pTimer; if(pClassName != null) params.customClass = pClassName; if (callbackFunction != null) { swal(params).then(function(){ if (callbackFunction != null) setTimeout(callbackFunction, 10); }); } else { swal(params); } } function alerta(mensaje){ alertPalco(null, mensaje); } function alertaLoading(mensaje, elToHide){ alertPalco(null, mensaje, null, null, 'above-alert'); $(elToHide).prop('disabled', true); $('.above-alert').attr('style', function(i,s) { return (s || '') + ' z-index:999999 !important' }); } function alertaOK(titulo, mensaje){ alertPalco(titulo, mensaje, "success"); } function alertaOKtimer(titulo, mensaje){ alertPalco(titulo, mensaje, "success", 1000); } function alertaExcepcion(title, msg, type) { //IF msg is null then is a error exception if (msg && title != null) { alertPalco(title, msg, (type != null) ? type : "warning"); } else { alertPalco(polyglot.t("Oops"), (title == null && msg != null) ? msg : title, (type != null) ? type : "error"); } gtmTrackEvent("popup_error"); } function alertaKO(titulo, mensaje) { if (mensaje) { alertPalco(titulo, mensaje, "error"); } else { alertPalco(polyglot.t("Error"), titulo, "error"); } } function confirmarMensaje(titulo, mensaje, textoOK, textoCancelar, funcionOk, funcionCancelar){ swal({ title: titulo, text: mensaje, type: "warning", // warning showCancelButton: true, confirmButtonText: textoOK, cancelButtonText: textoCancelar, confirmButtonClass: 'btn-alert right', cancelButtonClass: 'btn-alert-secondary', allowOutsideClick: false, allowEscapeKey: false }).then(function(result){ if (result){ if (funcionOk != null) setTimeout(funcionOk, 10); } else{ if (funcionCancelar != null) setTimeout(funcionCancelar, 10); } }).catch(swal.noop); } // =========== COLORES =========== /** * Función para modificar luminosidad de un color, o mezclar con otro color * @param p Porcentaje (-1.0 a 1.0) para * @param c0 Color inicial * @param c1 Color mezcla (opcional). Si se indica el resultado será la mezcla del color inicial con este. Sino la mezcla con blanco (+) o negro (-) * @returns Color resultado */ function shadeBlend(p, c0, c1) { var n = p < 0 ? p * -1 : p, u = Math.round, w = parseInt; if (c0.length > 7) { var f = c0.split(","), t = (c1 ? c1 : p < 0 ? "rgb(0,0,0)" : "rgb(255,255,255)").split(","), R = w(f[0].slice(4)), G = w(f[1]), B = w(f[2]); return "rgb(" + (u((w(t[0].slice(4)) - R) * n) + R) + "," + (u((w(t[1]) - G) * n) + G) + "," + (u((w(t[2]) - B) * n) + B) + ")" } else { var f = w(c0.slice(1), 16), t = w((c1 ? c1 : p < 0 ? "#000000" : "#FFFFFF").slice(1), 16), R1 = f >> 16, G1 = f >> 8 & 0x00FF, B1 = f & 0x0000FF; return "#" + (0x1000000 + (u(((t >> 16) - R1) * n) + R1) * 0x10000 + (u(((t >> 8 & 0x00FF) - G1) * n) + G1) * 0x100 + (u(((t & 0x0000FF) - B1) * n) + B1)).toString(16).slice(1) } } function getRandomColor() { var letters = '0123456789ABCDEF'; var color = '#'; for (var i = 0; i < 6; i++) { color += letters[Math.floor(Math.random() * 16)]; } return color; } //=========== FIN COLORES =========== 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 initCountrySelect(elementId, subElementId, selectedValue, addPhoneCode) { let code = getCodeTranslatedCountries(addPhoneCode); $(subElementId).html(code); $('.ui.dropdown').dropdown({ on: 'click', onChange: function(value, text, $selectedItem) { } }); //Default selected if(selectedValue && selectedValue != null) { $(elementId).dropdown('set selected', selectedValue.toLowerCase()); } } function getCodeRegions(addPhoneCode) { var code = ''; for(var e = 0;e < regions.length; e++) { var region = regions[e]; var codeRegion = getCodeCountry(region, addPhoneCode); code += codeRegion; } return code; } function getCodeTranslatedCountries(addPhoneCode) { var code = ''; for(let country of COUNTRIES) { var codeCountry = getCodeTranslatedCountry(country, addPhoneCode); code += codeCountry; } return code; } function getCodeTranslatedCountry(country, addPhoneCode) { let isoId = country.iso; let isoIdl = isoId.toLowerCase(); let prefixStr = country.phone_prefix; if(prefixStr == null || prefixStr == "") { prefixStr = "--"; } let code = ''; if (addPhoneCode) { code = '
'+country.country+' (' + prefixStr + ')
'; } else { code ='
'+country.country+'
'; } return code; } function getCodeCountry(region, addPhoneCode) { var isoId = region.iso; var isoIdl = isoId.toLowerCase(); var prefixStr = region.phonePrefix; if(prefixStr == null || prefixStr == "") { prefixStr = "--"; } var code = ''; if (addPhoneCode) { code = '
'+region.country+' (' + prefixStr + ')
'; } else { code = '
'+region.country+'
'; } return code; } function getCountryCodeFromPrefix(phonePrefix) { if (typeof regions != 'undefined' && regions != null) { for (var i in regions) { var region = regions[i]; if (region.phonePrefix == phonePrefix) { return region.iso; } } } } /** * Devuelve si el usuario está navegando en la web con un móvil * @returns */ function browsingInPhone() { var w = $(window).width(); if(w < 640){ return true; } return false; } function isMobileSize() { var w = $(window).width(); return (w <= 640); } function getCountrynameFromCode(code) { var name = ''; for(var i = 0; i < regions.length; i++) { var currentRegion = regions[i]; if(currentRegion.iso == code) { name = currentRegion.country; } } return name; } /** * ReplaceAt */ String.prototype.replaceAt=function(index, replacement) { return this.substr(0, index) + replacement+ this.substr(index + replacement.length); } function filterDetailWithPromoGitf(detailsWitnoutFilter) { var newDetails = new Array(); for(let i in detailsWitnoutFilter) { var objDetail = detailsWitnoutFilter[i]; if(!objDetail.isPromoGift) { newDetails.push(objDetail); } } return newDetails; } // <----------WEB ANALYTICS---------> function loadWebAnalytics() { if(denyExternalUrlsMode){ return; } // Analytics loadGtag(); // GTM if(gtmCode != null && gtmCode != "") { loadGoogleTagManager(gtmCode); } else { analyticsStatus.gtmInitialized = true; } } function gtag(){} function loadGtag() { let uaCode = CONFIG_GA4[0].value; if (!uaCode) { //console.log("Error: UA Code null"); return; } window.gtagDataLayer = window.gtagDataLayer || []; window.gtag = function () { gtagDataLayer.push(arguments); }; function configureGtag() { window.gtag("js", new Date()); window.gtag("config", uaCode, { referrer: document.referrer }); const adsCookiesString = localStorage.getItem('adsCookies'); var adsCookiesStatus = adsCookiesString != null && adsCookiesString == 'true'; gtag('consent', 'default', { ad_storage: adsCookiesStatus ? 'granted' : 'denied', analytics_storage: adsCookiesStatus ? 'granted' : 'denied', functionality_storage: adsCookiesStatus ? 'granted' : 'denied', personalization_storage: adsCookiesStatus ? 'granted' : 'denied', security_storage: 'granted' }); //Accounts for (let i in CONFIG_GA4) { let configGA4 = CONFIG_GA4[i]; if (configGA4.value != null && configGA4.value != "") { let configName = configGA4.name; let analyticsName = configGA4.value; if (analyticsName == null || analyticsName == '') { continue; } window.gtag('config', analyticsName, { 'name': configName, 'custom_map': { 'dimension1': 'idSesion', 'metric1': 'importeComision' }, 'referrer': document.referrer }); } } } function loadGtagScript() { var gtagScript = document.createElement("script"); gtagScript.async = true; gtagScript.src = "https://www.googletagmanager.com/gtag/js?l=gtagDataLayer"; gtagScript.onload = function () { configureGtag(); analyticsStatus.gtagInitialized = true; initGTMDatalayer(); }; gtagScript.onerror = function () { console.log("Error load gtag.js"); }; document.head.appendChild(gtagScript); } loadGtagScript(); } function loadGoogleTagManager(gtmCode) { if (!gtmCode && denyExternalUrlsMode) { return; } window.tieneGTM = true; window.dataLayer = window[dataLayer] || []; window.dataLayer.push({'gtm.start': new Date().getTime(),event:'gtm.js'}) // var scriptGtm = document.createElement('script'); scriptGtm.type = 'text/javascript'; scriptGtm.src = "https://www.googletagmanager.com/gtm.js?id=" + gtmCode; // + "&l=dataLayer"; scriptGtm.charset = 'utf-8'; scriptGtm.async = true; document.head.appendChild(scriptGtm); scriptGtm.onload = function () { analyticsStatus.gtmInitialized = true; initGTMDatalayer(); }; } /** * GOOGLE TAG MANAGER: TRACKING DATALAYER */ function initGTMDatalayer() { if ( (analyticsStatus.gtagConfigured && !analyticsStatus.gtagInitialized) || (analyticsStatus.gtmConfigured && !analyticsStatus.gtmInitialized) ) { return; } if (typeof getBasicDatalayer == 'function' && typeof buildEcommerce == 'function') { pushDatalayer(getBasicDatalayer(dataLayerP4)); pushDatalayer(buildEcommerce(dataLayerP4)); pushEcommerce(dataLayerP4); } if (dataLayerAction == "event_landing") { var items = []; items.push({ "id": dataLayerP4.eventId, "name": dataLayerP4.eventName, "category": dataLayerP4.venue, "provider": dataLayerP4.provider, "promoter": dataLayerP4.promoter, // Backwards compatibility with GA4 "item_id": dataLayerP4.eventId, "item_name": dataLayerP4.eventName, "item_category": dataLayerP4.venue }); gtag('event', 'view_item', { "items" : items }); } else if(dataLayerAction == "transaction_complete") { var saleKeyAnalytics = 'analytics_registered_order_' + dataLayerP4.transactionId; var keySaleLS = localStorage.getItem(saleKeyAnalytics); var shipping = 0; if (keySaleLS == null) { var items = []; var importeTotal = 0; for (var i in dataLayerP4.products) { var prod_transaction_complete = dataLayerP4.products[i]; items.push({ "id": dataLayerP4.eventId, "name": dataLayerP4.eventName, //"brand": dataLayerP4.venue, "category": dataLayerP4.venue, "variant": prod_transaction_complete.product, "quantity": prod_transaction_complete.qty, "price": prod_transaction_complete.price, // Backwards compatibility with GA4 "item_id": prod_transaction_complete.productId, "item_name": prod_transaction_complete.eventName, "item_category": dataLayerP4.venue }); shipping += Number(prod_transaction_complete.fee); importeTotal += Number(prod_transaction_complete.price); } gtag('event', 'purchase', { "transaction_id": dataLayerP4.transactionId, "value": importeTotal, "currency": CURRENCY_CODE, //finalCurrency "shipping": shipping, "items" : items, "affiliation" : dataLayerP4.affiliateId? dataLayerP4.affiliateId : null }); localStorage.setItem(saleKeyAnalytics, true); } } else if(dataLayerAction == "booking_complete") { var items = []; var importeTotal = 0; for (var i in dataLayerP4.products) { var prod_booking_complete = dataLayerP4.products[i]; items.push({ "id": dataLayerP4.eventId, "name": dataLayerP4.eventName, //"brand": dataLayerP4.venue, "category": dataLayerP4.venue, "variant": prod_booking_complete.product, "quantity": prod_booking_complete.qty, "price": prod_booking_complete.price, // Backwards compatibility with GA4 "item_id": prod_booking_complete.productId, "item_name": prod_booking_complete.eventName, "item_category": dataLayerP4.venue }); shipping += Number(prod_booking_complete.fee); importeTotal += Number(prod_booking_complete.price); } gtag('event', 'booking', { "transaction_id": dataLayerP4.transactionId, "value": importeTotal, "currency": CURRENCY_CODE, //finalCurrency "shipping": shipping, "items" : items, "affiliation" : dataLayerP4.affiliateId? dataLayerP4.affiliateId : null }); } else if(dataLayerAction == "checkout") { var items = []; var importeTotal = 0; for (var i in dataLayerP4.products) { var prod_checkout = dataLayerP4.products[i]; items.push({ "id": dataLayerP4.eventId, "name": dataLayerP4.eventName, //"brand": dataLayerP4.venue, "category": dataLayerP4.venue, "variant": prod_checkout.product, "quantity": prod_checkout.qty, "price": prod_checkout.price, // Backwards compatibility with GA4 "item_id": dataLayerP4.eventId, "item_name": dataLayerP4.eventName, "item_category": dataLayerP4.venue, "item_variant": prod_checkout.product }); importeTotal += Number(prod_checkout.price); } gtag('event', 'begin_checkout', { "items" : items, // Backwards compatibility with GA4 "value": importeTotal, "currency": CURRENCY_CODE //finalCurrency }); } } function trackFunnelStep(dataLayerP4, step, action, sale) { if (tieneGTM) { if (typeof generarCheckout == 'function') { pushDatalayer(generarCheckout(dataLayerP4, step, action, sale)); } } if (step == 2) { addToCartGA(sale.detalle); addToCartMetaPixel(sale.detalle); addToCartTikTokPixel(sale.detalle); } else if (step == 3) { addPaymentInfoGA(); addPaymentInfoMetaPixel(); addPaymentInfoTikTokPixel(); } else if (step == 4) { addInitiateCheckoutMetaPixel(); addInitiateCheckoutTikTokPixel(); } } function gtmTrackProductClick(sale) { if (tieneGTM) { if (typeof buildProductClick == 'function') { pushDatalayer(buildProductClick(sale)); } } if (dataLayerAction == 'products_selection') { var detalle = []; for (var i in sale.detalle) { if (!sale.detalle[i].esEntrada) { detalle.push(sale.detalle[i]); } } addToCartGA(detalle); addToCartMetaPixel(detalle); addToCartTikTokPixel(detalle); } } function addToCartGA(sale) { if (typeof gtag !== 'function') { return; } var items = []; //var shipping = 0; var importeTotal = 0; for(var i in sale) { var dv = sale[i] items.push({ 'name': dataLayerP4.eventName, 'id': dataLayerP4.eventId, 'price': dv.importe + dv.iva, 'brand': dataLayerP4.venue, 'variant': dv.litProducto, 'quantity': dv.cantidad, // Backwards compatibility with GA4 'item_name': dataLayerP4.eventName, 'item_id': dataLayerP4.eventId, 'item_brand': dataLayerP4.venue, 'item_variant': dv.litProducto }); // shipping += dv.importeComisionUsuario + dv.ivaComisionUsuario; importeTotal += dv.importe + dv.iva; } gtag('event', 'add_to_cart', { //ADD TO CART "items" : items, // Backwards compatibility with GA4 "currency" : CURRENCY_CODE, "value" : importeTotal }); } function addPaymentInfoGA() { if (typeof gtag !== 'function') { return; } var items = []; var importeTotal = 0; for (var i in dataLayerP4.products) { var prod = dataLayerP4.products[i]; items.push({ "id": dataLayerP4.eventId, "name": dataLayerP4.eventName, //"brand": dataLayerP4.venue, "category": dataLayerP4.venue, "variant": prod.product, "quantity": prod.qty, "price": prod.price, // Backwards compatibility with GA4 "item_id": dataLayerP4.eventId, "item_name": dataLayerP4.eventName, "item_category": dataLayerP4.venue, "item_variant": prod.product }); importeTotal += Number(prod.price); } gtag('event', 'add_payment_info', { "items": items, "payment_type": activeFormOfPayment.formaPago, "value": importeTotal, "currency": CURRENCY_CODE }); } function addToCartMetaPixel(sale) { if (typeof fbq !== 'function') { return } var pixel_contents = []; var totalValue = 0; var totalQuantity = 0; for(var i in sale) { var dv = sale[i]; var itemPriceWithIVA = dv.importe + dv.iva; totalValue += itemPriceWithIVA * dv.cantidad; totalQuantity += dv.cantidad; pixel_contents.push({ id: dv.idProducto, quantity: dv.cantidad, item_price: itemPriceWithIVA, productName: dv.litTipoProducto, eventId: dv.idEvento, eventName: dataLayerP4.eventName, }) } fbq('track', 'AddToCart', { contents: pixel_contents, content_type: 'product', value: totalValue, currency: CURRENCY_CODE, locator: typeof venta !== 'undefined' && venta !== null ? venta.localizador : null, content_name: dataLayerP4.eventName, content_category: dataLayerP4.venue, num_items: totalQuantity }) } function addPaymentInfoMetaPixel() { if (typeof fbq !== 'function') { return } const pixelData = prepareMetaPixelByDataLayerProducts(); fbq('track', 'AddPaymentInfo', { contents: pixelData.pixelContents, content_type: 'product', value: pixelData.totalValue, currency: CURRENCY_CODE, content_name: dataLayerP4.eventName, content_category: dataLayerP4.venue, num_items: pixelData.totalQuantity }) } function addInitiateCheckoutMetaPixel() { if (typeof fbq !== 'function') { return } const pixelData = prepareMetaPixelByDataLayerProducts(); fbq('track', 'InitiateCheckout', { contents: pixelData.pixelContents, content_type: 'product', value: pixelData.totalValue, currency: CURRENCY_CODE, content_name: dataLayerP4.eventName, content_category: dataLayerP4.venue, num_items: pixelData.totalQuantity }) } function purchaseMetaPixel() { if (typeof fbq !== 'function') { return } const pixelData = prepareMetaPixelByDataLayerProducts(); fbq('track', 'Purchase', { contents: pixelData.pixelContents, content_type: 'product', value: pixelData.totalValue, currency: CURRENCY_CODE, num_items: pixelData.totalQuantity, purchaseRef: purchaseRef }) } function addToCartTikTokPixel(sale) { if (!isTikTokPixelAvailable()) { return } const pixelData = prepareTikTokPixelFromSaleDetail(sale) ttq.track('AddToCart', { content_ids: pixelData.contentIds, content_type: 'product', quantity: pixelData.totalQuantity, value: pixelData.totalValue, currency: CURRENCY_CODE, content_name: pixelData.contentName, content_category: pixelData.contentCategory, description: pixelData.description }) } function addPaymentInfoTikTokPixel() { if (!isTikTokPixelAvailable()) { return } const pixelData = prepareTikTokPixelByDataLayerProducts(); ttq.track('AddPaymentInfo', { content_ids: pixelData.contentIds, content_type: 'product', quantity: pixelData.totalQuantity, value: pixelData.totalValue, currency: CURRENCY_CODE, content_name: pixelData.contentName, content_category: pixelData.contentCategory, description: pixelData.description }) } function addInitiateCheckoutTikTokPixel() { if (!isTikTokPixelAvailable()) { return } const pixelData = prepareTikTokPixelByDataLayerProducts(); ttq.track('InitiateCheckout', { content_ids: pixelData.contentIds, content_type: 'product', quantity: pixelData.totalQuantity, value: pixelData.totalValue, currency: CURRENCY_CODE, content_name: pixelData.contentName, content_category: pixelData.contentCategory, description: pixelData.description }) } function purchaseTikTokPixel() { if (!isTikTokPixelAvailable()) { return } var saleKeyTikTok = 'tiktok_registered_order_' + purchaseRef; var keySaleTikTokLS = localStorage.getItem(saleKeyTikTok); if (keySaleTikTokLS != null) { return } const pixelData = prepareTikTokPixelByDataLayerProducts(); ttq.track('Purchase', { content_ids: pixelData.contentIds, content_type: 'product', quantity: pixelData.totalQuantity, value: pixelData.totalValue, currency: CURRENCY_CODE, content_name: pixelData.contentName, content_category: pixelData.contentCategory, description: pixelData.description }) localStorage.setItem(saleKeyTikTok, true); } function prepareMetaPixelByDataLayerProducts() { const pixelData = { pixelContents: [], totalValue: 0, totalQuantity: 0 } for (const i in dataLayerP4.products) { const dv = dataLayerP4.products[i]; const itemPriceWithIVA = parseFloat(dv.price) + parseFloat(dv.fee); pixelData.totalValue += itemPriceWithIVA * parseInt(dv.qty); pixelData.totalQuantity += parseInt(dv.qty); pixelData.pixelContents.push({ id: dv.productId, quantity: parseInt(dv.qty), item_price: itemPriceWithIVA, productName: dv.product, eventId: dv.eventId, eventName: dv.eventName, }) } return pixelData; } function prepareTikTokPixelByDataLayerProducts() { const pixelData = { contentIds: [], totalValue: 0, totalQuantity: 0, contentName: dataLayerP4.eventName, contentCategory: dataLayerP4.venue, description: dataLayerP4.eventName, } for (const i in dataLayerP4.products) { const dv = dataLayerP4.products[i]; const itemPriceWithIVA = parseFloat(dv.price) + parseFloat(dv.fee); pixelData.totalValue += itemPriceWithIVA * parseInt(dv.qty); pixelData.totalQuantity += parseInt(dv.qty); if (dv.productId != null) { pixelData.contentIds.push(String(dv.productId)); } } pixelData.contentIds = [...new Set(pixelData.contentIds)]; return pixelData; } function prepareTikTokPixelFromSaleDetail(sale) { const pixelData = { contentIds: [], totalValue: 0, totalQuantity: 0, contentName: dataLayerP4.eventName, contentCategory: dataLayerP4.venue, description: dataLayerP4.eventName, } for (const i in sale) { const dv = sale[i]; const itemPriceWithIVA = dv.importe + dv.iva; pixelData.totalValue += itemPriceWithIVA * dv.cantidad; pixelData.totalQuantity += dv.cantidad; if (dv.idProducto != null) { pixelData.contentIds.push(String(dv.idProducto)); } if ((!pixelData.contentName || pixelData.contentName === '') && dv.litEvento) { pixelData.contentName = dv.litEvento; pixelData.description = dv.litEvento; } if ((!pixelData.contentCategory || pixelData.contentCategory === '') && dv.litRecinto) { pixelData.contentCategory = dv.litRecinto; } } pixelData.contentIds = [...new Set(pixelData.contentIds)]; return pixelData; } function isTikTokPixelAvailable() { return typeof ttq === 'function' || typeof ttq === 'object'; } function gtmTrackEvent(event) { if (tieneGTM) { if (typeof pushGTMEvent == 'function') { pushDatalayer(pushGTMEvent(event)); } } } function pushDatalayer(event) { if (!jQuery.isEmptyObject(event)) { dataLayer.push(event); } } function isInt(n){ return Number(n) === n && n % 1 === 0; } function isFloat(n){ return Number(n) === n && n % 1 !== 0; } function loadScript(url, callback) { var script = document.createElement("script") script.type = "text/javascript"; if (script.readyState){ //IE script.onreadystatechange = function(){ if (script.readyState == "loaded" || script.readyState == "complete"){ script.onreadystatechange = null; callback(); } }; } else { //Others script.onload = function(){ callback(); }; } script.src = url; document.getElementsByTagName("head")[0].appendChild(script); } function saltarAContenedor(idDestino){ var target = $('[id=' + idDestino +']'); var htarget = target.outerHeight(); var hpantalla = $(window).height(); var hbarra = $(".bar_action").innerHeight(); if (target.length) { var cordFinal = target.offset().top; if(hpantalla > htarget) { cordFinal = cordFinal - (((hpantalla-hbarra) - htarget) / 2); } $('html,body').animate({ scrollTop: cordFinal }, 500); return false; } } // ADDRESS EDITOR let currentAddressEditor = null; const COUNTRIES_WITH_STATES = ['US', 'MX', 'CA']; let originalLabelNames = null; function hideAddressModal() { $("#popup_address").removeClass("show"); } function submitField(event) { event.preventDefault(); } let phonePrefix = ''; function countrySelected() { let addressCountrySelected = document.querySelector('#countryDiv input').value.toUpperCase(); currentAddressEditor.countryConfiguration = getCountry(addressCountrySelected); configureAddressFormFields(currentAddressEditor.countryConfiguration); requireOptionalFields(currentAddressEditor.countryConfiguration); currentAddressEditor.countrySelected(document.querySelector('#countryDiv input').value.toUpperCase()); phonePrefix = document.querySelector('div[data-value=' + addressCountrySelected.toLowerCase() + ']').getAttribute('data-prefix'); } function requireOptionalFields(countryConfiguration) { if (countryConfiguration == null) { return; } if (currentAddressEditor != null && currentAddressEditor.countryConfiguration != null && !currentAddressEditor.countryConfiguration.fields.district.hidden) { $('#district').attr("required", currentAddressEditor.countryConfiguration.fields.district.required); } else { $('#district').attr("required", false); } if (currentAddressEditor != null && currentAddressEditor.countryConfiguration != null && !currentAddressEditor.countryConfiguration.fields.address_2.hidden) { $('#addressLine2').attr("required", currentAddressEditor.countryConfiguration.fields.address_2.required); } else { $('#district').attr("required", false); } } function configureAddressFormFields(countryConfiguration) { if (countryConfiguration == null) { return; } //Configure fields visibility if (countryConfiguration.fields.province.hidden) { $("#stateInput").parent().hide(); $("#stateInput").attr("required", false); currentAddressEditor.state = ""; $("#stateInput").val(""); } else { $("#stateInput").parent().show(); if (currentAddressEditor.addressEditorConfig.address.isMandatory) { $("#city").attr("required", true); } } if (countryConfiguration.fields.locality.hidden) { $("#city").parent().hide(); $("#city").attr("required", false); $("#city").val(""); } else { $("#city").parent().show(); if (currentAddressEditor.addressEditorConfig.address.isMandatory) { $("#city").attr("required", true); } } if (countryConfiguration.fields.postal_code.hidden) { $("#pc").parent().hide(); $("#pc").attr("required", false); $("#pc").val(""); } else { $("#pc").parent().show(); if(currentAddressEditor.addressEditorConfig.address.isMandatory) { $("#pc").attr("required", true); } } if (countryConfiguration.fields.address_1.hidden) { $("#addressLine1").parent().hide(); $("#addressLine1").attr("required", false); $("#addressLine1").val(""); } else { $("#addressLine1").parent().show(); if (currentAddressEditor.addressEditorConfig.address.isMandatory) { $("#addressLine1").attr("required", true); } } if (countryConfiguration.fields.address_2.hidden) { $("#addressLine2").parent().hide(); $("#addressLine2").val(""); } else { $("#addressLine2").parent().show(); } if (countryConfiguration.fields.district.hidden) { $('#addressDistrict').parent().hide(); $("#district").val(""); } else { $('#addressDistrict').parent().show(); } //Configure fields text if (originalLabelNames == null) { originalLabelNames = { "postal_code" : document.getElementById('pcLabel').innerText, "address_1" : document.getElementById('addressLine1Label').innerText, "address_2" : document.getElementById('addressLine2Label').innerText, "locality" : document.getElementById('cityLabel').innerText, "district" : document.getElementById('addressDistrict').innerText } } if (countryConfiguration.fields.province.name != null) { document.querySelector('#stateInput label').innerText = countryConfiguration.fields.province.name; } if (countryConfiguration.fields.locality.name != null) { document.getElementById('cityLabel').innerText = polyglot.t(countryConfiguration.fields.locality.name); document.getElementById('city').placeholder = polyglot.t(countryConfiguration.fields.locality.name); } else { document.getElementById('cityLabel').innerText = originalLabelNames.locality; document.getElementById('city').placeholder = originalLabelNames.locality; } if (countryConfiguration.fields.postal_code.name != null) { document.getElementById('pcLabel').innerText = countryConfiguration.fields.postal_code.name; } else { document.getElementById('pcLabel').innerText = originalLabelNames.postal_code; } if (countryConfiguration.fields.address_1.name != null) { document.getElementById('addressLine1Label').innerText = countryConfiguration.fields.address_1.name; } else { document.getElementById('addressLine1Label').innerText = originalLabelNames.address_1; } if (countryConfiguration.fields.address_2.name != null) { document.getElementById('addressLine2Label').innerText = countryConfiguration.fields.address_2.name; } else { document.getElementById('addressLine2Label').innerText = originalLabelNames.address_2; } if (countryConfiguration.fields.district.name != null) { document.getElementById('addressDistrict').innerText = polyglot.t(countryConfiguration.fields.district.name); document.getElementById('district').placeholder = polyglot.t(countryConfiguration.fields.district.name); } else { document.getElementById('addressDistrict').innerText = originalLabelNames.district; document.getElementById('district').placeholder = originalLabelNames.district; } } function goBackToAddressEditorModal() { hideAddressValidationModal(); $("#popup_address").addClass("show"); } function hideAddressValidationModal() { $("#popup_address_validation").removeClass("show"); } function setStateCode() { let stateName = document.querySelector('#stateInput input').value; stateCodeSelectedNotSaved = document.querySelector("#stateInput [data-value='" + stateName + "']").id.replace('select-state-', ''); } function saveSuggestedAddress() { currentAddressEditor.saveSuggestedAddress(); } function saveWithoutValidation() { setToNoValidate = true; $("#formAddressEdition").submit(); } function hideCitySuggestionModal() { $("#city_suggestion_popup").removeClass("show"); } $('#formAddressEdition').on("submit", function(ev) { ev.preventDefault(); return currentAddressEditor.validate(); }); function getTaxPrice(price, pctTax) { let priceWithoutTaxes = roundAmount(price * pctTax / (100 + pctTax)); return priceWithoutTaxes; } function isBlockUIVisible() { var elements = document.querySelectorAll(".blockUI"); for (var i = 0; i < elements.length; i++) { var element = elements[i]; // Comprobar si está oculto mediante CSS display 'none' var displayNotNone = !(window.getComputedStyle(element).display === "none"); // Comprobar si tiene opacidad 0 var opacityNotZero = !(window.getComputedStyle(element).opacity === "0"); // Comprobar si tiene visibilidad 'hidden' var visibilityNotHidden = !(window.getComputedStyle(element).visibility === "hidden"); // Comprobar si está fuera del flujo del documento con un tamaño de 0 var elementHasSize = element.offsetWidth > 0 && element.offsetHeight > 0; if (displayNotNone && opacityNotZero && visibilityNotHidden && elementHasSize) { return true; } } return false; } // function isValidPersonalNumberIdentifier(idCardType, nif) { const inputElement = document.querySelector('input[name="legalName"]'); const isValid = IdentityCard.create(idCardType, nif).validate(); if(idCardType == IdCardType.RNC_DO || idCardType == IdCardType.CEDULA_DO) { if(inputElement) { inputElement.disabled = true; } return (isValid)?IdCardValidationResultStatus.IN_VALIDATION:IdCardValidationResultStatus.NOT_VALID; } return (isValid)?IdCardValidationResultStatus.VALID:IdCardValidationResultStatus.NOT_VALID; } function instapagoSudebanCodes() { return [ { code: "0001", name: "Banco Central de Venezuela" }, { code: "0102", name: "Banco de Venezuela S.A.C.A. Banco Universal" }, { code: "0104", name: "Venezolano de Crédito, S.A. Banco Universal" }, { code: "0105", name: "Banco Mercantil, C.A. Banco Universal" }, { code: "0108", name: "Banco Provincial, S.A. Banco Universal" }, { code: "0114", name: "Bancaribe C.A. Banco Universal" }, { code: "0115", name: "Banco Exterior C.A. Banco Universal" }, { code: "0116", name: "Banco Occidental de Descuento, Banco Universal C.A." }, { code: "0128", name: "Banco Caroní C.A. Banco Universal" }, { code: "0134", name: "Banesco Banco Universal S.A.C.A." }, { code: "0137", name: "Banco Sofitasa C.A., Banco Universal" }, { code: "0138", name: "Banco Plaza, Banco Universal" }, { code: "0146", name: "Banco de la Gente Emprendedora C.A" }, { code: "0151", name: "BFC Banco Fondo Común C.A. Banco Universal" }, { code: "0156", name: "100% Banco, Banco Universal C.A." }, { code: "0157", name: "DelSur Banco Universal C.A." }, { code: "0163", name: "Banco del Tesoro, C.A. Banco Universal" }, { code: "0166", name: "Banco Agrícola de Venezuela, C.A. Banco Universal" }, { code: "0168", name: "Bancrecer, S.A. Banco Microfinanciero" }, { code: "0169", name: "Mi Banco, Banco Microfinanciero C.A." }, { code: "0171", name: "Banco Activo, Banco Universal C.A." }, { code: "0172", name: "Bancamica, Banco Microfinanciero C.A." }, { code: "0173", name: "Banco Internacional de Desarrollo, C.A. Banco Universal" }, { code: "0174", name: "Banplus Banco Universal, C.A." }, { code: "0175", name: "Banco Bicentenario del Pueblo de la Clase Obrera, Mujer y Comunas B.U." }, { code: "0176", name: "Novo Banco, S.A. Sucursal Venezuela Banco Universal" }, { code: "0177", name: "Banco de la Fuerza Armada Nacional Bolivariana, B.U." }, { code: "0190", name: "Citibank N.A." }, { code: "0191", name: "Banco Nacional de Crédito, C.A. Banco Universal" }, { code: "0601", name: "Instituto Municipal de Crédito Popular" } ]; }