Bug 19298: Placing a hold from a list at the OPAC should respect issuing rules
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 12 Sep 2017 16:03:04 +0000 (13:03 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 25 Oct 2017 15:14:39 +0000 (12:14 -0300)
The issuing rule retrieve to know if a hold can be placed on a record of
a list is not correct.

Test plan:
0/ With item-level_itypes = item level
1/ Define a item.itype=BK and biblioitems.itemtype=CF
2/ Create a default rule to allow on shelf holds
3/ Create a specific rule for CF with on shelf holds="If any
unavailable"
4/ Add this bibliographic record to a list and view the list
=> Without this patch you will not see "Place hold"
=> With this patch applied you will see the "Place hold" button,
respecting the correct issuing rule

Followed test plan, patches worked as described.

Note: Just to clarify the test plan slightly in step 4 where it says you will not see 'Place Hold' it means to
the left of the 'Save to another List' link below the item availability
in the opac-shelves.pl page. Not the 'Place hold' button in the grey
page header box.

Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
opac/opac-shelves.pl

index e5b9cc6..1feaf57 100755 (executable)
@@ -29,6 +29,7 @@ use C4::Output;
 use C4::Tags qw( get_tags );
 use C4::XSLT;
 
+use Koha::Biblios;
 use Koha::Biblioitems;
 use Koha::Items;
 use Koha::ItemTypes;
@@ -272,6 +273,7 @@ if ( $op eq 'view' ) {
                 my $this_item    = GetBiblioData($biblionumber);
                 my $record = GetMarcBiblio({ biblionumber => $biblionumber });
                 my $framework = GetFrameworkCode( $biblionumber );
+                my $biblio = Koha::Biblios->find( $biblionumber );
                 $record_processor->options({
                     interface => 'opac',
                     frameworkcode => $framework
@@ -315,8 +317,11 @@ if ( $op eq 'view' ) {
                     });
                 }
 
-                $this_item->{allow_onshelf_holds} = C4::Reserves::OnShelfHoldsAllowed($this_item, $patron);
-
+                my $items = $biblio->items;
+                while ( my $item = $items->next ) {
+                    $this_item->{allow_onshelf_holds} = C4::Reserves::OnShelfHoldsAllowed($item->unblessed, $patron);
+                    last if $this_item->{allow_onshelf_holds};
+                }
 
                 if ( grep {$_ eq $biblionumber} @cart_list) {
                     $this_item->{incart} = 1;