From a9ef94f211248261c3fd65fe551c4b8e1d618b7c Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 11 Mar 2020 06:00:27 -0400 Subject: [PATCH] Bug 24860: Skip non-matching volume holds in HoldsQueue Signed-off-by: Andrew Fuerste-Henry --- C4/HoldsQueue.pm | 48 +++++++++++++++++++--- .../prog/en/modules/circ/view_holdsqueue.tt | 2 + 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm index 5f2c2c556c..82eaedd39f 100755 --- a/C4/HoldsQueue.pm +++ b/C4/HoldsQueue.pm @@ -137,11 +137,14 @@ sub GetHoldsQueueItems { biblio.copyrightdate, biblio.subtitle, biblio.medium, biblio.part_number, biblio.part_name, biblioitems.publicationyear, biblioitems.pages, biblioitems.size, - biblioitems.isbn, items.copynumber + biblioitems.isbn, items.copynumber, + volumes.id AS volume_id, volumes.description AS volume_description FROM tmp_holdsqueue - JOIN biblio USING (biblionumber) - LEFT JOIN biblioitems USING (biblionumber) - LEFT JOIN items USING ( itemnumber) + JOIN biblio USING (biblionumber) + LEFT JOIN biblioitems USING (biblionumber) + LEFT JOIN items USING ( itemnumber) + LEFT JOIN volume_items USING ( itemnumber) + LEFT JOIN volumes ON ( volume_items.volume_id = volumes.id ) /; if ($branchlimit) { $query .=" WHERE tmp_holdsqueue.holdingbranch = ?"; @@ -277,7 +280,7 @@ sub GetPendingHoldRequestsForBib { my $dbh = C4::Context->dbh; my $request_query = "SELECT biblionumber, borrowernumber, itemnumber, priority, reserves.branchcode, - reservedate, reservenotes, borrowers.branchcode AS borrowerbranch, itemtype + reservedate, reservenotes, borrowers.branchcode AS borrowerbranch, itemtype, volume_id FROM reserves JOIN borrowers USING (borrowernumber) WHERE biblionumber = ? @@ -409,6 +412,8 @@ sub MapItemsToHoldRequests { || ( $item->{holdallowed} == 1 && $item->{homebranch} ne $request->{borrowerbranch} ); + next if $request->{volume_id} && $item->{_object}->volume && $item->{_object}->volume->id ne $request->{volume_id}; + next unless $item->{_object}->can_be_transferred( { to => $libraries->{ $request->{branchcode} } } ); my $local_holds_priority_item_branchcode = @@ -464,6 +469,9 @@ sub MapItemsToHoldRequests { || ( $request->{branchcode} eq $items_by_itemnumber{ $request->{itemnumber} }->{ $items_by_itemnumber{ $request->{itemnumber} }->{hold_fulfillment_policy} } ) and ( !$request->{itemtype} # If hold itemtype is set, item's itemtype must match || $items_by_itemnumber{ $request->{itemnumber} }->{itype} eq $request->{itemtype} ) + and ( !$request->{volume_id} # If hold volume is set, item's volume must match + || ( $items_by_itemnumber{ $request->{itemnumber} }->{_object}->volume + && $items_by_itemnumber{ $request->{itemnumber} }->{_object}->volume->id eq $request->{volume_id} ) ) ) and $items_by_itemnumber{ $request->{itemnumber} }->{_object}->can_be_transferred( { to => $libraries->{ $request->{branchcode} } } ) @@ -521,6 +529,8 @@ sub MapItemsToHoldRequests { || $request->{branchcode} eq $item->{ $item->{hold_fulfillment_policy} } ) && ( !$request->{itemtype} # If hold itemtype is set, item's itemtype must match || $items_by_itemnumber{ $request->{itemnumber} }->{itype} eq $request->{itemtype} ) + && ( !$request->{volume_id} # If hold volume is set, item's volume must match + || ( $item->{_object}->volume && $item->{_object}->volume->id eq $request->{volume_id} ) ) ) { $itemnumber = $item->{itemnumber}; @@ -547,6 +557,13 @@ sub MapItemsToHoldRequests { next unless ( !$request->{itemtype} || $item->{itype} eq $request->{itemtype} ); + # If hold volume is set, item's volume must match + next unless ( + !$request->{volume_id} + || ( $item->{_object}->volume + && $item->{_object}->volume->id eq $request->{volume_id} ) + ); + $itemnumber = $item->{itemnumber}; last; } @@ -584,6 +601,13 @@ sub MapItemsToHoldRequests { next unless ( !$request->{itemtype} || $item->{itype} eq $request->{itemtype} ); + # If hold volume is set, item's volume must match + next unless ( + !$request->{volume_id} + || ( $item->{_object}->volume + && $item->{_object}->volume->id eq $request->{volume_id} ) + ); + $itemnumber = $item->{itemnumber}; $holdingbranch = $branch; last PULL_BRANCHES; @@ -603,6 +627,13 @@ sub MapItemsToHoldRequests { next unless ( !$request->{itemtype} || $current_item->{itype} eq $request->{itemtype} ); + # If hold volume is set, item's volume must match + next unless ( + !$request->{volume_id} + || ( $current_item->{_object}->volume + && $current_item->{_object}->volume->id eq $request->{volume_id} ) + ); + next unless $items_by_itemnumber{ $current_item->{itemnumber} }->{_object}->can_be_transferred( { to => $libraries->{ $request->{branchcode} } } ); $itemnumber = $current_item->{itemnumber}; @@ -629,6 +660,13 @@ sub MapItemsToHoldRequests { next unless ( !$request->{itemtype} || $item->{itype} eq $request->{itemtype} ); + # If hold volume is set, item's volume must match + next unless ( + !$request->{volume_id} + || ( $item->{_object}->volume + && $item->{_object}->volume->id eq $request->{volume_id} ) + ); + next unless $items_by_itemnumber{ $item->{itemnumber} }->{_object}->can_be_transferred( { to => $libraries->{ $request->{branchcode} } } ); $itemnumber = $item->{itemnumber}; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt index 63bc6263de..ceb0031114 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt @@ -156,6 +156,8 @@ [% IF ( itemsloo.item_level_request ) %] Only item: [% itemsloo.barcode | html %] + [% ELSIF itemsloo.volume_id %] + [% itemsloo.barcode | html %] or any item from volume [% itemsloo.volume_description | html %] [% ELSE %] [% itemsloo.barcode | html %] or any available [% END %] -- 2.11.0