Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Presenters/Admin/ManageBlackoutsPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function PageLoad($userTimezone)

$blackouts = $this->manageBlackoutsService->LoadFiltered(
$this->page->GetPageNumber(),
null,
$this->page->GetPageSize(),
$this->page->GetSortField(),
$this->page->GetSortDirection(),
$filter,
Expand Down
8 changes: 7 additions & 1 deletion Presenters/Admin/ManageGroupsPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function PageLoad()
} else {
$groupList = $this->groupRepository->GetList(
$this->page->GetPageNumber(),
null,
$this->page->GetPageSize(),
$this->page->GetSortField(),
$this->page->GetSortDirection()
);
Expand Down Expand Up @@ -498,6 +498,12 @@ public function Export()
return;
}

$this->LoadDataForExport();
}

protected function LoadDataForExport()
{
// Load ALL groups (no pagination)
/** @var GroupItemView[] $groups */
$groups = $this->groupRepository->GetList()->Results();
/** @var UserItemView[] $userGroups */
Expand Down
14 changes: 10 additions & 4 deletions Presenters/Admin/ManageReservationsPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,13 @@ public function PageLoad($userTimezone)
$missedCheckout
);

// Use no pagination for CSV export to get all results
$pageNumber = $this->page->GetFormat() == 'csv' ? null : $this->page->GetPageNumber();
$pageSize = $this->page->GetFormat() == 'csv' ? null : $this->page->GetPageSize();

$reservations = $this->manageReservationsService->LoadFiltered(
$this->page->GetPageNumber(),
null,
$pageNumber,
$pageSize,
$this->page->GetSortField(),
$this->page->GetSortDirection(),
$filter,
Expand Down Expand Up @@ -350,7 +354,8 @@ public function ProcessDataRequest($dataRequest)
'text' => $terms->Text(),
'url' => $terms->Url(),
'filename' => $terms->FileName(),
'applicability' => $terms->Applicability()]
'applicability' => $terms->Applicability(),
]
);
} else {
$this->page->BindTerms(null);
Expand Down Expand Up @@ -746,7 +751,8 @@ public function SetFilterCustomAttributes($filters)
$this->FilterCustomAttributes = serialize($filters);
}

