diff --git a/Presenters/Admin/ManageBlackoutsPresenter.php b/Presenters/Admin/ManageBlackoutsPresenter.php index 3c3adc07fd..412a391e3e 100644 --- a/Presenters/Admin/ManageBlackoutsPresenter.php +++ b/Presenters/Admin/ManageBlackoutsPresenter.php @@ -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, diff --git a/Presenters/Admin/ManageGroupsPresenter.php b/Presenters/Admin/ManageGroupsPresenter.php index 82f2300fa0..9b16ba885f 100644 --- a/Presenters/Admin/ManageGroupsPresenter.php +++ b/Presenters/Admin/ManageGroupsPresenter.php @@ -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() ); @@ -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 */ diff --git a/Presenters/Admin/ManageReservationsPresenter.php b/Presenters/Admin/ManageReservationsPresenter.php index 199a6d851d..9797415cee 100644 --- a/Presenters/Admin/ManageReservationsPresenter.php +++ b/Presenters/Admin/ManageReservationsPresenter.php @@ -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, @@ -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); @@ -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' => '', diff --git a/Presenters/Admin/ManageResourcesPresenter.php b/Presenters/Admin/ManageResourcesPresenter.php index 6755c67e51..9d4e8c0093 100644 --- a/Presenters/Admin/ManageResourcesPresenter.php +++ b/Presenters/Admin/ManageResourcesPresenter.php @@ -151,7 +151,7 @@ public function PageLoad() $results = $this->resourceRepository->GetList( $this->page->GetPageNumber(), - null, + $this->page->GetPageSize(), null, null, $filterValues->AsFilter($resourceAttributes) @@ -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) { @@ -1232,7 +1289,6 @@ private function GetResourceImageDirectory($fileName) } } return $path = "$path/$fileName"; - ; } } diff --git a/Presenters/Admin/ManageSchedulesPresenter.php b/Presenters/Admin/ManageSchedulesPresenter.php index 509c22a70f..c765625658 100644 --- a/Presenters/Admin/ManageSchedulesPresenter.php +++ b/Presenters/Admin/ManageSchedulesPresenter.php @@ -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(); diff --git a/Presenters/Admin/ManageUsersPresenter.php b/Presenters/Admin/ManageUsersPresenter.php index 683d1f245b..3fa5babc13 100644 --- a/Presenters/Admin/ManageUsersPresenter.php +++ b/Presenters/Admin/ManageUsersPresenter.php @@ -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, @@ -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(), @@ -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(), @@ -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') { diff --git a/Presenters/ViewSchedulesPresenter.php b/Presenters/ViewSchedulesPresenter.php index f4861adde3..69a1997265 100644 --- a/Presenters/ViewSchedulesPresenter.php +++ b/Presenters/ViewSchedulesPresenter.php @@ -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(); diff --git a/Web/scripts/ajax-helpers.js b/Web/scripts/ajax-helpers.js index 716278cb1d..ff2e3c20ab 100644 --- a/Web/scripts/ajax-helpers.js +++ b/Web/scripts/ajax-helpers.js @@ -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')); diff --git a/lib/Common/SmartyPage.php b/lib/Common/SmartyPage.php index 58e6b31f84..beecdac2f8 100644 --- a/lib/Common/SmartyPage.php +++ b/lib/Common/SmartyPage.php @@ -241,6 +241,7 @@ protected function RegisterFunctions() $this->registerPlugin('modifier', 'strtolower', $this->Strtolower(...)); $this->registerPlugin('function', 'datatable', $this->CreateDataTable(...)); $this->registerPlugin('function', 'datatablefilter', $this->CreateDataTableFilter(...)); + $this->registerPlugin('function', 'pagination', $this->CreatePagination(...)); $this->registerPlugin('modifier', 'microtime', $this->Microtime(...)); $this->registerPlugin('modifier', 'array_key_exists', $this->ArrayKeyExists(...)); $this->registerPlugin('modifier', 'count', $this->Count(...)); @@ -657,7 +658,6 @@ public function CreateDataTable($params) { $tableId = $params['tableId']; $searchText = $this->Resources->GetString('Filter'); - $AllText = $this->Resources->GetString('All'); $NoResultsFoundText = $this->Resources->GetString('NoResultsFound'); $copyText = $this->Resources->GetString('Copy'); $exportText = $this->Resources->GetString('Export'); @@ -665,8 +665,6 @@ public function CreateDataTable($params) $showHideText = $this->Resources->GetString('ShowHide'); $infoText = $this->Resources->GetString('Info'); $lengthMenuText = $this->Resources->GetString('LengthMenu'); - $defaultPageSize = $this->GetDefaultDataTablePageSize(); - $lengthMenu = $this->BuildDataTableLengthMenu($AllText); if ($tableId == 'report-results') { $pagination = '"paging": false, @@ -675,12 +673,12 @@ public function CreateDataTable($params) "info": false, "ordering": false,'; } else { - $pagination = '"pageLength": ' . $defaultPageSize . ', "lengthMenu": ' . $lengthMenu . ','; + $pagination = '"paging": false, "info": false,'; } return sprintf( '