From eda39aaa2fc061217a7d3958c33c0a46856912ee Mon Sep 17 00:00:00 2001 From: Raphael Straub Date: Thu, 3 Apr 2025 09:55:02 +0000 Subject: [PATCH] Bug 39540: Add a warning to the circulation rules page if CalcFine is overwritten. This patch adds a warning to the "Circulation and fine rules" page in "Koha administration" if there is an enabled plugin that implements the overwrite_calc_fine plugin hook. To test: 1) Apply the patch. 2) In your browser go to /cgi-bin/koha/admin/smart-rules.pl and check that there is no warning on the top of the page. 3) Install a plugin that implements overwrite_calc_fine. 4) Reload /cgi-bin/koha/admin/smart-rules.pl and check that now there is a warning that displays the installed plugin's name. Sponsored-by: Karlsruhe Institute of Technology (KIT) --- admin/smart-rules.pl | 13 +++++++++++++ .../prog/en/modules/admin/smart-rules.tt | 10 ++++++++++ 2 files changed, 23 insertions(+) diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl index f0f358ccb1..2c1ed57a44 100755 --- a/admin/smart-rules.pl +++ b/admin/smart-rules.pl @@ -30,6 +30,7 @@ use Koha::CirculationRules; use Koha::Patron::Categories; use Koha::Caches; use Koha::Patrons; +use Koha::Plugins; my $input = CGI->new; my $dbh = C4::Context->dbh; @@ -791,6 +792,18 @@ while ( my $r = $all_rules->next ) { $rules->{ $r->{categorycode} // q{} }->{ $r->{itemtype} // q{} }->{ $r->{rule_name} } = $r->{rule_value}; } +if ( C4::Context->config("enable_plugins") ) { + $template->param( + overwrite_calc_fine_plugins => [ + Koha::Plugins->new->GetPlugins( + { + method => 'overwrite_calc_fine', + } + ) + ] + ); +} + $template->param( show_branch_cat_rule_form => 1 ); $template->param( 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 9ce8a43dbd..070b2e2835 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 @@ -50,6 +50,16 @@ [% END %] + [% IF overwrite_calc_fine_plugins.size %] +
+ The standard fine calculation is overwritten by the following plugin(s): + [% FOREACH plugin IN overwrite_calc_fine_plugins %] + [%- ", " | html IF !loop.first -%] + [%- plugin.get_metadata.name | html -%] + [%- END -%] +
+ [% END %] +

The rules are applied from most specific to less specific, using the first found in this order: