Skip to content

Commit

Permalink
Display last pickup date for available holds with SierraRest driver. (#…
Browse files Browse the repository at this point in the history
…1205)

- Adds support for doing the same with other drivers too.
  • Loading branch information
EreMaijala authored and demiankatz committed Jul 17, 2018
1 parent 94a095f commit 2708ad2
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 4 deletions.
3 changes: 3 additions & 0 deletions config/vufind/SierraRest.ini
Expand Up @@ -12,6 +12,9 @@ host = "https://sandbox.iii.com/iii/sierra-api"
client_key = "something"
; Sierra API client secret
client_secret = "very_secret"
; Sierra API version available (defaults to highest one required for full
; functionality in the driver)
;api_version = 5
; Timeout for HTTP requests
http_timeout = 30
; Redirect URL entered in Sierra for the patron-specific authentication (does not
Expand Down
1 change: 1 addition & 0 deletions languages/en.ini
Expand Up @@ -447,6 +447,7 @@ history_saved_searches = "Saved Searches"
history_search = "Search"
history_time = "Time"
hold_available = "Available for Pickup"
hold_available_until = "Available for Pickup Until %%date%%"
hold_cancel = "Cancel Hold"
hold_cancel_all = "Cancel All Holds"
hold_cancel_fail = "Your request was not canceled. Please contact the circulation desk for further assistance"
Expand Down
1 change: 1 addition & 0 deletions languages/fi.ini
Expand Up @@ -451,6 +451,7 @@ history_saved_searches = "Tallennetut haut"
history_search = "Haku"
history_time = "Aika"
hold_available = "Noudettavissa"
hold_available_until = "Noudettavissa - noudettava viimeistään %%date%%"
hold_cancel = "Peru varaus"
hold_cancel_all = "Peru kaikki varaukset"
hold_cancel_fail = "Varaustasi ei peruttu. Ota yhteyttä kirjaston asiakaspalveluun."
Expand Down
1 change: 1 addition & 0 deletions languages/sv.ini
Expand Up @@ -446,6 +446,7 @@ history_saved_searches = "Sparade sökningar"
history_search = "Sökning"
history_time = "Tid"
hold_available = "Kan avhämtas"
hold_available_until = "Kan avhämtas - sista avhämtningsdag %%date%%"
hold_cancel = "Annullera reserveringen"
hold_cancel_all = "Annullera alla reserveringar"
hold_cancel_fail = "Reserveringen kunde inte annulleras. Kontakta kundtjänst."
Expand Down
26 changes: 23 additions & 3 deletions module/VuFind/src/VuFind/ILS/Driver/SierraRest.php
Expand Up @@ -4,7 +4,7 @@
*
* PHP version 7
*
* Copyright (C) The National Library of Finland 2016-2017.
* Copyright (C) The National Library of Finland 2016-2018.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
Expand Down Expand Up @@ -141,6 +141,13 @@ class SierraRest extends AbstractBase implements TranslatorAwareInterface,
'd' => 'In Process'
];

/**
* Available API version
*
* @var int
*/
protected $apiVersion = 5;

/**
* Constructor
*
Expand Down Expand Up @@ -222,6 +229,10 @@ public function init()
);
}

if (isset($this->config['Catalog']['api_version'])) {
$this->apiVersion = $this->config['Catalog']['api_version'];
}

// Init session cache for session-specific data
$namespace = md5(
$this->config['Catalog']['host'] . '|'
Expand Down Expand Up @@ -711,12 +722,16 @@ public function getMyTransactionHistory($patron, $params)
*/
public function getMyHolds($patron)
{
$fields = 'id,record,frozen,placed,location,pickupLocation,status'
. ',recordType,priority,priorityQueueLength';
if ($this->apiVersion >= 5) {
$fields .= ',pickupByDate';
}
$result = $this->makeRequest(
['v3', 'patrons', $patron['id'], 'holds'],
[
'limit' => 10000,
'fields' => 'id,record,frozen,placed,location,pickupLocation'
. ',status,recordType,priority,priorityQueueLength'
'fields' => $fields
],
'GET',
$patron
Expand Down Expand Up @@ -762,6 +777,10 @@ public function getMyHolds($patron)
$position = ($entry['priority'] + 1) . ' / '
. $entry['priorityQueueLength'];
}
$lastPickup = !empty($entry['pickupByDate'])
? $this->dateConverter->convertToDisplayDate(
'Y-m-d', $entry['pickupByDate']
) : '';
$holds[] = [
'id' => $bibId,
'requestId' => $this->extractId($entry['id']),
Expand All @@ -770,6 +789,7 @@ public function getMyHolds($patron)
'create' => $this->dateConverter->convertToDisplayDate(
'Y-m-d', $entry['placed']
),
'last_pickup_date' => $lastPickup,
'position' => $position,
'available' => $available,
'in_transit' => $entry['status']['code'] == 't',
Expand Down
8 changes: 7 additions & 1 deletion themes/bootstrap3/templates/myresearch/holds.phtml
Expand Up @@ -149,7 +149,13 @@
<?php endif; ?>

<?php if (isset($ilsDetails['available']) && $ilsDetails['available'] == true): ?>
<div class="text-success"><?=$this->transEsc("hold_available") ?></div>
<div class="text-success">
<?php if (!empty($ilsDetails['last_pickup_date'])): ?>
<?=$this->transEsc('hold_available_until', ['%%date%%' => $ilsDetails['last_pickup_date']]) ?>
<?php else: ?>
<?=$this->transEsc('hold_available') ?>
<?php endif; ?>
</div>
<?php elseif (isset($ilsDetails['in_transit']) && $ilsDetails['in_transit']): ?>
<div class="text-success"><?=$this->transEsc('request_in_transit') . (is_string($ilsDetails['in_transit']) ? ': ' . $this->transEsc('institution_' . $ilsDetails['in_transit'], [], $ilsDetails['in_transit']) : '') ?></div>
<?php elseif (isset($ilsDetails['position'])): ?>
Expand Down

0 comments on commit 2708ad2

Please sign in to comment.