@@ -, +, @@
+admin/smart-rules.pl
+catalogue/detail.pl
+catalogue/itemsearch.pl
+catalogue/moredetail.pl
+reports/acquisitions_stats.pl
+reports/bor_issues_top.pl
+reports/cat_issues_top.pl
+reports/catalogue_out.pl
+reports/catalogue_stats.pl
+reports/issues_avg_stats.pl
+reports/issues_stats.pl
+reports/itemslost.pl
+reports/manager.pl
+reports/reserves_stats.pl
+suggestion/suggestion.pl
+tools/export.pl
+Opac:
+opac-detail.pl
+opac-MARCdetail.pl
+opac-search.pl
---
C4/Biblio.pm | 2 +-
C4/ItemType.pm | 13 +++++++++++--
C4/Items.pm | 10 +++++++++-
C4/Koha.pm | 9 +--------
Koha/Template/Plugin/ItemTypes.pm | 2 +-
admin/smart-rules.pl | 19 ++++++++++---------
catalogue/itemsearch.pl | 2 +-
catalogue/moredetail.pl | 4 ++--
.../prog/en/modules/admin/smart-rules.tt | 8 ++++----
.../intranet-tmpl/prog/en/modules/catalogue/detail.tt | 6 +++---
.../prog/en/modules/reports/acquisitions_stats.tt | 4 ++--
.../prog/en/modules/reports/bor_issues_top.tt | 2 +-
.../prog/en/modules/reports/catalogue_stats.tt | 8 +++-----
.../prog/en/modules/reports/issues_avg_stats.tt | 4 ++--
.../prog/en/modules/reports/itemtypes.tt | 3 ++-
.../prog/en/modules/suggestion/suggestion.tt | 4 ++--
opac/opac-detail.pl | 4 ++--
reports/acquisitions_stats.pl | 15 ++-------------
reports/bor_issues_top.pl | 4 ++--
reports/cat_issues_top.pl | 4 ++--
reports/catalogue_out.pl | 4 ++--
reports/catalogue_stats.pl | 6 ++----
reports/issues_avg_stats.pl | 19 ++++---------------
reports/issues_stats.pl | 4 ++--
reports/itemslost.pl | 4 ++--
reports/itemtypes.plugin | 14 +++++++-------
reports/reserves_stats.pl | 4 ++--
tools/export.pl | 2 +-
28 files changed, 85 insertions(+), 99 deletions(-)
--- a/C4/Biblio.pm
+++ a/C4/Biblio.pm
@@ -1658,7 +1658,7 @@ sub GetAuthorisedValueDesc {
#---- itemtypes
if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "itemtypes" ) {
- return getitemtypeinfo($value)->{description};
+ return getitemtypeinfo($value)->{translated_description};
}
#---- "true" authorized value
--- a/C4/ItemType.pm
+++ a/C4/ItemType.pm
@@ -21,6 +21,7 @@ package C4::ItemType;
use strict;
use warnings;
use C4::Context;
+use C4::Languages;
use Encode qw( encode );
our $AUTOLOAD;
@@ -78,9 +79,17 @@ sub all {
my ($class) = @_;
my $dbh = C4::Context->dbh;
+ my $language = C4::Languages::getlanguage();
my @itypes;
- for ( @{$dbh->selectall_arrayref(
- "SELECT * FROM itemtypes ORDER BY description", { Slice => {} })} )
+ 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($_);
}
--- a/C4/Items.pm
+++ a/C4/Items.pm
@@ -1301,6 +1301,7 @@ sub GetItemsInfo {
my ( $biblionumber ) = @_;
my $dbh = C4::Context->dbh;
# note biblioitems.* must be avoided to prevent large marc and marcxml fields from killing performance.
+ my $language = C4::Languages::getlanguage();
my $query = "
SELECT items.*,
biblio.*,
@@ -1326,6 +1327,7 @@ sub GetItemsInfo {
serial.serialseq,
serial.publisheddate,
itemtypes.description,
+ COALESCE( localization.translation, itemtypes.description ) AS translated_description,
itemtypes.notforloan as notforloan_per_itemtype,
holding.branchurl,
holding.branchname,
@@ -1344,9 +1346,15 @@ sub GetItemsInfo {
LEFT JOIN serial USING (serialid)
LEFT JOIN itemtypes ON itemtypes.itemtype = "
. (C4::Context->preference('item-level_itypes') ? 'items.itype' : 'biblioitems.itemtype');
+ $query .= q|
+ LEFT JOIN localization ON itemtypes.itemtype = localization.code
+ AND localization.entity = 'itemtypes'
+ AND localization.lang = ?
+ |;
+
$query .= " WHERE items.biblionumber = ? ORDER BY home.branchname, items.enumchron, LPAD( items.copynumber, 8, '0' ), items.dateaccessioned DESC" ;
my $sth = $dbh->prepare($query);
- $sth->execute($biblionumber);
+ $sth->execute($language, $biblionumber);
my $i = 0;
my @results;
my $serial;
--- a/C4/Koha.pm
+++ a/C4/Koha.pm
@@ -194,14 +194,7 @@ build a HTML select with the following code :
sub GetSupportList{
my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes");
if (!$advanced_search_types or $advanced_search_types =~ /itemtypes/) {
- my $query = qq|
- SELECT *
- FROM itemtypes
- order by description
- |;
- my $sth = C4::Context->dbh->prepare($query);
- $sth->execute;
- return $sth->fetchall_arrayref({});
+ return GetItemTypes( style => 'array' );
} else {
my $advsearchtypes = GetAuthorisedValues($advanced_search_types);
my @results= map {{itemtype=>$$_{authorised_value},description=>$$_{lib},imageurl=>$$_{imageurl}}} @$advsearchtypes;
--- a/Koha/Template/Plugin/ItemTypes.pm
+++ a/Koha/Template/Plugin/ItemTypes.pm
@@ -27,7 +27,7 @@ use C4::Koha;
sub GetDescription {
my ( $self, $itemtype ) = @_;
- my $itemtype = C4::Koha::getitemtypeinfo( $itemtype );
+ $itemtype = C4::Koha::getitemtypeinfo( $itemtype );
return $itemtype->{translated_description};
}
--- a/admin/smart-rules.pl
+++ a/admin/smart-rules.pl
@@ -46,6 +46,7 @@ my ($template, $loggedinuser, $cookie)
my $type=$input->param('type');
my $branch = $input->param('branch') || ( C4::Branch::onlymine() ? ( C4::Branch::mybranch() || '*' ) : '*' );
my $op = $input->param('op') || q{};
+my $language = C4::Languages::getlanguage();
if ($op eq 'delete') {
my $itemtype = $input->param('itemtype');
@@ -419,25 +420,25 @@ while (my $data=$sth->fetchrow_hashref){
}
$sth->finish;
-$sth=$dbh->prepare("SELECT description,itemtype FROM itemtypes ORDER BY description");
-$sth->execute;
-# $i=0;
my @row_loop;
-my @itemtypes;
-while (my $row=$sth->fetchrow_hashref){
- push @itemtypes,$row;
-}
+my @itemtypes = @{ GetItemTypes( style => 'array' ) };
my $sth2 = $dbh->prepare("
- SELECT issuingrules.*, itemtypes.description AS humanitemtype, categories.description AS humancategorycode
+ SELECT issuingrules.*,
+ itemtypes.description AS humanitemtype,
+ categories.description AS humancategorycode,
+ COALESCE( localization.translation, itemtypes.description ) AS translated_description
FROM issuingrules
LEFT JOIN itemtypes
ON (itemtypes.itemtype = issuingrules.itemtype)
LEFT JOIN categories
ON (categories.categorycode = issuingrules.categorycode)
+ LEFT JOIN localization ON issuingrules.itemtype = localization.code
+ AND localization.entity = 'itemtypes'
+ AND localization.lang = ?
WHERE issuingrules.branchcode = ?
");
-$sth2->execute($branch);
+$sth2->execute($language, $branch);
while (my $row = $sth2->fetchrow_hashref) {
$row->{'current_branch'} ||= $row->{'branchcode'};
--- a/catalogue/itemsearch.pl
+++ a/catalogue/itemsearch.pl
@@ -258,7 +258,7 @@ if ($format eq 'html') {
my @itemtypes = C4::ItemType->all();
foreach my $itemtype (@itemtypes) {
$itemtype->{value} = $itemtype->{itemtype};
- $itemtype->{label} = $itemtype->{description};
+ $itemtype->{label} = $itemtype->{translated_description};
}
my $ccode_avcode = GetAuthValCode('items.ccode') || 'CCODE';
my $ccodes = GetAuthorisedValues($ccode_avcode);
--- a/catalogue/moredetail.pl
+++ a/catalogue/moredetail.pl
@@ -127,7 +127,7 @@ my $ccodes= GetKohaAuthorisedValues('items.ccode',$fw);
my $copynumbers = GetKohaAuthorisedValues('items.copynumber',$fw);
my $itemtypes = GetItemTypes;
-$data->{'itemtypename'} = $itemtypes->{$data->{'itemtype'}}->{'description'};
+$data->{'itemtypename'} = $itemtypes->{$data->{'itemtype'}}->{'translated_description'};
$data->{'rentalcharge'} = sprintf( "%.2f", $data->{'rentalcharge'} );
foreach ( keys %{$data} ) {
$template->param( "$_" => defined $data->{$_} ? $data->{$_} : '' );
@@ -138,7 +138,7 @@ foreach my $item (@items){
$item->{itemlostloop}= GetAuthorisedValues(GetAuthValCode('items.itemlost',$fw),$item->{itemlost}) if GetAuthValCode('items.itemlost',$fw);
$item->{itemdamagedloop}= GetAuthorisedValues(GetAuthValCode('items.damaged',$fw),$item->{damaged}) if GetAuthValCode('items.damaged',$fw);
$item->{'collection'} = $ccodes->{ $item->{ccode} } if ($ccodes);
- $item->{'itype'} = $itemtypes->{ $item->{'itype'} }->{'description'};
+ $item->{'itype'} = $itemtypes->{ $item->{'itype'} }->{'translated_description'};
$item->{'replacementprice'} = sprintf( "%.2f", $item->{'replacementprice'} );
if ( defined $item->{'copynumber'} ) {
$item->{'displaycopy'} = 1;
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt
@@ -176,7 +176,7 @@ for="tobranch">Clone these rules to: Clone these rules to:
[% FOREACH itemtypeloo IN itemtypeloop %]
-
+
[% END %]
@@ -530,7 +530,7 @@ for="tobranch">Clone these rules to: Clone these rules to:
[% FOREACH itemtypeloo IN itemtypeloop %]
-
+
[% END %]
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
@@ -402,7 +402,7 @@ function verify_images() {
[% FOREACH subtitl IN subtitle %]
[% subtitl.subfield %]
[% END %]
- [% UNLESS ( item_level_itypes ) %][% END %]
+ [% UNLESS ( item_level_itypes ) %][% END %]
[% IF ( unititle ) %][% unititle |html %]
[% END %]
[% IF ( author ) %]By [% author %]
[% END %]
@@ -619,9 +619,9 @@ function verify_images() {
[% IF ( item_level_itypes ) %]
[% IF !noItemTypeImages && item.imageurl %]
-
+
[% END %]
- [% item.description %]
+ [% item.translated_description %]
|
[% END %]
[% UNLESS ( singlebranchmode ) %][% item.branchname %] [% END %] |
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/acquisitions_stats.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/acquisitions_stats.tt
@@ -223,8 +223,8 @@
|
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/bor_issues_top.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/bor_issues_top.tt
@@ -148,7 +148,7 @@ function Dopop(link) {
-
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/catalogue_stats.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/catalogue_stats.tt
@@ -164,11 +164,9 @@
|
|
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/issues_avg_stats.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/issues_avg_stats.tt
@@ -168,8 +168,8 @@
|
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemtypes.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemtypes.tt
@@ -1,3 +1,4 @@
+[% USE ItemTypes %]
[% INCLUDE 'doc-head-open.inc' %]
Koha › Reports › Catalog by item types
[% INCLUDE 'doc-head-close.inc' %]
@@ -47,7 +48,7 @@ $(document).ready(function(){
[% FOREACH loopitemtyp IN mainloo.loopitemtype %]
- [% loopitemtyp.itemtype %] |
+ [% ItemTypes.GetDescription( loopitemtyp.itemtype ) %] |
[% loopitemtyp.count %] |
[% END %]
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt
@@ -214,7 +214,7 @@ h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o
- Collection title:[% collectiontitle |html %]
- Document type:
[% FOREACH itemtypeloo IN itemtypeloop %]
- [% IF ( itemtypeloo.selected ) %][% itemtypeloo.description %][% END %]
+ [% IF ( itemtypeloo.selected ) %][% itemtypeloo.translated_description %][% END %]
[% END %]
[% IF ( patron_reason_loop ) %]
@@ -339,7 +339,7 @@ h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o
--- a/opac/opac-detail.pl
+++ a/opac/opac-detail.pl
@@ -521,7 +521,7 @@ my $itemtypes = GetItemTypes();
my $itemtype = $dat->{'itemtype'};
if ( $itemtype ) {
$dat->{'imageurl'} = getitemtypeimagelocation( 'opac', $itemtypes->{$itemtype}->{'imageurl'} );
- $dat->{'description'} = $itemtypes->{$itemtype}->{'description'};
+ $dat->{'description'} = $itemtypes->{$itemtype}->{translated_description};
}
my $shelflocations =GetKohaAuthorisedValues('items.location',$dat->{'frameworkcode'}, 'opac');
my $collections = GetKohaAuthorisedValues('items.ccode',$dat->{'frameworkcode'}, 'opac');
@@ -647,7 +647,7 @@ if ( not $viewallitems and @items > $max_items_to_display ) {
}
if (exists $itm->{itype} && defined($itm->{itype}) && exists $itemtypes->{ $itm->{itype} }) {
$itm->{'imageurl'} = getitemtypeimagelocation( 'opac', $itemtypes->{ $itm->{itype} }->{'imageurl'} );
- $itm->{'description'} = $itemtypes->{ $itm->{itype} }->{'description'};
+ $itm->{'description'} = $itemtypes->{ $itm->{itype} }->{translated_description};
}
foreach (qw(ccode enumchron copynumber itemnotes uri)) {
$itemfields{$_} = 1 if ($itm->{$_});
--- a/reports/acquisitions_stats.pl
+++ a/reports/acquisitions_stats.pl
@@ -124,18 +124,7 @@ else {
$req->execute;
my $booksellers = $req->fetchall_arrayref({});
- $req = $dbh->prepare("SELECT DISTINCTROW itemtype,description FROM itemtypes ORDER BY description");
- $req->execute;
- my @iselect;
- my %iselect;
- while ( my ( $value, $desc ) = $req->fetchrow ) {
- push @iselect, $value;
- $iselect{$value} = $desc;
- }
- my $ItemTypes = {
- values => \@iselect,
- labels => \%iselect,
- };
+ my $itemtypes = GetItemTypes( style => 'array' );
$req = $dbh->prepare("SELECT DISTINCTROW budget_code, budget_name FROM aqbudgets ORDER BY budget_name");
$req->execute;
@@ -212,7 +201,7 @@ else {
$template->param(
booksellers => $booksellers,
- ItemTypes => $ItemTypes,
+ itemtypes => $itemtypes,
Budgets => $Budgets,
hassort1 => $hassort1,
hassort2 => $hassort2,
--- a/reports/bor_issues_top.pl
+++ a/reports/bor_issues_top.pl
@@ -123,9 +123,9 @@ foreach (sort keys %$branches) {
my $itemtypes = GetItemTypes;
my @itemtypeloop;
-foreach (sort {$itemtypes->{$a}->{description} cmp $itemtypes->{$b}->{description}} keys %$itemtypes) {
+foreach (sort {$itemtypes->{$a}->{translated_description} cmp $itemtypes->{$b}->{translated_description}} keys %$itemtypes) {
my %row = (value => $_,
- description => $itemtypes->{$_}->{description},
+ description => $itemtypes->{$_}->{translated_description},
);
push @itemtypeloop, \%row;
}
--- a/reports/cat_issues_top.pl
+++ a/reports/cat_issues_top.pl
@@ -123,9 +123,9 @@ if ($do_it) {
#doctype
my $itemtypes = GetItemTypes;
my @itemtypeloop;
- foreach my $thisitemtype ( sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'}} keys %$itemtypes) {
+ foreach my $thisitemtype ( sort {$itemtypes->{$a}->{translated_description} cmp $itemtypes->{$b}->{translated_description}} keys %$itemtypes) {
my %row =(value => $thisitemtype,
- description => $itemtypes->{$thisitemtype}->{'description'},
+ description => $itemtypes->{$thisitemtype}->{translated_description},
);
push @itemtypeloop, \%row;
}
--- a/reports/catalogue_out.pl
+++ a/reports/catalogue_out.pl
@@ -65,14 +65,14 @@ if ($do_it) {
my $itemtypes = GetItemTypes();
my @itemtypeloop;
foreach (
- sort { $itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'} }
+ sort { $itemtypes->{$a}->{translated_description} cmp $itemtypes->{$b}->{translated_description} }
keys %$itemtypes
)
{
push @itemtypeloop,
{
value => $_,
- description => $itemtypes->{$_}->{'description'},
+ description => $itemtypes->{$_}->{translated_description},
};
}
--- a/reports/catalogue_stats.pl
+++ a/reports/catalogue_stats.pl
@@ -146,9 +146,7 @@ if ($do_it) {
my $hascote = 1;
my $highcote = 5;
- $req = $dbh->prepare("select itemtype, description from itemtypes order by description");
- $req->execute;
- my $CGIitemtype = $req->fetchall_arrayref({});
+ my $itemtypes = GetItemTypes( style => 'array' );
my $authvals = GetKohaAuthorisedValues("items.ccode");
my @authvals;
@@ -167,7 +165,7 @@ if ($do_it) {
$template->param(hasdewey=>$hasdewey,
haslccn => $haslccn,
hascote => $hascote,
- CGIItemType => $CGIitemtype,
+ itemtypes => $itemtypes,
CGIBranch => GetBranchesLoop(C4::Context->userenv->{'branch'}),
locationloop => \@locations,
authvals => \@authvals,
--- a/reports/issues_avg_stats.pl
+++ a/reports/issues_avg_stats.pl
@@ -134,20 +134,9 @@ if ($do_it) {
values => \@selectc,
labels => \%labelsc,
};
-
- $req = $dbh->prepare( "select distinctrow itemtype,description from itemtypes order by description");
- $req->execute;
- my @selecti;
- my %labelsi;
- while (my ($value,$desc) =$req->fetchrow) {
- push @selecti, $value;
- $labelsi{$value}=$desc;
- }
- my $ItemTypes = {
- values => \@selecti,
- labels => \%labelsi,
- };
-
+
+ my $itemtypes = GetItemTypes( style => 'array' );
+
$req = $dbh->prepare("select distinctrow sort1 from borrowers where sort1 is not null order by sort1");
$req->execute;
my @selects1;
@@ -178,7 +167,7 @@ if ($do_it) {
$template->param(
BorCat => $BorCat,
- ItemType => $ItemTypes,
+ itemtypes => $itemtypes,
branchloop => GetBranchesLoop(),
hassort1 => $hassort1,
hassort2 => $hassort2,
--- a/reports/issues_stats.pl
+++ a/reports/issues_stats.pl
@@ -133,8 +133,8 @@ my %select;
# create itemtype arrayref for