Bug 35961: Add missing includes
[koha.git] / Koha / CirculationRule.pm
1 package Koha::CirculationRule;
2
3 # Copyright Vaara-kirjastot 2015
4 #
5 # This file is part of Koha.
6 #
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.
11 #
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.
16 #
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>.
19
20 use Modern::Perl;
21
22 use base qw(Koha::Object);
23
24 use Koha::Libraries;
25 use Koha::Patron::Categories;
26 use Koha::ItemTypes;
27
28 =head1 NAME
29
30 Koha::CirculationRule - Koha CirculationRule  object class
31
32 =head1 API
33
34 =head2 Class Methods
35
36 =cut
37
38 =head3 library
39
40 =cut
41
42 sub library {
43     my ($self) = @_;
44     my $rs = $self->_result->branchcode;
45     return unless $rs;
46     return Koha::Library->_new_from_dbic($rs);
47 }
48
49 =head3 patron_category
50
51 =cut
52
53 sub patron_category {
54     my ($self) = @_;
55     my $rs = $self->_result->categorycode;
56     return unless $rs;
57     return Koha::Patron::Category->_new_from_dbic($rs);
58 }
59
60 =head3 item_type
61
62 =cut
63
64 sub item_type {
65     my ($self) = @_;
66     my $rs = $self->_result->itemtype;
67     return unless $rs;
68     return Koha::ItemTypes->_new_from_dbic($rs);
69 }
70
71 =head3 clone
72
73 Clone a circulation rule to another branch
74
75 =cut
76
77 sub clone {
78     my ($self, $to_branch) = @_;
79
80     my $cloned_rule = $self->unblessed;
81     $cloned_rule->{branchcode} = $to_branch;
82     delete $cloned_rule->{id};
83     return Koha::CirculationRule->new( $cloned_rule )->store;
84 }
85
86 =head3 _type
87
88 =cut
89
90 sub _type {
91     return 'CirculationRule';
92 }
93
94 1;