Bugzilla – Attachment 193667 Details for
Bug 41882
Batch hold modification tool updates pickup locations to disallowed libraries
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 41882: Enforce pickup location rules
Bug-41882-Enforce-pickup-location-rules.patch (text/plain), 8.06 KB, created by
Lucas Gass (lukeg)
on 2026-02-23 23:16:57 UTC
(
hide
)
Description:
Bug 41882: Enforce pickup location rules
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2026-02-23 23:16:57 UTC
Size:
8.06 KB
patch
obsolete
>From 9c4ecbc38fce613575bafc96aeff33a0039bbb1a Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Mon, 23 Feb 2026 23:16:20 +0000 >Subject: [PATCH] Bug 41882: Enforce pickup location rules > >--- > .../en/modules/tools/batch_modify_holds.tt | 62 +++++++++++++++++++ > tools/batch_modify_holds.pl | 42 ++++++++++++- > 2 files changed, 102 insertions(+), 2 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_modify_holds.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_modify_holds.tt >index de32ade2238..7b57c36502c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_modify_holds.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_modify_holds.tt >@@ -106,6 +106,7 @@ > <h1>Modified holds</h1> > <div id="modified_holds_results-wrapper"> > <div id="modified_holds_results" class="page-section"> >+ <h2>Holds updated</h2> > <table id="modified_holds"> > <thead> > <tr> >@@ -154,6 +155,61 @@ > </tbody> > </table> > </div> >+ [% IF failed_holds_obj.size %] >+ <div id="failed_holds_results" class="page-section"> >+ <h2>Holds not updated</h2> >+ <table id="failed_holds"> >+ <thead> >+ <tr> >+ <th>Title</th> >+ <th>Patron</th> >+ <th>Pickup location</th> >+ <th>Priority</th> >+ <th>Expiration date</th> >+ <th>Status</th> >+ <th>Suspended</th> >+ <th>Suspended until</th> >+ <th>Notes</th> >+ </tr> >+ </thead> >+ <tbody> >+ [% FOREACH failure IN failed_holds_obj %] >+ [% SET hold = failure.hold %] >+ <tr> >+ <td> >+ [% INCLUDE 'biblio-title.inc' biblio=hold.biblio link = 1 %] >+ <div class="alert alert-warning">[% failure.reason %]</div> >+ </td> >+ <td>[% INCLUDE 'patron-title.inc' invert_name=1 patron=hold.borrower hide_patron_infos_if_needed=1 link_to="circulation_reserves" %]</td> >+ <td>[% hold.branch.branchname | html %]</td> >+ <td>[% hold.priority | html %]</td> >+ <td>[% hold.expirationdate | $KohaDates %]</td> >+ <td> >+ [% IF hold.found == 'F' %] >+ <span>Fulfilled</span> >+ [% ELSIF hold.cancellationdate %] >+ <span>Cancelled</span> >+ [% ELSIF hold.found == 'W' %] >+ [% IF hold.cancellation_requests.count == 0 %] >+ <span>Waiting</span> >+ [% ELSE %] >+ <span>Cancelled</span> >+ [% END %] >+ [% ELSIF hold.found == 'T' %] >+ <span>In transit</span> >+ [% ELSE %] >+ <span>Pending</span> >+ [% END %] >+ </td> >+ <td>[% IF hold.suspend %]Yes[% ELSE %]No[% END %]</td> >+ <td>[% IF hold.suspend_until %][% hold.suspend_until | $KohaDates %][% ELSE %]-[% END %]</td> >+ <td>[% hold.reservenotes | html %]</td> >+ </tr> >+ [% END %] >+ </tbody> >+ </table> >+ </div> >+ [% END %] > <!-- /#modified_holds_results --> > <fieldset class="action"> > <a href="/cgi-bin/koha/tools/batch_modify_holds.pl">Return to batch hold modification</a> >@@ -648,6 +704,12 @@ > pagingType: "full", > autoWidth: false > }, table_settings); >+ [% IF failed_holds_obj.size %] >+ $("#failed_holds").kohaTable({ >+ pagingType: "full", >+ autoWidth: false >+ }, table_settings); >+ [% END %] > > }); > </script> >diff --git a/tools/batch_modify_holds.pl b/tools/batch_modify_holds.pl >index 4ba25f9cf40..f9e70ee8ded 100755 >--- a/tools/batch_modify_holds.pl >+++ b/tools/batch_modify_holds.pl >@@ -28,6 +28,9 @@ use C4::Output qw( output_html_with_http_headers ); > > use Koha::DateUtils qw( dt_from_string ); > use Koha::Holds; >+use Koha::Libraries; >+use Koha::Policy::Holds; >+use C4::Circulation qw( GetBranchItemRule ); > > my $input = CGI->new; > my $op = $input->param('op') // q|cud-form|; >@@ -59,7 +62,8 @@ if ( $op eq 'cud-form' ) { > my $clear_hold_notes = $input->param('clear_hold_notes'); > > @hold_ids = $input->multi_param('hold_id'); >- my @holds_data = (); >+ my @holds_data = (); >+ my @failed_holds = (); > > my $holds_to_update = > Koha::Holds->search( { reserve_id => { -in => \@hold_ids } }, { join => [ "item", "biblio" ] } ); >@@ -71,7 +75,39 @@ if ( $op eq 'cud-form' ) { > } > > if ( $new_pickup_loc && ( $hold->branchcode ne $new_pickup_loc ) ) { >- $hold->branchcode($new_pickup_loc)->store; >+ >+ #check if the new pickup location is allowed >+ my $pickup_allowed = 1; >+ my $item = $hold->item; >+ my $patron = $hold->patron; >+ my $branch = Koha::Policy::Holds->holds_control_library( $item, $patron ); >+ my $branchitemrule = GetBranchItemRule( $branch, $item->effective_itemtype ); >+ my $hold_fulfillment_policy = $branchitemrule->{hold_fulfillment_policy}; >+ my $item_library = Koha::Libraries->find( { branchcode => $item->homebranch } ); >+ my $reason; >+ >+ if ( $hold_fulfillment_policy eq 'holdgroup' >+ && !$item_library->validate_hold_sibling( { branchcode => $new_pickup_loc } ) ) >+ { >+ $pickup_allowed = 0; >+ $reason = "pickupNotInHoldGroup"; >+ } elsif ( ( $hold_fulfillment_policy eq 'homebranch' || $hold_fulfillment_policy eq 'holdingbranch' ) >+ && $new_pickup_loc ne $item->$hold_fulfillment_policy ) >+ { >+ $pickup_allowed = 0; >+ $reason = $hold_fulfillment_policy eq 'homebranch' ? 'pickupNotHomeLibrary' : 'pickupNotHoldingLibrary'; >+ >+ } elsif ( !$item->can_be_transferred( { to => Koha::Libraries->find($new_pickup_loc) } ) ) { >+ $pickup_allowed = 0; >+ $reason = 'cannotBeTransferred'; >+ } >+ >+ if ($pickup_allowed) { >+ $hold->branchcode($new_pickup_loc)->store; >+ } else { >+ push @failed_holds, { hold => $hold, reason => $reason }; >+ next; >+ } > } > > if ( $new_suspend_status ne "" ) { >@@ -104,7 +140,9 @@ if ( $op eq 'cud-form' ) { > $template->param( > updated_holds => to_json( \@hold_ids ), > updated_holds_obj => \@holds_data, >+ failed_holds_obj => \@failed_holds, > total_updated => scalar @holds_data, >+ total_failed => scalar @failed_holds, > view => 'report', > ); > >-- >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 41882
:
193667
|
193818
|
194175