@@ -, +, @@ CanItemBeReserved - Allow holds only on items that are currently checked out or otherwise unavailable. - If set to "Yes", patrons can place holds on items currently checked in. - If set to "If any unavailable", patrons can only place holds on items that are not unavailable. - If set to "If all unavailable", patrons can only place holds on items where *all* items on the record are unavailable. . "Yes", "If any unavailable", and "If all unavailable" . "Yes" ==> information column in the item table displays "Not on hold", the hold is placed, cancel the hold . "If any unavailable" and "If all unavailable" ==> the hold is not placed, message is "Cannot place hold. No items are available to be placed on hold.", red "X" in the hold column and the information column displays "Not on hold". . Query to place a hold using ILS-DI on a title that have all its items available, example query: http://127.0.0.1:8080/cgi-bin/koha/ilsdi.pl?service=HoldTitle&patron_id=1&bib_id=1&request_location=127.0.0.1 ==> Without the patch the hold is placed but it shouldn't be allowed, cancel the hold . Query to place a hold using ILS-DI on an available item, example query: http://127.0.0.1:8080/cgi-bin/koha/ilsdi.pl?service=HoldItem&patron_id=1&bib_id=1&item_id=1) ==> Without the patch the hold is placed but it shouldn't be allowed, cancel the hold . For the staff interface: there should be no change in behavour and should work as expected, for the red "X" in the items table additional text is added "onShelfHoldsNotAllowed". . For ILS-DI: these should now work as expected, with holds not placed, and this message in the results returned onShelfHoldsNotAllowed (check to confirm no holds place for either the patron or the item) . Tests: should still pass. --- C4/Reserves.pm | 17 ++++++++++++++--- .../intranet-tmpl/prog/en/modules/reserve/request.tt | 1 + t/db_dependent/Reserves.t | 16 ++++++++-------- 3 files changed, 23 insertions(+), 11 deletions(-) --- a/C4/Reserves.pm +++ a/C4/Reserves.pm @@ -352,6 +352,7 @@ sub CanBookBeReserved{ current checkout against the high holds threshold @RETURNS { status => OK }, if the Item can be reserved. + { status => onShelfHoldsNotAllowed }, if onShelfHoldsAllowed parameter and item availability combination doesn't allow holds. { status => ageRestricted }, if the Item is age restricted for this borrower. { status => damaged }, if the Item is damaged. { status => cannotReserveFromOtherBranches }, if syspref 'canreservefromotherbranches' is OK. @@ -371,6 +372,11 @@ sub CanItemBeReserved { my $dbh = C4::Context->dbh; my $ruleitemtype; # itemtype of the matching issuing rule my $allowedreserves = 0; # Total number of holds allowed across all records, default to none + my $holds_per_record = 1; # Total number of holds allowed for this one given record + my $holds_per_day; # Default to unlimited + my $opacitemholds = 'Y'; # Itemlevel holds default to allowed + my $on_shelf_holds = 0; # Default to "if any unavailable" + my $context = $params->{context} // ''; # we retrieve borrowers and items informations # # item->{itype} will come for biblioitems if necessery @@ -442,10 +448,11 @@ sub CanItemBeReserved { categorycode => $borrower->{'categorycode'}, itemtype => $item->effective_itemtype, branchcode => $branchcode, - rules => ['holds_per_record','holds_per_day'] + rules => ['holds_per_record','holds_per_day','onshelfholds'] }); - my $holds_per_record = $rights->{holds_per_record} // 1; - my $holds_per_day = $rights->{holds_per_day}; + $holds_per_record = $rights->{holds_per_record} // 1; + $holds_per_day = $rights->{holds_per_day}; + $on_shelf_holds = $rights->{onshelfholds}; my $search_params = { borrowernumber => $borrowernumber, @@ -453,6 +460,10 @@ sub CanItemBeReserved { }; $search_params->{found} = undef if $params->{ignore_found_holds}; + # Check for item on shelves and OnShelfHoldsAllowed + return { status => 'onShelfHoldsNotAllowed' } + unless IsAvailableForItemLevelRequest($item, $patron, $pickup_branchcode,1); + my $holds = Koha::Holds->search($search_params); if ( defined $holds_per_record && $holds_per_record ne '' && $holds->count() >= $holds_per_record ) { --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -1010,6 +1010,7 @@ tooManyReservesToday: _("Daily hold limit reached for patron"), tooManyReserves: _("Too many holds"), notReservable: _("Not holdable"), + onShelfHoldsNotAllowed: _("Not holdable"), cannotReserveFromOtherBranches: _("Patron is from different library"), itemAlreadyOnHold: _("Patron already has hold for this item"), cannotBeTransferred: _("Cannot be transferred to pickup library") --- a/t/db_dependent/Reserves.t +++ a/t/db_dependent/Reserves.t @@ -1234,14 +1234,14 @@ subtest 'AllowHoldOnPatronPossession test' => sub { value => { branchcode => $item->homebranch }}); Koha::CirculationRules->set_rules( - { - branchcode => undef, - categorycode => undef, - itemtype => undef, - rules => { - onshelfholds => 1, - } - } + { + branchcode => undef, + categorycode => undef, + itemtype => undef, + rules => { + onshelfholds => 1, + } + } ); C4::Circulation::AddIssue($patron->unblessed, --