/** * @name GetReservation * @param string $referenceNumber * @description Loads a specific reservation by reference number * @response ReservationResponse * @return void */ public function GetReservation($referenceNumber) { Log::Debug('GetReservation called. $referenceNumber=%s', $referenceNumber); $reservation = $this->reservationViewRepository->GetReservationForEditing($referenceNumber); if (!empty($reservation->ReferenceNumber)) { $attributes = $this->attributeService->GetByCategory(CustomAttributeCategory::RESERVATION); $response = new ReservationResponse($this->server, $reservation, $this->privacyFilter, $attributes); $this->server->WriteResponse($response); } else { $this->server->WriteResponse($response = RestResponse::NotFound(), RestResponse::NOT_FOUND_CODE); } }
/** * @name GetAllUsers * @description Loads all users that the current user can see. * Optional query string parameters: username, email, firstName, lastName, phone, organization, position and any custom attributes. * If searching on custom attributes, the query string parameter has to be in the format att#=value. * For example, Users/?att1=ExpectedAttribute1Value * @response UsersResponse * @return void */ public function GetUsers() { $attributes = $this->attributeService->GetByCategory(CustomAttributeCategory::USER); $filter = $this->GetUserFilter($attributes); $repository = $this->repositoryFactory->Create($this->server->GetSession()); $data = $repository->GetList(null, null, null, null, $filter->GetFilter(), AccountStatus::ACTIVE); $attributeLabels = array(); foreach ($attributes as $attribute) { $attributeLabels[$attribute->Id()] = $attribute->Label(); } $usersResponse = new UsersResponse($this->server, $data->Results(), $attributeLabels); unset($data); unset($attributeLabels); $this->server->WriteResponse($usersResponse); }
/** * @return Attribute[] */ public function GetResourceTypeAttributes() { $attributes = array(); $customAttributes = $this->_attributeService->GetByCategory(CustomAttributeCategory::RESOURCE_TYPE); foreach ($customAttributes as $ca) { $attributes[] = new Attribute($ca); } return $attributes; }
public function PageLoad() { if ($this->page->GetUserId() != null) { $userList = $this->userRepository->GetList(1, 1, null, null, new SqlFilterEquals(ColumnNames::USER_ID, $this->page->GetUserId())); } else { $userList = $this->userRepository->GetList($this->page->GetPageNumber(), $this->page->GetPageSize(), null, null, null, $this->page->GetFilterStatusId()); } $this->page->BindUsers($userList->Results()); $this->page->BindPageInfo($userList->PageInfo()); $groups = $this->groupViewRepository->GetList(); $this->page->BindGroups($groups->Results()); $user = $this->userRepository->LoadById(ServiceLocator::GetServer()->GetUserSession()->UserId); $resources = $this->GetResourcesThatCurrentUserCanAdminister($user); $this->page->BindResources($resources); $attributeList = $this->attributeService->GetByCategory(CustomAttributeCategory::USER); $this->page->BindAttributeList($attributeList); }
public function PageLoad() { $resourceAttributes = $this->attributeService->GetByCategory(CustomAttributeCategory::RESOURCE); $filterValues = $this->page->GetFilterValues(); $results = $this->resourceRepository->GetList($this->page->GetPageNumber(), $this->page->GetPageSize(), null, null, $filterValues->AsFilter($resourceAttributes)); $resources = $results->Results(); $this->page->BindResources($resources); $this->page->BindPageInfo($results->PageInfo()); $schedules = $this->scheduleRepository->GetAll(); $scheduleList = array(); /* @var $schedule Schedule */ foreach ($schedules as $schedule) { $scheduleList[$schedule->GetId()] = $schedule->GetName(); } $this->page->BindSchedules($scheduleList); $this->page->AllSchedules($schedules); $resourceTypes = $this->resourceRepository->GetResourceTypes(); $resourceTypeList = array(); /* @var $resourceType ResourceType */ foreach ($resourceTypes as $resourceType) { $resourceTypeList[$resourceType->Id()] = $resourceType; } $this->page->BindResourceTypes($resourceTypeList); $statusReasons = $this->resourceRepository->GetStatusReasons(); $statusReasonList = array(); foreach ($statusReasons as $reason) { $statusReasonList[$reason->Id()] = $reason; } $this->page->BindResourceStatusReasons($statusReasonList); $groups = $this->groupRepository->GetGroupsByRole(RoleLevel::RESOURCE_ADMIN); $this->page->BindAdminGroups($groups); $resourceIds = array(); foreach ($resources as $resource) { $resourceIds[] = $resource->GetId(); } $attributeList = $this->attributeService->GetAttributes(CustomAttributeCategory::RESOURCE, $resourceIds); $this->page->BindAttributeList($attributeList); $this->InitializeFilter($filterValues, $resourceAttributes); }
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(); } }
/** * @name GetCategoryAttributes * @description Gets all custom attribute definitions for the requested category * Categories are RESERVATION = 1, USER = 2, RESOURCE = 4, RESOURCE_TYPE = 5 * @response CustomAttributesResponse * @return void * @param int $categoryId */ public function GetAttributes($categoryId) { $attributes = $this->attributeService->GetByCategory($categoryId); $this->server->WriteResponse(new CustomAttributesResponse($this->server, $attributes)); }
/** * @param $currentUser UserSession */ public function PageLoad($currentUser) { $user = $this->userRepository->LoadById($this->page->GetUserId()); if ($this->privacyFilter->CanViewUser($currentUser, null, $user->Id())) { $this->page->SetCanViewUser(true); $attributes = $this->attributeService->GetByCategory(CustomAttributeCategory::USER); $this->page->BindAttributes($attributes); $this->page->BindUser($user); } else { $this->page->SetCanViewUser(false); } }