From 958a040b863122b37de183c99af7476d3e84ab21 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 item group holds in HoldsQueue Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Rebecca Coert --- C4/HoldsQueue.pm | 43 +++++++++++++++++-- .../prog/en/modules/circ/view_holdsqueue.tt | 2 + 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm index f2eb1ee4b8..f9a00729d7 100644 --- a/C4/HoldsQueue.pm +++ b/C4/HoldsQueue.pm @@ -131,11 +131,13 @@ sub GetHoldsQueueItems { biblio.copyrightdate, biblio.subtitle, biblio.medium, biblio.part_number, biblio.part_name, biblioitems.publicationyear, biblioitems.pages, biblioitems.size, - biblioitems.isbn, biblioitems.editionstatement, items.copynumber + biblioitems.isbn, biblioitems.editionstatement, items.copynumber, + item_groups.item_group_id, item_groups.description AS item_group_description FROM tmp_holdsqueue JOIN biblio USING (biblionumber) LEFT JOIN biblioitems USING (biblionumber) LEFT JOIN items USING ( itemnumber) + LEFT JOIN item_groups ON ( item_group_items.item_group_id = item_groups.item_group_id ) WHERE 1=1 /; if ($params->{branchlimit}) { @@ -275,7 +277,7 @@ sub GetPendingHoldRequestsForBib { my $dbh = C4::Context->dbh; my $request_query = "SELECT biblionumber, borrowernumber, itemnumber, priority, reserve_id, reserves.branchcode, - reservedate, reservenotes, borrowers.branchcode AS borrowerbranch, itemtype, item_level_hold + reservedate, reservenotes, borrowers.branchcode AS borrowerbranch, itemtype, item_level_hold, item_group_id FROM reserves JOIN borrowers USING (borrowernumber) WHERE biblionumber = ? @@ -456,6 +458,8 @@ sub MapItemsToHoldRequests { next if $request->{itemnumber} && $request->{itemnumber} != $item->{itemnumber}; + next if $request->{item_group_id} && $item->{_object}->item_group && $item->{_object}->item_group->id ne $request->{item_group_id}; + next unless $item->{_object}->can_be_transferred( { to => $libraries->{ $request->{branchcode} } } ); my $local_holds_priority_item_branchcode = @@ -510,7 +514,9 @@ sub MapItemsToHoldRequests { and _checkHoldPolicy($items_by_itemnumber{ $request->{itemnumber} }, $request) # Don't fill item level holds that contravene the hold pickup policy at this time and ( !$request->{itemtype} # If hold itemtype is set, item's itemtype must match || $items_by_itemnumber{ $request->{itemnumber} }->{itype} eq $request->{itemtype} ) - + and ( !$request->{item_group_id} # If hold item_group is set, item's item_group must match + || ( $items_by_itemnumber{ $request->{itemnumber} }->{_object}->item_group + && $items_by_itemnumber{ $request->{itemnumber} }->{_object}->item_group->id eq $request->{item_group_id} ) ) and $items_by_itemnumber{ $request->{itemnumber} }->{_object}->can_be_transferred( { to => $libraries->{ $request->{branchcode} } } ) ) @@ -567,6 +573,8 @@ sub MapItemsToHoldRequests { && _checkHoldPolicy($item, $request) # Don't fill item level holds that contravene the hold pickup policy at this time && ( !$request->{itemtype} # If hold itemtype is set, item's itemtype must match || ( $request->{itemnumber} && ( $items_by_itemnumber{ $request->{itemnumber} }->{itype} eq $request->{itemtype} ) ) ) + && ( !$request->{item_group_id} # If hold item_group is set, item's item_group must match + || ( $item->{_object}->item_group && $item->{_object}->item_group->id eq $request->{item_group_id} ) ) ) { $itemnumber = $item->{itemnumber}; @@ -592,6 +600,13 @@ sub MapItemsToHoldRequests { next unless ( !$request->{itemtype} || $item->{itype} eq $request->{itemtype} ); + # If hold item_group is set, item's item_group must match + next unless ( + !$request->{item_group_id} + || ( $item->{_object}->item_group + && $item->{_object}->item_group->id eq $request->{item_group_id} ) + ); + $itemnumber = $item->{itemnumber}; last; } @@ -629,6 +644,13 @@ sub MapItemsToHoldRequests { next unless ( !$request->{itemtype} || $item->{itype} eq $request->{itemtype} ); + # If hold item_group is set, item's item_group must match + next unless ( + !$request->{item_group_id} + || ( $item->{_object}->item_group + && $item->{_object}->item_group->id eq $request->{item_group_id} ) + ); + $itemnumber = $item->{itemnumber}; $holdingbranch = $branch; last PULL_BRANCHES; @@ -646,6 +668,14 @@ sub MapItemsToHoldRequests { next unless $items_by_itemnumber{ $current_item->{itemnumber} }->{_object}->can_be_transferred( { to => $libraries->{ $request->{branchcode} } } ); + # If hold item_group is set, item's item_group must match + next unless ( + !$request->{item_group_id} + || ( $current_item->{_object}->item_group + && $current_item->{_object}->item_group->id eq $request->{item_group_id} ) + ); + + $itemnumber = $current_item->{itemnumber}; last; # quit this loop as soon as we have a suitable item } @@ -666,6 +696,13 @@ sub MapItemsToHoldRequests { next unless ( !$request->{itemtype} || $item->{itype} eq $request->{itemtype} ); + # If hold item_group is set, item's item_group must match + next unless ( + !$request->{item_group_id} + || ( $item->{_object}->item_group + && $item->{_object}->item_group->id eq $request->{item_group_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 b0c0933df3..802627ab69 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 @@ -187,6 +187,8 @@ [% IF ( itemsloo.item_level_request ) %] Only item: [% itemsloo.barcode | html %] + [% ELSIF itemsloo.item_group_id %] + [% itemsloo.barcode | html %] or any item from item_group [% itemsloo.item_group_description | html %] [% ELSE %] [% itemsloo.barcode | html %] or any available [% END %] -- 2.30.2