You are here

function _bat_api_merge_non_blocking_events in Booking and Availability Management API 7.2

Merge non blocking events so that we display them as a continuous single event.

Parameters

array $events:

Return value

array

2 calls to _bat_api_merge_non_blocking_events()
bat_api_services_events_index_calendar in ./bat_api.module
Retrieve a list of events to use with Fullcalendar scheduler.
bat_api_services_matching_units_calendar in ./bat_api.module
Retrieve a list of events to use with Fullcalendar scheduler.

File

./bat_api.module, line 1160
API access to booking data for BAT.

Code

function _bat_api_merge_non_blocking_events($events) {
  $prev_id = FALSE;
  foreach ($events as $id => $event) {
    if ($prev_id !== FALSE && isset($event['rendering']) && $event['rendering'] == 'background' && !$event['blocking']) {
      $last_event = $events[$prev_id];
      if (isset($last_event['rendering']) && $last_event['rendering'] == 'background' && !$last_event['blocking']) {
        if ($last_event['resourceId'] == $event['resourceId'] && $last_event['title'] == $event['title'] && $last_event['color'] == $event['color']) {
          $events[$prev_id]['end'] = $event['end'];
          unset($events[$id]);
          continue;
        }
      }
    }
    $prev_id = $id;
  }
  return $events;
}