You are here

function bat_api_services_add_booking in Booking and Availability Management API 7

Create a new booking.

Parameters

$name:

$type:

$start_date:

$end_date:

1 string reference to 'bat_api_services_add_booking'
bat_api_services_resources in ./bat_api.module
Implements hook_services_resources().

File

./bat_api.module, line 673

Code

function bat_api_services_add_booking($type, $start_date, $end_date, $unit_id) {
  $return = new stdClass();
  $return->sessid = session_id();
  if (rooms_booking_type_load($type) !== FALSE) {
    $booking = rooms_booking_create(array(
      'type' => $type,
      'start_date' => $start_date,
      'end_date' => $end_date,
      'created' => REQUEST_TIME,
      'changed' => REQUEST_TIME,
    ));
    $unit = rooms_unit_load($unit_id);
    if ($unit !== FALSE) {
      $booking->unit_id = $unit_id;
      $booking->unit_type = $unit->type;
    }
    rooms_booking_save($booking);
    $return->booking_id = $booking->booking_id;
    $return->status = 1;
  }
  else {
    $return->status = 0;
  }
  return $return;
}