Skip to content
Snippets Groups Projects
Commit 0ce8a224 authored by Robert Lange's avatar Robert Lange
Browse files

refs #20842 [finc] refactor getPickUpLocations

* move getWachtlPickUpLocations from de_zwi2, de_d13 to LiberoWachtlTrait for PAIA usage to fetch pickUpLocations
* move getPickUpLocations from de_105, de_l152, de_15, de_ch1 to FincLibero for DAIA usage to fetch pickUpLocations
** check for config var "useWachtlPickupLocations" to use LiberoWachtlTrait
** check for useDaiaLocationId to use FincIls getPickUpLocations
** otherwise use customData from getCustomData

* refactor parseDaiaArray for getPickUpLocations
** set item_id for non-title-hold orders (storage retrieval request)
** also refs #20223
parent 774c3bf9
1 merge request!3refs #20945 [de_105] w3c validation - syntax fixes
...@@ -50,3 +50,8 @@ relative_path=FincILS.ini ...@@ -50,3 +50,8 @@ relative_path=FincILS.ini
; URIs that will be used for reading room views ; URIs that will be used for reading room views
;readingRoomURIs[] = "http://data.ub.uni-leipzig.de/resource/DE-15/pickup/zw01thekfo" ;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
...@@ -328,6 +328,8 @@ class FincLibero extends FincILS implements TranslatorAwareInterface ...@@ -328,6 +328,8 @@ class FincLibero extends FincILS implements TranslatorAwareInterface
) )
) { ) {
$result_item['item_id'] = $titleHoldId; $result_item['item_id'] = $titleHoldId;
} else {
$result_item['item_id'] = $item['id'];
} }
// custom DAIA field used in getHoldLink() // custom DAIA field used in getHoldLink()
...@@ -1269,4 +1271,47 @@ class FincLibero extends FincILS implements TranslatorAwareInterface ...@@ -1269,4 +1271,47 @@ class FincLibero extends FincILS implements TranslatorAwareInterface
{ {
return ''; 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 [];
}
} }
...@@ -442,6 +442,49 @@ trait LiberoWachtlTrait ...@@ -442,6 +442,49 @@ trait LiberoWachtlTrait
return $this->getLiberoWachtlResult($result, 'getMyProfile'); 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. * This method sends a PIN changing request to the LiberoWachtl.
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment