/** * @param UserSession $userSession * @param string $timezone */ 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(); $calendar = $this->calendarFactory->Create($type, $year, $month, $day, $timezone, $selectedSchedule->GetWeekdayStart()); $reservations = $this->reservationRepository->GetReservationList($calendar->FirstDay(), $calendar->LastDay()->AddDays(1), $userSession->UserId, ReservationUserLevel::ALL, $selectedScheduleId, $selectedResourceId); $calendar->AddReservations(CalendarReservation::FromViewList($reservations, $timezone)); $this->page->BindCalendar($calendar); $this->page->SetDisplayDate($calendar->FirstDay()); $this->page->BindFilters(new CalendarFilters($schedules, $resources, $selectedScheduleId, $selectedResourceId)); $this->page->SetScheduleId($selectedScheduleId); $this->page->SetResourceId($selectedResourceId); $this->page->SetFirstDay($selectedSchedule->GetWeekdayStart()); $details = $this->subscriptionService->ForUser($userSession->UserId); $this->page->BindSubscription($details); }