From 6ca88cb50e2135094b9dad51781a971f31613c9e 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 Signed-off-by: Bernardo Gonzalez Kriegel Tested on 19.11, no errors Signed-off-by: Joy Nelson (cherry picked from commit 359b9f2029a8171d673bbc84d21797283822b7e8) Signed-off-by: Lucas Gass --- admin/clone-rules.pl | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/admin/clone-rules.pl b/admin/clone-rules.pl index dd071252d9..814351a71a 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 eq '*' ? undef : $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.39.5