bat_booking_example.install in Booking and Availability Management Tools for Drupal 7
File
modules/bat_booking/bat_booking_example/bat_booking_example.install
View source
<?php
function bat_booking_example_install() {
bat_booking_example_create_availability_event_type();
bat_booking_example_create_standard_event_states();
}
function bat_booking_example_uninstall() {
bat_booking_example_delete_availability_event_type();
}
function bat_booking_example_create_availability_event_type() {
$event = new BatEventType(array(
'label' => 'Availability Example',
'type' => 'availability_example',
'fixed_event_states' => 1,
'event_granularity' => 'bat_daily',
'target_entity_type' => 'bat_unit',
));
bat_event_type_save($event);
}
function bat_booking_example_create_standard_event_states() {
$event_state = array(
'label' => 'Available',
'color' => '#8BA175',
'calendar_label' => 'AV',
'machine_name' => 'availability_example_available',
);
bat_event_save_state($event_state, 'availability_example');
$event_state = array(
'label' => 'Not Available',
'color' => '#CC2727',
'calendar_label' => 'N/A',
'machine_name' => 'availability_example_not_available',
);
bat_event_save_state($event_state, 'availability_example');
$event_state = array(
'label' => 'Booked',
'color' => '#1A1A73',
'calendar_label' => 'Booked',
'blocking' => 1,
'machine_name' => 'availability_example_available_booked',
);
bat_event_save_state($event_state, 'availability_example');
}
function bat_booking_example_delete_availability_event_type() {
if (module_exists('bat_event')) {
if ($event_type = bat_event_type_load('availability_example')) {
bat_event_type_delete($event_type);
}
}
}