diff --git a/module/finc/src/finc/ILS/Driver/FincLibero.php b/module/finc/src/finc/ILS/Driver/FincLibero.php index 47858569991c924390ac3219cd9404ccf99f8054..8f562ec316f6d5d3018d1cb9004bc719fdbd4adf 100644 --- a/module/finc/src/finc/ILS/Driver/FincLibero.php +++ b/module/finc/src/finc/ILS/Driver/FincLibero.php @@ -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; }