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>
This commit is contained in:
Hotel Raxa Dev
2025-07-11 07:43:22 +02:00
commit 5b1e2453c7
9816 changed files with 2784509 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
# OS or IDE folders/files to ignore
*~
._*
*.lock
*.DS_Store
*.swp
*.out
.cache
.project
.settings
nbproject
thumb.db
Thumbs.db
.idea/

View File

@@ -0,0 +1,193 @@
<?php
/*
Plugin Name: CMB2 Field Type: Select2
Plugin URI: https://github.com/mustardBees/cmb-field-select2
GitHub Plugin URI: https://github.com/mustardBees/cmb-field-select2
Description: Select2 field type for CMB2.
Version: 3.0.3
Author: Phil Wylie
Author URI: https://www.philwylie.co.uk/
License: GPLv2+
*/
/**
* Class PW_CMB2_Field_Select2
*/
// Exit if accessed directly
if( !defined( 'ABSPATH' ) ) exit;
if( !class_exists( 'PW_CMB2_Field_Select2' ) ) {
class PW_CMB2_Field_Select2 {
/**
* Current version number
*/
const VERSION = '3.0.3';
/**
* Initialize the plugin by hooking into CMB2
*/
public function __construct() {
add_filter( 'cmb2_render_pw_select', array( $this, 'render_pw_select' ), 10, 5 );
add_filter( 'cmb2_render_pw_multiselect', array( $this, 'render_pw_multiselect' ), 10, 5 );
add_filter( 'cmb2_sanitize_pw_multiselect', array( $this, 'pw_multiselect_sanitize' ), 10, 4 );
add_filter( 'cmb2_types_esc_pw_multiselect', array( $this, 'pw_multiselect_escaped_value' ), 10, 3 );
add_filter( 'cmb2_repeat_table_row_types', array( $this, 'pw_multiselect_table_row_class' ), 10, 1 );
}
/**
* Render select box field
*/
public function render_pw_select( $field, $field_escaped_value, $field_object_id, $field_object_type, $field_type_object ) {
$this->setup_admin_scripts();
if ( version_compare( CMB2_VERSION, '2.2.2', '>=' ) ) {
$field_type_object->type = new CMB2_Type_Select( $field_type_object );
}
echo $field_type_object->select( array(
'class' => 'pw_select2 pw_select',
'desc' => $field_type_object->_desc( true ),
'options' => '<option></option>' . $field_type_object->concat_items(),
'data-placeholder' => $field->args( 'attributes', 'placeholder' ) ? $field->args( 'attributes', 'placeholder' ) : $field->args( 'description' ),
) );
}
/**
* Render multi-value select input field
*/
public function render_pw_multiselect( $field, $field_escaped_value, $field_object_id, $field_object_type, $field_type_object ) {
$this->setup_admin_scripts();
if ( version_compare( CMB2_VERSION, '2.2.2', '>=' ) ) {
$field_type_object->type = new CMB2_Type_Select( $field_type_object );
}
$a = $field_type_object->parse_args( 'pw_multiselect', array(
'multiple' => 'multiple',
'style' => 'width: 99%',
'class' => 'pw_select2 pw_multiselect',
'name' => $field_type_object->_name() . '[]',
'id' => $field_type_object->_id(),
'desc' => $field_type_object->_desc( true ),
'options' => $this->get_pw_multiselect_options( $field_escaped_value, $field_type_object ),
'data-placeholder' => $field->args( 'attributes', 'placeholder' ) ? $field->args( 'attributes', 'placeholder' ) : $field->args( 'description' ),
) );
$attrs = $field_type_object->concat_attrs( $a, array( 'desc', 'options' ) );
echo sprintf( '<select%s>%s</select>%s', $attrs, $a['options'], $a['desc'] );
}
/**
* Return list of options for pw_multiselect
*
* Return the list of options, with selected options at the top preserving their order. This also handles the
* removal of selected options which no longer exist in the options array.
*/
public function get_pw_multiselect_options( $field_escaped_value = array(), $field_type_object = '' ) {
$options = (array) $field_type_object->field->options();
// If we have selected items, we need to preserve their order
if ( ! empty( $field_escaped_value ) ) {
$options = $this->sort_array_by_array( $options, $field_escaped_value );
}
$selected_items = '';
$other_items = '';
foreach ( $options as $option_value => $option_label ) {
// Clone args & modify for just this item
$option = array(
'value' => $option_value,
'label' => $option_label,
);
// Split options into those which are selected and the rest
if ( in_array( $option_value, (array) $field_escaped_value ) ) {
$option['checked'] = true;
$selected_items .= $field_type_object->select_option( $option );
} else {
$other_items .= $field_type_object->select_option( $option );
}
}
return $selected_items . $other_items;
}
/**
* Sort an array by the keys of another array
*
* @author Eran Galperin
* @link http://link.from.pw/1Waji4l
*/
public function sort_array_by_array( array $array, array $orderArray ) {
$ordered = array();
foreach ( $orderArray as $key ) {
if ( array_key_exists( $key, $array ) ) {
$ordered[ $key ] = $array[ $key ];
unset( $array[ $key ] );
}
}
return $ordered + $array;
}
/**
* Handle sanitization for repeatable fields
*/
public function pw_multiselect_sanitize( $check, $meta_value, $object_id, $field_args ) {
if ( ! is_array( $meta_value ) || ! $field_args['repeatable'] ) {
return $check;
}
foreach ( $meta_value as $key => $val ) {
$meta_value[$key] = array_map( 'sanitize_text_field', $val );
}
return $meta_value;
}
/**
* Handle escaping for repeatable fields
*/
public function pw_multiselect_escaped_value( $check, $meta_value, $field_args ) {
if ( ! is_array( $meta_value ) || ! $field_args['repeatable'] ) {
return $check;
}
foreach ( $meta_value as $key => $val ) {
$meta_value[$key] = array_map( 'esc_attr', $val );
}
return $meta_value;
}
/**
* Add 'table-layout' class to multi-value select field
*/
public function pw_multiselect_table_row_class( $check ) {
$check[] = 'pw_multiselect';
return $check;
}
/**
* Enqueue scripts and styles
*/
public function setup_admin_scripts() {
$asset_path = apply_filters( 'pw_cmb2_field_select2_asset_path', plugins_url( '', __FILE__ ) );
wp_register_script( 'pw-select2', $asset_path . '/js/select2.min.js', array( 'jquery-ui-sortable' ), '4.0.3' );
wp_enqueue_script( 'pw-select2-init', $asset_path . '/js/script.js', array( 'cmb2-scripts', 'pw-select2' ), self::VERSION );
wp_register_style( 'pw-select2', $asset_path . '/css/select2.min.css', array(), '4.0.3' );
wp_enqueue_style( 'pw-select2-tweaks', $asset_path . '/css/style.css', array( 'pw-select2' ), self::VERSION );
}
}
$pw_cmb2_field_select2 = new PW_CMB2_Field_Select2();
}

