🏨 Hotel Booking Enhancements: - Implemented Eagle Booking Advanced Pricing add-on - Added Booking.com-style rate management system - Created professional calendar interface for pricing - Integrated deals and discounts functionality 💰 Advanced Pricing Features: - Dynamic pricing models (per room, per person, per adult) - Base rates, adult rates, and child rates management - Length of stay discounts and early bird deals - Mobile rates and secret deals implementation - Seasonal promotions and flash sales 📅 Availability Management: - Real-time availability tracking - Stop sell and restriction controls - Closed to arrival/departure functionality - Minimum/maximum stay requirements - Automatic sold-out management 💳 Payment Integration: - Maintained Redsys payment gateway integration - Seamless integration with existing Eagle Booking - No modifications to core Eagle Booking plugin 🛠️ Technical Implementation: - Custom database tables for advanced pricing - WordPress hooks and filters integration - AJAX-powered admin interface - Data migration from existing Eagle Booking - Professional calendar view for revenue management 📊 Admin Interface: - Booking.com-style management dashboard - Visual rate and availability calendar - Bulk operations for date ranges - Statistics and analytics dashboard - Modal dialogs for quick editing 🔧 Code Quality: - WordPress coding standards compliance - Secure database operations with prepared statements - Proper input validation and sanitization - Error handling and logging - Responsive admin interface 🤖 Generated with Claude Code (https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
99 lines
3.9 KiB
PHP
99 lines
3.9 KiB
PHP
<?php
|
|
/* --------------------------------------------------------------------------
|
|
* Eagle Booking / Dates Exceptions
|
|
* Author: Eagle Themes
|
|
* Since: 1.0.4
|
|
* Modified: 1.2.4.5
|
|
---------------------------------------------------------------------------*/
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
function eb_room_is_available_block($eb_room_id, $eb_checkin, $eb_checkout) {
|
|
|
|
if ( $eb_checkin && $eb_checkout ) {
|
|
|
|
// Get Room Exceptions
|
|
$eb_exceptions_array = get_post_meta($eb_room_id, 'eagle_booking_mtb_room_block_exceptions', true);
|
|
|
|
// Set the check circle
|
|
$eb_check_start_date_format = DateTime::createFromFormat("m/d/Y", $eb_checkin)->format('m/d/Y');
|
|
$eb_check_end_date_format = DateTime::createFromFormat("m/d/Y", $eb_checkout)->format('m/d/Y');
|
|
$eb_check_circle = eb_total_booking_nights($eb_check_start_date_format, $eb_check_end_date_format);
|
|
|
|
// Initialize
|
|
$eb_is_available_block = true;
|
|
|
|
// Check the Room Blocks
|
|
if (!empty($eb_exceptions_array)) {
|
|
|
|
for ($eb_exceptions_array_i = 0; $eb_exceptions_array_i < count($eb_exceptions_array); $eb_exceptions_array_i++) {
|
|
|
|
// Get exception path
|
|
$eb_page_by_path = get_post($eb_exceptions_array[$eb_exceptions_array_i], OBJECT, 'eagle_exceptions');
|
|
|
|
if ( $eb_page_by_path ) {
|
|
|
|
// Exceptions MTB
|
|
$eb_exception_id = $eb_page_by_path->ID;
|
|
|
|
$eb_exception_name = get_the_title($eb_exception_id);
|
|
$eb_mtb_exception_date_from = get_post_meta($eb_exception_id, 'eagle_booking_mtb_exception_date_from', true);
|
|
$eb_mtb_exception_date_to = get_post_meta($eb_exception_id, 'eagle_booking_mtb_exception_date_to', true);
|
|
//$eb_mbt_exception_repeat = get_post_meta($eb_exception_id, 'eagle_booking_mtb_exception_repeat', true);
|
|
|
|
// Check if the exception still exists (in case it get deleted without updating the room)
|
|
if ( !empty( $eb_mtb_exception_date_from ) && !empty( $eb_mtb_exception_date_to ) ) {
|
|
|
|
// Get the total blocked booking nights
|
|
$eb_blocked_booking_nights = eb_total_booking_nights($eb_mtb_exception_date_from, $eb_mtb_exception_date_to);
|
|
|
|
// Format Exception Dates
|
|
$eb_new_date_from_ex_format = DateTime::createFromFormat("m/d/Y", $eb_mtb_exception_date_from)->format('Y/m/d');
|
|
$eb_new_date_to_ex_format = DateTime::createFromFormat("m/d/Y", $eb_mtb_exception_date_to)->format('Y/m/d');
|
|
|
|
// Set the check circle
|
|
$eb_checked_date = DateTime::createFromFormat("m/d/Y", $eb_checkin)->format('m/d/Y');
|
|
|
|
|
|
//Bug: Further investigation needed (it check checkin + 1)
|
|
$eb_checked_date = date('m/d/Y', strtotime($eb_checked_date . ' - 1 days'));
|
|
|
|
for ($eb_i_1 = 0; $eb_i_1 <= $eb_check_circle; $eb_i_1++) {
|
|
|
|
|
|
$eb_blocked_date = $eb_new_date_from_ex_format;
|
|
|
|
for ($eb_i_2 = 0; $eb_i_2 <= $eb_blocked_booking_nights; $eb_i_2++) {
|
|
|
|
|
|
if ($eb_checked_date == $eb_blocked_date) {
|
|
|
|
// echo $eb_checked_date .' = '. $eb_blocked_date;
|
|
$eb_is_available_block = false;
|
|
|
|
}
|
|
|
|
$eb_blocked_date = date('Y/m/d', strtotime($eb_blocked_date . ' + 1 days'));
|
|
|
|
}
|
|
|
|
$eb_checked_date = date('Y/m/d', strtotime($eb_checked_date . ' + 1 days'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
return $eb_is_available_block;
|
|
|
|
}
|
|
|
|
}
|