You are here

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

Implements hook_form_FORM_ID_alter().

FORM_ID = rooms_unit_delete_form

File

modules/rooms_booking/rooms_booking.module, line 522
Manage Bookings - Bookings are tied to a customer profile and possible a Unit ID and Order ID.

Code

function rooms_booking_form_rooms_unit_delete_form_alter(&$form, &$form_state) {
  $unit = $form_state['rooms_unit'];
  $bookings = rooms_booking_load_multiple(FALSE, array(
    'unit_id' => $unit->unit_id,
  ));
  if (count($bookings) > 0) {

    // This unit has associated bookings, don't allow deletion.
    form_set_error('confirm', t('This unit has associated bookings. Please delete all associated bookings before attempting to delete this unit.'));
    unset($form['description']);
    unset($form['actions']);
    unset($form['confirm']);
  }
}