From 2b2b0adfad211d0e2f7f4022056d20bb14f1d6e3 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 6 Aug 2025 17:46:55 +0000 Subject: [PATCH] Bug 36506: Add lost_item_processing_fee rule and CRUD Sponsored-by: The Main Library Alliance --- Koha/CirculationRules.pm | 4 + admin/smart-rules.pl | 24 ++ .../prog/en/modules/admin/smart-rules.tt | 349 +++++++++++------- 3 files changed, 240 insertions(+), 137 deletions(-) diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm index b0b2bd00c2b..f9202ffd873 100644 --- a/Koha/CirculationRules.pm +++ b/Koha/CirculationRules.pm @@ -56,6 +56,10 @@ our $RULE_KINDS = { processingreturn => { scope => ['branchcode'], }, + lost_item_processing_fee => { + scope => [ 'branchcode', 'itemtype' ], + can_be_blank => 0, + }, patron_maxissueqty => { scope => [ 'branchcode', 'categorycode' ], }, diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl index 7f5448f511c..2a386173f6c 100755 --- a/admin/smart-rules.pl +++ b/admin/smart-rules.pl @@ -264,6 +264,17 @@ if ( $op eq 'cud-delete' ) { } ); } +} elsif ( $op eq 'cud-delete-lost-item-processing-fee' ) { + my $itemtype = $input->param('itemtype'); + Koha::CirculationRules->set_rules( + { + branchcode => $branch eq '*' ? undef : $branch, + itemtype => $itemtype, + rules => { + lost_item_processing_fee => undef, + } + } + ); } # save the values entered @@ -720,6 +731,19 @@ elsif ( $op eq 'cud-add' ) { } ); } +} elsif ( $op eq 'cud-mod-lost-item-fee-rule' ) { + + my $lost_item_processing_fee_itemtype = $input->param('lost_item_processing_fee_itemtype'); + my $lost_item_processing_fee = $input->param('lost_item_processing_fee'); + + Koha::CirculationRules->set_rules( + { + branchcode => $branch, + itemtype => $lost_item_processing_fee_itemtype, + rules => { lost_item_processing_fee => $lost_item_processing_fee } + } + ) unless $lost_item_processing_fee eq ''; + } elsif ( $op eq "cud-set-waiting-hold-cancellation" ) { my $category = $input->param('waiting_hold_cancellation_category'); 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 49301081770..37753a2f893 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 @@ -1098,182 +1098,240 @@ [% END %] -
- [% IF current_branch == '*' %] -

Default lost item fee refund on return policy

- [% ELSE %] -

Lost item fee refund on return policy for [% Branches.GetName(current_branch) | html %]

- [% END %] -

Specify the default policy for lost item fees on return.

-
- [% INCLUDE 'csrf-token.inc' %] - - - - - - - - - - + + +
Refund lost item replacement feeRefund lost item processing fee 
- + + + + + + + + + - + - - -
Refund lost item replacement feeRefund lost item processing fee 
+ - - + + - - -
- + +
+ +
+ +
+
+ [% IF current_branch == '*' %] +

Default lost item fee policy

+ [% ELSE %] +

Lost item fee policy for [% Branches.GetName(current_branch) | html %]

+ [% END %] +

Specify the default policy for lost item fees.

+
+ [% INCLUDE 'csrf-token.inc' %] + + + + + + + + + [% SET c = undef %] + [% FOREACH i IN itemtypes %] + [% SET lost_item_processing_fee = all_rules.$c.$i.lost_item_processing_fee %] + + [% IF ( lost_item_processing_fee.defined && lost_item_processing_fee != '' ) %] + + + + + + [% END %] + [% END %] + + + + + +
Item typeLost item processing fee 
+ [% IF i == undef %] + All + [% ELSE %] + [% ItemTypes.GetDescription(i,1) | html %] + [% END %] + [% lost_item_processing_fee | $Price %] + Delete +
+ +
+
+
@@ -1458,6 +1516,11 @@ autoWidth: false, }); }); + $("#lost_item_processing_fee_form").validate({ + rules: { + lost_item_processing_fee: { required: true, number: true }, + }, + }); function clear_edit() { var cancel = confirm(_("Are you sure you want to cancel your changes?")); @@ -1665,6 +1728,18 @@ return f.submit(); }); + $(".delete-lost-item-processing-fee").on("click", function (e) { + e.preventDefault(); + if (!confirmDelete(MSG_CONFIRM_DELETE)) { + return false; + } + let f = $("#delete_form"); + f.find("[name='op']").val("cud-delete-lost-item-processing-fee"); + f.find("[name='itemtype']").val($(this).data("itemtype")); + f.find("[name='branch']").val($(this).data("branch")); + return f.submit(); + }); + $(".del-waiting-hold-cancellation").on("click", function (e) { e.preventDefault(); if (!confirmDelete(MSG_CONFIRM_DELETE)) { -- 2.39.5