You are here

protected function UnitPricingCalendar::prepareFullMonthArray in Rooms - Drupal Booking for Hotels, B&Bs and Vacation Rentals 7

Given an event it prepares the entire month array for it assuming no other events in the month and days where there is no event get set to the default state.

Parameters

RoomsEventInterface $event: The event to process.

Return value

array The days of the month states processed array.

Overrides RoomsCalendar::prepareFullMonthArray

1 call to UnitPricingCalendar::prepareFullMonthArray()
UnitPricingCalendar::getRawDayData in modules/rooms_pricing/includes/rooms_pricing.unit_pricing_calendar.inc
Given a date range it returns all data within that range including the start and end dates of states. The MySQL queries are kept simple and then the data is cleared up.

File

modules/rooms_pricing/includes/rooms_pricing.unit_pricing_calendar.inc, line 502
Contains UnitPricingCalendar.

Class

UnitPricingCalendar
Handles querying and updating the pricing information relative to a single bookable unit.

Code

protected function prepareFullMonthArray(RoomsEventInterface $event) {
  $days = array();
  $eod = rooms_end_of_month_dates($event
    ->startYear());
  $last_day = $eod[$event
    ->startMonth()];
  for ($i = 1; $i <= $last_day; $i++) {
    if ($i >= $event
      ->startDay() && $i <= $event
      ->endDay()) {
      $days['d' . $i] = commerce_currency_decimal_to_amount($event->amount, commerce_default_currency());
    }
    else {

      // When we are writing a new month to the DB make sure to have the placeholder value -1 for the days where the
      // default price is in effect. This means as a user changes the default price we will take it into account even
      // though the price data is now in a DB row.
      $days['d' . $i] = -1;
    }
  }
  return $days;
}