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
No related merge requests found
......@@ -385,12 +385,15 @@ class FincLibero extends FincILS implements TranslatorAwareInterface
{
$customData = [];
$customData['pickUpLocations'] = [];
// flag to indicate that we have a valid service for loan or presentation
$hasValidService = false;
foreach (['available', 'unavailable'] as $availability) {
if (isset($item[$availability])) {
foreach ($item[$availability] as $available) {
if (isset($available['service'])
&& in_array($available['service'], ['presentation', 'loan'])
) {
$hasValidService = true;
// deal with pickuplocations
if (isset($available['limitation'])
&& $pickUpLocations = $this->filterPickUpLocations(
......@@ -403,16 +406,6 @@ class FincLibero extends FincILS implements TranslatorAwareInterface
$customData['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
if (isset($available['limitation'])) {
......@@ -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;
}
......
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