Bug 23445: (RM follow-up) Add warning for unexpected lengthunit
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Fri, 16 Aug 2019 11:17:42 +0000 (12:17 +0100)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Fri, 16 Aug 2019 11:19:34 +0000 (12:19 +0100)
Discussions on this bug highlighted worries about behind the scenes
fallbacks to 'days' as a lengthunit should the lengthunit be set to an
unrecognised value. This patch adds a warning to the about page for any
such occurrences so librarians may be made aware of and resolve the issue.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

about.pl
koha-tmpl/intranet-tmpl/prog/en/modules/about.tt

index dacd39d..4738c32 100755 (executable)
--- a/about.pl
+++ b/about.pl
@@ -444,6 +444,22 @@ $template->param( 'bad_yaml_prefs' => \@bad_yaml_prefs ) if @bad_yaml_prefs;
         );
     }
 }
+
+# Circ rule warnings
+{
+    my $dbh   = C4::Context->dbh;
+    my $units = $dbh->selectall_arrayref(
+        q|SELECT branchcode, categorycode, itemtype, lengthunit FROM issuingrules WHERE lengthunit NOT IN ( 'days', 'hours' ); |,
+        { Slice => {} }
+    );
+
+    if (@$units) {
+        $template->param(
+            warnIssuingRules => 1,
+            ir_units         => $units,
+        );
+    }
+}
 my %versions = C4::Context::get_versions();
 
 $template->param(
index 60ce4ac..e935a74 100644 (file)
             <br/>
         [% END %]
 
-        [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatron || warnPrefAnonymousPatron_PatronDoesNotExist || warnNoActiveCurrency || QueryParserError || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration || oauth2_missing_deps || bad_yaml_prefs %]
+        [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatron || warnPrefAnonymousPatron_PatronDoesNotExist || warnNoActiveCurrency || QueryParserError || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration || oauth2_missing_deps || bad_yaml_prefs || warnIssuingRules %]
             <h2>Warnings regarding the system configuration</h2>
             <table>
                 <caption>Preferences and parameters</caption>
             </table>
         [% END %]
 
+        [% IF warnIssuingRules %]
+            <table>
+                <caption>Issuing rules</caption>
+                [% FOREACH unit IN ir_units %]
+                <tr>
+                    <th scope="row"><b>Warning</b></th>
+                    <td>The [% unit.branchcode | html %], [% unit.categorycode | html %], [% unit.itemtype %] 
+                        issuingrule will fallback to 'days' for 'lengthunit' as it is incorrectly defined as 
+                        [% unit.lengthunit | html %]. 
+                    </td>
+                </tr>
+                [% END %]
+            </table>
+        [% END %]
+
     [% ELSE %]
         <p>No warnings.</p>
     [% END %]