Bug 31692: Allow librarians to change hold type in staff client

To test:
1. Apply patch
2. Add item level hold to a record/item, make sure patron has no other
   holds on that record
3. Go to /cgi-bin/koha/reserve/request.pl?biblionumber=xxx where xxx is
   the record you placed the hold for
4. Under "Existing holds" table, in "Details" column you should see
   "Only item <barcode>" dropdown
5. Select "Next available" from the dropdown
6. Click Update hold(s)
7. Observe dropdown is gone and cell value has changed from
   "Only item <barcode>" to "Next available"
8. Cancel the hold and add two item level holds for the same patron
9. Under "Existing holds" table, in "Details" column you should see
   "Only item <barcode>", but no select dropdown

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Lari Taskula 2022-10-05 16:04:59 +00:00 committed by Tomas Cohen Arazi
parent 26afea24f8
commit b0f49d5daf
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
3 changed files with 46 additions and 1 deletions

View File

@ -176,6 +176,7 @@
[%- ELSE -%]
[%- IF ( hold.item_level_hold ) -%]
<em>
[%- IF ! hold.change_hold_type_allowed -%]
<span>Only item</span>
<a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% hold.biblionumber | uri %]&amp;itemnumber=[% hold.itemnumber | uri %]#item[% hold.itemnumber | uri %]">
[%- IF ( hold.barcodenumber ) -%]
@ -185,6 +186,25 @@
<span>No barcode</span>
[%- END -%]
</a>
[%- ELSE -%]
<select name="change_hold_type_[% hold.reserve_id | html %]">
<option selected="selected" value="">Only item [%- IF ( hold.barcodenumber ) -%]
[%- hold.barcodenumber | html -%]
[%- ELSE -%]
No barcode
[%- END -%]
</option>
<option value="1">Next available</option>
</select>
[%- IF ( hold.barcodenumber ) -%]
<input type="hidden" name="itemnumber" value="[% hold.itemnumber | html %]" />
[%- END -%]
[%- IF hold.itemtype -%]
<span style="display:none">Next available [% ItemTypes.GetDescription( hold.itemtype ) | html %] item</span>
[%- ELSE -%]
<span style="display:none">Next available</span>
[%- END -%]
[%- END -%]
</em>
[%- ELSE -%]
[%- IF hold.itemtype -%]

View File

@ -88,7 +88,21 @@ else {
} else {
$_->rethrow;
}
}
};
if ( $query->param( "change_hold_type_" . $reserve_id[$i] ) ) {
my $hold = Koha::Holds->find( $reserve_id[$i] );
try {
$hold->change_type;
} catch {
if ($_->isa('Koha::Exceptions::Hold::CannotChangeHoldType')){
warn $_;
} else {
$_->rethrow;
}
}
};
}
my @biblio_ids = uniq @biblionumber;
Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue(

View File

@ -579,6 +579,13 @@ if ( ( $findborrower && $borrowernumber_hold || $findclub && $club_hold )
$template->param( always_show_holds => $always_show_holds );
my $show_holds_now = $input->param('show_holds_now');
unless( (defined $always_show_holds && $always_show_holds eq 'DONT') && !$show_holds_now ){
my $holds_count_per_patron = { map { $_->{borrowernumber} => $_->{hold_count} }
@{ Koha::Holds->search( { biblionumber=> $biblionumber }, {
select => [ "borrowernumber", { count => { distinct => "reserve_id" } } ],
as => [ qw( borrowernumber hold_count ) ],
group_by => [ qw( borrowernumber ) ] }
)->unblessed
} };
my @reserves = Koha::Holds->search( { biblionumber => $biblionumber }, { order_by => 'priority' } )->as_list;
foreach my $res (
sort {
@ -630,6 +637,10 @@ if ( ( $findborrower && $borrowernumber_hold || $findclub && $club_hold )
$reserve{non_priority} = $res->non_priority();
$reserve{object} = $res;
if ( $holds_count_per_patron->{ $reserve{'borrowernumber'} } == 1 ) {
$reserve{'change_hold_type_allowed'} = 1;
}
push( @reserveloop, \%reserve );
}
}