コード例 #1
0
ファイル: CalendarPresenter.php プロジェクト: hugutux/booked
 public function PageLoad($userSession, $timezone)
 {
     $type = $this->page->GetCalendarType();
     $year = $this->page->GetYear();
     $month = $this->page->GetMonth();
     $day = $this->page->GetDay();
     $defaultDate = Date::Now()->ToTimezone($timezone);
     if (empty($year)) {
         $year = $defaultDate->Year();
     }
     if (empty($month)) {
         $month = $defaultDate->Month();
     }
     if (empty($day)) {
         $day = $defaultDate->Day();
     }
     $schedules = $this->scheduleRepository->GetAll();
     $showInaccessible = Configuration::Instance()->GetSectionKey(ConfigSection::SCHEDULE, ConfigKeys::SCHEDULE_SHOW_INACCESSIBLE_RESOURCES, new BooleanConverter());
     $resources = $this->resourceService->GetAllResources($showInaccessible, $userSession);
     $selectedScheduleId = $this->page->GetScheduleId();
     $selectedSchedule = $this->GetDefaultSchedule($schedules);
     $selectedResourceId = $this->page->GetResourceId();
     if (!empty($selectedResourceId)) {
         $subscriptionDetails = $this->subscriptionService->ForResource($selectedResourceId);
     } else {
         $subscriptionDetails = $this->subscriptionService->ForSchedule($selectedSchedule->GetId());
     }
     $calendar = $this->calendarFactory->Create($type, $year, $month, $day, $timezone, $selectedSchedule->GetWeekdayStart());
     $reservations = $this->reservationRepository->GetReservationList($calendar->FirstDay(), $calendar->LastDay()->AddDays(1), null, null, $selectedScheduleId, $selectedResourceId);
     $calendar->AddReservations(CalendarReservation::FromScheduleReservationList($reservations, $resources, $userSession, $this->privacyFilter));
     $this->page->BindCalendar($calendar);
     $this->page->BindFilters(new CalendarFilters($schedules, $resources, $selectedScheduleId, $selectedResourceId));
     $this->page->SetDisplayDate($calendar->FirstDay());
     $this->page->SetScheduleId($selectedScheduleId);
     $this->page->SetResourceId($selectedResourceId);
     $this->page->SetFirstDay($selectedSchedule->GetWeekdayStart());
     $this->page->BindSubscription($subscriptionDetails);
 }
コード例 #2
0
 public function testGroupsReservationsByResource()
 {
     $start = Date::Now();
     $end = Date::Now()->AddDays(1);
     $r1 = new TestReservationItemView(1, $start, $end, 1);
     $r1->SeriesId = 1;
     $r2 = new TestReservationItemView(2, $start, $end, 2);
     $r2->SeriesId = 1;
     $r3 = new TestReservationItemView(3, $start, $end, 1);
     $r3->SeriesId = 2;
     $reservations = array($r1, $r2, $r3);
     $resources = array(new FakeBookableResource(1, '1'), new FakeBookableResource(2, '2'));
     $calendarReservations = CalendarReservation::FromScheduleReservationList($reservations, $resources, $this->fakeUser, true);
     $this->assertEquals(2, count($calendarReservations));
 }