Implement Phase 8: Dashboard & Reports (v0.8.0)
Some checks failed
Create Release Package / build-release (push) Has been cancelled
Some checks failed
Create Release Package / build-release (push) Has been cancelled
- Add comprehensive admin dashboard with stat cards and widgets - Add Chart.js for occupancy/revenue trend charts - Add Reports page with Occupancy, Revenue, Guest tabs - Add CSV and PDF export functionality (using mPDF) - Add date range filters for reports Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
86
CLAUDE.md
86
CLAUDE.md
@@ -849,3 +849,89 @@ Admin features always work; frontend requires valid license.
|
||||
- Merged to main (fast-forward)
|
||||
- Tagged: `v0.7.1`
|
||||
- Pushed to origin: dev, main, v0.7.1
|
||||
|
||||
### 2026-02-03 - Version 0.8.0 (Dashboard & Reports)
|
||||
|
||||
**Completed:**
|
||||
|
||||
- Created `src/Admin/Dashboard.php` class (~700 lines)
|
||||
- `render()` method for full dashboard page
|
||||
- Occupancy stat card with current rate, room count, comparison to last month
|
||||
- Revenue stat card with this month, YTD, comparison
|
||||
- Bookings stat card with pending/confirmed counts
|
||||
- Guests stat card with total, new this month, repeat guests
|
||||
- Today's Activity widget showing check-ins and check-outs
|
||||
- Upcoming Bookings widget with next 7 days' bookings
|
||||
- Quick Actions widget (New Booking, New Guest, Calendar, Reports)
|
||||
- Occupancy trend chart (30-day line chart)
|
||||
- Revenue trend chart (6-month bar chart)
|
||||
- Data methods: `get_occupancy_stats()`, `get_revenue_stats()`, `get_booking_stats()`, `get_guest_stats()`
|
||||
- Chart data methods: `get_occupancy_trend_data()`, `get_revenue_trend_data()`
|
||||
- Transient caching for expensive calculations (1-hour expiry)
|
||||
- Created `src/Admin/Reports.php` class (~1100 lines)
|
||||
- Tabbed interface: Occupancy, Revenue, Guests
|
||||
- Date range filters with presets (this month, last month, this year, custom)
|
||||
- Occupancy Report: by room, by building with progress bars and status labels
|
||||
- Revenue Report: by room, by pricing tier, with averages
|
||||
- Guest Statistics: top guests by revenue, nationality breakdown
|
||||
- CSV export using native PHP `fputcsv()`
|
||||
- PDF export using mPDF with professional HTML styling
|
||||
- Summary cards with key metrics
|
||||
- Progress bar visualizations for occupancy rates
|
||||
- Added mPDF dependency to `composer.json` (`mpdf/mpdf ^8.2`)
|
||||
- Updated `src/Plugin.php`
|
||||
- Added Dashboard and Reports class imports
|
||||
- `render_dashboard_page()` delegates to `Dashboard::render()`
|
||||
- Added `render_reports_page()` method
|
||||
- Reports submenu registration
|
||||
- Updated menu ordering to include Reports
|
||||
- Chart.js CDN enqueuing on dashboard page
|
||||
- Chart data passed via `wp_localize_script()`
|
||||
- Dashboard CSS styles (~350 lines in admin.css)
|
||||
- Responsive grid layout (4-col stats, 2-col charts, 3-col activity)
|
||||
- Stat cards with icons and gradients
|
||||
- Widget components with headers
|
||||
- Activity list styling
|
||||
- Upcoming bookings table
|
||||
- Quick action buttons grid
|
||||
- Reports CSS styles (~200 lines in admin.css)
|
||||
- Filter form layout
|
||||
- Summary cards with primary variant
|
||||
- Progress bars for occupancy
|
||||
- Status labels (high/medium/low)
|
||||
- Export buttons styling
|
||||
- JavaScript additions in admin.js
|
||||
- `initDashboardCharts()` for Chart.js initialization
|
||||
- Occupancy line chart with tooltips and styling
|
||||
- Revenue bar chart with currency formatting
|
||||
- `initReportsPage()` for custom date toggle
|
||||
- Updated version to 0.8.0
|
||||
|
||||
**Files Created:**
|
||||
|
||||
- `src/Admin/Dashboard.php` - Dashboard page with widgets and charts
|
||||
- `src/Admin/Reports.php` - Reports page with tabs and export
|
||||
|
||||
**Files Changed:**
|
||||
|
||||
- `composer.json` - Added mpdf/mpdf dependency
|
||||
- `composer.lock` - Updated with mPDF and dependencies
|
||||
- `src/Plugin.php` - Dashboard/Reports integration, Chart.js enqueuing
|
||||
- `assets/css/admin.css` - Dashboard and Reports styles (~550 lines added)
|
||||
- `assets/js/admin.js` - Chart initialization, reports page handlers
|
||||
- `wp-bnb.php` - Version bump to 0.8.0
|
||||
- `CHANGELOG.md` - Added v0.8.0 release notes
|
||||
- `PLAN.md` - Marked Phase 8 as complete
|
||||
|
||||
**Learnings:**
|
||||
|
||||
- Chart.js CDN loading requires conditional enqueuing to avoid loading on all admin pages
|
||||
- Dashboard data methods should use transient caching for expensive queries
|
||||
- PDF export with mPDF requires HTML string generation with inline CSS
|
||||
- Reports use `get_posts()` with meta queries for date range filtering
|
||||
- Progress bar visualization done with CSS positioning and `min(100, value)` clamping
|
||||
- Chart.js 4.x uses `new Chart()` constructor with configuration object
|
||||
- PDF generation needs `try/catch` for mPDF exceptions
|
||||
- CSV export with BOM (`\xEF\xBB\xBF`) ensures Excel compatibility
|
||||
- Guest data aggregation from bookings uses unique key pattern for anonymous guests
|
||||
- Occupancy calculation: (booked nights / total room nights) * 100
|
||||
|
||||
Reference in New Issue
Block a user