You are here

public function UnitCalendar::getStates in Rooms - Drupal Booking for Hotels, B&Bs and Vacation Rentals 7

Given a date range returns all states in that range - useful when we are not interested in starting and ending dates but simply in states.

Parameters

DateTime $start_date: The start day of the range.

DateTime $end_date: The end date of our range.

bool $confirmed: Whether include confirmed states or not.

Return value

array An array of states within that range

Overrides UnitCalendarInterface::getStates

2 calls to UnitCalendar::getStates()
UnitCalendar::eventBlocked in modules/rooms_availability/includes/rooms_availability.unit_calendar.inc
Checks if an event is blocked, i.e. cannot be updated. This happens when the event id is in the rooms_booking_locks table and the new event_id is not the same as the one that is locked.
UnitCalendar::stateAvailability in modules/rooms_availability/includes/rooms_availability.unit_calendar.inc
Given a set of states (e.g. the desired states to accept a booking) we compare against the states the unit is actually in.

File

modules/rooms_availability/includes/rooms_availability.unit_calendar.inc, line 67
Class UnitCalendar Handles querying and updating the availability information relative to a single bookable unit.

Class

UnitCalendar
@file Class UnitCalendar Handles querying and updating the availability information relative to a single bookable unit.

Code

public function getStates(DateTime $start_date, DateTime $end_date, $confirmed = FALSE) {
  $states = array();

  // Get the raw day results.
  $results = $this
    ->getRawDayData($start_date, $end_date);
  foreach ($results[$this->unit_id] as $year => $months) {
    foreach ($months as $mid => $month) {
      foreach ($month['states'] as $state) {
        if ($state['state'] < 0 && !$confirmed) {
          $states[] = -1;
        }
        else {
          $states[] = $state['state'];
        }
      }
    }
  }
  $states = array_unique($states);
  return $states;
}