@@ -, +, @@ notforlan values as unavailable 1.1. Go to Administration > Circulation and fines rules 1.2. In the matrix, add a circulation like this - Patron category: All - Item type: Books - Current checkouts allowed: 10 - Current on-site checkouts allowed: 10 - Loan period: 21 - Holds allowed (total): 10 - Holds allowed (daily): 10 - Holds per record (count): 10 - On shelf holds allowed: If any unavailable - OPAC item level holds: Force 1.3. Click Save 2.1. Go to Cataloging 2.2. Click New record 2.3. Fill out the mandatory fields (by default in MARC21: 000, 003, 005, 008, 040, 245, and 942 (942 should be set to Books)) 2.4. Click Save 2.5. Fill out the following item fields - Not for loan: Ordered - Koha item type: Books 2.6. Click Add item 2.7. Click Normal to go to the detailed record 3.1. From the detailed record, click OPAC view: Open in new window. --> Note that the 'Place hold' option is not present 4.1. Back in the staff interface tab with the detailed record, click New > New item 4.2. Make sure the item type is set to Books 4.3. Add a barcode in p 4.4. Click Add item 5.1. Go back to the OPAC tab and refresh the page --> Note that the 'Place hold' option is still not present 6.1. In the staff interface tab, copy the barcode from the available item 6.2. Go to Patrons 6.3. Click on Search 6.4. Click Check out next to one of the patrons 6.5. Paste the barcode in the box and click Check out 7.1. Go back to the OPAC tab and refresh the page --> Note that the 'Place hold' option is now present 7.2. Click Place hold --> Note that only the checked out item is available to place on hold, if you click Show unholdable items, it will show the Ordered item, but you can't place a hold on it. --> Note that the 'Place hold' option is still present 9.1. Click Place hold --> Note that you can now place a hold on the 'Checked out' or the 'Ordered' item. 10.1. In the staff interface tab, click on 'Show checkouts' button 10.2. Select the Checked out item and click on 'Renew or check in selected items' button. 11.1. Go back to the OPAC tab and click on the book title right next to 'Place a hold on' checkbox to go back to the record details. --> Note that the 'Place hold' option is still present 11.2. Click Place hold --> Note that only the 'Ordered' item is available to place on hold, if you click Show unholdable items, it will show the Available item and you can't place a hold on it. 12.1 in the staff interface tab, click on 'Search catalog' and search for the record 12.2 click on 'Edit' then 'Edit items' 12.3 Delete the available item 13.1 Go back to the OPAC tab and click on the book title right next to 'Place a hold on' checkbox to go back to the record details. --> Note that the 'Place hold' option is present 13.2. Click Place hold --> Note that you can place a hold on the Ordered item. --- C4/Reserves.pm | 2 +- opac/opac-ISBDdetail.pl | 9 ++++----- opac/opac-MARCdetail.pl | 21 ++++++++++++++++----- opac/opac-detail.pl | 10 ++++------ 4 files changed, 25 insertions(+), 17 deletions(-) --- a/C4/Reserves.pm +++ a/C4/Reserves.pm @@ -1404,7 +1404,7 @@ sub IsAvailableForItemLevelRequest { my $any_available = ItemsAnyAvailableAndNotRestricted( { biblionumber => $item->biblionumber, patron => $patron }); return $any_available ? 0 : 1; } else { # on_shelf_holds == 0 "If any unavailable" (the description is rather cryptic and could still be improved) - return $item->onloan || IsItemOnHoldAndFound( $item->itemnumber ); + return $item->notforloan < 0 || $item->onloan || IsItemOnHoldAndFound( $item->itemnumber ); } } --- a/opac/opac-ISBDdetail.pl +++ a/opac/opac-ISBDdetail.pl @@ -52,7 +52,7 @@ use C4::Biblio qw( GetMarcISSN TransformMarcToKoha ); -use C4::Reserves; +use C4::Reserves qw( IsAvailableForItemLevelRequest ); use C4::Serials qw( CountSubscriptionFromBiblionumber SearchSubscriptions GetLatestSerials ); use C4::Koha qw( GetNormalizedEAN @@ -168,7 +168,7 @@ $template->param( subscriptionsnumber => $subscriptionsnumber, ); -my $allow_onshelf_holds; +my $can_item_be_reserved = 0; my $res = GetISBDView({ 'record' => $record, 'template' => 'opac', @@ -178,11 +178,10 @@ my $res = GetISBDView({ my $items = $biblio->items; while ( my $item = $items->next ) { - $allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } ) - unless $allow_onshelf_holds; + $can_item_be_reserved = $can_item_be_reserved || IsAvailableForItemLevelRequest($item, $patron, undef); } -if( $allow_onshelf_holds || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) { +if( $can_item_be_reserved || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) { $template->param( ReservableItems => 1 ); } --- a/opac/opac-MARCdetail.pl +++ a/opac/opac-MARCdetail.pl @@ -58,7 +58,7 @@ use C4::Biblio qw( GetMarcStructure TransformMarcToKoha ); -use C4::Reserves; +use C4::Reserves qw( IsAvailableForItemLevelRequest CanBookBeReserved ); use C4::Members; use C4::Koha qw( GetNormalizedISBN ); use List::MoreUtils qw( uniq ); @@ -136,15 +136,26 @@ $template->param( ) if $tagslib->{$bt_tag}->{$bt_subtag}->{hidden} <= 0 && # <=0 OPAC visible. $tagslib->{$bt_tag}->{$bt_subtag}->{hidden} > -8; # except -8; -my $allow_onshelf_holds; +my $currentbranch = C4::Context->userenv ? C4::Context->userenv->{branch} : undef; +my $is_available; $items->reset; while ( my $item = $items->next ) { - $allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } ) - unless $allow_onshelf_holds; + my $default_hold_pickup_location_pref = C4::Context->preference('DefaultHoldPickupLocation'); + my $pickup_branch; + if( $default_hold_pickup_location_pref eq 'homebranch' ){ + $pickup_branch = $item->{homebranch} ? $item->{homebranch} : undef; + } elsif ( $default_hold_pickup_location_pref eq 'holdingbranch' ){ + $pickup_branch = $item->{holdingbranch} ? $item->{holdingbranch} : undef; + } else { + $pickup_branch = $currentbranch; + } + $is_available = IsAvailableForItemLevelRequest($item, $patron, $pickup_branch) + unless $is_available; } -if( $allow_onshelf_holds || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) { +my $canReserve = CanBookBeReserved($loggedinuser, $biblionumber, $currentbranch); +if (!$loggedinuser || ($canReserve->{status} eq "OK" && $is_available)) { $template->param( ReservableItems => 1 ); } --- a/opac/opac-detail.pl +++ a/opac/opac-detail.pl @@ -60,7 +60,7 @@ use C4::External::Syndetics qw( use C4::Members; use C4::XSLT qw( XSLTParse4Display ); use C4::ShelfBrowser qw( GetNearbyItems ); -use C4::Reserves qw( GetReserveStatus ); +use C4::Reserves qw( GetReserveStatus IsAvailableForItemLevelRequest ); use C4::Charset qw( SetUTF8Flag ); use MARC::Field; use List::MoreUtils qw( any ); @@ -658,7 +658,7 @@ if ( C4::Context->preference('OPACAcquisitionDetails' ) ) { }; } -my $allow_onshelf_holds; +my $can_item_be_reserved = 0; my ( $itemloop_has_images, $otheritemloop_has_images ); if ( not $viewallitems and $items->count > $max_items_to_display ) { $template->param( @@ -682,9 +682,7 @@ else { $item_info->{holding_library_info} = $opac_info_holding->content if $opac_info_holding; $item_info->{home_library_info} = $opac_info_home->content if $opac_info_home; - $allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( - { item => $item, patron => $patron } ) - unless $allow_onshelf_holds; + $can_item_be_reserved = $can_item_be_reserved || IsAvailableForItemLevelRequest($item, $patron, undef); # get collection code description, too my $ccode = $item->ccode; @@ -759,7 +757,7 @@ else { } } -if( $allow_onshelf_holds || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) { +if( $can_item_be_reserved || CountItemsIssued($biblionumber) || $biblio->has_items_waiting_or_intransit ) { $template->param( ReservableItems => 1 ); } --