From 68061e7df7d4614f3e15c05cfc9e34e86d1c8b43 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 29 Oct 2025 15:22:24 +0000 Subject: [PATCH] Bug 41131: Don't allow limiting transfers from/to a single branch We say that you cannot limit transfers internally within a branch, but it seems we do allow you to, and don't show you when we do To test: 1 - Go to Admin->Library transfer limits 2 - On a branches page, uncheck the box for that branch e.g. don't allow FIC to transfer to CPL from CPL 3 - Save 4 - Note the box is still checked 5 - Check the DB SELECT * FROM branch_transfer_limits; 6 - There is a line to/from CPL! 7 - Apply patches 8 - updatedatabase 9 - Repeat 5 - the line is deleted! 10 - Try to create the rule again, not the box is now disabled 11 - Be sneaky, enable the box, uncheck it and save, no rule created 12 - Be sneaky, edit the HMTL for another button to make it limiting CPL to CPL, save, no rule created 13 - Sign off --- admin/branch_transfer_limits.pl | 1 + .../data/mysql/atomicupdate/bug_41131.pl | 19 +++++++++++++++++++ .../modules/admin/branch_transfer_limits.tt | 4 +++- 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100755 installer/data/mysql/atomicupdate/bug_41131.pl diff --git a/admin/branch_transfer_limits.pl b/admin/branch_transfer_limits.pl index e9ea5211169..1b09a08d0b4 100755 --- a/admin/branch_transfer_limits.pl +++ b/admin/branch_transfer_limits.pl @@ -65,6 +65,7 @@ if ( $input->param('updateLimits') && $op eq 'cud-update' ) { foreach my $code (@codes) { foreach my $toBranch (@branchcodes) { + next if $toBranch eq $branchcode; my $isSet = not $input->param( $code . "_" . $toBranch ); if ($isSet) { CreateBranchTransferLimit( $toBranch, $branchcode, $code ); diff --git a/installer/data/mysql/atomicupdate/bug_41131.pl b/installer/data/mysql/atomicupdate/bug_41131.pl new file mode 100755 index 00000000000..6178d45157a --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_41131.pl @@ -0,0 +1,19 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_success say_info); + +return { + bug_number => "41131", + description => "Delete transfer limits that are from a branch to the same branch", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + # Do you stuffs here + $dbh->do( + q{ + DELETE FROM branch_transfer_limits WHERE toBranch = fromBranch; + } + ); + say $out "Removed nonsensical transfer limits that prevent a branch transferring to itself"; + }, +}; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branch_transfer_limits.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branch_transfer_limits.tt index 00787368b8a..1996502301b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branch_transfer_limits.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branch_transfer_limits.tt @@ -96,7 +96,9 @@ > - [% IF ( to_branch_loo.isChecked ) %] + [% IF ( to_branch_loo.toBranch == branchcode ) %] + + [% ELSIF ( to_branch_loo.isChecked ) %]