コード例 #1
0
ファイル: ReservationService.php プロジェクト: hugutux/booked
 public function GetReservations(DateRange $dateRangeUtc, $scheduleId, $targetTimezone)
 {
     $reservationListing = $this->_coordinatorFactory->CreateReservationListing($targetTimezone);
     $reservations = $this->_repository->GetReservationList($dateRangeUtc->GetBegin(), $dateRangeUtc->GetEnd(), null, null, $scheduleId, null);
     Log::Debug("Found %s reservations for schedule %s between %s and %s", count($reservations), $scheduleId, $dateRangeUtc->GetBegin(), $dateRangeUtc->GetEnd());
     foreach ($reservations as $reservation) {
         $reservationListing->Add($reservation);
     }
     $blackouts = $this->_repository->GetBlackoutsWithin($dateRangeUtc, $scheduleId);
     Log::Debug("Found %s blackouts for schedule %s between %s and %s", count($blackouts), $scheduleId, $dateRangeUtc->GetBegin(), $dateRangeUtc->GetEnd());
     foreach ($blackouts as $blackout) {
         $reservationListing->AddBlackout($blackout);
     }
     return $reservationListing;
 }
コード例 #2
0
 /**
  * @param BlackoutSeries $blackoutSeries
  * @return array|BlackoutItemView[]
  */
 private function GetConflictingBlackouts($blackoutSeries)
 {
     $conflictingBlackouts = array();
     $blackouts = $blackoutSeries->AllBlackouts();
     foreach ($blackouts as $blackout) {
         $existingBlackouts = $this->reservationViewRepository->GetBlackoutsWithin($blackout->Date());
         foreach ($existingBlackouts as $existingBlackout) {
             if ($existingBlackout->SeriesId == $blackoutSeries->Id()) {
                 continue;
             }
             if ($blackoutSeries->ContainsResource($existingBlackout->ResourceId) && $blackout->Date()->Overlaps($existingBlackout->Date)) {
                 $conflictingBlackouts[] = $existingBlackout;
             }
         }
     }
     return $conflictingBlackouts;
 }
コード例 #3
0
 public function GetItemsBetween(Date $startDate, Date $endDate)
 {
     return $this->_repository->GetBlackoutsWithin(new DateRange($startDate, $endDate));
 }