You are here

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

Implements hook_form__FORM_ID_alter().

FORM_ID = rooms_booking_settings

File

modules/rooms_availability/rooms_availability.module, line 868
Manages availability for Bookable Units and displaying dates on the jquery FullCalendar plugin.

Code

function rooms_availability_form_rooms_booking_settings_alter(&$form, &$form_state, $form_id) {
  $form['label_settings'] = array(
    '#type' => 'fieldset',
    '#group' => 'rooms_settings',
    '#title' => t('Calendar Color Codes & Labels'),
  );
  $form['label_settings']['rooms_not_available_color'] = array(
    '#type' => 'textfield',
    '#title' => t('"@availability_status" color', array(
      '@availability_status' => t('Unavailable'),
    )),
    '#size' => 10,
    '#maxlength' => 7,
    '#default_value' => variable_get('rooms_not_available_color', '#CC2727'),
    '#element_validate' => array(
      'rooms_availability_validate_hex_color',
    ),
    '#dependency' => array(
      'edit-row-options-colors-legend' => array(
        'type',
      ),
    ),
    '#prefix' => '<div class="rooms-colorpicker-wrapper form-wrapper">',
    '#suffix' => '<div class="rooms-colorpicker"></div></div>',
    '#attributes' => array(
      'class' => array(
        'rooms-edit-colorpicker',
      ),
    ),
    '#attached' => array(
      // Add Farbtastic color picker.
      'library' => array(
        array(
          'system',
          'farbtastic',
        ),
      ),
      // Add javascript to trigger the colorpicker.
      'js' => array(
        drupal_get_path('module', 'rooms_availability') . '/js/rooms_color.js',
      ),
    ),
  );
  $form['label_settings']['rooms_not_available_text'] = array(
    '#type' => 'textfield',
    '#title' => t('"@availability_status" label', array(
      '@availability_status' => t('Unavailable'),
    )),
    '#size' => 10,
    '#maxlength' => 50,
    '#default_value' => variable_get('rooms_not_available_text', 'N/A'),
  );
  $form['label_settings']['rooms_available_color'] = array(
    '#type' => 'textfield',
    '#title' => t('"@availability_status" color', array(
      '@availability_status' => t('Available'),
    )),
    '#size' => 10,
    '#maxlength' => 7,
    '#default_value' => variable_get('rooms_available_color', '#8BA175'),
    '#element_validate' => array(
      'rooms_availability_validate_hex_color',
    ),
    '#dependency' => array(
      'edit-row-options-colors-legend' => array(
        'type',
      ),
    ),
    '#prefix' => '<div class="rooms-colorpicker-wrapper">',
    '#suffix' => '<div class="rooms-colorpicker"></div></div>',
    '#attributes' => array(
      'class' => array(
        'rooms-edit-colorpicker',
      ),
    ),
    '#attached' => array(
      // Add Farbtastic color picker.
      'library' => array(
        array(
          'system',
          'farbtastic',
        ),
      ),
      // Add javascript to trigger the colorpicker.
      'js' => array(
        drupal_get_path('module', 'rooms_availability') . '/js/rooms_color.js',
      ),
    ),
  );
  $form['label_settings']['rooms_available_text'] = array(
    '#type' => 'textfield',
    '#title' => t('"@availability_status" label', array(
      '@availability_status' => t('Available'),
    )),
    '#size' => 10,
    '#maxlength' => 50,
    '#default_value' => variable_get('rooms_available_text', 'AV'),
  );
  $form['label_settings']['rooms_on_request_color'] = array(
    '#type' => 'textfield',
    '#title' => t('"@availability_status" color', array(
      '@availability_status' => t('Available on Request'),
    )),
    '#size' => 10,
    '#maxlength' => 7,
    '#default_value' => variable_get('rooms_on_request_color', '#C5C5C5'),
    '#element_validate' => array(
      'rooms_availability_validate_hex_color',
    ),
    '#dependency' => array(
      'edit-row-options-colors-legend' => array(
        'type',
      ),
    ),
    '#prefix' => '<div class="rooms-colorpicker-wrapper">',
    '#suffix' => '<div class="rooms-colorpicker"></div></div>',
    '#attributes' => array(
      'class' => array(
        'rooms-edit-colorpicker',
      ),
    ),
    '#attached' => array(
      // Add Farbtastic color picker.
      'library' => array(
        array(
          'system',
          'farbtastic',
        ),
      ),
      // Add javascript to trigger the colorpicker.
      'js' => array(
        drupal_get_path('module', 'rooms_availability') . '/js/rooms_color.js',
      ),
    ),
  );
  $form['label_settings']['rooms_on_request_text'] = array(
    '#type' => 'textfield',
    '#title' => t('"@availability_status" label', array(
      '@availability_status' => t('Available on Request'),
    )),
    '#size' => 10,
    '#maxlength' => 50,
    '#default_value' => variable_get('rooms_on_request_text', 'ON-REQ'),
  );
  $form['label_settings']['rooms_anon_booking_color'] = array(
    '#type' => 'textfield',
    '#title' => t('"@availability_status" color', array(
      '@availability_status' => t('Anonymous booking'),
    )),
    '#size' => 10,
    '#maxlength' => 7,
    '#default_value' => variable_get('rooms_anon_booking_color', '#8C6A5A'),
    '#element_validate' => array(
      'rooms_availability_validate_hex_color',
    ),
    '#dependency' => array(
      'edit-row-options-colors-legend' => array(
        'type',
      ),
    ),
    '#prefix' => '<div class="rooms-colorpicker-wrapper">',
    '#suffix' => '<div class="rooms-colorpicker"></div></div>',
    '#attributes' => array(
      'class' => array(
        'rooms-edit-colorpicker',
      ),
    ),
    '#attached' => array(
      // Add Farbtastic color picker.
      'library' => array(
        array(
          'system',
          'farbtastic',
        ),
      ),
      // Add javascript to trigger the colorpicker.
      'js' => array(
        drupal_get_path('module', 'rooms_availability') . '/js/rooms_color.js',
      ),
    ),
  );
  $form['label_settings']['rooms_anon_booking_text'] = array(
    '#type' => 'textfield',
    '#title' => t('"@availability_status" label', array(
      '@availability_status' => t('Anonymous booking'),
    )),
    '#size' => 10,
    '#maxlength' => 50,
    '#default_value' => variable_get('rooms_anon_booking_text', 'A-B'),
  );
  $form['label_settings']['rooms_unconfirmed_booking_color'] = array(
    '#type' => 'textfield',
    '#title' => t('"@availability_status" color', array(
      '@availability_status' => t('Unconfirmed booking'),
    )),
    '#size' => 10,
    '#maxlength' => 7,
    '#default_value' => variable_get('rooms_unconfirmed_booking_color', '#6D8C9C'),
    '#element_validate' => array(
      'rooms_availability_validate_hex_color',
    ),
    '#dependency' => array(
      'edit-row-options-colors-legend' => array(
        'type',
      ),
    ),
    '#prefix' => '<div class="rooms-colorpicker-wrapper">',
    '#suffix' => '<div class="rooms-colorpicker"></div></div>',
    '#attributes' => array(
      'class' => array(
        'rooms-edit-colorpicker',
      ),
    ),
    '#attached' => array(
      // Add Farbtastic color picker.
      'library' => array(
        array(
          'system',
          'farbtastic',
        ),
      ),
      // Add javascript to trigger the colorpicker.
      'js' => array(
        drupal_get_path('module', 'rooms_availability') . '/js/rooms_color.js',
      ),
    ),
  );
  $form['label_settings']['rooms_unconfirmed_booking_text'] = array(
    '#type' => 'textfield',
    '#title' => t('"@availability_status" label', array(
      '@availability_status' => t('Unconfirmed booking'),
    )),
    '#size' => 10,
    '#maxlength' => 50,
    '#default_value' => variable_get('rooms_unconfirmed_booking_text', 'UNCONF'),
  );
  $form['label_settings']['rooms_view_unit_name'] = array(
    '#type' => 'checkboxes',
    '#options' => array(
      '1' => t('Display unit name in place of availability state label.'),
    ),
    '#default_value' => variable_get('rooms_view_unit_name', array(
      '',
    )),
  );
  $form['label_settings']['rooms_calendar_events_view'] = array(
    '#type' => 'radios',
    '#title' => t('Calendar Events Display Mode'),
    '#description' => t('Select how to display events on calendars.'),
    '#default_value' => variable_get('rooms_calendar_events_view', '0'),
    '#options' => array(
      '0' => t('Display events as starting at middle of day (check-in day) and ending at middle of check-out day'),
      '1' => t('Display events occupying full day box at start and ending on day of last night (day before check-out date)'),
    ),
  );
}