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

(-)a/C4/Biblio.pm (-1 / +3 lines)
Lines 44-49 use Koha::Acquisition::Currencies; Link Here
44
use Koha::Biblio::Metadata;
44
use Koha::Biblio::Metadata;
45
use Koha::Biblio::Metadatas;
45
use Koha::Biblio::Metadatas;
46
use Koha::Holds;
46
use Koha::Holds;
47
use Koha::ItemTypes;
47
use Koha::SearchEngine;
48
use Koha::SearchEngine;
48
use Koha::Libraries;
49
use Koha::Libraries;
49
50
Lines 1629-1635 sub GetAuthorisedValueDesc { Link Here
1629
1630
1630
        #---- itemtypes
1631
        #---- itemtypes
1631
        if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "itemtypes" ) {
1632
        if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "itemtypes" ) {
1632
            return getitemtypeinfo($value)->{translated_description};
1633
            my $itemtype = Koha::ItemTypes->find( $value );
1634
            return $itemtype ? $itemtype->translated_description : q||;
1633
        }
1635
        }
1634
1636
1635
        #---- "true" authorized value
1637
        #---- "true" authorized value
(-)a/Koha/Template/Plugin/ItemTypes.pm (-5 / +1 lines)
Lines 22-36 use Modern::Perl; Link Here
22
use Template::Plugin;
22
use Template::Plugin;
23
use base qw( Template::Plugin );
23
use base qw( Template::Plugin );
24
24
25
use C4::Koha;
26
use Koha::ItemTypes;
25
use Koha::ItemTypes;
27
26
28
sub GetDescription {
27
sub GetDescription {
29
    my ( $self, $itemtype ) = @_;
28
    my ( $self, $itemtype ) = @_;
30
29
    return Koha::ItemTypes->find( $itemtype )->translated_description;
31
    $itemtype = C4::Koha::getitemtypeinfo( $itemtype );
32
    return $itemtype->{translated_description};
33
34
}
30
}
35
31
36
sub Get {
32
sub Get {
(-)a/acqui/orderreceive.pl (-2 / +3 lines)
Lines 75-80 use C4::Koha; Link Here
75
75
76
use Koha::Acquisition::Booksellers;
76
use Koha::Acquisition::Booksellers;
77
use Koha::DateUtils qw( dt_from_string );
77
use Koha::DateUtils qw( dt_from_string );
78
use Koha::ItemTypes;
78
79
79
my $input      = new CGI;
80
my $input      = new CGI;
80
81
Lines 144-151 if ($AcqCreateItem eq 'receiving') { Link Here
144
        $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => $fw, kohafield => 'items.materials', authorised_value => $item->{materials} });
145
        $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => $fw, kohafield => 'items.materials', authorised_value => $item->{materials} });
145
        $item->{materials} = $descriptions->{lib} // '';
146
        $item->{materials} = $descriptions->{lib} // '';
146
147
147
        my $itemtype = getitemtypeinfo($item->{itype});
148
        my $itemtype = Koha::ItemsTypes->find( $item->{itype} );
148
        $item->{itemtype} = $itemtype->{description};
149
        $item->{itemtype} = $itemtype->description; # FIXME Should not it be translated_description?
149
        push @items, $item;
150
        push @items, $item;
150
    }
151
    }
151
    $template->param(items => \@items);
152
    $template->param(items => \@items);
(-)a/catalogue/getitem-ajax.pl (-2 / +3 lines)
Lines 29-34 use C4::Output; Link Here
29
use Koha::Libraries;
29
use Koha::Libraries;
30
30
31
use Koha::AuthorisedValues;
31
use Koha::AuthorisedValues;
32
use Koha::ItemTypes;
32
33
33
my $cgi = new CGI;
34
my $cgi = new CGI;
34
35
Lines 71-78 if($itemnumber) { Link Here
71
    $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({ frameworkcode => $fw, kohafield => 'items.materials', authorised_value => $item->{materials} });
72
    $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({ frameworkcode => $fw, kohafield => 'items.materials', authorised_value => $item->{materials} });
72
    $item->{materials} = $descriptions->{lib} // '';
73
    $item->{materials} = $descriptions->{lib} // '';
73
74
74
    my $itemtype = getitemtypeinfo($item->{itype});
75
    my $itemtype = Koha::ItemTypes->find( $item->{itype} );
75
    $item->{itemtype} = $itemtype->{description};
76
    $item->{itemtype} = $itemtype->description; # FIXME Should not it be translated_description?
76
}
77
}
77
78
78
my $json_text = to_json( $item, { utf8 => 1 } );
79
my $json_text = to_json( $item, { utf8 => 1 } );
(-)a/circ/transferstoreceive.pl (-2 / +3 lines)
Lines 36-41 use Date::Calc qw( Link Here
36
use C4::Koha;
36
use C4::Koha;
37
use C4::Reserves;
37
use C4::Reserves;
38
use Koha::Items;
38
use Koha::Items;
39
use Koha::ItemTypes;
39
use Koha::Libraries;
40
use Koha::Libraries;
40
use Koha::DateUtils;
41
use Koha::DateUtils;
41
use Koha::BiblioFrameworks;
42
use Koha::BiblioFrameworks;
Lines 89-98 while ( my $library = $libraries->next ) { Link Here
89
				$getransf{'diff'} = $diff;
90
				$getransf{'diff'} = $diff;
90
            }
91
            }
91
            my $gettitle     = GetBiblioFromItemNumber( $num->{'itemnumber'} );
92
            my $gettitle     = GetBiblioFromItemNumber( $num->{'itemnumber'} );
92
            my $itemtypeinfo = getitemtypeinfo( (C4::Context->preference('item-level_itypes')) ? $gettitle->{'itype'} : $gettitle->{'itemtype'} );
93
            my $itemtype = Koha::ItemTypes->find( (C4::Context->preference('item-level_itypes')) ? $gettitle->{'itype'} : $gettitle->{'itemtype'} );
93
94
94
            $getransf{'datetransfer'} = $num->{'datesent'};
95
            $getransf{'datetransfer'} = $num->{'datesent'};
95
            $getransf{'itemtype'} = $itemtypeinfo ->{'description'};
96
            $getransf{'itemtype'} = $itemtype->description; # FIXME Should not it be translated_description?
96
			foreach (qw(title author biblionumber itemnumber barcode homebranch holdingbranch itemcallnumber)) {
97
			foreach (qw(title author biblionumber itemnumber barcode homebranch holdingbranch itemcallnumber)) {
97
            	$getransf{$_} = $gettitle->{$_};
98
            	$getransf{$_} = $gettitle->{$_};
98
			}
99
			}
