Bug 7435: corrects Fund selectbox in addneworder
[koha.git] / C4 / Category.pm
1 package C4::Category;
2
3 # This file is part of Koha.
4 #
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 2 of the License, or (at your option) any later
8 # version.
9 #
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License along with
15 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
16 # Suite 330, Boston, MA  02111-1307 USA
17
18 use strict;
19 use warnings;
20 use C4::Context;
21
22 our $AUTOLOAD;
23
24
25
26
27 =head1 NAME
28
29 C4::Category - objects from the categories table
30
31 =head1 SYNOPSIS
32
33     use C4::Category;
34     my @categories = C4::Category->all;
35     print join("\n", map { $_->description } @categories), "\n";
36
37 =head1 DESCRIPTION
38
39 Objects of this class represent a row in the C<categories> table.
40
41 Currently, the bare minimum for using this as a read-only data source has
42 been implemented.  The API was designed to make it easy to transition to
43 an ORM later on.
44
45 =head1 API
46
47 =head2 Class Methods
48
49 =cut
50
51 =head3 C4::Category->new(\%opts)
52
53 Given a hashref, a new (in-memory) C4::Category object will be instantiated.
54 The database is not touched.
55
56 =cut
57
58 sub new {
59     my ($class, $opts) = @_;
60     bless $opts => $class;
61 }
62
63
64
65
66 =head3 C4::Category->all
67
68 This returns all the categories as objects.  By default they're ordered by
69 C<description>.
70
71 =cut
72
73 sub all {
74     my $class = shift;
75     map {
76         utf8::encode($_->{description});
77         $class->new($_);
78     } @{C4::Context->dbh->selectall_arrayref(
79         "SELECT * FROM categories ORDER BY description", { Slice => {} }
80     )};
81 }
82
83
84
85
86 =head2 Object Methods
87
88 These are read-only accessors for attributes of a C4::Category object.
89
90 =head3 $category->categorycode
91
92 =cut
93
94 =head3 $category->description
95
96 =cut
97
98 =head3 $category->enrolmentperiod
99
100 =cut
101
102 =head3 $category->upperagelimit
103
104 =cut
105
106 =head3 $category->dateofbirthrequired
107
108 =cut
109
110 =head3 $category->finetype
111
112 =cut
113
114 =head3 $category->bulk
115
116 =cut
117
118 =head3 $category->enrolmentfee
119
120 =cut
121
122 =head3 $category->overduenoticerequired
123
124 =cut
125
126 =head3 $category->issuelimit
127
128 =cut
129
130 =head3 $category->reservefee
131
132 =cut
133
134 =head3 $category->category_type
135
136 =cut
137
138 sub AUTOLOAD {
139     my $self = shift;
140     my $attr = $AUTOLOAD;
141     $attr =~ s/.*://;
142     if (exists $self->{$attr}) {
143         return $self->{$attr};
144     } else {
145         return undef;
146     }
147 }
148
149 sub DESTROY { }
150
151
152
153
154 =head1 SEE ALSO
155
156 The following modules make reference to the C<categories> table.
157
158 L<C4::Members>, L<C4::Overdues>, L<C4::Reserves>
159
160
161 =head1 AUTHOR
162
163 John Beppu <john.beppu@liblime.com>
164
165 =cut
166
167 1;