booked/WebServices/ResourcesWebService.php
/**
	 * @name GetAvailability
	 * @description Returns resource availability for the requested resource (optional). "availableAt" and "availableUntil" will include availability through the next 7 days
	 * Optional query string parameter: dateTime. If no dateTime is requested the current datetime will be used.
	 * @response ResourcesAvailabilityResponse
	 * @return void
	 */
@name GetAvailability
@description Returns resource availability for the requested resource (optional). "availableAt" and "availableUntil" will include availability through the next 7 days
Optional query string parameter: dateTime. If no dateTime is requested the current datetime will be used.
@response ResourcesAvailabilityResponse
@return void
@name GetAvailability @description Returns resource availability for the requested resource ( optional ) . " availableAt " and " availableUntil " will include availability through the next 7 days Optional query string parameter : dateTime . If no dateTime is requested the current datetime will be used . @response ResourcesAvailabilityResponse @return void
public function GetAvailability($resourceId = null)
	{
		$dateQueryString = $this->server->GetQueryString(WebServiceQueryStringKeys::DATE_TIME);
		if (!empty($dateQueryString))
		{
			$requestedTime = WebServiceDate::GetDate($dateQueryString, $this->server->GetSession());
		}
		else
		{
			$requestedTime = Date::Now();
		}
		if (empty($resourceId))
		{
			$resources = $this->resourceRepository->GetResourceList();
		}
		else
		{
			$resources[] = $this->resourceRepository->LoadById($resourceId);
		}
		$lastDateSearched = $requestedTime->AddDays(30);
		$reservations = $this->GetReservations($this->reservationRepository->GetReservations($requestedTime, $lastDateSearched, null, null, null, $resourceId));
		$resourceAvailability = array();
		foreach ($resources as $resource)
		{
			$reservation = $this->GetOngoingReservation($resource, $reservations);
			if ($reservation != null)
			{
				$lastReservationBeforeOpening = $this->GetLastReservationBeforeAnOpening($resource, $reservations);
				if ($lastReservationBeforeOpening == null)
				{
					$lastReservationBeforeOpening = $reservation;
				}
				$resourceAvailability[] = new ResourceAvailabilityResponse($this->server, $resource, $lastReservationBeforeOpening, null, $lastReservationBeforeOpening->EndDate, $lastDateSearched);
			}
			else
			{
				$resourceId = $resource->GetId();
				if (array_key_exists($resourceId, $reservations))
				{
					$resourceAvailability[] = new ResourceAvailabilityResponse($this->server, $resource, null, $reservations[$resourceId][0], null, $lastDateSearched);
				}
				else
				{
					$resourceAvailability[] = new ResourceAvailabilityResponse($this->server, $resource, null, null, null, $lastDateSearched);
				}
			}
		}
		$this->server->WriteResponse(new ResourcesAvailabilityResponse($this->server, $resourceAvailability));
	}
public function GetAvailability ( $ resourceId = null ) { $ dateQueryString = $ this -> server -> GetQueryString ( WebServiceQueryStringKeys :: DATE_TIME ) ; if ( ! empty ( $ dateQueryString ) ) { $ requestedTime = WebServiceDate :: GetDate ( $ dateQueryString , $ this -> server -> GetSession ( ) ) ; } else { $ requestedTime = Date :: Now ( ) ; } if ( empty ( $ resourceId ) ) { $ resources = $ this -> resourceRepository -> GetResourceList ( ) ; } else { $ resources [ ] = $ this -> resourceRepository -> LoadById ( $ resourceId ) ; } $ lastDateSearched = $ requestedTime -> AddDays ( 30 ) ; $ reservations = $ this -> GetReservations ( $ this -> reservationRepository -> GetReservations ( $ requestedTime , $ lastDateSearched , null , null , null , $ resourceId ) ) ; $ resourceAvailability = array ( ) ; foreach ( $ resources as $ resource ) { $ reservation = $ this -> GetOngoingReservation ( $ resource , $ reservations ) ; if ( $ reservation != null ) { $ lastReservationBeforeOpening = $ this -> GetLastReservationBeforeAnOpening ( $ resource , $ reservations ) ; if ( $ lastReservationBeforeOpening == null ) { $ lastReservationBeforeOpening = $ reservation ; } $ resourceAvailability [ ] = new ResourceAvailabilityResponse ( $ this -> server , $ resource , $ lastReservationBeforeOpening , null , $ lastReservationBeforeOpening -> EndDate , $ lastDateSearched ) ; } else { $ resourceId = $ resource -> GetId ( ) ; if ( array_key_exists ( $ resourceId , $ reservations ) ) { $ resourceAvailability [ ] = new ResourceAvailabilityResponse ( $ this -> server , $ resource , null , $ reservations [ $ resourceId ] [ 0 ] , null , $ lastDateSearched ) ; } else { $ resourceAvailability [ ] = new ResourceAvailabilityResponse ( $ this -> server , $ resource , null , null , null , $ lastDateSearched ) ; } } } $ this -> server -> WriteResponse ( new ResourcesAvailabilityResponse ( $ this -> server , $ resourceAvailability ) ) ; }
@name GetAvailability
 @description Returns resource availability for the requested resource (optional).
@name GetAvailability @description Returns resource availability for the requested resource ( optional ) .