View | Details | Raw Unified | Return to bug 9426
Collapse All | Expand All

(-)a/C4/ItemType.pm (+21 lines)
Lines 87-92 sub all { Link Here
87
    return @itypes;
87
    return @itypes;
88
}
88
}
89
89
90
=head3 C4::ItemType->new_from_code($code)
91
92
This returns the itemtype as object from code.
93
94
=cut
95
96
sub new_from_code {
97
    my ($class, $code) = @_;
98
    my $dbh = C4::Context->dbh;
99
    my $itype;
100
    my $sth = $dbh->prepare(q{
101
        SELECT * FROM itemtypes WHERE itemtype = ?
102
    });
103
    $sth->execute($code);
104
    my $data = $sth->fetchrow_hashref;
105
    if ($data) {
106
        $itype = $class->new($data);
107
        utf8::encode($itype->{description});
108
    }
109
    return $itype;
110
}
90
111
91
112
92
113
(-)a/Koha/Template/Plugin/KohaItemType.pm (-1 / +36 lines)
Line 0 Link Here
0
- 
1
package Koha::Template::Plugin::KohaItemType;
2
3
# Copyright 2013 BibLibre SARL
4
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use strict;
21
use warnings;
22
23
use Template::Plugin::Filter;
24
use base qw( Template::Plugin::Filter );
25
use warnings;
26
use strict;
27
28
use C4::ItemType;
29
30
sub filter {
31
    my ($self,$code) = @_;
32
    my $itemtype = C4::ItemType->new_from_code($code);
33
    return $itemtype ? $itemtype->description : '';
34
}
35
36
1;

Return to bug 9426