Bug 22847: Correctly displayed circ rule values for max_holds and maxissue*
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 3 May 2019 21:34:22 +0000 (17:34 -0400)
committerNick Clemens <nick@bywatersolutions.com>
Thu, 9 May 2019 14:32:27 +0000 (14:32 +0000)
There are several things going wrong on the circulation rules screen. The global rule is displayed for specific libraries (even if the rule does not exist for the library), and max_holds is always blank.

I have trouble finding the root of the issue, but I will propose a patch to fix both problem.

Certainly a mismatch between bug 18887 and bug 18925.

Test plan:
0. Do not apply the patch
1. Notice the issue on the circulation rules screen
2. Apply the patch
3. Confirm that the value you set are correctly displayed (and not the propagated ones!)

Signed-off-by: Liz Rea <wizzyrea@gmail.com>
Signed-off-by: Agustin Moyano <agustinmoyano@theke.io>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Koha/Template/Plugin/CirculationRules.pm
koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt

index 004ba92..04587d4 100644 (file)
@@ -26,9 +26,9 @@ use Koha::CirculationRules;
 sub Get {
     my ( $self, $branchcode, $categorycode, $itemtype, $rule_name ) = @_;
 
-    $branchcode   = undef if $branchcode eq q{};
-    $categorycode = undef if $categorycode eq q{};
-    $itemtype     = undef if $itemtype eq q{};
+    $branchcode   = undef if $branchcode eq q{}   or $branchcode eq q{*};
+    $categorycode = undef if $categorycode eq q{} or $branchcode eq q{*};
+    $itemtype     = undef if $itemtype eq q{}     or $branchcode eq q{*};
 
     my $rule = Koha::CirculationRules->get_effective_rule(
         {
@@ -45,9 +45,9 @@ sub Get {
 sub Search {
     my ( $self, $branchcode, $categorycode, $itemtype, $rule_name ) = @_;
 
-    $branchcode   = undef if $branchcode eq q{};
-    $categorycode = undef if $categorycode eq q{};
-    $itemtype     = undef if $itemtype eq q{};
+    $branchcode   = undef if $branchcode eq q{}   or $branchcode eq q{*};
+    $categorycode = undef if $categorycode eq q{} or $branchcode eq q{*};
+    $itemtype     = undef if $itemtype eq q{}     or $branchcode eq q{*};
 
     my $rule = Koha::CirculationRules->search(
         {
index bca8b25..0f26380 100644 (file)
                 <tr>
                     <td><em>Defaults[% UNLESS ( default_rules ) %] (not set)[% END %]</em></td>
                     <td>
-                        [% SET patron_maxissueqty = CirculationRules.Get( branchcode, undef, undef, 'patron_maxissueqty' ) %]
+                        [% SET patron_maxissueqty = CirculationRules.Search( current_branch, undef, undef, 'patron_maxissueqty' ) %]
                         <input type="text" name="patron_maxissueqty" size="3" value="[% patron_maxissueqty | html %]"/>
                     </td>
                     <td>
-                        [% SET patron_maxonsiteissueqty = CirculationRules.Get( branchcode, undef, undef, 'patron_maxonsiteissueqty' ) %]
+                        [% SET patron_maxonsiteissueqty = CirculationRules.Search( current_branch, undef, undef, 'patron_maxonsiteissueqty' ) %]
                         <input type="text" name="patron_maxonsiteissueqty" size="3" value="[% patron_maxonsiteissueqty | html %]"/>
                     </td>
                     <td>
-                        [% SET rule_value = CirculationRules.Get( current_branch, '*', undef, 'max_holds' ) %]
+                        [% SET rule_value = CirculationRules.Search( current_branch, undef , undef, 'max_holds' ) %]
                         <input name="max_holds" size="3" value="[% rule_value | html %]" />
                     </td>
                     <td>