BAT: 予約・空き状況管理ツール
A generalized Booking and Availability Management Framework for Drupal that provides a foundation for managing units, events, states, and bookings.
bat
概要
BAT(Booking and Availability Management Tools)は、空き状況管理、予約、予約管理など幅広いユースケースに対応できる基盤を提供するDrupal向けの包括的なフレームワークです。もともとRoomifyによって開発されたBATは、ホテル予約、機材レンタル、予約スケジューリング、リソース管理アプリケーションなどの複雑な予約システムを構築することを可能にします。
このモジュールは、Unit(予約可能なもの)、Event(ユニットに適用される時間ベースの状態)、Booking(特定の期間にユーザーとユニットを紐付ける予約)を中心とした柔軟なEntityベースのアーキテクチャを導入しています。BATは、日・時間・分単位の粒度で状態変更を追跡するための効率的なデータベースストレージ構造を使用しています。
主要なアーキテクチャ機能には、関連するユニットタイプを整理するためのType Group、カスタム状態を持つ設定可能なEvent Type、日単位と時間単位の両方の粒度のサポート、視覚的管理のためのFullCalendar統合、定期的な予約のためのEvent Seriesが含まれます。このモジュールは、PHP関数とhook実装の両方を通じてカスタマイズのための広範なAPIを提供します。
Features
- 部屋、機材、サービスなどの予約可能なリソースを表すカスタマイズ可能なバンドル(Type)を持つUnit Entity管理
- 設定可能な状態とターゲットEntityリファレンスを持つEventシステム。日/時間/分テーブルに空き状況データを効率的に保存
- EventおよびUnitにリンクされた予約を管理するためのBooking Entity
- 関連するユニットタイプを整理・グループ化するためのType Groupシステム
- 視覚的なイベント管理のためのタイムラインとスケジューラービューを備えたFullCalendar統合
- カスタマイズ可能なルールで定期的なイベントを作成するためのEvent Seriesサポート
- 任意のフィールド追加可能なEntityにユニットの空き状況カレンダーを埋め込むためのCalendar Referenceフィールド
- 日単位と時間単位の両方のイベント追跡のための粒度サポート
- バンドルレベルのアクセス制御(自分の/すべての表示/編集/削除)を持つ包括的なパーミッションシステム
- hookベースのカスタマイズによるEntityリストのクエリレベルアクセス制御
- 設定可能な保持期間を持つcronによる自動イベント状態クリーンアップ
- カスタムフィールドハンドラーを持つUnit、Event、BookingのViews統合
- Search APIおよびFacetsモジュール統合によるファセット検索サポート
- BAT Optionsサブモジュールを通じた価格オプションのCommerce統合
- 複雑な空き状況ルールを定義するためのConstraintシステム
Use Cases
Hotel Room Booking System
Create a hotel booking system with room types (Single, Double, Suite), individual room units, availability events, and guest bookings. Use Type Bundles for room classifications, Unit Types for room categories, Units for individual rooms, Event Types for availability/pricing, and Bookings for reservations. The FullCalendar UI provides visual management of room availability.
Equipment Rental Management
Build an equipment rental system for items like cameras, tools, or vehicles. Define equipment categories as Type Bundles, create Unit Types for equipment models, Units for individual items, and track rental periods using Events. The calendar reference field can display equipment availability on product pages.
Appointment Scheduling System
Create an appointment system for services like medical consultations or salon bookings. Use Units for service providers or rooms, Event Types for appointment slots with hourly granularity, and Bookings for confirmed appointments. Event Series can handle recurring availability patterns.
Resource Reservation for Facilities
Manage reservations for meeting rooms, sports facilities, or event spaces. Define facility types, create units for each bookable space, and use Events to track availability with support for both daily and hourly booking granularity.
Vacation Rental Property Management
Build a vacation rental platform with property types, individual rental units, seasonal pricing events, maintenance blocking events, and guest bookings. Use Type Groups to organize properties by location or category, and leverage the faceted search integration for availability filtering.
Tips
- Use the bat_event_get_calendar() function to efficiently query availability across multiple units - it caches the calendar setup for better performance.
- When creating Event Types, carefully consider granularity (daily vs hourly) as this affects database storage and cannot be easily changed later.
- Implement hook_bat_entity_access() for custom access control logic that goes beyond the standard CRUD permissions.
- Use Type Groups to organize related unit types for better administrative organization and potentially shared configuration.
- The Event Series module is ideal for recurring availability patterns like weekly opening hours or seasonal closures.
- Configure the FullCalendar Scheduler license properly if using premium timeline/resource views to avoid console warnings.
- Use bat_date_range_fields() to create consistent paired date picker fields in custom forms.
- For high-traffic sites, tune the old event cleanup settings to balance database size against cron execution time.
Technical Details
Admin Pages 20
/admin/bat
Main BAT administration landing page providing access to all BAT management areas including Units, Events, Bookings, Groups, and Configuration.
/admin/bat/config/date
Configure date formats used throughout BAT for events, search summaries, and calendar pop-ups.
/admin/bat/config/bat_event
Configure settings for automatic removal of old events during cron runs.
/admin/bat/config/fullcalendar
Configure global settings for FullCalendar display including time ranges, height, views, and licensing.
/admin/bat/config/maintenance
Database maintenance tools for BAT event tables including deletion of old events and table integrity fixes.
/admin/bat/unit
Unit management section providing access to Units, Types, Type Bundles, and Unit Bundles.
/admin/bat/unit/unit
List and manage all units. Units are the individual bookable resources.
/admin/bat/unit/unit_type
List and manage unit types. Unit types group similar units (e.g., Single Room, Double Room).
/admin/bat/unit/type-bundles
Manage type bundles (configuration entities) that define the structure of unit types.
/admin/bat/unit/unit-bundles
Manage unit bundles (configuration entities) that define the structure of units.
/admin/bat/events
Event management section providing access to Events, Event States, Event Types, and Event Series.
/admin/bat/events/event
List and manage all events. Events represent time-based states applied to units.
/admin/bat/events/state
Manage event states. States define the possible conditions a unit can be in (e.g., Available, Booked, Maintenance).
/admin/bat/events/event/event-types
Manage event types. Event types categorize events (e.g., Availability, Pricing).
/admin/bat/events/event_series
List and manage event series for recurring events.
/admin/bat/booking
Booking management section for managing reservations.
/admin/bat/config/booking
List and manage all bookings/reservations.
/admin/bat/group
Type Group management section for organizing related unit types.
/admin/bat/group/type-group
List and manage type groups for organizing related unit types.
/admin/bat/calendar/{unit_type}/{event_type}
Calendar view for bulk viewing and editing events for a specific unit type and event type combination. Requires BAT Event UI module.
権限 27
Hooks 6
hook_bat_entity_access
Allows modules to deny or provide access for a user to perform a non-view operation on a BAT entity before any other access check occurs. Return FALSE to deny, TRUE to allow, or nothing for normal permission checking.
hook_bat_event_target_entity_types
Allow modules to define entity types that may be referenced by BAT Events and provided to the BAT library as a Unit. Entity types must implement getEventDefaultValue() and formatEventValue() methods.
hook_bat_event_constraints_info
Allow modules to define event constraints that are applied when checking availability.
hook_bat_event_constraints_info_alter
Allow modules to alter defined event constraints.
hook_bat_facets_search_results_alter
Allow modules to alter results from faceted search.
hook_bat_entity_access_OP_condition_ENTITY_TYPE_alter
Allows modules to add conditions to the entity access query for specific operations and entity types.
Troubleshooting 5
Ensure the Event Type has been properly configured with the correct target entity type (bat_unit) and that Event States exist for that Event Type. Check that the FullCalendar module is enabled and configured at /admin/bat/config/fullcalendar.
BAT uses a granular permission system. Ensure the user has the appropriate 'create' permission for the specific entity type and bundle. Check permissions at /admin/people/permissions and look for bat_unit, bat_event, or bat_booking permissions.
Enable automatic old event cleanup at /admin/bat/config/bat_event. Configure the number of days to retain and events to delete per cron run. You can also manually trigger cleanup from /admin/bat/config/maintenance.
Verify that: 1) The referenced unit exists, 2) Events exist for the selected event type, 3) The field formatter is set to Timeline or Month view, 4) The user has 'view past event information' permission if viewing historical data.
Check that Event States are correctly configured for the Event Type. The bat_event_get_matching_units() function uses state machine names, not IDs. Verify that the states referenced in your search code exist and are associated with the correct Event Type.
Security Notes 5
- BAT implements query-level access control through hook_query_TAG_alter, ensuring users only see entities they have permission to view in listings.
- The 'bypass' permissions should be granted sparingly as they override all other access checks for the respective entity types.
- Event data is stored in custom tables (bat_event_*) that don't inherit Drupal's standard entity access - custom access checks are implemented in bat_entity_access().
- The BAT Facets module filters search results based on user permissions through hook_bat_facets_search_results_alter.
- When implementing custom constraints through hook_bat_event_constraints_info, ensure they don't expose sensitive availability data.