`;
}
$('#pci_results').html(html);
$('#modalPCI').modal('hide');
}
// If you encode the message in JSON before sending them,
// then decode here
// const decoded = JSON.parse(data);
});
}
window.AA_CONFIG = {
animationLength: 1500,
easingFunction: 'easeOutCirc',
readyEvent: 'aa-ready',
scrollOffset: 400
};
$(function(){
$(this).trigger(window.AA_CONFIG.readyEvent);
if (strCmd != '') {
$.notify({
icon: "ti-check",
message: strCmd
}, {
type: "success",
placement: {
from: "bottom",
align: "center"
},
allow_dismiss: false,
newest_on_top: true,
delay: 5000,
icon_type: "class",
template: `
`
});
}
$('.selectpicker').selectpicker();
$('.buttonRiepilogoPrenotazione').click(function() {
const timestamp = getCustomTimestamp();
var idriga = $(this).data('idriga') ?? '';
const xParams = "action=get_condizioni"
+ "&cart=" + idriga
+ "&type=" + getConParamType
+ "&key=" + getConParamKey
+ "&lang_current=" + LANG_CURRENT;
var data;
$.ajax({
type: "POST",
async: true,
dataType: "json",
url: getTPLUrl + "assets/ajax/get_condizioni.php?v=" + timestamp,
data: xParams,
success: function(data) {
if (data.status == 'ok') {
$.simpleDialog({
modalContent: `
${data.html_riepilogo_con_totale}
`,
confirmBtnText: LNG_CHIUDI,
closeButton: false
});
} else {
swal("Oops!", LNG_QUALCOSA_STORTO, "error");
}
},
error: function(data) {
swal("Oops!", LNG_QUALCOSA_STORTO, "error");
}
});
});
$('#pci_button').click(function() {
pciAddCart();
});
$("#completa-ordine").click(function() {
if (parseInt($('#ordine_acquistabile').val() ?? 0) > 0) {
if(fCheckObbligatori()) {
if (countVillages > 1 || countGrimaldi > 1) {
swal({
title: "Oops!",
text: LNG_PACCHETTO_ALLA_VOLTA,
imageUrl: getTPLImmaginiUrl + "sorry-male.png",
confirmButtonText: "Ok",
closeOnConfirm: true
});
} else if (countGrimaldi == 1) {
$('.quoteStep').addClass('hide');
$('#labelCartComplete, #modalCartComplete .modal-loader-grimaldi, #labelCartCompleteVerifica, #logoBoxGrimaldi').removeClass('hide');
$('#modalCartComplete').modal('show');
const xParams = "action=firstCheck"
+ "&cart=" + grimaldiCart
+ "&langCurrent=" + LANG_CURRENT;
const timestamp = getCustomTimestamp();
$.ajax({
type: "POST",
async: true,
dataType: "json",
url: getTPLUrl + "assets/ajax/grimaldiProgress.php?v=" + timestamp,
data: xParams,
success: function(data) {
if (data.status == 'done') {
if (countVillages == 1) {
// Option Grimaldi già creata
$('.quoteStep').addClass('hide');
$('#modalCartComplete .modal-loader-grimaldi, #logoBoxGrimaldi').addClass('hide');
$('#labelCartComplete').text('').removeClass('hide');
$('#modalCartComplete .modal-loader, #labelCartCompleteVerifica, #logoBoxNicolaus').removeClass('hide');
$('#modalCartComplete').modal('show');
const xParams = "action=firstCheck"
+ "&id=" + villageID
+ "&code=" + villageCode
+ "&cart=" + villageCart
+ "&langCurrent=" + LANG_CURRENT;
const timestamp = getCustomTimestamp();
$.ajax({
type: "POST",
async: true,
dataType: "json",
url: getTPLUrl + "assets/ajax/nicolausProgress.php?v=" + timestamp,
data: xParams,
success: function(data) {
if (data.status == 'ok') {
/*if (data.rq && parseInt(data.rq) > 0) {
swal({
title: LNG_SWEET_ATTENZIONE,
text: "Almeno uno dei servizi di questo preventivo è ON REQUEST: disponibilità soggetta a riconferma da parte del fornitore. Procedendo con l'ordine effettui una Richiesta Impegnativa a seguito della quale Valtur verificherà tale disponibilità ed eventualmente procederà con la conferma.",
confirmButtonText: "Ok",
closeOnConfirm: true
});
}*/
$('#modalCartComplete .modal-loader').addClass('hide');
stepCall('extra');
} else {
$('#modalCartComplete').modal('hide');
}
},
error: function(data) {
swal("Oops!", LNG_QUALCOSA_STORTO, "error");
$('#modalCartComplete').modal('hide');
}
});
} else {
fSaveData();
}
} else if (true || data.status == 'ok') {
stepCallGrimaldi('guests');
$('#modalCartComplete .modal-loader-grimaldi').addClass('hide');
} else if (data.status == 'token_off') {
$('#modalCartComplete').modal('hide');
swal({
title: "Oops!",
text: LNG_PRENOTAZIONE_NON_DISPONIBILE,
imageUrl: getTPLImmaginiUrl + "sorry-male.png",
confirmButtonText: "Ok",
closeOnConfirm: true
});
} else if (data.status == 'error') {
$('#modalCartComplete').modal('hide');
swal({
title: "Oops!",
text: LNG_STORTO_RIPROVA,
imageUrl: getTPLImmaginiUrl + "sorry-male.png",
confirmButtonText: "Ok",
closeOnConfirm: true
});
} else {
$('#modalCartComplete').modal('hide');
}
},
error: function(data) {
swal("Oops!", LNG_QUALCOSA_STORTO, "error");
$('#modalCartComplete').modal('hide');
}
});
} else if (countVillages == 1) {
$('.quoteStep').addClass('hide');
$('#labelCartComplete').text('').removeClass('hide');
$('#modalCartComplete .modal-loader, #labelCartCompleteVerifica, #logoBoxNicolaus').removeClass('hide');
$('#modalCartComplete').modal('show');
const xParams = "action=firstCheck"
+ "&id=" + villageID
+ "&code=" + villageCode
+ "&cart=" + villageCart
+ "&langCurrent=" + LANG_CURRENT;
const timestamp = getCustomTimestamp();
$.ajax({
type: "POST",
async: true,
dataType: "json",
url: getTPLUrl + "assets/ajax/nicolausProgress.php?v=" + timestamp,
data: xParams,
success: function(data) {
if (data.status == 'ok') {
/*if (data.rq && parseInt(data.rq) > 0) {
swal({
title: LNG_SWEET_ATTENZIONE,
text: "Almeno uno dei servizi di questo preventivo è ON REQUEST: disponibilità soggetta a riconferma da parte del fornitore. Procedendo con l'ordine effettui una Richiesta Impegnativa a seguito della quale Valtur verificherà tale disponibilità ed eventualmente procederà con la conferma.",
confirmButtonText: "Ok",
closeOnConfirm: true
});
}*/
$('#modalCartComplete .modal-loader').addClass('hide');
stepCall('extra');
} else {
$('#modalCartComplete').modal('hide');
}
},
error: function(data) {
swal("Oops!", LNG_QUALCOSA_STORTO, "error");
$('#modalCartComplete').modal('hide');
}
});
} else {
fSaveData();
}
}
} else {
swal(LNG_SWEET_ATTENZIONE, LNG_CARRELLO_ORDINENONDISPONIBILE, "error");
}
});
$('#txtEmail').change(function()
{
$('.loader-txtEmail').removeClass('hide');
$('#lbltxtEmail-login').addClass('hide');
$('#lbltxtEmail, #lbltxtEmail-login').html('');
$(".fg-txtEmail").removeClass("has-error");
if ($(this).val() && $(this).val() != '')
{
const xParams = "action=checkEmailCarrello"
+ "&pstrEmail=" + $('#txtEmail').val();
window.requestAnimationFrame(() => {
$.ajax({
type: "POST",
async: true,
dataType: "json",
url: getTPLUrl + "assets/ajax/checkContatto.php",
data: xParams,
success: function(data) {
if (data.email_check == 0)
{
// Email non corretta
if (data.email_errore == 2)
{
// ERRORE : email NON esiste
$('#lbltxtEmail').html(fHTMLErrore(LNG_FORM_EMAILNONESISTE));
$(".fg-txtEmail").addClass("has-error");
}
else if (data.email_errore == 1)
{
// ERRORE : email NON corretta
$('#lbltxtEmail').html(fHTMLErrore(LNG_FORM_EMAILNONCORRETTA));
$(".fg-txtEmail").addClass("has-error");
}
}
else if ($('#id_cliente').val() == '')
{
// Email corretta
if (data.email_exists == 1)
{
// AVVISO : email già in archivio
let text1 = LNG_CIAO_EMAIL_GIA_ISCRITTA;
text1 = text1.replace(`{name}`, `
`);
const text = text1 + '
' + text2;
$('#lbltxtEmail-login').removeClass('hide').html(text);
$('.row-scelta-registrazione-box').addClass('hide');
$('#email_gia_registrata').val(1);
}
else
{
$('.row-scelta-registrazione-box').removeClass('hide');
$('#email_gia_registrata').val(0);
}
}
}
});
});
}
else
{
// ERRORE : email obbligatoria
$('#lbltxtEmail').html(fHTMLErrore(LNG_FORM_OBBLIGATORIO));
$(".fg-txtEmail").addClass("has-error");
}
$('.loader-txtEmail').addClass('hide');
});
$('input[name=pagamento]').change(function() {
$('#totale_ordine_loader').removeClass('hide');
$('.scegli-pagamento-radio label > span').removeClass('active');
$('.pagamento_descrizione').addClass('hide');
var pagid = $(this).val();
if ($(this).prop('checked')) {
$('#pagamento_span_' + pagid).addClass('active');
$('.pagamento_descrizione_' + pagid).removeClass('hide');
}
fAggiornaTotaleOrdine();
$('#totale_ordine_loader').addClass('hide');
});
// sp_nazione
$('#cmbSpNazione').change(function()
{
if ($(this).val() == 'IT')
{
$('#label_ricarica_postepay').removeClass('hide');
$('#col-sp-citta').removeClass('col-md-8').addClass('col-md-4');
$('#col-sp-provincia').removeClass('hide');
//$('#via_ig').addClass('input-group');
}
else
{
$('#label_ricarica_postepay').addClass('hide');
if ($("input[name=pagamento]:checked").val() == X_ID_RECORD_RICARICA_POSTEPAY)
{
$('.scegli-pagamento-radio label > span').removeClass('active');
$('.pagamento_descrizione').addClass('hide');
$('#pagamento_paypal').prop('checked', true);
$('#pagamento_span_paypal').addClass('active');
$('.pagamento_descrizione_paypal').removeClass('hide');
}
$('#col-sp-provincia').addClass('hide');
$('#col-sp-citta').removeClass('col-md-4').addClass('col-md-8');
//$('#via_ig').removeClass('input-group');
}
fAggiornaTotaleOrdine();
});
// nazione
$('#cmbFattNazione').change(function()
{
if ($(this).val() == 'IT') {
$('#col-fatt-citta').removeClass('col-md-8').addClass('col-md-4');
$('#col-fatt-provincia').removeClass('hide');
} else {
$('#col-fatt-provincia').addClass('hide');
$('#col-fatt-citta').removeClass('col-md-4').addClass('col-md-8');
}
fAggiornaTotaleOrdine();
});
$('#verifica_codice_sconto').click(function() {
$('#row-sconto-carrello').addClass('hide');
$('#sconto_carrello_descrizione, #sconto_carrello_label').html('');
$('#sconto_carrello').val(0);
$('#codice_sconto_carrello').val('');
$('.fg-txtCodiceScontoInput').removeClass('has-error');
if ($.trim($('#txtCodiceScontoInput').val()) == '') {
$('.fg-txtCodiceScontoInput').addClass('has-error');
$('#txtCodiceScontoInput').focus();
} else {
$('.panel-hai-un-codice').addClass('hide');
$('.panel-hai-un-codice-loader').removeClass('hide');
let blnVerifica = false;
let strLabelTop = "";
let strLabel = "";
let strLabelType = "";
const params = "action=setCodiceSconto"
+ "&id_cliente=" + $("#id_cliente").val()
+ "&codice_sconto=" + $('#txtCodiceScontoInput').val()
+ "&lang_current=" + $('#lang_current').val();
window.requestAnimationFrame(() => {
$.ajax({
type: "POST",
async: true,
dataType: "json",
url: getTPLUrl + "assets/ajax/setCodiceSconto.php",
data: params,
success: function(data) {
if (data.status == 'ok') {
if (data.verifica) {
blnVerifica = true;
$('#sconto_carrello_descrizione').html(data.sconto_descrizione);
$('#sconto_carrello_label').html(data.sconto_valore_label);
$('#sconto_carrello').val(data.sconto_valore);
$('#codice_sconto_carrello').val(data.codice);
$('#row-sconto-carrello').removeClass('hide');
$('#codice_success_label').html(data.sconto_success_label);
$('#labelScontoCarrello').html(data.sconto_descrizione);
$('#valueScontoCarrello').html(data.sconto_valore_label);
strLabelTop = "Ok";
strLabel = LNG_COUPON_INSERITO;
strLabelType = "success";
proposteScontate = data.proposte_scontate;
// console.log("proposteScontate:", proposteScontate);
Object.entries(proposteScontate).forEach(([codice, proposta]) => {
if (proposta.id_carrello) {
$('#totale_riga_' + proposta.id_carrello).addClass('hide');
$('#totale_riga_' + proposta.id_carrello + '_scontato').html(`
${proposta.prezzo_format}
${proposta.sconto_format}
${proposta.totale_format}
`).removeClass('hide');
}
});
} else {
strLabelTop = data.label_top;
strLabel = data.label;
strLabelType = data.label_type;
}
fAggiornaTotaleOrdine();
$('.panel-hai-un-codice-loader').addClass('hide');
if (blnVerifica) {
$('.panel-hai-un-codice-success').removeClass('hide');
$('#rowScontoCarrello, #rowTotaleCarrello').removeClass('hide');
} else {
$('.panel-hai-un-codice').removeClass('hide');
$('#rowScontoCarrello, #rowTotaleCarrello').addClass('hide');
}
if (strLabelTop != "") {
swal(strLabelTop, strLabel,strLabelType);
}
} else {
$('.panel-hai-un-codice-loader').addClass('hide');
$('.panel-hai-un-codice').removeClass('hide');
$('#rowScontoCarrello, #rowTotaleCarrello').addClass('hide');
swal("Oops!", LNG_QUALCOSA_STORTO, "error");
}
},
error: function(data) {
$('.panel-hai-un-codice-loader').addClass('hide');
$('.panel-hai-un-codice').removeClass('hide');
$('#rowScontoCarrello, #rowTotaleCarrello').addClass('hide');
swal("Oops!", LNG_QUALCOSA_STORTO, "error");
}
});
});
}
});
$('#rimuovi_codice_sconto').click(function() {
$('.panel-hai-un-codice-success, #row-sconto-carrello').addClass('hide');
$('.panel-hai-un-codice-loader').removeClass('hide');
$('#sconto_carrello_descrizione, #sconto_carrello_label').html('');
$('#sconto_carrello').val(0);
$('#codice_sconto_carrello').val('');
$('#txtCodiceScontoInput').val('');
fAggiornaTotaleOrdine();
$('.panel-hai-un-codice-loader, #rowScontoCarrello, #rowTotaleCarrello, .totale_riga_scontato').addClass('hide');
$('.panel-hai-un-codice, .totale_riga').removeClass('hide');
swal("Ok", LNG_SCONTO_RIMOSSO, "success");
});
// Mostra domanda
$('.showdomanda').click(function()
{
$('#box_txtDomanda').addClass('hide');
$('#boxlista_txtDomanda').removeClass('hide');
});
// Mostra lista domande
$('.listadomande').change(function()
{
$('#txtDomanda').val($(this).val());
$('#boxlista_txtDomanda').addClass('hide');
$('#lbltxtDomanda').html('');
$('#box_txtDomanda').removeClass('hide');
$('#txtDomanda').focus();
});
$('#oPreload').addClass('hide');
});
function grimaldiMultirischio() {
if ($('#multirischio_si').prop('checked')) {
$('#gmd_prenotazioni, #gmd_polizza, #gmd_cartTotaleAssicurato').removeClass('hide');
$('#gmd_cartTotale').addClass('hide');
} else {
$('#gmd_polizza, #gmd_cartTotaleAssicurato').addClass('hide');
$('#gmd_cartTotale').removeClass('hide');
if (!$('#gmd_cartSconto').length) {
$('#gmd_prenotazioni').addClass('hide');
}
}
}
function getCustomTimestamp() {
const now = new Date();
const year = now.getFullYear();
const month = String(now.getMonth() + 1).padStart(2, '0'); // I mesi partono da 0, quindi aggiungi 1
const day = String(now.getDate()).padStart(2, '0');
const hours = String(now.getHours()).padStart(2, '0');
const minutes = String(now.getMinutes()).padStart(2, '0');
const seconds = String(now.getSeconds()).padStart(2, '0');
return `${year}${month}${day}${hours}${minutes}${seconds}`;
}
function pciRemoveCart() {
$('#pci_label_done').addClass('hide');
$('#pci_button').removeClass('hide'); // #pci_label,
$('#pci_results,#lbltxtAggiungiCarta').html('');
$('#cardToken').html('');
$('#cardType').val('');
$('#cardHolderName').val('');
$('#cardNumber').val('');
$('#expiration').val('');
$('#cvv').val('');
}
function pciAddCart() {
$('#pci_label_done').addClass('hide');
$('#pci_button').removeClass('hide'); // #pci_label,
$('#pci_results,#lbltxtAggiungiCarta').html('');
$('#cardToken').html('');
$('#cardType').val('');
$('#cardHolderName').val('');
$('#cardNumber').val('');
$('#expiration').val('');
$('#cvv').val('');
const xParams = "action=get_pci_iframe"
+ "&lang=" + lang_pci
+ "&amount=" + totale_paga_struttura;
$.ajax({
type: "POST",
async: true,
dataType: "json",
url: getTPLUrl + "assets/ajax/get_pci_iframe.php",
data: xParams,
success: function(data) {
if (data.status == 'ok') {
$('#pci_iframe').html('').append(data.html_iframe);
$('#modalPCI').modal('show');
} else {
swal("Oops!", LNG_QUALCOSA_STORTO, "error");
}
},
error: function(data) {
swal("Oops!", LNG_QUALCOSA_STORTO, "error");
}
});
}
function changeNazione() {
if ($('#cmbNazione').val() == 'IT')
{
$('#label_ricarica_postepay').removeClass('hide');
$('#col-citta').removeClass('col-md-8').addClass('col-md-4');
$('#col-provincia').removeClass('hide');
//$('#via_ig').addClass('input-group');
}
else
{
$('#label_ricarica_postepay').addClass('hide');
if ($("input[name=pagamento]:checked").val() == X_ID_RECORD_RICARICA_POSTEPAY)
{
$('.scegli-pagamento-radio label > span').removeClass('active');
$('.pagamento_descrizione').addClass('hide');
$('#pagamento_paypal').prop('checked', true);
$('#pagamento_span_paypal').addClass('active');
$('.pagamento_descrizione_paypal').removeClass('hide');
}
$('#col-provincia').addClass('hide');
$('#col-citta').removeClass('col-md-4').addClass('col-md-8');
//$('#via_ig').removeClass('input-group');
}
fAggiornaTotaleOrdine();
}
function fAggiornaTotaleOrdine() {
$('#totale_ordine_loader').removeClass('hide');
var data;
var strID_Pagamento = $("input[name=pagamento]:checked").val() ?? "";
var strNazione = $("#cmbSpNazione").val() || "IT";
const xParams = "action=setTotaleCarrello"
+ "&id_cliente=" + $("#id_cliente").val()
+ "&provincia=" + ($("#cmbSpProvincia").val() ?? "")
+ "&nazione=" + strNazione
+ "&id_pagamento=" + strID_Pagamento
+ "&sconto=" + ($("#sconto_carrello").val() ?? "")
+ "&totale_peso=" + ($("#totale_peso").val() ?? "")
+ "&assicurata_con=" + ($("#radioAssicurata_assicurata").prop('checked') ? 1 : 0)
+ "&pstrLangCurrent=" + ($("#lang_current").val() ?? X_EN)
+ "&totale_carrello_prodotti=" + $("#totale_carrello_prodotti").val()
+ "&totale_carrello_shop=" + $("#totale_carrello_shop").val();
window.requestAnimationFrame(() => {
$.ajax({
type: "POST",
async: true,
dataType: "json",
url: getTPLUrl + "assets/ajax/setCarrello.php",
data: xParams,
success: function(data)
{
if (data.status == 'ok')
{
$('#costo_spedizione').val(data.spedizione_totale);
$('#costo_spedizione_standard').val(data.spedizione_costo_db);
$('#costo_spedizione_assicurata').val(data.assicurazione_db);
$('.crl_spedizione_label').html(data.spedizione_label);
$('.crl_spedizione_totale_label').html(data.spedizione_totale_label);
if (parseInt(data.ordine_acquistabile ?? 0)) {
if (data.spedizione_costo_db) {
$('.crl_spedizione_standard').html(data.spedizione_costo);
} else {
$('.crl_spedizione_standard').html(' FREE');
}
if (data.spedizione_totale) {
$('.crl_spedizione_costo_label').html(data.spedizione_totale_format);
} else {
$('.crl_spedizione_costo_label').html('FREE');
}
$('.crl_costo_assicurata').html(data.assicurazione);
$('.spedizione_nondisponibile_provincia').addClass('hide');
$('.spedizione_nondisponibile').addClass('hide');
$('.assicurata_box').removeClass('hide');
} else if ($("#cmbNazione").val() == 'IT' && $.trim($("#cmbProvincia").val() ?? '') == '') {
$('.crl_spedizione_costo_label').html('Wähle die Provinz');
$('.assicurata_box').addClass('hide');
$('.spedizione_nondisponibile').addClass('hide');
$('.spedizione_nondisponibile_provincia').removeClass('hide');
} else {
$('.crl_spedizione_costo_label').html('nicht verfügbar');
$('.spedizione_nondisponibile_provincia').addClass('hide');
$('.assicurata_box').addClass('hide');
$('.spedizione_nondisponibile').removeClass('hide');
}
$('#crl_totale_label, #valueTotaleCarrello, #valueTotaleCarrelloBottom').html(data.totale_ordine);
// $('#rowScontoCarrello, #rowTotaleCarrello').removeClass('hide');
$('#ordine_acquistabile').val(parseInt(data.ordine_acquistabile));
if (strID_Pagamento == 'paypal'
|| strID_Pagamento == 'carta'
|| strID_Pagamento == 'postepay') {
$('#row-paypal-commissioni').removeClass('hide');
} else {
$('#row-paypal-commissioni').addClass('hide');
}
$('#totale_ordine_loader').addClass('hide');
} else {
$('#totale_ordine_loader').addClass('hide');
swal("Oops!", LNG_AJAX_IMPOSSIBILE, "error");
}
},
error: function(data) {
$('#totale_ordine_loader').addClass('hide');
swal("Oops!", LNG_AJAX_PROCEDURA, "error");
}
});
});
}
function fSaveData() {
fSaveData_loader("on");
var strDestination = '';
var strID_Ordine = '';
var strPagamento = '';
var formData = $("#frmCompletaOrdine").serializeArray();
formData.push({ name: "proposte_scontate", value: JSON.stringify(proposteScontate) });
$.ajax({
type: "POST",
async: true,
dataType: "json",
url: getTPLUrl + "assets/ajax/sendOrder.php",
data: $.param(formData),
success: function(data) {
strPagamento = data.pagamento;
if (data.status == 'obbligatori') {
$('#completaErrore').removeClass('hide');
swal("Oops!", LNG_FORM_INS_OBBLIGATORI, "warning");
} else {
$('#completaErrore').addClass('hide');
if (data.status == 'ok') {
if (hasFacebookId) {
if (parseInt(data.nuovo_cliente)) {
fbq('track', 'CompleteRegistration');
}
fbq('track', 'Purchase', {
value: data.totale_ordine,
currency: 'EUR',
content_type: 'product',
content_ids: [$('#facebook_content_ids').val()]
});
}
strID_Ordine = data.id_ordine;
strDestination = data.destination;
if (notEmpty(strID_Ordine) && notEmpty(strDestination)) {
location.href = strDestination;
} else {
fSaveData_loader("off");
}
} else {
fSaveData_loader("off");
swal("Oops!", LNG_QUALCOSA_STORTO, "error");
// alert("status not ok");
}
}
},
error: function(data) {
fSaveData_loader("off");
swal("Oops!", LNG_QUALCOSA_STORTO, "error");
// alert("sendOrder error");
}
});
}
function fSaveData_loader(stato) {
if (stato == "on") {
$('submit').focus();
$('#submitBut').addClass('hide');
$('#submitLoad').removeClass('hide');
} else {
$('#submitLoad').addClass('hide');
$('#submitBut').removeClass('hide');
}
}
// Controllo campi obbligatori
function fCheckObbligatori() {
var blnReturn = true;
var strAlert = "";
$('submit').focus();
$('#submitBut').addClass('hide');
$('#submitLoad').removeClass('hide');
$(".has-error").removeClass("has-error");
$(".lbl").html("");
var strID_Contatto = ($('#id_cliente').length ? $('#id_cliente').val() : '');
// Controllo email
if ($("#txtEmail").val() != '') {
$('#loader-email').removeClass('hide');
$('#lbltxtEmail').html('');
var intErrore = '';
window.requestAnimationFrame(() => {
$.ajax({
type: "POST",
async: true,
dataType: "json",
url: getTPLUrl + "assets/ajax/checkEmail.php",
data: "action=checkEmail&pstrEmail=" + $("#txtEmail").val(),
success: function(data)
{
intErrore = data.errore;
if (intErrore == 1)
{
// ERRORE : email NON corretta
blnReturn = false;
$('#lbltxtEmail').html(fHTMLErrore("Die Adresse ist nicht korrekt."));
$(".fg-txtEmail").addClass("has-error");
strAlert = "Die Adresse ist nicht korrekt.";
}
else if (intErrore == 2)
{
// ERRORE : email NON esiste
blnReturn = false;
$('#lbltxtEmail').html(fHTMLErrore("Die Adresse existiert nicht."));
$(".fg-txtEmail").addClass("has-error");
strAlert = "Die Adresse existiert nicht.";
}
if (data.status == 'errore') {
blnSaved = false;
} else if (data.status == 'ok') {
blnSaved = true;
} else {
swal("Oops...", LNG_AJAX_PROCEDURA, "error");
// alert("1");
}
},
error: function(data) {
swal("Oops...", LNG_AJAX_PROCEDURA, "error");
// alert("2");
}
});
});
}
if (blnReturn)
{
$('.required').each(function()
{
if ($.trim($(this).val()) == "")
{
blnReturn = false;
$("#lbl" + $(this).attr("name")).html(fHTMLErrore(LNG_FORM_OBBLIGATORIO));
$(".fg-" + $(this).attr("name")).addClass("has-error");
if (strAlert == "") {
strAlert = LNG_FORM_INS_OBBLIGATORI; // + $(this).attr("name") + $("#lbl" + $(this).attr("name")).attr("title");
}
} else {
$("#lbl" + $(this).attr("name")).html("");
}
});
if (blnReturn && (countGrimaldi || countVillages)) {
if ($.trim($('#txtIndirizzo').val()) == '' ) {
blnReturn = false;
$('#lbltxtIndirizzo').html(fHTMLErrore(LNG_FORM_OBBLIGATORIO));
$(".fg-txtIndirizzo").addClass("has-error");
if (strAlert == "") {
strAlert = "Geben Sie das Feld ein: Anschrift";
}
} else {
$('#lbltxtIndirizzo').html("");
}
if (blnReturn) {
if ($.trim($('#txtCivico').val()) == '' ) {
blnReturn = false;
$('#lbltxtCivico').html(fHTMLErrore(LNG_FORM_OBBLIGATORIO));
$(".fg-txtCivico").addClass("has-error");
if (strAlert == "") {
strAlert = "Geben Sie das Feld ein: Civico";
}
} else {
$('#lbltxtCivico').html("");
}
}
if (blnReturn) {
if ($.trim($('#txtCap').val()) == '' ) {
blnReturn = false;
$('#lbltxtCap').html(fHTMLErrore(LNG_FORM_OBBLIGATORIO));
$(".fg-txtCap").addClass("has-error");
if (strAlert == "") {
strAlert = "Geben Sie das Feld ein: Zip";
}
} else {
$('#lbltxtCap').html("");
}
}
if (blnReturn) {
if ($.trim($('#txtCitta').val()) == '' ) {
blnReturn = false;
$('#lbltxtCitta').html(fHTMLErrore(LNG_FORM_OBBLIGATORIO));
$(".fg-txtCitta").addClass("has-error");
if (strAlert == "") {
strAlert = "Geben Sie das Feld ein: City";
}
} else {
$('#lbltxtCitta').html("");
}
}
if (blnReturn) {
if ($.trim($('#cmbNazione').val()) == '' ) {
blnReturn = false;
$('#lblcmbNazione').html(fHTMLErrore(LNG_FORM_OBBLIGATORIO));
$(".fg-cmbNazione").addClass("has-error");
if (strAlert == "") {
strAlert = "Geben Sie das Feld ein: Volk";
}
} else {
$('#lblcmbNazione').html("");
}
}
if (blnReturn && $('#cmbNazione').val() == 'IT') {
if ($.trim($('#cmbProvincia').val()) == '' ) {
blnReturn = false;
$('#lblcmbProvincia').html(fHTMLErrore(LNG_FORM_OBBLIGATORIO));
$(".fg-cmbProvincia").addClass("has-error");
if (strAlert == "") {
strAlert = "Betreten Sie die Provinz";
}
} else {
$('#lblcmbProvincia').html("");
}
}
}
}
if (blnReturn && $('#fattura_si').prop('checked')) {
// Controllo ragione sociale
if ($.trim($('#txtFattNominativo').val()) == '' ) {
blnReturn = false;
$('#lbltxtFattNominativo').html(fHTMLErrore(LNG_FORM_OBBLIGATORIO));
$(".fg-txtFattNominativo").addClass("has-error");
if (strAlert == "") {
strAlert = LNG_INS_RS_FATTURA;
}
} else {
$('#lbltxtFattNominativo').html("");
}
// Controllo codice fiscale o partita IVA
if ($.trim($('#txtCodiceFiscale').val()) == ''
&& $.trim($('#txtPartitaIva').val()) == '' )
{
blnReturn = false;
$('#lbltxtCodiceFiscale, #lbltxtPartitaIva').html(fHTMLErrore(LNG_FORM_OBBLIGATORIO));
$(".fg-txtCodiceFiscale, .fg-txtPartitaIva").addClass("has-error");
if (strAlert == "") {
strAlert =LNG_INS_CF_FATTURA;
}
} else {
$('#lbltxtCodiceFiscale, #lbltxtPartitaIva').html("");
}
// Controllo indirizzo
if ($.trim($('#txtFattIndirizzo').val()) == '' ) {
blnReturn = false;
$('#lbltxtFattIndirizzo').html(fHTMLErrore(LNG_FORM_OBBLIGATORIO));
$(".fg-txtFattIndirizzo").addClass("has-error");
if (strAlert == "") {
strAlert = LNG_INS_INDIRIZZO_FATTURA;
}
} else {
$('#lbltxtFattIndirizzo').html("");
}
// Controllo cap
if ($.trim($('#txtFattCap').val()) == '' ) {
blnReturn = false;
$('#lbltxtFattCap').html(fHTMLErrore(LNG_FORM_OBBLIGATORIO));
$(".fg-txtFattCap").addClass("has-error");
if (strAlert == "") {
strAlert = LNG_INS_CAP_FATTURA;
}
} else {
$('#lbltxtFattCap').html("");
}
// Controllo citta
if ($.trim($('#txtFattCitta').val()) == '' ) {
blnReturn = false;
$('#lbltxtFattCitta').html(fHTMLErrore(LNG_FORM_OBBLIGATORIO));
$(".fg-txtFattCitta").addClass("has-error");
if (strAlert == "") {
strAlert = LNG_INS_CITTA_FATTURA;
}
} else {
$('#lbltxtFattCitta').html("");
}
// Controllo nazione
if ($.trim($('#cmbFattNazione').val()) == '' ) {
blnReturn = false;
$('#lblcmbFattNazione').html(fHTMLErrore(LNG_FORM_OBBLIGATORIO));
$(".fg-cmbFattNazione").addClass("has-error");
if (strAlert == "") {
strAlert = LNG_INS_NAZIONE_FATTURA;
}
} else {
$('#lblcmbFattNazione').html("");
}
// Controllo provincia
if ($('#cmbFattNazione').val() == 'IT'
&& $.trim($('#cmbFattProvincia').val()) == '' )
{
blnReturn = false;
$('#lblcmbFattProvincia').html(fHTMLErrore(LNG_FORM_OBBLIGATORIO));
$(".fg-cmbFattProvincia").addClass("has-error");
if (strAlert == "") {
strAlert = LNG_INS_PROVINCIA_FATTURA;
}
} else {
$('#lblcmbFattProvincia').html("");
}
}
if (blnReturn && parseInt($('#has_shop').val()) > 0) {
// Controllo indirizzo
if ($.trim($('#txtSpIndirizzo').val()) == '' ) {
blnReturn = false;
$('#lbltxtSpIndirizzo').html(fHTMLErrore(LNG_FORM_OBBLIGATORIO));
$(".fg-txtSpIndirizzo").addClass("has-error");
if (strAlert == "") {
strAlert = LNG_INS_INDIRIZZO_SPEDIZIONE;
}
} else {
$('#lbltxtSpIndirizzo').html("");
}
// Controllo civico
if ($.trim($('#txtCivico').val()) == '' ) {
blnReturn = false;
$('#lbltxtCivico').html(fHTMLErrore(LNG_FORM_OBBLIGATORIO));
$(".fg-txtCivico").addClass("has-error");
if (strAlert == "") {
strAlert = LNG_INS_CIVICO_SPEDIZIONE;
}
} else {
$('#lbltxtCivico').html("");
}
// Controllo cap
if ($.trim($('#txtSpCap').val()) == '' ) {
blnReturn = false;
$('#lbltxtSpCap').html(fHTMLErrore(LNG_FORM_OBBLIGATORIO));
$(".fg-txtSpCap").addClass("has-error");
if (strAlert == "") {
strAlert = LNG_INS_CAP_SPEDIZIONE;
}
} else {
$('#lbltxtSpCap').html("");
}
// Controllo citta
if ($.trim($('#txtSpCitta').val()) == '') {
blnReturn = false;
$('#lbltxtSpCitta').html(fHTMLErrore(LNG_FORM_OBBLIGATORIO));
$(".fg-txtSpCitta").addClass("has-error");
if (strAlert == "") {
strAlert = LNG_INS_CITTA_SPEDIZIONE;
}
} else {
$('#lbltxtSpCitta').html("");
}
// Controllo nazione
if ($.trim($('#cmbSpNazione').val()) == '' ) {
blnReturn = false;
$('#lblcmbSpNazione').html(fHTMLErrore(LNG_FORM_OBBLIGATORIO));
$(".fg-cmbSpNazione").addClass("has-error");
if (strAlert == "") {
strAlert = LNG_INS_NAZIONE_SPEDIZIONE;
}
} else {
$('#lblcmbSpNazione').html("");
}
// Controllo provincia
if ($('#cmbSpNazione').val() == 'IT'
&& $.trim($('#cmbSpProvincia').val()) == '' )
{
blnReturn = false;
$('#lblcmbSpProvincia').html(fHTMLErrore(LNG_FORM_OBBLIGATORIO));
$(".fg-cmbSpProvincia").addClass("has-error");
if (strAlert == "") {
strAlert = LNG_INS_PROVINCIA_SPEDIZIONE;
}
} else {
$('#lblcmbSpProvincia').html("");
}
}
if (blnReturn)
{
if (!parseInt($('#email_gia_registrata').val())) {
// Controllo password
if ($.trim($('#txtPassword').val()) == '') {
blnReturn = false;
$("#lbltxtPassword").html(fHTMLErrore( LNG_FORM_OBBLIGATORIO));
$(".fg-txtPassword").addClass("has-error");
if (strAlert == "") {
strAlert = "Geben Sie Ihr Passwort ein";
}
} else {
$("#lbltxtPassword").html("");
}
if ($.trim($('#txtConfermaPassword').val()) == '') {
blnReturn = false;
$("#lbltxtConfermaPassword").html(fHTMLErrore( LNG_FORM_OBBLIGATORIO));
$(".fg-txtConfermaPassword").addClass("has-error");
if (strAlert == "") {
strAlert = "Geben Sie die Passwortbestätigung ein";
}
} else {
$("#lbltxtConfermaPassword").html("");
}
if ($('#txtPassword').val() != '' || $('#txtConfermaPassword').val() != '' ) {
if ($('#txtPassword').val() != $('#txtConfermaPassword').val()) {
blnReturn = false;
$('#lbltxtConfermaPassword').html(fHTMLErrore("Das Passwort ist nicht dasselbe."));
$(".fg-txtConfermaPassword").addClass("has-error");
if (strAlert == "") {
strAlert = "Das Passwort ist nicht dasselbe.";
}
} else {
$('#lbltxtConfermaPassword').html("");
}
}
if ($.trim($('#txtDomanda').val()) == '') {
$('#boxlista_txtDomanda').addClass('hide');
$('#box_txtDomanda').removeClass('hide');
blnReturn = false;
$('#lbltxtDomanda').html(fHTMLErrore(LNG_FORM_OBBLIGATORIO));
$(".fg-txtDomanda").addClass("has-error");
} else {
$('#lbltxtRisposta').html("");
}
if ($.trim($('#txtRisposta').val()) == '') {
blnReturn = false;
$('#lbltxtRisposta').html(fHTMLErrore(LNG_FORM_OBBLIGATORIO));
$(".fg-txtRisposta").addClass("has-error");
} else {
$('#lbltxtRisposta').html("");
}
}
}
if (blnReturn)
{
if (parseFloat($('#totale_paga_struttura').val()) > 0)
{
if (!$('#cardToken').length || $.trim($('#cardToken').text()) == '')
{
blnReturn = false;
const html = `
Sie müssen Ihre Karte hinzufügen, um Ihre Reservierung zu bestätigen
`;
$('#lbltxtAggiungiCarta').html(html);
if (strAlert == "") {
strAlert = `Sie müssen Ihre Karte hinzufügen, um Ihre Reservierung zu bestätigen`;
}
}
}
}
if (blnReturn)
{
// Controllo condizioni
if(!$('#condizioni').prop('checked'))
{
blnReturn = false;
$('#lblcondizioni').html(fHTMLErrore("Obligatorische Abnahme."));
$(".fg-condizioni").addClass("has-error");
if (strAlert == "") {
strAlert = "Die Bestätigung des Lesens der Bedingungen ist obligatorisch";
}
} else {
$('#lblcondizioni').html("");
}
}
if (blnReturn)
{
// Controllo regolamento
if(!$('#regolamento').prop('checked'))
{
blnReturn = false;
$('#lblregolamento').html(fHTMLErrore("Obligatorische Abnahme."));
$(".fg-regolamento").addClass("has-error");
if (strAlert == "") {
strAlert = "Die Annahme der Allgemeinen Geschäftsbedingungen ist obligatorisch";
}
} else {
$('#lblregolamento').html("");
}
}
if (blnReturn)
{
// Controllo privacy
if(!$('#privacy').prop('checked'))
{
blnReturn = false;
$('#lblprivacy').html(fHTMLErrore("Obligatorische Abnahme."));
$(".fg-privacy").addClass("has-error");
if (strAlert == "") {
strAlert = "Die Akzeptanz der Datenschutzrichtlinie ist obligatorisch";
}
}
else $('#lblprivacy').html("");
}
$('#submitLoad').addClass('hide');
$('#submitBut').removeClass('hide');
if (!blnReturn){
$('#completaErrore').removeClass('hide');
if (strAlert != "") {
swal(LNG_SWEET_ATTENZIONE, strAlert, "error");
}
} else {
$('#completaErrore').addClass('hide');
}
return blnReturn;
}
function fHTMLErrore(pstr) {
return '' + pstr + '';
}
// Aggiorna quantita
function fAggiornaQuantita(pstrKey, pintID_Riga) {
fLoading(1);
var pintQuantita = $('#quantita_'+pintID_Riga).val();
window.requestAnimationFrame(() => {
$.ajax({
type: "POST",
async: true,
dataType: "json",
url: getTPLUrl + "assets/ajax/setCarrello.php",
data: "action=aggiornaQuantita&pstrKey=" + pstrKey + "&pintID_Riga=" + pintID_Riga + "&pintQuantita=" + pintQuantita,
success: function(data)
{
if (data.status == 'ok'){
location.href = 'https://www.metour.it/de/einkaufen'
+ (data.max == 'exceed' ? '?max=exceed' : '');
}
else {
swal("Oops!", LNG_AJAX_IMPOSSIBILE, "error");
}
},
error: function(data) {
swal("Oops!", LNG_AJAX_PROCEDURA, "error");
}
});
});
}
// Rimuovi prodotto
function fDelProd(pstrKey, pintID_Riga) {
swal({
title: LNG_SWEET_ATTENZIONE,
text: "Möchten Sie dieses Produkt aus dem Warenkorb löschen?",
type: "warning",
showCancelButton: true,
cancelButtonText: "Nein, abbrechen",
confirmButtonText: "Ja, löschen!",
closeOnConfirm: true
},
function(){
fLoading(1);
window.requestAnimationFrame(() => {
$.ajax({
type: "POST",
async: true,
dataType: "json",
url: getTPLUrl + "assets/ajax/setCarrello.php",
data: "action=rimuoviProdotto&pstrKey=" + pstrKey + "&pintID_Riga=" + pintID_Riga,
success: function(data)
{
if (data.status == 'ok') {
location.href = 'https://www.metour.it/de/einkaufen';
} else {
swal("Oops!", LNG_AJAX_IMPOSSIBILE, "error");
}
},
error: function(data) {
swal("Oops!", LNG_AJAX_PROCEDURA, "error");
}
});
});
});
}
// Svuota carrello
function fSvuotaCarrello(pstrKey) {
swal({
title: LNG_SWEET_ATTENZIONE,
text: "Möchten Sie alle Produkte aus dem Warenkorb löschen?",
type: "warning",
showCancelButton: true,
cancelButtonText: "Nein, abbrechen",
confirmButtonText: "Ja, löschen!",
closeOnConfirm: true
},
function()
{
fLoading(1);
window.requestAnimationFrame(() => {
$.ajax({
type: "POST",
async: true,
dataType: "json",
url: getTPLUrl + "assets/ajax/setCarrello.php",
data: "action=svuotaCarrello&pstrKey=" + pstrKey,
success: function(data) {
if (data.status == 'ok') {
location.href = 'https://www.metour.it/de/einkaufen';
} else {
swal("Oops!", LNG_AJAX_IMPOSSIBILE, "error");
}
},
error: function(data) {
swal("Oops!", LNG_AJAX_PROCEDURA, "error");
}
});
});
});
}
function stepCallGrimaldi(step) {
let xParams = "action=grimaldiProgress"
+ "&step=" + encodeURIComponent(step)
+ "&cart=" + encodeURIComponent(grimaldiCart)
+ "&langCurrent=" + encodeURIComponent(LANG_CURRENT)
+ "&email=" + encodeURIComponent($("#txtEmail").val() ?? "")
+ "&nome=" + encodeURIComponent($("#txtNome").val() ?? "")
+ "&cognome=" + encodeURIComponent($("#txtCognome").val() ?? "")
+ "&nazionalita=" + encodeURIComponent($("#cmbNazionalita").val() ?? "")
+ "&recapito=" + encodeURIComponent(pulisciNumero($("#txtRecapito1").val() ?? ""))
+ "&indirizzo=" + encodeURIComponent($.trim($("#txtIndirizzo").val() ?? ""))
+ "&civico=" + encodeURIComponent($("#txtCivico").val() ?? "")
+ "&cap=" + encodeURIComponent($("#txtCap").val() ?? "")
+ "&citta=" + encodeURIComponent($("#txtCitta").val() ?? "")
+ "&provincia=" + encodeURIComponent($("#cmbProvincia").val() ?? "")
+ "&nazione=" + encodeURIComponent($("#cmbNazione").val() ?? "")
+ "&multirischio=" + ($("#multirischio_si").prop("checked") ? "si" : "no")
+ "&sconto_carrello=" + encodeURIComponent($("#sconto_carrello").val() ?? "")
+ "&codice_sconto_carrello=" + encodeURIComponent($("#codice_sconto_carrello").val() ?? "")
+ "&sconto_carrello_descrizione=" + encodeURIComponent($("#labelScontoCarrello").text() ?? "")
+ "&proposte_scontate=" + JSON.stringify(proposteScontate);
const timestamp = getCustomTimestamp();
let dobInputs;
$.ajax({
type: "POST",
async: true,
dataType: "json",
url: getTPLUrl + "assets/ajax/grimaldiProgress.php?v=" + timestamp,
data: xParams,
success: function(data) {
if (data.status == 'ok') {
if (data.lastQuoteResponse == "quote_error") {
swal({
title: "Oops!",
text: "Etwas ist schief gelaufen. Bitte überprüfen Sie die Daten.",
imageUrl: getTPLImmaginiUrl + "sorry-male.png",
confirmButtonText: "Ok",
closeOnConfirm: true
});
$('.loaderCall').addClass('hide');
$('#buttonCall').removeClass('hide');
} else if (data.lastQuoteResponse == "quote_off") {
swal({
title: "Oops!",
text: "Das Angebot ist nicht verfügbar.",
imageUrl: getTPLImmaginiUrl + "sorry-male.png",
confirmButtonText: "Ok",
closeOnConfirm: true
});
$('.loaderCall').addClass('hide');
$('#buttonCall').removeClass('hide');
} else {
let stepSelector = 'quoteStepGrimaldi_' + step;
if (step == 'guests') {
$('#html_grimaldi_guests').html(data.html);
}
$('#frmGrimaldiProgress .selectpicker').selectpicker();
$('.quoteStep').addClass('hide');
$('#'+stepSelector).removeClass('hide');
$('#modalCartComplete .modal-loader-grimaldi').addClass('hide');
if (step == 'guests') {
$('.required-progress-grimaldi').on('change', function() {
const $input = $(this);
const $formGroup = $input.closest('.form-group');
if (!$input.val() || $input.val().trim().length < 1) {
$formGroup.addClass("has-error");
} else {
$formGroup.removeClass("has-error");
}
});
}
$('#labelCartCompleteVerifica').addClass('hide');
if (step == 'guests') {
$('#labelCartComplete').html(`
👌
Ok, Buchung ist möglich! `).removeClass('hide');
}
}
}
$('.loaderCall').addClass('hide');
$('#buttonCall').removeClass('hide');
$('#modalCartComplete').focus();
document.getElementById("modalCartComplete").scrollTo({
top: 0,
behavior: "smooth"
});
},
error: function(data) {
swal("Oops!", LNG_QUALCOSA_STORTO, "error");
$('.loaderCall').addClass('hide');
$('#buttonCall').removeClass('hide');
}
});
}
function stepCall(step) {
let bCHeck = true;
let xParams = "action=nicolausProgress"
+ "&step=" + step
+ "&id=" + villageID
+ "&code=" + villageCode
+ "&cart=" + villageCart
+ "&langCurrent=" + LANG_CURRENT
+ "&email=" + encodeURIComponent($("#txtEmail").val() ?? "")
+ "&nome=" + encodeURIComponent($("#txtNome").val() ?? "")
+ "&cognome=" + encodeURIComponent($("#txtCognome").val() ?? "")
+ "&nazionalita=" + encodeURIComponent($("#cmbNazionalita").val() ?? "")
+ "&recapito=" + encodeURIComponent(pulisciNumero($("#txtRecapito1").val() ?? ""))
+ "&indirizzo=" + encodeURIComponent($.trim($("#txtIndirizzo").val() ?? ""))
+ "&civico=" + encodeURIComponent($("#txtCivico").val() ?? "")
+ "&cap=" + encodeURIComponent($("#txtCap").val() ?? "")
+ "&citta=" + encodeURIComponent($("#txtCitta").val() ?? "")
+ "&provincia=" + encodeURIComponent($("#cmbProvincia").val() ?? "")
+ "&nazione=" + encodeURIComponent($("#cmbNazione").val() ?? "")
+ "&codice_fiscale=" + encodeURIComponent($("#txtCodiceFiscale").val() ?? "")
+ "&insuranceSereno=" + ($("#insuranceSereno").val() ?? "")
+ "&insuranceSerenoExtraPrice=" + ($("#insuranceSerenoExtraPrice").val() ?? "")
+ "&insuranceSerenoTopPrice=" + ($("#insuranceSerenoTopPrice").val() ?? "")
+ "&insuranceHealth=" + ($("#insuranceHealth").val() ?? "")
+ "&insuranceHealthExtraPrice=" + ($("#insuranceHealthExtraPrice").val() ?? "")
+ "&insuranceHealthTopPrice=" + ($("#insuranceHealthTopPrice").val() ?? "")
+ "&sconto_carrello=" + encodeURIComponent($("#sconto_carrello").val() ?? "")
+ "&codice_sconto_carrello=" + encodeURIComponent($("#codice_sconto_carrello").val() ?? "")
+ "&sconto_carrello_descrizione=" + encodeURIComponent($("#labelScontoCarrello").text() ?? "")
+ "&proposte_scontate=" + JSON.stringify(proposteScontate);
if (step === 'summary') {
$('#buttonCall').addClass('hide');
$('.loaderCall').removeClass('hide');
bCHeck = fCheckGuests();
let taxCode = $("#sCodiceFiscale").val() ?? "";
taxCode = taxCode.toUpperCase();
const villageGuests = {
"booking": {
"title": $("#cTitolo").val() ?? "",
"name": $("#sNome").val() ?? "",
"lastName": $("#sCognome").val() ?? "",
"phone": rimuoviPrefisso($("#sPhone").val() ?? ""),
"email": $("#sEmail").val() ?? "",
"country": $("#cNazione").val() ?? "",
"province": $("#sProvincia").val() ?? "",
"zipCode": $("#sCap").val() ?? "",
"address": $("#sIndirizzo").val() ?? "",
"number": $("#sCivico").val() ?? "",
"city": $("#sCitta").val() ?? "",
"taxCode": taxCode,
"dob": $("#sDataNascita").val() ?? "",
"dobloc": $("#sLuogoNascita").val() ?? "",
},
"car": {
"licensePlate": $("#carLicense").val() ?? "",
"carModel": $("#carModel").val() ?? "",
"telephone": rimuoviPrefisso($("#carPhone").val() ?? ""),
},
"adults": [],
"children": [],
"infants": [],
};
let iGuestAdult = 0;
$(".guestAdult").each(function() {
if ($("#sNome" + iGuestAdult).val()) {
villageGuests.adults.push({
"name": $("#sNome" + iGuestAdult).val() ?? "",
"lastName": $("#sCognome" + iGuestAdult).val() ?? "",
"sex": $("#cSesso" + iGuestAdult).val() ?? "",
"country": $("#cNazione" + iGuestAdult).val() ?? "",
"dob": $("#sDataNascita" + iGuestAdult).val() ?? ""
});
iGuestAdult++;
}
});
let igCount = 0;
$(".guestChild").each(function() {
if ($("#sNome" + igCount).val()) {
if ($(this).hasClass('infant')) {
villageGuests.infants.push({
"name": $("#sNome" + igCount + "c").val() ?? "",
"lastName": $("#sCognome" + igCount + "c").val() ?? "",
"sex": $("#cSesso" + igCount + "c").val() ?? "",
"country": $("#cNazione" + igCount + "c").val() ?? "",
"age": $(this).data("age") ? parseInt($(this).data("age")) : 0,
"dob": $("#sDataNascita" + igCount + "c").val() ?? ""
});
} else {
villageGuests.children.push({
"name": $("#sNome" + igCount + "c").val() ?? "",
"lastName": $("#sCognome" + igCount + "c").val() ?? "",
"sex": $("#cSesso" + igCount + "c").val() ?? "",
"country": $("#cNazione" + igCount + "c").val() ?? "",
"age": $(this).data("age") ? parseInt($(this).data("age")) : 0,
"dob": $("#sDataNascita" + igCount + "c").val() ?? ""
});
}
igCount++;
}
});
xParams += "&guests=" + JSON.stringify(villageGuests);
}
if (bCHeck) {
const timestamp = getCustomTimestamp();
let dobInputs;
$.ajax({
type: "POST",
async: true,
dataType: "json",
url: getTPLUrl + "assets/ajax/nicolausProgress.php?v=" + timestamp,
data: xParams,
success: function(data) {
if (data.status == 'ok') {
if (data.lastQuoteResponse == "quote_error") {
swal({
title: "Oops!",
text: "Das Angebot wurde nicht angenommen. Bitte überprüfen Sie die Daten.",
imageUrl: getTPLImmaginiUrl + "sorry-male.png",
confirmButtonText: "Ok",
closeOnConfirm: true
});
$('.loaderCall').addClass('hide');
$('#buttonCall').removeClass('hide');
} else if (data.lastQuoteResponse == "quote_off") {
swal({
title: "Oops!",
text: "Das Angebot ist nicht verfügbar.",
imageUrl: getTPLImmaginiUrl + "sorry-male.png",
confirmButtonText: "Ok",
closeOnConfirm: true
});
$('.loaderCall').addClass('hide');
$('#buttonCall').removeClass('hide');
} else {
let stepSelector = 'quoteStep_' + step;
if (step == 'guests') {
$('#html_guests').html(data.html);
} else if (step == 'summary') {
$('#html_summary').html(data.html);
}
$('#frmGrimaldiProgress .selectpicker').selectpicker();
$('.quoteStep').addClass('hide');
$('#'+stepSelector).removeClass('hide');
$('#modalCartComplete .modal-loader').addClass('hide');
if (step == 'guests') {
// Seleziona tutti gli elementi con la classe .dataNascita
// i campi .dataNascita devono avere gli attributi:
// data-before_or_equal (data nel formato 'YYYY-MM-DD')
// data-after (data nel formato 'YYYY-MM-DD')
// data-format (stringa: 'DD/MM/YYYY' oppure 'YYYY-MM-DD')
dobInputs = document.querySelectorAll('.dataNascita');
dobInputs.forEach(dobInput => {
const beforeOrEqual = new Date(dobInput.dataset.before_or_equal);
const after = new Date(dobInput.dataset.after);
const format = dobInput.dataset.format;
const inputId = dobInput.id ?? '';
dobInput.addEventListener('input', (e) => {
const value = e.target.value;
const maskedValue = LF_applyMask(value, format);
e.target.value = maskedValue;
});
dobInput.addEventListener('blur', (e) => {
const value = e.target.value;
const isValid = LF_validateDate(value, format);
$(".fg-"+inputId).removeClass("has-error");
$("#lbl"+inputId).html("");
if (!value) {
$(".fg-"+inputId).addClass("has-error");
$("#lbl"+inputId).html("");
// alert('Inserisci la data di nascita.');
return;
}
if (!isValid) {
$(".fg-"+inputId).addClass("has-error");
$("#lbl"+inputId).html("La data non è valida");
// alert('La data inserita non è valida.');
return;
}
const date = LF_parseDate(value, format);
if (date > beforeOrEqual) {
const text = (`Das Geburtsdatum muss vor oder gleich dem {data} liegen`).replace(`{data}`, `${LF_formatDate(beforeOrEqual, (LANG_CURRENT == X_IT ? 'DD/MM/YYYY' : 'YYYY-MM-DD'))}`);
$('.fg-'+inputId).addClass("has-error");
$("#lbl"+inputId).html(text);
// $("#lbl"+inputId).html(`La data di nascita deve essere precedente o uguale al ${LF_formatDate(beforeOrEqual, (LANG_CURRENT == X_IT ? 'DD/MM/YYYY' : 'YYYY-MM-DD'))}`);
return;
}
if (date < after) {
const text = (`Das Geburtsdatum muss nach dem {data} liegen`).replace(`{data}`, `${LF_formatDate(after, (LANG_CURRENT == X_IT ? 'DD/MM/YYYY' : 'YYYY-MM-DD'))}`);
$('.fg-'+inputId).addClass("has-error");
$("#lbl"+inputId).html(text);
// $("#lbl"+inputId).html(`La data di nascita deve essere successiva al ${LF_formatDate(after, (LANG_CURRENT == X_IT ? 'DD/MM/YYYY' : 'YYYY-MM-DD'))}`);
return;
}
// Copia la data nel campo dob2 se esiste
const dob2Input = document.querySelector('input[name="sDataNascita0"]');
if (inputId == "sDataNascita" && dob2Input && !dob2Input.value) {
dob2Input.value = value;
$(".fg-"+dob2Input.id).removeClass("has-error");
$("#lbl"+dob2Input.id).html("");
}
});
});
$('.required-progress:not(.dataNascita)').on('change', function() {
const $input = $(this);
const $formGroup = $input.closest('.form-group');
if (!$input.val() || $input.val().trim().length < 1) {
$formGroup.addClass("has-error");
} else {
$formGroup.removeClass("has-error");
}
});
$('#sCodiceFiscale').on('change', function() {
const $input = $(this);
const $formGroup = $input.closest('.form-group');
const codiceFiscale = $input.val().trim();
// Rimuove eventuali errori precedenti
$formGroup.removeClass("has-error");
// Verifica lunghezza e formato
if (codiceFiscale.length !== 16 || !/^[A-Z0-9]+$/i.test(codiceFiscale)) {
$formGroup.addClass("has-error");
//alert("Il codice fiscale deve essere di 16 caratteri e contenere solo lettere e numeri.");
$input.focus();
}
});
}
$('#frmProgress .selectpicker').selectpicker();
if (step == 'extra') {
$('#labelCartCompleteVerifica').addClass('hide');
$('#labelCartComplete').html(`
👌
Ok, Buchung ist möglich! `).removeClass('hide');
} else if (step == 'guests') {
$('#labelCartComplete').text('Reisedaten eingeben').removeClass('hide');
} else {
$('#labelCartComplete').addClass('hide');
}
}
}
$('.loaderCall').addClass('hide');
$('#buttonCall').removeClass('hide');
$('#modalCartComplete').focus();
document.getElementById("modalCartComplete").scrollTo({
top: 0,
behavior: "smooth"
});
},
error: function(data) {
swal("Oops!", LNG_QUALCOSA_STORTO, "error");
$('.loaderCall').addClass('hide');
$('#buttonCall').removeClass('hide');
}
});
}
}
function LF_applyMask(value, format) {
/*const numbers = value.replace(/\D/g, '');
let maskedValue = '';
if (format === 'DD/MM/YYYY') {
if (numbers.length >= 2) maskedValue += numbers.substring(0, 2) + '/';
if (numbers.length >= 4) maskedValue += numbers.substring(2, 4) + '/';
if (numbers.length >= 6) maskedValue += numbers.substring(4, 8);
} else if (format === 'YYYY-MM-DD') {
if (numbers.length >= 4) maskedValue += numbers.substring(0, 4) + '-';
if (numbers.length >= 6) maskedValue += numbers.substring(4, 6) + '-';
if (numbers.length >= 8) maskedValue += numbers.substring(6, 8);
}
return maskedValue;*/
let maskedValue = value.replace(/\D/g, ""); // Rimuove caratteri non numerici
// Aggiungi gli slash in base alla lunghezza
if (maskedValue.length > 2 && maskedValue.length <= 4) {
maskedValue = maskedValue.slice(0, 2) + "/" + maskedValue.slice(2);
} else if (value.length > 4) {
maskedValue = maskedValue.slice(0, 2) + "/" + maskedValue.slice(2, 4) + "/" + maskedValue.slice(4, 8);
}
return maskedValue;
}
function LF_validateDate(value, format) {
const date = LF_parseDate(value, format);
return !isNaN(date.getTime());
}
function LF_parseDate(value, format) {
let day, month, year;
if (format === 'DD/MM/YYYY') {
[day, month, year] = value.split('/');
} else if (format === 'YYYY-MM-DD') {
[year, month, day] = value.split('-');
}
return new Date(year, month - 1, day);
}
function LF_formatDate(date, format) {
const day = String(date.getDate()).padStart(2, '0');
const month = String(date.getMonth() + 1).padStart(2, '0');
const year = date.getFullYear();
if (format === 'DD/MM/YYYY') {
return `${day}/${month}/${year}`;
} else if (format === 'YYYY-MM-DD') {
return `${year}-${month}-${day}`;
}
return '';
}
function changeProgressRequired(obj) {
// console.log("obj:",obj);
const $input = obj;
const id = $input.attr('id') ?? '';
const $formGroup = $input.closest('.form-group');
// console.log("val:",$input.val());
if (!$input.val() || $input.val().trim().length < 1) {
$formGroup.addClass("has-error");
} else {
$formGroup.removeClass("has-error");
}
if (id == 'cNazione') {
if ($input.val() == 'IT') {
$('#col-cNazione').removeClass('col-md-10').addClass('col-md-5');
$('#col-sProvincia').removeClass('hide');
} else {
$('#col-cNazione').removeClass('col-md-5').addClass('col-md-10');
$('#col-sProvincia').addClass('hide');
}
}
}
function stepCallBack(step) {
if (step == 'extra') {
$('#labelCartComplete').html(`🥳Ok, Buchung ist möglich!`).removeClass('hide');
} else if (step == 'guests') {
$('#labelCartComplete').text('Geben Sie die Gästedaten ein').removeClass('hide');
} else {
$('#labelCartComplete').addClass('hide');
}
$('.quoteStep').addClass('hide');
$('#quoteStep_'+step).removeClass('hide');
$('#modalCartComplete').focus();
document.getElementById("modalCartComplete").scrollTo({
top: 0,
behavior: "smooth"
});
}
function fCheckGuestsGrimaldi() {
let bReturn = true;
$('.form-group').removeClass('has-error');
$('.required-progress-grimaldi').each(function () {
const $input = $(this);
const cSelector = $input.attr('id');
if (cSelector) {
const $formGroup = $('.fg-' + cSelector);
// Controllo se il campo è vuoto
if (!$input.val() || $input.val().trim() === '') {
$formGroup.addClass('has-error');
bReturn = false;
// console.log("cSelector:", cSelector);
// console.log("cSelectorName:", $input.attr('name'));
}
}
});
if (!bReturn) {
swal({
title: "Oops!",
text: "Bitte füllen Sie alle Felder korrekt aus.",
imageUrl: getTPLImmaginiUrl + "sorry-male.png",
confirmButtonText: "Ok",
closeOnConfirm: true
});
}
return bReturn;
}
function fCheckGuests() {
let bReturn = true;
$('.form-group').removeClass('has-error');
$('.required-progress').each(function () {
const $input = $(this);
const cSelector = $input.attr('id');
if (cSelector) {
const $formGroup = $('.fg-' + cSelector);
// Controllo se il campo è vuoto
if (!$input.val() || $input.val().trim() === '') {
$formGroup.addClass('has-error');
bReturn = false;
// console.log("cSelector:", cSelector);
// console.log("cSelectorName:", $input.attr('name'));
}
// Controllo specifico per il campo data
else if ($input.hasClass('dataNascita')) {
dobInputs = document.querySelectorAll('.dataNascita');
dobInputs.forEach(dobInput => {
const beforeOrEqual = new Date(dobInput.dataset.before_or_equal);
const after = new Date(dobInput.dataset.after);
const format = dobInput.dataset.format;
const inputId = dobInput.id ?? '';
dobInput.addEventListener('input', (e) => {
const value = e.target.value;
const maskedValue = LF_applyMask(value, format);
e.target.value = maskedValue;
});
dobInput.addEventListener('blur', (e) => {
const value = e.target.value;
const isValid = LF_validateDate(value, format);
$(".fg-"+inputId).removeClass("has-error");
$("#lbl"+inputId).html("");
if (!value) {
bReturn = false;
$(".fg-"+inputId).addClass("has-error");
$("#lbl"+inputId).html("");
// alert('Inserisci la data di nascita.');
return;
}
if (!isValid) {
bReturn = false;
$(".fg-"+inputId).addClass("has-error");
$("#lbl"+inputId).html("Das Datum ist ungültig");
// alert('La data inserita non è valida.');
return;
}
const date = LF_parseDate(value, format);
if (date > beforeOrEqual) {
const text = (`Das Geburtsdatum muss vor oder gleich dem {data} liegen`).replace(`{data}`, `${LF_formatDate(beforeOrEqual, (LANG_CURRENT == X_IT ? 'DD/MM/YYYY' : 'YYYY-MM-DD'))}`);
bReturn = false;
$('.fg-'+inputId).addClass("has-error");
$("#lbl"+inputId).html(text);
// $("#lbl"+inputId).html(`La data di nascita deve essere precedente o uguale al ${LF_formatDate(beforeOrEqual, (LANG_CURRENT == X_IT ? 'DD/MM/YYYY' : 'YYYY-MM-DD'))}`);
return;
}
if (date < after) {
const text = (`Das Geburtsdatum muss nach dem {data} liegen`).replace(`{data}`, `${LF_formatDate(after, (LANG_CURRENT == X_IT ? 'DD/MM/YYYY' : 'YYYY-MM-DD'))}`);
bReturn = false;
$('.fg-'+inputId).addClass("has-error");
$("#lbl"+inputId).html(text);
// $("#lbl"+inputId).html(`La data di nascita deve essere successiva al ${LF_formatDate(after, (LANG_CURRENT == X_IT ? 'DD/MM/YYYY' : 'YYYY-MM-DD'))}`);
return;
}
});
});
}
// Controllo specifico per il codice fiscale
else if ($input.attr('id') === 'sCodiceFiscale') {
const codiceFiscale = $input.val().trim();
if (codiceFiscale.length !== 16 || !/^[A-Z0-9]+$/i.test(codiceFiscale)) {
$formGroup.addClass('has-error');
bReturn = false;
// console.log("cSelector:", cSelector);
// console.log("cSelectorName:", $input.attr('name'));
}
}
}
});
if (!bReturn) {
$('.loaderCall').addClass('hide');
$('#buttonCall').removeClass('hide');
swal({
title: "Oops!",
text: "Bitte füllen Sie alle Felder korrekt aus.",
imageUrl: getTPLImmaginiUrl + "sorry-male.png",
confirmButtonText: "Ok",
closeOnConfirm: true
});
}
return bReturn;
}
function addInsurance(insuranceName, insuranceType) {
if (insuranceName == 'Sereno') {
$('#insuranceSereno').val(insuranceType);
if (insuranceType == 'Extra') {
$('#addInsurance_SerenoExtra, #addInsurance_SerenoTopSelected').addClass('hide');
$('#addInsurance_SerenoExtraSelected, #addInsurance_SerenoTop').removeClass('hide');
$('#boxInsurance_SerenoExtra').addClass('active');
$('#boxInsurance_SerenoTop').removeClass('active');
} else if (insuranceType == 'Top') {
$('#addInsurance_SerenoTop, #addInsurance_SerenoExtraSelected').addClass('hide');
$('#addInsurance_SerenoTopSelected, #addInsurance_SerenoExtra').removeClass('hide');
$('#boxInsurance_SerenoTop').addClass('active');
$('#boxInsurance_SerenoExtra').removeClass('active');
}
} else if (insuranceName == 'Health') {
$('#insuranceHealth').val(insuranceType);
if (insuranceType == 'Extra') {
$('#addInsurance_HealthExtra, #addInsurance_HealthTopSelected').addClass('hide');
$('#addInsurance_HealthExtraSelected, #addInsurance_HealthTop').removeClass('hide');
$('#boxInsurance_HealthExtra').addClass('active');
$('#boxInsurance_HealthTop').removeClass('active');
} else if (insuranceType == 'Top') {
$('#addInsurance_HealthTop, #addInsurance_HealthExtraSelected').addClass('hide');
$('#addInsurance_HealthTopSelected, #addInsurance_HealthExtra').removeClass('hide');
$('#boxInsurance_HealthTop').addClass('active');
$('#boxInsurance_HealthExtra').removeClass('active');
}
}
}
function removeInsurance(insuranceName, insuranceType, hasTransport) {
if (insuranceName == 'Sereno') {
$('#insuranceSereno').val('');
if (insuranceType == 'Extra') {
$('#addInsurance_SerenoExtraSelected').addClass('hide');
$('#addInsurance_SerenoExtra').removeClass('hide');
$('#boxInsurance_SerenoExtra').removeClass('active');
} else if (insuranceType == 'Top') {
$('#addInsurance_SerenoTopSelected').addClass('hide');
$('#addInsurance_SerenoTop').removeClass('hide');
$('#boxInsurance_SerenoTop').removeClass('active');
}
} else if (insuranceName == 'Health') {
$('#insuranceHealth').val('');
if (insuranceType == 'Extra') {
$('#addInsurance_HealthExtraSelected').addClass('hide');
$('#addInsurance_HealthExtra').removeClass('hide');
$('#boxInsurance_HealthExtra').removeClass('active');
} else if (insuranceType == 'Top') {
$('#addInsurance_HealthTopSelected').addClass('hide');
$('#addInsurance_HealthTop').removeClass('hide');
$('#boxInsurance_HealthTop').removeClass('active');
}
}
}
function addService(service) {
$('#addServicePremium').addClass('hide');
$('#loaderServicePremium').removeClass('hide');
window.requestAnimationFrame(() => {
if (service == 'premium') {
const timestamp = getCustomTimestamp();
const xParams = "action=addService"
+ "&service=" + service
+ "&id=" + villageID
+ "&code=" + villageCode
+ "&cart=" + villageCart
+ "&langCurrent=" + LANG_CURRENT;
$.ajax({
type: "POST",
async: true,
dataType: "json",
url: getTPLUrl + "assets/ajax/nicolausProgress.php?v=" + timestamp,
data: xParams,
success: function(data) {
if (data.status == 'ok') {
$('#loaderServicePremium').addClass('hide');
$('#removeServicePremium, #removeServicePremiumDesc').removeClass('hide');
} else {
$('#loaderServicePremium').addClass('hide');
$('#addServicePremium').removeClass('hide');
}
},
error: function(data) {
swal("Oops!", LNG_QUALCOSA_STORTO, "error");
$('#loaderServicePremium').addClass('hide');
$('#addServicePremium').removeClass('hide');
}
});
}
});
}
function removeService(service) {
window.requestAnimationFrame(() => {
if (service == 'premium') {
swal({
title: LNG_SWEET_ATTENZIONE,
text: "Möchten Sie diesen Service aus Ihrer Bestellung entfernen?",
type: "warning",
showCancelButton: true,
cancelButtonText: "Nein, abbrechen",
confirmButtonText: "Ja, entfernen!",
closeOnConfirm: true
},
function()
{
$('#removeServicePremium, #removeServicePremiumDesc').addClass('hide');
$('#loaderServicePremium').removeClass('hide');
const timestamp = getCustomTimestamp();
const xParams = "action=removeService"
+ "&service=" + service
+ "&id=" + villageID
+ "&code=" + villageCode
+ "&cart=" + villageCart
+ "&langCurrent=" + LANG_CURRENT;
window.requestAnimationFrame(() => {
$.ajax({
type: "POST",
async: true,
dataType: "json",
url: getTPLUrl + "assets/ajax/nicolausProgress.php?v=" + timestamp,
data: xParams,
success: function(data) {
if (data.status == 'ok') {
$('#loaderServicePremium').addClass('hide');
$('#addServicePremium').removeClass('hide');
} else {
$('#loaderServicePremium').addClass('hide');
$('#removeServicePremium, #removeServicePremiumDesc').removeClass('hide');
}
},
error: function(data) {
swal("Oops!", LNG_QUALCOSA_STORTO, "error");
$('#loaderServicePremium').addClass('hide');
$('#removeServicePremium, #removeServicePremiumDesc').removeClass('hide');
}
});
});
});
}
});
}
function paymentProceedGrimaldi() {
bCHeck = fCheckGuestsGrimaldi();
$('#buttonPaymentGrimaldi').addClass('hide');
$('.loaderPaymentGrimaldi').removeClass('hide');
if (!bCHeck) {
$('#buttonPaymentGrimaldi').removeClass('hide');
$('.loaderPaymentGrimaldi').addClass('hide');
} else if (!$('#condizioni_grimaldi').prop('checked')) {
swal({
title: "Oops!",
text: "Um mit der Buchung der Reise fortfahren zu können, ist die Annahme der Allgemeinen Geschäftsbedingungen erforderlich.",
imageUrl: getTPLImmaginiUrl + "sorry-male.png",
confirmButtonText: "Ok",
closeOnConfirm: true
});
$('#buttonPaymentGrimaldi').removeClass('hide');
$('.loaderPaymentGrimaldi').addClass('hide');
} else {
window.requestAnimationFrame(() => {
const sailGuests = {
"booking": {
"main": 0,
"name": "",
"lastName": "",
"sex": "",
"country": "",
"dob": "",
"dobloc": "",
"docType": "",
"docNumber": "",
"docNumber": "",
"pmr": 0,
"prefix": $("#piPrefisso").val() ?? "",
"phone": $("#piPhone").val() ?? "",
"email": $("#piEmail").val() ?? "",
"city": $("#piCitta").val() ?? "",
"address": $("#piIndirizzo").val() ?? "",
"zipCode": $("#piCap").val() ?? "",
"sosPrefix": $("#sosPrefisso").val() ?? "",
"sosPhone": $("#sosPhone").val() ?? "",
},
"adults": [],
"children": [],
"vehicles": [],
};
$(".targa").each(function() {
const index = $(this).data("index");
if ($("#piTarga" + index).val()) {
sailGuests.vehicles.push({
"targa": $("#piTarga" + index).val() ?? "",
"marca": $("#piMarca" + index).val() ?? "",
"modello": $("#piModello" + index).val() ?? "",
"tipoAlimentazione": $("#piTipoAlimentazione" + index).val() ?? "",
});
}
});
const adultIntestatario = parseInt($('input[name="intestatario"]:checked').val() ?? 0);
let iGuestAdult = 0;
$(".guestAdult").each(function() {
if ($("#paNome" + iGuestAdult).val()) {
if (iGuestAdult == adultIntestatario) {
sailGuests.booking.main = 1;
sailGuests.booking.name = $("#paNome" + iGuestAdult).val() ?? "";
sailGuests.booking.lastName = $("#paCognome" + iGuestAdult).val() ?? "";
sailGuests.booking.sex = $("#paSesso" + iGuestAdult).val() ?? "M";
sailGuests.booking.country = $("#paNazione" + iGuestAdult).val() ?? "";
sailGuests.booking.dob = $("#paDataNascita" + iGuestAdult).val() ?? "";
sailGuests.booking.dobloc = $("#paLuogoNascita" + iGuestAdult).val() ?? "";
sailGuests.booking.docType = $("#paTipoDocumento" + iGuestAdult).val() ?? "";
sailGuests.booking.docNumber = $("#paNumeroDocumento" + iGuestAdult).val() ?? "";
sailGuests.booking.pmr = $("#paPmr" + iGuestAdult).prop("checked") ? 1 : 0;
}
sailGuests.adults.push({
"main": (iGuestAdult == adultIntestatario ? 1 : 0),
"name": $("#paNome" + iGuestAdult).val() ?? "",
"lastName": $("#paCognome" + iGuestAdult).val() ?? "",
"sex": $("#paSesso" + iGuestAdult).val() ?? "",
"country": $("#paNazione" + iGuestAdult).val() ?? "",
"dob": $("#paDataNascita" + iGuestAdult).val() ?? "",
"dobloc": $("#paLuogoNascita" + iGuestAdult).val() ?? "",
"doctype": $("#paTipoDocumento" + iGuestAdult).val() ?? "",
"docnumber": $("#paNumeroDocumento" + iGuestAdult).val() ?? "",
"pmr": $("#paPmr" + iGuestAdult).prop("checked") ? 1 : 0
});
iGuestAdult++;
}
});
let igCount = 0;
$(".guestChild").each(function() {
if ($("#pcNome" + igCount).val()) {
sailGuests.children.push({
"name": $("#pcNome" + igCount).val() ?? "",
"lastName": $("#pcCognome" + igCount).val() ?? "",
"sex": $("#pcSesso" + igCount).val() ?? "",
"country": $("#pcNazione" + igCount).val() ?? "",
"dob": $("#pcDataNascita" + igCount).val() ?? "",
"dobloc": $("#pcLuogoNascita" + igCount).val() ?? "",
"doctype": $("#pcTipoDocumento" + igCount).val() ?? "",
"docnumber": $("#pcNumeroDocumento" + igCount).val() ?? "",
"pmr": $("#pcPmr" + igCount).prop("checked") ? 1 : 0
});
igCount++;
}
});
const xParams = "action=createOption"
+ "&cart=" + grimaldiCart
+ "&langCurrent=" + LANG_CURRENT
+ "&sailGuests=" + JSON.stringify(sailGuests)
+ "&multirischio=" + ($("#multirischio_si").prop("checked") ? "si" : "no");
const timestamp = getCustomTimestamp();
$.ajax({
type: "POST",
async: true,
dataType: "json",
url: getTPLUrl + "assets/ajax/grimaldiProgress.php?v=" + timestamp,
data: xParams,
success: function(data) {
if (data.status == 'ok') {
$('#modalCartComplete .modal-loader-grimaldi').addClass('hide');
if (countVillages == 1) {
$('.quoteStep').addClass('hide');
$('#logoBoxGrimaldi').addClass('hide');
$('#labelCartComplete').text('').removeClass('hide');
$('#modalCartComplete .modal-loader, #labelCartCompleteVerifica, #logoBoxNicolaus').removeClass('hide');
const xParams = "action=firstCheck"
+ "&id=" + villageID
+ "&code=" + villageCode
+ "&cart=" + villageCart
+ "&langCurrent=" + LANG_CURRENT;
const timestamp = getCustomTimestamp();
$.ajax({
type: "POST",
async: true,
dataType: "json",
url: getTPLUrl + "assets/ajax/nicolausProgress.php?v=" + timestamp,
data: xParams,
success: function(data) {
if (data.status == 'ok') {
/*if (data.rq && parseInt(data.rq) > 0) {
swal({
title: LNG_SWEET_ATTENZIONE,
text: "Almeno uno dei servizi di questo preventivo è ON REQUEST: disponibilità soggetta a riconferma da parte del fornitore. Procedendo con l'ordine effettui una Richiesta Impegnativa a seguito della quale Valtur verificherà tale disponibilità ed eventualmente procederà con la conferma.",
confirmButtonText: "Ok",
closeOnConfirm: true
});
}*/
$('#modalCartComplete .modal-loader').addClass('hide');
stepCall('extra');
} else {
$('#modalCartComplete').modal('hide');
}
},
error: function(data) {
swal("Oops!", LNG_QUALCOSA_STORTO, "error");
$('#modalCartComplete').modal('hide');
}
});
} else {
async function handlePaymentGrimaldi() {
await fSaveData();
// $('.loaderPaymentGrimaldi').addClass('hide');
// $('#buttonPaymentGrimaldi').removeClass('hide');
}
handlePaymentGrimaldi();
}
} else {
if (data.message) {
swal("Oops!", data.message, "error");
} else {
swal("Oops!", LNG_QUALCOSA_STORTO, "error");
}
$('#buttonPaymentGrimaldi').removeClass('hide');
$('.loaderPaymentGrimaldi').addClass('hide');
}
},
error: function(data) {
swal("Oops!", LNG_QUALCOSA_STORTO, "error");
$('#buttonPaymentGrimaldi').removeClass('hide');
$('.loaderPaymentGrimaldi').addClass('hide');
}
});
});
}
}
function paymentProceed() {
$('#buttonPayment').addClass('hide');
$('.loaderPayment').removeClass('hide');
if (!$('#condizioni_valtur').prop('checked')) {
swal({
title: "Oops!",
text: "Um mit der Buchung der Reise fortfahren zu können, ist die Annahme der Allgemeinen Geschäftsbedingungen erforderlich.",
imageUrl: getTPLImmaginiUrl + "sorry-male.png",
confirmButtonText: "Ok",
closeOnConfirm: true
});
} else {
window.requestAnimationFrame(() => {
async function handlePayment() {
await fSaveData();
$('.loaderPayment').addClass('hide');
$('#buttonPayment').removeClass('hide');
}
handlePayment();
});
}
}
function validateItalianDate(input) {
const datePattern = /^(\d{2})\/(\d{2})\/(\d{4})$/;
const match = input.value.match(datePattern);
const formGroup = input.closest('.form-group'); // || input.closest('.fg-sDataNascita');
formGroup.classList.remove("has-error");
if (!match) {
formGroup.classList.add("has-error");
input.value = ''; // Svuota il campo se il formato è errato
return false;
}
const day = parseInt(match[1], 10);
const month = parseInt(match[2], 10);
const year = parseInt(match[3], 10);
// Crea una data e verifica che i valori coincidano
const date = new Date(year, month - 1, day);
if (
date.getFullYear() === year &&
date.getMonth() === month - 1 &&
date.getDate() === day
) {
formGroup.classList.remove("has-error"); // La data è valida, rimuove l'errore
return true;
} else {
formGroup.classList.add("has-error"); // La data non è valida, aggiunge l'errore
input.value = ''; // Svuota il campo se la data è invalida
return false;
}
}
function rimuoviPrefisso(numero) {
return numero.replace(/^\+\d{1,3}/, '');
}
function pulisciNumero(numero) {
// 1) Rimuove tutti i caratteri che non siano cifre o il simbolo "+"
numero = numero.replace(/[^\d+]/g, '');
// 2) Se inizia con "+"
if (numero.startsWith('+')) {
// Rimuove i primi 3 caratteri, es. "+39" o "+44"
numero = numero.substring(3);
// 3) Se inizia con "00"
} else if (numero.startsWith('00')) {
// Rimuove i primi 4 caratteri, es. "0039", "0044"
numero = numero.substring(4);
}
// 4) Restituisce il numero rimanente
return numero;
}