Bug 3609 Fix fr-FR user permissions
[koha.git] / C4 / Category.pm
blob3dc6327f28697e7406f3b1813878cef4408e3ce6
1 package C4::Category;
3 # This file is part of Koha.
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.
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.
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
18 use strict;
19 use warnings;
20 use C4::Context;
22 our $AUTOLOAD;
27 =head1 NAME
29 C4::Category - objects from the categories table
31 =head1 SYNOPSIS
33 use C4::Category;
34 my @categories = C4::Category->all;
35 print join("\n", map { $_->description } @categories), "\n";
37 =head1 DESCRIPTION
39 Objects of this class represent a row in the C<categories> table.
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.
45 =head1 API
47 =head2 Class Methods
49 =cut
51 =head3 C4::Category->new(\%opts)
53 Given a hashref, a new (in-memory) C4::Category object will be instantiated.
54 The database is not touched.
56 =cut
58 sub new {
59 my ($class, $opts) = @_;
60 bless $opts => $class;
66 =head3 C4::Category->all
68 This returns all the categories as objects. By default they're ordered by
69 C<description>.
71 =cut
73 sub all {
74 my ($class) = @_;
75 my $dbh = C4::Context->dbh;
76 return map { $class->new($_) } @{$dbh->selectall_arrayref(
77 # The categories table is small enough for
78 # `SELECT *` to be harmless.
79 "SELECT * FROM categories ORDER BY description",
80 { Slice => {} },
81 )};
87 =head2 Object Methods
89 These are read-only accessors for attributes of a C4::Category object.
91 =head3 $category->categorycode
93 =head3 $category->description
95 =head3 $category->enrolmentperiod
97 =head3 $category->upperagelimit
99 =head3 $category->dateofbirthrequired
101 =head3 $category->finetype
103 =head3 $category->bulk
105 =head3 $category->enrolmentfee
107 =head3 $category->overduenoticerequired
109 =head3 $category->issuelimit
111 =head3 $category->reservefee
113 =head3 $category->category_type
115 =cut
117 sub AUTOLOAD {
118 my $self = shift;
119 my $attr = $AUTOLOAD;
120 $attr =~ s/.*://;
121 if (exists $self->{$attr}) {
122 return $self->{$attr};
123 } else {
124 return undef;
128 sub DESTROY { }
133 =head1 SEE ALSO
135 The following modules make reference to the C<categories> table.
137 L<C4::Members>, L<C4::Overdues>, L<C4::Reserves>
140 =head1 AUTHOR
142 John Beppu <john.beppu@liblime.com>
144 =cut