|
Lines 24-29
use base qw( Template::Plugin );
Link Here
|
| 24 |
use Koha::CirculationRules; |
24 |
use Koha::CirculationRules; |
| 25 |
use C4::Circulation qw( GetRenewCount ); |
25 |
use C4::Circulation qw( GetRenewCount ); |
| 26 |
|
26 |
|
|
|
27 |
=head1 NAME |
| 28 |
|
| 29 |
Koha::Template::Plugin::CirculationRules - A template plugin for dealing with things related to circulation |
| 30 |
|
| 31 |
|
| 32 |
=head2 Methods |
| 33 |
|
| 34 |
=head3 Get |
| 35 |
|
| 36 |
[% SET rule = CirculationRules.Get( branchcode, categorycode, itemtype, rule_name ) %] |
| 37 |
|
| 38 |
Returns the effective rule value for the given tuple. |
| 39 |
|
| 40 |
=cut |
| 41 |
|
| 27 |
sub Get { |
42 |
sub Get { |
| 28 |
my ( $self, $branchcode, $categorycode, $itemtype, $rule_name ) = @_; |
43 |
my ( $self, $branchcode, $categorycode, $itemtype, $rule_name ) = @_; |
| 29 |
|
44 |
|
|
Lines 43-48
sub Get {
Link Here
|
| 43 |
return $rule->rule_value if $rule; |
58 |
return $rule->rule_value if $rule; |
| 44 |
} |
59 |
} |
| 45 |
|
60 |
|
|
|
61 |
=head3 Search |
| 62 |
|
| 63 |
[% SET rule = CirculationRules.Search( branchcode, categorycode, itemtype, rule_name, { want_rule = 1 } ) %] |
| 64 |
|
| 65 |
Returns the first rule that matches the given critea. |
| 66 |
It does not perform precedence sorting as CirculationRules.Get would. |
| 67 |
|
| 68 |
By default, it returns only the rule value. Set want_rule to true to return |
| 69 |
the rule object. |
| 70 |
|
| 71 |
=cut |
| 72 |
|
| 46 |
sub Search { |
73 |
sub Search { |
| 47 |
my ( $self, $branchcode, $categorycode, $itemtype, $rule_name, $params) = @_; |
74 |
my ( $self, $branchcode, $categorycode, $itemtype, $rule_name, $params) = @_; |
| 48 |
|
75 |
|
|
Lines 63-68
sub Search {
Link Here
|
| 63 |
return $rule->rule_value if $rule; |
90 |
return $rule->rule_value if $rule; |
| 64 |
} |
91 |
} |
| 65 |
|
92 |
|
|
|
93 |
=head3 Renewals |
| 94 |
|
| 95 |
[% SET renewals = CirculationRules.Renewals( borrowernumber, itemnumber ) %] |
| 96 |
[% renewals.remaining | html %] |
| 97 |
|
| 98 |
Returns a hash of data about renewals for a checkout, by the given borrowernumber and itemnumber. |
| 99 |
|
| 100 |
Hash keys include: |
| 101 |
count - The number of renewals already used |
| 102 |
allowed - The total number of renewals this checkout may have |
| 103 |
remaining - The total number of renewals that can still be made |
| 104 |
unseen_count - The number of unseen renewals already used |
| 105 |
unseen_allowed - The total number of unseen renewals this checkout may have |
| 106 |
unseen_remaining - The total number of unseen renewals that can still be made |
| 107 |
|
| 108 |
=cut |
| 109 |
|
| 66 |
sub Renewals { |
110 |
sub Renewals { |
| 67 |
my ( $self, $borrowernumber, $itemnumber ) = @_; |
111 |
my ( $self, $borrowernumber, $itemnumber ) = @_; |
| 68 |
|
112 |
|
| 69 |
- |
|
|