var core_url = ""; var stripeToken = ''; var product_name = ''; var product_price = ''; var selected = '';//para el extra extendido var timeout = null; var id_reserv = null; var update_people_peticion = false; var havequestions = false; var havequestionsmenu = false; var questions = false; var nummenu_select = 0; var numpeople_reserv = 0; var nummenu_posibility = 0; var menuseleccionados = false; var classifyseleccionados = false; var extra_pos; var redeem = false; var code = null; var show_waiting_search = false; var call_code; var hour_motor_conf = false; var first_hour_conf; var space_time; var first_iteration = false; var stop_validation = false; var invoice_generate_reserv = 0; var required_billing_information = 0; var typeReserveBillingInfoRequired = []; var checkBillingInfoRequired = false; var limitAmountBullingDataReserv = []; var timeout_reserv = 0; //variables para carrito de compra var shopping_cart = 0; var productextras = []; var shoppingproduct = []; var prix_productselecttotal = 0; var prix_totalproducts = 0; var prix_eachproduct = []; var infoproducts = []; var numberproducts = []; var infoproduct; var hasInitialProduct = false; var productincart = 0; var therearemenus = false; var thereareproducts = true; var noproductsnomenus = false; var productos; var extra_message_column = 0; var newsletter_obli_motores = 0; var subscribe_check_shown_motores = 1; var use_conditions_check_shown_motores = 1; var personal_data_check_shown_motores = 1; var subscribe_checked_motores = 0; var zone_waiting_list = 0; var pay_type_use_secure = 0; var id_reserv_secure_stripe = -1; var highlight = {}; var highlight_loading = {}; var product_group = '0'; var has_discount = false; var new_price_discount_global = ''; var has_origin_correct = false; var not_first_step_go_datos_personales = false; var pay_type_use = 0; var product_use_card = null; var payment_intent = ''; var extra_avaible_reserv_module = ''; var isSetupIntent = false; var countdown_started = false; interval_comprove_redsys = false; // GOOGLE TAG MANAGER VARS var date_tag; var people_tag; var hour_tag; var date_add; var preciopagado = 0; var product_tag = 0; // 0 waiting_list, 1 free_reserv, 2 cancellation_policy, 3 ticket var total_fire = 0; var show_birthday = 0; var show_extra_field = false; var obligate_birthday = 0; var can_choose_type_reserve = 0; var id_redsys = ''; var amount_total_redsys = 0; var position_currency = 1; var email_tag = ''; var ectd_client = false; var ectd_client_int_call_code = false; var ectd_client_country = false; var isBillingInfoRequired = false; var isNecessaryCard = false; var hidePreviouPrice = false; var elements; var paymentElement; var stripeObjectConfig = { hidePostalCode: true, style: { base: { iconColor: '#F99A52', color: '#909090', lineHeight: '48px', fontWeight: 400, fontFamily: '"Helvetica Neue", "Helvetica", sans-serif', fontSize: '19px', '::placeholder': { color: '#CFD7DF', } }, }, fields: { billingDetails: { address: { country: 'never' } } }, terms: { applePay: 'never', auBecsDebit: 'never', bancontact: 'never', card: 'never', cashapp: 'never', googlePay: 'never', ideal: 'never', paypal: 'never', sepaDebit: 'never', sofort: 'never', usBankAccount: 'never' } }; var paymentCountryCode = 'ES'; var paymentName = ''; var paymentEmail = ''; var activeCalendarColorPeople = false; var adyenTypeMotor = 'ClassicMotor'; var paymentIntent = ''; var amountTotal = 0; $(document).ready(function () { $("#dialog").dialog({ autoOpen: false }); // cargar cuadros load_boxes2(); $("#have").hide(); $('#creditnumber_modulo').keyup(function () { var number = $(this).val().split(" ").join(""); // remove hyphens if (number.length > 0) { number = number.match(new RegExp('.{1,4}', 'g')).join(" "); } if (number.length > 20) { number = number.substr(0, 19); } $(this).val(number); }); }); //Carga las cajas del modulo function load_boxes2() { stop_validation = true; $.post(core_url + '/reservation/ibox2/' + getVipReservationValue(), { language: language, restaurant: restaurant, force_date: force_date, start: start, end: end, only_this_people: only_this_people, min_people: min_people, max_people: max_people, time_fix: time_fix, day: day_pre, skip_blocked_tables : skipBlockedTables, marketplace: isMarketplace() }, function (data) { if (data.error === 0) { const today = new Date(); const todayMonth = today.toLocaleString('en-US', { month: "2-digit" }); const todayDay = today.toLocaleString('en-US', { day: "2-digit" }); date_add = `${today.getFullYear()}-${todayMonth}-${todayDay}`; var includeLogoCoverEngine = '0'; $('#footerCoverDiv').css('display', 'none'); if (data.restaurant_config.includeLogoCoverEngine != '') { includeLogoCoverEngine = data.restaurant_config.includeLogoCoverEngine; } if (includeLogoCoverEngine == '1') { $('#footerCoverDiv').css('display', 'block'); if (data.urlFooterCover != '') { $('#urlLogoCover').attr('href', data.urlFooterCover); } } if (data.motor_first_product == 0) { if (motor_first_product == 1) { motor_first_product = 0; $('#extra_box_product').html(''); $('#extra_box_product').hide(); $('#infoproduct').show(); $('#personas_box').show(); $('#extra_box').show(); $('#hour_box').show(); $('#price_product_special').hide(); } if (not_first_step == '1') { $('#datos_reserva').hide(); } $('#login_box').html(data.login_box); $('#date_box').html(data.date_box); $('#info-box').html(data.info_box); total_fire = data.total_fire; show_extra_field = data.restaurant_config.extra_field || data.restaurant_config.extra_field.active == '1'; pay_type_use = data.pay_type_use; show_birthday = data.restaurant_config.information.show_birthday; obligate_birthday = data.restaurant_config.information.obligate_birthday; can_choose_type_reserve = data.restaurant_config.information.can_choose_type_reserve; shopping_cart = parseInt(data.shopping_cart); extra_message_column = parseInt(data.show_message_rules); newsletter_obli_motores = parseInt(data.newsletter_obli_motores); subscribe_check_shown_motores = parseInt(data.subscribe_check_shown_motores); use_conditions_check_shown_motores = parseInt(data.use_conditions_check_shown_motores); personal_data_check_shown_motores = parseInt(data.personal_data_check_shown_motores); subscribe_checked_motores = parseInt(data.subscribe_checked_motores); invoice_generate_reserv = parseInt(data.invoice_generate_reserv); required_billing_information = parseInt(data.required_billing_information); legal_check_1_motores = data.legal_check_1_motores; legal_check_2_motores = data.legal_check_2_motores; legal_check_3_motores = data.legal_check_3_motores; call_code = data.call_code; hour_motor_conf = data.hour_motor_conf; position_currency = data.restaurant_config.position_currency; typeReserveBillingInfoRequired = data.type_reserve_billing_info_required; limitAmountBullingDataReserv = data.limit_amount_billing_data_reserv; activeCalendarColorPeople = data.restaurant_config.activeCalendarColorPeople == '1' ? true : false; if (hour_motor_conf) { space_time = data.space_time; first_hour_conf = data.first_hour_conf; } if (intcallcode_pre != '') { $('#int_call_code').val(intcallcode_pre); } else { $('#int_call_code').val(data.call_code); } people_box(data.personas_box); hour_box(data.hour_box); update_hours(); extra_box(data.extra_box); login_box(data); $('#hour-box-select').val(-1); info_box2(); hour_box_group_request(data.hours_grouprequest); // preselection if (day_pre != '') { var day_pre_sp = day_pre.split("-"); $('#datepicker').datepicker("setDate", new Date(day_pre_sp[0], day_pre_sp[1] - 1, day_pre_sp[2])); update_hour_people(); day_pre = ''; } else { hour_box_extra(data.extra_hour_box); } } else { $('#login_box').html(data.login_box); $('#date_box').html(data.date_box); $('#info-box').html(data.info_box); show_extra_field = data.restaurant_config.extra_field || data.restaurant_config.extra_field.active == '1'; show_birthday = data.restaurant_config.information.show_birthday; obligate_birthday = data.restaurant_config.information.obligate_birthday; can_choose_type_reserve = data.restaurant_config.information.can_choose_type_reserve; shopping_cart = parseInt(data.shopping_cart); extra_message_column = parseInt(data.show_message_rules); newsletter_obli_motores = parseInt(data.newsletter_obli_motores); subscribe_check_shown_motores = parseInt(data.subscribe_check_shown_motores); use_conditions_check_shown_motores = parseInt(data.use_conditions_check_shown_motores); personal_data_check_shown_motores = parseInt(data.personal_data_check_shown_motores); subscribe_checked_motores = parseInt(data.subscribe_checked_motores); required_billing_information = parseInt(data.required_billing_information); legal_check_1_motores = data.legal_check_1_motores; legal_check_2_motores = data.legal_check_2_motores; legal_check_3_motores = data.legal_check_3_motores; call_code = data.call_code; hour_motor_conf = data.hour_motor_conf; position_currency = data.restaurant_config.position_currency; typeReserveBillingInfoRequired = data.type_reserve_billing_info_required; limitAmountBullingDataReserv = data.limit_amount_billing_data_reserv; if (intcallcode_pre != '') { $('#int_call_code').val(intcallcode_pre); } else { $('#int_call_code').val(data.call_code); } for (let k in data.products) { let option = $('') .val(data.products[k].extra) .text(data.products[k].name); $('#extra-box-select-product').append(option); } $('#extra-box-select-product').change(function () { update_product_first(); }); } if (data.wl_hidden_button_web == '1' && data.waiting_list_lunch == '0' && data.waiting_list_dinner == '0') { $('#waiting_button_list').hide(); } } else { alert(data.error); } }, "json"); } // FUNCIONES FIRST PRODUCTS IN MOTOR function update_date_product() { var date = $('#datepicker').val(); stop_validation = true; $.post(core_url + '/reservation/update_date_product', { language: language, restaurant: restaurant, date: date }, function (data) { if ((motor_first_product == 1 && data.motor_first_product == 1) || (motor_first_product == 0 && data.motor_first_product == 1)) { if (motor_first_product == 0 && data.motor_first_product == 1) { motor_first_product = 1; $('#infoproduct').hide(); $('#extra_box_product').show(); } $('#extra_box_product').html(data.extra_box); for (let k in data.products) { let option = $('') .val(data.products[k].extra) .text(data.products[k].name); $('#extra-box-select-product').append(option); } $('#extra-box-select-product').change(function () { update_product_first(); }); $('#personas_box').html(''); $('#hour_box').html(''); $('#extra_box').html(''); $('#personas_box').hide(); $('#extra_box').hide(); $('#hour_box').hide(); $('.product-name, .product-price, .product-price-total, .product-description').text(''); $('#price_product_special').hide(); } else { if (motor_first_product == 1 && data.motor_first_product == 0) { $('#infoproduct').show(); motor_first_product = 0; $('#extra_box_product').html(''); $('#extra_box_product').hide(); $('#personas_box').show(); $('#extra_box').show(); $('#hour_box').show(); $('.product-name, .product-price, .product-price-total, .product-description').text(''); $('#price_product_special').hide(); update_hour_people(); } else { if (motor_first_product == 0 && data.motor_first_product == 0) { update_hour_people(); } } } hour_box_group_request(data.hours_grouprequest); }, "json"); } function update_product_first() { var product_select = $('#extra-box-select-product').val(); var date = $('#datepicker').val(); var selection = $('#extra-box-select-product').val(); stop_validation = true; $.post(core_url + '/reservation/update_product_first', { language: language, restaurant: restaurant, date: date, product_select: product_select, selection: selection }, function (data) { $('#personas_box').html(data.people_box_product); $('#people-box-select').change(function () { change_people_product(); }); $('#hour_box').html(data.hour_box_product); $('#hour-box-select').change(function () { change_hour_product(); }); $('#personas_box').show(); $('#hour_box').show(); $('#hour_box_extra_group_request').html(data.hour_box_product); $('#extra_message_zone').html(''); $('#extra_message_zone').hide(); change_hour_product(); hour_box_group_request(data.hours_grouprequest); product_name = data.product.product_name + ', ' || ''; product_description = data.product.product_description || ''; // Actualizar vat var vat = 100 + parseFloat(data.product.product_vat); // grupos var people = $('#people-box-select').val(); if (people == undefined || people == null) { people = 1; } if (data.product.product == 3) { $('#price_product_special').show(); if (data.product.price_people != 0) { if (data.product.product_groups == 0) { $('.forpeople').show(); if (restaurant == 'a-cuatro-manos') { $('.product-price').text(print_price_currency((data.product.price_people / 100).toFixed(2), currency_str) + per_person + ' ' + iva_incluido); } else { if (vat != 100) { $('.product-price').text(print_price_currency((data.product.price_people / 100).toFixed(2), currency_str) + per_person + ' ' + iva_incluido); } else { $('.product-price').text(print_price_currency((data.product.price_people / 100).toFixed(2), currency_str) + per_person); } } $('.info_header2').show(); if (vat != 100) { $('.product-price-total').text(total + ': ' + print_price_currency((data.product.price_people / 100 * people).toFixed(2), currency_str) + ' ' + iva_incluido + ' (' + print_price_currency((data.product.price_people / vat * 1).toFixed(2), currency_str) + ' ' + iva_no_incluido + ')'); } else { $('.product-price-total').text(total + ': ' + print_price_currency((data.product.price_people / 100 * people).toFixed(2), currency_str)); } } else { $('.forpeople').hide(); if (vat != 100) { $('.product-price').text(print_price_currency((data.product.price_people / 100).toFixed(2), currency_str) + ' ' + iva_incluido); } else { $('.product-price').text(print_price_currency((data.product.price_people / 100).toFixed(2), currency_str)); } $('.info_header2').show(); if (vat != 100) { $('.product-price-total').text(total + ': ' + print_price_currency((data.product.price_people / 100).toFixed(2), currency_str) + ' ' + iva_incluido + ' (' + print_price_currency((data.product.price_people / vat).toFixed(2), currency_str) + ' ' + iva_no_incluido + ')'); } else { $('.product-price-total').text(total + ': ' + print_price_currency((data.product.price_people / 100).toFixed(2), currency_str)); } } } else { $('.product-price').text(''); $('.product-price-total').text(''); } $('.product-name').text(product_name); $('.product-description').html(product_description); } else { $('#price_product_special').hide(); } }, "json"); } function change_people_product() { var product_select = $('#extra-box-select-product').val(); var date = $('#datepicker').val(); var people = $('#people-box-select').val(); if (people == undefined || people == null) { people = 1; } var selection = $('#extra-box-select-product').val(); stop_validation = true; $.post(core_url + '/reservation/change_people_product', { language: language, restaurant: restaurant, date: date, product_select: product_select, selection: selection, people: people }, function (data) { $('#hour_box').html(data.hour_box_product); $('#hour-box-select').change(function () { change_hour_product(); }); $('#personas_box').show(); $('#hour_box').show(); change_hour_product(); product_name = data.product.product_name + ', ' || ''; product_description = data.product.product_description || ''; // Actualizar vat var vat = 100 + parseFloat(data.product.product_vat); // grupos var people = $('#people-box-select').val(); if (data.product.product == 3) { $('#price_product_special').show(); if (data.product.price_people != 0) { if (data.product.product_groups == 0) { $('.forpeople').show(); if (restaurant == 'a-cuatro-manos') { $('.product-price').text(print_price_currency((data.product.price_people / 100).toFixed(2), currency_str) + per_person + ' ' + iva_incluido); } else { if (vat != 100) { $('.product-price').text(print_price_currency((data.product.price_people / 100).toFixed(2), currency_str) + per_person + ' ' + iva_incluido); } else { $('.product-price').text(print_price_currency((data.product.price_people / 100).toFixed(2), currency_str) + per_person); } } $('#people-box-select').val(people); $('.info_header2').show(); if (vat != 100) { $('.product-price-total').text(total + ': ' + print_price_currency((data.product.price_people / 100 * people).toFixed(2), currency_str) + ' ' + iva_incluido + ' (' + print_price_currency((data.product.price_people / vat * 1).toFixed(2), currency_str) + ' ' + iva_no_incluido + ')'); } else { $('.product-price-total').text(total + ': ' + print_price_currency((data.product.price_people / 100 * people).toFixed(2), currency_str)); } } else { $('.forpeople').hide(); if (vat != 100) { $('.product-price').text(print_price_currency((data.product.price_people / 100).toFixed(2), currency_str) + ' ' + iva_incluido); } else { $('.product-price').text(print_price_currency((data.product.price_people / 100).toFixed(2), currency_str)); } $('.info_header2').show(); if (vat != 100) { $('.product-price-total').text(total + ': ' + print_price_currency((data.product.price_people / 100).toFixed(2), currency_str) + ' ' + iva_incluido + ' (' + print_price_currency((data.product.price_people / vat).toFixed(2), currency_str) + ' ' + iva_no_incluido + ')'); } else { $('.product-price-total').text(total + ': ' + print_price_currency((data.product.price_people / 100).toFixed(2), currency_str)); } } } else { $('.product-price').text(''); $('.product-price-total').text(''); } $('.product-name').text(product_name); $('.product-description').html(product_description); } else { $('#price_product_special').hide(); } }, "json"); } function change_hour_product() { var product_select = $('#extra-box-select-product').val(); var date = $('#datepicker').val(); var people = $('#people-box-select').val(); var hour = $('#hour-box-select').val(); var selection = $('#extra-box-select-product').val(); $.post(core_url + '/reservation/change_hour_product', { language: language, restaurant: restaurant, date: date, product_select: product_select, selection: selection, people: people, hour: hour }, function (data) { $('#hour_box').html(data.hour_box_product); $('#hour-box-select').change(function () { change_hour_product(); }); $('#hour_box').show(); if (data.message_rule != false && data.message_rule != '') { $('.extra_message').html(data.message_rule); $('#extra_message_container').show(); } else { if (data.message_rule == '') { $('.extra_message').html(''); } else { $('#extra_message_container').hide(); } } if (data.extra_box != false) { $('#extra_box').html(data.extra_box); $('#extra-box-select').change(function () { change_extra_zone_product(); }); $('#extra_box').show(); change_extra_zone_product(); } else { if (hour !== $('#hour-box-select').val()) { //BlueBarFacts change_hour_product(); } stop_validation = false; } }, "json"); } function change_extra_zone_product() { var product_select = $('#extra-box-select-product').val(); var date = $('#datepicker').val(); var people = $('#people-box-select').val(); var hour = $('#hour-box-select').val(); var selection = $('#extra-box-select-product').val(); var zone = $('#extra-box-select').val(); $.post(core_url + '/reservation/change_extra_zone_product', { language: language, restaurant: restaurant, date: date, product_select: product_select, selection: selection, people: people, hour: hour, zone: zone }, function (data) { $('#hour_box').html(data.hour_box_product); $('#hour-box-select').change(function () { change_hour_product(); }); if (data.message_rule != false && data.message_rule != '') { $('.extra_message').html(data.message_rule); $('#extra_message_container').show(); } stop_validation = false; }, "json"); } function transform_timecover(time, prefix_null = false) { if (time == undefined || time == null || time == 1 || time == 2 || time == 3) { if (time == 1) { return comida_text; } if (time == 2) { return cena_text; } if (time == 3) { return comida_cena_text; } return time; } var horanow = time; horanow = horanow.split(":"); var prefix_format_hour = prefix_null ? '' : hourAbbreviation; if (typeof horanow[1] != 'undefined' && horanow[1].includes('pm')) { prefix_format_hour = ' pm'; } else if (typeof horanow[1] != 'undefined' && horanow[1].includes('am')) { prefix_format_hour = ' am'; } var hh1 = parseInt(horanow[0], 10); var mm1 = parseInt(horanow[1], 10); mm1 = String(mm1); if (mm1.length < 2) { var addchar = (2 - mm1.length); for (let i = 0; i < addchar; i++) { mm1 = "0" + mm1; } } if (mm1.length > 2) { mm1 = mm1.substr(0, 2); } if (hh1 > 23) { hh1 = (hh1 - 24); hh1 = String(hh1) if (hh1.length < 2) { addchar = (2 - hh1.length); for (let i = 0; i < addchar; i++) { hh1 = "0" + hh1; } } if (hh1.length > 2) { hh1 = hh1.substr(0, 2); } } return hour_format == 1 && prefix_format_hour == ' h' ? changeHourFormat(hh1 + ":" + mm1) : hh1 + ":" + mm1 + prefix_format_hour; } function sumaFecha(hours, d, fecha) { if (hours == undefined || hours == null) { return fecha; } var horanow = hours; horanow = horanow.split(":"); var hh1 = parseInt(horanow[0], 10); if (hh1 > 23) { var Fecha = new Date(); var sFecha = fecha || (Fecha.getDate() + "/" + (Fecha.getMonth() + 1) + "/" + Fecha.getFullYear()); var sep = sFecha.indexOf('/') != -1 ? '/' : '-'; var aFecha = sFecha.split(sep); var fecha = aFecha[2] + '/' + aFecha[1] + '/' + aFecha[0]; fecha = new Date(fecha); fecha.setDate(fecha.getDate() + parseInt(d)); var anno = fecha.getFullYear(); var mes = fecha.getMonth() + 1; var dia = fecha.getDate(); mes = (mes < 10) ? ("0" + mes) : mes; dia = (dia < 10) ? ("0" + dia) : dia; var fechaFinal = '(' + aFecha[0] + '->' + dia + ')' + sep + mes + sep + anno; return (fechaFinal); } else { return fecha; } } //Muestra la parte de datos personales (Pantalla 2) function datos_personales() { const urlParams = new URLSearchParams(window.location.search); const source = urlParams.get('source'); preciopagado = 0; if ($('#people-box-select').val() == '') { alert(t352p); stop_validation = true; } if (!stop_validation && !update_people_peticion) { if ($('#extra-box-select-product').val() == -1) { alert(select_product); return; } if (hour_motor_conf) { var hours = $('#timepicker_motor').val(); hours = get_cover_hour(hours); var hours_show = hours; } else { var hours = $('#hour-box-select').val(); var hours_show = $('#hour-box-select :selected').text(); } date = $('#datepicker').val(); people = $('#people-box-select').val(); $('input[name="reserveType"]').change(function(){ reserveType = $('input[name="reserveType"]:checked').val(); // 1 => personal reserve | 2 => hotel/concierge/agencia reserve if (reserveType == 1) { $('.reserve-normal').removeClass('hide'); $('#info_prescriber').addClass('hide'); $('.prescriber-client-info').addClass('hide'); } if (reserveType == 2) { $('.reserve-normal').addClass('hide'); $('#user_email').val(''); $('#user_phone').val(''); $('#info_prescriber').removeClass('hide'); $('.prescriber-client-info').removeClass('hide'); } }); if (shopping_cart == 1) { var index; var num_comensales_aux = 0; for (index = 0; index < infoproducts.length; index++) { if (infoproducts[index].product_groups == 0) { num_comensales_aux = num_comensales_aux + numberproducts[index]; } } //no hay productos para elegir en forma de menu, pero al menos tiene que haber seleccionado uno if (!therearemenus) { if (productextras.length > 0) { therearemenus = true; num_comensales_aux = people; } else { if (!thereareproducts) { noproductsnomenus = true; therearemenus = true; num_comensales_aux = people; } } } if (therearemenus || !thereareproducts || $('#extra-box-select-product').val() == undefined) { if (num_comensales_aux == parseInt(people) || $('#extra-box-select-product').val() == undefined) { if ($('#extra-box-select').length != 0) { // obligación de elejir // TODO igual para el eslector der producto extra if ($('#extra-box-select').val() == undefined) { alert(select_table_type); return; } } $('#login_box').show(); $('#info-box').show(); if ($('#extra-box-select').length) { if (selected != '') { extra = selected; } if (selected != '') { extra = selected; } else { extra = $('#extra-box-select').val(); } if (extra == -1 || extra == undefined) { extra_string = ''; } else { extra_string = text5 + $('#extra-box-select option:selected').text(); } } else { extra = '-1'; extra_string = ''; } if (productextras.length == 0) { if (!noproductsnomenus) { extra = -1; } } else { extra = productextras; } $('.selectpicker').selectpicker(); var textPeople = people > 1 ? text4 : text4s; jQuery('.info_perview').text(sumaFecha(hours, 1, date) + ' | ' + transform_timecover(hours_show) + ' | ' + people + ' ' + textPeople + extra_string); // TAG MANAGER date_tag = date; people_tag = people; hour_tag = hours; extra_avaible_reserv_module = extra; // Disable web components (datepicker, hour and people) $('#datepicker').datepicker('disable'); $('#people-box-select').prop("disabled", true); $('#hour-box-select').prop("disabled", true); $('#extra-box-select').prop("disabled", true); $('#extra-box-select-product').prop("disabled", true); validateRecaptcha(function(recaptchaToken) { jQuery.post(core_url + '/reservs/avaible_reserv_module/' + getVipReservationValue(), { recaptchaToken: recaptchaToken, language: language, restaurant: restaurant, hour: hours, date: date, people: people, extra: extra, skip_blocked_tables : skipBlockedTables, source: source, utm_emailmarketing: utm_emailmarketing || false, }, function (data) { // Disable web components (datepicker, hour and people) $('#datepicker').datepicker('enable'); $('#people-box-select').prop("disabled", false); $('#hour-box-select').prop("disabled", false); $('#extra-box-select').prop("disabled", false); $('#extra-box-select-product').prop("disabled", false); if (data.resp == 1) { if (not_first_step == '1') { $('#loading_up').hide(); } if ( (data.product != undefined && parseInt(data.product.card) == 1 && parseInt(data.product.amount_total) != 0) || (data.product != undefined && parseInt(data.product.card) == 1 && data.product.product == 2) || (data.product != undefined && parseInt(data.product.card) == 1 && data.product.product == 5) ) { isNecessaryCard = true; $("#invoice_data_div").show(); } else { isNecessaryCard = false; $("#invoice_data_div").hide(); } if (type_landing == '2' || type_landing == '3') { jQuery('#select_type_client').show(); jQuery('#datos_reserva').hide(); jQuery('#waiting-box').hide(); jQuery('#group-request-box').hide(); } else { // Systema Reconocimiento Cliente Email if (data.system_email_motor == 1) { $('#button_search_email').removeAttr('disabled'); $('#edit_data_system').prop('disabled', !!skipBlockedTables); $('#search_email_client').val(skipBlockedTables && memberEmail ? memberEmail : ''); jQuery('#system_email_motor').show(); jQuery('#datos_reserva').hide(); jQuery('#waiting-box').hide(); jQuery('#group-request-box').hide(); $('#search_email_client').bind('keypress', function (e) { // Number 13 is the "Enter" key on the keyboard if (e.keyCode === 13) { $('#button_search_email').click(); } }); } else { $('#edit_data_system').prop('disabled', !!skipBlockedTables); jQuery('#datos_personales').show(); jQuery('#reg_button').show(); jQuery('.condiciones').show(); jQuery('#datos_reserva').hide(); jQuery('#waiting-box').hide(); jQuery('#group-request-box').hide(); } } if (name_pre != '') { $('#user_email').val(email_pre); $('#user_first_name').val(name_pre); $('#user_last_name').val(lastname_pre); $('#user_phone').val(phone_pre); $('#commentary').val(commentary); $('#birthday').val(moment(birthday).format("YYYY-MM-DD")); $('#food_restrictions').val(allergens_text); if (allergens_yes == 'true') { $('#food_restriction_block').css("display", "block"); $('#has_food_restrictions').attr("checked", true); } if (allergens_no == 'true') { $('#food_restriction_block').css("display", "none"); $('#no_food_restrictions').attr("checked", true); } if (intcallcode_pre != '') { $('#int_call_code').val(intcallcode_pre); } } // cambiamos el texto del botón $('#reg_button > button').html(data.txt); //Llamar a la Api para bloquear la mesa if (data.timeout_reserv > 0) { timeout_reserv = parseInt(data.timeout_reserv); id_reserv = data.id_reserv; if (time_end_reserv_motor == '1') { if (pay_type_use != '8') { $('#alert_time').show(); if (!countdown_started) { count_down(); } } } if (pay_type_use != '8') { timeout = setTimeout(function () { alert(expired_reservation_time_comp); $('#container_module_reserv').hide(); $('body div:first').css({ "display": "none" }); $('#finish_reserv_time_out').show(); //location.reload(true); }, data.timeout_reserv * 1000); } } if (data.product != undefined && data.product.product == 3) { if (data.product.product_groups === '1') { preciopagado = data.product.price_people / 100; } else { preciopagado = data.product.price_people * people_tag / 100; } product_group = data.product.product_groups; } if (data.product != undefined) { product_tag = data.product.product; } else { product_tag = 1; } checkBillingInfoRequired = check_billing_info_required(preciopagado); if (checkBillingInfoRequired === true) { $('#invoice_data_div').hide(); var labels = document.getElementsByTagName('label'); for (var i = 0; i < labels.length; i++) { var labelText = labels[i].textContent; if (labelText.includes('(*)')) { labels[i].textContent = labelText.replace('(*)', ''); } } } } else { //en caso de que tenga activada la opcion de mostrar todas las horas //no haya disnopibilidad y hay que mostrar opciones en ese mismo // restaurantes y en otros restaurantes del grupo if (data.notreservable == true) { if (data.notreservable_type == 4) { alert(data.error_text); } else { jQuery('#datos_reserva').hide(); jQuery('#waiting-box').hide(); jQuery('#group-request-box').hide(); jQuery('.loadingserchnobottom').show(); if (data.notreservable_type == 1) { jQuery.post(core_url + '/reservation/search_restaurant_groups_nobottom', { language: language, restaurant: restaurant, hour: hours, date: date, people: people }, function (data) { $('#searchwithoutbottom').html(data.html_search); $('#searchwithoutbottom').show(); jQuery('.loadingserchnobottom').hide(); }, "json"); } if (data.notreservable_type == 2) { jQuery.post(core_url + '/reservation/waiting_list_nobottom', { language: language, restaurant: restaurant, hour: hours, date: date, people: people }, function (data) { $('#searchwithoutbottom').html(data.html_search); if (waitingListShowLuner == 1) { $('#waiting_button_list').show(); } else { $('#waiting_button_list').hide(); } $('#searchwithoutbottom').show(); jQuery('.loadingserchnobottom').hide(); }, "json"); } if (data.notreservable_type == 3) { var text1 = ''; jQuery.post(core_url + '/reservation/search_restaurant_groups_nobottom', { language: language, restaurant: restaurant, hour: hours, date: date, people: people }, function (data) { text1 = data.html_search; jQuery.post(core_url + '/reservation/waiting_list_nobottom', { language: language, restaurant: restaurant, hour: hours, date: date, people: people }, function (data2) { $('#searchwithoutbottom').html(text1 + data2.html_search); if (waitingListShowLuner == 1) { $('#waiting_button_list').show(); } else { $('#waiting_button_list').hide(); } $('#searchwithoutbottom').show(); jQuery('.loadingserchnobottom').hide(); $('.cross-type3').hide(); }, "json"); }, "json"); } } } else { alert(data.error_text); } } }, "json"); }); } else { //$('#botonsumarproduct').popover('show'); alert(menu_igual_comensal); } } else { alert(product_almenos); } } else { if (motor_first_product == 0) { if ($('#extra-box-select').length != 0) { // obligación de elejir // TODO igual para el eslector der producto extra if ($('#extra-box-select').val() == undefined) { alert(select_table_type); return; } } $('#login_box').show(); $('#info-box').show(); //selecciona producto var selection = $('#extra-box-select-product').val(); var extra = $('#extra-box-select').val(); if (selection != undefined) { $("#extra-box-select option[value='" + extra + "']").val(selection); } //fin seleccion de producto if ($('#extra-box-select').length) { if (selected != '') { extra = selected; } else { extra = $('#extra-box-select').val(); } if (extra == -1 || extra == undefined) { extra_string = ''; } else { extra_string = text5 + $('#extra-box-select option:selected').text(); } } else { extra = '-1'; extra_string = ''; if (selected != undefined && selected != '') { extra = $('#extra-box-select-product').val(); if (extra == null) { extra = selected; } } } extra_pos = JSON.parse(extra); if (extra_pos["3"] == '') { extra_pos = -1; } } else { $('#login_box').show(); $('#info-box').show(); var selection = $('#extra-box-select-product').val(); var extra = $('#extra-box-select').val(); if (extra == undefined) { extra_string = ''; var array = { "1": 'x', "2": -1, "3": selection }; extra = JSON.stringify(array); } else { extra_string = text5 + $('#extra-box-select option:selected').text(); extra = JSON.parse(extra); extra["3"] = selection; extra = JSON.stringify(extra); } } $('.selectpicker').selectpicker(); var textPeople = people > 1 ? text4 : text4s; jQuery('.info_perview').text(sumaFecha(hours, 1, date) + ' | ' + transform_timecover(hours_show) + ' | ' + people + ' ' + textPeople + extra_string); // TAG MANAGER date_tag = date; people_tag = people; hour_tag = hours; extra_avaible_reserv_module = extra; // Disable web components (datepicker, hour and people) $('#datepicker').datepicker('disable'); $('#people-box-select').prop("disabled", true); $('#hour-box-select').prop("disabled", true); $('#extra-box-select').prop("disabled", true); $('#extra-box-select-product').prop("disabled", true); validateRecaptcha(function(recaptchaToken) { jQuery.post(core_url + '/reservs/avaible_reserv_module/' + getVipReservationValue(), { recaptchaToken: recaptchaToken, language: language, restaurant: restaurant, hour: hours, date: date, people: people, extra: extra, skip_blocked_tables : skipBlockedTables, source: source, utm_emailmarketing: utm_emailmarketing || false, }, function (data) { // Disable web components (datepicker, hour and people) $('#datepicker').datepicker('enable'); $('#people-box-select').prop("disabled", false); $('#hour-box-select').prop("disabled", false); $('#extra-box-select').prop("disabled", false); $('#extra-box-select-product').prop("disabled", false); if (data.resp == 1) { if (not_first_step == '1') { $('#loading_up').hide(); } if ( (data.product != undefined && parseInt(data.product.card) == 1 && parseInt(data.product.amount_total) != 0) || (data.product != undefined && parseInt(data.product.card) == 1 && data.product.product == 2) || (data.product != undefined && parseInt(data.product.card) == 1 && data.product.product == 5) ) { isNecessaryCard = true; $("#invoice_data_div").show(); } else { isNecessaryCard = false; $("#invoice_data_div").hide(); } if (type_landing == '2' || type_landing == '3') { jQuery('#select_type_client').show(); jQuery('#datos_reserva').hide(); jQuery('#waiting-box').hide(); jQuery('#group-request-box').hide(); } else { // Systema Reconocimiento Cliente Email if (data.system_email_motor == 1) { $('#button_search_email').removeAttr('disabled'); $('#edit_data_system').prop('disabled', !!skipBlockedTables); $('#search_email_client').val(skipBlockedTables && memberEmail ? memberEmail : ''); jQuery('#system_email_motor').show(); jQuery('#datos_reserva').hide(); jQuery('#waiting-box').hide(); jQuery('#group-request-box').hide(); $('#search_email_client').bind('keypress', function (e) { // Number 13 is the "Enter" key on the keyboard if (e.keyCode === 13) { $('#button_search_email').click(); } }); } else { $('#edit_data_system').prop('disabled', !!skipBlockedTables); jQuery('#datos_personales').show(); jQuery('#reg_button').show(); jQuery('.condiciones').show(); jQuery('#datos_reserva').hide(); jQuery('#waiting-box').hide(); jQuery('#group-request-box').hide(); } } if (name_pre != '') { $('#user_email').val(email_pre); $('#user_first_name').val(name_pre); $('#user_last_name').val(lastname_pre); $('#user_phone').val(phone_pre); $('#commentary').val(commentary); $('#birthday').val(moment(birthday).format("YYYY-MM-DD")); $('#food_restrictions').val(allergens_text); if (allergens_yes == 'true') { $('#food_restriction_block').css("display", "block"); $('#has_food_restrictions').attr("checked", true); } if (allergens_no == 'true') { $('#food_restriction_block').css("display", "none"); $('#no_food_restrictions').attr("checked", true); } if (intcallcode_pre != '') { $('#int_call_code').val(intcallcode_pre); } } // cambiamos el texto del botón $('#reg_button > button').html(data.txt); //Llamar a la Api para bloquear la mesa if (data.timeout_reserv > 0) { timeout_reserv = parseInt(data.timeout_reserv); id_reserv = data.id_reserv; if (time_end_reserv_motor == '1') { if (pay_type_use != '8') { $('#alert_time').show(); var dt = new Date(); dt.setSeconds(dt.getSeconds() + timeout_reserv); if (!countdown_started) { count_down(); } } } if (pay_type_use != '8') { timeout = setTimeout(function () { alert(expired_reservation_time_comp); $('#container_module_reserv').hide(); $('body div:first').css({ "display": "none" }); $('#finish_reserv_time_out').show(); //location.reload(true); }, data.timeout_reserv * 1000); } } if (data.product != undefined && data.product.product == 3) { if (data.product.product_groups === '1') { preciopagado = data.product.price_people / 100; } else { preciopagado = data.product.price_people * people_tag / 100; } product_group = data.product.product_groups; } if (data.product != undefined) { product_tag = data.product.product; } else { product_tag = 1; } checkBillingInfoRequired = check_billing_info_required(preciopagado); if (checkBillingInfoRequired === true) { $('#invoice_data_div').hide(); var labels = document.getElementsByTagName('label'); for (var i = 0; i < labels.length; i++) { var labelText = labels[i].textContent; if (labelText.includes('(*)')) { labels[i].textContent = labelText.replace('(*)', ''); } } } } else { //en caso de que tenga activada la opcion de mostrar todas las horas //no haya disnopibilidad y hay que mostrar opciones en ese mismo // restaurantes y en otros restaurantes del grupo if (data.notreservable == true) { if (data.notreservable_type == 4) { alert(data.error_text); } else { jQuery('#datos_reserva').hide(); jQuery('#waiting-box').hide(); jQuery('#group-request-box').hide(); jQuery('.loadingserchnobottom').show(); if (data.notreservable_type == 1) { jQuery.post(core_url + '/reservation/search_restaurant_groups_nobottom', { language: language, restaurant: restaurant, hour: hours, date: date, people: people }, function (data) { $('#searchwithoutbottom').html(data.html_search); $('#searchwithoutbottom').show(); jQuery('.loadingserchnobottom').hide(); }, "json"); } if (data.notreservable_type == 2) { jQuery.post(core_url + '/reservation/waiting_list_nobottom', { language: language, restaurant: restaurant, hour: hours, date: date, people: people }, function (data) { $('#searchwithoutbottom').html(data.html_search); if (waitingListShowLuner == 1) { $('#waiting_button_list').show(); } else { $('#waiting_button_list').hide(); } $('#searchwithoutbottom').show(); jQuery('.loadingserchnobottom').hide(); }, "json"); } if (data.notreservable_type == 3) { var text1 = ''; jQuery.post(core_url + '/reservation/search_restaurant_groups_nobottom', { language: language, restaurant: restaurant, hour: hours, date: date, people: people }, function (data) { text1 = data.html_search; jQuery.post(core_url + '/reservation/waiting_list_nobottom', { language: language, restaurant: restaurant, hour: hours, date: date, people: people }, function (data2) { $('#searchwithoutbottom').html(text1 + data2.html_search); if (waitingListShowLuner == 1) { $('#waiting_button_list').show(); } else { $('#waiting_button_list').hide(); } $('#searchwithoutbottom').show(); jQuery('.loadingserchnobottom').hide(); $('.cross-type3').hide(); }, "json"); }, "json"); } } } else { alert(data.error_text); } } }, "json"); }); } } $("html,body").scrollTop(0); //$('html, body', window.parent.document).animate({scrollTop:0}, 'slow'); } function crosseling_future() { var loading = '
Loading...
'; $('#resp_future_table').html(loading); if (hour_motor_conf) { var hours = $('#timepicker_motor').val(); hours = get_cover_hour(hours); } else { var hours = $('#hour-box-select').val(); } date = $('#datepicker').val(); people = $('#people-box-select').val(); jQuery.post(core_url + '/reservation/searchRestaurantCrosselingFuture', { language: language, restaurant: restaurant, hour: hours, date: date, people: people }, function (data) { $('#resp_future_table').html(data.html_search); $('#btn_cross_future').addClass('hidden'); }, "json"); } function crosseling_future_close() { $('#resp_future_table').addClass('hidden'); $('#btn_cross_future_view').removeClass('hidden'); } function crosseling_future_open() { $('#resp_future_table').removeClass('hidden'); $('#btn_cross_future_view').addClass('hidden'); } function crosseling_others() { var loading = '
Loading...
'; $('#resp_others_table').html(loading); if (hour_motor_conf) { var hours = $('#timepicker_motor').val(); hours = get_cover_hour(hours); } else { var hours = $('#hour-box-select').val(); } date = $('#datepicker').val(); people = $('#people-box-select').val(); jQuery.post(core_url + '/reservation/searchRestaurantCrosselingOthers', { language: language, restaurant: restaurant, hour: hours, date: date, people: people }, function (data) { $('#resp_others_table').html(data.html_search); $('#btn_cross_otrher').addClass('hidden'); }, "json"); } function crosseling_others_close() { $('#resp_others_table').addClass('hidden'); $('#btn_cross_otrher_view').removeClass('hidden'); } function crosseling_others_open() { $('#resp_others_table').removeClass('hidden'); $('#btn_cross_otrher_view').addClass('hidden'); } function search_email_client() { $('#button_search_email').attr("disabled", "disabled"); var email_search = $('#search_email_client').val().trim(); var emailValid = validateEmail(email_search); $('#user_first_name').val(''); $('#user_last_name').val(''); $('#user_phone').val(''); $('#postal_code').val(''); $('#country_select').val(''); $('#user_email2').val(''); $("#have").show(); if (emailValid) { $.post(core_url + '/reservation/search_email_client', { language: language, restaurant: restaurant, email: email_search }, function (data) { if (data.client_found) { client_email_system = data.client; ectd_client = true; $('#button_search_email').removeAttr('disabled'); $('#name_accort_user').html(data.client.name_abbr) $('#email_user').html(data.client.email) $('#phone_user').html(tel_phone + ' ' + data.client.phone_abbr) $('#first_step_system').hide(); $('#second_step_system').show(); if (show_extra_field && data.client.extra_field_abbr != undefined && data.client.extra_field_abbr != '') { $('#extra_field').html(data.client.extra_field_abbr) $('#extra_field').show(); } if(data.client.is_same_restaurant) { $(".data_treatment").hide(); $("#data_treatment_consent_email").prop("disabled", true); if (data.client.legal_data_treatment_consent == 1) { $("#data_treatment_consent_email").prop("checked", true); } else { $("#data_treatment_consent_email").prop("checked", false); } } else { $(".data_treatment").show(); $("#data_treatment_consent_email").prop("disabled", false); $("#data_treatment_consent_email").prop("checked", false); } } else { $('#user_email').val(email_search); jQuery('#datos_personales').show(); jQuery('#reg_button').show(); jQuery('.condiciones').show(); jQuery('#datos_reserva').hide(); jQuery('#system_email_motor').hide(); jQuery('#waiting-box').hide(); jQuery('#group-request-box').hide(); $(".data_treatment").show(); $("#data_treatment_consent_email").prop("disabled", false); $("#data_treatment_consent_email").prop("checked", false); } }, "json"); } else { $('#button_search_email').removeAttr('disabled'); alert(text12); } } function edit_data_system() { if (typeof skipBlockedTables !== 'undefined' && skipBlockedTables) { return false; } ectd_client = false; $('#int_call_code').val(call_code); $('#country_select').val('ES'); var email_search = $('#search_email_client').val().trim(); $('#user_email').val(email_search); $('#second_step_system').hide(); $('#search_email_client').val(''); $('#user_first_name').val(''); $('#user_last_name').val(''); $('#user_phone').val(''); $('#comment_text').val(''); $('#first_step_system').show(); $('.header_ticket_es').css('display', 'none'); $('.header_ticket_es_second').css('display', 'none'); jQuery('#datos_personales').show(); jQuery('#reg_button').show(); jQuery('.condiciones').show(); jQuery('#datos_reserva').hide(); jQuery('#system_email_motor').hide(); jQuery('#waiting-box').hide(); jQuery('#group-request-box').hide(); } function back_init_email() { jQuery('#system_email_motor').hide(); jQuery('#datos_reserva').show(); jQuery('#waiting-box').show(); jQuery('#group-request-box').show(); } function back_first_step() { $('#button_search_email').removeAttr('disabled'); jQuery('#second_step_system').hide(); jQuery('#first_step_system').show(); } function validate_system() { $('#finish_reserv_system').attr('disabled', 'disabled'); var allergens = false; $('#user_email').val(client_email_system.email); if (security_email_motor == "1") { $('#user_email2').val(client_email_system.email); } $('#user_first_name').val(client_email_system.first_name); $('#user_last_name').val(client_email_system.last_name); $('#user_phone').val(client_email_system.phone); if (security_phone_motor == "1") { $('#user_phone2').val(client_email_system.phone); } $('#int_call_code').val(client_email_system.int_call_code); $('#postal_code').val(client_email_system.postalcode); $('#country_select').val(client_email_system.country); ectd_client_int_call_code = client_email_system.int_call_code; ectd_client_country = client_email_system.country; if (show_extra_field && client_email_system.extra_field_abbr != undefined && client_email_system.extra_field_abbr != '') { $('#extra_field_client').val(client_email_system.extra_field_client); } if ($("#consentimiento_legal_email").is(":visible") && $('#consentimiento_legal_email').is(':checked') === true) { document.getElementById("consentimiento_legal").checked = true; } if ($('#subscribe_newsletter_email').is(':checked') === true) { document.getElementById("subscribe_newsletter").checked = true; } if ($('#data_treatment_consent_email').is(':checked') === true) { document.getElementById("data_treatment_consent").checked = true; } $('#no_food_restrictions').prop('checked', true); validate(); } function especial_datos_personales() { jQuery('#select_type_client').hide(); if (name_pre != '') { $('#user_email').val(email_pre); $('#user_first_name').val(name_pre); $('#user_last_name').val(lastname_pre); $('#user_phone').val(phone_pre); $('#commentary').val(commentary); $('#birthday').val(moment(birthday).format("YYYY-MM-DD")); $('#food_restrictions').val(allergens_text); if (allergens_yes == 'true') { $('#food_restriction_block').css("display", "block"); $('#has_food_restrictions').attr("checked", true); } if (allergens_no == 'true') { $('#food_restriction_block').css("display", "none"); $('#no_food_restrictions').attr("checked", true); } if (intcallcode_pre != '') { $('#int_call_code').val(intcallcode_pre); } } jQuery('#datos_personales').show(); jQuery('#reg_button').show(); jQuery('.condiciones').show(); if (type_landing == 2) { origin = company; jQuery('#info_especial').hide(); } if (type_landing == 3) { jQuery('.email-box').hide(); } jQuery('#datos_reserva').hide(); jQuery('#waiting-box').hide(); jQuery('#group-request-box').hide(); } function normal_datos_personales() { type_landing = 1; origin = company; jQuery('#select_type_client').hide(); if (name_pre != '') { $('#user_email').val(email_pre); $('#user_first_name').val(name_pre); $('#user_last_name').val(lastname_pre); $('#user_phone').val(phone_pre); $('#commentary').val(commentary); $('#birthday').val(moment(birthday).format("YYYY-MM-DD")); $('#food_restrictions').val(allergens_text); if (allergens_yes == 'true') { $('#food_restriction_block').css("display", "block"); $('#has_food_restrictions').attr("checked", true); } if (allergens_no == 'true') { $('#food_restriction_block').css("display", "none"); $('#no_food_restrictions').attr("checked", true); } if (intcallcode_pre != '') { $('#int_call_code').val(intcallcode_pre); } } jQuery('#datos_personales').show(); jQuery('#reg_button').show(); jQuery('.condiciones').show(); jQuery('#info_especial').show(); jQuery('#datos_reserva').hide(); jQuery('#waiting-box').hide(); jQuery('#group-request-box').hide(); } function reset_load_data(path) { location.href = path + '?name=' + $('#user_first_name').val() + '&lastname=' + $('#user_last_name').val() + '&email=' + $('#user_email').val() + '&birthday=' + $('#birthday').val() + '&intcallcode=' + $('#int_call_code').val() + '&phone=' + $('#user_phone').val() + '&commentary=' + $('#commentary').val() + '&allergens_yes=' + $('#has_food_restrictions').is(":checked") + '&allergens_no=' + $('#no_food_restrictions').is(":checked") + '&allergens_text=' + escape($('#food_restrictions').val()); } //Cierra la parte de datos personales (Pantalla 1) function inicio() { var ok = true; if (id_reserv != null) { if (time_end_reserv_motor == '1') { clearTimeout(llamada); first_time_time_reserv = true; $('#alert_time').hide(); } if (confirm(lose_table)) { ok = true; jQuery.post(core_url + '/reservs/free_reserv', { restaurant: restaurant, id_reserv: id_reserv }, function (data) { // se cancela si se dan las conficiones necesarias; }, "json"); } else { ok = false; } } if (redeem) { redeem = false; code = ''; $('#have').css('display', 'block'); $('#btn-validate_ticket').removeAttr('disabled'); $('#ticket').val(""); $('#ticket').css('display', 'none'); $('#btn-validate_ticket').css('display', 'none'); $('#code').html(''); } if (ok) { $("#have").show(); $('#ticket').css('display', 'none'); $('#btn-validate_ticket').css('display', 'none'); $('.condiciones').show(); $('#reg_button').show(); $('#datos_reserva').show(); $('#waiting-box').show(); $('#group-request-box').show(); $('#datos_personales').hide(); $('#searchwithoutbottom').hide(); $('#addCommentary').removeClass('commentary_waiting'); $('#extra_list').hide(); $('#extra_list_group_request').hide(); $('#end_box').hide(); if (motor_first_product == 0) { update_hour_people(); } else { update_date_product(); } } } //Cierra la parte de pago function closePayBox() { $('#pay-box').hide(); //$('#datos_reserva').show(); $('#login_box').show(); $('#info-box').show(); jQuery('#datos_personales').show(); jQuery('#reg_button').show(); jQuery('.condiciones').show(); $('#button_search_email').removeAttr('disabled'); jQuery('#second_step_system').hide(); jQuery('#first_step_system').show(); $('#finish_reserv_system').removeAttr('disabled'); $('#loading_system_email').hide(); } //Cierra la parte de pago desde solicitud de grupo function closePayBoxGroupRequest() { $('#pay-box-group_request').hide(); $('#login_box').show(); $('#info-box').show(); } function search_othergroup_show() { $('#select_search').show(); $('#button_search').show(); $('#goback_search').show(); $('#people_search_group').show(); $('#personas_box').hide(); $('#hour_box').hide(); $('#search_othergroup').hide(); $('#waiting_button_list').hide(); $('#reservar_button').hide(); $('#people_search').val($('#people-box-select').val()); $('#extra_box').hide(); $('.extra_message').hide(); show_waiting_search = true; } function search_othergroup() { date = $('#datepicker').val(); people = $('#people_search').val(); luner = $('#search_luner').val(); $('#table_search').hide(); $('#loadingsearch').show(); $.post(core_url + '/reservation/search_restaurant_groups', { language: language, restaurant: restaurant, people: people, luner: luner, date: date }, function (data) { $('#loadingsearch').hide(); $('#table_search').html(data.html_search); $('#table_search').show(); }, "json"); } function goback_reserv() { $('#select_search').hide(); $('#button_search').hide(); $('#table_search').hide(); $('#goback_search').hide(); $('#people_search_group').hide(); $('#personas_box').show(); $('#hour_box').show(); $('#search_othergroup').show(); $('#waiting_button_list').show(); $('#reservar_button').show(); $('#extra_box').show(); $('.extra_message').show(); show_waiting_search = false; } function addProduct() { var selection = $('#extra-box-select-product').val(); if (selection == null || selection == "-1") { alert(select_product); return; } var extra = $('#extra-box-select').val(); var numMenu = parseInt($('#numberproduct').val()); people = parseInt($('#people-box-select').val()); var productname = ""; if (shoppingproduct.length == 1) { if (shoppingproduct[0] == "No has seleccionado ningún producto.") { shoppingproduct = []; } } if (selection != undefined) { $("#extra-box-select option[value='" + extra + "']").val(selection); productname = $('#product-name2').text() + $('#product-price2').text() + " " + $('#product-price-total2').text(); } //fin seleccion de producto if ($('#extra-box-select').length) { if (selected != '' && selected != undefined) { extra = selected; productname = $('#product-name2').text() + $('#product-price2').text() + " " + $('#product-price-total2').text(); } else { extra = $('#extra-box-select').val(); productname = $('#product-name2').text() + $('#product-price2').text() + " " + $('#product-price-total2').text(); } if (extra == -1 || extra == undefined) { extra_string = ''; productname = $('#product-name2').text() + $('#product-price2').text() + " " + $('#product-price-total2').text(); } else { extra_string = text5 + $('#extra-box-select option:selected').text(); productname = $('#product-name2').text() + $('#product-price2').text() + " " + $('#product-price-total2').text(); } } else { extra = '-1'; extra_string = ''; if (selection != undefined) { extra = $('#extra-box-select-product').val(); } } var index; var num_comensales_aux = 0; for (index = 0; index < infoproducts.length; index++) { if (infoproducts[index].product_groups == 0) { num_comensales_aux = num_comensales_aux + numberproducts[index]; } }; if (infoproduct.product_groups == 0) { num_comensales_aux = num_comensales_aux + numMenu; } if (num_comensales_aux <= people) { if (productextras.indexOf(extra) >= 0) { var index = productextras.indexOf(extra); if (infoproduct.product_groups == 0) { productincart = productincart + numMenu; document.getElementById('productincart').innerHTML = productincart; var numberperson = numberproducts[index] + numMenu; var date = $('#datepicker').val(); if (hour_motor_conf) { var hour = $('#timepicker_motor').val(); hour = get_cover_hour(hour); } else { var hour = $('#hour-box-select').val(); } $.post(core_url + '/reservation/update_extra_message', { language: language, restaurant: restaurant, date: date, hour: hour, extra: extra, people: numberperson }, function (data) { $('.product-name').text(''); $('.product-description').text(''); var vat = 100 + parseFloat(data.product.product_vat); infoproducts[index] = data.product; numberproducts[index] = numberperson; if (vat != 100) { shoppingproduct[index] = data.product.product_name + ', ' + print_price_currency((data.product.price_people / vat).toFixed(2), currency_str) + per_person + iva_no_incluido + ' (' + data.product.amount_total_str + ' ' + iva_incluido + ')'; } else { shoppingproduct[index] = data.product.product_name + ', ' + print_price_currency((data.product.price_people / vat).toFixed(2), currency_str) + per_person; } prix_totalproducts = prix_totalproducts + prix_productselecttotal; prix_eachproduct[index] = prix_eachproduct[index] + prix_productselecttotal; updateCart(); }, "json"); } else { var numberperson = numberproducts[index] + numMenu; var date = $('#datepicker').val(); if (hour_motor_conf) { var hour = $('#timepicker_motor').val(); hour = get_cover_hour(hour); } else { var hour = $('#hour-box-select').val(); } productincart = productincart + numMenu; document.getElementById('productincart').innerHTML = productincart; $.post(core_url + '/reservation/update_extra_message', { language: language, restaurant: restaurant, date: date, hour: hour, extra: extra, people: numberperson }, function (data) { $('.product-name').text(''); $('.product-description').text(''); var vat = 100 + parseFloat(data.product.product_vat); if (vat != 100) { shoppingproduct[index] = data.product.product_name + ', ' + print_price_currency((data.product.price_people / vat).toFixed(2), currency_str) + per_unit + ' ' + iva_no_incluido + ' (' + print_price_currency(data.product.amount_total / 100 * numberperson, currency_str) + ' ' + iva_incluido + ')'; } else { shoppingproduct[index] = data.product.product_name + ', ' + print_price_currency((data.product.price_people / vat).toFixed(2), currency_str) + per_unit; } prix_totalproducts = prix_totalproducts + prix_productselecttotal * numMenu; prix_eachproduct[index] = prix_eachproduct[index] + prix_productselecttotal * numMenu; numberproducts[index] = numberperson; updateCart(); }, "json"); } } else { shoppingproduct.push(productname); if (infoproduct.product_groups == 0) { prix_totalproducts = prix_totalproducts + prix_productselecttotal; } else { prix_totalproducts = prix_totalproducts + prix_productselecttotal * numMenu; } if (infoproduct.product_groups == 0) { prix_eachproduct.push(prix_productselecttotal); } else { prix_eachproduct.push(prix_productselecttotal * numMenu); } productincart = productincart + numMenu; document.getElementById('productincart').innerHTML = productincart; productextras.push(extra); infoproducts.push(infoproduct); numberproducts.push(numMenu); updateCart(); } } else { alert(menu_mayor_comensal); } } function updateCart() { $.post(core_url + '/reservation/addproduct_shopping', { restaurant: restaurant, language: language, products: shoppingproduct, precio: prix_totalproducts, productosinfo: infoproducts, numberproduct: numberproducts }, function (data) { $('#products-cart').html(data.shopping); }, "json"); } // Toggles the visibility of the shopping cart function toggleShoppingCart() { if ($('#shopping-cart').css('display') === 'none') { $('#shopping-cart').css('display', 'table'); } else { $('#shopping-cart').css('display', 'none'); } } function seeshoppingCart_card() { var precio = prix_totalproducts; if (has_discount && new_price_discount_global !== '') { precio = new_price_discount_global; } $.post(core_url + '/reservation/addproduct_shopping_card', { restaurant: restaurant, language: language, products: shoppingproduct, precio: precio, productosinfo: infoproducts, numberproduct: numberproducts }, function (data) { $('#products-cart-global').html(data.shopping); $('#shopping-cart-global').toggle(); }, "json"); } function outshoppingcard_cart() { $('#shopping-cart-global').toggle(); } function outshoppingcard() { $('#datos_reserva').show(); $('#shopping-cart').hide(); } function deleteproduct(id) { productextras.splice(id, 1); prix_totalproducts = prix_totalproducts - prix_eachproduct[id]; prix_eachproduct.splice(id, 1); shoppingproduct.splice(id, 1); infoproducts.splice(id, 1); var aux_number = numberproducts[id]; productincart = productincart - aux_number; document.getElementById('productincart').innerHTML = productincart; numberproducts.splice(id, 1); $.post(core_url + '/reservation/addproduct_shopping', { restaurant: restaurant, language: language, products: shoppingproduct, precio: prix_totalproducts, productosinfo: infoproducts, numberproduct: numberproducts }, function (data) { $('#products-cart').html(data.shopping); }, "json"); } function sumproduct(index) { var infoproduct_aux = infoproducts[index]; var numMenu = parseInt($("#numberproduct" + index).val()); var num_comensales_aux = 0; people = parseInt($('#people-box-select').val()); for (var index1 = 0; index1 < infoproducts.length; index1++) { if (infoproducts[index1].product_groups == 0) { num_comensales_aux = num_comensales_aux + numberproducts[index1]; } } if (infoproduct_aux.product_groups == 0) { num_comensales_aux = num_comensales_aux + 1; } if (num_comensales_aux <= people) { productincart = productincart + 1; document.getElementById('productincart').innerHTML = productincart; document.getElementById('numberproduct' + index).value = numMenu + 1; if (infoproduct_aux.product_groups == 0) { var numberperson = numberproducts[index] + 1; var date = $('#datepicker').val(); if (hour_motor_conf) { var hour = $('#timepicker_motor').val(); hour = get_cover_hour(hour); } else { var hour = $('#hour-box-select').val(); } $.post(core_url + '/reservation/update_extra_message', { language: language, restaurant: restaurant, date: date, hour: hour, extra: productextras[index], people: numberperson }, function (data) { $('.product-name').text(''); $('.product-description').text(''); var vat = 100 + parseFloat(data.product.product_vat); infoproducts[index] = data.product; numberproducts[index] = numberperson; if (vat != 100) { shoppingproduct[index] = data.product.product_name + ', ' + print_price_currency((data.product.price_people / vat).toFixed(2), currency_str) + per_person + iva_no_incluido + ' (' + data.product.amount_total_str + ' ' + iva_incluido + ')'; } else { shoppingproduct[index] = data.product.product_name + ', ' + print_price_currency((data.product.price_people / vat).toFixed(2), currency_str) + per_person; } var prix_aux = data.product.amount_total / 100; var prix_rest = infoproduct_aux.amount_total / 100; prix_eachproduct[index] = data.product.amount_total / 100; prix_totalproducts = prix_totalproducts - prix_rest + prix_aux; $.post(core_url + '/reservation/addproduct_shopping', { restaurant: restaurant, language: language, products: shoppingproduct, precio: prix_totalproducts, productosinfo: infoproducts, numberproduct: numberproducts }, function (data) { $('#products-cart').html(data.shopping); }, "json"); }, "json"); } else { var numberperson = numberproducts[index] + 1; var date = $('#datepicker').val(); if (hour_motor_conf) { var hour = $('#timepicker_motor').val(); hour = get_cover_hour(hour); } else { var hour = $('#hour-box-select').val(); } $.post(core_url + '/reservation/update_extra_message', { language: language, restaurant: restaurant, date: date, hour: hour, extra: productextras[index], people: numberperson }, function (data) { $('.product-name').text(''); $('.product-description').text(''); var vat = 100 + parseFloat(data.product.product_vat); numberproducts[index] = numMenu + 1; if (vat != 100) { shoppingproduct[index] = data.product.product_name + ', ' + print_price_currency((data.product.price_people / vat).toFixed(2), currency_str) + per_unit + ' ' + iva_no_incluido + ' (' + print_price_currency(data.product.amount_total / 100 * numberperson, currency_str) + ' ' + iva_incluido + ')'; } else { shoppingproduct[index] = data.product.product_name + ', ' + print_price_currency((data.product.price_people / vat).toFixed(2), currency_str) + per_unit; } prix_totalproducts = prix_totalproducts + (infoproduct_aux.amount_total / 100); prix_eachproduct[index] = prix_eachproduct[index] + (infoproduct_aux.amount_total / 100); $.post(core_url + '/reservation/addproduct_shopping', { restaurant: restaurant, language: language, products: shoppingproduct, precio: prix_totalproducts, productosinfo: infoproducts, numberproduct: numberproducts }, function (data) { $('#products-cart').html(data.shopping); }, "json"); }, "json"); } } else { alert(menu_mayor_comensal); } } function restproduct(index) { var infoproduct_aux = infoproducts[index]; var numMenu = parseInt($("#numberproduct" + index).val()); if (numMenu != 1) { productincart = productincart - 1; document.getElementById('productincart').innerHTML = productincart; document.getElementById('numberproduct' + index).value = numMenu - 1; if (infoproduct_aux.product_groups == 0) { var numberperson = numberproducts[index] - 1; var date = $('#datepicker').val(); if (hour_motor_conf) { var hour = $('#timepicker_motor').val(); hour = get_cover_hour(hour); } else { var hour = $('#hour-box-select').val(); } $.post(core_url + '/reservation/update_extra_message', { language: language, restaurant: restaurant, date: date, hour: hour, extra: productextras[index], people: numberperson }, function (data) { $('.product-name').text(''); $('.product-description').text(''); var vat = 100 + parseFloat(data.product.product_vat); infoproducts[index] = data.product; numberproducts[index] = numberperson; if (vat != 100) { shoppingproduct[index] = data.product.product_name + ', ' + print_price_currency((data.product.price_people / vat).toFixed(2), currency_str) + per_person + iva_no_incluido + ' (' + data.product.amount_total_str + ' ' + iva_incluido + ')'; } else { shoppingproduct[index] = data.product.product_name + ', ' + print_price_currency((data.product.price_people / vat).toFixed(2), currency_str) + per_person; } var prix_aux = data.product.amount_total / 100; var prix_rest = infoproduct_aux.amount_total / 100; prix_eachproduct[index] = data.product.amount_total / 100; prix_totalproducts = prix_totalproducts - prix_rest + prix_aux; $.post(core_url + '/reservation/addproduct_shopping', { restaurant: restaurant, language: language, products: shoppingproduct, precio: prix_totalproducts, productosinfo: infoproducts, numberproduct: numberproducts }, function (data) { $('#products-cart').html(data.shopping); }, "json"); }, "json"); } else { var numberperson = numberproducts[index] - 1; var date = $('#datepicker').val(); if (hour_motor_conf) { var hour = $('#timepicker_motor').val(); hour = get_cover_hour(hour); } else { var hour = $('#hour-box-select').val(); } $.post(core_url + '/reservation/update_extra_message', { restaurant: restaurant, language: language, restaurant: restaurant, date: date, hour: hour, extra: productextras[index], people: numberperson }, function (data) { $('.product-name').text(''); $('.product-description').text(''); var vat = 100 + parseFloat(data.product.product_vat); numberproducts[index] = numMenu - 1; if (vat != 100) { shoppingproduct[index] = data.product.product_name + ', ' + print_price_currency((data.product.price_people / vat).toFixed(2), currency_str) + per_unit + ' ' + iva_no_incluido + ' (' + print_price_currency(data.product.amount_total / 100 * numberperson, currency_str) + ' ' + iva_incluido + ')'; } else { shoppingproduct[index] = data.product.product_name + ', ' + print_price_currency((data.product.price_people / vat).toFixed(2), currency_str) + per_unit; } prix_totalproducts = prix_totalproducts - (infoproduct_aux.amount_total / 100); prix_eachproduct[index] = prix_eachproduct[index] - (infoproduct_aux.amount_total / 100); $.post(core_url + '/reservation/addproduct_shopping', { restaurant: restaurant, language: language, products: shoppingproduct, precio: prix_totalproducts, productosinfo: infoproducts, numberproduct: numberproducts }, function (data) { $('#products-cart').html(data.shopping); }, "json"); }, "json"); } } else { deleteproduct(index); } } // Abre la lista de espera function waiting() { date = $('#datepicker').val(); $("#invoice_data_div").hide(); $('#have').hide(); if (date == '') { alert('Seleccione un día'); } else { $('#searchwithoutbottom').hide(); $('.selectpicker').selectpicker(); $.post(core_url + '/reservs/avaible_waiting_list', { language: language, restaurant: restaurant, dia: date }, function (data) { if (data.resp == 1) { if (restaurant == 'celler-de-can-roca') { $('#commentary_div').hide(); } //hour = $('#hour-box-select').val(); people = $('#people-box-select').val(); jQuery('#info_perview').text(w_text + date + ':'); $('#extra_people').val(people); $('#extra_list').show(); $('#datos_personales').show(); $('#waiting-box').show(); $('#group-request-box').hide(); $('#datos_reserva').hide(); $('#reg_button').hide(); $('.condiciones').hide(); $('#addCommentary').addClass('commentary_waiting'); if (data.zone_waiting_list == 1) { $('#zone_extra').html(data.zone_box); $('#zone_extra').show(); zone_waiting_list = parseInt(data.zone_waiting_list); } // Borrado $('.product-price-total').text(""); $('.info_perview').text(date); product_tag = 0; $('.reservarButton').attr('disabled', false); } else { alert(data.error_text); } }, "json"); } } // Abre la solicitud de grupo function group_request() { const date = $('#datepicker').val(); $("#invoice_data_div").hide(); $('#have').hide(); $('#searchwithoutbottom').hide(); $('.selectpicker').selectpicker(); if (restaurant == 'celler-de-can-roca') { $('#commentary_div').hide(); } if ($('#extra_people_group_request').hasClass('group_request_select')) { $('#extra_people_group_request').val('-1'); } else { $('#extra_people_group_request').val(''); } $('#extra_list_group_request').show(); $('#datos_personales').show(); $('#waiting-box').hide(); $('#group-request-box').show(); $('#datos_reserva').hide(); $('#reg_button').hide(); $('.condiciones').hide(); $('#addCommentary').addClass('commentary_waiting'); $('.product-price-total').text(""); $('.info_perview').text(date); product_tag = 0; $('.reservarButton').attr('disabled', false); // Eliminamos las opciones de tipo cadena de texto del desplegable de horas: $("#extra_hour_group_request option[value='1']").remove(); $("#extra_hour_group_request option[value='2']").remove(); $("#extra_hour_group_request option[value='3']").remove(); // Si seleccionó una hora anteriormente, seleccionamos la misma en el nuevo desplegable: if ($('#hour-box-select').val() !== null && $('#hour-box-select').val() !== '' && $('#hour-box-select').val() !== undefined) { $('#extra_hour_group_request').val($('#hour-box-select').val()); } } // vuelve al principio function clear() { $('#user_first_name').val(''); $('#user_last_name').val(''); $('#user_email').val(''); $('#user_phone').val(''); $('#commentary').val(''); $('#int_call_code').val(call_code); $('#extra_list').hide(); $('#extra_list_group_request').hide(); $('#extra_people').val(''); $('#extra_hour').val(); } // PAntalla final de confirmación function fin() { $('#end_box').show(); } // Guarda lista de espera function waiting_final(buttom) { buttom.disabled = 'disabled'; user_name = $('#user_first_name').val(); user_last_name = $('#user_last_name').val(); user_email = $('#user_email').val(); user_phone = $('#user_phone').val(); date = $('#datepicker').val(); people = $('#extra_people').val(); hour = $('#extra_hour').val(); int_call_code = $('#int_call_code').val(); commentary_client = $('#commentary').val(); if ($('#has_food_restrictions').is(':checked') === true && $('#food_restrictions').val() !== '') { commentary_client += allergens_lang_text + $('#food_restrictions').val(); } subscribe_newsletter = $('#subscribe_newsletter').is(':checked') ? 1 : 0; data_treatment_consent = $('#data_treatment_consent').is(':checked') ? 1 : 0; var consentimiento_legal = $('#consentimiento_legal').is(":checked"); if (zone_waiting_list == 1) { var zone_select = $('#zone-box-select').val(); if (zone_select != -1 && zone_select != '-1') { commentary_client += moduleWaitingListZone + zone_select; } } var allergens = false; var allergens_text = ''; if ($('#has_food_restrictions').is(':checked') === true) { if ($('#food_restrictions').val() !== '') { allergens_text += allergens_lang_text + $('#food_restrictions').val(); } allergens = true; } if ($('#no_food_restrictions').is(':checked') === true || $('#aller').length == 0) { allergens = true; } var commentary_required_empty = 0; if (commentary_required == 1 && commentary_shown == 1 && $('#commentary').val() == "") { commentary_required_empty = 1; } if (consentimiento_legal || personal_data_check_shown_motores == 0) { if (subscribe_newsletter == 1 || newsletter_obli_motores == 0 || subscribe_check_shown_motores == 0) { if (user_name != '' && user_last_name != '' && user_email != '' && user_phone != '' && people != '' && hour != 0) { var email_address = user_email.toLowerCase(); if (validateEmail(email_address)) { if (allergens) { if (commentary_required_empty != 1) { validateRecaptcha(function(recaptchaToken) { $.post(core_url + '/reservs/new_reserv_waiting', { recaptchaToken: recaptchaToken, st: st, language: language, restaurant: restaurant, people: people, dia: date, hour: hour, user_name: user_name, user_last_name: user_last_name, user_email: user_email, user_phone: user_phone, int_call_code: int_call_code, commentary_client: commentary_client, food_restriction: allergens_text, subscribe_newsletter: subscribe_newsletter, data_treatment_consent: data_treatment_consent }, function (data) { if (data.resp == 1) { //inicio(); //clear(); $('#info_end_reserv').html('' + waiting_list + ': ' + user_name + ' ' + user_last_name + '
' + date + ' | ' + transform_timecover(hour) + ' | ' + people + text4 + '
' + commentary_client + '
'); $('#info_end_txt').text(text6); $('#datos_personales').hide(); if (!isMarketplace() && data.htmlproductmotor.active == 1) { $('#product_motorhtml').html(data.htmlproductmotor.html_css); } $('#end_box').show(); //alert(text6); } else { alert(data.msg); buttom.disabled = ''; } }, "json"); }); } else { alert(text19); buttom.disabled = ''; } } else { alert(text16); buttom.disabled = ''; } } else { alert(text7); buttom.disabled = ''; } } else { alert(text8); buttom.disabled = ''; } } else { alert(newsletter_obli_motores_text); buttom.disabled = ''; } } else { $('#btn-validate').removeAttr('disabled'); alert(text14); buttom.disabled = ''; } } // Guarda la reserva en forma de solicitud de grupo (pendiente pero sin ocupación) function group_request_final(buttom) { $("#loading").show(); buttom.disabled = 'disabled'; var people = $('#extra_people_group_request').val(); var user_first_name = $('#user_first_name').val(); var user_last_name = $('#user_last_name').val(); var user_phone = $('#user_phone').val(); var user_email = $('#user_email').val(); var consentimiento_legal = $('#consentimiento_legal').is(":checked"); var subscribe_newsletter = $('#subscribe_newsletter').is(':checked') ? 1 : 0; var commentary_required_empty = 0; if (commentary_required == 1 && commentary_shown == 1 && $('#commentary').val() == "") { commentary_required_empty = 1; } if (consentimiento_legal || personal_data_check_shown_motores == 0) { if (newsletter_obli_motores == 0 || subscribe_newsletter == 1 || subscribe_check_shown_motores == 0) { if (commentary_required_empty == 0) { if (user_first_name !== '' && user_last_name !== '' && user_email !== '' && user_phone !== '' && people !== '' && people != -1 && people != null) { var email_address = user_email.toLowerCase(); if (validateEmail(email_address)) { // Comprobamos si debe solicitar tarjeta if (groupRequestCancelPolicy == 1 || groupRequestHoldOnCard == 1) { check_pay_group_request(); } else { do_group_request(); } } else { alert(text7); buttom.disabled = ''; $("#loading").hide(); } } else { alert(text8); buttom.disabled = ''; $("#loading").hide(); } } else { alert(text19); buttom.disabled = ''; $("#loading").hide(); } } else { alert(newsletter_obli_motores_text); buttom.disabled = ''; $("#loading").hide(); } } else { $('#btn-validate').removeAttr('disabled'); alert(text14); buttom.disabled = ''; $("#loading").hide(); } } function do_group_request() { var people = $('#extra_people_group_request').val(); var hour = $('#extra_hour_group_request').val(); var user_first_name = $('#user_first_name').val(); var user_last_name = $('#user_last_name').val(); var int_call_code = $('#int_call_code').val(); var user_phone = $('#user_phone').val(); var date = $('#datepicker').val(); var user_email = $('#user_email').val(); var commentary_client = $('#commentary').val(); var allergens_text = ''; var subscribe_newsletter = $('#subscribe_newsletter').is(':checked') ? 1 : 0; var data_treatment_consent = $('#data_treatment_consent').is(':checked') ? 1 : 0; $('#loading').show(); $('#pay_button_group_request').disabled = 'disabled'; if ($('#has_food_restrictions').is(':checked') === true && $('#food_restrictions').val() !== '') { allergens_text += allergens_lang_text + $('#food_restrictions').val(); } // if the hour is one digit, we add a 0 at the beginning if (hour.length == 4) { hour = '0' + hour; } validateRecaptcha(function(recaptchaToken) { $.post(core_url + '/reservs/new_reserv_group_request', { recaptchaToken: recaptchaToken, st: st, language: language, restaurant: restaurant, people: people, dia: date, hour: hour, user_name: user_first_name, user_last_name: user_last_name, user_email: user_email, user_phone: user_phone, int_call_code: int_call_code, subscribe_newsletter: subscribe_newsletter, data_treatment_consent: data_treatment_consent, allergens_text: allergens_text, commentary_client: commentary_client, stripeToken: stripeToken, payment_intent: payment_intent, is_group: 1, origin: origin, org: org, motor: 'classic' }, function (data) { if (data.resp == 1) { $('#alert_time').hide(); $('#pay-box-group_request').hide(); $('#loading').hide(); $('#datos_personales').hide(); $('#info_end_txt').html(data.txt); $('#info_end_reserv').html(data.reserv + '
' + commentary_client + '
' + allergens_text + ''); $('#pay_button_group_request').attr('disabled', false); $('#end_box').show(); } else { alert(data.msg); $('#loading').hide(); $('#group-request-box input').attr('disabled', false); $('#pay_button_group_request').attr('disabled', false); } }, "json"); }); } // Actualiza el cuadro de personas function people_box(data) { var people = $('#people-box-select').val(); $('#personas_box').html(data); if (people != undefined) $('#people-box-select').val(people); $('#people-box-select').change(function () { if (shopping_cart == 1) { empty_cart(); } update_hours(); }); } // Actualiza el cuadro de horas function hour_box(data, updatePeople = true) { var hour = $('#hour-box-select').val(); $('#hour_box').html(data); if (hour_pre != '' && (hour == '' || hour == undefined)) { if ($("#hour-box-select option[value='" + hour_pre + "']").length) { hour = hour_pre; } first_hour_conf = hour_pre; } if ($("#hour-box-select option[value='" + hour + "']").length) { $('#hour-box-select').val(hour); } else { $('#hour-box-select').val(-1); } $('#hour-box-select').change(function () { stop_validation = true; update_people(); }); if (hour_motor_conf) { $('#timepicker_motor').timepicker({ disableFocus: true, showInputs: false, defaultTime: first_hour_conf, minuteStep: parseInt(space_time), showMeridian: false }) .on('hide.timepicker', function (e) { update_people(); }); } if (updatePeople || (hour_pre != '' && (hour == '' || hour == undefined))) { stop_validation = true; if ($("#hour-box-select option[value='" + hour_pre + "']").length != 0) { if (updatePeople) { update_people(); } stop_validation = false; $('#hour-box-select').val(hour_pre); } } } // Actualiza el cuadro de horas reservable o no function hour_box_extra(data) { $('#hour_box_extra').html(data); } // Actualiza el cuadro de horas de solicitud de grupos. function hour_box_group_request(hours) { $("#extra_hour_group_request").empty(); Object.keys(hours).forEach(function (key) { key = transform_timecover(key, true); var timeString = key; $('#extra_hour_group_request').append($('"); $('.product-name').html(""); $('.product-description').html(""); $('.product-price, .product-price-total').text(''); for (let k in data.products) { let option = $('') .val(data.products[k].extra) .text(data.products[k].name); $('#extra-box-select-product').append(option); } $('#select-product').show(); $('#extra-box-select-product').show(); $('#numberproduct').show(); $('#botonsumarproduct').show(); $('#botonsumarproduct2').show(); $('#extra-box-select-product').change(function () { if ($('#extra-box-select-product').val() != -1) { $("#extra-box-select-product option[value=" + -1 + "]").attr("disabled", "disabled"); } }); if (data.product.product_groups == 0) { document.getElementById('numberproduct').value = people; } else { document.getElementById('numberproduct').value = 1; } empty_cart(); $('#extra-box-select-product').val(data.selected); } else { thereareproducts = false; } $('#extra-box-select-product').val("-1"); if (data.selected == undefined) { selected = ''; } else { selected = data.selected; } if ($('#extra-box-select').is(":visible")) { if (extra_message_column == 0) { $('#extra_message_container').removeClass('col-xs-offset-6'); $('#extra_message_container').removeClass('col-xs-6'); $('#extra_message_container').addClass('col-xs-12'); } } }, "json"); } else { var date = $('#datepicker').val(); if (hour_motor_conf) { var hour = $('#timepicker_motor').val(); hour = get_cover_hour(hour); } else { var hour = $('#hour-box-select').val(); } if (hour == null && hour_pre != '') { $('#hour-box-select').val(hour_pre); hour = hour_pre; } var selection = $('#extra-box-select').val(); var first_iteration = false; if (selection == undefined) { if ($('#extra-box-select').is(":visible")) { first_iteration = true; } selection = "productosinregla" } var people = $('#people-box-select').val(); $.post(core_url + '/reservation/update_extra_message', { language: language, restaurant: restaurant, date: date, hour: hour, extra: selection, people: people }, function (data) { $('.product-name').text(''); $('.product-description').text(''); $('#select-product').hide(); $('#extra-box-select-product').hide(); if (extra_message_column == 0) { $('#extra_message_container').addClass('col-xs-offset-6'); $('#extra_message_container').addClass('col-xs-6'); $('#extra_message_container').removeClass('col-xs-12'); } if (!first_iteration) { $('.extra_message').html(data.message); } if (typeof data.product !== 'undefined' && (data.product.product == 3 || (data.product.product == 2 && typeof data.product.product_name !== 'undefined' && data.product.product_name !== ''))) { showProduct(data.product); } else { if (typeof data.product !== 'undefined' && parseInt(data.product.product) === 2) { selected = data.selected; if (data.product.product_name !== '') { $('.product-description').html(data.product.product_name); } else { $('.product-description').html(''); } if (typeof data.product.product_description !== 'undefined' && data.product.product_description !== '' && data.product.product_description !== data.product.product_name) { $('.product-name').html(data.product.product_name); $('.product-description').html(data.product.product_description); $('.product-price, .product-price-total').html(''); } else { $('.product-name, .product-price, .product-price-total').html(''); } } else { if (!hasInitialProduct) { $('.product-name, .product-price, .product-price-total, .product-description').html(''); } } } // Múltiples precios $('#extra-box-select-product').empty(); if (typeof data.products !== 'undefined') { //select_a_product $('#extra-box-select-product').append(""); $('.product-name').html(""); $('.product-description').html(""); $('.product-price, .product-price-total').text(''); $('#extra-box-select-product').change(function () { if ($('#extra-box-select-product').val() != -1) { $("#extra-box-select-product option[value=" + -1 + "]").attr("disabled", "disabled"); } }); for (let k in data.products) { let option = $('') .val(data.products[k].extra) .text(data.products[k].name); $('#extra-box-select-product').append(option); } if (!data.notshow_product) { $('#select-product').show(); if (($('#extra-box-select').val() != -1 && $('#extra-box-select').val() != null) || !$("#extra-box-select").is(":visible")) { $('#extra-box-select-product').show(); } if (!hasInitialProduct) { $('#extra-box-select-product').val("-1").change(); } } } if (($('#extra-box-select').length > 0) && ($('#extra-box-select').val() == "-1" || $('#extra-box-select').val() == null)) { $('.product-name, .product-price, .product-price-total, .product-description').html(''); } selected = ''; if (typeof data.selected !== 'undefined') { selected = data.selected; } if ($('#extra-box-select').is(":visible")) { if (extra_message_column == 0) { $('#extra_message_container').removeClass('col-xs-offset-6'); $('#extra_message_container').removeClass('col-xs-6'); $('#extra_message_container').addClass('col-xs-12'); if ($('#extra-box-select').val() !== null || isJSON($('#extra-box-select').val())) { showProduct(data.product); } } } }, "json"); } } function isJSON(something) { if (typeof something != 'string') something = JSON.stringify(something); try { JSON.parse(something); return true; } catch (e) { return false; } } function showProduct(product) { if (typeof product !== 'undefined' && typeof product.product_name !== 'undefined' && ($('#extra-box-select-product').val() != -1 || hasInitialProduct)) { product_name = product.product_name + ', ' || ''; product_description = product.product_description || ''; let productPrecio = ''; let productPrecioTotal = ''; let pachaZone = ''; let partProduct = ''; // Actualizar vat var vat = 100 + parseFloat(product.product_vat); // Hide or show the prize hidePreviouPrice = !($("#extra-box-select").is(":visible") && ($("#extra-box-select").val() == '-1' || $("#extra-box-select").val() == null) ); // grupos if (product.product_groups == 0) { var people = $('#people-box-select').val(); if (typeof product.price_people !== 'undefined' && parseInt(product.price_people) !== 0) { $('.forpeople').show(); if (vat != 100) { productPrecio = print_price_currency((product.price_people / 100).toFixed(2), currency_str) + per_person + ' ' + iva_incluido $('.product-price').text(productPrecio); productPrecioTotal = total + ': ' + print_price_currency((product.price_people / 100 * people).toFixed(2), currency_str) + ' ' + iva_incluido + ' (' + print_price_currency((product.price_people * people / vat).toFixed(2), currency_str) + ' ' + iva_no_incluido + ')' $('.product-price-total').text(productPrecioTotal); } else { productPrecio = print_price_currency((product.price_people / 100).toFixed(2), currency_str) + per_person; $('.product-price').text(productPrecio); productPrecioTotal = total + ': ' + print_price_currency((product.price_people / 100 * people).toFixed(2), currency_str) $('.product-price-total').text(productPrecioTotal); } } else { $('.forpeople').hide(); $('.product-price').text(''); $('.product-price-total').text(''); } if (typeof people !== 'undefined') { $('#people-box-select').val(people); $('.info_header2').show(); } } else { if (typeof product.price_people !== 'undefined' && parseInt(product.price_people) !== 0) { if (product.product_groups == undefined) { $('.forpeople').show(); } else { $('.forpeople').hide(); } if (parseInt(vat) !== 100) { productPrecio = print_price_currency((product.price_people / 100).toFixed(2), currency_str) + ' ' + iva_incluido; $('.product-price').text(productPrecio); productPrecioTotal = total + ': ' + print_price_currency((product.price_people / 100).toFixed(2), currency_str) + ' ' + iva_incluido + ' (' + print_price_currency((product.price_people / vat).toFixed(2), currency_str) + ' ' + iva_no_incluido + ')'; $('.product-price-total').text(productPrecioTotal); } else { productPrecio = print_price_currency((product.price_people / 100).toFixed(2), currency_str); $('.product-price').text(productPrecio); productPrecioTotal = total + ': ' + print_price_currency((product.price_people / 100).toFixed(2), currency_str); $('.product-price-total').text(productPrecioTotal); } } else { $('.forpeople').hide(); $('.product-price').text(''); $('.product-price-total').text(''); } $('.info_header2').show(); } if (typeof product_name !== 'undefined') { $('.product-name').html(product_name); } if (product.price_people == 0) { $('.product-name').text(product.product_name); } if (typeof product_description !== 'undefined') { $('.product-description').html(product_description); } if ($("#infomap").is(":visible")) { pachaZone = $("#infomap").html(); partProduct = pachaZone.split("
"); if (partProduct.length > 1) { $("#infomap").html(partProduct[0]); $("#infomap").append('
' + product_name + ' ' + productPrecio + '
' + product_description + ' ' + productPrecioTotal); } } if (hidePreviouPrice === false) { $(".product-name").css("display", "none"); $(".product-description").css("display", "none"); $(".product-price").css("display", "none"); $(".product-price-total").css("display", "none"); } else { $(".product-name").css("display", "initial"); $(".product-description").css("display", "block"); $(".product-price").css("display", "initial"); $(".product-price-total").css("display", "initial"); } } } function update_message_extra_product_shop() { var date = $('#datepicker').val(); if (hour_motor_conf) { var hour = $('#timepicker_motor').val(); hour = get_cover_hour(hour); } else { var hour = $('#hour-box-select').val(); } var selection = $('#extra-box-select-product').val(); var people = $('#people-box-select').val(); var people_real_select = parseInt($('#numberproduct').val()); $.post(core_url + '/reservation/update_extra_message', { language: language, restaurant: restaurant, date: date, hour: hour, extra: selection, people: people, people_real_select: people_real_select }, function (data) { $('.product-name').text(''); $('.product-description').text(''); $('.extra_message').html(data.message); if (data.product != undefined && (data.product.product == 3 || (data.product.product == 2 && data.product.product_name != undefined && data.product.product_name != ''))) { product_name = data.product.product_name + ', ' || ''; product_description = data.product.product_description || ''; infoproduct = data.product; // Actualizar vat var vat = 100 + parseFloat(data.product.product_vat); // grupos if (data.product.product_groups == 0) { if (data.product.price_people != 0) { $('.forpeople').hide(); if (vat != 100) { $('.product-price').text(print_price_currency((data.product.price_people / 100).toFixed(2), currency_str) + per_person + ' ' + iva_incluido); $('.product-price-total').text(total + ': ' + print_price_currency((data.product.price_people / 100 * people_real_select).toFixed(2), currency_str) + ' ' + iva_incluido + ' (' + print_price_currency((data.product.price_people / vat * people_real_select).toFixed(2), currency_str) + ' ' + iva_no_incluido + ')'); } else { $('.product-price').text(print_price_currency((data.product.price_people / 100).toFixed(2), currency_str) + per_person); $('.product-price-total').text(total + ': ' + print_price_currency((data.product.price_people / 100 * people_real_select).toFixed(2), currency_str)); } } else { $('.forpeople').hide(); $('.product-price').text(''); $('.product-price-total').text(''); } //$('#people-box-select').val(people); $('.info_header2').show(); } else { if (data.product.product_groups == undefined) { $('.forpeople').hide(); } else { $('.forpeople').hide(); } if (data.product.price_people != 0) { if (vat != 100) { $('.product-price').text(print_price_currency((data.product.price_people / 100).toFixed(2), currency_str) + per_unit + ' ' + iva_incluido); $('.product-price-total').text(total + ': ' + print_price_currency((data.product.price_people / 100 * people_real_select).toFixed(2), currency_str) + ' ' + iva_incluido + ' (' + print_price_currency((data.product.price_people / vat * people_real_select).toFixed(2), currency_str) + ' ' + iva_no_incluido + ')'); } else { $('.product-price').text(print_price_currency((data.product.price_people / 100).toFixed(2), currency_str) + per_unit); $('.product-price-total').text(total + ': ' + print_price_currency((data.product.price_people / 100 * people_real_select).toFixed(2), currency_str)); } } else { $('.forpeople').hide(); $('.product-price').text(''); $('.product-price-total').text(''); } $('.info_header2').show(); } $('.product-name').text(product_name); if (data.product.price_people == 0) { $('.product-name').text(data.product.product_name); } $('.product-description').html(product_description); //$('.product-price').text((data.product.price_people/vat).toFixed(2) + currency_str + per_person + iva_no_incluido); if (data.product.price_people != 0) { prix_productselecttotal = data.product.amount_total / 100; } else { prix_productselecttotal = 0; } // aplicamos el producto seleccionado //var extra = $('#extra-box-select').val(); //$("#extra-box-select option[value='"+extra+"']").val(selection); selected = data.selected; } else { if (data.product != undefined && data.product.product == 2) { selected = data.selected; if (data.product.product_name != '') { $('.product-description').html(data.product.product_name); } else { $('.product-description').text(''); } $('.product-name, .product-price, .product-price-total').text(''); } else { $('.product-name, .product-price, .product-price-total, .product-description').text(''); } prix_productselecttotal = 0; } }, "json"); } function update_message_extra_product() { if (shopping_cart == 1) { var date = $('#datepicker').val(); if (hour_motor_conf) { var hour = $('#timepicker_motor').val(); hour = get_cover_hour(hour); } else { var hour = $('#hour-box-select').val(); } var selection = $('#extra-box-select-product').val(); var persons = $('#people-box-select').val(); var people = $('#people-box-select').val(); var people_real_select = parseInt($('#numberproduct').val()); $.post(core_url + '/reservation/update_extra_message', { language: language, restaurant: restaurant, date: date, hour: hour, extra: selection, people: people, people_real_select: people_real_select }, function (data) { $('.product-name').text(''); $('.product-description').text(''); $('.extra_message').html(data.message); if (data.product != undefined && (data.product.product == 3 || (data.product.product == 2 && data.product.product_name != undefined && data.product.product_name != ''))) { if (data.product.product_groups == 0 && persons != people) { document.getElementById('numberproduct').value = persons; update_message_extra_product(); } else { product_name = data.product.product_name || ''; product_description = data.product.product_description || ''; infoproduct = data.product; // Actualizar vat if (data.product.product_groups == 1) { document.getElementById('numberproduct').value = 1; } var vat = 100 + parseFloat(data.product.product_vat); // grupos if (data.product.product_groups == 0) { if (data.product.price_people != 0) { $('.forpeople').hide(); product_name += ", "; if (vat != 100) { $('.product-price').text(print_price_currency((data.product.price_people / 100).toFixed(2), currency_str) + per_person + ' ' + iva_incluido); $('.product-price-total').text(total + ': ' + print_price_currency((data.product.price_people / 100 * people_real_select).toFixed(2), currency_str) + ' ' + iva_incluido + ' (' + print_price_currency((data.product.price_people / vat * people_real_select).toFixed(2), currency_str) + ' ' + iva_no_incluido + ')'); } else { $('.product-price').text(print_price_currency((data.product.price_people / 100).toFixed(2), currency_str) + per_person); $('.product-price-total').text(total + ': ' + print_price_currency((data.product.price_people / 100 * people_real_select).toFixed(2), currency_str)); } } else { $('.forpeople').hide(); $('.product-price').text(''); $('.product-price-total').text(''); } //$('#people-box-select').val(people); $('.info_header2').show(); } else { if (data.product.product_groups == undefined) { $('.forpeople').hide(); } else { $('.forpeople').hide(); } if (data.product.price_people != 0) { product_name += ", "; if (vat != 100) { $('.product-price').text(print_price_currency((data.product.price_people / 100).toFixed(2), currency_str) + per_unit + ' ' + iva_incluido); $('.product-price-total').text(total + ': ' + print_price_currency((data.product.price_people / 100 * people_real_select).toFixed(2), currency_str) + ' ' + iva_incluido + ' (' + print_price_currency((data.product.price_people / vat * people_real_select).toFixed(2), currency_str) + ' ' + iva_no_incluido + ')'); } else { $('.product-price').text(print_price_currency((data.product.price_people / 100).toFixed(2), currency_str) + per_unit); $('.product-price-total').text(total + ': ' + print_price_currency((data.product.price_people / 100 * people_real_select).toFixed(2), currency_str)); } } else { $('.forpeople').hide(); $('.product-price').text(''); $('.product-price-total').text(''); } $('.info_header2').show(); } $('.product-name').text(product_name); if (data.product.price_people == 0) { $('.product-name').text(data.product.product_name); } $('.product-description').html(product_description); //$('.product-price').text((data.product.price_people/vat).toFixed(2) + currency_str+ per_person + iva_no_incluido); if (data.product.price_people != 0) { prix_productselecttotal = data.product.amount_total / 100; } else { prix_productselecttotal = 0; } selected = data.selected; } } else { if (data.product != undefined && (data.product.product == 2 || data.product.product == 5)) { selected = data.selected; if (data.product.product_name != '') { $('.product-description').html(data.product.product_name); } else { $('.product-description').text(''); } $('.product-name, .product-price, .product-price-total').text(''); } else { $('.product-name, .product-price, .product-price-total, .product-description').text(''); } prix_productselecttotal = 0; } }, "json"); } else { var date = $('#datepicker').val(); if (hour_motor_conf) { var hour = $('#timepicker_motor').val(); hour = get_cover_hour(hour); } else { var hour = $('#hour-box-select').val(); } var selection = $('#extra-box-select-product').val(); var people = $('#people-box-select').val(); $.post(core_url + '/reservation/update_extra_message', { language: language, restaurant: restaurant, date: date, hour: hour, extra: selection, people: people }, function (data) { $('.product-name').text(''); $('.product-description').text(''); $('.extra_message').html(data.message); if (data.product != undefined && data.product.product == 3) { showProduct(data.product) product_name = data.product.product_name + ', ' || ''; product_description = data.product.product_description || ''; // Actualizar vat var vat = 100 + parseFloat(data.product.product_vat); // grupos if (data.product.product_groups == 0) { if (data.product.price_people != 0) { $('.forpeople').show(); if (vat != 100) { $('.product-price').text(print_price_currency((data.product.price_people / 100).toFixed(2), currency_str) + per_person + ' ' + iva_incluido); $('.product-price-total').text(total + ': ' + print_price_currency((data.product.price_people / 100 * people).toFixed(2), currency_str) + ' ' + iva_incluido + ' (' + print_price_currency((data.product.price_people / vat * people).toFixed(2), currency_str) + ' ' + iva_no_incluido + ')'); } else { $('.product-price').text(print_price_currency((data.product.price_people / 100).toFixed(2), currency_str) + per_person); $('.product-price-total').text(total + ': ' + print_price_currency((data.product.price_people / 100 * people).toFixed(2), currency_str)); } } else { $('.forpeople').hide(); $('.product-price').text(''); $('.product-price-total').text(''); } $('#people-box-select').val(people); $('.info_header2').show(); } else { if (data.product.product_groups == undefined) { $('.forpeople').show(); } else { $('.forpeople').hide(); } if (data.product.price_people != 0) { if (vat != 100) { $('.product-price').text(print_price_currency((data.product.price_people / 100).toFixed(2), currency_str) + ' ' + iva_incluido); $('.product-price-total').text(total + ': ' + print_price_currency((data.product.price_people / 100).toFixed(2), currency_str) + ' ' + iva_incluido + ' (' + print_price_currency((data.product.price_people / vat).toFixed(2), currency_str) + ' ' + iva_no_incluido + ')'); } else { $('.product-price').text(print_price_currency((data.product.price_people / 100).toFixed(2), currency_str)); $('.product-price-total').text(total + ': ' + print_price_currency((data.product.price_people / 100).toFixed(2), currency_str)); } } else { $('.forpeople').hide(); $('.product-price').text(''); $('.product-price-total').text(''); } $('.info_header2').show(); } $('.product-name').text(product_name); if (data.product.price_people == 0) { $('.product-name').text(data.product.product_name); } $('.product-description').html(product_description); //$('.product-price').text((data.product.price_people/vat).toFixed(2) + currency_str+ per_person + iva_no_incluido); // aplicamos el producto seleccionado //var extra = $('#extra-box-select').val(); //$("#extra-box-select option[value='"+extra+"']").val(selection); selected = data.selected; } else { if (data.product != undefined && (data.product.product == 2 || data.product.product == 5)) { showProduct(data.product) selected = data.selected; if (data.product.product_name != '') { $('.product-description').html(data.product.product_name); } else { $('.product-description').text(''); } if (data.product.product_description != undefined && data.product.product_description != '' && data.product.product_description != data.product.product_name) { $('.product-name').html(data.product.product_name); $('.product-description').html(data.product.product_description); $('.product-price, .product-price-total').text(''); } else { $('.product-name, .product-price, .product-price-total').text(''); } } else { $('.product-name, .product-price, .product-price-total, .product-description').text(''); } } }, "json"); } } //Pop de confirmación de los datos function info_box2() { $('#reg_button').click(function () { // Todo Obsolete var people = $('#people-box-select').val(); if (hour_motor_conf) { var hour = $('#timepicker_motor').val(); hour = get_cover_hour(hour); } else { var hour = $('#hour-box-select').val(); } var day = fecha($('#datepicker').datepicker('getDate')); msg = '' + text9 + '' + people + ',' + text10 + '' + hour + '
' + text11 + '' + day; $('#textPopConfirm').html(msg); }); } //Validación de los datos function login_box(data) { if (data.is_logged === 0) { user_mail = new LiveValidation('user_email', { wait: 5000 }); user_mail.add(Validate.Presence, { failureMessage: necesario }); //chech de email $('#user_password').bind('keypress', function (e) { if (e.keyCode === 13) { $('#reg_button').click(); } }); $("#r50_info_link").click(function () { $('#r50_info').toggle(); return false; }); $('#user_email').focusout(function () { var email_address = $('#user_email').val().toLowerCase(); if (validateEmail(email_address)) { $.post(core_url + '/user/chk_email', { email: email_address }, function (data) { if (data.resp === 1) { $("#user_email").addClass('success'); $("#recuperar").show(); } else { $("#user_email").removeClass('success'); $("#recuperar").hide(); } }, "json"); } }); if (security_email_motor == "1") { $('#user_email2').focusout(function () { var email_address = $('#user_email2').val().toLowerCase(); if (validateEmail(email_address)) { $.post(core_url + '/user/chk_email', { email: email_address }, function (data) { if (data.resp === 1) { $("#user_email2").addClass('success'); $("#recuperar").show(); } else { $("#user_email2").removeClass('success'); $("#recuperar").hide(); } }, "json"); } }); } } else { user_phone = new LiveValidation('user_phone', { wait: 3000 }); user_phone.add(Validate.Length, { minimum: 7 }); user_phone.add(Validate.Presence, { failureMessage: necesario }); //nombre user_first_name = new LiveValidation('user_first_name', { wait: 3000 }); user_first_name.add(Validate.Presence, { failureMessage: necesario }); //apellido user_last_name = new LiveValidation('user_last_name', { wait: 3000 }); user_last_name.add(Validate.Presence, { failureMessage: necesario }); user_last_name = new LiveValidation('user_email', { wait: 3000 }); user_last_name.add(Validate.Presence, { failureMessage: necesario }); //teléfono user_phone = new LiveValidation('user_phone', { wait: 3000 }); user_phone.add(Validate.Length, { minimum: 7 }); user_phone.add(Validate.Presence, { failureMessage: necesario }); $('#user_phone').bind('keypress', function (e) { if (e.keyCode === 13) { $('#reg_button').click(); } }); if (security_email_motor == "1") { user_email = new LiveValidation('user_email2', { validMessage: "" }); user_email.add(Validate.Confirmation, { match: 'user_email', failureMessage: same_email }); } if (security_phone_motor == "1") { user_phone = new LiveValidation('user_phone2', { validMessage: "" }); user_phone.add(Validate.Confirmation, { match: 'user_phone', failureMessage: same_phone }); } } } // Comprueba que no haya datos en blanco y registra al usuario en caso de no estarlo function validate() { $('#btn-validate').attr('disabled', 'disabled'); $('#loading_system_email').show(); var allergens = false; var commentary = $('#commentary').val(); var user_email = $('#user_email').val(); var user_phone = $('#user_phone').val(); var birthday = $('#birthday').val(); user_phone = check_phone(user_phone); user_email = check_email(user_email); if (security_email_motor == "1") { var user_email2 = $('#user_email2').val(); var emailValid = validateEmail2(user_email, user_email2); if (emailValid === 1) { emailValid = false; var not_same = true; } else { var not_same = false; } } else { var emailValid = validateEmail(user_email); var not_same = false; } var not_samephone = false; var phoneValid = true; if (security_phone_motor == "1") { phoneValid = $('#user_phone').val() == $('#user_phone2').val(); not_samephone = !phoneValid; } var type_2_landing = false; if (type_landing == 2) { emailValid = true; type_2_landing = true; } if (type_landing == 3) { text13 = text13a; } if (type_landing == 3 && $('#user_phone').val() !== '') { emailValid = true; type_2_landing = true; } var date = $('#datepicker').val(); if (hour_motor_conf) { var hour = $('#timepicker_motor').val(); hour = get_cover_hour(hour); } else { var hour = $('#hour-box-select').val(); } var user_first_name = $('#user_first_name').val(); var user_last_name = $('#user_last_name').val(); var postal_code = $('#postal_code').val(); var country = $('#country_select').val(); var consentimiento_legal = $('#consentimiento_legal').is(":checked"); var subscribe_newsletter = $('#subscribe_newsletter').is(':checked') ? 1 : 0; var data_treatment_consent = $('#data_treatment_consent').is(':checked') ? 1 : 0; var int_call_code = $('#int_call_code').val(); var allergens_text = ''; if ($('#has_food_restrictions').is(':checked') === true) { if ($('#food_restrictions').val() !== '') { allergens_text += allergens_lang_text + $('#food_restrictions').val(); } allergens = true; } if ($('#no_food_restrictions').is(':checked') === true || $('#aller').length == 0) { allergens = true; } if (!$("#consentimiento_legal").is(":visible")) { consentimiento_legal = true; } var commentary_required_empty = 0; if (commentary_required == 1 && commentary_shown == 1 && $('#commentary').val() == "") { commentary_required_empty = 1; } var reserve_type = $('input[name="reserveType"]:checked').val() || 1; var prescriber_name = $('#prescriber_name').val(); var prescriber_intcallcode = $('#prescriber_intcallcode').val(); var prescriber_phone = $('#prescriber_phone').val(); var prescriber_email = $('#prescriber_email').val(); var prescriber_province = $('#prescriber_province').val(); var prescriber_postalcode = $('#prescriber_postalcode').val(); if (consentimiento_legal || personal_data_check_shown_motores == 0) { if (newsletter_obli_motores == 0 || subscribe_newsletter == 1 || subscribe_check_shown_motores == 0) { if ((type_2_landing && user_last_name !== '' && user_first_name !== '') || (reserve_type == 2 && user_first_name !== '' && user_last_name !== '') || (reserve_type == 1 && user_email !== '' && user_first_name !== '' && user_last_name !== '' && user_phone !== '' && (postal_code !== '' || country == undefined))) { if ((emailValid && phoneValid) || reserve_type == 2) { if ((obligate_birthday == 0) || (obligate_birthday == 1 && birthday !== '')) { if (invoice_generate_reserv == 0 || (invoice_generate_reserv == 1 && required_billing_information == 0) || parseInt(product_tag) == 1 || (parseInt(product_tag) !== 1 && invoice_generate_reserv == 1 && required_billing_information == 1 && check_invoice_data())) { if (commentary_required_empty == 0) { if (isNaN(user_phone) == false || ectd_client === true) { if (allergens == true) { validateRecaptcha(function(recaptchaToken) { if (id_reserv != null) { email_tag = user_email; $.post(core_url + '/pay/validate', { recaptchaToken: recaptchaToken, st: st, language: language, phone: user_phone, name: user_first_name, last_name: user_last_name, email: user_email, id_reserv: id_reserv, int_call_code: int_call_code, allergens_text: allergens_text, postal_code: postal_code, birthday: birthday, country: country, subscribe_newsletter: subscribe_newsletter, data_treatment_consent: data_treatment_consent, date: date, hour: hour, extra: extra_avaible_reserv_module, type_landing: type_landing, restaurant: restaurant, ectd_client: ectd_client, skip_blocked_tables: skipBlockedTables, reserve_type: reserve_type, prescriber_name: prescriber_name, prescriber_intcallcode: prescriber_intcallcode, prescriber_phone: prescriber_phone, prescriber_email: prescriber_email, prescriber_province: prescriber_province, prescriber_postalcode: prescriber_postalcode }, function (data) { if (data.resp == 1) { havequestions = data.havequestions; havequestionsmenu = data.havequestionsmenu; if (extra_pos == -1) { if (data.haveclassify) { haveclassify(); } else { if (data.havequestions || data.havequestionsmenu) { if (data.havequestionsmenu) { havemenu(); } else { havequestion(); } } else { id_resps = false; check_pay(); } } } else { if (data.haveclassify) { haveclassify(); } else { if (data.havequestions) { havequestion(); } else { id_resps = false; check_pay(); } } } } else { $('#finish_reserv_system').removeAttr('disabled'); $('#loading_system_email').hide(); $('#btn-validate').removeAttr('disabled'); alert(data.error_text); } }, "json"); } else { email_tag = user_email; $.post(core_url + '/pay/validate', { recaptchaToken: recaptchaToken, st: st, language: language, phone: user_phone, name: user_first_name, last_name: user_last_name, email: user_email, birthday: birthday, int_call_code: int_call_code, allergens_text: allergens_text, postal_code: postal_code, country: country, subscribe_newsletter: subscribe_newsletter, data_treatment_consent: data_treatment_consent, date: date, hour: hour, extra: extra_avaible_reserv_module, restaurant: restaurant, type_landing: type_landing, ectd_client: ectd_client, reserve_type: reserve_type, prescriber_name: prescriber_name, prescriber_intcallcode: prescriber_intcallcode, prescriber_phone: prescriber_phone, prescriber_email: prescriber_email, prescriber_province: prescriber_province, prescriber_postalcode: prescriber_postalcode }, function (data) { if (data.resp == 1) { havequestions = data.havequestions; havequestionsmenu = data.havequestionsmenu; if (extra_pos == -1) { if (data.haveclassify) { haveclassify(); } else { if (data.havequestions || data.havequestionsmenu) { if (data.havequestionsmenu) { havemenu(); } else { havequestion(); } } else { id_resps = false; check_pay(); } } } else { if (data.haveclassify) { haveclassify(); } else { if (data.havequestions) { havequestion(); } else { id_resps = false; check_pay(); } } } } else { $('#finish_reserv_system').removeAttr('disabled'); $('#loading_system_email').hide(); $('#btn-validate').removeAttr('disabled'); alert(data.error_text); } }, "json"); } }); } else { $('#finish_reserv_system').removeAttr('disabled'); $('#loading_system_email').hide(); $('#btn-validate').removeAttr('disabled'); alert(text16); } } else { $('#finish_reserv_system').removeAttr('disabled'); $('#loading_system_email').hide(); $('#btn-validate').removeAttr('disabled'); alert(text20); } } else { $('#finish_reserv_system').removeAttr('disabled'); $('#loading_system_email').hide(); $('#btn-validate').removeAttr('disabled'); alert(text19); } } else { $('#finish_reserv_system').removeAttr('disabled'); $('#loading_system_email').hide(); $('#btn-validate').removeAttr('disabled'); alert(data_invoice); } } else { $('#finish_reserv_system').removeAttr('disabled'); $('#loading_system_email').hide(); $('#btn-validate').removeAttr('disabled'); alert(obligate_birthday_text); } } else { $('#finish_reserv_system').removeAttr('disabled'); $('#loading_system_email').hide(); $('#btn-validate').removeAttr('disabled'); if (!emailValid) { if (not_same) { alert(not_same_email); } else { alert(text12); } } if (!phoneValid && not_samephone) { alert(not_same_phone); } } } else { $('#finish_reserv_system').removeAttr('disabled'); $('#loading_system_email').hide(); $('#btn-validate').removeAttr('disabled'); if (askcountry == 1) { alert(text13); } else { alert(text13b); } } } else { $('#finish_reserv_system').removeAttr('disabled'); $('#loading_system_email').hide(); $('#btn-validate').removeAttr('disabled'); alert(check_mark_obli + ' "' + legal_check_3_motores[language].replace(/(<([^>]+)>)/gi, "") + '"'); } } else { $('#finish_reserv_system').removeAttr('disabled'); $('#loading_system_email').hide(); $('#btn-validate').removeAttr('disabled'); if (!consentimiento_legal && personal_data_check_shown_motores == 1) { alert(check_mark_obli + ' "' + legal_check_2_motores[language].replace(/(<([^>]+)>)/gi, "") + '"'); } } } function check_invoice_data() { let typeDocumentInvoice = $('#type_document_invoice').val(); let dniCifInvoice = $('#dni_cif_invoice').val(); if (typeDocumentInvoice == 1 && dniCifInvoice != '' && !checkValidDNI(dniCifInvoice)) { return false; } if (check_billing_info_required(preciopagado)) { return true; } let nameInvoice = $('#name_invoice').val(); let postalCodeInvoice = $('#postal_code_invoice').val(); let addressInvoice = $('#address_invoice').val(); let localityInvoice = $('#locality_invoice').val(); let provinceInvoice = $('#province_invoice').val(); let typeClient = $('#type_client').val(); if (isNecessaryCard === false) { return true; } else { if (nameInvoice != '' && dniCifInvoice != '' && postalCodeInvoice != '' && addressInvoice != '' && localityInvoice != '' && provinceInvoice != '' && typeDocumentInvoice != '' && typeClient != '' ) { return true; } else { return false; } } } function checkValidDNI(value) { var validChars = 'TRWAGMYFPDXBNJZSQVHLCKET'; var nifRexp = /^[0-9]{8}[TRWAGMYFPDXBNJZSQVHLCKET]$/i; var nieRexp = /^[XYZ][0-9]{7}[TRWAGMYFPDXBNJZSQVHLCKET]$/i; var str = value.toString().toUpperCase(); if (!nifRexp.test(str) && !nieRexp.test(str)) return false; var nie = str .replace(/^[X]/, '0') .replace(/^[Y]/, '1') .replace(/^[Z]/, '2'); var letter = str.substr(-1); var charIndex = parseInt(nie.substr(0, 8)) % 23; if (validChars.charAt(charIndex) === letter) { return true; } alert(dataDNIWrong); return false; } function check_billing_info_required(preciopagado = 0) { if (product_tag === 0) { return false; } let attribute = ''; switch (product_tag) { case 1: attribute = 'free_reserv'; break; case 2: attribute = 'cancelp_reserv'; break; case 3: attribute = 'ticket_reserv'; break; default: attribute = ''; } let applyLimit = limitAmountBullingDataReserv && (typeof limitAmountBullingDataReserv.active !== 'undefined') && parseInt(limitAmountBullingDataReserv.active) === 1 && limitAmountBullingDataReserv.limit_amount !== 0 && preciopagado >= limitAmountBullingDataReserv.limit_amount; if (typeReserveBillingInfoRequired[attribute] === false) { return true; } if (typeReserveBillingInfoRequired[attribute] === true && limitAmountBullingDataReserv && parseInt(limitAmountBullingDataReserv.active) === 0) { return false; } return ((!applyLimit && typeReserveBillingInfoRequired[attribute]) || ( parseInt(limitAmountBullingDataReserv.active) == 0 && parseInt(required_billing_information) == 1 && parseInt(product_tag) == 3 )); } function validate_ticket() { $('#btn-validate_ticket').attr('disabled', 'disabled'); var date = $('#datepicker').val(); var ticket = $('#ticket').val(); var people = $('#people-box-select').val(); if (hour_motor_conf) { var hour = $('#timepicker_motor').val(); hour = get_cover_hour(hour); } else { var hour = $('#hour-box-select').val(); } $.post(core_url + '/Reservs/code_check_module', { restaurant: restaurant, ticket: ticket, people: people, date: date, hour: hour, language: language, origin: origin }, function (data) { if (data.resp == 1) { //cuando el ticket ya se ha usado tiene reserva asociada if (data.id_reserv != -1) { alert(validatetext8); $('#btn-validate_ticket').removeAttr('disabled'); } else { alert(validatetext5); code = ticket; $('#ticket').css('display', 'none'); $('.header_ticket_es').css('display', 'none'); $('.header_ticket_es_second').css('display', 'none'); $('#btn-validate_ticket').css('display', 'none'); $('#code').html(validatetext7 + " " + code + "
" + validatetext9 + " " + data.product_name + "
" + validatetext10 + " " + data.people); if (data.type_discount === undefined || data.type_discount === null || data.type_discount == '') { redeem = true; has_discount = false; $('.product-name, .product-price, .product-price-total, .product-description').text(''); $('#price_product_special').hide(); } else { redeem = false; has_discount = true; has_origin_correct = data.has_origin_correct; // Add the discount text next to the total price var new_price_discount = ''; var preciototalpagado = preciopagado; if (shopping_cart == 1) { preciototalpagado = prix_totalproducts; if (data.mode_discount === '1') { new_price_discount = preciototalpagado - (parseInt(data.amount_discount) / 100); } else { var discount = parseInt(data.amount_discount) / 100 * preciototalpagado; new_price_discount = preciototalpagado - discount; } } else { if (data.mode_discount === '1') { new_price_discount = preciototalpagado - (parseInt(data.amount_discount) / 100); } else { var discount = parseInt(data.amount_discount) / 100 * preciototalpagado; new_price_discount = preciototalpagado - discount; } } if (new_price_discount !== '') { new_price_discount = parseFloat(new_price_discount).toFixed(2); new_price_discount_global = new_price_discount; } $('#datos_personales .product-price-total').parent().append(", " + total_product_discount + ': ' + print_price_currency(new_price_discount, currency_str) + ' ' + iva_incluido + ""); $('#pay-box .product-price-total').parent().append(", " + total_product_discount + ': ' + print_price_currency(new_price_discount, currency_str) + ' ' + iva_incluido + ""); } } } else { if (data.errormssg != undefined) { alert(data.errormssg); } else { alert(validatetext6); } $('#btn-validate_ticket').removeAttr('disabled'); $('#ticket').val(""); } }, "json"); $('#btn-validate').removeAttr('disabled'); } function validate_ticket_es() { $('#btn-validate_ticket_es').attr('disabled', 'disabled'); var date = $('#datepicker').val(); var ticket = $('#ticket_es').val(); var people = $('#people-box-select').val(); if (hour_motor_conf) { var hour = $('#timepicker_motor').val(); hour = get_cover_hour(hour); } else { var hour = $('#hour-box-select').val(); } $.post(core_url + '/Reservs/code_check_module', { restaurant: restaurant, ticket: ticket, people: people, date: date, hour: hour, language: language, origin: origin }, function (data) { if (data.resp == 1) { //cuando el ticket ya se ha usado tiene reserva asociada if (data.id_reserv != -1) { alert(validatetext8); $('#btn-validate_ticket_es').removeAttr('disabled'); } else { alert(validatetext5); code = ticket; $('#ticket_es').css('display', 'none'); $('.header_ticket_es').css('display', 'none'); $('.header_ticket_es_second').css('display', 'none'); $('#have').css('display', 'none'); $('#btn-validate_ticket_es').css('display', 'none'); $('#code').html(validatetext7 + " " + code + "
" + validatetext9 + " " + data.product_name + "
" + validatetext10 + " " + data.people); $('#code_es').html(validatetext7 + " " + code + "
" + validatetext9 + " " + data.product_name + "
" + validatetext10 + " " + data.people); if (data.type_discount === undefined || data.type_discount === null || data.type_discount == '') { redeem = true; has_discount = false; $('.product-name, .product-price, .product-price-total, .product-description').text(''); $('#price_product_special').hide(); } else { redeem = false; has_discount = true; has_origin_correct = data.has_origin_correct; // Add the discount text next to the total price var new_price_discount = ''; var preciototalpagado = preciopagado; if (shopping_cart == 1) { preciototalpagado = prix_totalproducts; if (data.mode_discount === '1') { new_price_discount = preciototalpagado - (parseInt(data.amount_discount) / 100); } else { var discount = parseInt(data.amount_discount) / 100 * preciototalpagado; new_price_discount = preciototalpagado - discount; } } else { if (data.mode_discount === '1') { new_price_discount = preciototalpagado - (parseInt(data.amount_discount) / 100); } else { var discount = parseInt(data.amount_discount) / 100 * preciototalpagado; new_price_discount = preciototalpagado - discount; } } if (new_price_discount !== '') { new_price_discount = parseFloat(new_price_discount).toFixed(2); new_price_discount_global = new_price_discount; } $('#pay-box .product-price-total').parent().append(", " + total_product_discount + ': ' + print_price_currency(new_price_discount, currency_str) + ' ' + iva_incluido + ""); } } } else { if (data.errormssg != undefined) { alert(data.errormssg); } else { alert(validatetext6); } $('#btn-validate_ticket_es').removeAttr('disabled'); $('#ticket_es').val(""); } }, "json"); $('#btn-validate').removeAttr('disabled'); } function havequestion() { if (havequestions) { $('#system_email_motor').hide(); $.post(core_url + '/Reservation/question_restaurant', { language: language, restaurant: restaurant, }, function (data) { $('#btn-validate').removeAttr('disabled'); questions = data.questions; $('#login_box').hide(); $('#info-box').hide(); $('#selection_menu_free').hide(); $('#questions_restaurant').show(); $('#questions_restaurant').html(data.questions_restaurant); $('#buttonquestionsreserv').html($('#reg_button > button').html()); }, "json"); } else { savequestionInformation(); } } function haveclassify() { $('#system_email_motor').hide(); numpeople_reserv = $('#people-box-select').val(); nummenu_select = 0; $.post(core_url + '/Reservation/classify_restaurant', { language: language, restaurant: restaurant }, function (data) { $('#btn-validate').removeAttr('disabled'); questions = data.questions; nummenu_posibility = data.nummenu; $('#login_box').hide(); $('#info-box').hide(); $('#selection_menu_free').hide(); $('#selection_menu_free').html(''); $('#selection_menu_free').show(); $('#selection_menu_free').html(data.questions_restaurant); $('#menu_classify').html($('#reg_button > button').html()); }, "json"); } function havemenu() { if (havequestionsmenu) { $('#system_email_motor').hide(); numpeople_reserv = $('#people-box-select').val(); nummenu_select = 0; $.post(core_url + '/Reservation/menu_restaurant', { language: language, restaurant: restaurant }, function (data) { $('#btn-validate').removeAttr('disabled'); questions = data.questions; nummenu_posibility = data.nummenu; $('#login_box').hide(); $('#info-box').hide(); $('#selection_menu_free').show(); $('#selection_menu_free').html(data.questions_restaurant); $('#menu_question').html($('#reg_button > button').html()); }, "json"); } else { havequestion(); } } function restproduct_menu(id) { var num = parseInt(document.getElementById('numbermenu' + id).value); if (num - 1 < 0) { alert(menumenorcero); } else { document.getElementById('numbermenu' + id).value = num - 1; nummenu_select--; } } function sumproduct_menu(id) { var num = parseInt(document.getElementById('numbermenu' + id).value); if (nummenu_select + 1 > numpeople_reserv) { alert(menuigualpeople); } else { document.getElementById('numbermenu' + id).value = num + 1; nummenu_select++; } } function restproduct_classify(id) { var num = parseInt(document.getElementById('numberclassify' + id).value); if (num - 1 < 0) { alert(classifymenorcero); } else { document.getElementById('numberclassify' + id).value = num - 1; nummenu_select--; } } function sumproduct_classify(id) { var num = parseInt(document.getElementById('numberclassify' + id).value); if (nummenu_select + 1 > numpeople_reserv) { alert(classifyigualpeople); } else { document.getElementById('numberclassify' + id).value = num + 1; nummenu_select++; } } function savemenuInformation() { $('#menu_question').attr('disabled', 'disabled'); if (nummenu_select == numpeople_reserv) { menuseleccionados = []; for (var i = 0; i < nummenu_posibility; i++) { if (parseInt(document.getElementById('numbermenu' + i).value) > 0) { menuseleccionados[i] = parseInt(document.getElementById('numbermenu' + i).value); } } havequestion(); } else { $('#menu_question').removeAttr('disabled'); alert(menuigualpeople_next); } } function saveclassifyInformation() { $('#menu_classify').attr('disabled', 'disabled'); if (nummenu_select == numpeople_reserv) { classifyseleccionados = []; for (var i = 0; i < nummenu_posibility; i++) { if (parseInt(document.getElementById('numberclassify' + i).value) > 0) { classifyseleccionados[i] = parseInt(document.getElementById('numberclassify' + i).value); } } havemenu(); } else { $('#menu_classify').removeAttr('disabled'); alert(classifyigualpeople_next); } } function savequestionInformation() { const MAX_RESPONSE_CHARS = 250; $('#buttonquestionsreserv').attr('disabled', 'disabled'); var respquestion = false; var validateMaxResponseChars = true; var required_questions = []; if (havequestions) { var contador = 0; var contador4 = 0; var aux = false; respquestion = {}; for (var index in questions) { if (questions[index].motoroff == 0) { if (questions[index].tipo == 1 || questions[index].tipo == 3) { var contador2 = 0; var optionsselect = []; if (questions[index].tipo == 3) { contador4++; var contador3 = 0; var contador5 = 0; for (var index2 in questions[index].possibleresp) { if (document.getElementById('response_' + contador + '_' + contador5).checked) { contador3++; } contador5++; } if (contador3 == 0) { aux = true; var questionnumber = parseInt(index) + 1; } } for (var index2 in questions[index].possibleresp) { if (document.getElementById('response_' + contador + '_' + contador2).checked) { optionsselect.push(contador2); } contador2++; } respquestion[questions[index].id_question] = optionsselect; } else { if (questions[index].tipo == 2) { let responseQuestion = $("#response_" + contador).val(); if (responseQuestion.length > MAX_RESPONSE_CHARS) { validateMaxResponseChars = false; } else { respquestion[questions[index].id_question] = responseQuestion; } } } if (questions[index].requiredanswer == 1 && (questions[index].tipo == 1 || questions[index].tipo == 2)) { var num_q = parseInt(index) + 1; var answer = respquestion[questions[index].id_question] != '' ? true : false; required_questions.push({ 'answer': answer, 'num_question': num_q }); } } contador++; } } if (contador4 > 0 && aux) { $('#buttonquestionsreserv').removeAttr('disabled'); alert(checkedtest + questionnumber); } else if (!validateMaxResponseChars) { $('#buttonquestionsreserv').removeAttr('disabled'); alert(alertMaxResponseChars); } else if (required_questions.filter((q) => q.answer === false).length > 0) { $('#buttonquestionsreserv').removeAttr('disabled'); required_questions.forEach(r_quest => { if (!r_quest.answer) { alert(checked_required_answer + r_quest.num_question); } }); } else { $.post(core_url + '/Reservation/savequestionInformation', { language: language, restaurant: restaurant, respquestion: respquestion, menuseleccionados: menuseleccionados, classifyseleccionados: classifyseleccionados, }, function (data) { id_resps = data.id_resps; check_pay(); }, "json"); } } function gobackdatospersonales() { ectd_client = false; $('#user_first_name').val(''); $('#user_last_name').val(''); $('#user_phone').val(''); $('#comment_text').val(''); $('#questions_restaurant').hide(); $('#selection_menu_free').hide(); $('#login_box').show(); $('#info-box').show(); jQuery('#datos_personales').show(); jQuery('#reg_button').show(); jQuery('.condiciones').show(); $('#button_search_email').removeAttr('disabled'); jQuery('#second_step_system').hide(); jQuery('#first_step_system').show(); $('#finish_reserv_system').removeAttr('disabled'); $('#loading_system_email').hide(); } // comprobación de pago function check_pay() { var date = $('#datepicker').val(); var people = $('#people-box-select').val(); if (hour_motor_conf) { var hour = $('#timepicker_motor').val(); hour = get_cover_hour(hour); } else { var hour = $('#hour-box-select').val(); } if (motor_first_product == 0) { var extra = -1; if (shopping_cart == 1) { if (productextras.length != 0) { extra = productextras; } else { if ($('#extra-box-select').length) { extra = $('#extra-box-select').val(); } } } else { if (selected != '') { extra = selected; } else { if ($('#extra-box-select').length) { extra = $('#extra-box-select').val(); } } } } else { var selection = $('#extra-box-select-product').val(); var extra = $('#extra-box-select').val(); if (extra == undefined) { extra_string = ''; var array = { "1": 'x', "2": -1, "3": selection }; extra = JSON.stringify(array); } else { extra_string = text5 + $('#extra-box-select option:selected').text(); extra = JSON.parse(extra); extra["3"] = selection; extra = JSON.stringify(extra); } } extra_adyen = extra; var user_first_name = $('#user_first_name').val(); var user_last_name = $('#user_last_name').val(); var birthday = $('#birthday').val(); var user_email = $('#user_email').val(); var int_call_code = $('#int_call_code').val(); var user_phone = $('#user_phone').val(); var postal_code = $('#postal_code').val(); var country = $('#country_select').val(); var commentary = $('#commentary').val(); var allergens_text = ''; if (show_extra_field) { var extra_field_client = $('#extra_field_client').val(); } else { var extra_field_client = false; } if ($('#has_food_restrictions').is(':checked') === true && $('#food_restrictions').val() !== '') { allergens_text += allergens_lang_text + $('#food_restrictions').val(); } var subscribe_newsletter = $('#subscribe_newsletter').is(':checked') ? 1 : 0; var data_treatment_consent = $('#data_treatment_consent').is(':checked') ? 1 : 0; if (invoice_generate_reserv == 1) { var nameInvoice = $('#name_invoice').val(); var dniCifInvoice = $('#dni_cif_invoice').val(); var postalCodeInvoice = $('#postal_code_invoice').val(); var addressInvoice = $('#address_invoice').val(); var localityInvoice = $('#locality_invoice').val(); var provinceInvoice = $('#province_invoice').val(); var typeDocumentInvoice = $('#type_document_invoice').val(); var typeClient = $('#type_client').val(); } else { var nameInvoice = false; var dniCifInvoice = false; var postalCodeInvoice = false; var addressInvoice = false; var localityInvoice = false; var provinceInvoice = false; var typeDocumentInvoice = false; var typeClient = false; } var reserve_type = $('input[name="reserveType"]:checked').val() || 1; var prescriber_name = $('#prescriber_name').val(); var prescriber_intcallcode = $('#prescriber_intcallcode').val(); var prescriber_phone = $('#prescriber_phone').val(); var prescriber_email = $('#prescriber_email').val(); var prescriber_province = $('#prescriber_province').val(); var prescriber_postalcode = $('#prescriber_postalcode').val(); $('#tiket').hide(); $('#p_cancel').hide(); $('#hold_card').hide(); // ya está validado todo, vemos si necesitamos tarjeta if (shopping_cart == 0) { numberproducts = false; } $.post(core_url + '/Pay/use_card', { vip: getVipReservationValue(), language: language, dia: date, hour: hour, restaurant: restaurant, people: people, extra: extra, birthday: birthday, extra_field_client: extra_field_client, phone: user_phone, name: user_first_name, last_name: user_last_name, room_number: room_number_pre, email: user_email, id_reserv: id_reserv, int_call_code: ectd_client === true ? ectd_client_int_call_code : int_call_code, allergens_text: allergens_text, postal_code: postal_code, country: ectd_client === true ? ectd_client_country : country, subscribe_newsletter: subscribe_newsletter, data_treatment_consent: data_treatment_consent, commentary: commentary, type_landing: type_landing, redeem: redeem, numberproducts: numberproducts, id_resps: id_resps, menuseleccionados: menuseleccionados, has_discount: has_discount, code: code, origin: origin, org: org, name_invoice: nameInvoice, type_document_invoice: typeDocumentInvoice, type_client: typeClient, dni_cif_invoice: dniCifInvoice, postal_code_invoice: postalCodeInvoice, address_invoice: addressInvoice, locality_invoice: localityInvoice, province_invoice: provinceInvoice, ectd_client: ectd_client, skip_blocked_tables : skipBlockedTables, reserve_type: reserve_type, prescriber_name: prescriber_name, prescriber_intcallcode: prescriber_intcallcode, prescriber_phone: prescriber_phone, prescriber_email: prescriber_email, prescriber_province: prescriber_province, prescriber_postalcode: prescriber_postalcode, crossIdRestOrigin: crossIdRestOrigin, reference: adyenTypeMotor, utm_emailmarketing: utm_emailmarketing || false, }, function (data) { pay_type_use = data.pay_type_use; product_use_card = data.product; isSetupIntent = data.isSetupIntent; var data_use_card = data; if (data.resp == 0) { $('#finish_reserv_system').removeAttr('disabled'); $('#loading_system_email').hide(); $('#buttonquestionsreserv').removeAttr('disabled'); $('#btn-validate').removeAttr('disabled'); alert(data.error_text); } else { paymentCountryCode = data.country; paymentName = data.labelTotalStripe; paymentEmail = user_email; pay_type_use_secure = data.pay_type_use_secure; if (data_use_card.card == 1 && !redeem) { if (data_use_card.pay_type_use !== null && data_use_card.pay_type_use == 2) { $('#btn-validate').removeAttr('disabled'); // pide tarjeta $('#login_box').hide(); $('#info-box').hide(); $('#questions_restaurant').hide(); $('#selection_menu_free').hide(); $('#system_email_motor').hide(); $('#pay-box').show(); $.post(core_url + '/api2/DataCash/setup_datacash', { language: language, day: date, hour: hour, restaurant: restaurant, people: people, extra: extra, phone: user_phone, int_call_code: int_call_code, postal_code: postal_code, country: country, first_name: user_first_name, last_name: user_last_name, email: user_email, commentary: commentary, allergens_text: allergens_text, subscribe_newsletter: subscribe_newsletter, data_treatment_consent: data_treatment_consent, data_card: data, id_resps: id_resps, menuseleccionados: menuseleccionados, room_number: room_number_pre }, function (data) { if (data.url !== null && data.url !== '') { window.open(data.url, 'DataCas', 'height=750, width=1024'); } else if (data.error !== null && data.error !== '') { alert(data.error); } }, "json"); } else { // if it is a stripe payment if (data_use_card.pay_type_use !== null && ( data_use_card.pay_type_use == 0 || data_use_card.pay_type_use == 3 ) ) { let elementsObject = { mode: 'payment', currency: data.currencyStripe, amount: data.amount_total, setup_future_usage: 'off_session', locale: languagestripe }; if (isSetupIntent || data_use_card.product == 2) { elementsObject.mode = 'setup'; delete elementsObject.amount; } if (!isSetupIntent && data_use_card.product == 5) { elementsObject.captureMethod = 'manual'; } elements = stripe.elements(elementsObject); paymentElement = elements.create('payment', stripeObjectConfig); } if (data_use_card.pay_type_use !== null && data_use_card.pay_type_use == 6) { // DIVILO $('#login_box').hide(); $('#info-box').hide(); $('#questions_restaurant').hide(); $('#selection_menu_free').hide(); $('#system_email_motor').hide(); $('#pay-box').show(); $('.creditcard').hide(); id_reserv_divilo = data.id_reserv; amount_total_divilo = data.amount_total; code_divilo = data.code; selection = $('#extra-box-select-product').val(); extra = $('#extra-box-select').val(); if (extra == undefined) { extra_string = ''; var array = { "1": 'x', "2": -1, "3": selection }; extra_divilo = JSON.stringify(array); } else { extra_string = text5 + $('#extra-box-select option:selected').text(); extra = JSON.parse(extra); extra["3"] = selection; extra_divilo = JSON.stringify(extra); } if (data.product == 3){ createPayments(data.id_reserv, data.amount_total, data.code); } if (data.product == 2){ createPaymentTokenize(data.id_reserv, data.amount_total, data.token_reserv, data.id_user, data.end_date); } window.addEventListener("message", receiveMessageFromIframePage, false); } if (data_use_card.pay_type_use !== null && data_use_card.pay_type_use == 11) { let env = data.env; let client = data.client; let sessionID = data.sessionID; let sessionData = data.sessionData; let paymentMethodsRequest = data.paymentMethods; merchant = data.merchant; amount = data.amount_total; reserv_token = data.id_reserv; pay_code = data.code; currency = data.currency; locale = data.locale; reference = data.reference; initAdyen(env, client, sessionID, sessionData, paymentMethodsRequest, locale, 'create'); $('#login_box').hide(); $('#info-box').hide(); $('#questions_restaurant').hide(); $('#selection_menu_free').hide(); $('#system_email_motor').hide(); $('.creditcard').hide(); $('#pay-box').show(); } if (data_use_card.pay_type_use !== null && data_use_card.pay_type_use == 0) { // STRIPE WIHOUT 3D SECURE if (data_use_card.iframeOpeningOption == 1 || (data_use_card.iframeOpeningOption == 2 && isMobileDevice())) { paymentIntent = data_use_card.id; amountTotal = data.amount_total; $('#insert-card').show(); $('#pay_button').hide(); } else { paymentElement.mount('#payment-elements'); } $('#login_box').hide(); $('#info-box').hide(); $('#questions_restaurant').hide(); $('#selection_menu_free').hide(); $('#system_email_motor').hide(); $('#pay-box').show(); if (data_use_card.product == 2 && !redeem) { if (data_use_card.p_cancel_hours == -1) { $('.havehour').hide(); } else { $('.nohour').hide(); $('.p_cancel_hours').html(translate_hours(data_use_card.p_cancel_hours)); } if (data_use_card.product == 5) { $('#hold_card').show(); } else { $('#p_cancel').show(); } $('.p_cancel_people').html(print_price_currency(data_use_card.p_cancel_people, currency_str)); $('.p_cancel').html(data_use_card.p_cancel); $('.amount').html(data_use_card.amount); $('#resume_cart').html(data_use_card.resume_cart); if (data_use_card.message_pol_cancel != false && data_use_card.message_pol_cancel != undefined) { $('#p_cancel_personalize').html(data_use_card.message_pol_cancel); $('#p_cancel_personalize').show(); $('#p_cancel').hide(); $('#hold_card').hide(); } } if (data_use_card.product == 3 && !redeem) { // ticket $('.amount').html(data_use_card.amount); if (shopping_cart == 1) { productos = data.products; if (data.products !== undefined && data.products !== null && data.products !== '') { $('#botonsumarproduct3').show(); } new_price_discount_global = data_use_card.amount_float; } $('#tiket').show(); $('#resume_cart').html(data_use_card.resume_cart); $('.price_ticket').html(data_use_card.amount); $('.price_total').html(data_use_card.amount_total_str); if (data_use_card.message_product != false && data_use_card.message_product != undefined) { $('#message_product_personalize').html(data_use_card.message_product); $('#message_product_personalize').show(); $('#message_product_normal').hide(); } } } else if (data_use_card.pay_type_use !== null && (data_use_card.pay_type_use == 3 || data_use_card.pay_type_use == 5 || data_use_card.pay_type_use == 11) && data_use_card.pay_type_use_secure == 1) { // STRIPE WITH 3D SECURE id_reserv_secure_stripe = data.id_reserv; if (id_reserv == null) { timeout = setTimeout(function () { alert(expired_reservation_time_comp); $('#container_module_reserv').hide(); $('body div:first').css({ "display": "none" }); $('#finish_reserv_time_out').show(); $('#alert_time').hide(); }, data.time_out_secure_stripe * 1000); if (!countdown_started) { count_down_general(data.time_out_secure_stripe); } $('#alert_time').show(); } if (data_use_card.pay_type_use == 3) { if (data_use_card.iframeOpeningOption == 1 || (data_use_card.iframeOpeningOption == 2 && isMobileDevice())) { paymentIntent = data_use_card.id; amountTotal = data.amount_total; $('#insert-card').show(); $('#pay_button').hide(); } else { // Mount and show the card form $('#pay_button').prop('data-secret', data.payment_intent_client_secret); paymentElement.mount('#payment-elements'); } } else if (data_use_card.pay_type_use == 5) { $('.creditcard').hide(); $('.payment_info').html(data.form_redsys); $('#tiket').addClass('text-center'); $('#pagoLogo').hide(); $('#redsys_go').show(); id_redsys = data.id; amount_total = data.amount_total; } $('#login_box').hide(); $('#info-box').hide(); $('#questions_restaurant').hide(); $('#selection_menu_free').hide(); $('#system_email_motor').hide(); $('#pay-box').show(); $('#closePayBoxReturnButton').hide(); if ((data_use_card.product == 2 || data_use_card.product == 5) && !redeem) { if (data_use_card.p_cancel_hours == -1) { $('.havehour').hide(); } else { $('.nohour').hide(); $('.p_cancel_hours').html(translate_hours(data_use_card.p_cancel_hours)); } if (data_use_card.product == 5) { $('#hold_card').show(); } else { $('#p_cancel').show(); } $('.p_cancel_people').html(print_price_currency(data_use_card.p_cancel_people, currency_str)); $('.p_cancel').html(data_use_card.p_cancel); if (data_use_card.hold_card_days_before) { $('.hold_card_days_before').html(data_use_card.hold_card_days_before); } $('.amount').html(data_use_card.amount); $('#resume_cart').html(data_use_card.resume_cart); if (data_use_card.message_pol_cancel != false && data_use_card.message_pol_cancel != undefined) { $('#p_cancel_personalize').html(data_use_card.message_pol_cancel); $('#p_cancel_personalize').show(); $('#p_cancel').hide(); $('#hold_card').hide(); } } if (data_use_card.product == 3 && !redeem) { // ticket $('.amount').html(data_use_card.amount); if (shopping_cart == 1) { productos = data_use_card.products; if (data.products !== undefined && data.products !== null && data.products !== '') { $('#botonsumarproduct3').show(); } new_price_discount_global = data_use_card.amount_float; } $('#tiket').show(); $('#resume_cart').html(data_use_card.resume_cart); $('.price_ticket').html(data_use_card.price_people_str); $('.price_total').html(data_use_card.amount_total_str); if (data_use_card.message_product != false && data_use_card.message_product != undefined) { $('#message_product_personalize').html(data_use_card.message_product); $('#message_product_personalize').show(); $('#message_product_normal').hide(); } } } else if (data_use_card.pay_type_use == 7) { //MercadoPago id_reserv_secure_stripe = data.id_reserv; var completed = false; $('#login_box').hide(); $('#info-box').hide(); $('#questions_restaurant').hide(); $('#selection_menu_free').hide(); $('#system_email_motor').hide(); $('#closePayBoxReturnButton').hide(); timeout = setTimeout(function () { $.post(core_url + '/coverv2/NReserv/getStatusByToken', { id_reserv: data.id_reserv, }, function (response) { if (response.status == "0") { alert(expired_reservation_time_comp); $('#alert_time').hide(); $('.mp-mercadopago-checkout-wrapper').hide(); $('#container_module_reserv').hide(); $('body div:first').css({ "display": "none" }); $('#finish_reserv_time_out').show(); $('#alert_time').hide(); completed = true; } }, "json"); }, data.time_out_secure_stripe * 1000); if (!completed) { if (!countdown_started) { count_down_general(data.time_out_secure_stripe); } } $('#alert_time').show(); $('.creditcard').hide(); const mercadopago = new MercadoPago(data.public_key, { locale: data.seller_locale }); mercadopago.checkout({ preference: { id: data.preference_id }, autoOpen: true, }); $('#tiket').addClass('text-center'); $('#pagoLogo').hide(); $('#text-redsys').show(); } else if (data_use_card.pay_type_use == 8) { //Paylands id_reserv_secure_stripe = data.id_reserv; var completed = false; $('#login_box').hide(); $('#info-box').hide(); $('#questions_restaurant').hide(); $('#selection_menu_free').hide(); $('#system_email_motor').hide(); $('#closePayBoxReturnButton').hide(); timeout = setTimeout(function () { $.post(core_url + '/coverv2/NReserv/getStatusByToken', { id_reserv: data.id_reserv, }, function (response) { $('#alert_time').hide(); if(response.status == "0"){ alert(expired_reservation_time_comp); $('#paylands').hide(); $('#container_module_reserv').hide(); $('body div:first').css({"display":"none"}); $('#finish_reserv_time_out').show(); $('#alert_time').hide(); completed = true; } }, "json"); }, data.time_out_secure_stripe * 1000); if (!completed) { if (!countdown_started) { count_down_general(data.time_out_secure_stripe); } } $('#alert_time').show(); $('.creditcard').hide(); var urlIframe = data.base_url + 'payment/process/' + data.preference_id; let iframeHtml =''; $('#paymentFrames').html('
'+iframeHtml+'
'); } } } else { // se reserva reserv(); } } }, "json"); } function receiveMessageFromIframePage(event) { switch (event.data.msg) { case 'OPERATION_KO': comprovePayDivilo(code_divilo, id_reserv_divilo); $('#alert_time').hide(); $('#divilo').hide(); break; case 'OPERATION_OK': comprovePayDivilo(code_divilo, id_reserv_divilo); $('#alert_time').hide(); $('#divilo').hide(); if (timeout) { clearTimeout(timeout); } break; } } function createPayments(id_reserv, amount_total, code) { $.post('/payments/DiviloPayment/getUrlIntegration', { }) .then(function onSuccess(response) { var url_integration = JSON.parse(response).url; const merchantId = sjcl.encrypt(DIVILO_SECRET, DIVILO_MERCHANT_ID); const acquirerBin = sjcl.encrypt(DIVILO_SECRET, DIVILO_ACQUIRER_ID); const key = sjcl.encrypt(DIVILO_SECRET, DIVILO_KEY); const terminal = sjcl.encrypt(DIVILO_SECRET, DIVILO_TERMINAL_ID); const orderId = sjcl.encrypt(DIVILO_SECRET, code); const amount = sjcl.encrypt(DIVILO_SECRET, amount_total.toString()); const description = sjcl.encrypt(DIVILO_SECRET, 'Reserva ' + id_reserv); const regExp = /=/g; var link = url_integration + btoa(merchantId).replace(regExp,".")+ "/"+ btoa(acquirerBin).replace(regExp,".")+ "/"+ btoa(key).replace(regExp,".")+ "/"+ btoa(terminal).replace(regExp,".")+ "/"+ btoa(orderId).replace(regExp,".")+ "/"+ btoa(amount).replace(regExp,".")+ "/"+ btoa(description).replace(regExp,"."); var iframe = document.createElement('iframe'); iframe.frameBorder = 0; iframe.width = "100%"; iframe.height = "400px"; iframe.id = "payment"; iframe.setAttribute("src", link); document.getElementById("iframe-divilo-container").appendChild(iframe); }); } function createPaymentTokenize(id_reserv, amount_total, token_reserv, id_user, end_date) { $.post('/payments/DiviloPayment/getUrlIntegration', { 'url': 'url_platform_payment_tokenize' }) .then(function onSuccess(response) { var url_integration = JSON.parse(response).url; const merchantId = sjcl.encrypt(DIVILO_SECRET, DIVILO_MERCHANT_ID); const acquirerBin = sjcl.encrypt(DIVILO_SECRET, DIVILO_ACQUIRER_ID); const key = sjcl.encrypt(DIVILO_SECRET, DIVILO_KEY); const terminal = sjcl.encrypt(DIVILO_SECRET, DIVILO_TERMINAL_ID); const orderId = sjcl.encrypt(DIVILO_SECRET, token_reserv); const amount = sjcl.encrypt(DIVILO_SECRET, amount_total.toString()); const desc = sjcl.encrypt(DIVILO_SECRET, 'Reserva ' + id_reserv); const userId = sjcl.encrypt(DIVILO_SECRET, id_user); // need change const endDate = sjcl.encrypt(DIVILO_SECRET, end_date); // need change, format YYYYMMDD const regExp = /=/g; var link = url_integration + btoa(merchantId).replace(regExp,".") + "/" + btoa(acquirerBin).replace(regExp,".") + "/" + btoa(key).replace(regExp,".") + "/" + btoa(terminal).replace(regExp,".") + "/" + btoa(orderId).replace(regExp,".") + "/" + btoa(userId).replace(regExp,".") + "/" + btoa(amount).replace(regExp,".") + "/" + btoa(desc).replace(regExp,".") + "/" + btoa(endDate).replace(regExp,"."); var iframe = document.createElement('iframe'); iframe.frameBorder=0; iframe.width="100%"; iframe.height="400px"; iframe.id="payment"; iframe.setAttribute("src", link); //document.getElementById('add-payment').style.display = 'none'; //document.getElementById('add-payment-token').style.display = 'none'; //document.getElementById('add-payment-tokenize').style.display = 'none'; document.getElementById("iframe-divilo-container").appendChild(iframe); }); } function comprovePayDivilo(code, reserv) { $.post('/payments/DiviloPayment/comprovePaymentDivilo', { 'code': code, 'reserv': reserv }, function (data) { if (data.resp == 1) { $.post(core_url + '/pay/pay_web_text_information', { restaurant: restaurant, id_reserv: id_reserv_divilo, extra: extra_divilo, numberproducts: numberproducts, redeem: redeem, code: code_divilo, origin: origin, amount_payment: amount_total_divilo, language: language }, function (data) { $('#btn-validate').removeAttr('disabled'); $('#buttonquestionsreserv').removeAttr('disabled'); if (data.resp == 1) { $("#loadingr50").hide(); $('#pay_button').removeAttr("disabled"); $('#loading').hide(); $("#loadingr50_n").hide(); $("#loadingr50_n").hide(); $('#finish_reserv_system').removeAttr('disabled'); $('#loading_system_email').hide(); $('#system_email_motor').hide(); $("#datos_personales").hide(); $("#pay-box").hide(); $("#pay-box-group_request").hide(); $('#questions_restaurant').hide(); $('#selection_menu_free').hide(); $('#end_box').show(); $('#alert_time').hide(); if (!isMarketplace() && data.htmlproductmotor.active == 1) { $('#product_motorhtml').html(data.htmlproductmotor.html_css); } $('#pay-box input').val(''); $('#pay-box-group_request input').val(''); $('#info_end_txt').html(data.txt); $('#info_end_reserv').html(data.reserv + '
' + commentary + '
' + allergens_text + ''); execute_external(data); $('#buttonquestionsreserv').prop('disabled', false); } else if (data.resp == 0) { if (data.camrocaexit == 1) { alert(expired_reservation_time_comp); $('#container_module_reserv').hide(); $('#finish_reserv_time_out').show(); } else { if (data.pay_error != undefined && data.pay_error != false) { alert(traducir(data.pay_error)); } if (data.error_text != undefined) { alert(data.error_text); } $('#pay_button').removeAttr("disabled"); $("#loadingr50").hide(); $('#finish_reserv_system').removeAttr('disabled'); $('#loading_system_email').hide(); } $('#buttonquestionsreserv').prop('disabled', false); } else { $.post(core_url + '/Logs/add_error_log_new_relic', { restaurant: restaurant, msg: 'Error de respuesta en pay_web_text_information Divilo', origin: 'Antiguo Motor', response: data }) .then(function onSuccess(response) { alert(t490b); }).catch(function onError(data) { alert(t490); }); } }, "json"); } else { $('#alert_time').hide(); clearTimeout(timeout); $('#iframe-divilo-container').hide(); $('#info_end_txt').html('Error al finalizar el pago'); $('#loading').hide(); $("#datos_personales").hide(); $('#questions_restaurant').hide(); $("#pay-box").hide(); $('#end_box').show(); } }, "json"); } function goInsertCard() { intervalComproveStripe = setInterval(function () { comproveStripePayment(paymentIntent, amountTotal) }, 3000); window.open(core_url + "/p/stripe/ic/" + restaurant + "/" + id_reserv_secure_stripe + "/" + paymentIntent); } function go_redsys() { interval_comprove_redsys = setInterval(function () { comprove_redsys_payment(id_redsys, amount_total_redsys) }, 3000); $('#redsys_go').hide(); document.redsysAcsForm.submit(); $('#text-redsys').show(); } function goRedsysGroupRequest() { interval_comprove_redsys = setInterval(function () { comprove_redsys_payment(id_redsys, amount_total_redsys) }, 3000); $('.redsys-iframe-content').remove(); $('#redsys_go_group_request').hide(); document.redsysAcsForm.submit(); $('#text-redsys').show(); } function comproveStripePayment(paymentIntent, amountTotal) { $.post(core_url + '/p/stripe/cp', { paymentIntent: paymentIntent, reservId: id_reserv_secure_stripe }, function (data) { if (data.resp == 1) { clearTimeout(timeout); clearTimeout(intervalComproveStripe); var extra = -1; if (type_landing == 2 || type_landing == 3) { origin = company; } if (motor_first_product == 0) { if (shopping_cart == 1) { if (productextras.length > 0) { extra = productextras; } else { if (selected != '') { extra = selected; } if (noproductsnomenus) { if ($('#extra-box-select').length) { extra = $('#extra-box-select').val(); } } } } else { if (selected != '') { extra = selected; if ($('#extra-box-select-product').length && $('#extra-box-select-product').val() != null) { extra = $('#extra-box-select-product').val(); } } else { if ($('#extra-box-select').length) { extra = $('#extra-box-select').val(); } } numberproducts = false; } } else { var selection = $('#extra-box-select-product').val(); var extra = $('#extra-box-select').val(); if (extra == undefined) { extra_string = ''; var array = { "1": 'x', "2": -1, "3": selection }; extra = JSON.stringify(array); } else { extra_string = text5 + $('#extra-box-select option:selected').text(); extra = JSON.parse(extra); extra["3"] = selection; extra = JSON.stringify(extra); } } finishReservClassicMotor(amountTotal, extra); } }); } function isMobileDevice() { const userAgent = navigator.userAgent || navigator.vendor || window.opera; return ( /android/i.test(userAgent) || (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) || /Windows Phone/i.test(userAgent) || (/Macintosh/i.test(userAgent) && 'ontouchend' in document) ); } function comprove_redsys_payment(id_external_pay, amount_total) { $.post(core_url + '/payments/RedsysPayment/comprovePaymentRedsys', { id_external_pay: id_external_pay, id_reserv: id_reserv_secure_stripe }, function (data) { if (data.resp == 1) { clearTimeout(timeout); clearTimeout(interval_comprove_redsys); var commentary = $('#commentary').val(); var allergens_text = ''; if ($('#has_food_restrictions').is(':checked') === true && $('#food_restrictions').val() !== '') { allergens_text += allergens_lang_text + $('#food_restrictions').val(); } var extra = -1; if (type_landing == 2 || type_landing == 3) { origin = company; } if (motor_first_product == 0) { if (shopping_cart == 1) { if (productextras.length > 0) { extra = productextras; } else { if (selected != '') { extra = selected; } if (noproductsnomenus) { if ($('#extra-box-select').length) { extra = $('#extra-box-select').val(); } } } } else { if (selected != '') { extra = selected; if ($('#extra-box-select-product').length && $('#extra-box-select-product').val() != null) { extra = $('#extra-box-select-product').val(); } } else { if ($('#extra-box-select').length) { extra = $('#extra-box-select').val(); } } numberproducts = false; } } else { var selection = $('#extra-box-select-product').val(); var extra = $('#extra-box-select').val(); if (extra == undefined) { extra_string = ''; var array = { "1": 'x', "2": -1, "3": selection }; extra = JSON.stringify(array); } else { extra_string = text5 + $('#extra-box-select option:selected').text(); extra = JSON.parse(extra); extra["3"] = selection; extra = JSON.stringify(extra); } } $.post(core_url + '/pay/pay_web_text_information', { restaurant: restaurant, id_reserv: id_reserv_secure_stripe, extra: extra, numberproducts: numberproducts, redeem: redeem, code: code, origin: origin, amount_payment: amount_total, language: language }, function (data) { $('#btn-validate').removeAttr('disabled'); $('#buttonquestionsreserv').removeAttr('disabled'); if (data.resp == 1) { $("#loadingr50").hide(); $('#pay_button').removeAttr("disabled"); $('#loading').hide(); $("#loadingr50_n").hide(); $("#loadingr50_n").hide(); $('#finish_reserv_system').removeAttr('disabled'); $('#loading_system_email').hide(); $('#system_email_motor').hide(); $("#datos_personales").hide(); $("#pay-box").hide(); $("#pay-box-group_request").hide(); $('#questions_restaurant').hide(); $('#selection_menu_free').hide(); $('#end_box').show(); $('#alert_time').hide(); if (!isMarketplace() && data.htmlproductmotor.active == 1) { $('#product_motorhtml').html(data.htmlproductmotor.html_css); } $('#pay-box input').val(''); $('#pay-box-group_request input').val(''); $('#info_end_txt').html(data.txt); $('#info_end_reserv').html(data.reserv + '
' + commentary + '
' + allergens_text + ''); execute_external(data); $('#buttonquestionsreserv').prop('disabled', false); } else if (data.resp == 0) { if (data.camrocaexit == 1) { alert(expired_reservation_time_comp); $('#container_module_reserv').hide(); $('#finish_reserv_time_out').show(); } else { if (data.pay_error != undefined && data.pay_error != false) { alert(traducir(data.pay_error)); } if (data.error_text != undefined) { alert(data.error_text); } $('#pay_button').removeAttr("disabled"); $("#loadingr50").hide(); $('#finish_reserv_system').removeAttr('disabled'); $('#loading_system_email').hide(); } $('#buttonquestionsreserv').prop('disabled', false); } else { $.post(core_url + '/Logs/add_error_log_new_relic', { restaurant: restaurant, msg: 'Error de respuesta en pay_web_confirm_stripe_reserv Redsys', origin: 'Antiguo Motor', response: data }, function (data) { alert(t490); }, "json"); } }, "json"); } }, "json"); } // comprobación de pago para solicitud de grupo function check_pay_group_request() { var date = $('#datepicker').val(); var people = $('#extra_people_group_request').val(); var hour = $('#extra_hour_group_request').val(); // if the hour is one digit, we add a 0 at the beginning if (hour.length == 4) { hour = '0' + hour; } if (motor_first_product == 0) { var extra = -1; if (shopping_cart == 1) { if (productextras.length != 0) { extra = productextras; } } else { if (selected != '') { extra = selected; } else { if ($('#extra-box-select').length) { extra = $('#extra-box-select').val(); } } } } else { var selection = $('#extra-box-select-product').val(); var extra = $('#extra-box-select').val(); if (extra == undefined) { extra_string = ''; var array = { "1": 'x', "2": -1, "3": selection }; extra = JSON.stringify(array); } else { extra_string = text5 + $('#extra-box-select option:selected').text(); extra = JSON.parse(extra); extra["3"] = selection; extra = JSON.stringify(extra); } } extra_adyen = extra; var user_first_name = $('#user_first_name').val(); var user_last_name = $('#user_last_name').val(); var user_email = $('#user_email').val(); var int_call_code = $('#int_call_code').val(); var user_phone = $('#user_phone').val(); var postal_code = $('#postal_code').val(); var country = $('#country_select').val(); var commentary = $('#commentary').val(); var allergens_text = ''; if (invoice_generate_reserv == 1) { var nameInvoice = $('#name_invoice').val(); var dniCifInvoice = $('#dni_cif_invoice').val(); var postalCodeInvoice = $('#postal_code_invoice').val(); var addressInvoice = $('#address_invoice').val(); var localityInvoice = $('#locality_invoice').val(); var provinceInvoice = $('#province_invoice').val(); var typeDocumentInvoice = $('#type_document_invoice').val(); var typeClient = $('#type_client').val(); } else { var nameInvoice = false; var dniCifInvoice = false; var postalCodeInvoice = false; var addressInvoice = false; var localityInvoice = false; var provinceInvoice = false; var typeDocumentInvoice = false; var typeClient = false; } if ($('#has_food_restrictions').is(':checked') === true && $('#food_restrictions').val() !== '') { allergens_text += allergens_lang_text + $('#food_restrictions').val(); } var subscribe_newsletter = $('#subscribe_newsletter').is(':checked') ? 1 : 0; var data_treatment_consent = $('#subscribe_newsletter').is(':checked') ? 1 : 0; $('#tiket').hide(); $('#p_cancel').hide(); $('#hold_card').hide(); // ya está validado todo, vemos si necesitamos tarjeta if (shopping_cart == 0) { numberproducts = false; } if (typeof id_resps === 'undefined') { id_resps = false; } adyenTypeMotor = 'ClassicMotorGroupRequest'; $.post(core_url + '/Pay/use_card', { language: language, dia: date, hour: hour, restaurant: restaurant, people: people, extra: extra, phone: user_phone, name: user_first_name, last_name: user_last_name, email: user_email, id_reserv: id_reserv, int_call_code: int_call_code, allergens_text: allergens_text, postal_code: postal_code, country: country, subscribe_newsletter: subscribe_newsletter, data_treatment_consent: data_treatment_consent, commentary: commentary, type_landing: type_landing, redeem: redeem, numberproducts: numberproducts, id_resps: id_resps, menuseleccionados: menuseleccionados, has_discount: has_discount, code: code, origin: origin, org: org, group_request: true, name_invoice: nameInvoice, type_document_invoice: typeDocumentInvoice, type_client: typeClient, dni_cif_invoice: dniCifInvoice, postal_code_invoice: postalCodeInvoice, address_invoice: addressInvoice, locality_invoice: localityInvoice, province_invoice: provinceInvoice, groupRequestCancelPolicy: groupRequestCancelPolicy, groupRequestHoldOnCard: groupRequestHoldOnCard, reference: adyenTypeMotor }, function (data) { if (data.card == 1 && !redeem) { pay_type_use = data.pay_type_use; product_use_card = data.product; id_reserv_secure_stripe = data.id_reserv; if (pay_type_use === 3) { //Stripe $('#pay_button_group_request').prop('data-secret', data.payment_intent_client_secret); isSetupIntent = data.isSetupIntent; paymentCountryCode = data.country; paymentName = data.labelTotalStripe; paymentEmail = user_email; let elementsObject = { mode: 'payment', currency: data.currencyStripe, amount: data.amount_total, setup_future_usage: 'off_session', locale: languagestripe }; if (isSetupIntent || product_use_card == 2) { elementsObject.mode = 'setup'; delete elementsObject.amount; } if (!isSetupIntent && product_use_card == 5) { elementsObject.captureMethod = 'manual'; } elements = stripe.elements(elementsObject); paymentElement = elements.create('payment', stripeObjectConfig); paymentElement.mount('#payment-elements-group'); } else if (pay_type_use == 5) { //Redsys $('.creditcard').hide(); $('.payment_info_gr').html(data.form_redsys); $('#tiket').addClass('text-center'); $('#pagoLogo_group').hide(); $('#redsys_go_group_request').show(); id_redsys = data.id; amount_total = data.amount_total; } else if (pay_type_use == 11) { $('.adyen-normal-reserv').remove(); let env = data.env; let client = data.client; let sessionID = data.sessionID; let sessionData = data.sessionData; let paymentMethodsRequest = data.paymentMethods; merchant = data.merchant; amount = data.amount_total; reserv_token = data.id_reserv; pay_code = data.code; currency = data.currency; locale = data.locale; reference = data.reference; initAdyen(env, client, sessionID, sessionData, paymentMethodsRequest, locale, 'create'); $('.creditcard').hide(); } $('#btn-validate').removeAttr('disabled'); // pide tarjeta $('#login_box').hide(); $('#info-box').hide(); $('#questions_restaurant').hide(); $('#selection_menu_free').hide(); $('#pay-box-group_request').show(); $('#closePayBoxReturnButtonRequest').hide(); $('#havehour_group_personalized').hide(); if ((data.product == 2 || data.product == 5) && !redeem) { if (data.product == 5) { $('#hold_card_group').show(); } else { $('#p_cancel_group').show(); } if (data.p_cancel_hours == -1) { $('.havehour_group').hide(); } else { $('.nohour_group').hide(); if (data.message_pol_cancel != '') { $('.havehour_group').hide(); $('#havehour_group_personalized').show(); $('.p_cancel_group_personalized_msg').html(data.message_pol_cancel); } else { $('#havehour_group_personalized').hide(); $('.p_cancel_group_hours').html(translate_hours(data.p_cancel_hours)); } } $('#p_cancel_group').show(); $('.p_cancel_group_people').html(print_price_currency(data.p_cancel_people, currency_str)); $('.p_cancel_group').html(data.p_cancel); $('.amount').html(data.amount); $('#resume_cart_group_request').html('Solicitar'); $('.info_perview').text(date + ' | ' + transform_timecover(hour) + ' | ' + people); } if (pay_type_use != '8') { timeout = setTimeout(function () { alert(expired_reservation_time_comp); $('#container_module_reserv').hide(); $('body div:first').css({ "display": "none" }); $('#finish_reserv_time_out').show(); $('#alert_time').hide(); }, data.time_out_secure_stripe * 1000); } if (!countdown_started) { count_down_general(data.time_out_secure_stripe); } $('#alert_time').show(); } else { // se hace la solicitud de grupo do_group_request(); } }, "json"); } function finishReservClassicMotor(totalAmount, extra) { $('#finish_reserv_time_out').hide(); $('#alert_time').hide(); $('#container_module_reserv').show(); clearTimeout(timeout); $.post(core_url + '/pay/pay_web_text_information', { restaurant: restaurant, id_reserv: id_reserv_secure_stripe, extra: extra, numberproducts: numberproducts, redeem: redeem, code: code, origin: origin, payment_intent: {"amount": totalAmount}, language: language }, function (data) { $('#btn-validate').removeAttr('disabled'); $('#buttonquestionsreserv').removeAttr('disabled'); if (data.resp == 1) { $("#loadingr50").hide(); $('#pay_button').removeAttr("disabled"); $('#loading').hide(); $("#loadingr50_n").hide(); $("#loadingr50_n").hide(); $('#finish_reserv_system').removeAttr('disabled'); $('#loading_system_email').hide(); $('#system_email_motor').hide(); $("#datos_personales").hide(); $("#pay-box").hide(); $("#pay-box-group_request").hide(); $('#questions_restaurant').hide(); $('#selection_menu_free').hide(); $('#end_box').show(); $('#alert_time').hide(); if (!isMarketplace() && data.htmlproductmotor.active == 1) { $('#product_motorhtml').html(data.htmlproductmotor.html_css); } $('#pay-box input').val(''); $('#info_end_txt').html(data.txt); $('#info_end_reserv').html(data.reserv + '
' + commentary + '
' + allergens_text + ''); execute_external(data); $('#buttonquestionsreserv').prop('disabled', false); } else if (data.resp == 0) { if (data.camrocaexit == 1) { alert(expired_reservation_time_comp); $('#container_module_reserv').hide(); $('#finish_reserv_time_out').show(); //location.reload(true); } else { if (data.pay_error != undefined && data.pay_error != false) { alert(traducir(data.pay_error)); } if (data.error_text != undefined) { alert(data.error_text); } $('#pay_button').removeAttr("disabled"); $("#loadingr50").hide(); $('#finish_reserv_system').removeAttr('disabled'); $('#loading_system_email').hide(); } $('#buttonquestionsreserv').prop('disabled', false); } else { $.post(core_url + '/Logs/add_error_log_new_relic', { restaurant: restaurant, msg: 'Error de respuesta en pay_web_confirm_stripe_reserv', origin: 'Antiguo Motor', response: data }) .then(function onSuccess(response) { alert(t490b); }).catch(function onError(data) { alert(t490); }); } }, "json"); } // Realiza el pago function reserv() { $("#loadingr50").show(); $("#loadingr50_n").show(); $('#pay_button').attr("disabled", "disabled"); $('#loading').show(); $('#loading_system_email').show(); var user_first_name = $('#user_first_name').val(); var user_last_name = $('#user_last_name').val(); var int_call_code = $('#int_call_code').val(); var user_phone = $('#user_phone').val(); var birthday = $('#birthday').val(); var date = $('#datepicker').val(); var people = $('#people-box-select').val(); var postal_code = $('#postal_code').val(); var country = $('#country_select').val(); if (show_extra_field) { var extra_field_client = $('#extra_field_client').val(); } else { var extra_field_client = false; } if (hour_motor_conf) { var hour = $('#timepicker_motor').val(); hour = get_cover_hour(hour); } else { var hour = $('#hour-box-select').val(); } var user_email = $('#user_email').val(); var commentary = $('#commentary').val(); var allergens_text = ''; if ($('#has_food_restrictions').is(':checked') === true && $('#food_restrictions').val() !== '') { allergens_text += allergens_lang_text + $('#food_restrictions').val(); } var subscribe_newsletter = $('#subscribe_newsletter').is(':checked') ? 1 : 0; var data_treatment_consent = $('#data_treatment_consent').is(':checked') ? 1 : 0; var extra = -1; if (type_landing == 2 || type_landing == 3) { origin = company; } if (motor_first_product == 0) { if (shopping_cart == 1) { if (productextras.length > 0) { extra = productextras; } else { if (selected != '') { extra = selected; } if (noproductsnomenus) { if ($('#extra-box-select').length) { extra = $('#extra-box-select').val(); } } } } else { if (selected != '') { extra = selected; if ($('#extra-box-select-product').length && $('#extra-box-select-product').val() != null) { extra = $('#extra-box-select-product').val(); } } else { if ($('#extra-box-select').length) { extra = $('#extra-box-select').val(); } } numberproducts = false; } } else { var selection = $('#extra-box-select-product').val(); var extra = $('#extra-box-select').val(); if (extra == undefined) { extra_string = ''; var array = { "1": 'x', "2": -1, "3": selection }; extra = JSON.stringify(array); } else { extra_string = text5 + $('#extra-box-select option:selected').text(); extra = JSON.parse(extra); extra["3"] = selection; extra = JSON.stringify(extra); } } extra_adyen = extra; if (required_billing_information) { var nameInvoice = $('#name_invoice').val(); var dniCifInvoice = $('#dni_cif_invoice').val(); var postalCodeInvoice = $('#postal_code_invoice').val(); var addressInvoice = $('#address_invoice').val(); var localityInvoice = $('#locality_invoice').val(); var provinceInvoice = $('#province_invoice').val(); var typeDocumentInvoice = $('#type_document_invoice').val(); var typeClient = $('#type_client').val(); } else { var nameInvoice = false; var dniCifInvoice = false; var postalCodeInvoice = false; var addressInvoice = false; var localityInvoice = false; var provinceInvoice = false; var typeDocumentInvoice = false; var typeClient = false; } var reserve_type = $('input[name="reserveType"]:checked').val() || 1; var prescriber_name = $('#prescriber_name').val(); var prescriber_intcallcode = $('#prescriber_intcallcode').val(); var prescriber_phone = $('#prescriber_phone').val(); var prescriber_email = $('#prescriber_email').val(); var prescriber_province = $('#prescriber_province').val(); var prescriber_postalcode = $('#prescriber_postalcode').val(); if (pay_type_use !== null && pay_type_use !== undefined && pay_type_use == 3 && !redeem) { var clientSecret = $('#pay_button').prop('data-secret'); var callback_setup_3dsecure = function (result) { if (result.error) { $("#loadingr50").hide(); $("#loadingr50_n").hide(); $('#pay_button').removeAttr("disabled"); alert(result.error.message); } else if (result.paymentIntent || result.setupIntent) { if (result.setupIntent !== undefined && result.setupIntent !== null) { result.paymentIntent = result.setupIntent; } $('#finish_reserv_time_out').hide(); $('#alert_time').hide(); $('#container_module_reserv').show(); // TODO >> AQUI YA SE HA CONFIRMADO EL PAGO POR LO QUE HABRIA QUE CONFIMAR LA RESERVA, CREAR EL CLIENTE EN STRIPE, PONER ID DE STRIPE EN COVER, NOTIFICACIONES, ETC $.post(core_url + '/pay/pay_web_confirm_stripe_reserv', { restaurant: restaurant, id_reserv: id_reserv_secure_stripe, extra: extra, numberproducts: numberproducts, redeem: redeem, code: code, origin: origin, org: org, payment_intent: result.paymentIntent, language: language }, function (data) { clearTimeout(timeout); $('#btn-validate').removeAttr('disabled'); $('#buttonquestionsreserv').removeAttr('disabled'); if (data.resp == 1) { $("#loadingr50").hide(); $('#pay_button').removeAttr("disabled"); $('#loading').hide(); $("#loadingr50_n").hide(); $("#loadingr50_n").hide(); $('#finish_reserv_system').removeAttr('disabled'); $('#loading_system_email').hide(); $('#system_email_motor').hide(); $("#datos_personales").hide(); $("#pay-box").hide(); $('#questions_restaurant').hide(); $('#selection_menu_free').hide(); $('#end_box').show(); $('#alert_time').hide(); if (!isMarketplace() && data.htmlproductmotor.active == 1) { $('#product_motorhtml').html(data.htmlproductmotor.html_css); } $('#pay-box input').val(''); $('#info_end_txt').html(data.txt); $('#info_end_reserv').html(data.reserv + '
' + commentary + '
' + allergens_text + ''); execute_external(data); $('#buttonquestionsreserv').prop('disabled', false); } else if (data.resp == 0) { if (data.camrocaexit == 1) { alert(expired_reservation_time_comp); $('#container_module_reserv').hide(); $('#finish_reserv_time_out').show(); //location.reload(true); } else { if (data.pay_error != undefined && data.pay_error != false) { alert(traducir(data.pay_error)); } if (data.error_text != undefined) { alert(data.error_text); } $('#pay_button').removeAttr("disabled"); $("#loadingr50").hide(); $('#finish_reserv_system').removeAttr('disabled'); $('#loading_system_email').hide(); } $('#buttonquestionsreserv').prop('disabled', false); } else { $.post(core_url + '/Logs/add_error_log_new_relic', { restaurant: restaurant, msg: 'Error de respuesta en pay_web_confirm_stripe_reserv', origin: 'Antiguo Motor', response: data }, function (data) { alert(t490); }, "json"); } }, "json"); } else { alert('Ni error ni confirmado, tratar esto'); // TODO >> PENDIENTE TRATAR ESTO } }; var callback_setup_3dsecure_tickets = function (result) { if (result.error) { $("#loadingr50").hide(); $("#loadingr50_n").hide(); $('#pay_button').removeAttr("disabled"); alert(result.error.message); } else if (result.paymentIntent || result.setupIntent) { if (result.setupIntent !== undefined && result.setupIntent !== null) { result.paymentIntent = result.setupIntent; } finishReservClassicMotor(result.paymentIntent.amount, extra); } }; if (product_use_card == 3) { // Trigger form validation and wallet collection elements.submit(); // Use the clientSecret and Elements instance to confirm the setup stripe.confirmPayment({ elements, clientSecret, confirmParams: { return_url: 'https://example.com/order/123/complete', payment_method_data: { billing_details: { name: paymentName, email: paymentEmail, address: { country: paymentCountryCode } } } }, redirect: "if_required", }).then(callback_setup_3dsecure_tickets); } else if (product_use_card == 2) { // Trigger form validation and wallet collection elements.submit(); // Use the clientSecret and Elements instance to confirm the setup stripe.confirmSetup({ elements, clientSecret, confirmParams: { return_url: 'https://example.com/order/123/complete', payment_method_data: { billing_details: { name: paymentName, email: paymentEmail, address: { country: paymentCountryCode } } } }, redirect: "if_required", }).then(callback_setup_3dsecure_tickets); } else if (product_use_card == 5) { if (isSetupIntent) { // Trigger form validation and wallet collection elements.submit(); // Use the clientSecret and Elements instance to confirm the setup stripe.confirmSetup({ elements, clientSecret, confirmParams: { return_url: 'https://example.com/order/123/complete', payment_method_data: { billing_details: { name: paymentName, email: paymentEmail, address: { country: paymentCountryCode } } } }, redirect: "if_required", }).then(callback_setup_3dsecure_tickets); } else { // Trigger form validation and wallet collection elements.submit(); // Use the clientSecret and Elements instance to confirm the setup stripe.confirmPayment({ elements, clientSecret, confirmParams: { return_url: 'https://example.com/order/123/complete', payment_method_data: { billing_details: { name: paymentName, email: paymentEmail, address: { country: paymentCountryCode } } } }, redirect: "if_required", }).then(callback_setup_3dsecure_tickets); } } } else { validateRecaptcha(function (recaptchaToken) { if (id_reserv != null) { $.post(core_url + '/pay/pay_web', { recaptchaToken: recaptchaToken, st: st, language: language, stripeToken: stripeToken, restaurant: restaurant, people: people, day: date, hour: hour, phone: user_phone, int_call_code: ectd_client_int_call_code !== false ? ectd_client_int_call_code : int_call_code, allergens_text: allergens_text, postal_code: postal_code, country: ectd_client_country !== false ? ectd_client_country : country, name: user_first_name, last_name: user_last_name, birthday: birthday, extra_field_client: extra_field_client, email: user_email, commentary: commentary, provenance: provenance, origin: origin, org: org, extra: extra, numberproducts: numberproducts, clientID: clientID, id_reserv: id_reserv, subscribe_newsletter: subscribe_newsletter, data_treatment_consent: data_treatment_consent, id_resps: id_resps, menuseleccionados: menuseleccionados, redeem: redeem, code: code, type_landing: type_landing, card_number: card_number, ectd_client: ectd_client, name_invoice: nameInvoice, type_document_invoice: typeDocumentInvoice, type_client: typeClient, dni_cif_invoice: dniCifInvoice, postal_code_invoice: postalCodeInvoice, address_invoice: addressInvoice, locality_invoice: localityInvoice, province_invoice: provinceInvoice, reserve_type: reserve_type, prescriber_name: prescriber_name, prescriber_intcallcode: prescriber_intcallcode, prescriber_phone: prescriber_phone, prescriber_email: prescriber_email, prescriber_province: prescriber_province, prescriber_postalcode: prescriber_postalcode, crossIdRestOrigin: crossIdRestOrigin, utm_emailmarketing: utm_emailmarketing || false, }, function (data) { clearTimeout(timeout); $('#btn-validate').removeAttr('disabled'); $('#buttonquestionsreserv').removeAttr('disabled'); if (data.resp == 1) { $("#loadingr50").hide(); $('#pay_button').removeAttr("disabled"); $('#loading').hide(); $("#loadingr50_n").hide(); $("#loadingr50_n").hide(); $('#finish_reserv_system').removeAttr('disabled'); $('#loading_system_email').hide(); $('#system_email_motor').hide(); //closePayBox(); //inicio(); //clear(); $("#datos_personales").hide(); $("#pay-box").hide(); $('#questions_restaurant').hide(); $('#selection_menu_free').hide(); $('#end_box').show(); $('#alert_time').hide(); if (!isMarketplace() && data.htmlproductmotor.active == 1) { $('#product_motorhtml').html(data.htmlproductmotor.html_css); } $('#pay-box input').val(''); $('#info_end_txt').html(data.txt); $('#info_end_reserv').html(data.reserv + '
' + commentary + '
' + allergens_text + ''); //alert(data.txt); execute_external({ token: data.token, date: data.date, time: data.time, pax: data.pax }); $('#buttonquestionsreserv').prop('disabled', false); } else { if (data.camrocaexit == 1) { alert(expired_reservation_time_comp); $('#container_module_reserv').hide(); $('#finish_reserv_time_out').show(); //location.reload(true); } else { if (data.pay_error != undefined && data.pay_error != false) { alert(traducir(data.pay_error)); } if (data.error_text != undefined) { alert(data.error_text); } $('#pay_button').removeAttr("disabled"); $("#loadingr50").hide(); $('#finish_reserv_system').removeAttr('disabled'); $('#loading_system_email').hide(); } $('#buttonquestionsreserv').prop('disabled', false); } }, "json"); } else { $.post(core_url + '/pay/pay_web/' + getVipReservationValue(), { recaptchaToken: recaptchaToken, st: st, language: language, stripeToken: stripeToken, restaurant: restaurant, people: people, day: date, hour: hour, phone: user_phone, int_call_code: ectd_client === true ? ectd_client_int_call_code : int_call_code, postal_code: postal_code, country: ectd_client === true ? ectd_client_country : country, name: user_first_name, last_name: user_last_name, birthday: birthday, extra_field_client: extra_field_client, email: user_email, commentary: commentary, allergens_text: allergens_text, provenance: provenance, origin: origin, org: org, extra: extra, numberproducts: numberproducts, clientID: clientID, redeem: redeem, code: code, subscribe_newsletter: subscribe_newsletter, data_treatment_consent: data_treatment_consent, id_resps: id_resps, menuseleccionados: menuseleccionados, type_landing: type_landing, card_number: card_number, ectd_client: ectd_client, name_invoice: nameInvoice, type_document_invoice: typeDocumentInvoice, type_client: typeClient, dni_cif_invoice: dniCifInvoice, postal_code_invoice: postalCodeInvoice, address_invoice: addressInvoice, locality_invoice: localityInvoice, province_invoice: provinceInvoice, room_number: room_number_pre, skip_blocked_tables : skipBlockedTables, reserve_type: reserve_type, prescriber_name: prescriber_name, prescriber_intcallcode: prescriber_intcallcode, prescriber_phone: prescriber_phone, prescriber_email: prescriber_email, prescriber_province: prescriber_province, prescriber_postalcode: prescriber_postalcode, crossIdRestOrigin: crossIdRestOrigin, utm_emailmarketing: utm_emailmarketing || false, }, function (data) { clearTimeout(timeout); $('#btn-validate').removeAttr('disabled'); if (data.resp == 1) { $("#loadingr50").hide(); $('#pay_button').removeAttr("disabled"); $('#loading').hide(); $("#loadingr50_n").hide(); $('#finish_reserv_system').removeAttr('disabled'); $('#loading_system_email').hide(); $('#system_email_motor').hide(); //closePayBox(); //inicio(); //clear(); $('#questions_restaurant').hide(); $('#selection_menu_free').hide(); $("#datos_personales").hide(); $("#pay-box").hide(); $('#end_box').show(); $('#alert_time').hide(); if (!isMarketplace() && data.htmlproductmotor.active == 1) { $('#product_motorhtml').html(data.htmlproductmotor.html_css); } $('#pay-box input').val(''); $('#info_end_txt').html(data.txt); $('#info_end_reserv').html(data.reserv + '
' + commentary + '
' + allergens_text + ''); //alert(data.txt); execute_external({ token: data.token, date: data.date, time: data.time, pax: data.pax }); $('#buttonquestionsreserv').prop('disabled', false); } else { if (data.pay_error != undefined && data.pay_error != false) { alert(traducir(data.pay_error)); } if (data.error_text != undefined) { alert(data.error_text); } if (data.to_index != undefined) { inicio(); } $('#pay_button').removeAttr("disabled"); $("#loadingr50").hide(); $('#finish_reserv_system').removeAttr('disabled'); $('#loading_system_email').hide(); $('#system_email_motor').hide(); $('#buttonquestionsreserv').prop('disabled', false); } }, "json"); } }); } } function execute_external(reserv) { if (origin == 'klikin' || origin == 'klikin_tommyMels') { try { Android.finishBooking('CONFIRMED'); } catch (err) { } try { window.webkit.messageHandlers.finishBooking.postMessage('CONFIRMED'); } catch (err) { } } if (pixel_facebook_active) { try { fbq('track', 'Schedule'); } catch (err) { } } parent.postMessage({ reserv: reserv }, '*'); } function pay_modulo() { $("#loadingr50").show(); $('#pay_button').attr("disabled", "disabled"); if (pay_type_use !== null && pay_type_use !== undefined && (pay_type_use == 3 || pay_type_use == 7 || pay_type_use == 11)) { reserv(); } else { stripe.createToken(card).then(function (result) { $("#loadingr50").hide(); $('#pay_button').removeAttr("disabled"); if (result.error) { alert(traducir(result.error)); } else { stripeToken = result.token.id; reserv(); } }); } } /** * Function executed when you click in the Pay button (From Group Request) */ function pay_modulo_group_request() { $("#loadingr50_group").show(); $('#pay_button_group_request').attr("disabled", "disabled"); if (pay_type_use !== null && pay_type_use !== undefined && pay_type_use === 3) { var clientSecret = $('#pay_button_group_request').prop('data-secret'); var callback_setup_3dsecure = function (result) { if (result.error) { $("#loadingr50").hide(); $("#loadingr50_n").hide(); $('#pay_button').removeAttr("disabled"); alert(result.error.message); } else if (result.paymentIntent || result.setupIntent) { if (result.setupIntent !== undefined && result.setupIntent !== null) { result.paymentIntent = result.setupIntent; } $("#loadingr50_group").hide(); $('#pay_button_group_request').removeAttr("disabled"); payment_intent = result.paymentIntent; $('#finish_reserv_time_out').hide(); $('#container_module_reserv').show(); clearTimeout(timeout); do_group_request(); } else { alert('Ni error ni confirmado, tratar esto'); // TODO >> PENDIENTE TRATAR ESTO } }; if (product_use_card == 3) { // Trigger form validation and wallet collection elements.submit(); // Use the clientSecret and Elements instance to confirm the setup stripe.confirmPayment({ elements, clientSecret, confirmParams: { return_url: 'https://example.com/order/123/complete', payment_method_data: { billing_details: { name: paymentName, email: paymentEmail, address: { country: paymentCountryCode } } } }, redirect: "if_required", }).then(callback_setup_3dsecure); } else if (product_use_card == 2) { // Trigger form validation and wallet collection elements.submit(); // Use the clientSecret and Elements instance to confirm the setup stripe.confirmSetup({ elements, clientSecret, confirmParams: { return_url: 'https://example.com/order/123/complete', payment_method_data: { billing_details: { name: paymentName, email: paymentEmail, address: { country: paymentCountryCode } } } }, redirect: "if_required", }).then(callback_setup_3dsecure); } else if (product_use_card == 5) { if (isSetupIntent) { // Trigger form validation and wallet collection elements.submit(); // Use the clientSecret and Elements instance to confirm the setup stripe.confirmSetup({ elements, clientSecret, confirmParams: { return_url: 'https://example.com/order/123/complete', payment_method_data: { billing_details: { name: paymentName, email: paymentEmail, address: { country: paymentCountryCode } } } }, redirect: "if_required", }).then(callback_setup_3dsecure); } else { // Trigger form validation and wallet collection elements.submit(); // Use the clientSecret and Elements instance to confirm the setup stripe.confirmPayment({ elements, clientSecret, confirmParams: { return_url: 'https://example.com/order/123/complete', payment_method_data: { billing_details: { name: paymentName, email: paymentEmail, address: { country: paymentCountryCode } } } }, redirect: "if_required", }).then(callback_setup_3dsecure); } } } else { stripe.createToken(card).then(function (result) { $("#loadingr50_group").hide(); $('#pay_button_group_request').removeAttr("disabled"); if (result.error) { alert(traducir(result.error)); } else { stripeToken = result.token.id; // se hace la solicitud de grupo con politica de cancelación do_group_request(); } }); } } function load_colours() { $('#datepicker').datepicker('option', 'beforeShowDay', highlightDays); } function highlightDays(date) { //si no existe nos traemos ese mes var day = ("0" + date.getDate()).slice(-2); var month = ("0" + (date.getMonth() + 1)).slice(-2); var year = date.getFullYear(); date_str = year + '-' + month + '-' + day; if (highlight[date_str] == undefined) { load_highlight(date); return [true, ""]; } else { return highlight[date_str]; } } function load_highlight(date) { var month = ("0" + (date.getMonth() + 1)).slice(-2); var year = date.getFullYear(); var people = $('#people-box-select').val() || 0; if (highlight_loading[year + '-' + month] == undefined || highlight_loading[year + '-' + month] == 0) { highlight_loading[year + '-' + month] = 1; $.post(core_url + '/reservation/highlight', { language: language, restaurant: restaurant, month: month, year: year, vip: getVipReservationValue(), skip_blocked_tables : skipBlockedTables, people: people}, function (data) { highlightloading = false; for (k in data) { highlight[k] = data[k]; } highlight_loading[year + '-' + month] = 0; var ok = true; for (k in highlight_loading) {// si todo ha cargado if (highlight_loading[k] == 1) { ok = false; } } if (ok) { $('#datepicker').datepicker("refresh"); } }, "json"); } } //Valida el email function validateEmail(email_address) { var validate = true; var st_email = email_address; var ch_filter = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; validate = ch_filter.test(st_email); if (validate) { let tldList = loadTLDsSync(); if(!tldList || tldList.length == 0) { return validate; } var emailParts = st_email.split('@'); var domain = emailParts[1].toLowerCase(); var tld = domain.split('.').pop(); if (domain.length > 0 && tldList.includes(tld)) { validate = true; } else { validate = false; } } return validate; } function validateEmail2(email_address, email_address2) { if (email_address != email_address2) { return 1; } else { return validateEmail(email_address); } } function loadTLDsSync() { let tldList = []; var xhr = new XMLHttpRequest(); xhr.open('GET', 'https://data.iana.org/TLD/tlds-alpha-by-domain.txt', false); try { xhr.send(null); if (xhr.status === 200) { tldList = xhr.responseText .split('\n') .filter(line => line && !line.startsWith('#')) .map(line => line.toLowerCase()); } else { tldList = []; } } catch (e) { console.error('Error en petición síncrona:', e); tldList = []; } return tldList; } function traducir(text) { if (text == "The 'exp_year' parameter should be an integer (instead, is option1).") { return yearCaducidad; } if (text == "This card number looks invalid") { return cardIncorrecto; } if (text == "Your card's expiration month is invalid.") { return mesIncorrecto; } if (text == "Your card's security code is incorrect.") { return cvvInvalido; } if (text == "Your card's security code is invalid.") { return cvvInvalido; } if (text == "Your card was declined.") { return cardRechazada; } if (text == "Your card's expiration date is incorrect.") { return cardCaducada; } if (text == "An error occurred while processing your card. Try again in a little bit.") { return errorCobro; } if (text == "Your card's security code is incorrect.") { return cvvNoValido; } if (text == "Your card number is incorrect.") { return cardIncorrect; } if (text == "The card number is not a valid credit card number.") { return cardIncorrect1; } if (text == "Your card was declined. You can call your bank for details") { return cardIncorrect2; } if (text == "Your card was declined.") { return cardIncorrect3; } if (text == "An error occurred while processing your card. Try again in a little bit.") { return cardIncorrect4; } return errorDesconocido; } function new_commentary() { $('#commentary_reserv').show(); $('#datos_personales').hide(); } function volver_commentary() { $('#commentary_reserv').hide(); $('#datos_personales').show(); } function show_legal(restaurant, type, custom) { window.open(core_url + "/legal/load_legal_dynamic/" + restaurant + "/" + language + "/use_conditions/" + type + "/" + custom); } function show_legal2(restaurant, type, custom) { window.open(core_url + "/legal/load_legal_dynamic/" + restaurant + "/" + language + "/personal_info/" + type + "/" + custom); } function translate_hours(hours) { switch (hours) { case '72': return '3d'; case '96': return '4d'; case '120': return '5d'; case '144': return '6d'; case '168': return '7d'; case '192': return '8d'; case '216': return '9d'; case '240': return '10d'; case '264': return '11d'; case '288': return '12d'; case '312': return '13d'; case '336': return '14d'; case '360': return '15d'; default: return (hours + 'h'); } } function toggle_food_restrictions() { var checked = $('#has_food_restrictions').is(':checked'); if (checked === true) { $('#food_restriction_block').css('display', 'block'); $('#no_food_restrictions').attr('checked', false); } else { $('#food_restriction_block').css('display', 'none'); } } function allergens_check() { var checked = $('#no_food_restrictions').is(':checked'); if (checked === true) { $('#has_food_restrictions').attr('checked', false); } $('#food_restriction_block').css('display', 'none'); // } else { // $('#food_restriction_block').css('display', 'none'); // } } function insert_code() { $('#have').css('display', 'none'); $('#ticket').css('display', 'block'); $('.header_ticket_es').css('display', 'inline'); $('.header_ticket_es_second').css('display', 'block'); $('#btn-validate_ticket').css('display', 'block'); } function insert_code_es() { $('#have_es').css('display', 'none'); $('#ticket_es').css('display', 'block'); $('.header_ticket_es').css('display', 'inline'); $('.header_ticket_es_second').css('display', 'block'); $('#btn-validate_ticket_es').css('display', 'block'); } function get_cover_hour(time) { if (time != undefined) { var horanow = time; horanow = horanow.split(":"); var prefix_format_hour = ''; if (typeof horanow[1] != 'undefined' && horanow[1].includes('pm')) { prefix_format_hour = ' pm'; } else if (typeof horanow[1] != 'undefined' && horanow[1].includes('am')) { prefix_format_hour = ' am'; } var hh1 = parseInt(horanow[0], 10); var mm1 = parseInt(horanow[1], 10); mm1 = String(mm1); if (mm1.length < 2) { var addchar = (2 - mm1.length); for (let i = 0; i < addchar; i++) { mm1 = "0" + mm1; } } if (hh1 < 7) { hh1 = 0 + (hh1 + 24); hh1 = String(hh1); if (hh1.length < 2) { addchar = (2 - hh1.length); for (let i = 0; i < addchar; i++) { hh1 = "0" + hh1; } } } return hh1 + ":" + mm1 + prefix_format_hour; } } var first_time_time_reserv = true; var segundos = parseInt(timeout_reserv); var minutos = segundos / 60; var llamada; var ceromin = ''; var ceroseg = ''; function count_down() { var dt = new Date(); dt.setSeconds(dt.getSeconds() + timeout_reserv); var x = setInterval(function () { countdown_started = true; // Get today's date and time var now = new Date().getTime(); // Find the distance between now and the count down date var distance = dt - now; // Time calculations for minutes and seconds var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); var seconds = Math.floor((distance % (1000 * 60)) / 1000); // Display the result in the element with id="reloj" $('#reloj').html(minutes + ':' + seconds + ' ' + minutes_text); // If the count down is finished, write some text if (distance < 0) { clearInterval(x); countdown_started = false; } }, 1000); } function count_down_general(time_out_specific) { var dt = new Date(); dt.setSeconds(dt.getSeconds() + time_out_specific); var x = setInterval(function () { countdown_started = true; // Get today's date and time var now = new Date().getTime(); // Find the distance between now and the count down date var distance = dt - now; // Time calculations for minutes and seconds var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); var seconds = Math.floor((distance % (1000 * 60)) / 1000); if (seconds < 10) { seconds = seconds.toString().padStart(2, 0); } // Display the result in the element with id="reloj" $('#reloj').html(minutes + ':' + seconds + ' ' + minutes_text); // If the count down is finished, write some text if (distance < 0) { clearInterval(x); countdown_started = false; } }, 1000); } function check_phone(phone) { if ((phone != undefined || phone != null) && typeof phone === 'string') { phone = phone.replace(/ /g, ""); phone = phone.replace(/[&\/\#,+_()$~%'":*?<>{}|]/g, ""); $('#user_phone').val(phone); } return phone; } function check_email(email) { if ((email != undefined || email != null) && typeof email === 'string') { email = email.replace(/ /g, ""); $('#user_email').val(email); } return email; } function devolvercero(minutos, segundos) { if (minutos < 10) { ceromin = '0'; } if (segundos < 10) { ceroseg = '0'; } else { ceroseg = ''; } } function print_price_currency(price, currency) { if (position_currency == 1) { return `${price}${currency}`; } else { return `${currency}${price}`; } } //Mapa interactivo function show_map() { var date = $('#datepicker').val(); var time = $('#hour-box-select').val(); // Load interactive Map $.post(core_url + '/reservation/interactiveMap', { restaurant: restaurant }, function (data) { $('#interactive-map-content').html(data.map); $('#interactive-map').show(); setTimeout(function () { $('div#interactive-map-content > img').imageMap(); }, 3000); }, "json"); hidePreviouPrice = true; $(".map").maphilight(); } function choose_zone(element) { var zone = $(element).attr('zone'); var finded = false; $("#extra-box-select option").filter(function () { if ($(this).text() == zone) { finded = true; return this; } }).prop("selected", true).trigger('change'); if (finded) { hide_map(); } else { alert(area_not_avaible); } } function hide_map() { $('#interactive-map').hide(); } function getVipReservationValue() { if ($("#vip_reservation").length) { return $("#vip_reservation").val(); } else { return 0; } } function isMarketplace() { if (typeof marketplace != 'undefined' && marketplace == '1') { return true; } return false } // empty and hide cart function empty_cart() { $('#shopping-cart').hide(); productincart = 0; document.getElementById('productincart').innerHTML = 0; productextras = []; shoppingproduct = []; numberproducts = []; infoproducts = []; prix_eachproduct = []; prix_totalproducts = 0; $.post(core_url + '/reservation/addproduct_shopping', { restaurant: restaurant, language: language, products: shoppingproduct, precio: 0, productosinfo: infoproducts }, function (data) { $('#products-cart').html(data.shopping); }, "json"); }