Skip to content
Merged
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
Empty file modified config/vufind/KohaILSDI.ini
100755 → 100644
Empty file.
22 changes: 21 additions & 1 deletion config/vufind/LOTS.ini
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ showReservationButton = true

[Suggestions]
allowAnonymous = true
; Example
; Example
; librariesToRemove="LIB1", "MAIN", "X"
librariesToRemove=""
; Note: The 'author' field is always visible and not hidden
Expand Down Expand Up @@ -123,5 +123,25 @@ showItemsInVufind = true
; SUPLER-212/Andra-eller-ta-bort-reservera-knapp-pa-exemplar
hideDetailReserveEvenIfInKoha = true

; LotsLerum-160
showAvailabilityInResults = false ; Set to false to hide the availability section
enableDebug = false ; Set to true to enable debug logging
maxBranches = 100 ; Maximum number of branches to process

[NotFinished]
showBankIDOption = false

; LotsLerum-158
; LOTS Session timeout configuration
; Session timeout configuration
[SessionTimeout]
; Enable or disable session timeout modal
enabled = false

; Use session CSRF EXPIRE time instead of configured timeout_minutes
; If true, will use EXPIRE from $_SESSION['__Laminas']['csrf']['EXPIRE']
; If false, will use timeout_minutes setting
use_session_expire = true

; Session timeout in minutes (used only when use_session_expire = false)
timeout_minutes = 60
8 changes: 8 additions & 0 deletions languages/en.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1329,3 +1329,11 @@ Your Tags = "Your Tags"
your_match_would_be_here = "Your match would be here."
Zip = "Zip"
zoom = "Zoom"
; LOTS begin
session_expired = "Your session has expired. Please login again."
Branch = "Branch"
Available copies = "Available copies"
Total copies = "Total copies"
No book found = "No book found"
Select branch = "Select branch"
; LOTS end
12 changes: 12 additions & 0 deletions languages/en.ini.lots-8.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
; LOTS begin
; Add the contents of this file to your language file in the folder /usr/local/vufind/local/languages or /usr/local/vufind/languages
; English (en.ini)
session_expired = "Your session has expired. Please login again."

; LotsLerum-160
Branch = "Branch"
Available copies = "Available copies"
Total copies = "Total copies"
No book found = "No book found"
Select branch = "Select branch"
; LOTS end
8 changes: 8 additions & 0 deletions languages/sv.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1451,3 +1451,11 @@ suggestion_top_paragraph="<p>Fyll i formuläret för att lämna ett inköpsförs
Give suggestions=Inköpsförslag
Patron ID=Låntagarnummer
ils_availability_detail="<br/><i class="fas fa-caret-down"></i><font color='#000'>Tillgängliga exemplar: %d/%d</font>
; LOTS begin
session_expired = "Din session har gått ut. Vänligen logga in igen."
Branch = "Filial"
Available copies = "Tillgängliga exemplar"
Total copies = "Totalt antal exemplar"
No book found = "Inga exemplar"
Select branch = "Välj filial"
; LOTS end
12 changes: 12 additions & 0 deletions languages/sv.ini.lots-8.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
; LOTS begin
; Add the contents of this file to your language file in the folder /usr/local/vufind/local/languages or /usr/local/vufind/languages
; Swedish (sv.ini)
session_expired = "Din session har gått ut. Vänligen logga in igen."

; LotsLerum-160
Branch = "Filial"
Available copies = "Tillgängliga exemplar"
Total copies = "Totalt antal exemplar"
No book found = "Inga exemplar"
Select branch = "Välj filial"
; LOTS end
15 changes: 0 additions & 15 deletions local/config/vufind/LOTS.ini

This file was deleted.

2 changes: 0 additions & 2 deletions local/languages/en.ini

This file was deleted.

2 changes: 0 additions & 2 deletions local/languages/sv.ini

This file was deleted.

142 changes: 141 additions & 1 deletion module/LOTS/src/LOTS/ILS/Driver/KohaRest.php
Original file line number Diff line number Diff line change
Expand Up @@ -544,5 +544,145 @@ protected function getTransactions($patron, $params, $checkedIn)
'count' => $result['headers']['X-Total-Count'] ?? count($transactions),
$arrayKey => $transactions
];
}
}

/**
* Helper method to check if debug logging is enabled
*
* @return bool True if debug logging is enabled, false otherwise
*/
protected function isDebugEnabled()
{
return isset($this->lotsConfig->Record->enableDebug)
&& $this->lotsConfig->Record->enableDebug == true;
}

/**
* Conditional debug logging method
*
* @param string $message Debug message to log
*/
protected function debugLog($message)
{
if ($this->isDebugEnabled()) {
$this->debug($message);
}
}

/**
* Get a list of available branches from Koha (excluding hidden ones).
*
* @return array List of branches with 'id' and 'name'
*/
public function getAvailableBranches()
{
// Cache the result to avoid multiple API calls
if ($this->availableBranches === null) {
$this->availableBranches = [];

$this->debugLog('Calling getAvailableBranches');

try {
// Fetch all branches in one request by setting high _per_page to handle pagination
$response = $this->makeRequest([
'path' => ['v1', 'libraries'],
'query' => ['_per_page' => 100] // Assuming <100 branches; adjust if more
]);
$this->debugLog('Response from /v1/libraries: ' . var_export($response, true));
} catch (\Exception $e) {
$this->debugLog('Exception in getAvailableBranches: ' . $e->getMessage());
return $this->availableBranches;
}

if ($response && isset($response['data'])) {
foreach ($response['data'] as $branch) {
if (!isset($branch['hidden']) || $branch['hidden'] != 1) {
$this->availableBranches[] = [
'id' => $branch['library_id'] ?? $branch['id'] ?? null,
'name' => $branch['name'] ?? $branch['branchname'] ?? 'Unnamed Branch',
];
}
}
} else {
$this->debugLog('No branches data found in response');
}

$this->debugLog('Returning branches: ' . var_export($this->availableBranches, true));
}

return $this->availableBranches;
}

/**
* Get availability information for a specific branch or all branches if no branch is specified.
*
* @param string|null $branchId The branch ID to check, or null for all branches
* @param string|null $biblionumber The biblionumber to check availability for
* @return array Array with 'available' and 'total' counts per branch
*/
public function getAvailability($branchId = null, $biblionumber = null)
{
$availability = [];

$this->debugLog('Calling getAvailability for branch: ' . ($branchId ?? 'all'));
if (!$biblionumber) {
$biblionumber = $this->getBiblionumber();
if (!$biblionumber) {
$this->debugLog('No biblionumber available, skipping availability check');
return [];
}
}

try {
$response = $this->makeRequest(
[
'path' => ['v1', 'contrib', 'kohasuomi', 'availability', 'biblios', $biblionumber, 'search'],
]
);
$this->debugLog('Response from /v1/contrib/kohasuomi/availability/biblios/' . $biblionumber . '/search: ' . var_export($response, true));
} catch (\Exception $e) {
$this->debugLog('Exception in getAvailability: ' . $e->getMessage());
return [];
}

if ($response && isset($response['data']['item_availabilities'])) {
foreach ($response['data']['item_availabilities'] as $item) {
$holdingLibraryId = $item['holding_library_id'];
if (!isset($availability[$holdingLibraryId])) {
$availability[$holdingLibraryId] = [
'available' => 0,
'total' => 0,
];
}
$availability[$holdingLibraryId]['total']++;
if ($item['availability']['available']) {
$availability[$holdingLibraryId]['available']++;
}
}
} else {
$this->debugLog('No items data found in response');
}

// If a specific branch is requested, return only that branch's data
if ($branchId && isset($availability[$branchId])) {
return $availability[$branchId];
}

$this->debugLog('Returning availability: ' . var_export($availability, true));
return $availability;
}

/**
* Get the biblionumber for the current record.
*
* @return string|null Biblionumber or null if not available
*/
protected function getBiblionumber()
{
if (isset($this->driver) && method_exists($this->driver, 'getUniqueID')) {
return $this->driver->getUniqueID();
}
return null;
}

}
9 changes: 7 additions & 2 deletions themes/lots/templates/RecordDriver/DefaultRecord/core.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,20 @@ if (!isset($showSummaryLink)) {
// showCorefields[2] = "Language"
// showCorefields[3] = "Published"
// showCorefields[3] = "Subjects"

$showAllCorefields = $config->Record->showAllCorefields;
$showCorefields = $config->Record->showCorefields;
$showCorefields = $showCorefields->toArray();
if ($showCorefields instanceof Laminas\Config\Config) {
$showCorefields = $showCorefields->toArray();
}
if (!isset($showCorefields)) {
$showCorefields = ['nope'];
}

$showCorefieldPrefixes = $config->Record->showCorefieldPrefixes;
$showCorefieldPrefixes = $showCorefieldPrefixes->toArray();
if ($showCorefieldPrefixes instanceof Laminas\Config\Config) {
$showCorefieldPrefixes = $showCorefieldPrefixes->toArray();
}
if (!isset($showCorefieldPrefixes)) {
$showCorefieldPrefixes = ['nope'];
}
Expand Down
Loading
Loading