You are here

function bat_api_services_pricing_index in Booking and Availability Management API 7

Retrieves pricing data in for each unit in an order list of unit ids.

Parameters

$unit_ids:

$start_date:

$duration:

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

File

./bat_api.module, line 576

Code

function bat_api_services_pricing_index($unit_ids, $start_date, $duration) {
  $return = new stdClass();
  $return->sessid = session_id();
  $start_date_object = new DateTime($start_date);
  $end_date_object = clone $start_date_object;
  $end_date_object
    ->add(new DateInterval('P' . $duration));
  $ids = explode(',', $unit_ids);
  $events_json = array();
  foreach ($ids as $id) {
    $unit = rooms_unit_load($id);
    $rc = new UnitPricingCalendar($unit->unit_id, $unit->default_state);
    $events = $rc
      ->getEvents($start_date_object, $end_date_object);
    foreach ($events as $event) {
      $events_json[$id][] = $event
        ->formatJson();
    }
  }
  $return->events = $events_json;
  return $return;
}