You are here

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

A basic form that allows us to update the state of the calendar.

1 string reference to 'update_availability_calendar_form'
rooms_availability_page in modules/rooms_availability/rooms_availability.module
Callback for admin/rooms/units/unit/%unit/availability - builds availability page by adding calendar and pulling events from availability table.

File

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

Code

function update_availability_calendar_form($form, &$form_state, $unit_id, $year, $month) {
  $form['#attributes']['class'][] = 'rooms-management-form rooms-availability-calendar-form';
  $form['rooms_update_availability'] = array(
    '#type' => 'fieldset',
    '#title' => t('Update Unit Availability'),
    '#description' => t('Change the availability status for a specified date range.'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['rooms_update_availability']['unit_id'] = array(
    '#type' => 'hidden',
    '#value' => $unit_id,
  );
  $form['rooms_update_availability']['rooms_date_range'] = rooms_date_range_fields();

  // Unset a js setting.
  drupal_add_js(array(
    'rooms' => array(
      'roomsBookingStartDay' => 0,
    ),
  ), 'setting');
  $state_options = rooms_unit_state_options();
  $form['rooms_update_availability']['unit_state'] = array(
    '#type' => 'select',
    '#title' => t('Change status to'),
    '#options' => $state_options,
  );
  $form['rooms_update_availability']['actions'] = array(
    '#type' => 'container',
    '#attributes' => array(
      'class' => array(
        'form-actions',
      ),
    ),
    '#weight' => 400,
  );

  // We add the form's #submit array to this button along with the actual submit
  // handler to preserve any submit handlers added by a form callback_wrapper.
  $submit = array();
  if (!empty($form['rooms_update_availability']['#submit'])) {
    $submit += $form['rooms_update_availability']['#submit'];
  }
  $form['rooms_update_availability']['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Update Availability'),
    '#submit' => $submit + array(
      'update_availability_calendar_form_submit',
    ),
  );

  // We append the validate handler to #validate in case a form callback_wrapper
  // is used to add validate handlers earlier.
  $form['#validate'][] = 'rooms_form_start_end_dates_validate';
  return $form;
}