From f77b1e3c0b36a0d859eb2c2a4ebc7bb76509b11a 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 339156a5eb..9f5d4d6284 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, item_level_hold + reservedate, reservenotes, borrowers.branchcode AS borrowerbranch, itemtype, item_level_hold, volume_id FROM reserves JOIN borrowers USING (borrowernumber) WHERE biblionumber = ? @@ -411,6 +414,8 @@ sub MapItemsToHoldRequests { next if $request->{itemnumber} && $request->{itemnumber} != $item->{itemnumber}; + 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 = @@ -466,6 +471,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} } } ) @@ -523,6 +531,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}; @@ -549,6 +559,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; } @@ -586,6 +603,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; @@ -605,6 +629,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}; @@ -631,6 +662,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 d467a1bf00..fc57053336 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.24.1 (Apple Git-126)