Bugzilla – Attachment 181226 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 missing filters
Bug-31698-Add-missing-filters.patch (text/plain), 6.37 KB, created by
Lucas Gass (lukeg)
on 2025-04-21 18:19:55 UTC
(
hide
)
Description:
Bug 31698: Add missing filters
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2025-04-21 18:19:55 UTC
Size:
6.37 KB
patch
obsolete
>From eb2976a53013ddc71c42585450818084730dd40b Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Tue, 25 Mar 2025 20:14:00 +0000 >Subject: [PATCH] Bug 31698: Add missing filters > >--- > Koha/Hold.pm | 16 ++++++------- > .../prog/en/includes/holds_table.inc | 2 +- > .../prog/en/modules/reserve/request.tt | 4 ++-- > reserve/request.pl | 23 ++++++++++++++----- > 4 files changed, 28 insertions(+), 17 deletions(-) > >diff --git a/Koha/Hold.pm b/Koha/Hold.pm >index 36336dad812..392cda0e234 100644 >--- a/Koha/Hold.pm >+++ b/Koha/Hold.pm >@@ -187,8 +187,9 @@ $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 $original = $self; > my $original_biblionumber = $self->biblionumber; > >@@ -202,20 +203,19 @@ sub move_hold_item { > C4::Reserves::CanItemBeReserved( $patron, $new_item, $self->branchcode, { ignore_hold_counts => 1 } ); > > if ( $canReserve->{status} eq 'OK' ) { >- >- # Find the lowest priority among holds on the new item >- my $highest_new_priority = Koha::Holds->search( >+ my $max = 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 $base_priority = $max ? $max->priority : 0; >+ my $priority = $base_priority + 1; >+ 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/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc >index d031f55dc2e..0d26304999e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc >@@ -56,7 +56,7 @@ > data-id="[% hold.reserve_id | html %]" > data-item_level_hold="[% hold.item_level_hold | html %]" > data-itemnumber="[% hold.itemnumber | html %]" >- data-biblionumber="[% hold.biblionumber %]" >+ data-biblionumber="[% hold.biblionumber | html %]" > /></td> > <td> > <input type="hidden" name="reserve_id" value="[% hold.reserve_id | html %]" /> >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 afc5d935288..697f7c02e72 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >@@ -181,7 +181,7 @@ > [% FOREACH hold IN hold_move_successes %] > <li> > <label>Hold ID: </label> >- <span>[% hold.hold_id %]</span> >+ <span>[% hold.hold_id | html %]</span> > <span> - Moved from [%- INCLUDE 'biblio-title.inc' biblio=hold.original_biblio link = 1 -%] to [%- INCLUDE 'biblio-title.inc' biblio=hold.target_biblio link = 1 -%]</span> > </li> > [% END %] >@@ -195,7 +195,7 @@ > [% FOREACH fail IN hold_move_failures %] > <li> > <label>Hold ID: </label> >- <span>[% fail.hold_id %]</span> >+ <span>[% fail.hold_id | html %]</span> > [% SWITCH fail.error %] > [% CASE 'cannotReserveFromOtherBranches' %] > <span>Target item cannot be reserved from other branches</span> >diff --git a/reserve/request.pl b/reserve/request.pl >index 60768041ad0..e3d3282608b 100755 >--- a/reserve/request.pl >+++ b/reserve/request.pl >@@ -120,10 +120,20 @@ 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; >+ >+ #need to get the biblionumber of the original hold >+ my $original_biblionumber = $moving_holds[0]->biblionumber; >+ >+ my $offset = 0; >+ foreach my $hold (@moving_holds) { > my $original_biblio = Koha::Biblios->find( $hold->biblionumber ); >- my $result = $hold->move_hold_item( >+ >+ my $result = $hold->move_hold_item( > { > new_itemnumber => $new_itemnumber, > new_biblionumber => $new_biblionumber, >@@ -133,14 +143,14 @@ if ( $op eq 'cud-move' ) { > #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, >@@ -149,7 +159,8 @@ if ( $op eq 'cud-move' ) { > } > } > >- push @biblionumbers, $new_biblionumber; >+ C4::Reserves::_FixPriority( { biblionumber => $original_biblionumber } ); >+ push @biblionumbers, $original_biblionumber; > > $template->param( > hold_move_successes => \@success_messages, >-- >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