public static $filterKeys = ['FilterStartDateDelta' => -7,
public static $filterKeys = [
'FilterStartDateDelta' => -7,
'FilterEndDateDelta' => +7,
'FilterUserId' => '',
'FilterUserName' => '',
Expand Down
62 changes: 59 additions & 3 deletions Presenters/Admin/ManageResourcesPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public function PageLoad()

$results = $this->resourceRepository->GetList(
$this->page->GetPageNumber(),
null,
$this->page->GetPageSize(),
null,
null,
$filterValues->AsFilter($resourceAttributes)
Expand Down Expand Up @@ -1091,10 +1091,67 @@ public function ImportResource()

public function ExportResources()
{
$this->PageLoad();
$this->LoadDataForExport();
$this->page->ShowExportCsv();
}

protected function LoadDataForExport()
{
$resourceAttributes = $this->attributeService->GetByCategory(CustomAttributeCategory::RESOURCE);

$filterValues = $this->page->GetFilterValues();

// Load ALL resources matching the filters (no pagination)
$results = $this->resourceRepository->GetList(
null, // No pagination
null, // No pagination
null,
null,
$filterValues->AsFilter($resourceAttributes)
);
$resources = $results->Results();
$this->page->BindResources($resources);
// Note: We skip BindPageInfo() as pagination info is not needed for CSV export

// Load all auxiliary data (same as PageLoad)
$schedules = $this->scheduleRepository->GetAll();
$scheduleList = [];

/* @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 = [];

/* @var ResourceType $resourceType */
foreach ($resourceTypes as $resourceType) {
$resourceTypeList[$resourceType->Id()] = $resourceType;
}
$this->page->BindResourceTypes($resourceTypeList);

$statusReasons = $this->resourceRepository->GetStatusReasons();
$statusReasonList = [];

foreach ($statusReasons as $reason) {
$statusReasonList[$reason->Id()] = $reason;
}
$this->page->BindResourceStatusReasons($statusReasonList);

$groups = $this->groupRepository->GetGroupsByRole(RoleLevel::RESOURCE_ADMIN);
$this->page->BindAdminGroups($groups);

$attributeList = $this->attributeService->GetByCategory(CustomAttributeCategory::RESOURCE);
$this->page->BindAttributeList($attributeList);

$this->InitializeFilter($filterValues, $resourceAttributes);

$this->page->BindResourceGroups($this->resourceRepository->GetResourceGroups(null, new ResourceFilterNone()));
}

protected function LoadValidators($action)
{
if ($action == ManageResourcesActions::ActionChangeAttribute) {
Expand Down Expand Up @@ -1232,7 +1289,6 @@ private function GetResourceImageDirectory($fileName)
}
}
return $path = "$path/$fileName";
;
}
}

Expand Down
2 changes: 1 addition & 1 deletion Presenters/Admin/ManageSchedulesPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ public function __construct(

public function PageLoad()
{
$results = $this->manageSchedulesService->GetList($this->page->GetPageNumber(), null);
$results = $this->manageSchedulesService->GetList($this->page->GetPageNumber(), $this->page->GetPageSize());
$schedules = $results->Results();

$sourceSchedules = $this->manageSchedulesService->GetSourceSchedules();
Expand Down
39 changes: 35 additions & 4 deletions Presenters/Admin/ManageUsersPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public function PageLoad()
} else {
$userList = $this->userRepository->GetList(
$this->page->GetPageNumber(),
null,
$this->page->GetPageSize(),
$this->page->GetSortField(),
$this->page->GetSortDirection(),
null,
Expand Down Expand Up @@ -256,7 +256,8 @@ public function AddUser()
$extraAttributes = [
UserAttribute::Organization => $this->page->GetOrganization(),
UserAttribute::Phone => $this->page->GetPhone(),
UserAttribute::Position => $this->page->GetPosition()];
UserAttribute::Position => $this->page->GetPosition(),
];

$user = $this->manageUsersService->AddUser(
$this->page->GetUserName(),
Expand Down Expand Up @@ -300,7 +301,8 @@ public function UpdateUser()
$extraAttributes = [
UserAttribute::Organization => $this->page->GetOrganization(),
UserAttribute::Phone => $this->page->GetPhone(),
UserAttribute::Position => $this->page->GetPosition()];
UserAttribute::Position => $this->page->GetPosition(),
];

$this->manageUsersService->UpdateUser(
$this->page->GetUserId(),
Expand Down Expand Up @@ -378,10 +380,39 @@ public function ExportUsers()
return;
}

$this->PageLoad();
$this->LoadDataForExport();
$this->page->ShowExportCsv();
}

protected function LoadDataForExport()
{
// Load ALL users matching filters (no pagination)
$userList = $this->userRepository->GetList(
null, // No pagination
null, // No pagination
$this->page->GetSortField(),
$this->page->GetSortDirection(),
$this->page->GetUserId() != null ? new SqlFilterEquals(ColumnNames::USER_ID, $this->page->GetUserId()) : null,
$this->page->GetUserId() != null ? AccountStatus::ALL : $this->page->GetFilterStatusId()
);

$this->page->BindUsers($userList->Results());
// Note: We skip BindPageInfo() as pagination info is not needed for CSV export

$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);

$this->page->BindStatusDescriptions();
}

public function ProcessDataRequest($dataRequest)
{
if ($dataRequest == 'permissions') {
Expand Down
2 changes: 1 addition & 1 deletion Presenters/ViewSchedulesPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct(

public function PageLoad()
{
$results = $this->manageSchedulesService->GetList(null, null);
$results = $this->manageSchedulesService->GetList($this->page->GetPageNumber(), $this->page->GetPageSize());
$schedules = $results->Results();

$sourceSchedules = $this->manageSchedulesService->GetSourceSchedules();
Expand Down
2 changes: 1 addition & 1 deletion Web/scripts/ajax-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ function HtmlDecode(encoded) {
}

function ajaxPagination(element, callback) {
element.find('a.page').on('click', function (e) {
element.find('a[data-page][data-page-size]').on('click', function (e) {
e.preventDefault();
var a = $(e.target);
callback(a.data('page'), a.data('page-size'));
Expand Down
Loading
Loading