#---- itemtypes
if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "itemtypes" ) {
- return getitemtypeinfo($value)->{description};
+ return getitemtypeinfo($value)->{translated_description};
}
#---- "true" authorized value
use strict;
use warnings;
use C4::Context;
+use C4::Languages;
use Encode qw( encode );
our $AUTOLOAD;
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($_);
}
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.*,
serial.serialseq,
serial.publisheddate,
itemtypes.description,
+ COALESCE( localization.translation, itemtypes.description ) AS translated_description,
itemtypes.notforloan as notforloan_per_itemtype,
holding.branchurl,
holding.branchname,
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;
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;
sub GetDescription {
my ( $self, $itemtype ) = @_;
- my $itemtype = C4::Koha::getitemtypeinfo( $itemtype );
+ $itemtype = C4::Koha::getitemtypeinfo( $itemtype );
return $itemtype->{translated_description};
}
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');
}
$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'};
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);
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->{$_} : '' );
$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;
<td>[% IF ( rule.default_humanitemtype ) %]
<em>All</em>
[% ELSE %]
- [% rule.humanitemtype %]
+ [% rule.translated_description %]
[% END %]
</td>
<td>[% IF ( rule.unlimited_maxissueqty ) %]
<select name="itemtype" id="matrixitemtype" style="width:13em;">
<option value="*">All</option>
[% FOREACH itemtypeloo IN itemtypeloop %]
- <option value="[% itemtypeloo.itemtype %]">[% itemtypeloo.description %]</option>
+ <option value="[% itemtypeloo.itemtype %]">[% itemtypeloo.translated_description %]</option>
[% END %]
</select>
</td>
<td>[% IF ( branch_item_rule_loo.default_humanitemtype ) %]
<em>Default</em>
[% ELSE %]
- [% branch_item_rule_loo.humanitemtype %]
+ [% branch_item_rule_loo.translated_description %]
[% END %]
</td>
<td>[% IF ( branch_item_rule_loo.holdallowed_any ) %]
<td>
<select name="itemtype">
[% FOREACH itemtypeloo IN itemtypeloop %]
- <option value="[% itemtypeloo.itemtype %]">[% itemtypeloo.description %]</option>
+ <option value="[% itemtypeloo.itemtype %]">[% itemtypeloo.translated_description %]</option>
[% END %]
</select>
</td>
[% FOREACH subtitl IN subtitle %]
<h4>[% subtitl.subfield %]</h4>
[% END %]
- [% UNLESS ( item_level_itypes ) %]<img src="[% imageurl %]" alt="[% description %]" title="[% description %]">[% END %]
+ [% UNLESS ( item_level_itypes ) %]<img src="[% imageurl %]" alt="[% translated_description %]" title="[% translated_description %]">[% END %]
[% IF ( unititle ) %]<p>[% unititle |html %]</p>[% END %]
[% IF ( author ) %]<p>By <a href="/cgi-bin/koha/catalogue/search.pl?q=au:[% author |url %]">[% author %]</a></p>[% END %]
<ul>
[% IF ( item_level_itypes ) %]
<td class="itype">
[% IF !noItemTypeImages && item.imageurl %]
- <img src="[% item.imageurl %]" alt="[% item.description %]" title="[% item.description %]" />
+ <img src="[% item.imageurl %]" alt="[% item.translated_description %]" title="[% item.translated_description %]" />
[% END %]
- [% item.description %]
+ [% item.translated_description %]
</td>
[% END %]
<td class="location">[% UNLESS ( singlebranchmode ) %][% item.branchname %] [% END %]</td>
<td>
<select name="Filter" size="1" id="itemtypes">
<option value="">All item types</option>
- [% FOREACH value IN ItemTypes.values %]
- <option value="[% value %]">[% ItemTypes.labels.$value %]</option>
+ [% FOREACH itemtype IN itemtypes %]
+ <option value="[% itemtype.itemtype %]">[% itemtype.translated_description %]</option>
[% END %]
</select>
</td>
<li>
<label for="documenttype">Item type: </label><select name="Filter" id="documenttype"><option value="" > Any item type</option>
[% FOREACH itemtypeloo IN itemtypeloop %]
- <option value="[% itemtypeloo.value %]" >[% itemtypeloo.description %] </option>
+ <option value="[% itemtypeloo.value %]" >[% itemtypeloo.translated_description %] </option>
[% END %]
</select>
</li>
<td><input type="radio" name="Column" value="[% item_itype %]" /></td>
<td><select name="Filter" id="[% item_itype %]">
<option value=""> </option>
- [% FOREACH CGIItemTyp IN CGIItemType %]
- [% IF ( CGIItemTyp.selected ) %]
- <option value="[% CGIItemTyp.itemtype %]" selected="selected">[% CGIItemTyp.description %]</option>[% ELSE %]<option value="[% CGIItemTyp.itemtype %]">[% CGIItemTyp.description %]</option>[% END %]
-
- [% END %]
+ [% FOREACH itemtype IN itemtypes %]
+ <option value="[% itemtype.itemtype %]">[% itemtype.translated_description %]</option>
+ [% END %]
</select>
</td>
</tr>
<td>
<select name="Filter" size="1" id="itemtypes">
<option value=""></option>
- [% FOREACH value IN ItemType.values %]
- <option value="[%- value -%]">[%- ItemType.labels.$value -%]</option>
+ [% FOREACH itemtype IN itemtypes %]
+ <option value="[%- itemtype.itemtype -%]">[%- itemtype.translated_description -%]</option>
[% END %]
</select>
</td>
+[% USE ItemTypes %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha › Reports › Catalog by item types</title>
[% INCLUDE 'doc-head-close.inc' %]
<tbody>
[% FOREACH loopitemtyp IN mainloo.loopitemtype %]
<tr>
- <td>[% loopitemtyp.itemtype %]</td>
+ <td>[% ItemTypes.GetDescription( loopitemtyp.itemtype ) %]</td>
<td>[% loopitemtyp.count %]</td>
</tr>
[% END %]
<li><span class="label">Collection title:</span>[% collectiontitle |html %]</li>
<li><span class="label">Document type:</span>
[% FOREACH itemtypeloo IN itemtypeloop %]
- [% IF ( itemtypeloo.selected ) %][% itemtypeloo.description %][% END %]
+ [% IF ( itemtypeloo.selected ) %][% itemtypeloo.translated_description %][% END %]
[% END %]
</li>
[% IF ( patron_reason_loop ) %]
<select id="itemtype" name="itemtype" >
[% FOREACH itemtypeloo IN itemtypeloop %]
[% IF ( itemtypeloo.selected ) %]<option selected="selected" value="[% itemtypeloo.itemtype %]">[% ELSE %]<option value="[% itemtypeloo.itemtype %]">[% END %]
- [% itemtypeloo.description %]</option>
+ [% itemtypeloo.translated_description %]</option>
[% END %]
</select>
</li>
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');
}
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->{$_});
$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;
$template->param(
booksellers => $booksellers,
- ItemTypes => $ItemTypes,
+ itemtypes => $itemtypes,
Budgets => $Budgets,
hassort1 => $hassort1,
hassort2 => $hassort2,
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;
}
#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;
}
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},
};
}
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;
$template->param(hasdewey=>$hasdewey,
haslccn => $haslccn,
hascote => $hascote,
- CGIItemType => $CGIitemtype,
+ itemtypes => $itemtypes,
CGIBranch => GetBranchesLoop(C4::Context->userenv->{'branch'}),
locationloop => \@locations,
authvals => \@authvals,
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;
$template->param(
BorCat => $BorCat,
- ItemType => $ItemTypes,
+ itemtypes => $itemtypes,
branchloop => GetBranchesLoop(),
hassort1 => $hassort1,
hassort2 => $hassort2,
# create itemtype arrayref for <select>.
my @itemtypeloop;
-for my $itype ( sort {$itemtypes->{$a}->{description} cmp $itemtypes->{$b}->{description}} keys(%$itemtypes)) {
- push @itemtypeloop, { code => $itype , description => $itemtypes->{$itype}->{description} } ;
+for my $itype ( sort {$itemtypes->{$a}->{translated_description} cmp $itemtypes->{$b}->{translated_description}} keys(%$itemtypes)) {
+ push @itemtypeloop, { code => $itype , description => $itemtypes->{$itype}->{translated_description} } ;
}
# location list
# getting all itemtypes
my $itemtypes = &GetItemTypes();
my @itemtypesloop;
-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 @itemtypesloop, \%row;
}
if ($branch) {
if (C4::Context->preference('item-level_itypes')) {
$sth = $dbh->prepare("
- SELECT description, items.itype as itemtype, COUNT(*) AS total
+ SELECT itemtype, description, items.itype as itemtype, COUNT(*) AS total
FROM itemtypes,items
WHERE items.itype=itemtypes.itemtype
AND items.holdingbranch=?
}
else {
$sth = $dbh->prepare("
- SELECT description, biblioitems.itemtype, COUNT(*) AS total
+ SELECT itemtype, description, biblioitems.itemtype, COUNT(*) AS total
FROM itemtypes, biblioitems, items
WHERE biblioitems.itemtype=itemtypes.itemtype
AND items.biblioitemnumber=biblioitems.biblioitemnumber
} else {
if (C4::Context->preference('item-level_itypes')) {
$sth = $dbh->prepare("
- SELECT description,items.itype AS itemtype, COUNT(*) AS total
+ SELECT itemtype, description,items.itype AS itemtype, COUNT(*) AS total
FROM itemtypes,items
WHERE items.itype=itemtypes.itemtype
GROUP BY items.itype
ORDER BY itemtypes.description");
}
else {
- $sth = $dbh->prepare("SELECT description, biblioitems.itemtype, COUNT(*) AS total
+ $sth = $dbh->prepare("SELECT itemtype, description, biblioitems.itemtype, COUNT(*) AS total
FROM itemtypes, biblioitems,items
WHERE biblioitems.itemtype=itemtypes.itemtype
AND biblioitems.biblioitemnumber = items.biblioitemnumber
}
$sth->execute;
}
- my ($description,$biblioitems,$total);
+ my ($itemtype, $description,$biblioitems,$total);
my $grantotal = 0;
my $count = 0;
- while (($description,$biblioitems,$total) = $sth->fetchrow) {
+ while (($itemtype, $description,$biblioitems,$total) = $sth->fetchrow) {
my %line;
if($count % 2){
$line{toggle} = 1;
} else {
$line{toggle} = 0;
}
- $line{itemtype} = $description;
+ $line{itemtype} = $itemtype;
$line{count} = $total;
$grantotal += $total;
push @results,\%line;
# create itemtype arrayref for <select>.
my @itemtypeloop;
-for my $itype ( sort {$itemtypes->{$a}->{description} cmp $itemtypes->{$b}->{description}} keys(%$itemtypes)) {
- push @itemtypeloop, { code => $itype , description => $itemtypes->{$itype}->{description} } ;
+for my $itype ( sort {$itemtypes->{$a}->{translated_description} cmp $itemtypes->{$b}->{translated_description}} keys(%$itemtypes)) {
+ push @itemtypeloop, { code => $itype , description => $itemtypes->{$itype}->{translated_description} } ;
}
# location list
foreach my $thisitemtype ( sort keys %$itemtypes ) {
my %row = (
value => $thisitemtype,
- description => $itemtypes->{$thisitemtype}->{'description'},
+ description => $itemtypes->{$thisitemtype}->{translated_description},
);
push @itemtypesloop, \%row;
}