Skip to content

Commit

Permalink
Display loan types from Folio.
Browse files Browse the repository at this point in the history
  • Loading branch information
bbusenius committed Jan 9, 2025
1 parent 339607a commit a84c575
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions languages/en.ini
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,7 @@ loan_history_empty = "You do not have any loans in your loan history."
loan_history_purge_all = "Purge History"
loan_history_purge_selected = "Purge Selected"
loan_history_selected_purged = "Selected loans have been purged from your loan history"
Loan Type = "Loan type"
Local Login = "Local Login"
local_login_desc = "Enter the username and password you created for this site."
Located = "Located"
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 @@ -30,6 +30,9 @@
</span>
<?php if ($availabilityStatus->isAvailable()): ?>
<?php /* Begin Available Items (Holds) */ ?>
<?php if (isset($holding['loan_type_id']) && !empty($holding['loan_type_name'])):?>
<span class="loan-period"><?=$this->transEsc('Loan Type')?>: <?=$holding['loan_type_name']?>&nbsp;</span>
<?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 (isset($holding['loan_type_id']) && !empty($holding['loan_type_name'])):?>
<span class="loan-period"><?=$this->transEsc('Loan Type')?>: <?=$holding['loan_type_name']?>&nbsp;</span>
<?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

0 comments on commit a84c575

Please sign in to comment.