Guest Reviews

What our guests say about our properties

Explore some of our apartments and houses in the local towns or contact us for offers!

'; printWindow.document.write(voucherHtml); printWindow.document.close(); printWindow.onload = function() { printWindow.print(); }; }); // Init to step 1 updateWizardStep(1); // Init pets checkbox to reflect includePets // Initialize Stripe Elements for embedded mode var stripeCfgInit = (typeof window.myrentStripeConfig !== 'undefined' && window.myrentStripeConfig) ? window.myrentStripeConfig : { enabled: false }; if (stripeCfgInit.enabled && stripeCfgInit.mode === 'embedded' && stripeCfgInit.publishable) { (function initStripeEmbedded() { function loadStripeJs(callback) { if (window.Stripe) { callback(); return; } var script = document.querySelector('script[src="https://js.stripe.com/v3/"]'); if (script) { script.addEventListener('load', callback); return; } script = document.createElement('script'); script.src = 'https://js.stripe.com/v3/'; script.onload = callback; document.head.appendChild(script); } loadStripeJs(function() { try { window.myrentStripe = window.Stripe(stripeCfgInit.publishable); var elements = window.myrentStripe.elements(); window.myrentStripeCard = elements.create('card', { hidePostalCode: true }); window.myrentStripeCard.mount('#stripe-card-element'); } catch (e) { console.error('Stripe init error:', e); var errEl = document.getElementById('stripe-card-errors'); if (errEl) { errEl.textContent = 'Card form could not be initialized. Please try again or use bank transfer.'; } } }); })(); } if (includePets) { jQuery('#booking-has-pets').prop('checked', true); } // Bind form submit to AJAX booking (desktop & mobile reuse) jQuery('#booking-modal').on('submit', '#booking-form', function(e) { e.preventDefault(); submitBooking(); }); } function startStripeEmbeddedPayment(fullName, hasPets, special) { var stripeCfg = (typeof window.myrentStripeConfig !== 'undefined' && window.myrentStripeConfig) ? window.myrentStripeConfig : { enabled: false }; if (!stripeCfg.enabled || stripeCfg.mode !== 'embedded' || !stripeCfg.publishable) { alert('Card payments are not available at the moment. Please use bank transfer.'); return; } var ctx = (typeof window.myrentWizardContext !== 'undefined' && window.myrentWizardContext) ? window.myrentWizardContext : {}; var depositNow = ctx.deposit || 0; if (!depositNow || depositNow <= 0) { alert('Cannot determine deposit amount for card payment.'); return; } var amountCents = Math.round(depositNow * 100); var $btn = jQuery('#booking-form button[type="submit"]'); var originalText = $btn.text(); $btn.prop('disabled', true).html(' Processing card payment...'); jQuery.ajax({ url: 'https://hitourist.travel/wp-admin/admin-ajax.php', type: 'POST', dataType: 'json', data: { // Koristimo alias action ime radi kompatibilnosti action: 'myrent_stripe_pi', amount: amountCents, currency: 'eur', object_id: jQuery('#booking-property-id').val(), checkin: jQuery('#booking-checkin').val(), checkout: jQuery('#booking-checkout').val(), guests: jQuery('#booking-guests').val() }, success: function(response) { if (!response.success || !response.data || !response.data.client_secret) { $btn.prop('disabled', false).text(originalText); alert('Unable to initialize card payment. Please try again or use bank transfer.'); return; } var clientSecret = response.data.client_secret; if (!window.myrentStripe || !window.myrentStripeCard) { $btn.prop('disabled', false).text(originalText); alert('Card form is not ready. Please try again or use bank transfer.'); return; } window.myrentStripe.confirmCardPayment(clientSecret, { payment_method: { card: window.myrentStripeCard, billing_details: { name: fullName, email: jQuery('#booking-email').val() || '' } } }).then(function(result) { if (result.error) { var errEl = document.getElementById('stripe-card-errors'); if (errEl) { errEl.textContent = result.error.message; } $btn.prop('disabled', false).text(originalText); } else if (result.paymentIntent && result.paymentIntent.status === 'succeeded') { window.myrentStripePaymentStatus = 'success'; if (!window.myrentWizardContext) { window.myrentWizardContext = {}; } window.myrentWizardContext.paymentIntentId = result.paymentIntent.id; // Nakon uspješnog plaćanja ponovno pozovi submitBooking da napravi MyRent rezervaciju $btn.prop('disabled', false).text(originalText); submitBooking(); } else { $btn.prop('disabled', false).text(originalText); alert('Card payment did not complete. Please try again or use bank transfer.'); } }); }, error: function() { $btn.prop('disabled', false).text(originalText); alert('Error initializing card payment. Please try again or use bank transfer.'); } }); } function startStripeCheckoutPayment(fullName, hasPets, special) { var stripeCfg = (typeof window.myrentStripeConfig !== 'undefined' && window.myrentStripeConfig) ? window.myrentStripeConfig : { enabled: false }; if (!stripeCfg.enabled || stripeCfg.mode !== 'checkout' || !stripeCfg.publishable) { alert("Card payments are not available at the moment. Please use bank transfer."); return; } var ctx = (typeof window.myrentWizardContext !== 'undefined' && window.myrentWizardContext) ? window.myrentWizardContext : {}; var depositNow = ctx.deposit || 0; if (!depositNow || depositNow <= 0) { alert("Cannot determine deposit amount for card payment."); return; } var amountCents = Math.round(depositNow * 100); // Store booking context in localStorage so we can auto-create MyRent booking after redirect try { var checkoutContext = { propertyId: jQuery('#booking-property-id').val(), checkin: jQuery('#booking-checkin').val(), checkout: jQuery('#booking-checkout').val(), guests: jQuery('#booking-guests').val(), total_price: jQuery('#booking-total-price').val(), fullName: fullName, email: jQuery('#booking-email').val(), phone: jQuery('#booking-phone').val(), country: jQuery('#booking-country').val(), hasPets: hasPets, special: special, source: 'desktop' }; if (window.localStorage) { window.localStorage.setItem('myrent_stripe_checkout_ctx', JSON.stringify(checkoutContext)); } } catch (e) { if (window.console) { console.error('Stripe Checkout context store error:', e); } } var $btn = jQuery('#booking-form button[type="submit"]'); var originalText = $btn.text(); $btn.prop('disabled', true).html(' Processing card payment...'); jQuery.ajax({ url: 'https://hitourist.travel/wp-admin/admin-ajax.php', type: 'POST', dataType: 'json', data: { action: 'myrent_stripe_create_checkout_session', amount: amountCents, currency: 'eur', object_id: jQuery('#booking-property-id').val(), checkin: jQuery('#booking-checkin').val(), checkout: jQuery('#booking-checkout').val(), guests: jQuery('#booking-guests').val() }, success: function(response) { if (!response.success || !response.data || !response.data.url) { $btn.prop('disabled', false).text(originalText); alert("Unable to initialize card payment. Please try again or use bank transfer."); return; } // Redirect to Stripe Checkout URL window.location.href = response.data.url; }, error: function() { $btn.prop('disabled', false).text(originalText); alert("Error initializing card payment. Please try again or use bank transfer."); } }); } // v3.9.286: Export showBookingWizardModal to window for booking-desktop.js window.showBookingWizardModal = showBookingWizardModal; // Legacy showBookingModal function is no longer used (kept for backwards compatibility) function showBookingModal(propertyId, checkIn, checkOut, guests, petsChoice) { showBookingWizardModal(propertyId, checkIn, checkOut, guests, petsChoice); } // React to wizard success to switch to step 3 window.addEventListener('bookingWizardSuccess', function() { if (jQuery('#booking-modal .booking-step.step-3').length) { if (typeof window.myrentUpdateWizardStep === 'function') { window.myrentUpdateWizardStep(3); } else { jQuery('#booking-modal .booking-step').hide().removeClass('active'); jQuery('#booking-modal .booking-step.step-3').show().addClass('active'); jQuery('#booking-modal .booking-step-indicator').each(function() { var s = jQuery(this).data('step'); if (s < 3) { jQuery(this).css('opacity', 1).find('span:first').css('background', '#38a169').css('color', '#fff'); } else if (s === 3) { jQuery(this).css('opacity', 1).find('span:first').css('background', '#c8a35f').css('color', '#fff'); } else { jQuery(this).css('opacity', 0.6).find('span:first').css('background', '#e2e8f0').css('color', '#4a5568'); } }); } // If guest portal URL is available, populate link box var portalUrl = jQuery('#booking-modal').data('guest-portal-url'); if (portalUrl) { jQuery('#booking-guest-portal-link').attr('href', portalUrl); jQuery('#booking-guest-portal').show(); jQuery('#booking-guest-portal-link-button').attr('href', portalUrl).show(); } // v3.9.234: Store booking data for voucher download window.desktopBookingData = { property: jQuery('#booking-modal h2:first').text() || '', dates: jQuery('#booking-modal').data('checkin') + ' - ' + jQuery('#booking-modal').data('checkout'), nights: jQuery('#booking-modal').data('nights') || '', guests: jQuery('#booking-modal').data('guests') || '', guestName: jQuery('#booking-full-name').val() || '', total: jQuery('#booking-modal').data('total') || '', guestPortalUrl: portalUrl || null }; } }); function getBookingIdempotencyKey(scope) { window.myrentBookingIdempotencyKeys = window.myrentBookingIdempotencyKeys || {}; if (!window.myrentBookingIdempotencyKeys[scope]) { if (window.crypto && typeof window.crypto.randomUUID === 'function') { window.myrentBookingIdempotencyKeys[scope] = window.crypto.randomUUID(); } else { window.myrentBookingIdempotencyKeys[scope] = 'booking-' + Date.now() + '-' + Math.random().toString(36).slice(2, 14); } } return window.myrentBookingIdempotencyKeys[scope]; } function clearBookingIdempotencyKey(scope) { if (window.myrentBookingIdempotencyKeys) { delete window.myrentBookingIdempotencyKeys[scope]; } } window.myrentGetBookingIdempotencyKey = getBookingIdempotencyKey; window.myrentClearBookingIdempotencyKey = clearBookingIdempotencyKey; // Submit booking to MyRent API function submitBooking() { var fullName = (jQuery('#booking-full-name').val() || '').trim(); var hasPets = jQuery('#booking-has-pets').length && jQuery('#booking-has-pets').is(':checked') ? 1 : 0; var special = jQuery('#booking-special').val() || ''; // Payment method selected in step 2 var paymentMethod = 'bank'; if (typeof window.myrentWizardContext !== 'undefined' && window.myrentWizardContext && window.myrentWizardContext.paymentMethod) { paymentMethod = window.myrentWizardContext.paymentMethod; } else if (jQuery('input[name="booking-payment-method"]').length) { paymentMethod = jQuery('input[name="booking-payment-method"]:checked').val() || 'bank'; } else if (jQuery('#booking-payment-method-hidden').length) { paymentMethod = jQuery('#booking-payment-method-hidden').val() || 'bank'; } // Ako je kartično plaćanje i Stripe embedded omogućen, prvo obavi Stripe plaćanje var stripeCfg = (typeof window.myrentStripeConfig !== 'undefined' && window.myrentStripeConfig) ? window.myrentStripeConfig : { enabled: false }; if (paymentMethod === 'card' && stripeCfg.enabled) { if (stripeCfg.mode === 'embedded' && !window.myrentStripePaymentStatus) { startStripeEmbeddedPayment(fullName, hasPets, special); return; } if (stripeCfg.mode === 'checkout') { startStripeCheckoutPayment(fullName, hasPets, special); return; } } if (window.myrentBookingSubmitting) { return; } window.myrentBookingSubmitting = true; // Append payment info to special requests so MyRent vidi čime gost želi platiti var cfg = (typeof window.myrentPaymentConfig !== 'undefined' && window.myrentPaymentConfig) ? window.myrentPaymentConfig : {}; if (paymentMethod === 'bank') { special = (special ? special + "\n\n" : '') + 'Payment method: Bank transfer'; } else if (paymentMethod === 'card') { var gwLabel = cfg.cardGateway || 'stripe'; special = (special ? special + "\n\n" : '') + 'Payment method: Credit card (' + gwLabel + ')'; } // debug removed: submitBooking paymentMethod var formData = { action: 'create_booking', property_id: jQuery('#booking-property-id').val(), checkin: jQuery('#booking-checkin').val(), checkout: jQuery('#booking-checkout').val(), guests: jQuery('#booking-guests').val(), total_price: jQuery('#booking-total-price').val(), guest_name: fullName, guest_email: jQuery('#booking-email').val(), guest_phone: jQuery('#booking-phone').val(), guest_country: jQuery('#booking-country').val(), special_requests: special, pets: hasPets, promo_code: (window.myrentPromoCode && typeof window.myrentPromoCode === 'string') ? window.myrentPromoCode : '', payment_method: paymentMethod, idempotency_key: getBookingIdempotencyKey('desktop') }; var $btn = jQuery('#booking-form button[type="submit"]'); var originalText = $btn.text(); $btn.prop('disabled', true).html(' Kreiram rezervaciju...'); jQuery.ajax({ url: 'https://hitourist.travel/wp-admin/admin-ajax.php', type: 'POST', data: formData, success: function(response) { if (response.success) { clearBookingIdempotencyKey('desktop'); window.myrentBookingSubmitting = false; // On success, move wizard to step 3 (confirmation) if (jQuery('#booking-modal .booking-step.step-3').length) { // Pohrani osnovne podatke za voucher i step 3 var ctx = (typeof window.myrentWizardContext !== 'undefined' && window.myrentWizardContext) ? window.myrentWizardContext : {}; var step3PaymentMethod = ctx.paymentMethod || 'bank'; window.desktopBookingData = window.desktopBookingData || {}; window.desktopBookingData.property = ctx.propertyName || (typeof propertyData !== 'undefined' ? propertyData.name : ''); window.desktopBookingData.dates = moment(jQuery('#booking-checkin').val()).format('DD.MM.YYYY') + ' - ' + moment(jQuery('#booking-checkout').val()).format('DD.MM.YYYY'); window.desktopBookingData.nights = (searchParams && searchParams.nights) ? searchParams.nights : ctx.nights || nights; window.desktopBookingData.guests = jQuery('#booking-guests').val(); window.desktopBookingData.total = Math.round(ctx.total || effectiveTotal); // Ako je odabran bank transfer, prikaži bankovne podatke u step 3 if (step3PaymentMethod === 'bank') { var cfgBank = (typeof window.myrentPaymentConfig !== 'undefined' && window.myrentPaymentConfig) ? window.myrentPaymentConfig : {}; var bankHtml = ''; bankHtml += '
'; bankHtml += '
Bank transfer payment details
'; var amountNow = ctx.deposit || (window.myrentDepositDetails && window.myrentDepositDetails.amount ? window.myrentDepositDetails.amount : 0); bankHtml += '
Amount to pay now: €' + Math.round(amountNow) + '
'; if (cfgBank.bankCompanyName) bankHtml += '
Company: ' + cfgBank.bankCompanyName + '
'; if (cfgBank.bankVatId) bankHtml += '
VAT ID / OIB: ' + cfgBank.bankVatId + '
'; if (cfgBank.bankAddress) bankHtml += '
Address: ' + cfgBank.bankAddress + '
'; if (cfgBank.bankAccountName) bankHtml += '
Bank account: ' + cfgBank.bankAccountName + '
'; if (cfgBank.bankIban) bankHtml += '
IBAN: ' + cfgBank.bankIban + '
'; if (cfgBank.bankSwift) bankHtml += '
SWIFT/BIC: ' + cfgBank.bankSwift + '
'; bankHtml += '
Please include your name and booking dates as payment reference.
'; bankHtml += '
'; jQuery('#booking-modal .booking-step.step-3').prepend(bankHtml); } var payload = response.data || {}; // attach booking info for step 3 (booking_id, rent_id if provided) if (payload.booking_id) { jQuery('#booking-modal').data('booking-id', payload.booking_id); } if (payload.rent_id) { jQuery('#booking-modal').data('rent-id', payload.rent_id); } if (payload.guest_portal_url) { jQuery('#booking-modal').data('guest-portal-url', payload.guest_portal_url); } var event = new Event('bookingWizardSuccess'); window.dispatchEvent(event); } else { alert('✅ ' + response.data.message); closeBookingModal(); location.reload(); } } else { alert('❌ ' + response.data.message); window.myrentBookingSubmitting = false; $btn.prop('disabled', false).text(originalText); } }, error: function() { alert('Error creating reservation. Please try again.'); window.myrentBookingSubmitting = false; $btn.prop('disabled', false).text(originalText); } }); } // Close booking modal function closeBookingModal() { jQuery('#booking-modal').remove(); jQuery('body').css('overflow', ''); } // v3.7.5: NEW Two-Month Calendar with Prices, Min Stay, and Changeover Days function generateAvailabilityCalendar() { var container = jQuery('#calendar-months-container'); if (container.length === 0) { container = jQuery('#availability-calendar'); } if (container.length === 0) { return; } var propertyId = container.closest('[data-property-id]').data('property-id') || (typeof propertyData !== 'undefined' ? propertyData.id : ''); if (!propertyId) { container.html('
Property ID nije pronađen.
'); return; } window.calendarContainer = container; window.calendarPropertyId = propertyId; container.html('
Loading calendar...
'); // v3.7.8: Wait for calendar rules (loaded via AJAX in single-property.php) jQuery(document).off('myrentCalendarRulesLoaded.newcal').on('myrentCalendarRulesLoaded.newcal', function() { // Start from first available check-in date if (window.myrentFirstAvailableCheckin) { window.currentCalendarStart = moment(window.myrentFirstAvailableCheckin).startOf('month'); } else { window.currentCalendarStart = moment().startOf('month'); } renderTwoMonthCalendar(); }); // If rules already loaded, render immediately if (window.myrentCalendarRulesLoaded && window.myrentCalendarRules) { if (window.myrentFirstAvailableCheckin) { window.currentCalendarStart = moment(window.myrentFirstAvailableCheckin).startOf('month'); } else { window.currentCalendarStart = moment().startOf('month'); } renderTwoMonthCalendar(); } else { // Wait max 3 seconds for rules, then show basic calendar setTimeout(function() { if (!window.myrentCalendarRulesLoaded) { window.currentCalendarStart = moment().startOf('month'); renderTwoMonthCalendar(); } }, 3000); } } // v3.7.17: Render calendar - two months on desktop, one month on mobile with nav arrows function renderTwoMonthCalendar() { var container = window.calendarContainer || jQuery('#calendar-months-container'); if (!container.length) return; var isMobile = window.innerWidth <= 768; var monthsToShow = isMobile ? 1 : 2; var html = '
'; var startMonth = window.currentCalendarStart || moment().startOf('month'); // Generate months for (var i = 0; i < monthsToShow; i++) { var month = startMonth.clone().add(i, 'months'); var isFirst = (i === 0); var isLast = (i === monthsToShow - 1); html += generateFullMonthCalendar(month, isFirst, isLast, isMobile); } html += '
'; // Add legend html += '
'; html += '
Available
'; html += '
Booked
'; html += '
Changeover
'; html += '
Fixed check-in day
'; html += '
'; container.html(html); // Bind click events for date selection bindCalendarClicks(); } // v3.7.17: Helper function to check if a day is booked/unavailable function isDayBooked(dateStr) { if (!window.myrentCalendarRules || !window.myrentCalendarRules[dateStr]) { return false; } var rule = window.myrentCalendarRules[dateStr]; return rule.is_booked || !rule.free; } // v3.7.17: Generate single month with navigation arrows in header function generateFullMonthCalendar(month, showPrev, showNext, isMobile) { var monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; var weekdays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; var html = '
'; html += '
'; // v3.7.17: Add prev arrow on first month if (showPrev) { html += ''; } else if (!isMobile) { html += ''; } html += '' + monthNames[month.month()] + ' ' + month.format('YYYY') + ''; // v3.7.17: Add next arrow on last month (or on mobile single month) if (showNext || isMobile) { html += ''; } else if (!isMobile) { html += ''; } html += '
'; html += '
'; weekdays.forEach(function(day) { html += '
' + day + '
'; }); html += '
'; html += '
'; var firstDay = month.clone().startOf('month'); var lastDay = month.clone().endOf('month'); var startOffset = firstDay.day(); // 0 = Sunday // Empty cells before first day for (var i = 0; i < startOffset; i++) { html += '
'; } var today = moment(); for (var day = 1; day <= lastDay.date(); day++) { var currentDate = month.clone().date(day); var dateStr = currentDate.format('YYYY-MM-DD'); var isPast = currentDate.isBefore(today, 'day'); var isToday = currentDate.isSame(today, 'day'); // v3.7.13: Get data from myrentCalendarRules (loaded via AJAX in single-property.php) var rule = (window.myrentCalendarRules && window.myrentCalendarRules[dateStr]) ? window.myrentCalendarRules[dateStr] : null; var price = rule ? (rule.price || 0) : 0; var minStay = rule ? (parseInt(rule.min_stay, 10) || 1) : 1; var isFree = rule ? rule.free : true; var isBooked = rule ? rule.is_booked : false; var canCheckIn = rule ? rule.check_in : true; var canCheckOut = rule ? rule.check_out : true; // v3.7.13: Calculate transition days based on adjacent days var prevDateStr = currentDate.clone().subtract(1, 'day').format('YYYY-MM-DD'); var nextDateStr = currentDate.clone().add(1, 'day').format('YYYY-MM-DD'); var prevDayBooked = isDayBooked(prevDateStr); var currentDayBooked = isBooked || !isFree; var nextDayBooked = isDayBooked(nextDateStr); // v3.7.13: CHANGEOVER DAY LOGIC (corrected): // A "changeover" day is when guests check OUT in the morning and new guests check IN in the afternoon // API marks this day as "booked" but it's actually available for new check-in // 1. CHECKOUT-POSITION (Changeover day - guests leaving): // Day is marked as BOOKED but PREVIOUS day was FREE // = This is the checkout day of a reservation (guests leave morning, new can arrive) // = Diagonal: green top-left → red bottom-right (↘) // = Clickable as both CHECKOUT and CHECK-IN date var isCheckoutPosition = currentDayBooked && !prevDayBooked && !isPast; // 2. CHECKIN-POSITION (Day after checkout): // Day is FREE but PREVIOUS day was BOOKED // = First fully free day after a booking ends // = Diagonal: red top-left → green bottom-right (↗) // = Clickable as CHECK-IN date var isCheckinPosition = !currentDayBooked && prevDayBooked && !isPast; // Build CSS classes var classes = 'cal-day'; if (isPast) { classes += ' past'; } else if (isCheckoutPosition) { // Changeover day - checkout morning, checkin afternoon // Show diagonal ↘ (green→red) - this day is available for new booking classes += ' checkout-position available'; } else if (isCheckinPosition) { // Day after booking ends - diagonal ↗ (red→green) classes += ' checkin-position available'; } else if (currentDayBooked) { classes += ' unavailable'; } else if (!canCheckIn && isFree) { classes += ' checkout-only available'; } else if (isFree) { classes += ' available'; } if (isToday) classes += ' today'; // v3.7.13: Check-in/out allowed on changeover days and free days if ((canCheckIn && !currentDayBooked) || isCheckoutPosition) classes += ' can-checkin'; if ((canCheckOut && !currentDayBooked) || isCheckoutPosition) classes += ' can-checkout'; html += '
'; html += '
' + day + '
'; // Show price if available and not past (show on changeover days too) if (price > 0 && !isPast && (!currentDayBooked || isCheckoutPosition)) { html += '
€' + Math.round(price) + '
'; } // Show min_stay if > 1 and can check-in (including changeover days) if (minStay > 1 && (canCheckIn || isCheckoutPosition) && (!currentDayBooked || isCheckoutPosition)) { html += '
min ' + minStay + '
'; } html += '
'; } html += '
'; return html; } // v3.7.12: Bind click events for selecting dates function bindCalendarClicks() { jQuery('.cal-day.available, .cal-day.checkin-position, .cal-day.checkout-position').off('click').on('click', function() { var $day = jQuery(this); var dateStr = $day.data('date'); var canCheckin = $day.hasClass('can-checkin'); // v3.7.2: Get booking pattern for messages var bookingPattern = getCalendarBookingPattern(); if (!canCheckin && !window.myrentCalSelectedCheckin) { // Can't start booking on non-checkin day var dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; var selectedDay = dayNames[moment(dateStr).day()]; var message = 'Check-in is not allowed on ' + selectedDay + '.'; if (bookingPattern) { message += '\n\nThis property requires ' + bookingPattern + ' bookings.'; } message += '\n\nPlease select a valid check-in day.'; alert(message); return; } if (!window.myrentCalSelectedCheckin) { // First click - select check-in window.myrentCalSelectedCheckin = dateStr; $day.addClass('selected-checkin'); jQuery('.cal-day').removeClass('in-range selected-checkout'); } else { // Second click - select check-out var checkinMoment = moment(window.myrentCalSelectedCheckin); var checkoutMoment = moment(dateStr); if (checkoutMoment.isSameOrBefore(checkinMoment)) { // Reset and start over jQuery('.cal-day').removeClass('selected-checkin selected-checkout in-range'); window.myrentCalSelectedCheckin = dateStr; $day.addClass('selected-checkin'); return; } // Validate min_stay var nights = checkoutMoment.diff(checkinMoment, 'days'); var minStay = parseInt(jQuery('.cal-day[data-date="' + window.myrentCalSelectedCheckin + '"]').data('minstay')) || 1; if (nights < minStay) { var message = 'Minimum stay for this period is ' + minStay + ' nights.'; message += '\nYou selected ' + nights + ' night' + (nights !== 1 ? 's' : '') + '.'; message += '\n\nPlease select at least ' + minStay + ' nights.'; alert(message); return; } // Check if checkout is allowed on this day var canCheckout = $day.hasClass('can-checkout'); if (!canCheckout) { var dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; var selectedDay = dayNames[checkoutMoment.day()]; var message = 'Check-out is not allowed on ' + selectedDay + '.'; if (bookingPattern) { message += '\n\nThis property requires ' + bookingPattern + ' bookings.'; } message += '\n\nPlease select a valid check-out day.'; alert(message); return; } // v3.7.12: Validate that all days in range are available (no booked days in between) var blockedDates = checkForBlockedDatesInRange(checkinMoment, checkoutMoment); if (blockedDates.length > 0) { var message = 'The selected period contains unavailable dates:\n\n'; blockedDates.forEach(function(d) { message += '• ' + moment(d).format('DD.MM.YYYY') + '\n'; }); message += '\nPlease select a period without booked dates.'; alert(message); return; } // Valid selection - mark checkout and highlight range $day.addClass('selected-checkout'); highlightRange(window.myrentCalSelectedCheckin, dateStr); // Update the daterangepicker input and calculate price updateDatepickerFromCalendar(window.myrentCalSelectedCheckin, dateStr, nights); } }); } // v3.7.12: Check if there are any blocked/booked dates in the selected range function checkForBlockedDatesInRange(startMoment, endMoment) { var blockedDates = []; var current = startMoment.clone().add(1, 'day'); // Start from day after check-in while (current.isBefore(endMoment, 'day')) { var dateStr = current.format('YYYY-MM-DD'); // Check if this date is booked/unavailable if (window.myrentCalendarRules && window.myrentCalendarRules[dateStr]) { var rule = window.myrentCalendarRules[dateStr]; if (rule.is_booked || !rule.free) { blockedDates.push(dateStr); } } current.add(1, 'day'); } return blockedDates; } // v3.7.2: Get booking pattern from calendar rules function getCalendarBookingPattern() { if (!window.myrentCalendarRules) return null; var dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; var checkinDays = {}; var dates = Object.keys(window.myrentCalendarRules).slice(0, 30); dates.forEach(function(dateStr) { var rule = window.myrentCalendarRules[dateStr]; if (rule.check_in && rule.free && !rule.is_booked) { var dayOfWeek = moment(dateStr).day(); checkinDays[dayOfWeek] = (checkinDays[dayOfWeek] || 0) + 1; } }); var maxCount = 0; var dominantDay = -1; Object.keys(checkinDays).forEach(function(day) { if (checkinDays[day] > maxCount) { maxCount = checkinDays[day]; dominantDay = parseInt(day); } }); if (dominantDay >= 0 && maxCount >= 3) { return dayNames[dominantDay] + ' to ' + dayNames[dominantDay]; } return null; } // v3.7.0: Highlight range between check-in and check-out function highlightRange(startDate, endDate) { var start = moment(startDate); var end = moment(endDate); jQuery('.cal-day').removeClass('in-range'); jQuery('.cal-day').each(function() { var $day = jQuery(this); var dayDate = moment($day.data('date')); if (dayDate.isAfter(start) && dayDate.isBefore(end)) { $day.addClass('in-range'); } }); } // v3.7.2: Update daterangepicker input from calendar selection AND calculate price function updateDatepickerFromCalendar(checkin, checkout, nights) { var checkinMoment = moment(checkin); var checkoutMoment = moment(checkout); // Update desktop datepicker var $desktopPicker = jQuery('#property-daterange'); if ($desktopPicker.length && $desktopPicker.data('daterangepicker')) { var picker = $desktopPicker.data('daterangepicker'); picker.setStartDate(checkinMoment); picker.setEndDate(checkoutMoment); $desktopPicker.val(checkinMoment.format('DD.MM.YYYY') + ' - ' + checkoutMoment.format('DD.MM.YYYY')); } // Update mobile datepicker var $mobilePicker = jQuery('#mobile-daterange'); if ($mobilePicker.length && $mobilePicker.data('daterangepicker')) { var mobilePicker = $mobilePicker.data('daterangepicker'); mobilePicker.setStartDate(checkinMoment); mobilePicker.setEndDate(checkoutMoment); $mobilePicker.val(checkinMoment.format('DD.MM.YYYY') + ' - ' + checkoutMoment.format('DD.MM.YYYY')); } // v3.7.5: Calculate and display price var checkinDisplay = checkinMoment.format('DD.MM.YYYY'); var checkoutDisplay = checkoutMoment.format('DD.MM.YYYY'); var nightsLabel = nights === 1 ? 'night' : 'nights'; jQuery.ajax({ url: 'https://hitourist.travel/wp-admin/admin-ajax.php', type: 'POST', data: { action: 'get_property_price', property_id: window.calendarPropertyId, checkin: checkin, checkout: checkout }, success: function(response) { if (response.success && response.data && response.data.total_price > 0) { var price = parseFloat(response.data.total_price); var responseNights = parseInt(response.data.nights) || nights; var pricePerNight = Math.round(price / responseNights); // Update #price-total-amount and related elements directly jQuery('#price-total-amount').text('€' + Math.round(price).toLocaleString()); jQuery('#price-period-info').text(checkinDisplay + ' → ' + checkoutDisplay); jQuery('#price-breakdown-info').text(responseNights + ' ' + nightsLabel + ' × €' + pricePerNight + ' per night'); jQuery('#booking-total-price-display').fadeIn(); // Update total price display widget (if function exists) if (typeof window.updateTotalPriceDisplay === 'function') { window.updateTotalPriceDisplay(checkinDisplay, checkoutDisplay, responseNights, price); } // Update booking period price display updateCalendarPriceDisplay(checkinMoment, checkoutMoment, responseNights, price); // v3.7.15: Store validated dates globally for booking - BOTH objects window.myrentValidatedBooking = { checkin: checkin, checkout: checkout, nights: responseNights, price: price, valid: true }; // v3.7.15: Also update searchParams for proceedToBooking function window.searchParams = { checkin: checkin, checkout: checkout, guests: window.searchParams ? (window.searchParams.guests || 2) : 2, nights: responseNights, totalPrice: price }; // console.log('💰 Price stored in searchParams:', window.searchParams); // console.log('💰 Price stored in myrentValidatedBooking:', window.myrentValidatedBooking); // v3.7.22: Store selected dates for mobile modal window.calendarSelectedDates = { checkin: checkin, checkout: checkout, nights: responseNights, totalPrice: price }; // console.log('📱 [CALENDAR] calendarSelectedDates set:', window.calendarSelectedDates); // v3.7.23: Update mobile floating button with selected price and change text var $mobileFloat = jQuery('#mobile-booking-float'); // console.log('📱 [CALENDAR] Mobile float button found:', $mobileFloat.length > 0); if ($mobileFloat.length) { $mobileFloat.addClass('has-dates'); // Update price display jQuery('#mobile-float-nights').text(responseNights + (responseNights === 1 ? ' night' : ' nights')); jQuery('#mobile-float-amount').text('€' + Math.round(price).toLocaleString()); jQuery('#mobile-float-period').text(''); // Change button text and icon jQuery('#mobile-float-text').text('Book Now'); jQuery('#mobile-float-icon').removeClass('fa-calendar').addClass('fa-check'); // console.log('📱 [CALENDAR] Mobile float button updated - price:', price, ', text: Book Now'); } // v3.7.23: Check if mobile view - open modal instead of scrolling var isMobile = window.innerWidth < 992; // console.log('📱 [CALENDAR] Is mobile view:', isMobile, '(width:', window.innerWidth, ')'); // console.log('📱 [CALENDAR] openMobileBooking function exists:', typeof openMobileBooking === 'function'); // console.log('📱 [CALENDAR] window.openMobileBooking exists:', typeof window.openMobileBooking === 'function'); if (isMobile) { // On mobile: open booking modal directly // console.log('📱 [CALENDAR] Attempting to open mobile modal...'); setTimeout(function() { if (typeof openMobileBooking === 'function') { // console.log('📱 [CALENDAR] Calling openMobileBooking()'); openMobileBooking(); } else if (typeof window.openMobileBooking === 'function') { // console.log('📱 [CALENDAR] Calling window.openMobileBooking()'); window.openMobileBooking(); } else { console.error('📱 [CALENDAR] ERROR: openMobileBooking function not found!'); // Fallback: try to show modal directly var $modal = jQuery('#mobile-booking-modal'); if ($modal.length) { // console.log('📱 [CALENDAR] Fallback: showing modal directly'); $modal.css('display', 'flex'); document.body.style.overflow = 'hidden'; } } }, 300); } else { // On desktop: scroll to booking card // console.log('📱 [CALENDAR] Desktop view - scrolling to booking card'); setTimeout(function() { var $bookingCard = jQuery('.booking-card'); if ($bookingCard.length) { jQuery('html, body').animate({ scrollTop: $bookingCard.offset().top - 100 }, 800); // Pulse the Book Now button var $bookBtn = $bookingCard.find('.btn-success, button[type="submit"]'); if ($bookBtn.length) { $bookBtn.addClass('pulse-animation'); setTimeout(function() { $bookBtn.removeClass('pulse-animation'); }, 2000); } // Show confirmation hint - v3.9.72: Compact inline hint that doesn't push content if (jQuery('.calendar-booking-hint').length === 0) { // Add hint AFTER the date selector, not at top var $dateSelector = $bookingCard.find('.booking-dates, #booking-dates-display, .date-selector').first(); if ($dateSelector.length) { $dateSelector.after('
Dates selected! Click "Book Now" below.
'); } else { $bookingCard.find('.booking-widget-content, .card-body').first().prepend('
Dates selected! Click "Book Now" below.
'); } setTimeout(function() { jQuery('.calendar-booking-hint').fadeOut(function() { jQuery(this).remove(); }); }, 4000); } } }, 300); } } else { jQuery('#booking-total-price-display').fadeOut(); window.myrentValidatedBooking = { valid: false }; } }, error: function(xhr, status, error) { window.myrentValidatedBooking = { valid: false }; } }); } // v3.7.5: Update price display from calendar function updateCalendarPriceDisplay(startDate, endDate, nights, price) { // Remove existing price display jQuery('.booking-period-price').remove(); var nightsLabel = nights === 1 ? 'night' : 'nights'; var pricePerNight = Math.round(price / nights); var html = '
'; html += '
'; html += '
'; html += ''; html += startDate.format('DD.MM.YYYY') + ' → ' + endDate.format('DD.MM.YYYY'); html += '
'; html += '
'; html += '€' + Math.round(price).toLocaleString(); html += '
'; html += '
'; html += nights + ' ' + nightsLabel + ' × €' + pricePerNight + '/night'; html += '
'; html += '
'; html += '
'; jQuery('.price-display').after(html); } // Navigation functions function previousMonth() { window.currentCalendarStart = window.currentCalendarStart.subtract(1, 'month'); window.myrentCalSelectedCheckin = null; renderTwoMonthCalendar(); } function nextMonth() { window.currentCalendarStart = window.currentCalendarStart.add(1, 'month'); window.myrentCalSelectedCheckin = null; renderTwoMonthCalendar(); } // v3.7.17: Make navigation functions global window.previousMonth = previousMonth; window.nextMonth = nextMonth; // v3.7.17: Re-render calendar on window resize (for mobile/desktop switch) var resizeTimer; jQuery(window).on('resize', function() { clearTimeout(resizeTimer); resizeTimer = setTimeout(function() { if (jQuery('#calendar-months-container').length > 0) { renderTwoMonthCalendar(); } }, 250); }); // Initialize calendar if (jQuery('#calendar-months-container').length > 0 || jQuery('#availability-calendar').length > 0) { if (typeof moment !== 'undefined') { generateAvailabilityCalendar(); } else { setTimeout(function() { if (typeof moment !== 'undefined') { generateAvailabilityCalendar(); } }, 100); } }