View File

@@ -0,0 +1,14 @@
{
"name": "mustardBees/cmb-field-select2",
"description": "Select2 field type for CMB2",
"license": "GPL-2.0+",
"type": "wordpress-plugin",
"keywords": ["wordpress", "plugin"],
"homepage": "https://github.com/mustardBees/cmb-field-select2",
"authors": [
{
"name": "Phil Wylie",
"homepage": "http://www.philwylie.co.uk/"
}
]
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,9 @@
.cmb-type-pw-multiselect .select2-selection__choice,
.cmb-type-pw-multiselect .select2-search--inline {
margin-bottom: 0;
line-height: inherit;
}
.cmb-type-pw-multiselect .select2-selection__choice {
cursor: move !important;
}

View File

@@ -0,0 +1,121 @@
(function ($) {
'use strict';
$('.pw_select').each(function () {
$(this).select2({
allowClear: true
});
});
$.fn.extend({
select2_sortable: function () {
var select = $(this);
$(select).select2();
var ul = $(select).next('.select2-container').first('ul.select2-selection__rendered');
ul.sortable({
containment: 'parent',
items : 'li:not(.select2-search--inline)',
tolerance : 'pointer',
stop : function () {
$($(ul).find('.select2-selection__choice').get().reverse()).each(function () {
var id = $(this).data('data').id;
var option = select.find('option[value="' + id + '"]')[0];
$(select).prepend(option);
});
}
});
}
});
$('.pw_multiselect').each(function () {
$(this).select2_sortable();
});
// Before a new group row is added, destroy Select2. We'll reinitialise after the row is added
$('.cmb-repeatable-group').on('cmb2_add_group_row_start', function (event, instance) {
var $table = $(document.getElementById($(instance).data('selector')));
var $oldRow = $table.find('.cmb-repeatable-grouping').last();
$oldRow.find('.pw_select2').each(function () {
$(this).select2('destroy');
});
});
// When a new group row is added, clear selection and initialise Select2
$('.cmb-repeatable-group').on('cmb2_add_row', function (event, newRow) {
$(newRow).find('.pw_select').each(function () {
$('option:selected', this).removeAttr("selected");
$(this).select2({
allowClear: true
});
});
$(newRow).find('.pw_multiselect').each(function () {
$('option:selected', this).removeAttr("selected");
$(this).select2_sortable();
});
// Reinitialise the field we previously destroyed
$(newRow).prev().find('.pw_select').each(function () {
$(this).select2({
allowClear: true
});
});
// Reinitialise the field we previously destroyed
$(newRow).prev().find('.pw_multiselect').each(function () {
$(this).select2_sortable();
});
});
// Before a group row is shifted, destroy Select2. We'll reinitialise after the row shift
$('.cmb-repeatable-group').on('cmb2_shift_rows_start', function (event, instance) {
var groupWrap = $(instance).closest('.cmb-repeatable-group');
groupWrap.find('.pw_select2').each(function () {
$(this).select2('destroy');
});
});
// When a group row is shifted, reinitialise Select2
$('.cmb-repeatable-group').on('cmb2_shift_rows_complete', function (event, instance) {
var groupWrap = $(instance).closest('.cmb-repeatable-group');
groupWrap.find('.pw_select').each(function () {
$(this).select2({
allowClear: true
});
});
groupWrap.find('.pw_multiselect').each(function () {
$(this).select2_sortable();
});
});
// Before a new repeatable field row is added, destroy Select2. We'll reinitialise after the row is added
$('.cmb-add-row-button').on('click', function (event) {
var $table = $(document.getElementById($(event.target).data('selector')));
var $oldRow = $table.find('.cmb-row').last();
$oldRow.find('.pw_select2').each(function () {
$(this).select2('destroy');
});
});
// When a new repeatable field row is added, clear selection and initialise Select2
$('.cmb-repeat-table').on('cmb2_add_row', function (event, newRow) {
// Reinitialise the field we previously destroyed
$(newRow).prev().find('.pw_select').each(function () {
$('option:selected', this).removeAttr("selected");
$(this).select2({
allowClear: true
});
});
// Reinitialise the field we previously destroyed
$(newRow).prev().find('.pw_multiselect').each(function () {
$('option:selected', this).removeAttr("selected");
$(this).select2_sortable();
});
});
})(jQuery);

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,125 @@
# CMB2 Field Type: Select2
## Description
[Select2](https://select2.github.io/) field type for [CMB2](https://github.com/WebDevStudios/CMB2 "Custom Metaboxes and Fields for WordPress 2").
This plugin gives you two additional field types based on Select2:
1. The `pw_select` field acts much like the default `select` field. However, it adds typeahead-style search allowing you to quickly make a selection from a large list
2. The `pw_multiselect` field allows you to select multiple values with typeahead-style search. The values can be dragged and dropped to reorder
## Installation
You can install this field type as you would a WordPress plugin:
1. Download the plugin
2. Place the plugin folder in your `/wp-content/plugins/` directory
3. Activate the plugin in the Plugin dashboard
Alternatively, you can include this field type within your plugin/theme. The path to front end assets (JS/CSS) can be filtered using `pw_cmb2_field_select2_asset_path`. See an example where we [load assets from the current active theme](http://link.from.pw/pw_cmb2_field_select2_asset_path).
## Usage
`pw_select` - Select box with with typeahead-style search. Example:
```php
$cmb->add_field( array(
'name' => 'Cooking time',
'id' => $prefix . 'cooking_time',
'desc' => 'Cooking time',
'type' => 'pw_select',
'options' => array(
'5' => '5 minutes',
'10' => '10 minutes',
'30' => 'Half an hour',
'60' => '1 hour',
),
) );
```
`pw_multiselect` - Multi-value select box with drag and drop reordering. Example:
```php
$cmb->add_field( array(
'name' => 'Ingredients',
'id' => $prefix . 'ingredients',
'desc' => 'Select ingredients. Drag to reorder.',
'type' => 'pw_multiselect',
'options' => array(
'flour' => 'Flour',
'salt' => 'Salt',
'eggs' => 'Eggs',
'milk' => 'Milk',
'butter' => 'Butter',
),
) );
```
### Placeholder
You can specify placeholder text through the attributes array. Example:
```php
$cmb->add_field( array(
'name' => 'Ingredients',
'id' => $prefix . 'ingredients',
'desc' => 'Select this recipes ingredients.',
'type' => 'pw_multiselect',
'options' => array(
'flour' => 'Flour',
'salt' => 'Salt',
'eggs' => 'Eggs',
'milk' => 'Milk',
'butter' => 'Butter',
),
'attributes' => array(
'placeholder' => 'Select ingredients. Drag to reorder'
),
) );
```
### Custom Select2 configuration and overriding default configuration options
You can define Select2 configuration options using HTML5 `data-*` attributes. It's worth reading up on the [available options](https://select2.github.io/options.html#data-attributes) over on the Select2 website. Example:
```php
$cmb->add_field( array(
'name' => 'Ingredients',
'id' => $prefix . 'ingredients',
'desc' => 'Select ingredients. Drag to reorder.',
'type' => 'pw_multiselect',
'options' => array(
'flour' => 'Flour',
'salt' => 'Salt',
'eggs' => 'Eggs',
'milk' => 'Milk',
'butter' => 'Butter',
),
'attributes' => array(
'data-maximum-selection-length' => '2',
),
) );
```
## Helper functions
You may want to populate the options array dynamically. Common use cases include listing out posts and taxonomy terms. I've written a number of generic helper functions which can be used to return a CMB2 style array for both [posts](http://link.from.pw/1PkJmWc) and [terms](http://link.from.pw/1TDArjR).
## Limitations/known issues
If youd like to help out, pull requests are more than welcome!
* This field does not work well as a repeatable field within a repeatable group.
* Yoast SEO also loads Select2. Currently a version behind, there is an issue with the previous version of Select2 and it's ability to position the dropdown relative to the field.
## Screenshots
### Select box
![Image](screenshot-1.png?raw=true)
### Multi-value select box
![Image](screenshot-2.png?raw=true)
![Image](screenshot-3.png?raw=true)
![Image](screenshot-4.png?raw=true)

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB