Bugzilla – Attachment 179711 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: Use _ShiftPriority to deal with priority
Bug-31698-Use-ShiftPriority-to-deal-with-priority.patch (text/plain), 4.00 KB, created by
Lucas Gass (lukeg)
on 2025-03-25 22:55:54 UTC
(
hide
)
Description:
Bug 31698: Use _ShiftPriority to deal with priority
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2025-03-25 22:55:54 UTC
Size:
4.00 KB
patch
obsolete
>From d407d1d8873549a9e8b13375c4995ab1bbed8f99 Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Tue, 25 Mar 2025 22:53:59 +0000 >Subject: [PATCH] Bug 31698: Use _ShiftPriority to deal with priority > >--- > Koha/Hold.pm | 16 ++++++---------- > reserve/request.pl | 29 ++++++++++++++++++++++++----- > 2 files changed, 30 insertions(+), 15 deletions(-) > >diff --git a/Koha/Hold.pm b/Koha/Hold.pm >index 36336dad812..89869382b05 100644 >--- a/Koha/Hold.pm >+++ b/Koha/Hold.pm >@@ -187,8 +187,10 @@ $hold->move_hold_item(); > sub move_hold_item { > my ( $self, $args ) = @_; > >- my $new_itemnumber = $args->{new_itemnumber}; >- my $new_biblionumber = $args->{new_biblionumber}; >+ my $new_itemnumber = $args->{new_itemnumber}; >+ my $new_biblionumber = $args->{new_biblionumber}; >+ my $priority = $args->{priority}; >+ > my $original = $self; > my $original_biblionumber = $self->biblionumber; > >@@ -203,19 +205,13 @@ sub move_hold_item { > > if ( $canReserve->{status} eq 'OK' ) { > >- # Find the lowest priority among holds on the new item >- my $highest_new_priority = Koha::Holds->search( >- { biblionumber => $new_biblionumber }, >- { order_by => { -desc => 'priority' }, rows => 1 } >- )->next; >- my $next_available_priority = >- $highest_new_priority ? $highest_new_priority->priority + 1 : 1; # Always start at 1 if empty >+ my $new_priority = C4::Reserves::_ShiftPriority( $new_biblionumber, $priority ); > > $self->update( > { > itemnumber => $new_item->itemnumber, > biblionumber => $new_item->biblionumber, >- priority => $next_available_priority, >+ priority => $new_priority, > } > ); > >diff --git a/reserve/request.pl b/reserve/request.pl >index 60768041ad0..83134b0e304 100755 >--- a/reserve/request.pl >+++ b/reserve/request.pl >@@ -120,27 +120,46 @@ if ( $op eq 'cud-move' ) { > my @success_messages; > my @error_messages; > >- foreach my $hold_id (@hold_ids) { >- my $hold = Koha::Holds->find($hold_id); >+ #Get a list of all the holds to move, ordered by current priority >+ my @moving_holds = Koha::Holds->search( >+ { reserve_id => \@hold_ids }, >+ { order_by => { -asc => 'priority' } } >+ )->as_list; >+ >+ #Get the highest current priority of the target biblio >+ my $highest_priority = Koha::Holds->search( >+ { biblionumber => $new_biblionumber }, >+ { order_by => { -desc => 'priority' }, rows => 1 } >+ )->next; >+ >+ #Get a starting priority point to increment from on the new biblio >+ my $base_priority = $highest_priority ? $highest_priority->priority : 0; >+ >+ my $offset = 0; >+ foreach my $hold (@moving_holds) { > my $original_biblio = Koha::Biblios->find( $hold->biblionumber ); >- my $result = $hold->move_hold_item( >+ >+ #increment priority >+ my $priority = ( $base_priority + $offset++ ) + 1; >+ my $result = $hold->move_hold_item( > { > new_itemnumber => $new_itemnumber, > new_biblionumber => $new_biblionumber, >+ priority => $priority > } > ); > > #push info about successes and errors to the template > if ( $result->{success} ) { > push @success_messages, { >- hold_id => $hold_id, >+ hold_id => $hold->id, > success => 1, > original_biblio => $original_biblio, > target_biblio => $target_biblio, > }; > } else { > push @error_messages, { >- hold_id => $hold_id, >+ hold_id => $hold->id, > success => 0, > original_biblio => $original_biblio, > target_biblio => $target_biblio, >-- >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