394 lines
8.9 KiB
PHP
Raw Normal View History

Hotel Raxa - Advanced Booking System Implementation 🏨 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>
2025-07-11 07:43:22 +02:00
<?php
/**
* Eagle Booking Advanced Pricing - Main Admin View
*
* @package EB_Advanced_Pricing
* @since 1.0.0
*/
defined('ABSPATH') || exit;
// Get current tab
$current_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'calendar';
// Get available rooms
$rooms = get_posts(array(
'post_type' => 'eagle_rooms',
'posts_per_page' => -1,
'post_status' => 'publish'
));
$current_room = isset($_GET['room_id']) ? intval($_GET['room_id']) : (count($rooms) > 0 ? $rooms[0]->ID : 0);
?>
<div class="wrap">
<h1><?php _e('Eagle Booking Advanced Pricing', 'eb-advanced-pricing'); ?></h1>
<div class="eb-ap-header">
<div class="eb-ap-room-selector">
<label for="eb-ap-room-select"><?php _e('Select Room:', 'eb-advanced-pricing'); ?></label>
<select id="eb-ap-room-select" name="room_id" onchange="ebApChangeRoom(this.value)">
<?php foreach ($rooms as $room): ?>
<option value="<?php echo $room->ID; ?>" <?php selected($current_room, $room->ID); ?>>
<?php echo esc_html($room->post_title); ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="eb-ap-date-selector">
<input type="date" id="eb-ap-start-date" value="<?php echo date('Y-m-d'); ?>" />
<span>to</span>
<input type="date" id="eb-ap-end-date" value="<?php echo date('Y-m-d', strtotime('+30 days')); ?>" />
<button class="button" onclick="ebApUpdateView()"><?php _e('Update View', 'eb-advanced-pricing'); ?></button>
</div>
</div>
<nav class="nav-tab-wrapper">
<a href="?page=eb-advanced-pricing&tab=calendar&room_id=<?php echo $current_room; ?>"
class="nav-tab <?php echo $current_tab == 'calendar' ? 'nav-tab-active' : ''; ?>">
<?php _e('Calendar View', 'eb-advanced-pricing'); ?>
</a>
<a href="?page=eb-advanced-pricing&tab=rates&room_id=<?php echo $current_room; ?>"
class="nav-tab <?php echo $current_tab == 'rates' ? 'nav-tab-active' : ''; ?>">
<?php _e('Rate Management', 'eb-advanced-pricing'); ?>
</a>
<a href="?page=eb-advanced-pricing&tab=availability&room_id=<?php echo $current_room; ?>"
class="nav-tab <?php echo $current_tab == 'availability' ? 'nav-tab-active' : ''; ?>">
<?php _e('Availability', 'eb-advanced-pricing'); ?>
</a>
<a href="?page=eb-advanced-pricing&tab=deals&room_id=<?php echo $current_room; ?>"
class="nav-tab <?php echo $current_tab == 'deals' ? 'nav-tab-active' : ''; ?>">
<?php _e('Deals & Discounts', 'eb-advanced-pricing'); ?>
</a>
<a href="?page=eb-advanced-pricing&tab=bulk&room_id=<?php echo $current_room; ?>"
class="nav-tab <?php echo $current_tab == 'bulk' ? 'nav-tab-active' : ''; ?>">
<?php _e('Bulk Operations', 'eb-advanced-pricing'); ?>
</a>
<a href="?page=eb-advanced-pricing&tab=settings&room_id=<?php echo $current_room; ?>"
class="nav-tab <?php echo $current_tab == 'settings' ? 'nav-tab-active' : ''; ?>">
<?php _e('Settings', 'eb-advanced-pricing'); ?>
</a>
</nav>
<div class="eb-ap-content">
<?php
switch ($current_tab) {
case 'calendar':
include 'calendar.php';
break;
case 'rates':
include 'rates.php';
break;
case 'availability':
include 'availability.php';
break;
case 'deals':
include 'deals.php';
break;
case 'bulk':
include 'bulk.php';
break;
case 'settings':
include 'settings.php';
break;
default:
include 'calendar.php';
}
?>
</div>
</div>
<script>
function ebApChangeRoom(roomId) {
const currentUrl = new URL(window.location.href);
currentUrl.searchParams.set('room_id', roomId);
window.location.href = currentUrl.toString();
}
function ebApUpdateView() {
const startDate = document.getElementById('eb-ap-start-date').value;
const endDate = document.getElementById('eb-ap-end-date').value;
if (startDate && endDate) {
const currentUrl = new URL(window.location.href);
currentUrl.searchParams.set('start_date', startDate);
currentUrl.searchParams.set('end_date', endDate);
window.location.href = currentUrl.toString();
}
}
</script>
<style>
.eb-ap-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
padding: 15px;
background: #f9f9f9;
border: 1px solid #ddd;
border-radius: 4px;
}
.eb-ap-room-selector select,
.eb-ap-date-selector input {
margin: 0 5px;
padding: 5px 10px;
}
.eb-ap-content {
margin-top: 20px;
}
.eb-ap-calendar {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
.eb-ap-calendar th,
.eb-ap-calendar td {
border: 1px solid #ddd;
padding: 8px;
text-align: center;
vertical-align: middle;
}
.eb-ap-calendar th {
background-color: #f5f5f5;
font-weight: bold;
}
.eb-ap-calendar .rate-cell {
background-color: #e8f4f8;
cursor: pointer;
position: relative;
}
.eb-ap-calendar .rate-cell:hover {
background-color: #d1ecf1;
}
.eb-ap-calendar .availability-cell {
background-color: #f8f9fa;
cursor: pointer;
}
.eb-ap-calendar .availability-cell:hover {
background-color: #e9ecef;
}
.eb-ap-calendar .deal-cell {
background-color: #d4edda;
cursor: pointer;
}
.eb-ap-calendar .deal-cell:hover {
background-color: #c3e6cb;
}
.eb-ap-calendar .blocked-cell {
background-color: #f8d7da;
color: #721c24;
}
.eb-ap-calendar .sold-out-cell {
background-color: #ffeaa7;
color: #636e72;
}
.eb-ap-form-row {
display: flex;
gap: 15px;
margin-bottom: 15px;
align-items: center;
}
.eb-ap-form-group {
flex: 1;
}
.eb-ap-form-group label {
display: block;
margin-bottom: 5px;
font-weight: bold;
}
.eb-ap-form-group input,
.eb-ap-form-group select,
.eb-ap-form-group textarea {
width: 100%;
padding: 8px;
border: 1px solid #ddd;
border-radius: 4px;
}
.eb-ap-section {
background: #fff;
padding: 20px;
margin-bottom: 20px;
border: 1px solid #ddd;
border-radius: 4px;
}
.eb-ap-section h3 {
margin-top: 0;
margin-bottom: 15px;
padding-bottom: 10px;
border-bottom: 1px solid #eee;
}
.eb-ap-actions {
margin-top: 20px;
padding-top: 15px;
border-top: 1px solid #eee;
}
.eb-ap-loading {
display: none;
text-align: center;
padding: 20px;
}
.eb-ap-loading.active {
display: block;
}
.eb-ap-error {
background-color: #f8d7da;
color: #721c24;
padding: 10px;
border-radius: 4px;
margin-bottom: 15px;
}
.eb-ap-success {
background-color: #d4edda;
color: #155724;
padding: 10px;
border-radius: 4px;
margin-bottom: 15px;
}
.eb-ap-stats {
display: flex;
gap: 20px;
margin-bottom: 20px;
}
.eb-ap-stat-box {
flex: 1;
background: #f8f9fa;
padding: 15px;
border-radius: 4px;
text-align: center;
}
.eb-ap-stat-box .stat-value {
font-size: 24px;
font-weight: bold;
color: #007cba;
}
.eb-ap-stat-box .stat-label {
font-size: 14px;
color: #666;
margin-top: 5px;
}
.eb-ap-modal {
display: none;
position: fixed;
z-index: 1000;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.5);
}
.eb-ap-modal-content {
background-color: #fefefe;
margin: 5% auto;
padding: 20px;
border: none;
border-radius: 4px;
width: 80%;
max-width: 600px;
position: relative;
}
.eb-ap-modal-close {
position: absolute;
top: 10px;
right: 15px;
font-size: 28px;
font-weight: bold;
cursor: pointer;
color: #aaa;
}
.eb-ap-modal-close:hover {
color: #000;
}
.eb-ap-table {
width: 100%;
border-collapse: collapse;
margin-top: 15px;
}
.eb-ap-table th,
.eb-ap-table td {
border: 1px solid #ddd;
padding: 12px;
text-align: left;
}
.eb-ap-table th {
background-color: #f5f5f5;
font-weight: bold;
}
.eb-ap-table .actions {
text-align: center;
width: 120px;
}
.eb-ap-table .actions button {
margin: 0 2px;
padding: 4px 8px;
font-size: 12px;
}
.eb-ap-button-group {
display: flex;
gap: 10px;
margin-top: 15px;
}
.eb-ap-button-group .button {
flex: 1;
}
@media (max-width: 768px) {
.eb-ap-header {
flex-direction: column;
gap: 15px;
}
.eb-ap-form-row {
flex-direction: column;
}
.eb-ap-stats {
flex-direction: column;
}
.eb-ap-modal-content {
width: 95%;
margin: 10% auto;
}
}
</style>