You are here

function rooms_booking_manager_alter_rooms_booking_settings in Rooms - Drupal Booking for Hotels, B&Bs and Vacation Rentals 7

Alters for the 'rooms_booking_settings' form.

1 call to rooms_booking_manager_alter_rooms_booking_settings()
rooms_booking_manager_form_alter in modules/rooms_booking_manager/rooms_booking_manager.module
Implements hook_form_alter().

File

modules/rooms_booking_manager/rooms_booking_manager.module, line 2464
Rooms Booking Manager brings together all the pieces required to find a room and book it - including the DrupalCommerce integration

Code

function rooms_booking_manager_alter_rooms_booking_settings(&$form, &$form_state, $form_id) {
  $form['rooms_checkout_settings'] = array(
    '#type' => 'fieldset',
    '#group' => 'rooms_settings',
    '#title' => t('Rooms checkout settings'),
  );
  $form['rooms_checkout_settings']['rooms_checkout_style'] = array(
    '#type' => 'radios',
    '#title' => t('Checkout presentation style'),
    '#options' => array(
      ROOMS_COMMERCE_CHECKOUT => t('Commerce checkout'),
      ROOMS_ENQ_CHECKOUT => t('Enquiry checkout'),
    ),
    '#default_value' => variable_get('rooms_checkout_style', ROOMS_COMMERCE_CHECKOUT),
  );
  $form['rooms_checkout_settings']['commerce_section'] = array(
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#title' => t('Commerce checkout cart availability settings'),
    '#states' => array(
      'visible' => array(
        ':input[name="rooms_checkout_style"]' => array(
          'value' => ROOMS_COMMERCE_CHECKOUT,
        ),
      ),
    ),
  );
  $form['rooms_checkout_settings']['commerce_section']['rooms_use_commerce_filter'] = array(
    '#type' => 'checkbox',
    '#title' => t('Do not show units as available if they are in another user\'s cart'),
    '#options' => rooms_assoc_range(0, 1),
    '#description' => t('If this box is checked, Rooms will show units as unavailable once a booking including them has been placed in a user\'s cart. If it is unchecked, multiple users may place the same unit in their cart, and the first user to check out complete their order will successfully complete their booking. For scenarios such as hotels with multiple units of the same type it is recommended to enable this.'),
    '#default_value' => variable_get('rooms_use_commerce_filter', '1'),
  );
  $form['rooms_checkout_settings']['enquiry_section'] = array(
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#title' => t('Enquiry checkout form settings'),
    '#description' => t('Select the fields that will be shown to the user in the enquiry form page. (name and email are required)'),
    '#states' => array(
      'visible' => array(
        ':input[name="rooms_checkout_style"]' => array(
          'value' => ROOMS_ENQ_CHECKOUT,
        ),
      ),
    ),
  );
  $form['rooms_checkout_settings']['enquiry_section']['rooms_enquiry_form_address'] = array(
    '#prefix' => '<div class="container-inline">',
    '#type' => 'checkbox',
    '#title' => t('Full address fields'),
    '#default_value' => variable_get('rooms_enquiry_form_address', 1),
  );
  $form['rooms_checkout_settings']['enquiry_section']['rooms_enquiry_form_address_required'] = array(
    '#suffix' => '</div>',
    '#type' => 'checkbox',
    '#title' => t('Required'),
    '#default_value' => variable_get('rooms_enquiry_form_address_required', 1),
    '#states' => array(
      'visible' => array(
        ':input[name="rooms_enquiry_form_address"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $form['rooms_checkout_settings']['enquiry_section']['rooms_enquiry_form_comments'] = array(
    '#prefix' => '<div class="container-inline">',
    '#type' => 'checkbox',
    '#title' => t('Comments field'),
    '#default_value' => variable_get('rooms_enquiry_form_comments', 1),
  );
  $form['rooms_checkout_settings']['enquiry_section']['rooms_enquiry_form_comments_required'] = array(
    '#suffix' => '</div>',
    '#type' => 'checkbox',
    '#title' => t('Required'),
    '#default_value' => variable_get('rooms_enquiry_form_comments_required', 1),
    '#states' => array(
      'visible' => array(
        ':input[name="rooms_enquiry_form_comments"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $form['rooms_checkout_settings']['enquiry_section']['rooms_booking_manager_enquiry_form_confirmation'] = array(
    '#type' => 'textarea',
    '#title' => t('Confirmation message'),
    '#default_value' => variable_get_value('rooms_booking_manager_enquiry_form_confirmation'),
  );
  $form['rooms_checkout_settings']['rooms_price_calculation'] = array(
    '#type' => 'radios',
    '#title' => t('Price calculation'),
    '#options' => array(
      ROOMS_PER_NIGHT => t('Per unit per night'),
      ROOMS_PER_PERSON => t('Per person per night'),
    ),
    '#default_value' => variable_get('rooms_price_calculation', ROOMS_PER_NIGHT),
  );
  $form['rooms_checkout_settings']['rooms_manually_booking_create_order'] = array(
    '#type' => 'checkbox',
    '#title' => t('Create orders for manually generated bookings'),
    '#options' => rooms_assoc_range(0, 1),
    '#description' => t('This will create a Commerce order for bookings created via the admin interface of Rooms.'),
    '#default_value' => variable_get('rooms_manually_booking_create_order', '1'),
  );
  rooms_booking_manager_deposit_config_form($form, $form_state);
  $booking_types = rooms_booking_get_types();
  $options = array();
  foreach ($booking_types as $type) {
    $options[$type->type] = $type->label;
  }
  $form['rooms_booking_settings']['rooms_advance_bookings_period'] = array(
    '#type' => 'rules_duration',
    '#title' => t('Advance Bookings'),
    '#description' => t('This will limit how far in the future bookings can be made. If you
    would like to allow specific rules to not have any limitations they should be
    assigned the "Book in advance without time limitations" permission.'),
    '#default_value' => variable_get('rooms_advance_bookings_period', 15552000),
  );
  $form['rooms_booking_settings']['rooms_booking_type'] = array(
    '#type' => 'select',
    '#title' => t('Active Booking type'),
    '#options' => $options,
    '#description' => t('The booking type created by Commerce.'),
    '#default_value' => variable_get('rooms_booking_type', 'standard_booking'),
  );
  $form['rooms_search_settings'] = array(
    '#type' => 'fieldset',
    '#group' => 'rooms_settings',
    '#title' => t('Rooms availability search settings'),
  );
  $form['rooms_search_settings']['rooms_presentation_style'] = array(
    '#type' => 'radios',
    '#title' => t('Results Presentation Mode'),
    '#description' => t('Choose whether to display results grouped by unit type or as single units.'),
    '#options' => array(
      ROOMS_PER_TYPE => t('Show availability on a per-type basis.'),
      ROOMS_INDIVIDUAL => t('Show availability of individual units.'),
    ),
    '#default_value' => variable_get('rooms_presentation_style', ROOMS_PER_TYPE),
  );
  $form['rooms_search_settings']['rooms_booking_manager_search_form_max_group_size'] = array(
    '#type' => 'select',
    '#title' => t('Maximum group size to display'),
    '#description' => t('Select the maximum group size to display in the availability search form select list'),
    '#options' => rooms_assoc_range(1, 20),
    '#default_value' => variable_get('rooms_booking_manager_search_form_max_group_size', 8),
  );
  $form['rooms_search_settings']['rooms_booking_manager_search_form_units'] = array(
    '#type' => 'select',
    '#title' => t('Number of units to display'),
    '#description' => t('Select the maximum number of units to display in the availability search form select list'),
    '#options' => rooms_assoc_range(1, 8),
    '#default_value' => variable_get('rooms_booking_manager_search_form_units', 6),
  );
  $form['rooms_search_settings']['rooms_display_children'] = array(
    '#type' => 'checkbox',
    '#title' => t('Display children choice in availability search'),
    '#description' => t('Select whether both group size and children can be shown.'),
    '#default_value' => variable_get('rooms_display_children', ROOMS_DISPLAY_CHILDREN_NO),
  );
  $form['rooms_search_settings']['rooms_booking_manager_type_selector'] = array(
    '#type' => 'checkbox',
    '#description' => t('Display a drop-down list of unit types for filtering the availability search.'),
    '#title' => t('Display unit type selector in availability search'),
    '#default_value' => variable_get('rooms_booking_manager_type_selector', ROOMS_DISPLAY_TYPE_SELECTOR_NO),
  );
  $form['rooms_search_settings']['rooms_display_unit_type_selector'] = array(
    '#type' => 'fieldset',
    '#title' => t('Valid unit types'),
    '#states' => array(
      'visible' => array(
        '#edit-rooms-booking-manager-type-selector' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $unit_types = variable_get('rooms_unit_type_selector', array());
  $form['rooms_search_settings']['rooms_display_unit_type_selector']['rooms_unit_type_selector'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Select unit types to show to user in the Unit-Type selector.'),
    '#group' => 'rooms_display_unit_type_selector',
    '#options' => rooms_unit_types_ids(),
    '#default_value' => array_keys($unit_types),
  );
  $form['rooms_booking_settings']['rooms_valid_availability_states'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Valid availability states'),
    '#description' => t('Select the states for which units should show as available in a search.'),
    '#options' => array(
      ROOMS_AVAILABLE => t('Units marked as available.'),
      ROOMS_ON_REQUEST => t('Units marked as available on request.'),
    ),
    '#default_value' => variable_get('rooms_valid_availability_states', array(
      ROOMS_AVAILABLE,
      ROOMS_ON_REQUEST,
    )),
  );
  $form['rooms_admin_settings']['rooms_date_format'] = array(
    '#type' => 'item',
    '#title' => t('Rooms PHP Date Format'),
    '#description' => t("A custom date format for Booking labels, search summary and calendar pop-ups. Define a php date format string like 'm-d-Y' (see <a href=\"@link\">http://php.net/date</a> for more details).", array(
      '@link' => 'http://php.net/date',
    )),
  );
  $form['rooms_admin_settings']['rooms_date_format']['rooms_date_format'] = array(
    '#type' => 'textfield',
    '#size' => 12,
    '#prefix' => '<div class="container-inline form-item">' . t('Date format') . ': &nbsp;',
    '#suffix' => '</div>',
    '#default_value' => variable_get('rooms_date_format', 'd-m-Y'),
  );
  $form['#validate'][] = 'rooms_booking_manager_alter_rooms_booking_settings_validate';
}