=cut
sub GetAuthorisedValueByCode {
- my ( $category, $authvalcode ) = @_;
+ my ( $category, $authvalcode, $opac ) = @_;
+ my $field = $opac ? 'lib_opac' : 'lib';
my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare("SELECT lib FROM authorised_values WHERE category=? AND authorised_value =?");
+ my $sth = $dbh->prepare("SELECT $field FROM authorised_values WHERE category=? AND authorised_value =?");
$sth->execute( $category, $authvalcode );
while ( my $data = $sth->fetchrow_hashref ) {
- return $data->{'lib'};
+ return $data->{ $field };
}
}
--- /dev/null
+package Koha::Template::Plugin::KohaAuthorisedValues;
+
+# Copyright ByWater Solutions 2012
+
+# 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 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.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+use Modern::Perl;
+
+use Template::Plugin;
+use base qw( Template::Plugin );
+
+use C4::Koha;
+
+sub GetByCode {
+ my ( $self, $category, $code, $opac ) = @_;
+ return GetAuthorisedValueByCode( $category, $code, $opac );
+}
+
+1;
+[% USE KohaAuthorisedValues %]
+
[% IF ( item.datedue ) %]
[% IF ( OPACShowCheckoutName ) %]
Checked out to [% item.cardnumber %] [% item.firstname %] [% item.surname %]
[% ELSIF ( item.wthdrawn ) %]
Item withdrawn
[% ELSIF ( item.itemlost ) %]
- [% IF ( item.lostimageurl ) %]
- <img src="[% item.lostimageurl %]" alt="[% item.lostimagelabel %]" title="[% item.lostimagelabel %]">
+ [% IF KohaAuthorisedValues.GetByCode( 'LOST', item.itemlost, 1 ) %]
+ [% KohaAuthorisedValues.GetByCode( 'LOST', item.itemlost, 1 ) %]
[% ELSE %]
- Item lost
+ [% IF ( item.lostimageurl ) %]
+ <img src="[% item.lostimageurl %]" alt="[% item.lostimagelabel %]" title="[% item.lostimagelabel %]">
+ [% ELSE %]
+ Item lost
+ [% END %]
[% END %]
[% ELSIF ( item.itemnotforloan ) %]
[% IF ( item.notforloanvalue ) %]
[% ELSIF ( item.notforloan_per_itemtype ) %]
Not for loan [% IF ( item.restrictedopac ) %]<span class="restricted">([% item.restrictedopac %])</span>[% END %]
[% ELSIF ( item.damaged ) %]
- Item damaged
+ [% IF KohaAuthorisedValues.GetByCode( 'DAMAGED', item.damaged, 1 ) %]
+ [% KohaAuthorisedValues.GetByCode( 'DAMAGED', item.damaged, 1 ) %]
+ [% ELSE %]
+ Item damaged
+ [% END %]
[% ELSE %]
Available [% IF ( item.restrictedopac ) %]<span class="restricted">([% item.restrictedopac %])</span>[% END %]
[% END %]