The C4::Koha::getitemtypeinfo subroutine did the almost same job as
GetItemTypes. On top of that it returned the imageurl value processed by
C4::Koha::getitemtypeimagelocation.
This value is only used from the 2 [opac-]shelves.pl scripts. Then it's
better not retrieve it only when we need it.
Test plan:
Play with the different scripts touched by this patch and focus on item
types. The same description as prior to this patch must be displayed.
Note that sometimes it is not the translated description which is
displayed, but that should be fixed on another bug report. Indeed we do
not expect this patch to change any behaviors.
Signed-off-by: Lari Taskula <lari.taskula@jns.fi>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
15 files changed:
use Koha::Biblio::Metadata;
use Koha::Biblio::Metadatas;
use Koha::Holds;
use Koha::Biblio::Metadata;
use Koha::Biblio::Metadatas;
use Koha::Holds;
use Koha::SearchEngine;
use Koha::Libraries;
use Koha::SearchEngine;
use Koha::Libraries;
#---- itemtypes
if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "itemtypes" ) {
#---- itemtypes
if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "itemtypes" ) {
- return getitemtypeinfo($value)->{translated_description};
+ my $itemtype = Koha::ItemTypes->find( $value );
+ return $itemtype ? $itemtype->translated_description : q||;
}
#---- "true" authorized value
}
#---- "true" authorized value
use Template::Plugin;
use base qw( Template::Plugin );
use Template::Plugin;
use base qw( Template::Plugin );
use Koha::ItemTypes;
sub GetDescription {
my ( $self, $itemtype ) = @_;
use Koha::ItemTypes;
sub GetDescription {
my ( $self, $itemtype ) = @_;
-
- $itemtype = C4::Koha::getitemtypeinfo( $itemtype );
- return $itemtype->{translated_description};
-
+ return Koha::ItemTypes->find( $itemtype )->translated_description;
use Koha::Acquisition::Booksellers;
use Koha::DateUtils qw( dt_from_string );
use Koha::Acquisition::Booksellers;
use Koha::DateUtils qw( dt_from_string );
$descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => $fw, kohafield => 'items.materials', authorised_value => $item->{materials} });
$item->{materials} = $descriptions->{lib} // '';
$descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => $fw, kohafield => 'items.materials', authorised_value => $item->{materials} });
$item->{materials} = $descriptions->{lib} // '';
- my $itemtype = getitemtypeinfo($item->{itype});
- $item->{itemtype} = $itemtype->{description};
+ my $itemtype = Koha::ItemsTypes->find( $item->{itype} );
+ $item->{itemtype} = $itemtype->description; # FIXME Should not it be translated_description?
push @items, $item;
}
$template->param(items => \@items);
push @items, $item;
}
$template->param(items => \@items);
use Koha::Libraries;
use Koha::AuthorisedValues;
use Koha::Libraries;
use Koha::AuthorisedValues;
$descriptions = Koha::AuthorisedValues->get_description_by_koha_field({ frameworkcode => $fw, kohafield => 'items.materials', authorised_value => $item->{materials} });
$item->{materials} = $descriptions->{lib} // '';
$descriptions = Koha::AuthorisedValues->get_description_by_koha_field({ frameworkcode => $fw, kohafield => 'items.materials', authorised_value => $item->{materials} });
$item->{materials} = $descriptions->{lib} // '';
- my $itemtype = getitemtypeinfo($item->{itype});
- $item->{itemtype} = $itemtype->{description};
+ my $itemtype = Koha::ItemTypes->find( $item->{itype} );
+ $item->{itemtype} = $itemtype->description; # FIXME Should not it be translated_description?
}
my $json_text = to_json( $item, { utf8 => 1 } );
}
my $json_text = to_json( $item, { utf8 => 1 } );
use C4::Koha;
use C4::Reserves;
use Koha::Items;
use C4::Koha;
use C4::Reserves;
use Koha::Items;
use Koha::Libraries;
use Koha::DateUtils;
use Koha::BiblioFrameworks;
use Koha::Libraries;
use Koha::DateUtils;
use Koha::BiblioFrameworks;
$getransf{'diff'} = $diff;
}
my $gettitle = GetBiblioFromItemNumber( $num->{'itemnumber'} );
$getransf{'diff'} = $diff;
}
my $gettitle = GetBiblioFromItemNumber( $num->{'itemnumber'} );
- my $itemtypeinfo = getitemtypeinfo( (C4::Context->preference('item-level_itypes')) ? $gettitle->{'itype'} : $gettitle->{'itemtype'} );
+ my $itemtype = Koha::ItemTypes->find( (C4::Context->preference('item-level_itypes')) ? $gettitle->{'itype'} : $gettitle->{'itemtype'} );
$getransf{'datetransfer'} = $num->{'datesent'};
$getransf{'datetransfer'} = $num->{'datesent'};
- $getransf{'itemtype'} = $itemtypeinfo ->{'description'};
+ $getransf{'itemtype'} = $itemtype->description; # FIXME Should not it be translated_description?
foreach (qw(title author biblionumber itemnumber barcode homebranch holdingbranch itemcallnumber)) {
$getransf{$_} = $gettitle->{$_};
}
foreach (qw(title author biblionumber itemnumber barcode homebranch holdingbranch itemcallnumber)) {
$getransf{$_} = $gettitle->{$_};
}
use C4::Koha;
use Koha::DateUtils;
use Koha::BiblioFrameworks;
use C4::Koha;
use Koha::DateUtils;
use Koha::BiblioFrameworks;
# fix up item type for display
$gettitle->{'itemtype'} = C4::Context->preference('item-level_itypes') ? $gettitle->{'itype'} : $gettitle->{'itemtype'};
my $getborrower = GetMember(borrowernumber => $num->{'borrowernumber'});
# fix up item type for display
$gettitle->{'itemtype'} = C4::Context->preference('item-level_itypes') ? $gettitle->{'itype'} : $gettitle->{'itemtype'};
my $getborrower = GetMember(borrowernumber => $num->{'borrowernumber'});
- my $itemtypeinfo = getitemtypeinfo( $gettitle->{'itemtype'} ); # using the fixed up itype/itemtype
+ my $itemtype = Koha::ItemTypes->find( $gettitle->{'itemtype'} ); # using the fixed up itype/itemtype
$getreserv{'waitingdate'} = $num->{'waitingdate'};
my ( $expire_year, $expire_month, $expire_day ) = split (/-/, $num->{'expirationdate'});
my $calcDate = Date_to_Days( $expire_year, $expire_month, $expire_day );
$getreserv{'waitingdate'} = $num->{'waitingdate'};
my ( $expire_year, $expire_month, $expire_day ) = split (/-/, $num->{'expirationdate'});
my $calcDate = Date_to_Days( $expire_year, $expire_month, $expire_day );
- $getreserv{'itemtype'} = $itemtypeinfo->{'description'};
+ $getreserv{'itemtype'} = $itemtype->description; # FIXME Should not it be translated_description?
$getreserv{'title'} = $gettitle->{'title'};
$getreserv{'subtitle'} = GetRecordValue('subtitle', GetMarcBiblio($gettitle->{'biblionumber'}), GetFrameworkCode($gettitle->{'biblionumber'}));
$getreserv{'biblionumber'} = $gettitle->{'biblionumber'};
$getreserv{'title'} = $gettitle->{'title'};
$getreserv{'subtitle'} = GetRecordValue('subtitle', GetMarcBiblio($gettitle->{'biblionumber'}), GetFrameworkCode($gettitle->{'biblionumber'}));
$getreserv{'biblionumber'} = $gettitle->{'biblionumber'};
use C4::Auth;
use C4::Output;
use C4::Members;
use C4::Auth;
use C4::Output;
use C4::Members;
-use C4::Koha qw( getitemtypeinfo );
use C4::Circulation qw( GetIssuingCharges );
use C4::Reserves;
use C4::Items;
use Koha::Holds;
use C4::Circulation qw( GetIssuingCharges );
use C4::Reserves;
use C4::Items;
use Koha::Holds;
my $input = CGI->new;
my $borrowernumber = $input->param('borrowernumber');
my $input = CGI->new;
my $borrowernumber = $input->param('borrowernumber');
my ( $charge, $itemtype ) =
GetIssuingCharges( $issue->{itemnumber}, $borrowernumber );
my ( $charge, $itemtype ) =
GetIssuingCharges( $issue->{itemnumber}, $borrowernumber );
- my $itemtypeinfo = getitemtypeinfo($itemtype);
- $row{'itemtype_description'} = $itemtypeinfo->{description};
+ my $itemtype = Koha::ItemTypes->find( $itemtype );
+ $row{'itemtype_description'} = $itemtype->description; #FIXME Should not it be translated_description
$row{'charge'} = sprintf( "%.2f", $charge );
$row{'charge'} = sprintf( "%.2f", $charge );
use C4::Output;
use CGI qw ( -utf8 );
use C4::Biblio;
use C4::Output;
use CGI qw ( -utf8 );
use C4::Biblio;
-use C4::Koha; # use getitemtypeinfo
use C4::SocialData;
use C4::External::OverDrive;
use C4::SocialData;
use C4::External::OverDrive;
use Koha::LibraryCategories;
use Koha::Ratings;
use Koha::Virtualshelves;
use Koha::LibraryCategories;
use Koha::Ratings;
use Koha::Virtualshelves;
# add translated_description to itemtypes
foreach my $itemtype ( keys %{$itemtypes} ) {
# Itemtypes search categories don't have (yet) translated descriptions, they are auth values (and could still have no descriptions too BZ 18400)
# add translated_description to itemtypes
foreach my $itemtype ( keys %{$itemtypes} ) {
# Itemtypes search categories don't have (yet) translated descriptions, they are auth values (and could still have no descriptions too BZ 18400)
- my $translated_description = getitemtypeinfo( $itemtype, 'opac' )->{translated_description};
+ my $translated_description = Koha::ItemTypes->find( $itemtype )->translated_description;
$itemtypes->{$itemtype}->{translated_description} = $translated_description || $itemtypes->{$itemtype}->{description} || q{};
}
$itemtypes->{$itemtype}->{translated_description} = $translated_description || $itemtypes->{$itemtype}->{description} || q{};
}
use C4::XSLT;
use Koha::Biblioitems;
use C4::XSLT;
use Koha::Biblioitems;
use Koha::Virtualshelves;
use Koha::RecordProcessor;
use Koha::Virtualshelves;
use Koha::RecordProcessor;
my $marcflavour = C4::Context->preference("marcflavour");
my $itemtype = Koha::Biblioitems->search({ biblionumber => $content->biblionumber })->next->itemtype;
my $marcflavour = C4::Context->preference("marcflavour");
my $itemtype = Koha::Biblioitems->search({ biblionumber => $content->biblionumber })->next->itemtype;
- my $itemtypeinfo = getitemtypeinfo( $itemtype, 'opac' );
- $this_item->{imageurl} = $itemtypeinfo->{imageurl};
- $this_item->{description} = $itemtypeinfo->{description};
- $this_item->{notforloan} = $itemtypeinfo->{notforloan};
+ $itemtype = Koha::ItemTypes->find( $itemtype );
+ $this_item->{imageurl} = C4::Koha::getitemtypeimagelocation( 'opac', $itemtype->imageurl );
+ $this_item->{description} = $itemtype->description; #FIXME Should not it be translated_description?
+ $this_item->{notforloan} = $itemtype->notforloan;
$this_item->{'coins'} = GetCOinSBiblio($record);
$this_item->{'subtitle'} = GetRecordValue( 'subtitle', $record, GetFrameworkCode( $biblionumber ) );
$this_item->{'normalized_upc'} = GetNormalizedUPC( $record, $marcflavour );
$this_item->{'coins'} = GetCOinSBiblio($record);
$this_item->{'subtitle'} = GetRecordValue( 'subtitle', $record, GetFrameworkCode( $biblionumber ) );
$this_item->{'normalized_upc'} = GetNormalizedUPC( $record, $marcflavour );
use C4::Output;
use CGI qw ( -utf8 );
use C4::Biblio;
use C4::Output;
use CGI qw ( -utf8 );
use C4::Biblio;
-use C4::Koha; # use getitemtypeinfo
use Koha::AuthorisedValues;
use Koha::DateUtils;
use Koha::AuthorisedValues;
use Koha::DateUtils;
my ( $renewals_count, $renewals_allowed, $renewals_remaining ) =
GetRenewCount( $c->{borrowernumber}, $c->{itemnumber} );
my ( $renewals_count, $renewals_allowed, $renewals_remaining ) =
GetRenewCount( $c->{borrowernumber}, $c->{itemnumber} );
- my $itemtype = C4::Koha::getitemtypeinfo( $item_level_itypes ? $c->{itype} : $c->{itemtype} );
+ my $itemtype = Koha::ItemTypes->find( $item_level_itypes ? $c->{itype} : $c->{itemtype} );
my $location;
if ( $c->{location} ) {
my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $c->{location} });
my $location;
if ( $c->{location} ) {
my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $c->{location} });
author => $c->{author},
barcode => $c->{barcode},
itemtype => $item_level_itypes ? $c->{itype} : $c->{itemtype},
author => $c->{author},
barcode => $c->{barcode},
itemtype => $item_level_itypes ? $c->{itype} : $c->{itemtype},
- itemtype_description => $itemtype->{translated_description},
+ itemtype_description => $itemtype->translated_description,
location => $location,
homebranch => $c->{homebranch},
itemnotes => $c->{itemnotes},
location => $location,
homebranch => $c->{homebranch},
itemnotes => $c->{itemnotes},
use Koha::DateUtils;
use Koha::Holds;
use Koha::DateUtils;
use Koha::Holds;
use Koha::Libraries;
my $input = new CGI;
use Koha::Libraries;
my $input = new CGI;
my $itemtype_limit;
if ( $h->itemtype ) {
my $itemtype_limit;
if ( $h->itemtype ) {
- my $itemtype = C4::Koha::getitemtypeinfo( $h->itemtype );
- $itemtype_limit = $itemtype->{translated_description};
+ my $itemtype = Koha::ItemTypes->find( $h->itemtype );
+ $itemtype_limit = $itemtype->translated_description;
}
my $libraries = Koha::Libraries->search({}, { order_by => ['branchname'] })->unblessed;
}
my $libraries = Koha::Libraries->search({}, { order_by => ['branchname'] })->unblessed;
use Modern::Perl;
use DateTime::Format::MySQL;
use Modern::Perl;
use DateTime::Format::MySQL;
-use Test::More tests => 7;
+use Test::More tests => 6;
-subtest 'Itemtype info Tests' => sub {
- like ( getitemtypeinfo( $itype_1->{itemtype} )->{'imageurl'}, qr/intranet-tmpl/, 'getitemtypeinfo on unspecified interface returns intranet imageurl (legacy behavior)' );
- like ( getitemtypeinfo( $itype_1->{itemtype}, 'intranet')->{'imageurl'}, qr/intranet-tmpl/, 'getitemtypeinfo on "intranet" interface returns intranet imageurl' );
- like ( getitemtypeinfo( $itype_1->{itemtype}, 'opac')->{'imageurl'}, qr/opac-tmpl/, 'getitemtypeinfo on "opac" interface returns opac imageurl' );
-};
-
### test for C4::Koha->GetDailyQuote()
SKIP:
{
### test for C4::Koha->GetDailyQuote()
SKIP:
{
use Koha::Biblios;
use Koha::Biblioitems;
use Koha::Biblios;
use Koha::Biblioitems;
use Koha::CsvProfiles;
use Koha::Virtualshelves;
use Koha::CsvProfiles;
use Koha::Virtualshelves;
my $marcflavour = C4::Context->preference("marcflavour");
my $itemtype = Koha::Biblioitems->search({ biblionumber => $content->biblionumber })->next->itemtype;
my $marcflavour = C4::Context->preference("marcflavour");
my $itemtype = Koha::Biblioitems->search({ biblionumber => $content->biblionumber })->next->itemtype;
- my $itemtypeinfo = getitemtypeinfo( $itemtype, 'intranet' );
+ $itemtype = Koha::ItemTypes->find( $itemtype );
my $biblio = Koha::Biblios->find( $content->biblionumber );
$this_item->{title} = $biblio->title;
$this_item->{author} = $biblio->author;
$this_item->{dateadded} = $content->dateadded;
my $biblio = Koha::Biblios->find( $content->biblionumber );
$this_item->{title} = $biblio->title;
$this_item->{author} = $biblio->author;
$this_item->{dateadded} = $content->dateadded;
- $this_item->{imageurl} = $itemtypeinfo->{imageurl};
- $this_item->{description} = $itemtypeinfo->{description};
- $this_item->{notforloan} = $itemtypeinfo->{notforloan};
+ $this_item->{imageurl} = C4::Koha::getitemtypeimagelocation( 'intranet', $itemtype->imageurl );
+ $this_item->{description} = $itemtype->description; #FIXME Should not it be translated_description
+ $this_item->{notforloan} = $itemtype->notforloan;
$this_item->{'coins'} = GetCOinSBiblio($record);
$this_item->{'subtitle'} = GetRecordValue( 'subtitle', $record, GetFrameworkCode( $biblionumber ) );
$this_item->{'normalized_upc'} = GetNormalizedUPC( $record, $marcflavour );
$this_item->{'coins'} = GetCOinSBiblio($record);
$this_item->{'subtitle'} = GetRecordValue( 'subtitle', $record, GetFrameworkCode( $biblionumber ) );
$this_item->{'normalized_upc'} = GetNormalizedUPC( $record, $marcflavour );