From 117dcf4c0134f672eeb46faa4f9033c407d2096e Mon Sep 17 00:00:00 2001 From: Agustin Moyano Date: Sat, 4 May 2019 04:03:20 -0300 Subject: [PATCH] Bug 18928: Add Branches.HasCirculationRules and set branchcode in CirculationRules.Search This patch tackles two issues: 1) Defaults row always says (not set) because "default_rules" param was deleted from smart-rules.pl. 2) When setting standard hold rules for all libraries, hold policy, pickup and return always says 'Not Set' even if you defined values. This is because "current_branch" variable was used in CirculationRules.Search, and current_branch value for default is "*". Solutions: 1) Add Koha::Template::Plugin::Branches->HasCirculationRules method that returns 1 if defined branch has circulation rules. 2) Switch "current_branch" for "branchcode" whose value is undef for default rules. To test: 1) Apply previous patches 2) set default values for all libraries CHECK => hold policy, pickup and return remains in 'Not set' 3) select a library 4) set values for that library CHECK => first column always says "Defaults (not set)" 5) Apply this patch SUCCESS => Hold, pickup and return default values for all libraries are now shown => First column of default rules, and of the library selected in step 3 only says "Defaults" 6) Sign off --- Koha/Template/Plugin/Branches.pm | 13 +++++++++++++ .../intranet-tmpl/prog/en/modules/admin/smart-rules.tt | 10 ++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Koha/Template/Plugin/Branches.pm b/Koha/Template/Plugin/Branches.pm index da615f5673..23c98441bf 100644 --- a/Koha/Template/Plugin/Branches.pm +++ b/Koha/Template/Plugin/Branches.pm @@ -105,4 +105,17 @@ sub pickup_locations { return $libraries; } +sub HasCirculationRules { + my ( $self, $branchcode) = @_; + + $branchcode = undef if $branchcode eq q{}; + + my @rules = Koha::CirculationRules->search( + { + branchcode => $branchcode + } + ); + + return scalar(@rules) > 1; +} 1; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt index fac20ae7fd..1a32c1b8cf 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt @@ -397,6 +397,7 @@
+ @@ -409,6 +410,7 @@ + [% SET default_rules = Branches.HasCirculationRules( branchcode ) %]
 Actions
Defaults[% UNLESS ( default_rules ) %] (not set)[% END %] [% SET patron_maxissueqty = CirculationRules.Get( branchcode, undef, undef, 'patron_maxissueqty' ) %] @@ -419,12 +421,12 @@ - [% SET rule_value = CirculationRules.Get( current_branch, '*', undef, 'max_holds' ) %] + [% SET rule_value = CirculationRules.Get( branchcode, '*', undef, 'max_holds' ) %]