function bat_api_services_booking_index in Booking and Availability Management API 7
Provides bookings from the start date onwards ordered by unit ids.
Parameters
$unit_ids:
$start_date:
$duration:
1 string reference to 'bat_api_services_booking_index'
- bat_api_services_resources in ./
bat_api.module - Implements hook_services_resources().
File
- ./
bat_api.module, line 634
Code
function bat_api_services_booking_index($unit_ids, $start_date, $duration) {
$return = new stdClass();
$return->sessid = session_id();
$ids = explode(',', $unit_ids);
$query = db_select('rooms_bookings', 'n')
->fields('n', array(
'booking_id',
'type',
'name',
'unit_id',
'start_date',
'end_date',
));
if (!empty($ids)) {
$query
->condition('unit_id', $ids, 'IN');
}
$query
->orderBy('unit_id');
$rooms_bookings = $query
->execute()
->fetchAll();
$bookings = array();
foreach ($rooms_bookings as $rooms_booking) {
$bookings[$rooms_booking->unit_id][] = array(
'booking_id' => $rooms_booking->booking_id,
'type' => $rooms_booking->type,
'name' => $rooms_booking->name,
'start_date' => $rooms_booking->start_date,
'end_date' => $rooms_booking->end_date,
);
}
$return->bookings = $bookings;
return $return;
}