Bugzilla – Attachment 179279 Details for
Bug 31698
Add ability to move a hold to a new bibliographic record/item
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31698: Make move_hold_item use CanItemBeReserved and add logging
Bug-31698-Make-moveholditem-use-CanItemBeReserved-.patch (text/plain), 4.40 KB, created by
Lucas Gass (lukeg)
on 2025-03-13 17:44:25 UTC
(
hide
)
Description:
Bug 31698: Make move_hold_item use CanItemBeReserved and add logging
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2025-03-13 17:44:25 UTC
Size:
4.40 KB
patch
obsolete
>From 4979c75d3901e93e0e637a6ae8702e5e1e6c48e3 Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Thu, 13 Mar 2025 17:38:10 +0000 >Subject: [PATCH] Bug 31698: Make move_hold_item use CanItemBeReserved and add > logging > >--- > Koha/Hold.pm | 31 ++++++++++++++++++++++++------- > reserve/request.pl | 37 +++++++++++++++++++++++++++++++++---- > 2 files changed, 57 insertions(+), 11 deletions(-) > >diff --git a/Koha/Hold.pm b/Koha/Hold.pm >index da4bf1767ee..2368e0b53e4 100644 >--- a/Koha/Hold.pm >+++ b/Koha/Hold.pm >@@ -189,15 +189,32 @@ sub move_hold_item { > > my $new_itemnumber = $args->{new_itemnumber}; > my $new_biblionumber = $args->{new_biblionumber}; >+ my $original = $self; >+ >+ my $patron = Koha::Patrons->find( { borrowernumber => $self->borrowernumber } ); >+ my $new_item = Koha::Items->find( { itemnumber => $new_itemnumber } ); > > if ($new_itemnumber) { >- my $new_item = Koha::Items->find( { itemnumber => $new_itemnumber } ); >- $self->update( >- { >- itemnumber => $new_item->itemnumber, >- biblionumber => $new_item->biblionumber >- } >- ); >+ >+ #check to see if moving this hold is allowed >+ my $canReserve = >+ C4::Reserves::CanItemBeReserved( $patron, $new_item, $self->branchcode, { ignore_hold_counts => 1 } ); >+ >+ if ( $canReserve->{status} eq 'OK' ) { >+ $self->update( >+ { >+ itemnumber => $new_item->itemnumber, >+ biblionumber => $new_item->biblionumber >+ } >+ ); >+ >+ C4::Log::logaction( 'HOLDS', 'MODIFY', $self->reserve_id, $self, undef, $original ) >+ if C4::Context->preference('HoldsLog'); >+ >+ return { success => 1, hold => $self }; >+ } else { >+ return { success => 0, error => $canReserve->{status} }; >+ } > } > return $self; > } >diff --git a/reserve/request.pl b/reserve/request.pl >index c56c2287b79..60768041ad0 100755 >--- a/reserve/request.pl >+++ b/reserve/request.pl >@@ -91,6 +91,7 @@ my $exceeded_maxreserves; > my $exceeded_holds_per_record; > my @failed_holds = $input->multi_param('failed_holds'); > my $form_submitted = $input->param('form_submitted'); >+my @biblionumbers = $input->multi_param('biblionumber'); > > my $op = $input->param('op') || q{}; > >@@ -113,17 +114,47 @@ if ( $op eq 'cud-move' ) { > } elsif ( $op eq 'cud-move_hold_item' ) { > my $new_itemnumber = $input->param('new_itemnumber'); > my $new_biblionumber = $input->param('new_biblionumber'); >+ my $target_biblio = Koha::Biblios->find($new_biblionumber); > my @hold_ids = $input->multi_param('hold_id'); >+ >+ my @success_messages; >+ my @error_messages; >+ > foreach my $hold_id (@hold_ids) { >- my $hold = Koha::Holds->find($hold_id); >- $hold->move_hold_item( >+ my $hold = Koha::Holds->find($hold_id); >+ my $original_biblio = Koha::Biblios->find( $hold->biblionumber ); >+ my $result = $hold->move_hold_item( > { > new_itemnumber => $new_itemnumber, > new_biblionumber => $new_biblionumber, > } > ); >+ >+ #push info about successes and errors to the template >+ if ( $result->{success} ) { >+ push @success_messages, { >+ hold_id => $hold_id, >+ success => 1, >+ original_biblio => $original_biblio, >+ target_biblio => $target_biblio, >+ }; >+ } else { >+ push @error_messages, { >+ hold_id => $hold_id, >+ success => 0, >+ original_biblio => $original_biblio, >+ target_biblio => $target_biblio, >+ error => $result->{error}, >+ }; >+ } > } > >+ push @biblionumbers, $new_biblionumber; >+ >+ $template->param( >+ hold_move_successes => \@success_messages, >+ hold_move_failures => \@error_messages, >+ ); > } elsif ( $op eq 'cud-cancel' ) { > my $reserve_id = $input->param('reserve_id'); > my $cancellation_reason = $input->param("cancellation-reason"); >@@ -187,8 +218,6 @@ if ($form_submitted) { > } > } > >-my @biblionumbers = $input->multi_param('biblionumber'); >- > my $multi_hold = @biblionumbers > 1; > $template->param( > multi_hold => $multi_hold, >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 31698
:
179226
|
179235
|
179236
|
179279
|
179287
|
179290
|
179291
|
179292
|
179295
|
179704
|
179711
|
179713
|
181222
|
181223
|
181224
|
181225
|
181226
|
181228
|
181229
|
181230
|
181231
|
181232
|
181233
|
181234
|
181929
|
181930
|
181944
|
181945
|
181946
|
181947
|
181948
|
181951
|
181952
|
181953
|
181954
|
181955
|
181956
|
181957
|
181958
|
181959
|
181960
|
181961
|
181962
|
182639
|
182640
|
182641