From 32475570c4b98ba5d0fd0e51634013eb4ffdf835 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 3 Jun 2022 13:14:06 -0400 Subject: [PATCH] Bug 30901: Add Renewals method to CirculationRules template plugin It would be useful to be able to report renewals used/remaining in some notices and slips. Test Plan: 1) Apply this patch 2) Add the following to the RENEWAL notices: -- [% USE CirculationRules %] [% SET renewals = CirculationRules.Renewals( borrower.id, item.id ) %] You have used [% renewals.count %] of [% renewals.allowed %], you have [% renewals.remaining %] renewals left. -- 3) Trigger a renewal notice 4) Verify the text is correct! Signed-off-by: Lucas Gass Signed-off-by: Fridolin Somers Signed-off-by: Tomas Cohen Arazi --- Koha/Template/Plugin/CirculationRules.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Koha/Template/Plugin/CirculationRules.pm b/Koha/Template/Plugin/CirculationRules.pm index 7956bc8d80..0d6f40bb8b 100644 --- a/Koha/Template/Plugin/CirculationRules.pm +++ b/Koha/Template/Plugin/CirculationRules.pm @@ -22,6 +22,7 @@ use Modern::Perl; use base qw( Template::Plugin ); use Koha::CirculationRules; +use C4::Circulation qw( GetRenewCount ); sub Get { my ( $self, $branchcode, $categorycode, $itemtype, $rule_name ) = @_; @@ -62,4 +63,19 @@ sub Search { return $rule->rule_value if $rule; } +sub Renewals { + my ( $self, $borrowernumber, $itemnumber ) = @_; + + my ( $count, $allowed, $remaining, $unseen_count, $unseen_allowed, $unseen_remaining ) = GetRenewCount( $borrowernumber, $itemnumber ); + + return { + count => $count, + allowed => $allowed, + remaining => $remaining, + unseen_count => $unseen_count, + unseen_allowed => $unseen_allowed, + unseen_remaining => $unseen_remaining, + }; +} + 1; -- 2.39.5