From f6334b595b0db7f64fabc8c65f9883bd24cad247 Mon Sep 17 00:00:00 2001 From: David Cook Date: Mon, 12 Feb 2024 23:17:05 +0000 Subject: [PATCH] Bug 15565: Place multiple holds on one record on staff interface --- .../prog/en/modules/reserve/request.tt | 70 ++++++++++++++--- reserve/placerequest.pl | 78 ++++++++++--------- reserve/request.pl | 3 + 3 files changed, 107 insertions(+), 44 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt index 025d5b0ca1..883caf483d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -168,6 +168,56 @@ [% END %] + [% IF ( failed_holds ) %] +
+ One or more holds were not placed due to following errors: + +
+ [% END %] + [% IF ( messagetransfert ) %]

Hold found for ([% nextreservtitle | html %]), please transfer

@@ -745,9 +795,9 @@ Hold must be item group level [% ELSIF ( itemloo.available ) %] - + [% ELSIF ( itemloo.override ) %] - + [% ELSE %] @@ -1502,11 +1552,11 @@ if ( ! $("#requestany").is(":checked") ) { // requestany not selected, go through the item-specific cases - if ( $('input[type="radio"]:checked').length > 0 ) { + if ( $('input[name="checkitem"]:checked').length > 0 ) { // got item-specific hold requests in the form! // verify they have a pickup location selected - if (table.find('input[type="radio"]:checked') + if (table.find('input[name="checkitem"]:checked') .closest('tr') .find(".pickup_locations").val() === null) { @@ -1597,15 +1647,17 @@ } }); $("input[name=checkitem]").click(function() { - onechecked = 0; + let onechecked = 0; $("input[name=checkitem]").each(function() { if(this.checked){ - onechecked = 1; + onechecked++; } }); - if(onechecked == 1){ + if(onechecked > 0){ $("#requestany").prop("checked", false); $("#holds_to_place_count").prop('disabled', true); + + $("#holds_to_place_count").val(onechecked); } else { $("#requestany").prop("checked",true); $("#holds_to_place_count").prop('disabled', false); @@ -1683,10 +1735,10 @@ [% IF Koha.Preference('EnableItemGroupHolds') %] $(':radio[name="item_group_id"]').change(function(){ - $(':radio[name="checkitem"]').prop('checked', false); + $('input[name="checkitem"]').prop('checked', false); }); - $(':radio[name="checkitem"]').change(function(){ + $('input[name="checkitem"]').change(function(){ $(':radio[name="item_group_id"]').prop('checked', false); }); [% END %] diff --git a/reserve/placerequest.pl b/reserve/placerequest.pl index a253fb5547..95e30836d3 100755 --- a/reserve/placerequest.pl +++ b/reserve/placerequest.pl @@ -44,7 +44,7 @@ my $branch = $input->param('pickup'); my $startdate = $input->param('reserve_date') || ''; my @rank = $input->multi_param('rank-request'); my $title = $input->param('title'); -my $checkitem = $input->param('checkitem'); +my @checkitems = $input->multi_param('checkitem'); my $item_group_id = $input->param('item_group_id'); my $expirationdate = $input->param('expiration_date'); my $itemtype = $input->param('itemtype') || undef; @@ -63,43 +63,46 @@ foreach my $bibnum ( @holdable_bibs ) { $bibinfos{$bibnum} = \%bibinfo; } -my $found; - if ( $patron ) { - + my %failed_holds; foreach my $biblionumber ( keys %bibinfos ) { my $can_override = C4::Context->preference('AllowHoldPolicyOverride'); - if ( defined $checkitem && $checkitem ne '' ) { - - if ( my $item_pickup_location = $input->param("item_pickup_$checkitem") ) { + if ( @checkitems ) { + for ( my $i = 0; $i < scalar @checkitems; $i++ ){ + my $checkitem = $checkitems[$i]; + if ( my $item_pickup_location = $input->param("item_pickup_$checkitem") ) { - my $item = Koha::Items->find($checkitem); + my $item = Koha::Items->find($checkitem); - if ( $item->biblionumber ne $biblionumber ) { - $biblionumber = $item->biblionumber; - } - - my $can_item_be_reserved = CanItemBeReserved($patron, $item, $item_pickup_location)->{status}; + if ( $item->biblionumber ne $biblionumber ) { + $biblionumber = $item->biblionumber; + } - if ( $can_item_be_reserved eq 'OK' || ( $can_item_be_reserved ne 'itemAlreadyOnHold' && $can_override ) ) { - AddReserve( - { - branchcode => $item_pickup_location, - borrowernumber => $patron->borrowernumber, - biblionumber => $biblionumber, - priority => $rank[0], - reservation_date => $startdate, - expiration_date => $expirationdate, - notes => $notes, - title => $title, - itemnumber => $checkitem, - found => $found, - itemtype => $itemtype, - non_priority => $non_priority, - } - ); + my $can_item_be_reserved = CanItemBeReserved($patron, $item, $item_pickup_location)->{status}; + + if ( $can_item_be_reserved eq 'OK' || ( $can_item_be_reserved ne 'itemAlreadyOnHold' && $can_override ) ) { + AddReserve( + { + branchcode => $item_pickup_location, + borrowernumber => $patron->borrowernumber, + biblionumber => $biblionumber, + priority => $rank[$i], + reservation_date => $startdate, + expiration_date => $expirationdate, + notes => $notes, + title => $title, + itemnumber => $checkitem, + found => undef, + itemtype => $itemtype, + non_priority => $non_priority, + } + ); + } + else { + $failed_holds{$can_item_be_reserved} = 1; + } } } @@ -116,8 +119,8 @@ if ( $patron ) { expiration_date => $expirationdate, notes => $notes, title => $bibinfo->{title}, - itemnumber => $checkitem, - found => $found, + itemnumber => undef, + found => undef, itemtype => $itemtype, non_priority => $non_priority, } @@ -137,8 +140,8 @@ if ( $patron ) { expiration_date => $expirationdate, notes => $notes, title => $title, - itemnumber => $checkitem, - found => $found, + itemnumber => undef, + found => undef, itemtype => $itemtype, non_priority => $non_priority, item_group_id => $item_group_id, @@ -150,7 +153,12 @@ if ( $patron ) { } my $redirect_url = URI->new("request.pl"); - $redirect_url->query_form( biblionumber => [@biblionumbers]); + my @failed_hold_msgs = (); + #NOTE: Deduplicate failed hold reason statuses/codes + foreach my $msg (keys %failed_holds){ + push(@failed_hold_msgs,$msg); + } + $redirect_url->query_form( biblionumber => [@biblionumbers], failed_holds => \@failed_hold_msgs); print $input->redirect($redirect_url); } elsif ( $borrowernumber eq '' ) { diff --git a/reserve/request.pl b/reserve/request.pl index 186b3faff5..78823b4a7b 100755 --- a/reserve/request.pl +++ b/reserve/request.pl @@ -88,6 +88,7 @@ my $warnings; my $messages; my $exceeded_maxreserves; my $exceeded_holds_per_record; +my @failed_holds = $input->multi_param('failed_holds'); my $action = $input->param('action'); $action ||= q{}; @@ -709,6 +710,8 @@ $template->param( pickup => $pickup || C4::Context->userenv->{branch} ); $template->param(borrowernumber => $borrowernumber_hold); +$template->param( failed_holds => \@failed_holds ); + # printout the page output_html_with_http_headers $input, $cookie, $template->output; -- 2.30.2