Add booking system with calendar and email notifications (v0.3.0)
All checks were successful
Create Release Package / build-release (push) Successful in 1m5s

- Booking Custom Post Type with full management features
- Room and guest relationship tracking
- Check-in/check-out date management with validation
- Booking status workflow (pending, confirmed, checked_in, checked_out, cancelled)
- Automatic price calculation using existing Calculator
- Availability system with real-time conflict detection
- AJAX endpoint for instant availability validation
- Calendar admin page with monthly view and room/building filters
- Color-coded booking status display with legend
- Email notifications for new bookings, confirmations, and cancellations
- HTML email templates with placeholder-based system
- Auto-generated booking references (BNB-YYYY-NNNNN)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-31 14:37:48 +01:00
parent dabfe1e826
commit 0c601df568
11 changed files with 3419 additions and 28 deletions

View File

@@ -207,10 +207,15 @@ wp-bnb/
├── src/ # PHP source code (PSR-4: Magdev\WpBnb)
│ ├── Plugin.php # Main plugin singleton
│ ├── Admin/ # Admin pages
│ │ ├── Calendar.php # Availability calendar page
│ │ └── Seasons.php # Seasons management page
│ ├── Booking/ # Booking system
│ │ ├── Availability.php # Availability checking
│ │ └── EmailNotifier.php # Email notifications
│ ├── License/
│ │ └── Manager.php # License management
│ ├── PostTypes/ # Custom post types
│ │ ├── Booking.php # Booking post type
│ │ ├── Building.php # Building post type
│ │ └── Room.php # Room post type
│ ├── Pricing/ # Pricing system
@@ -397,3 +402,69 @@ Admin features always work; frontend requires valid license.
- Price modifiers as multipliers are more flexible than percentages
- Calculator class separates concerns from post type class
- Weekend days stored as comma-separated string in options
### 2026-01-31 - Version 0.3.0 (Booking System)
**Completed:**
- Created `src/PostTypes/Booking.php` custom post type
- Room and guest relationship tracking
- Check-in/check-out date management with validation
- Status workflow (pending, confirmed, checked_in, checked_out, cancelled)
- Auto-generated booking references (BNB-YYYY-NNNNN)
- Four meta boxes: Room & Dates, Guest Info, Pricing, Status & Notes
- Conflict detection prevents double-booking
- Price calculation using existing Calculator class
- Admin columns with room, guest, dates, nights, price, status
- Filters by room and status
- Status badges with color coding
- Created `src/Booking/Availability.php` class
- Real-time availability checking via AJAX
- Conflict detection algorithm
- Calendar data generation for rooms and buildings
- Utility methods for upcoming bookings, today's check-ins/outs
- Created `src/Admin/Calendar.php` admin page
- Monthly calendar view with room/building filters
- Color-coded booking status display
- Month navigation (previous/next/today)
- Click-to-edit booking functionality
- Hover tooltips with booking details
- Legend for status colors
- Created `src/Booking/EmailNotifier.php` class
- Admin notification for new bookings
- Guest confirmation email on booking confirmation
- Cancellation emails to guest and admin
- HTML email templates with inline styles
- Placeholder-based template system
- Filter hooks for customizing emails
- Updated `src/Plugin.php`
- Registered Booking post type
- Initialized Calendar admin page
- Initialized EmailNotifier
- Added AJAX handler for availability checking
- Updated asset enqueuing for Booking screens
- Updated `assets/js/admin.js`
- Booking form with AJAX availability checking
- Real-time nights display
- Price calculation and display
- Status preview update
- Date validation (check-out after check-in)
- Calendar page interactivity
- Updated `assets/css/admin.css`
- Booking info display styles
- Availability status indicators
- Price breakdown styles
- Calendar grid and cell styles
- Legend and filter styles
- Responsive design for calendar
- Updated version to 0.3.0
**Learnings:**
- Booking conflicts use overlap detection: `A.check_in < B.check_out AND A.check_out > B.check_in`
- Excluding cancelled bookings from conflict checks allows rebooking same dates
- Guest info stored in booking meta (Phase 4 will add separate Guest CPT)
- AJAX availability check returns price calculation for immediate feedback
- Calendar displays bookings color-coded by status for quick visual overview
- HTML email templates with inline CSS for better email client compatibility
- Status transitions can trigger different email notifications via hooks