Skip to content
Snippets Groups Projects
Commit a1d9077c authored by Robert Lange's avatar Robert Lange Committed by Dorian Merz
Browse files

refs #19717 [finc] fix multiple pickup locations in FincLibero::getCustomData

* multiple pickup locations should be possible and not overwritten
* but a fallback of department as pickup location should only be set, when
** there has been a service of presentation or loan
** and no pickup location could be filtered
parent 7b997593
Branches
Tags
No related merge requests found
...@@ -385,12 +385,15 @@ class FincLibero extends FincILS implements TranslatorAwareInterface ...@@ -385,12 +385,15 @@ class FincLibero extends FincILS implements TranslatorAwareInterface
{ {
$customData = []; $customData = [];
$customData['pickUpLocations'] = []; $customData['pickUpLocations'] = [];
// flag to indicate that we have a valid service for loan or presentation
$hasValidService = false;
foreach (['available', 'unavailable'] as $availability) { foreach (['available', 'unavailable'] as $availability) {
if (isset($item[$availability])) { if (isset($item[$availability])) {
foreach ($item[$availability] as $available) { foreach ($item[$availability] as $available) {
if (isset($available['service']) if (isset($available['service'])
&& in_array($available['service'], ['presentation', 'loan']) && in_array($available['service'], ['presentation', 'loan'])
) { ) {
$hasValidService = true;
// deal with pickuplocations // deal with pickuplocations
if (isset($available['limitation']) if (isset($available['limitation'])
&& $pickUpLocations = $this->filterPickUpLocations( && $pickUpLocations = $this->filterPickUpLocations(
...@@ -403,16 +406,6 @@ class FincLibero extends FincILS implements TranslatorAwareInterface ...@@ -403,16 +406,6 @@ class FincLibero extends FincILS implements TranslatorAwareInterface
$customData['pickUpLocations'], $customData['pickUpLocations'],
$pickUpLocations $pickUpLocations
); );
} elseif (empty($customData['pickUpLocations']) && isset($item['department'])) {
// if we have no explicit limitations qualifying for
// pickUpLocations, assume the item's department as single
// pickUpLocation
$customData['pickUpLocations'] = array_merge($customData['pickUpLocations'], [
[
'locationID' => $item['department']['id'],
'locationDisplay' => $item['department']['content']
]
]);
} }
// deal with EmailHold information // deal with EmailHold information
if (isset($available['limitation'])) { if (isset($available['limitation'])) {
...@@ -435,6 +428,19 @@ class FincLibero extends FincILS implements TranslatorAwareInterface ...@@ -435,6 +428,19 @@ class FincLibero extends FincILS implements TranslatorAwareInterface
} }
} }
} }
// check if we have a valid service, but no pickup locations given, then set fallback pickup location department
if ($hasValidService && empty($customData['pickUpLocations']) && isset($item['department'])) {
// if we have no explicit limitations qualifying for
// pickUpLocations, assume the item's department as single
// pickUpLocation
$customData['pickUpLocations'] = [
[
'locationID' => $item['department']['id'],
'locationDisplay' => $item['department']['content']
]
];
}
return $customData; return $customData;
} }
......
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