package C4::ItemType;
+# Copyright Liblime 2009
+# Parts Copyright Tamil 2011
+#
# This file is part of Koha.
#
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
#
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
#
-# You should have received a copy of the GNU General Public License along with
-# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
-# Suite 330, Boston, MA 02111-1307 USA
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
use strict;
use warnings;
use C4::Context;
+use C4::Languages;
+use Encode qw( encode );
our $AUTOLOAD;
sub all {
my ($class) = @_;
my $dbh = C4::Context->dbh;
- return map { $class->new($_) } @{$dbh->selectall_arrayref(
- # The itemtypes table is small enough for
- # `SELECT *` to be harmless.
- "SELECT * FROM itemtypes ORDER BY description",
- { Slice => {} },
- )};
+
+ my $language = C4::Languages::getlanguage();
+ my @itypes;
+ for ( @{$dbh->selectall_arrayref(q|
+ SELECT *,
+ COALESCE( localization.translation, itemtypes.description ) AS translated_description
+ FROM itemtypes
+ LEFT JOIN localization ON itemtypes.itemtype = localization.code
+ AND localization.entity = 'itemtypes'
+ AND localization.lang = ?
+ ORDER BY description
+ |, { Slice => {} }, $language)} )
+ {
+ push @itypes, $class->new($_);
+ }
+ return @itypes;
+}
+
+
+
+
+=head3 C4::ItemType->get
+
+Return the itemtype indicated by the itemtype given as argument, as
+an object.
+
+=cut
+
+sub get {
+ my ($class, $itemtype) = @_;
+
+ return unless defined $itemtype;
+
+ my $dbh = C4::Context->dbh;
+
+ my $data = $dbh->selectrow_hashref(
+ "SELECT * FROM itemtypes WHERE itemtype = ?", undef, $itemtype
+ );
+ return $class->new($data);
}
=head3 $itemtype->itemtype
+=cut
+
=head3 $itemtype->description
+=cut
+
=head3 $itemtype->renewalsallowed
+=cut
+
=head3 $itemtype->rentalcharge
+=cut
+
=head3 $itemtype->notforloan
+=cut
+
=head3 $itemtype->imageurl
+=cut
+
+=head3 $itemtype->checkinmsg
+
+=cut
+
=head3 $itemtype->summary
=cut
L<C4::Overdues>,
L<C4::Reserves>,
L<C4::Search>,
-L<C4::VirtualShelves::Page>,
-L<C4::VirtualShelves>,
L<C4::XSLT>