Bug 4877 [ENH] - Update man page for koha-create
[koha.git] / C4 / ItemType.pm
blobe66d9178071588120e2559bcd5e2a9c7f646f561
1 package C4::ItemType;
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::ItemType - objects from the itemtypes table
31 =head1 SYNOPSIS
33 use C4::ItemType;
34 my @itemtypes = C4::ItemType->all;
35 print join("\n", map { $_->description } @itemtypes), "\n";
37 =head1 DESCRIPTION
39 Objects of this class represent a row in the C<itemtypes> 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::ItemType->new(\%opts)
53 Given a hashref, a new (in-memory) C4::ItemType 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::ItemType->all
68 This returns all the itemtypes 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 itemtypes table is small enough for
78 # `SELECT *` to be harmless.
79 "SELECT * FROM itemtypes ORDER BY description",
80 { Slice => {} },
81 )};
87 =head2 Object Methods
89 These are read-only accessors for attributes of a C4::ItemType object.
91 =head3 $itemtype->itemtype
93 =cut
95 =head3 $itemtype->description
97 =cut
99 =head3 $itemtype->renewalsallowed
101 =cut
103 =head3 $itemtype->rentalcharge
105 =cut
107 =head3 $itemtype->notforloan
109 =cut
111 =head3 $itemtype->imageurl
113 =cut
115 =head3 $itemtype->summary
117 =cut
119 sub AUTOLOAD {
120 my $self = shift;
121 my $attr = $AUTOLOAD;
122 $attr =~ s/.*://;
123 if (exists $self->{$attr}) {
124 return $self->{$attr};
125 } else {
126 return undef;
130 sub DESTROY { }
134 # ack itemtypes | grep '\.pm' | awk '{ print $1 }' | sed 's/:.*$//' | sort | uniq | sed -e 's,/,::,g' -e 's/\.pm//' -e 's/^/L<C4::/' -e 's/$/>,/'
136 =head1 SEE ALSO
138 The following modules make reference to the C<itemtypes> table.
140 L<C4::Biblio>,
141 L<C4::Circulation>,
142 L<C4::Context>,
143 L<C4::Items>,
144 L<C4::Koha>,
145 L<C4::Labels>,
146 L<C4::Overdues>,
147 L<C4::Reserves>,
148 L<C4::Search>,
149 L<C4::VirtualShelves::Page>,
150 L<C4::VirtualShelves>,
151 L<C4::XSLT>
155 =head1 AUTHOR
157 John Beppu <john.beppu@liblime.com>
159 =cut