Bug 17600: Standardize our EXPORT_OK
[srvgit] / Koha / Club / Enrollment.pm
1 package Koha::Club::Enrollment;
2
3 # Copyright ByWater Solutions 2014
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::Clubs;
25 use Koha::Patrons;
26 use Koha::DateUtils qw( dt_from_string );
27 use DateTime;
28
29 use base qw(Koha::Object);
30
31 =head1 NAME
32
33 Koha::Club::Enrollment
34
35 Represents a "pattern" on which many clubs can be created.
36 In this way we can directly compare different clubs of the same 'template'
37 for statistical purposes.
38
39 =head1 API
40
41 =head2 Class Methods
42
43 =cut
44
45 =head3 cancel
46
47 =cut
48
49 sub cancel {
50     my ( $self ) = @_;
51
52     $self->_result()->update( { date_canceled => \'NOW()' } );
53
54     return $self;
55 }
56
57 =head3 club
58
59 =cut
60
61 sub club {
62     my ( $self ) = @_;
63     return Koha::Clubs->find( $self->club_id() );
64 }
65
66 =head3 patron
67
68 =cut
69
70 sub patron {
71     my ( $self ) = @_;
72     return Koha::Patrons->find( $self->borrowernumber() );
73 }
74
75 =head3 is_canceled
76
77 Determines if enrollment is canceled
78
79 =cut
80
81 sub is_canceled {
82     my ( $self ) = @_;
83
84     return 0 unless $self->date_canceled;
85     my $today = dt_from_string;
86     my $date_canceled = dt_from_string( $self->date_canceled );
87
88     return DateTime->compare($date_canceled, $today) < 1;
89 }
90
91 =head3 type
92
93 =cut
94
95 sub _type {
96     return 'ClubEnrollment';
97 }
98
99 =head1 AUTHOR
100
101 Kyle M Hall <kyle@bywatersolutions.com>
102
103 =cut
104
105 1;