From c99d3c18a4463802c6759ed097405b67d556d4b3 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 8 May 2020 12:14:07 +0200 Subject: [PATCH] Bug 25400: [< 20.05] Fix cloning of circulation rules This patch is for 19.11 and anterior versions. The clone functionnality does not clone the "already moved rules" maxissueqty and maxonsiteissueqty. Test plan: Clone some circ rules from one branch to another Confirm that all the rules have been copied correctly --- admin/clone-rules.pl | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/admin/clone-rules.pl b/admin/clone-rules.pl index dd071252d9..ddb311396d 100755 --- a/admin/clone-rules.pl +++ b/admin/clone-rules.pl @@ -32,6 +32,7 @@ use C4::Output; use C4::Auth; use C4::Koha; use C4::Debug; +use Koha::CirculationRules; my $input = new CGI; my $dbh = C4::Context->dbh; @@ -91,6 +92,16 @@ if ($frombranch && $tobranch) { $sth = $dbh->prepare($query); $res = $sth->execute(); + # For already moved rules, maxissueqty and maxonsiteissueqty + Koha::CirculationRules->search({branchcode => $tobranch})->delete; + my $rules = Koha::CirculationRules->search({ branchcode => $frombranch }); + while ( my $rule = $rules->next ) { + my $cloned_rule = $rule->unblessed; + $cloned_rule->{branchcode} = $tobranch; + delete $cloned_rule->{id}; + Koha::CirculationRule->new( $cloned_rule )->store; + } + $template->param(result => "1"); $template->param(error => $error); } -- 2.20.1