3 # Copyright Liblime 2009
4 # Parts Copyright Tamil 2011
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # Koha is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with Koha; if not, see <http://www.gnu.org/licenses>.
24 use Encode
qw( encode );
33 C4::ItemType - objects from the itemtypes table
38 my @itemtypes = C4::ItemType->all;
39 print join("\n", map { $_->description } @itemtypes), "\n";
43 Objects of this class represent a row in the C<itemtypes> table.
45 Currently, the bare minimum for using this as a read-only data source has
46 been implemented. The API was designed to make it easy to transition to
55 =head3 C4::ItemType->new(\%opts)
57 Given a hashref, a new (in-memory) C4::ItemType object will be instantiated.
58 The database is not touched.
63 my ($class, $opts) = @_;
64 bless $opts => $class;
70 =head3 C4::ItemType->all
72 This returns all the itemtypes as objects. By default they're ordered by
79 my $dbh = C4
::Context
->dbh;
82 for ( @
{$dbh->selectall_arrayref(
83 "SELECT * FROM itemtypes ORDER BY description", { Slice
=> {} })} )
85 push @itypes, $class->new($_);
93 =head3 C4::ItemType->get
95 Return the itemtype indicated by the itemtype given as argument, as
101 my ($class, $itemtype) = @_;
103 return unless defined $itemtype;
105 my $dbh = C4
::Context
->dbh;
107 my $data = $dbh->selectrow_hashref(
108 "SELECT * FROM itemtypes WHERE itemtype = ?", undef, $itemtype
110 return $class->new($data);
116 =head2 Object Methods
118 These are read-only accessors for attributes of a C4::ItemType object.
120 =head3 $itemtype->itemtype
124 =head3 $itemtype->description
128 =head3 $itemtype->renewalsallowed
132 =head3 $itemtype->rentalcharge
136 =head3 $itemtype->notforloan
140 =head3 $itemtype->imageurl
144 =head3 $itemtype->checkinmsg
148 =head3 $itemtype->summary
154 my $attr = $AUTOLOAD;
156 if (exists $self->{$attr}) {
157 return $self->{$attr};
167 # ack itemtypes | grep '\.pm' | awk '{ print $1 }' | sed 's/:.*$//' | sort | uniq | sed -e 's,/,::,g' -e 's/\.pm//' -e 's/^/L<C4::/' -e 's/$/>,/'
171 The following modules make reference to the C<itemtypes> table.
182 L<C4::VirtualShelves::Page>,
183 L<C4::VirtualShelves>,
190 John Beppu <john.beppu@liblime.com>