Bug 18309: Add UNIMARC field 214 and its subfields
[koha.git] / Koha / Template / Plugin / CirculationRules.pm
blob04587d4d517e04ec92e5a78eecbfedc01fcdd9ba
1 package Koha::Template::Plugin::CirculationRules;
3 # Copyright ByWater Solutions 2017
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 use Modern::Perl;
22 use base qw( Template::Plugin );
24 use Koha::CirculationRules;
26 sub Get {
27 my ( $self, $branchcode, $categorycode, $itemtype, $rule_name ) = @_;
29 $branchcode = undef if $branchcode eq q{} or $branchcode eq q{*};
30 $categorycode = undef if $categorycode eq q{} or $branchcode eq q{*};
31 $itemtype = undef if $itemtype eq q{} or $branchcode eq q{*};
33 my $rule = Koha::CirculationRules->get_effective_rule(
35 branchcode => $branchcode,
36 categorycode => $categorycode,
37 itemtype => $itemtype,
38 rule_name => $rule_name,
42 return $rule->rule_value if $rule;
45 sub Search {
46 my ( $self, $branchcode, $categorycode, $itemtype, $rule_name ) = @_;
48 $branchcode = undef if $branchcode eq q{} or $branchcode eq q{*};
49 $categorycode = undef if $categorycode eq q{} or $branchcode eq q{*};
50 $itemtype = undef if $itemtype eq q{} or $branchcode eq q{*};
52 my $rule = Koha::CirculationRules->search(
54 branchcode => $branchcode,
55 categorycode => $categorycode,
56 itemtype => $itemtype,
57 rule_name => $rule_name,
59 )->next;
61 return $rule->rule_value if $rule;