From 2708ad2d60c8dd6e2b2cfa4bf5e150f547e8eab9 Mon Sep 17 00:00:00 2001 From: Ere Maijala Date: Tue, 17 Jul 2018 17:55:04 +0300 Subject: [PATCH] Display last pickup date for available holds with SierraRest driver. (#1205) - Adds support for doing the same with other drivers too. --- config/vufind/SierraRest.ini | 3 +++ languages/en.ini | 1 + languages/fi.ini | 1 + languages/sv.ini | 1 + .../src/VuFind/ILS/Driver/SierraRest.php | 26 ++++++++++++++++--- .../templates/myresearch/holds.phtml | 8 +++++- 6 files changed, 36 insertions(+), 4 deletions(-) diff --git a/config/vufind/SierraRest.ini b/config/vufind/SierraRest.ini index c702bcb5dc3..4f0074fddbe 100644 --- a/config/vufind/SierraRest.ini +++ b/config/vufind/SierraRest.ini @@ -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 diff --git a/languages/en.ini b/languages/en.ini index 369d4810717..3031a66d013 100644 --- a/languages/en.ini +++ b/languages/en.ini @@ -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" diff --git a/languages/fi.ini b/languages/fi.ini index 84e21ab0b20..8edbd131d4e 100644 --- a/languages/fi.ini +++ b/languages/fi.ini @@ -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." diff --git a/languages/sv.ini b/languages/sv.ini index 75368406c95..3ddde6970a7 100644 --- a/languages/sv.ini +++ b/languages/sv.ini @@ -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." diff --git a/module/VuFind/src/VuFind/ILS/Driver/SierraRest.php b/module/VuFind/src/VuFind/ILS/Driver/SierraRest.php index 73d34e30e2f..4ba768032ab 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/SierraRest.php +++ b/module/VuFind/src/VuFind/ILS/Driver/SierraRest.php @@ -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, @@ -141,6 +141,13 @@ class SierraRest extends AbstractBase implements TranslatorAwareInterface, 'd' => 'In Process' ]; + /** + * Available API version + * + * @var int + */ + protected $apiVersion = 5; + /** * Constructor * @@ -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'] . '|' @@ -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 @@ -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']), @@ -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', diff --git a/themes/bootstrap3/templates/myresearch/holds.phtml b/themes/bootstrap3/templates/myresearch/holds.phtml index 1c5fc30e6e5..74ce8c7ea09 100644 --- a/themes/bootstrap3/templates/myresearch/holds.phtml +++ b/themes/bootstrap3/templates/myresearch/holds.phtml @@ -149,7 +149,13 @@ -
transEsc("hold_available") ?>
+
+ + transEsc('hold_available_until', ['%%date%%' => $ilsDetails['last_pickup_date']]) ?> + + transEsc('hold_available') ?> + +
transEsc('request_in_transit') . (is_string($ilsDetails['in_transit']) ? ': ' . $this->transEsc('institution_' . $ilsDetails['in_transit'], [], $ilsDetails['in_transit']) : '') ?>