BAT: Booking and Availability Tools
bat
A generalized Booking and Availability Management Framework for Drupal that provides a foundation for managing units, events, states, and bookings.
Overview
BAT (Booking and Availability Management Tools) is a comprehensive framework for Drupal that provides a foundation through which a wide range of availability management, reservation, and booking use cases can be addressed. Originally developed by Roomify, BAT enables developers to build complex reservation systems such as hotel booking, equipment rental, appointment scheduling, and resource management applications.
The module introduces a flexible entity-based architecture centered around Units (things that can be booked), Events (time-based states applied to units), and Bookings (reservations that link users to units for specific time periods). BAT uses an efficient database storage structure for tracking state changes at day, hour, or minute granularity.
Key architectural features include: Type Groups for organizing related unit types, configurable Event Types with custom states, support for both daily and hourly granularity, FullCalendar integration for visual management, and Event Series for recurring bookings. The module provides extensive APIs through both PHP functions and hook implementations for customization.
Features
- Unit entity management with customizable bundles (Types) for representing bookable resources like rooms, equipment, or services
- Event system with configurable states and target entity references, storing availability data efficiently in day/hour/minute tables
- Booking entity for managing reservations linked to events and units
- Type Group system for organizing and grouping related unit types
- FullCalendar integration with timeline and scheduler views for visual event management
- Event Series support for creating recurring events with customizable rules
- Calendar Reference fields for embedding unit availability calendars on any fieldable entity
- Granularity support for both daily and hourly event tracking
- Comprehensive permission system with bundle-level access control (view/edit/delete own/any)
- Query-level access control for entity listings with hook-based customization
- Automatic event state cleanup via cron with configurable retention periods
- Views integration for units, events, and bookings with custom field handlers
- Faceted search support through Search API and Facets module integration
- Commerce integration for pricing options through the BAT Options submodule
- Constraint system for defining complex availability rules
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.
Dependencies
Related Projects
Full Views integration with custom field handlers for units, events, and bookings. Includes relationship handlers for entity references.
Through bat_facets submodule, provides availability-based facet widgets for filtering search results based on unit availability.
Through bat_options submodule, provides options/pricing field types that integrate with Drupal Commerce for pricing and payment handling.
Through bat_fullcalendar submodule, provides rich calendar UI for viewing and managing events with support for timeline, scheduler, and standard calendar views.
Core dependency for bat_event, provides the date range field type used for event dates.
External module required for bat_event_ui, provides REST API endpoints for calendar data.
Admin Pages
| Title | Path | Description |
|---|---|---|
| Bat | /admin/bat |
Main BAT administration landing page providing access to all BAT management areas including Units, Events, Bookings, Groups, and Configuration. |
| Date | /admin/bat/config/date |
Configure date formats used throughout BAT for events, search summaries, and calendar pop-ups. |
| Bat Event Settings | /admin/bat/config/bat_event |
Configure settings for automatic removal of old events during cron runs. |
| Fullcalendar | /admin/bat/config/fullcalendar |
Configure global settings for FullCalendar display including time ranges, height, views, and licensing. |
| Bat Event Maintenance | /admin/bat/config/maintenance |
Database maintenance tools for BAT event tables including deletion of old events and table integrity fixes. |
| Unit | /admin/bat/unit |
Unit management section providing access to Units, Types, Type Bundles, and Unit Bundles. |
| Unit list | /admin/bat/unit/unit |
List and manage all units. Units are the individual bookable resources. |
| Unit type list | /admin/bat/unit/unit_type |
List and manage unit types. Unit types group similar units (e.g., Single Room, Double Room). |
| Type Bundle list | /admin/bat/unit/type-bundles |
Manage type bundles (configuration entities) that define the structure of unit types. |
| Unit Bundle list | /admin/bat/unit/unit-bundles |
Manage unit bundles (configuration entities) that define the structure of units. |
| Events | /admin/bat/events |
Event management section providing access to Events, Event States, Event Types, and Event Series. |
| Event list | /admin/bat/events/event |
List and manage all events. Events represent time-based states applied to units. |
| State | /admin/bat/events/state |
Manage event states. States define the possible conditions a unit can be in (e.g., Available, Booked, Maintenance). |
| Event Type list | /admin/bat/events/event/event-types |
Manage event types. Event types categorize events (e.g., Availability, Pricing). |
| Event series list | /admin/bat/events/event_series |
List and manage event series for recurring events. |
| Booking | /admin/bat/booking |
Booking management section for managing reservations. |
| Booking list | /admin/bat/config/booking |
List and manage all bookings/reservations. |
| Group | /admin/bat/group |
Type Group management section for organizing related unit types. |
| Type Groups | /admin/bat/group/type-group |
List and manage type groups for organizing related unit types. |
| Calendar | /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. |
Permissions
| Permission | Description |
|---|---|
|
Allows users to manage site-wide BAT configuration settings. |
|
Allows users to add type group bundles and configure their fields. |
|
Allows users to view any unpublished type group. |
|
Allows users to view own unpublished type groups. |
|
Allows users to perform any action on Type Group entities. |
|
Allows users to create type groups. |
|
Allows users to view any type group. |
|
Allows users to edit any type group. |
|
Allows users to delete any type group. |
|
Allows users to add unit bundles and configure their fields. |
|
Allows users to add type bundles and configure their fields. |
|
Allows users to view any unpublished unit. |
|
Allows users to view own unpublished units. |
|
Allows users to view any unpublished type. |
|
Allows users to view own unpublished types. |
|
Allows users to perform any action on Unit entities. |
|
Allows users to perform any action on Unit Type entities. |
|
Allows users to add event types and configure their fields. |
|
Allows users to add event states. |
|
Allows users to perform any action on Event entities. |
|
Allows users to add booking types and configure their fields. |
|
Allows users to access booking page. |
|
Allows users to perform any action on Booking entities. |
|
Allows users to manipulate events on calendar. |
|
Allow users to view event info in the past (especially via event reference field). |
|
Allows users to add event series types and configure their fields. |
|
Allows users to perform any action on Event Series entities. |
Hooks
| Hook | Description |
|---|---|
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
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
- 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.