Skip to content
Snippets Groups Projects
Commit 08252a83 authored by Robert Lange's avatar Robert Lange
Browse files

refs #23952 [finc] refactor loanHistoryAction

* rename loanHistoryAction to historicloansAction as in VuFind MyResearchController
** rename in menu

* config: set historic_loan_page_size to 30 as it is obvious default???

* rename getMyLoanHistory to getMyTransactionHistory in LiberoWachtlTrait
** remove erronemous custom pagination
** rename also in AjaxHandler for badges count

* remove obsolete code for paginator in historicloans.phtml
parent df7672be
No related merge requests found
...@@ -363,7 +363,7 @@ title_level_holds_mode = "disabled" ...@@ -363,7 +363,7 @@ title_level_holds_mode = "disabled"
; The number of historic loans to display per page; 0 for no limit (may cause ; The number of historic loans to display per page; 0 for no limit (may cause
; memory problems for users with a large number of historic loans). Default = 50 ; memory problems for users with a large number of historic loans). Default = 50
;historic_loan_page_size = 50 historic_loan_page_size = 30
; Whether to display the item barcode for each loan. Default is false. ; Whether to display the item barcode for each loan. Default is false.
;display_checked_out_item_barcode = true ;display_checked_out_item_barcode = true
......
...@@ -55,7 +55,7 @@ class GetUserLoanHistory extends \VuFind\AjaxHandler\AbstractUserRequestAction ...@@ -55,7 +55,7 @@ class GetUserLoanHistory extends \VuFind\AjaxHandler\AbstractUserRequestAction
if (!$this->ils->checkCapability('getMyTransactions')) { if (!$this->ils->checkCapability('getMyTransactions')) {
return $this->formatResponse('', self::STATUS_HTTP_ERROR, 405); return $this->formatResponse('', self::STATUS_HTTP_ERROR, 405);
} }
$items = $this->ils->getMyLoanHistory($patron, 100); $items = $this->ils->getMyTransactionHistory($patron, 0);
$counts = [ 'ok' => $items['total'] ]; $counts = [ 'ok' => $items['total'] ];
return $this->formatResponse($counts); return $this->formatResponse($counts);
......
...@@ -626,11 +626,10 @@ trait LiberoWachtlTrait ...@@ -626,11 +626,10 @@ trait LiberoWachtlTrait
} }
/** /**
* Customized getMyLoanHistory * Customized getMyTransactionHistory method for LiberoWachtl
* *
* @param array $patron Array returned from patronLogin() * @param array $patron Array returned from patronLogin()
* @param int $lastLine Integer until LiberoWachtl should process history * @param int $currentPage Current page of loan history
* incrementally
* *
* @return array $retval * @return array $retval
* - ['items'] Array with items of loan history * - ['items'] Array with items of loan history
...@@ -638,12 +637,12 @@ trait LiberoWachtlTrait ...@@ -638,12 +637,12 @@ trait LiberoWachtlTrait
* @throws \Exception * @throws \Exception
* @throws ILSException * @throws ILSException
*/ */
public function getMyLoanHistory($patron, $lastLine) public function getMyTransactionHistory($patron, $currentPage = null)
{ {
$params = $this->getLiberoWachtlRequestParams(); $params = $this->getLiberoWachtlRequestParams();
$params['memberCode'] = $patron['cat_username']; $params['memberCode'] = $patron['cat_username'];
$params['password'] = $patron['cat_password']; $params['password'] = $patron['cat_password'];
$params['pageNumber'] = 1; $params['pageNumber'] = $currentPage ?? 1;
try { try {
$result = $this->httpService->get( $result = $this->httpService->get(
$this->getLiberoWachtlUrl() . 'getMyLoanHistory.jsp', $this->getLiberoWachtlUrl() . 'getMyLoanHistory.jsp',
...@@ -675,43 +674,7 @@ trait LiberoWachtlTrait ...@@ -675,43 +674,7 @@ trait LiberoWachtlTrait
} }
$retval = []; $retval = [];
$retval['total'] = $details['rowCount']; $retval['total'] = $details['rowCount'];
$retval['items'] = $details['getMyLoanHistory']; $retval['items'] = $this->getLiberoWachtlResult($result, 'getMyLoanHistory');
// Check if more entries are required than in first called.
if (count($details['getMyLoanHistory']) < $lastLine) {
// iteration over Libero view pager and security anchor to not iterate
// over more pages than exists
for ($page = 2; $page <= $details['pageCount']; $page++) {
// overwrite param pageNumber
$params['pageNumber'] = $page;
try {
$result = $this->httpService->get(
$this->getLiberoWachtlUrl() . 'getMyLoanHistory.jsp',
$params,
null,
$this->getLiberoWachtlRequestHeaders()
);
} catch (\Exception $e) {
throw new ILSException($e->getMessage());
}
if (!$result->isSuccess()) {
// log error for debugging
$this->debug(
'HTTP status ' . $result->getStatusCode() .
' received'
);
return false;
}
// merge with previous request
$retval['items'] = array_merge(
$retval['items'],
$this->getLiberoWachtlResult($result, 'getMyLoanHistory')
);
// If there are requested lines collected break the iteration
if (count($retval['items']) > $lastLine) {
break;
}
}
}
$ids = $this->getAlternativeItemId(array_column($retval['items'], FincILS::ILS_IDENTIFIER_BARCODE), FincILS::ILS_IDENTIFIER_BARCODE); $ids = $this->getAlternativeItemId(array_column($retval['items'], FincILS::ILS_IDENTIFIER_BARCODE), FincILS::ILS_IDENTIFIER_BARCODE);
foreach ($retval['items'] as $number => &$current) { foreach ($retval['items'] as $number => &$current) {
......
...@@ -17,25 +17,9 @@ ...@@ -17,25 +17,9 @@
<?=$this->context($this)->renderInContext('librarycards/selectcard.phtml', ['user' => $this->auth()->isLoggedIn()]); ?> <?=$this->context($this)->renderInContext('librarycards/selectcard.phtml', ['user' => $this->auth()->isLoggedIn()]); ?>
<?php if (!empty($this->transactions)): ?> <?php if (!empty($this->recordList)): ?>
<?php /* finc adds aria-label */ ?> <?php /* finc adds aria-label */ ?>
<nav class="search-header hidden-print" aria-label="<?=$this->transEscAttr('aria_search_header')?>"> <nav class="search-header hidden-print" aria-label="<?=$this->transEscAttr('aria_search_header')?>">
<?php if ($this->paginator): ?>
<div class="search-stats">
<?php
$end = min(
$this->paginator->getAbsoluteItemNumber($this->paginator->getItemCountPerPage()),
$this->paginator->getTotalItemCount()
);
$transParams = [
'%%start%%' => $this->localizedNumber($this->paginator->getAbsoluteItemNumber(1)),
'%%end%%' => $this->localizedNumber($end),
'%%total%%' => $this->localizedNumber($this->paginator->getTotalItemCount())
];
?>
<?=$this->translate('showing_items_of_html', $transParams); ?>
</div>
<?php endif; ?>
<?php if ($this->sortList): ?> <?php if ($this->sortList): ?>
<?=$this->context($this)->renderInContext('myresearch/controls/sort.phtml', ['sortList' => $this->sortList]); ?> <?=$this->context($this)->renderInContext('myresearch/controls/sort.phtml', ['sortList' => $this->sortList]); ?>
<?php endif; ?> <?php endif; ?>
...@@ -43,7 +27,7 @@ ...@@ -43,7 +27,7 @@
<?php /* finc uses ul to present list structure correctly, adds empty 'lang' attribute #18535 */ ?> <?php /* finc uses ul to present list structure correctly, adds empty 'lang' attribute #18535 */ ?>
<ul class="record-list"> <ul class="record-list">
<?php $i = 0; foreach ($this->transactions as $resource): ?> <?php $i = 0; foreach ($this->recordList as $resource): ?>
<?php $ilsDetails = $resource->getExtraDetail('ils_details'); ?> <?php $ilsDetails = $resource->getExtraDetail('ils_details'); ?>
<?php $describedById = $resource->getSourceIdentifier() . '|' . (empty($resource->getUniqueId()) ? md5(serialize($resource->getExtraDetail("ils_details"))) : $resource->getUniqueId()); ?> <?php $describedById = $resource->getSourceIdentifier() . '|' . (empty($resource->getUniqueId()) ? md5(serialize($resource->getExtraDetail("ils_details"))) : $resource->getUniqueId()); ?>
<li id="record<?=$this->escapeHtmlAttr($resource->getUniqueId())?>" class="result"> <li id="record<?=$this->escapeHtmlAttr($resource->getUniqueId())?>" class="result">
......
...@@ -78,9 +78,9 @@ ...@@ -78,9 +78,9 @@
</li> </li>
<?php endif; ?> <?php endif; ?>
<?php /* finc: adds historic loans */ ?> <?php /* finc: adds historic loans */ ?>
<?php if ($ilsOnline && $this->ils()->checkCapability('getMyLoanHistory', $capabilityParams) && $routeExists('myresearch-loanhistory')): ?> <?php if ($ilsOnline && $this->ils()->checkCapability('getMyTransactionHistory', $capabilityParams) && $routeExists('myresearch-loanhistory')): ?>
<li class="facet"> <li class="facet">
<a href="<?=$this->url('myresearch-loanhistory')?>"<?=$this->active == 'loanhistory' ? ' class="active" aria-current="page"' : ''?>> <a href="<?=$this->url('myresearch-historicloans')?>"<?=$this->active == 'historicloans' ? ' class="active" aria-current="page"' : ''?>>
<i class="fa fa-fw fa-history" aria-hidden="true"></i> <?=$this->transEsc('Loan History')?> <i class="fa fa-fw fa-history" aria-hidden="true"></i> <?=$this->transEsc('Loan History')?>
</a> </a>
</li> </li>
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment