Bug 17835: Replace GetItemTypes with Koha::ItemTypes

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Lari Taskula <lari.taskula@jns.fi>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2017-01-03 11:05:15 +01:00 committed by Kyle M Hall
parent 53ce807f6e
commit 8d5b4306e0
45 changed files with 131 additions and 167 deletions

View File

@ -41,6 +41,7 @@ use Koha::Database;
use Koha::Biblioitems;
use Koha::Items;
use Koha::ItemTypes;
use Koha::SearchEngine;
use Koha::SearchEngine::Search;
use Koha::Libraries;
@ -2892,12 +2893,12 @@ sub PrepareItemrecordDisplay {
#----- itemtypes
} elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" ) {
my $itemtypes = GetItemTypes( style => 'array' );
my $itemtypes = Koha::ItemTypes->search_with_localization;
push @authorised_values, ""
unless ( $tagslib->{$tag}->{$subfield}->{mandatory} );
for my $itemtype ( @$itemtypes ) {
push @authorised_values, $itemtype->{itemtype};
$authorised_lib{$itemtype->{itemtype}} = $itemtype->{translated_description};
while ( my $itemtype = $itemtypes->next ) {
push @authorised_values, $itemtype->itemtype;
$authorised_lib{$itemtype->itemtype} = $itemtype->translated_description;
}
if ($defaultvalues && $defaultvalues->{'itemtype'}) {
$defaultvalue = $defaultvalues->{'itemtype'};

View File

@ -31,6 +31,7 @@ use C4::Reserves; # GetReserveStatus
use C4::Debug;
use C4::Charset;
use Koha::AuthorisedValues;
use Koha::ItemTypes;
use Koha::Libraries;
use Koha::Patrons;
use YAML;
@ -1867,7 +1868,8 @@ sub searchResults {
my $notforloan_authorised_value = $av->count ? $av->next->authorised_value : undef;
#Get itemtype hash
my %itemtypes = %{ GetItemTypes() };
my $itemtypes = Koha::ItemTypes->search_with_localization;
my %itemtypes = map { $_->{itemtype} => $_ } @{ $itemtypes->unblessed };
#search item field code
my ($itemtag, undef) = &GetMarcFromKohaField( "items.itemnumber", "" );

View File

@ -30,6 +30,7 @@ use C4::Biblio;
use C4::Circulation;
use C4::Reserves;
use Koha::AuthorisedValues;
use Koha::ItemTypes;
use Koha::XSLT_Handler;
use Koha::Libraries;
@ -280,7 +281,7 @@ sub buildKohaItemsNamespace {
my %branches = map { $_->branchcode => $_->branchname } Koha::Libraries->search({}, { order_by => 'branchname' });
my $itemtypes = GetItemTypes();
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
my $location = "";
my $ccode = "";
my $xml = '';

View File

@ -23,6 +23,7 @@ use Template::Plugin;
use base qw( Template::Plugin );
use C4::Koha;
use Koha::ItemTypes;
sub GetDescription {
my ( $self, $itemtype ) = @_;
@ -33,9 +34,7 @@ sub GetDescription {
}
sub Get {
my @itemtypes = @{ GetItemTypes(style => 'array') };
@itemtypes = sort { $a->{description} cmp $b->{description} } @itemtypes;
return \@itemtypes;
return Koha::ItemTypes->search_with_localization->unblessed;
}
1;

View File

@ -56,6 +56,7 @@ use C4::Members qw/GetMember/;
use Koha::EDI qw/create_edi_order get_edifact_ean/;
use Koha::Acquisition::Booksellers;
use Koha::ItemTypes;
our $input=new CGI;
@ -174,7 +175,6 @@ sub printbasketgrouppdf{
$ord->{total_tax_excluded} = $ord->{ecost_tax_excluded} * $ord->{quantity};
my $bib = GetBiblioData($ord->{biblionumber});
my $itemtypes = GetItemTypes();
#FIXME DELETE ME
# 0 1 2 3 4 5 6 7 8 9
@ -195,7 +195,7 @@ sub printbasketgrouppdf{
}
}
$ord->{itemtype} = ( $ord->{itemtype} and $bib->{itemtype} ) ? $itemtypes->{$bib->{itemtype}}->{description} : undef;
$ord->{itemtype} = ( $ord->{itemtype} and $bib->{itemtype} ) ? Koha::ItemTypes->find( $bib->{itemtype} )->description : undef;
$ord->{en} = $en ? $en : undef;
$ord->{edition} = $edition ? $edition : undef;

View File

@ -63,7 +63,6 @@ use warnings;
use CGI qw ( -utf8 );
use C4::Context;
use C4::Koha; # GetItemTypes
use C4::Acquisition;
use C4::Auth;
use C4::Output;

View File

@ -468,8 +468,7 @@ $template->param(
my $patron_categories = Koha::Patron::Categories->search({}, { order_by => ['description'] });
my @row_loop;
my @itemtypes = @{ GetItemTypes( style => 'array' ) };
@itemtypes = sort { lc $a->{translated_description} cmp lc $b->{translated_description} } @itemtypes;
my $itemtypes = Koha::ItemTypes->search_with_localization;
my $sth2 = $dbh->prepare("
SELECT issuingrules.*,
@ -616,7 +615,7 @@ $template->param(default_rules => ($defaults ? 1 : 0));
$template->param(
patron_categories => $patron_categories,
itemtypeloop => \@itemtypes,
itemtypeloop => $itemtypes,
rules => \@sorted_row_loop,
humanbranch => ($branch ne '*' ? $branch : ''),
current_branch => $branch,

View File

@ -32,6 +32,7 @@ use MARC::File::USMARC;
use MARC::File::XML;
use C4::Biblio;
use Koha::Authority::Types;
use Koha::ItemTypes;
use vars qw( $tagslib);
use vars qw( $authorised_values_sth);
use vars qw( $is_a_modif );
@ -91,10 +92,10 @@ sub build_authorized_values_list {
&& ( $value || $tagslib->{$tag}->{$subfield}->{defaultvalue} ) );
my $itemtype;
my $itemtypes = GetItemTypes( style => 'array' );
for my $itemtype ( @$itemtypes ) {
push @authorised_values, $itemtype->{itemtype};
$authorised_lib{$itemtype->{itemtype}} = $itemtype->{translated_description};
my $itemtypes = Koha::ItemTypes->search_with_localization;
while ( $itemtype = $itemtypes->next ) {
push @authorised_values, $itemtype->itemtype;
$authorised_lib{$itemtype->itemtype} = $itemtype->translated_description;
}
$value = $itemtype unless ($value);

View File

@ -44,6 +44,7 @@ use C4::Acquisition qw(GetOrdersByBiblionumber);
use Koha::AuthorisedValues;
use Koha::Biblios;
use Koha::Items;
use Koha::ItemTypes;
use Koha::Patrons;
use Koha::Virtualshelves;
@ -129,8 +130,8 @@ my $marcurlsarray = GetMarcUrls ($record,$marcflavour);
my $marchostsarray = GetMarcHosts($record,$marcflavour);
my $subtitle = GetRecordValue('subtitle', $record, $fw);
# Get Branches, Itemtypes and Locations
my $itemtypes = GetItemTypes();
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } };
my $dbh = C4::Context->dbh;
my @all_items = GetItemsInfo( $biblionumber );

View File

@ -124,7 +124,8 @@ my $ccodes =
{ map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.ccode' } ) };
my $copynumbers =
{ map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.copynumber' } ) };
my $itemtypes = GetItemTypes;
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
$data->{'itemtypename'} = $itemtypes->{$data->{'itemtype'}}->{'translated_description'};
$data->{'rentalcharge'} = sprintf( "%.2f", $data->{'rentalcharge'} );

View File

@ -151,6 +151,7 @@ use URI::Escape;
use POSIX qw(ceil floor);
use C4::Search::History;
use Koha::ItemTypes;
use Koha::LibraryCategories;
use Koha::Virtualshelves;
use Koha::SearchEngine::Search;
@ -221,7 +222,7 @@ $template->param(
);
# load the Type stuff
my $itemtypes = GetItemTypes;
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
# the index parameter is different for item-level itemtypes
my $itype_or_itemtype = (C4::Context->preference("item-level_itypes"))?'itype':'itemtype';
my @advancedsearchesloop;
@ -515,7 +516,7 @@ my $facets; # this object stores the faceted results that display on the left-ha
my $results_hashref;
eval {
my $itemtypes = GetItemTypes;
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
( $error, $results_hashref, $facets ) = $searcher->search_compat(
$query, $simple_query, \@sort_by, \@servers,
$results_per_page, $offset, $expanded_facet, undef,
@ -780,7 +781,7 @@ sub prepare_adv_search_types {
# the index parameter is different for item-level itemtypes
my $itype_or_itemtype =
( C4::Context->preference("item-level_itypes") ) ? 'itype' : 'itemtype';
my $itemtypes = GetItemTypes;
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
my ( $cnt, @result );
foreach my $advanced_srch_type (@advanced_search_types) {

View File

@ -37,6 +37,7 @@ use C4::Charset;
use Koha::BiblioFrameworks;
use Koha::DateUtils;
use Koha::ItemTypes;
use Koha::Libraries;
use Koha::BiblioFrameworks;
@ -188,10 +189,10 @@ sub build_authorized_values_list {
&& ( $value || $tagslib->{$tag}->{$subfield}->{defaultvalue} ) );
my $itemtype;
my $itemtypes = GetItemTypes( style => 'array' );
for my $itemtype ( @$itemtypes ) {
push @authorised_values, $itemtype->{itemtype};
$authorised_lib{$itemtype->{itemtype}} = $itemtype->{translated_description};
my $itemtypes = Koha::ItemTypes->search_with_localization;
while ( $itemtype = $itemtypes->next ) {
push @authorised_values, $itemtype->itemtype;
$authorised_lib{$itemtype->itemtype} = $itemtype->translated_description;
}
$value = $itemtype unless ($value);
}

View File

@ -31,6 +31,7 @@ use C4::Circulation;
use C4::Koha;
use C4::ClassSource;
use Koha::DateUtils;
use Koha::ItemTypes;
use Koha::Libraries;
use List::MoreUtils qw/any/;
use C4::Search;
@ -182,10 +183,10 @@ sub generate_subfield_form {
}
elsif ( $subfieldlib->{authorised_value} eq "itemtypes" ) {
push @authorised_values, "" unless ( $subfieldlib->{mandatory} );
my $itemtypes = GetItemTypes( style => 'array' );
for my $itemtype ( @$itemtypes ) {
push @authorised_values, $itemtype->{itemtype};
$authorised_lib{$itemtype->{itemtype}} = $itemtype->{translated_description};
my $itemtypes = Koha::ItemTypes->search_with_localization;
while ( my $itemtype = $itemtypes->next ) {
push @authorised_values, $itemtype->itemtype;
$authorised_lib{$itemtype->itemtype} = $itemtype->translated_description;
}
unless ( $value ) {

View File

@ -29,10 +29,11 @@ use C4::Auth;
use C4::Output;
use C4::Biblio;
use C4::Items;
use C4::Koha; # GetItemTypes
use C4::HoldsQueue qw(GetHoldsQueueItems);
use Koha::BiblioFrameworks;
use Koha::ItemTypes;
my $query = new CGI;
my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
{
@ -62,16 +63,16 @@ if ( $run_report ) {
}
# getting all itemtypes
my $itemtypes = &GetItemTypes();
my $itemtypes = Koha::ItemTypes->search({}, {order_by => 'itemtype'});;
my @itemtypesloop;
foreach my $thisitemtype ( sort keys %$itemtypes ) {
while ( my $itemtype = $itemtypes->next ) {
push @itemtypesloop, {
value => $thisitemtype,
description => $itemtypes->{$thisitemtype}->{'description'},
value => $itemtype->itemtype,
description => $itemtypes->description, # FIXME Don't we want the translated_description here?
};
}
$template->param(
$template->param( # FIXME Could be improved passing the $itemtypes iterator directly to the template
itemtypeloop => \@itemtypesloop,
);

View File

@ -30,6 +30,8 @@ use Koha::Items;
use C4::CourseReserves qw(GetCourse GetCourseItem GetCourseReserve ModCourseItem ModCourseReserve);
use Koha::ItemTypes;
my $cgi = new CGI;
my $action = $cgi->param('action') || '';
@ -68,6 +70,7 @@ if ( $action eq 'lookup' ) {
)
: undef;
my $itemtypes = Koha::ItemTypes->search;
$template->param(
item => $item,
title => $title,
@ -76,7 +79,7 @@ if ( $action eq 'lookup' ) {
ccodes => GetAuthorisedValues('CCODE'),
locations => GetAuthorisedValues('LOC'),
itypes => GetItemTypes( style => 'array' ),
itypes => $itemtypes, # FIXME We certainly want to display the translated_description in the template
return => $return,
);

View File

@ -147,8 +147,8 @@ function Dopop(link) {
</select> </li>
<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.translated_description %] </option>
[% FOREACH itemtype IN itemtypes %]
<option value="[% itemtype.itemtype %]" >[% itemtype.translated_description %] </option>
[% END %]
</select>
</li>

View File

@ -120,8 +120,8 @@
</li>
<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>
[% FOREACH itemtype IN itemtypes %]
<option value="[% itemtype.itemtype %]" >[% itemtype.translated_description %] </option>
[% END %]
</select>
</li>

View File

@ -97,8 +97,8 @@
<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>
[% FOREACH itemtype IN itemtypes %]
<option value="[% itemtype.itemtype %]">[% itemtype.translated_description %]</option>
[% END %]
</select>
</li>

View File

@ -167,8 +167,8 @@
<td><input type="radio" name="Column" value="itemtype" /></td>
<td><select name="Filter" id="itemtype">
<option value=""> </option>
[% FOREACH itemtypeloo IN itemtypeloop %]
<option value="[% itemtypeloo.code %]">[% itemtypeloo.description %]</option>
[% FOREACH itemtype IN itemtypes %]
<option value="[% itemtype.itemtype %]">[% itemtype.translated_description %]</option>
[% END %]
</select>
</td>

View File

@ -106,11 +106,8 @@
</select></li>
<li><label for="itemtypesfilter">Item type: </label><select name="itemtypesfilter" id="itemtypesfilter">
<option value="">All</option>
[% FOREACH itemtypeloo IN itemtypeloop %]
[% IF ( itemtypeloo.selected ) %]<option value="[% itemtypeloo.value %]" selected="selected">[% itemtypeloo.description %]</option>
[% ELSE %]
<option value="[% itemtypeloo.value %]">[% itemtypeloo.description %]</option>
[% END %]
[% FOREACH itemtype IN itemtypes %]
<option value="[% itemtype.itemtype %]">[% itemtype.translated_description %]</option>
[% END %]
</select></li>

View File

@ -89,12 +89,8 @@ $(document).ready(function() {
<label for="itemtype">Item type: </label>
<select name="itemtype" id="itemtype">
<option value="">-- All --</option>
[% FOREACH itemtypeloo IN itemtypeloop %]
[% IF ( itemtypeloo.selected ) %]
<option value="[% itemtypeloo.value %]" selected="selected">[% itemtypeloo.description %]</option>
[% ELSE %]
<option value="[% itemtypeloo.value %]">[% itemtypeloo.description %]</option>
[% END %]
[% FOREACH itemtype IN itemtypes %]
<option value="[% itemtype.itemtype %]">[% itemtype.translated_description %]</option>
[% END %]
</select>
</li>

View File

@ -31,11 +31,11 @@ use C4::Context;
use C4::Search qw(SimpleSearch);
use C4::Biblio qw(TransformMarcToKoha);
use C4::Items qw(GetItemInfosOf get_itemnumbers_of);
use C4::Koha qw(GetItemTypes);
use C4::Creators::Lib qw(html_table);
use C4::Debug;
use Koha::DateUtils;
use Koha::ItemTypes;
use Koha::SearchEngine::Search;
BEGIN {
@ -251,12 +251,15 @@ else {
debug => 1,
}
);
my $itemtypes = GetItemTypes;
my $itemtypes = Koha::ItemTypes->search;
my @itemtypeloop;
foreach my $thisitemtype ( keys %$itemtypes ) {
while ( my $itemtype = $itemtypes->next ) {
# FIXME This must be improved:
# - pass the iterator to the template
# - display the translated_description
my %row = (
value => $thisitemtype,
description => $itemtypes->{$thisitemtype}->{'description'},
value => $itemtype->itemtype,
description => $itemtype->description,
);
push @itemtypeloop, \%row;
}

View File

@ -53,6 +53,7 @@ use C4::Acquisition;
use C4::Serials; # uses getsubscriptionfrom biblionumber
use C4::Koha;
use C4::Members; # GetMember
use Koha::ItemTypes;
use Koha::RecordProcessor;
@ -162,7 +163,7 @@ my $res = GetISBDView({
'framework' => $framework
});
my $itemtypes = GetItemTypes();
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
my $borrower = GetMember( 'borrowernumber' => $loggedinuser );
for my $itm (@items) {
$norequests = 0

View File

@ -50,6 +50,7 @@ use C4::CourseReserves qw(GetItemCourseReservesInfo);
use Koha::RecordProcessor;
use Koha::AuthorisedValues;
use Koha::Biblios;
use Koha::ItemTypes;
use Koha::Virtualshelves;
use Koha::Ratings;
use Koha::Reviews;
@ -206,7 +207,7 @@ if ($session->param('busc')) {
my ($arrParamsBusc, $offset, $results_per_page) = @_;
my $expanded_facet = $arrParamsBusc->{'expand'};
my $itemtypes = GetItemTypes;
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
my @servers;
@servers = @{$arrParamsBusc->{'server'}} if $arrParamsBusc->{'server'};
@servers = ("biblioserver") unless (@servers);
@ -538,7 +539,7 @@ my $HideMARC = $record_processor->filters->[0]->should_hide_marc(
interface => 'opac',
} );
my $itemtypes = GetItemTypes();
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
# imageurl:
my $itemtype = $dat->{'itemtype'};
if ( $itemtype ) {

View File

@ -32,6 +32,8 @@ use MARC::Record;
use C4::Output;
use C4::Charset qw(StripNonXmlChars);
use Koha::ItemTypes;
my $query = new CGI;
# if opacreadinghistory is disabled, leave immediately
@ -55,7 +57,7 @@ my ( $borr ) = GetMember( borrowernumber => $borrowernumber );
$template->param(%{$borr});
my $itemtypes = GetItemTypes();
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
# get the record
my $order = $query->param('order') || '';

View File

@ -35,6 +35,7 @@ use C4::Debug;
use Koha::AuthorisedValues;
use Koha::DateUtils;
use Koha::Items;
use Koha::ItemTypes;
use Koha::Libraries;
use Koha::Patrons;
use Date::Calc qw/Today Date_to_Days/;
@ -100,7 +101,7 @@ if ( $reservefee > 0){
$template->param( RESERVE_CHARGE => sprintf("%.2f",$reservefee));
}
my $itemTypes = GetItemTypes();
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
# There are two ways of calling this script, with a single biblio num
# or multiple biblio nums.
@ -419,14 +420,14 @@ foreach my $biblioNum (@biblionumbers) {
$biblioLoopIter{reqholdnotes}=0; #TODO: For future use
if (!$itemLevelTypes && $biblioData->{itemtype}) {
$biblioLoopIter{translated_description} = $itemTypes->{$biblioData->{itemtype}}{translated_description};
$biblioLoopIter{imageurl} = getitemtypeimagesrc() . "/". $itemTypes->{$biblioData->{itemtype}}{imageurl};
$biblioLoopIter{translated_description} = $itemtypes->{$biblioData->{itemtype}}{translated_description};
$biblioLoopIter{imageurl} = getitemtypeimagesrc() . "/". $itemtypes->{$biblioData->{itemtype}}{imageurl};
}
foreach my $itemInfo (@{$biblioData->{itemInfos}}) {
if ($itemLevelTypes && $itemInfo->{itype}) {
$itemInfo->{translated_description} = $itemTypes->{$itemInfo->{itype}}{translated_description};
$itemInfo->{imageurl} = getitemtypeimagesrc() . "/". $itemTypes->{$itemInfo->{itype}}{imageurl};
$itemInfo->{translated_description} = $itemtypes->{$itemInfo->{itype}}{translated_description};
$itemInfo->{imageurl} = getitemtypeimagesrc() . "/". $itemtypes->{$itemInfo->{itype}}{imageurl};
}
if (!$itemInfo->{'notforloan'} && !($itemInfo->{'itemnotforloan'} > 0)) {
@ -550,7 +551,7 @@ foreach my $biblioNum (@biblionumbers) {
}
}
$itemLoopIter->{imageurl} = getitemtypeimagelocation( 'opac', $itemTypes->{ $itemInfo->{itype} }{imageurl} );
$itemLoopIter->{imageurl} = getitemtypeimagelocation( 'opac', $itemtypes->{ $itemInfo->{itype} }{imageurl} );
# Show serial enumeration when needed
if ($itemLoopIter->{enumchron}) {

View File

@ -229,8 +229,6 @@ foreach my $itemtype ( keys %{$itemtypes} ) {
$itemtypes->{$itemtype}->{translated_description} =
( $translated_description ) ? $translated_description : $itemtypes->{$itemtype}->{description};
}
# Load the Type stuff without search categories for facets
my $itemtypes_nocategory = GetItemTypes;
# the index parameter is different for item-level itemtypes
my $itype_or_itemtype = (C4::Context->preference("item-level_itypes"))?'itype':'itemtype';
my @advancedsearchesloop;

View File

@ -48,8 +48,6 @@ if ( ! C4::Context->preference('OpacTopissue') ) {
exit;
}
my $itemtypes = GetItemTypes();
my ($template, $borrowernumber, $cookie) = get_template_and_user(
{
template_name => 'opac-topissues.tt',

View File

@ -36,6 +36,7 @@ use C4::Letters;
use Koha::DateUtils;
use Koha::Holds;
use Koha::Database;
use Koha::ItemTypes;
use Koha::Patron::Attribute::Types;
use Koha::Patron::Messages;
use Koha::Patron::Discharge;
@ -175,7 +176,7 @@ my $count = 0;
my $overdues_count = 0;
my @overdues;
my @issuedat;
my $itemtypes = GetItemTypes();
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
my $issues = GetPendingIssues($borrowernumber);
if ($issues){
foreach my $issue ( sort { $b->{date_due}->datetime() cmp $a->{date_due}->datetime() } @{$issues} ) {

View File

@ -27,6 +27,7 @@ use C4::Output;
use C4::Koha;
use C4::Circulation;
use C4::Biblio;
use Koha::ItemTypes;
use Koha::DateUtils;
use Koha::Libraries;
@ -124,8 +125,6 @@ else {
$req->execute;
my $booksellers = $req->fetchall_arrayref({});
my $itemtypes = GetItemTypes( style => 'array' );
$req = $dbh->prepare("SELECT DISTINCTROW budget_code, budget_name FROM aqbudgets ORDER BY budget_name");
$req->execute;
my @bselect;
@ -195,9 +194,10 @@ else {
$ccode_avlist = GetAuthorisedValues($ccode_subfield_structure->{authorised_value});
}
my $itemtypes = Koha::ItemTypes->search_with_localization;
$template->param(
booksellers => $booksellers,
itemtypes => $itemtypes,
itemtypes => $itemtypes, # FIXME Should use the TT plugin instead
Budgets => $Budgets,
hassort1 => $hassort1,
hassort2 => $hassort2,

View File

@ -30,6 +30,7 @@ use C4::Reports;
use C4::Debug;
use Koha::DateUtils;
use Koha::ItemTypes;
use Koha::Patron::Categories;
=head1 NAME
@ -110,21 +111,12 @@ my @values;
my @mime = ( map { {type =>$_} } (split /[;:]/, 'CSV') ); # FIXME translation
my $delims = GetDelimiterChoices;
my $itemtypes = GetItemTypes;
my @itemtypeloop;
foreach (sort {$itemtypes->{$a}->{translated_description} cmp $itemtypes->{$b}->{translated_description}} keys %$itemtypes) {
my %row = (value => $_,
translated_description => $itemtypes->{$_}->{translated_description},
);
push @itemtypeloop, \%row;
}
my $patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['categorycode']});
my $itemtypes = Koha::ItemTypes->search_with_localization;
$template->param(
mimeloop => \@mime,
CGIseplist => $delims,
itemtypeloop => \@itemtypeloop,
itemtypes => $itemtypes,
patron_categories => $patron_categories,
);
output_html_with_http_headers $input, $cookie, $template->output;

View File

@ -29,6 +29,7 @@ use C4::Circulation;
use C4::Reports;
use C4::Members;
use Koha::DateUtils;
use Koha::ItemTypes;
=head1 NAME
@ -118,14 +119,7 @@ if ($do_it) {
my $CGIsepChoice=GetDelimiterChoices;
#doctype
my $itemtypes = GetItemTypes;
my @itemtypeloop;
foreach my $thisitemtype ( sort {$itemtypes->{$a}->{translated_description} cmp $itemtypes->{$b}->{translated_description}} keys %$itemtypes) {
my %row =(value => $thisitemtype,
description => $itemtypes->{$thisitemtype}->{translated_description},
);
push @itemtypeloop, \%row;
}
my $itemtypes = Koha::ItemTypes->search_with_localization;
#ccode
my $ccodes = GetAuthorisedValues('CCODE');
@ -156,7 +150,7 @@ if ($do_it) {
$template->param(
CGIextChoice => $CGIextChoice,
CGIsepChoice => $CGIsepChoice,
itemtypeloop =>\@itemtypeloop,
itemtypes => $itemtypes,
ccodeloop =>\@ccodeloop,
shelvinglocloop =>\@shelvinglocloop,
patron_categories => $patron_categories,

View File

@ -25,7 +25,6 @@ use C4::Auth;
use C4::Context;
use C4::Debug;
use C4::Output;
use C4::Koha; # GetItemTypes
# use Date::Manip; # TODO: add not borrowed since date X criteria
use Data::Dumper;
@ -60,23 +59,9 @@ if ($do_it) {
exit; # in either case, exit after do_it
}
# Displaying choices (i.e., not do_it)
my $itemtypes = GetItemTypes();
my @itemtypeloop;
foreach (
sort { $itemtypes->{$a}->{translated_description} cmp $itemtypes->{$b}->{translated_description} }
keys %$itemtypes
)
{
push @itemtypeloop,
{
value => $_,
description => $itemtypes->{$_}->{translated_description},
};
}
my $itemtypes = Koha::ItemTypes->search_with_localization;
$template->param(
itemtypeloop => \@itemtypeloop,
itemtypes => $itemtypes,
);
output_html_with_http_headers $input, $cookie, $template->output;

View File

@ -31,6 +31,7 @@ use C4::Biblio qw/GetMarcSubfieldStructureFromKohaField/;
use Koha::AuthorisedValues;
use Koha::DateUtils;
use Koha::ItemTypes;
=head1 NAME
@ -120,7 +121,7 @@ if ($do_it) {
my $req;
my @select;
my $itemtypes = GetItemTypes( style => 'array' );
my $itemtypes = Koha::ItemTypes->search_with_localization;
my @authvals = map { { code => $_->{authorised_value}, description => $_->{lib} } } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } );
my @locations = map { { code => $_->{authorised_value}, description => $_->{lib} } } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } );

View File

@ -28,6 +28,7 @@ use C4::Koha;
use C4::Circulation;
use C4::Reports;
use Koha::DateUtils;
use Koha::ItemTypes;
use Koha::Patron::Categories;
use Date::Calc qw(Delta_Days);
@ -119,7 +120,7 @@ if ($do_it) {
} else {
my $patron_categories = Koha::Patron::Categories->search({}, {order_by => ['description']});
my $itemtypes = GetItemTypes( style => 'array' );
my $itemtypes = Koha::ItemTypes->search_with_localization;
my $dbh = C4::Context->dbh;
my $req = $dbh->prepare("select distinctrow sort1 from borrowers where sort1 is not null order by sort1");

View File

@ -34,6 +34,7 @@ use C4::Members;
use Koha::AuthorisedValues;
use Koha::DateUtils;
use Koha::ItemTypes;
use C4::Members::AttributeTypes;
=head1 NAME
@ -87,7 +88,6 @@ $sep = "\t" if ($sep eq 'tabulation');
$template->param(do_it => $do_it,
);
our $itemtypes = GetItemTypes();
our @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
our $locations = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } ) };
@ -146,10 +146,7 @@ my %labels;
my %select;
# create itemtype arrayref for <select>.
my @itemtypeloop;
for my $itype ( sort {$itemtypes->{$a}->{translated_description} cmp $itemtypes->{$b}->{translated_description}} keys(%$itemtypes)) {
push @itemtypeloop, { code => $itype , description => $itemtypes->{$itype}->{translated_description} } ;
}
our $itemtypes = Koha::ItemTypes->search_with_localization;
# location list
my @locations;
@ -181,7 +178,7 @@ foreach my $attribute_type (@attribute_types) {
$template->param(
categoryloop => \@patron_categories,
itemtypeloop => \@itemtypeloop,
itemtypes => $itemtypes,
locationloop => \@locations,
ccodeloop => \@ccodes,
hassort1 => $hassort1,

View File

@ -33,7 +33,6 @@ use C4::Auth;
use C4::Output;
use C4::Biblio;
use C4::Items;
use C4::Koha; # GetItemTypes
use Koha::DateUtils;
my $query = new CGI;
@ -80,21 +79,13 @@ if ( $get_items ) {
}
# getting all itemtypes
my $itemtypes = &GetItemTypes();
my @itemtypesloop;
foreach my $thisitemtype ( sort {$itemtypes->{$a}->{translated_description} cmp $itemtypes->{$b}->{translated_description}} keys %$itemtypes ) {
my %row = (
value => $thisitemtype,
description => $itemtypes->{$thisitemtype}->{'translated_description'},
);
push @itemtypesloop, \%row;
}
my $itemtypes = Koha::ItemTypes->search_with_localization;
# get lost statuses
my $lost_status_loop = C4::Koha::GetAuthorisedValues( 'LOST' );
$template->param(
itemtypeloop => \@itemtypesloop,
itemtypes => $itemtypes,
loststatusloop => $lost_status_loop,
);

View File

@ -30,6 +30,7 @@ use C4::Reports;
use C4::Members;
use Koha::AuthorisedValues;
use Koha::DateUtils;
use Koha::ItemTypes;
use Koha::Libraries;
use Koha::Patron::Categories;
use List::MoreUtils qw/any/;
@ -74,7 +75,6 @@ $sep = "\t" if ($sep eq 'tabulation');
$template->param(do_it => $do_it,
);
my $itemtypes = GetItemTypes();
my @patron_categories = Koha::Patron::Categories->search_limited({}, {order_by => ['description']});
my $locations = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } ) };
@ -130,11 +130,7 @@ my @values;
my %labels;
my %select;
# create itemtype arrayref for <select>.
my @itemtypeloop;
for my $itype ( sort {$itemtypes->{$a}->{translated_description} cmp $itemtypes->{$b}->{translated_description}} keys(%$itemtypes)) {
push @itemtypeloop, { code => $itype , description => $itemtypes->{$itype}->{translated_description} } ;
}
my $itemtypes = Koha::ItemTypes->search_with_localization;
# location list
my @locations;
@ -153,7 +149,7 @@ my $CGIsepChoice=GetDelimiterChoices;
$template->param(
categoryloop => \@patron_categories,
itemtypeloop => \@itemtypeloop,
itemtypes => $itemtypes,
locationloop => \@locations,
ccodeloop => \@ccodes,
hassort1=> $hassort1,
@ -319,13 +315,12 @@ sub display_value {
my ( $crit, $value ) = @_;
my $locations = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.location' }, { order_by => ['description'] } ) };
my $ccodes = { map { ( $_->{authorised_value} => $_->{lib} ) } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.ccode' }, { order_by => ['description'] } ) };
my $itemtypes = GetItemTypes();
my $Bsort1 = GetAuthorisedValues("Bsort1");
my $Bsort2 = GetAuthorisedValues("Bsort2");
my $display_value =
( $crit =~ /ccode/ ) ? $ccodes->{$value}
: ( $crit =~ /location/ ) ? $locations->{$value}
: ( $crit =~ /itemtype/ ) ? $itemtypes->{$value}->{description}
: ( $crit =~ /itemtype/ ) ? Koha::ItemTypes->find( $value )->translated_description
: ( $crit =~ /branch/ ) ? Koha::Libraries->find($value)->branchname
: ( $crit =~ /reservestatus/ ) ? reservestatushuman($value)
: $value; # default fallback

View File

@ -45,6 +45,7 @@ use C4::Search; # enabled_staff_search_views
use Koha::DateUtils;
use Koha::Holds;
use Koha::Items;
use Koha::ItemTypes;
use Koha::Libraries;
use Koha::Patrons;
@ -64,7 +65,7 @@ my $multihold = $input->param('multi_hold');
$template->param(multi_hold => $multihold);
my $showallitems = $input->param('showallitems');
my $itemtypes = GetItemTypes();
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
# Select borrowers infos
my $findborrower = $input->param('findborrower');

View File

@ -32,6 +32,7 @@ use C4::Serials::Numberpattern;
use C4::Letters;
use Koha::AdditionalField;
use Koha::DateUtils;
use Koha::ItemTypes;
use Carp;
#use Smart::Comments;
@ -141,8 +142,9 @@ for my $field ( @$additional_fields ) {
}
$template->param( additional_fields_for_subscription => $additional_fields );
my $typeloop = GetItemTypes();
my $typeloop = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
# FIXME We should use the translated_description for item types
my @typearg =
map { { code => $_, value => $typeloop->{$_}{'description'}, selected => ( ( $subs->{itemtype} and $_ eq $subs->{itemtype} ) ? "selected=\"selected\"" : "" ), } } sort keys %{$typeloop};
my @previoustypearg =

View File

@ -58,6 +58,7 @@ use C4::Search;
use C4::Biblio;
use C4::Debug;
use Koha::ItemTypes;
use Koha::SearchEngine;
use Koha::SearchEngine::Search;
@ -196,8 +197,10 @@ else {
);
# load the itemtypes
my $itemtypes = GetItemTypes();
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
my @itemtypesloop;
# FIXME This is uselessly complex, the iterator should be send to the template
# FIXME The translated_description should be used
foreach my $thisitemtype (
sort {
$itemtypes->{$a}->{'description'}

View File

@ -24,7 +24,6 @@ use CGI qw ( -utf8 );
use C4::Auth; # get_template_and_user
use C4::Output;
use C4::Suggestions;
use C4::Koha; #GetItemTypes
use C4::Budgets;
use C4::Search;
use C4::Members;

View File

@ -25,6 +25,7 @@ use CGI qw ( -utf8 );
use C4::Auth qw/check_api_auth/;
use C4::Context;
use C4::Koha;
use Koha::ItemTypes;
use XML::Simple;
my $query = new CGI;
@ -113,7 +114,7 @@ sub _get_bib_number_tag {
sub _get_biblioitem_itemtypes {
my $result = shift;
my $itemtypes = GetItemTypes;
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
my $sth = $dbh->prepare_cached("SELECT tagfield, tagsubfield
FROM marc_subfield_structure
WHERE frameworkcode = ''

View File

@ -37,6 +37,7 @@ use List::MoreUtils qw/uniq/;
use Koha::Biblios;
use Koha::DateUtils;
use Koha::ItemTypes;
my $input = new CGI;
my $dbh = C4::Context->dbh;
@ -361,10 +362,10 @@ foreach my $tag (sort keys %{$tagslib}) {
}
elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" ) {
push @authorised_values, "";
my $itemtypes = GetItemTypes( style => 'array' );
for my $itemtype ( @$itemtypes ) {
push @authorised_values, $itemtype->{itemtype};
$authorised_lib{$itemtype->{itemtype}} = $itemtype->{translated_description};
my $itemtypes = Koha::ItemTypes->search_with_localization;
while ( my $itemtype = $itemtypes->next ) {
push @authorised_values, $itemtype->itemtype;
$authorised_lib{$itemtype->itemtype} = $itemtype->translated_description;
}
$value = "";

View File

@ -21,7 +21,6 @@ use CGI qw ( -utf8 );
use MARC::File::XML;
use List::MoreUtils qw(uniq);
use C4::Auth;
use C4::Koha; # GetItemTypes
use C4::Output;
use Koha::Authority::Types;
@ -30,6 +29,7 @@ use Koha::CsvProfiles;
use Koha::Database;
use Koha::DateUtils qw( dt_from_string output_pref );
use Koha::Exporter::Record;
use Koha::ItemTypes;
use Koha::Libraries;
my $query = new CGI;
@ -266,15 +266,7 @@ if ( $op eq "export" ) {
else {
my $itemtypes = GetItemTypes;
my @itemtypesloop;
foreach my $thisitemtype ( sort keys %$itemtypes ) {
my %row = (
value => $thisitemtype,
description => $itemtypes->{$thisitemtype}->{translated_description},
);
push @itemtypesloop, \%row;
}
my $itemtypes = Koha::ItemTypes->search_with_localization;
my $authority_types = Koha::Authority::Types->search( {}, { order_by => ['authtypecode'] } );
@ -305,7 +297,7 @@ else {
$template->param(
libraries => $libraries,
itemtypeloop => \@itemtypesloop,
itemtypes => $itemtypes,
authority_types => $authority_types,
export_remove_fields => C4::Context->preference("ExportRemoveFields"),
csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc' }) ],