Bug 20473: Whitespace
[koha.git] / Koha / AdditionalContent.pm
1 package Koha::AdditionalContent;
2
3 # Copyright ByWater Solutions 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
23 use Koha::Database;
24 use Koha::DateUtils qw( dt_from_string );
25 use Koha::Libraries;
26 use Koha::Patrons;
27
28 use base qw(Koha::Object);
29
30 =head1 NAME
31
32 Koha::AdditionalContent - Koha Additional content object class
33
34 =head1 API
35
36 =head2 Class Methods
37
38 =cut
39
40 =head3 author
41
42     $additional_content->author;
43
44 Return the Koha::Patron object for the patron who authored this additional content
45
46 =cut
47
48 sub author {
49     my ($self) = @_;
50     my $author_rs = $self->_result->borrowernumber;
51     return unless $author_rs;
52     return Koha::Patron->_new_from_dbic($author_rs);
53 }
54
55 =head3 is_expired
56
57 my $is_expired = $additional_content->is_expired;
58
59 Returns 1 if the additional content is expired or 0;
60
61 =cut
62
63 sub is_expired {
64     my ( $self ) = @_;
65
66     return 0 unless $self->expirationdate;
67     return 1 if dt_from_string( $self->expirationdate ) < dt_from_string->truncate( to => 'day' );
68     return 0;
69 }
70
71 =head3 library
72
73 my $library = $additional_content->library;
74
75 Returns Koha::Library object or undef
76
77 =cut
78
79 sub library {
80     my ( $self ) = @_;
81
82     my $library_rs = $self->_result->branchcode;
83     return unless $library_rs;
84     return Koha::Library->_new_from_dbic( $library_rs );
85 }
86
87
88 =head3 _type
89
90 =cut
91
92 sub _type {
93     return 'AdditionalContent';
94 }
95
96 =head1 AUTHOR
97
98 Kyle M Hall <kyle@bywatersolutions.com>
99
100 =cut
101
102 1;