Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display loan types from FOLIO #4183

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from
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
1 change: 1 addition & 0 deletions languages/en.ini
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,7 @@ load_tag_error = "Error: Could Not Load Tags"
Loading = "Loading"
loading_ellipsis = "Loading…"
Loan History = "Loan History"
Loan Type = "Loan type"
loan_history_all_purged = "Your loan history has been purged"
loan_history_confirm_purge_all = "Do you wish to purge all loans from your loan history?"
loan_history_confirm_purge_selected = "Do you wish to purge selected loans from your loan history?"
Expand Down
40 changes: 40 additions & 0 deletions module/VuFind/src/VuFind/ILS/Driver/Folio.php
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,35 @@ protected function getLocationData($locationId)
return compact('name', 'code', 'isActive', 'servicePointIds');
}

/**
* Get data about a loan type.
*
* @param string $loanTypeId UUID
*
* @return array
*/
protected function getLoanTypeData($loanTypeId)
{
$cacheKey = 'loanTypeMap';
$loanTypeMap = $this->getCachedData($cacheKey);
if (null === $loanTypeMap) {
$loanTypeMap = [];
foreach (
$this->getPagedResults(
'loantypes',
'/loan-types'
) as $loanType
) {
if (isset($loanType->name)) {
$name = $loanType->name;
$loanTypeMap[$loanType->id] = compact('name');
}
}
}
$this->putCachedData($cacheKey, $loanTypeMap);
return $loanTypeMap[$loanTypeId];
}

/**
* Choose a call number and callnumber prefix.
*
Expand Down Expand Up @@ -812,6 +841,15 @@ protected function formatHoldingItem(
);
$locAndHoldings = $this->getItemFieldsFromNonItemData($locationId, $holdingDetails, $currentLoan);

$loanTypeName = '';
$tempLoanTypeId = $item->temporaryLoanType->id ?? '';
$permLoanTypeId = $item->permanentLoanType->id ?? '';
$loanTypeId = !empty($tempLoanTypeId) ? $tempLoanTypeId : $permLoanTypeId;
if (!empty($loanTypeId)) {
$loanData = $this->getLoanTypeData($loanTypeId);
$loanTypeName = $loanData['name'];
}

return $callNumberData + $locAndHoldings + [
'id' => $bibId,
'item_id' => $item->id,
Expand All @@ -826,6 +864,8 @@ protected function formatHoldingItem(
'reserve' => 'TODO',
'addLink' => 'check',
'bound_with_records' => $boundWithRecords,
'loan_type_id' => $loanTypeId,
'loan_type_name' => $loanTypeName,
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,8 @@ protected function getExpectedGetHoldingResult(): array
'addLink' => true,
'bound_with_records' => [],
'folio_location_is_active' => true,
'loan_type_id' => '',
'loan_type_name' => '',
],
],
'electronic_holdings' => [],
Expand Down Expand Up @@ -1012,6 +1014,8 @@ public function testGetHoldingWithFolioSorting(): void
'addLink' => true,
'bound_with_records' => [],
'folio_location_is_active' => true,
'loan_type_id' => '',
'loan_type_name' => '',
],
],
'electronic_holdings' => [],
Expand Down Expand Up @@ -1058,6 +1062,8 @@ public function testGetHoldingFilteringOfEmptyHoldingStatements(): void
'addLink' => true,
'bound_with_records' => [],
'folio_location_is_active' => true,
'loan_type_id' => '',
'loan_type_name' => '',
],
],
'electronic_holdings' => [],
Expand Down Expand Up @@ -1102,6 +1108,8 @@ public function testGetHoldingWithDueDate(): void
'addLink' => true,
'bound_with_records' => [],
'folio_location_is_active' => true,
'loan_type_id' => '',
'loan_type_name' => '',
],
],
'electronic_holdings' => [],
Expand Down Expand Up @@ -1148,6 +1156,8 @@ public function testGetHoldingMultiVolumeWithVuFindSorting(): void
'addLink' => true,
'bound_with_records' => [],
'folio_location_is_active' => true,
'loan_type_id' => '',
'loan_type_name' => '',
],
1 => [
'callnumber_prefix' => '',
Expand All @@ -1173,6 +1183,8 @@ public function testGetHoldingMultiVolumeWithVuFindSorting(): void
'addLink' => true,
'bound_with_records' => [],
'folio_location_is_active' => true,
'loan_type_id' => '',
'loan_type_name' => '',
],
],
'electronic_holdings' => [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
</span>
<?php if ($availabilityStatus->isAvailable()): ?>
<?php /* Begin Available Items (Holds) */ ?>
<?php if (!empty($holding['loan_type_name'])): ?>
<span class="loan-type"><?=$this->transEsc('Loan Type')?>: <?=$holding['loan_type_name']?>&nbsp;</span>
<?php endif; ?>
<?php if ($holding['link'] ?? false): ?>
<a class="<?=$check ? 'checkRequest request-check ' : ''?>placehold icon-link" <?php if (!empty($holding['linkLightbox'])): ?>data-lightbox <?php endif; ?>href="<?=$this->escapeHtmlAttr($this->recordLinker()->getRequestUrl($holding['link']))?>">
<?=$this->icon('place-hold', 'icon-link__icon') ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
</span>
<?php if ($availabilityStatus->isAvailable()): ?>
<?php /* Begin Available Items (Holds) */ ?>
<?php if (!empty($holding['loan_type_name'])): ?>
<span class="loan-type"><?=$this->transEsc('Loan Type')?>: <?=$holding['loan_type_name']?>&nbsp;</span>
<?php endif; ?>
<?php if ($holding['link'] ?? false): ?>
<a class="<?=$check ? 'checkRequest request-check ' : ''?>placehold icon-link" <?php if (!empty($holding['linkLightbox'])): ?>data-lightbox <?php endif; ?>href="<?=$this->escapeHtmlAttr($this->recordLinker()->getRequestUrl($holding['link']))?>">
<?=$this->icon('place-hold', 'icon-link__icon') ?>
Expand Down
Loading