Files

140 lines
4.9 KiB
JavaScript
Raw Permalink 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 14:44:06 +02:00
/**
* Payment Scheduler Admin JavaScript
*
* Handles the admin interface for the automated payment scheduler
*
* 🤖 Generated with Claude Code (https://claude.ai/code)
*/
jQuery(document).ready(function($) {
// Save scheduler settings
$('#scheduler-settings-form').on('submit', function(e) {
e.preventDefault();
var $form = $(this);
var $button = $form.find('button[type="submit"]');
var originalText = $button.text();
$button.text('Saving...').prop('disabled', true);
var formData = {
action: 'save_scheduler_settings',
nonce: ebScheduler.nonce,
days_before: $('#days_before').val(),
percentage: $('#percentage').val(),
expiry_hours: $('#expiry_hours').val(),
admin_notifications: $('#admin_notifications').is(':checked') ? 'yes' : 'no'
};
$.ajax({
url: ebScheduler.ajaxurl,
type: 'POST',
data: formData,
success: function(response) {
if (response.success) {
showNotice('Settings saved successfully!', 'success');
} else {
showNotice('Error: ' + response.data, 'error');
}
},
error: function() {
showNotice('An error occurred while saving settings.', 'error');
},
complete: function() {
$button.text(originalText).prop('disabled', false);
}
});
});
// Manual payment check
$('#manual-payment-check').on('click', function() {
if (!confirm(ebScheduler.strings.confirmManualRun)) {
return;
}
var $button = $(this);
var originalText = $button.text();
$button.text(ebScheduler.strings.processing).prop('disabled', true);
$.ajax({
url: ebScheduler.ajaxurl,
type: 'POST',
data: {
action: 'manual_payment_check',
nonce: ebScheduler.nonce
},
success: function(response) {
if (response.success) {
var results = response.data;
var message = 'Manual check completed!\n\n' +
'Processed: ' + results.processed + ' bookings\n' +
'Sent: ' + results.sent + ' payment requests\n' +
'Skipped: ' + results.skipped + ' bookings\n' +
'Errors: ' + results.errors;
showNotice(message.replace(/\n/g, '<br>'), 'success');
// Reload page after 3 seconds to show updated activity
setTimeout(function() {
location.reload();
}, 3000);
} else {
showNotice('Error: ' + response.data, 'error');
}
},
error: function() {
showNotice('An error occurred during the manual check.', 'error');
},
complete: function() {
$button.text(originalText).prop('disabled', false);
}
});
});
// Form validation
$('#days_before').on('input', function() {
var value = parseInt($(this).val());
if (value < 1) $(this).val(1);
if (value > 365) $(this).val(365);
});
$('#percentage').on('input', function() {
var value = parseInt($(this).val());
if (value < 1) $(this).val(1);
if (value > 100) $(this).val(100);
});
// Show admin notices
function showNotice(message, type) {
var noticeClass = type === 'success' ? 'notice-success' : 'notice-error';
var $notice = $('<div class="notice ' + noticeClass + ' is-dismissible"><p>' + message + '</p><button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button></div>');
$('.wrap h1').after($notice);
// Auto-dismiss after 8 seconds
setTimeout(function() {
$notice.fadeOut(function() {
$(this).remove();
});
}, 8000);
// Handle manual dismiss
$notice.find('.notice-dismiss').on('click', function() {
$notice.fadeOut(function() {
$(this).remove();
});
});
}
// Real-time activity updates (every 60 seconds if on the page)
if (window.location.href.includes('eb-payment-scheduler')) {
setInterval(function() {
// Only refresh if no forms are currently being submitted
if (!$('button:disabled').length) {
$('.activity-log').load(location.href + ' .activity-log > *');
}
}, 60000);
}
});