diff --git a/config/vufind/VoyagerRestful.ini b/config/vufind/VoyagerRestful.ini index e0933fa92043473872cfd05ccb606802a35dc6c2..230b04350f2c86310220519a28bed02cc379ee1b 100644 --- a/config/vufind/VoyagerRestful.ini +++ b/config/vufind/VoyagerRestful.ini @@ -186,8 +186,12 @@ disableAvailabilityCheckForRequestGroups = "15:19:21:32" ;excludedItemLocations = "2:4:23:10" ; By default a patron can place a hold on records he/she already has on loan. -; Uncomment this setting to prevent placing a hold on something already on loan for -; the patron. +; This setting can be used to modify this behavior. Must be one of the following: +; 1) false to indicate that loans are not checked (default setting). +; 2) true to indicate that any loan on the bibliographic record prevents further +; holds. +; 3) "same-item" to indicate that a loan on the specific item prevents placing a hold +; on it. ;checkLoans = true ; Optional help texts that can be displayed on the hold form diff --git a/languages/en.ini b/languages/en.ini index 07c1e36eed86a3d6b1a6ba5b5960c734f9ec7df1..9a9c12c91be67f47259db249b1e13cddf3fa6ab8 100644 --- a/languages/en.ini +++ b/languages/en.ini @@ -452,6 +452,7 @@ hold_place_fail_missing = "Your request failed. Some data was missing. Please co hold_place_success_html = "Your request was successful. <a href="%%url%%">Your Holds and Recalls</a>." hold_profile_html = "For hold and recall information, please establish your <a href="%%url%%">Library Catalog Profile</a>." hold_queue_position = "Queue Position" +hold_record_already_on_loan = "You already have the record on loan" hold_request_group = "Request from" hold_requested_group = "Requested from" hold_required_by = "No longer required after" diff --git a/languages/fi.ini b/languages/fi.ini index dfe9c8dc4a818dc9b533bdc1bb2fcfb54169282a..a1e62b4cbb106ccd0daf78bdce22265b51b3a5fe 100644 --- a/languages/fi.ini +++ b/languages/fi.ini @@ -455,6 +455,7 @@ hold_place_fail_missing = "Pyyntö epäonnistui puuttuvien tietojen vuoksi. Ota hold_place_success_html = "Varauspyyntö onnistui. <a href="%%url%%">Varaukset</a>." hold_profile_html = "Kirjaudu <a href="%%url%%">kirjastokortilla</a> nähdäksesi varaukset." hold_queue_position = "Sijainti jonossa" +hold_record_already_on_loan = "Teos on jo sinulla lainassa" hold_request_group = "Varauksen kohde" hold_requested_group = "Varauksen kohde" hold_required_by = "Viimeinen voimassaolopäivä" diff --git a/languages/sv.ini b/languages/sv.ini index d1205ee37960ba80d1e419d5dc4a1505769a6b8b..d05f8ae1f26041fb6017f7c299278a02caa33feb 100644 --- a/languages/sv.ini +++ b/languages/sv.ini @@ -450,6 +450,7 @@ hold_place_fail_missing = "Reservering misslyckades p.g.a. att uppgifter saknas. hold_place_success_html = "Material har reserverats. <a href="%%url%%">Reserveringar</a>." hold_profile_html = "Logga in <a href %%url%%>med bibliotekskortet</a> för att se reserveringsmöjligheter." hold_queue_position = "Placering i kön" +hold_record_already_on_loan = "Du har detta material redan utlånad" hold_request_group = "Reservera från" hold_requested_group = "Reserverad från" hold_required_by = "Sista giltighetsdagen" diff --git a/module/VuFind/src/VuFind/ILS/Driver/VoyagerRestful.php b/module/VuFind/src/VuFind/ILS/Driver/VoyagerRestful.php index c67cc1c6c003584276c52e160be4cb4878ffb676..76bd82cca96eae066482f400f862aff3a39388c5 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/VoyagerRestful.php +++ b/module/VuFind/src/VuFind/ILS/Driver/VoyagerRestful.php @@ -1622,14 +1622,15 @@ EOT; } /** - * Check whether the given patron has the given bib record on loan. + * Check whether the given patron has the given bib record or its item on loan. * * @param int $patronId Patron ID - * @param int $bibId BIB ID + * @param int $bibId Bib ID + * @param int $itemId Item ID (optional) * * @return bool */ - protected function isRecordOnLoan($patronId, $bibId) + protected function isRecordOnLoan($patronId, $bibId, $itemId = null) { $sqlExpressions = [ 'count(cta.ITEM_ID) CNT' @@ -1659,6 +1660,11 @@ EOT; $sqlBind = ['patronId' => $patronId, 'bibId' => $bibId]; + if (null !== $itemId) { + $sqlWhere[] = 'cta.ITEM_ID=:itemId'; + $sqlBind['itemId'] = $itemId; + } + $sqlArray = [ 'expressions' => $sqlExpressions, 'from' => $sqlFrom, @@ -2022,7 +2028,9 @@ EOT; // Optional check that the patron doesn't already have the bib on loan if ($this->checkLoans) { - if ($this->isRecordOnLoan($patron['id'], $bibId)) { + $checkItemId = $this->checkLoans === 'same-item' && $level == 'copy' + && $itemId ? $itemId : null; + if ($this->isRecordOnLoan($patron['id'], $bibId, $checkItemId)) { return $this->holdError('hold_record_already_on_loan'); } }