Bugzilla – Attachment 181223 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: Add new move_hold_item subroutine to Hold.pm
Bug-31698-Add-new-moveholditem-subroutine-to-Holdp.patch (text/plain), 4.52 KB, created by
Lucas Gass (lukeg)
on 2025-04-21 18:19:44 UTC
(
hide
)
Description:
Bug 31698: Add new move_hold_item subroutine to Hold.pm
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2025-04-21 18:19:44 UTC
Size:
4.52 KB
patch
obsolete
>From 464b09682dff17a19245eebee18402f2a3a8c8c0 Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Wed, 12 Mar 2025 21:31:35 +0000 >Subject: [PATCH] Bug 31698: Add new move_hold_item subroutine to Hold.pm > >--- > Koha/Hold.pm | 41 +++++++++++++++++++++++++++++++++++++++ > reserve/request.pl | 48 ++++++++++++++++++++++++++++++++++++++++++++-- > 2 files changed, 87 insertions(+), 2 deletions(-) > >diff --git a/Koha/Hold.pm b/Koha/Hold.pm >index b3bf4a02b76..2368e0b53e4 100644 >--- a/Koha/Hold.pm >+++ b/Koha/Hold.pm >@@ -178,6 +178,47 @@ sub delete { > return $deleted; > } > >+=head3 move_hold_item >+ >+$hold->move_hold_item(); >+ >+=cut >+ >+sub move_hold_item { >+ my ( $self, $args ) = @_; >+ >+ 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) { >+ >+ #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; >+} >+ > =head3 set_transfer > > =cut >diff --git a/reserve/request.pl b/reserve/request.pl >index c5e354aa7d2..60768041ad0 100755 >--- a/reserve/request.pl >+++ b/reserve/request.pl >@@ -44,6 +44,7 @@ use C4::Search qw( enabled_staff_search_views ); > use Koha::Biblios; > use Koha::Checkouts; > use Koha::Holds; >+use Koha::Hold; > use Koha::CirculationRules; > use Koha::Items; > use Koha::ItemTypes; >@@ -90,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{}; > >@@ -109,6 +111,50 @@ if ( $op eq 'cud-move' ) { > $next_priority, $first_priority, $last_priority > ); > } >+} 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); >+ 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"); >@@ -172,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