public function PageLoad($userTimezone) { $session = ServiceLocator::GetServer()->GetUserSession(); $this->page->BindSchedules($this->scheduleRepository->GetAll()); $this->page->BindResources($this->resourceRepository->GetResourceList()); $statusReasonList = array(); foreach ($this->resourceRepository->GetStatusReasons() as $reason) { $statusReasonList[$reason->Id()] = $reason; } $this->page->BindResourceStatuses($statusReasonList); $startDateString = $this->page->GetStartDate(); $endDateString = $this->page->GetEndDate(); $filterPreferences = new ReservationFilterPreferences(); $filterPreferences->Load($this->userPreferenceRepository, $session->UserId); $startDate = $this->GetDate($startDateString, $userTimezone, $filterPreferences->GetFilterStartDateDelta()); $endDate = $this->GetDate($endDateString, $userTimezone, $filterPreferences->GetFilterEndDateDelta()); $scheduleId = $this->page->GetScheduleId(); $resourceId = $this->page->GetResourceId(); $userId = $this->page->GetUserId(); $userName = $this->page->GetUserName(); $reservationStatusId = $this->page->GetReservationStatusId(); $referenceNumber = $this->page->GetReferenceNumber(); $resourceStatusId = $this->page->GetResourceStatusFilterId(); $resourceReasonId = $this->page->GetResourceStatusReasonFilterId(); if (!$this->page->FilterButtonPressed()) { // Get filter settings from db $referenceNumber = $filterPreferences->GetFilterReferenceNumber(); $scheduleId = $filterPreferences->GetFilterScheduleId(); $resourceId = $filterPreferences->GetFilterResourceId(); $userId = $filterPreferences->GetFilterUserId(); $userName = $filterPreferences->GetFilterUserName(); $reservationStatusId = $filterPreferences->GetFilterReservationStatusId(); $resourceStatusId = $filterPreferences->GetFilterResourceStatusId(); $resourceReasonId = $filterPreferences->GetFilterResourceReasonId(); $filters = $filterPreferences->GetFilterCustomAttributes(); } else { $startOffset = $this->GetDateOffsetFromToday($startDate, $userTimezone); $endOffset = $this->GetDateOffsetFromToday($endDate, $userTimezone); $formFilters = $this->page->GetAttributeFilters(); $filters = array(); foreach ($formFilters as $filter) { $filters[$filter->Id] = $filter->Value; } $filterPreferences->SetFilterStartDateDelta($startOffset == null ? -14 : $startOffset); $filterPreferences->SetFilterEndDateDelta($endOffset == null ? 14 : $endOffset); $filterPreferences->SetFilterReferenceNumber($referenceNumber); $filterPreferences->SetFilterScheduleId($scheduleId); $filterPreferences->SetFilterResourceId($resourceId); $filterPreferences->SetFilterUserId($userId); $filterPreferences->SetFilterUserName($userName); $filterPreferences->SetFilterReservationStatusId($reservationStatusId); $filterPreferences->SetFilterResourceStatusId($resourceStatusId); $filterPreferences->SetFilterResourceReasonId($resourceReasonId); $filterPreferences->SetFilterCustomAttributes($filters); $filterPreferences->Update($this->userPreferenceRepository, $session->UserId); } $reservationAttributes = $this->attributeService->GetByCategory(CustomAttributeCategory::RESERVATION); $attributeFilters = array(); foreach ($reservationAttributes as $attribute) { $attributeValue = null; if (array_key_exists($attribute->Id(), $filters)) { $attributeValue = $filters[$attribute->Id()]; } $attributeFilters[] = new Attribute($attribute, $attributeValue); } $this->page->SetStartDate($startDate); $this->page->SetEndDate($endDate); $this->page->SetReferenceNumber($referenceNumber); $this->page->SetScheduleId($scheduleId); $this->page->SetResourceId($resourceId); $this->page->SetUserId($userId); $this->page->SetUserName($userName); $this->page->SetReservationStatusId($reservationStatusId); $this->page->SetResourceStatusFilterId($resourceStatusId); $this->page->SetResourceStatusReasonFilterId($resourceReasonId); $this->page->SetAttributeFilters($attributeFilters); $this->page->SetReservationAttributes($reservationAttributes); $filter = new ReservationFilter($startDate, $endDate, $referenceNumber, $scheduleId, $resourceId, $userId, $reservationStatusId, $resourceStatusId, $resourceReasonId, $attributeFilters); $reservations = $this->manageReservationsService->LoadFiltered($this->page->GetPageNumber(), $this->page->GetPageSize(), $filter, $session); /** @var ReservationItemView[] $reservationList */ $reservationList = $reservations->Results(); $this->page->BindReservations($reservationList); $this->page->BindPageInfo($reservations->PageInfo()); $seriesIds = array(); /** @var $reservationItemView ReservationItemView */ foreach ($reservationList as $reservationItemView) { $seriesIds[] = $reservationItemView->SeriesId; } if ($this->page->GetFormat() == 'csv') { $this->page->ShowCsv(); } else { $this->page->ShowPage(); } }