diff --git a/local/config/vufind/FincLibero.ini b/local/config/vufind/FincLibero.ini index 26fb4a666a515219f64e3131dccad0fea6de5e75..3b73011fd7f88f3a4f2e1cf71a1d30fe1aea2eac 100644 --- a/local/config/vufind/FincLibero.ini +++ b/local/config/vufind/FincLibero.ini @@ -50,3 +50,8 @@ relative_path=FincILS.ini ; URIs that will be used for reading room views ;readingRoomURIs[] = "http://data.ub.uni-leipzig.de/resource/DE-15/pickup/zw01thekfo" + +; use Wachtl service for departments instead of DAIA details +;useWachtlPickupLocations = false +; use locationid and not customData +;useDaiaLocationId = true diff --git a/module/finc/src/finc/ILS/Driver/FincLibero.php b/module/finc/src/finc/ILS/Driver/FincLibero.php index 91d958f1bf604b53a71c8e72ecc1e3c9763c7219..ec2aed3e4ee37fa7011f3bfe07e13c2163d9e5f0 100644 --- a/module/finc/src/finc/ILS/Driver/FincLibero.php +++ b/module/finc/src/finc/ILS/Driver/FincLibero.php @@ -328,6 +328,8 @@ class FincLibero extends FincILS implements TranslatorAwareInterface ) ) { $result_item['item_id'] = $titleHoldId; + } else { + $result_item['item_id'] = $item['id']; } // custom DAIA field used in getHoldLink() @@ -1269,4 +1271,47 @@ class FincLibero extends FincILS implements TranslatorAwareInterface { return ''; } + + /** + * This method returns a list of locations where a user may collect a hold. + * + * @param array $patron Patron array returned by patronLogin method + * @param array $details Hold information array similar to placeHold's input + * @return array Array of associative arrays containing these keys: + * locationID - A pick up location id or code (string) + * locationDisplay – The text to display for the location (string) + * + * @link https://vufind.org/wiki/development:plugins:ils_drivers#getpickuplocations + */ + public function getPickUpLocations($patron = [], $details = []) + { + // use departments of Wachtl, not DAIA + if ($this->config['General']['useWachtlPickupLocations'] ?? false) { + return $this->getWachtlPickUpLocations($details); + } + + // use location and locationid, not customData of DAIA + if ($this->config['General']['useDaiaLocationId'] ?? false) { + return parent::getPickUpLocations($patron, $details); + } + + // use DAIA customData + if ($details != [] && isset($details['id'])) { + $statusItems = $this->getStatus($details['id']); + foreach ($statusItems as $statusItem) { + if ($statusItem['item_id'] == $details['item_id']) { + // our pickUpLocations are stored in the customData array upon + // processing the DAIA availability information + if (isset($statusItem['customData']) + && isset($statusItem['customData']['pickUpLocations']) + ) { + return $statusItem['customData']['pickUpLocations']; + } else { + return $this->stackURIs ?? []; + } + } + } + } + return []; + } } diff --git a/module/finc/src/finc/ILS/Driver/LiberoWachtlTrait.php b/module/finc/src/finc/ILS/Driver/LiberoWachtlTrait.php index 343989de53894480b66d025a5190961018c2bf74..ea403ca867fdc0414af5f4319f10cd870d64b7e1 100644 --- a/module/finc/src/finc/ILS/Driver/LiberoWachtlTrait.php +++ b/module/finc/src/finc/ILS/Driver/LiberoWachtlTrait.php @@ -442,6 +442,49 @@ trait LiberoWachtlTrait return $this->getLiberoWachtlResult($result, 'getMyProfile'); } + /** + * This method returns a list of locations where a user may collect a hold. + * + * @param array $details Hold information array similar to placeHold's input - needed for overriden method in de_zi4 + * + * @return array $locations Array of associative arrays containing these keys: + * locationID - A pick up location id or code (string) + * locationDisplay – The text to display for the location (string) + * @throws \Exception + * @throws \ILSException + * + * @link https://vufind.org/wiki/development:plugins:ils_drivers#getpickuplocations + */ + public function getWachtlPickUpLocations($details = []) + { + $locations = []; + + try { + $client = $this->httpService->createClient( + $this->baseUrl . + $this->config['General']['liberoDbName'] . + '/departments' + ); + $result = $client->send(); + } catch (\Exception $e) { + throw new ILSException($e->getMessage()); + } + + if ($result->isSuccess()) { + $arr = json_decode($result->getBody(), true); + $i = 0; + foreach ($arr as $code => $name) { + $locations[] + = ['locationID' => $code, 'locationDisplay' => $name] + ; + } + } else { + $this->debug( + "No list of pickup locations found." + ); + } + return $locations; + } /** * This method sends a PIN changing request to the LiberoWachtl.