(-)a/circ/waitingreserves.pl (-2 / +3 lines)
Lines 37-42 use C4::Reserves; Link Here
37
use C4::Koha;
37
use C4::Koha;
38
use Koha::DateUtils;
38
use Koha::DateUtils;
39
use Koha::BiblioFrameworks;
39
use Koha::BiblioFrameworks;
40
use Koha::ItemTypes;
40
41
41
my $input = new CGI;
42
my $input = new CGI;
42
43
Lines 104-115 foreach my $num (@getreserves) { Link Here
104
    # fix up item type for display
105
    # fix up item type for display
105
    $gettitle->{'itemtype'} = C4::Context->preference('item-level_itypes') ? $gettitle->{'itype'} : $gettitle->{'itemtype'};
106
    $gettitle->{'itemtype'} = C4::Context->preference('item-level_itypes') ? $gettitle->{'itype'} : $gettitle->{'itemtype'};
106
    my $getborrower = GetMember(borrowernumber => $num->{'borrowernumber'});
107
    my $getborrower = GetMember(borrowernumber => $num->{'borrowernumber'});
107
    my $itemtypeinfo = getitemtypeinfo( $gettitle->{'itemtype'} );  # using the fixed up itype/itemtype
108
    my $itemtype = Koha::ItemTypes->find( $gettitle->{'itemtype'} );  # using the fixed up itype/itemtype
108
    $getreserv{'waitingdate'} = $num->{'waitingdate'};
109
    $getreserv{'waitingdate'} = $num->{'waitingdate'};
109
    my ( $expire_year, $expire_month, $expire_day ) = split (/-/, $num->{'expirationdate'});
110
    my ( $expire_year, $expire_month, $expire_day ) = split (/-/, $num->{'expirationdate'});
110
    my $calcDate = Date_to_Days( $expire_year, $expire_month, $expire_day );
111
    my $calcDate = Date_to_Days( $expire_year, $expire_month, $expire_day );
111
112
112
    $getreserv{'itemtype'}       = $itemtypeinfo->{'description'};
113
    $getreserv{'itemtype'}       = $itemtype->description; # FIXME Should not it be translated_description?
113
    $getreserv{'title'}          = $gettitle->{'title'};
114
    $getreserv{'title'}          = $gettitle->{'title'};
114
    $getreserv{'subtitle'}       = GetRecordValue('subtitle', GetMarcBiblio($gettitle->{'biblionumber'}), GetFrameworkCode($gettitle->{'biblionumber'}));
115
    $getreserv{'subtitle'}       = GetRecordValue('subtitle', GetMarcBiblio($gettitle->{'biblionumber'}), GetFrameworkCode($gettitle->{'biblionumber'}));
115
    $getreserv{'biblionumber'}   = $gettitle->{'biblionumber'};
116
    $getreserv{'biblionumber'}   = $gettitle->{'biblionumber'};
(-)a/members/summary-print.pl (-3 / +3 lines)
Lines 22-32 use CGI; Link Here
22
use C4::Auth;
22
use C4::Auth;
23
use C4::Output;
23
use C4::Output;
24
use C4::Members;
24
use C4::Members;
25
use C4::Koha qw( getitemtypeinfo );
26
use C4::Circulation qw( GetIssuingCharges );
25
use C4::Circulation qw( GetIssuingCharges );
27
use C4::Reserves;
26
use C4::Reserves;
28
use C4::Items;
27
use C4::Items;
29
use Koha::Holds;
28
use Koha::Holds;
29
use Koha::ItemTypes;
30
30
31
my $input          = CGI->new;
31
my $input          = CGI->new;
32
my $borrowernumber = $input->param('borrowernumber');
32
my $borrowernumber = $input->param('borrowernumber');
Lines 94-101 sub build_issue_data { Link Here
94
        my ( $charge, $itemtype ) =
94
        my ( $charge, $itemtype ) =
95
          GetIssuingCharges( $issue->{itemnumber}, $borrowernumber );
95
          GetIssuingCharges( $issue->{itemnumber}, $borrowernumber );
96
96
97
        my $itemtypeinfo = getitemtypeinfo($itemtype);
97
        my $itemtype = Koha::ItemTypes->find( $itemtype );
98
        $row{'itemtype_description'} = $itemtypeinfo->{description};
98
        $row{'itemtype_description'} = $itemtype->description; #FIXME Should not it be translated_description
99
99
100
        $row{'charge'} = sprintf( "%.2f", $charge );
100
        $row{'charge'} = sprintf( "%.2f", $charge );
101
101
(-)a/opac/opac-browser.pl (-1 lines)
Lines 32-38 use C4::Context; Link Here
32
use C4::Output;
32
use C4::Output;
33
use CGI qw ( -utf8 );
33
use CGI qw ( -utf8 );
34
use C4::Biblio;
34
use C4::Biblio;
35
use C4::Koha;       # use getitemtypeinfo
36
35
37
my $query = new CGI;
36
my $query = new CGI;
38
37
(-)a/opac/opac-search.pl (-1 / +2 lines)
Lines 52-57 use C4::Tags qw(get_tags); Link Here
52
use C4::SocialData;
52
use C4::SocialData;
53
use C4::External::OverDrive;
53
use C4::External::OverDrive;
54
54
55
use Koha::ItemTypes;
55
use Koha::LibraryCategories;
56
use Koha::LibraryCategories;
56
use Koha::Ratings;
57
use Koha::Ratings;
57
use Koha::Virtualshelves;
58
use Koha::Virtualshelves;
Lines 225-231 my $itemtypes = GetItemTypesCategorized; Link Here
225
# add translated_description to itemtypes
226
# add translated_description to itemtypes
226
foreach my $itemtype ( keys %{$itemtypes} ) {
227
foreach my $itemtype ( keys %{$itemtypes} ) {
227
    # Itemtypes search categories don't have (yet) translated descriptions, they are auth values (and could still have no descriptions too BZ 18400)
228
    # Itemtypes search categories don't have (yet) translated descriptions, they are auth values (and could still have no descriptions too BZ 18400)
228
    my $translated_description = getitemtypeinfo( $itemtype, 'opac' )->{translated_description};
229
    my $translated_description = Koha::ItemTypes->find( $itemtype )->translated_description;
229
    $itemtypes->{$itemtype}->{translated_description} = $translated_description || $itemtypes->{$itemtype}->{description} || q{};
230
    $itemtypes->{$itemtype}->{translated_description} = $translated_description || $itemtypes->{$itemtype}->{description} || q{};
230
}
231
}
231
232
(-)a/opac/opac-shelves.pl (-4 / +5 lines)
Lines 30-35 use C4::Tags qw( get_tags ); Link Here
30
use C4::XSLT;
30
use C4::XSLT;
31
31
32
use Koha::Biblioitems;
32
use Koha::Biblioitems;
33
use Koha::ItemTypes;
33
use Koha::Virtualshelves;
34
use Koha::Virtualshelves;
34
use Koha::RecordProcessor;
35
use Koha::RecordProcessor;
35
36
Lines 280-289 if ( $op eq 'view' ) { Link Here
280
281
281
                my $marcflavour = C4::Context->preference("marcflavour");
282
                my $marcflavour = C4::Context->preference("marcflavour");
282
                my $itemtype = Koha::Biblioitems->search({ biblionumber => $content->biblionumber })->next->itemtype;
283
                my $itemtype = Koha::Biblioitems->search({ biblionumber => $content->biblionumber })->next->itemtype;
283
                my $itemtypeinfo = getitemtypeinfo( $itemtype, 'opac' );
284
                $itemtype = Koha::ItemTypes->find( $itemtype );
284
                $this_item->{imageurl}          = $itemtypeinfo->{imageurl};
285
                $this_item->{imageurl}          = C4::Koha::getitemtypeimagelocation( 'opac', $itemtype->imageurl );
285
                $this_item->{description}       = $itemtypeinfo->{description};
286
                $this_item->{description}       = $itemtype->description; #FIXME Should not it be translated_description?
286
                $this_item->{notforloan}        = $itemtypeinfo->{notforloan};
287
                $this_item->{notforloan}        = $itemtype->notforloan;
287
                $this_item->{'coins'}           = GetCOinSBiblio($record);
288
                $this_item->{'coins'}           = GetCOinSBiblio($record);
288
                $this_item->{'subtitle'}        = GetRecordValue( 'subtitle', $record, GetFrameworkCode( $biblionumber ) );
289
                $this_item->{'subtitle'}        = GetRecordValue( 'subtitle', $record, GetFrameworkCode( $biblionumber ) );
289
                $this_item->{'normalized_upc'}  = GetNormalizedUPC( $record, $marcflavour );
290
                $this_item->{'normalized_upc'}  = GetNormalizedUPC( $record, $marcflavour );
(-)a/opac/opac-tags_subject.pl (-1 lines)
Lines 32-38 use C4::Context; Link Here
32
use C4::Output;
32
use C4::Output;
33
use CGI qw ( -utf8 );
33
use CGI qw ( -utf8 );
34
use C4::Biblio;
34
use C4::Biblio;
35
use C4::Koha;       # use getitemtypeinfo
36
35
37
my $query = new CGI;
36
my $query = new CGI;
38
37
(-)a/svc/checkouts (-2 / +3 lines)
Lines 31-36 use C4::Context; Link Here
31
31
32
use Koha::AuthorisedValues;
32
use Koha::AuthorisedValues;
33
use Koha::DateUtils;
33
use Koha::DateUtils;
34
use Koha::ItemTypes;
34
35
35
my $input = new CGI;
36
my $input = new CGI;
36
37
Lines 148-154 while ( my $c = $sth->fetchrow_hashref() ) { Link Here
148
    my ( $renewals_count, $renewals_allowed, $renewals_remaining ) =
149
    my ( $renewals_count, $renewals_allowed, $renewals_remaining ) =
149
      GetRenewCount( $c->{borrowernumber}, $c->{itemnumber} );
150
      GetRenewCount( $c->{borrowernumber}, $c->{itemnumber} );
150
151
151
    my $itemtype = C4::Koha::getitemtypeinfo( $item_level_itypes ? $c->{itype} : $c->{itemtype} );
152
    my $itemtype = Koha::ItemTypes->find( $item_level_itypes ? $c->{itype} : $c->{itemtype} );
152
    my $location;
153
    my $location;
153
    if ( $c->{location} ) {
154
    if ( $c->{location} ) {
154
        my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $c->{location} });
155
        my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $c->{location} });
Lines 170-176 while ( my $c = $sth->fetchrow_hashref() ) { Link Here
170
        author               => $c->{author},
171
        author               => $c->{author},
171
        barcode              => $c->{barcode},
172
        barcode              => $c->{barcode},
172
        itemtype             => $item_level_itypes ? $c->{itype} : $c->{itemtype},
173
        itemtype             => $item_level_itypes ? $c->{itype} : $c->{itemtype},
173
        itemtype_description => $itemtype->{translated_description},
174
        itemtype_description => $itemtype->translated_description,
174
        location             => $location,
175
        location             => $location,
175
        homebranch           => $c->{homebranch},
176
        homebranch           => $c->{homebranch},
176
        itemnotes            => $c->{itemnotes},
177
        itemnotes            => $c->{itemnotes},
(-)a/svc/holds (-2 / +3 lines)
Lines 30-35 use C4::Context; Link Here
30
30
31
use Koha::DateUtils;
31
use Koha::DateUtils;
32
use Koha::Holds;
32
use Koha::Holds;
33
use Koha::ItemTypes;
33
use Koha::Libraries;
34
use Koha::Libraries;
34
35
35
my $input = new CGI;
36
my $input = new CGI;
Lines 75-82 while ( my $h = $holds_rs->next() ) { Link Here
75
76
76
    my $itemtype_limit;
77
    my $itemtype_limit;
77
    if ( $h->itemtype ) {
78
    if ( $h->itemtype ) {
78
        my $itemtype = C4::Koha::getitemtypeinfo( $h->itemtype );
79
        my $itemtype = Koha::ItemTypes->find( $h->itemtype );
79
        $itemtype_limit = $itemtype->{translated_description};
80
        $itemtype_limit = $itemtype->translated_description;
80
    }
81
    }
81
82
82
    my $libraries = Koha::Libraries->search({}, { order_by => ['branchname'] })->unblessed;
83
    my $libraries = Koha::Libraries->search({}, { order_by => ['branchname'] })->unblessed;
(-)a/t/db_dependent/Koha.t (-7 / +1 lines)
Lines 5-11 Link Here
5
5
6
use Modern::Perl;
6
use Modern::Perl;
7
use DateTime::Format::MySQL;
7
use DateTime::Format::MySQL;
8
use Test::More tests => 7;
8
use Test::More tests => 6;
9
9
10
use t::lib::TestBuilder;
10
use t::lib::TestBuilder;
11
11
Lines 157-168 subtest 'Authorized Values Tests' => sub { Link Here
157
157
158
};
158
};
159
159
160
subtest 'Itemtype info Tests' => sub {
161
    like ( getitemtypeinfo( $itype_1->{itemtype} )->{'imageurl'}, qr/intranet-tmpl/, 'getitemtypeinfo on unspecified interface returns intranet imageurl (legacy behavior)' );
162
    like ( getitemtypeinfo( $itype_1->{itemtype}, 'intranet')->{'imageurl'}, qr/intranet-tmpl/, 'getitemtypeinfo on "intranet" interface returns intranet imageurl' );
163
    like ( getitemtypeinfo( $itype_1->{itemtype}, 'opac')->{'imageurl'}, qr/opac-tmpl/, 'getitemtypeinfo on "opac" interface returns opac imageurl' );
164
};
165
166
### test for C4::Koha->GetDailyQuote()
160
### test for C4::Koha->GetDailyQuote()
167
SKIP:
161
SKIP:
168
    {
162
    {
(-)a/virtualshelves/shelves.pl (-5 / +5 lines)
Lines 29-34 use C4::XSLT; Link Here
29
29
30
use Koha::Biblios;
30
use Koha::Biblios;
31
use Koha::Biblioitems;
31
use Koha::Biblioitems;
32
use Koha::ItemTypes;
32
use Koha::CsvProfiles;
33
use Koha::CsvProfiles;
33
use Koha::Virtualshelves;
34
use Koha::Virtualshelves;
34
35
Lines 244-257 if ( $op eq 'view' ) { Link Here
244
245
245
                my $marcflavour = C4::Context->preference("marcflavour");
246
                my $marcflavour = C4::Context->preference("marcflavour");
246
                my $itemtype = Koha::Biblioitems->search({ biblionumber => $content->biblionumber })->next->itemtype;
247
                my $itemtype = Koha::Biblioitems->search({ biblionumber => $content->biblionumber })->next->itemtype;
247
                my $itemtypeinfo = getitemtypeinfo( $itemtype, 'intranet' );
248
                $itemtype = Koha::ItemTypes->find( $itemtype );
248
                my $biblio = Koha::Biblios->find( $content->biblionumber );
249
                my $biblio = Koha::Biblios->find( $content->biblionumber );
249
                $this_item->{title}             = $biblio->title;
250
                $this_item->{title}             = $biblio->title;
250
                $this_item->{author}            = $biblio->author;
251
                $this_item->{author}            = $biblio->author;
251
                $this_item->{dateadded}         = $content->dateadded;
252
                $this_item->{dateadded}         = $content->dateadded;
252
                $this_item->{imageurl}          = $itemtypeinfo->{imageurl};
253
                $this_item->{imageurl}          = C4::Koha::getitemtypeimagelocation( 'intranet', $itemtype->imageurl );
253
                $this_item->{description}       = $itemtypeinfo->{description};
254
                $this_item->{description}       = $itemtype->description; #FIXME Should not it be translated_description
254
                $this_item->{notforloan}        = $itemtypeinfo->{notforloan};
255
                $this_item->{notforloan}        = $itemtype->notforloan;
255
                $this_item->{'coins'}           = GetCOinSBiblio($record);
256
                $this_item->{'coins'}           = GetCOinSBiblio($record);
256
                $this_item->{'subtitle'}        = GetRecordValue( 'subtitle', $record, GetFrameworkCode( $biblionumber ) );
257
                $this_item->{'subtitle'}        = GetRecordValue( 'subtitle', $record, GetFrameworkCode( $biblionumber ) );
257
                $this_item->{'normalized_upc'}  = GetNormalizedUPC( $record, $marcflavour );
258
                $this_item->{'normalized_upc'}  = GetNormalizedUPC( $record, $marcflavour );
258
- 

Return to bug 17843