Bug 17835: Remove the subroutine GetItemTypes
At this point the subroutine is no longer in used. 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:
parent
8d5b4306e0
commit
72dd80fae9
86
C4/Koha.pm
86
C4/Koha.pm
|
|
@ -41,7 +41,7 @@ BEGIN {
|
|||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(
|
||||
&GetPrinters &GetPrinter
|
||||
&GetItemTypes &getitemtypeinfo
|
||||
&getitemtypeinfo
|
||||
&GetItemTypesCategorized
|
||||
&getallthemes
|
||||
&getFacets
|
||||
|
|
@ -85,90 +85,6 @@ Koha.pm provides many functions for Koha scripts.
|
|||
|
||||
=cut
|
||||
|
||||
=head2 GetItemTypes
|
||||
|
||||
$itemtypes = &GetItemTypes( style => $style );
|
||||
|
||||
Returns information about existing itemtypes.
|
||||
|
||||
Params:
|
||||
style: either 'array' or 'hash', defaults to 'hash'.
|
||||
'array' returns an arrayref,
|
||||
'hash' return a hashref with the itemtype value as the key
|
||||
|
||||
build a HTML select with the following code :
|
||||
|
||||
=head3 in PERL SCRIPT
|
||||
|
||||
my $itemtypes = GetItemTypes;
|
||||
my @itemtypesloop;
|
||||
foreach my $thisitemtype (sort keys %$itemtypes) {
|
||||
my $selected = 1 if $thisitemtype eq $itemtype;
|
||||
my %row =(value => $thisitemtype,
|
||||
selected => $selected,
|
||||
description => $itemtypes->{$thisitemtype}->{'description'},
|
||||
);
|
||||
push @itemtypesloop, \%row;
|
||||
}
|
||||
$template->param(itemtypeloop => \@itemtypesloop);
|
||||
|
||||
=head3 in TEMPLATE
|
||||
|
||||
<form action='<!-- TMPL_VAR name="script_name" -->' method=post>
|
||||
<select name="itemtype">
|
||||
<option value="">Default</option>
|
||||
<!-- TMPL_LOOP name="itemtypeloop" -->
|
||||
<option value="<!-- TMPL_VAR name="value" -->" <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->><!-- TMPL_VAR name="description" --></option>
|
||||
<!-- /TMPL_LOOP -->
|
||||
</select>
|
||||
<input type=text name=searchfield value="<!-- TMPL_VAR name="searchfield" -->">
|
||||
<input type="submit" value="OK" class="button">
|
||||
</form>
|
||||
|
||||
=cut
|
||||
|
||||
sub GetItemTypes {
|
||||
my ( %params ) = @_;
|
||||
my $style = defined( $params{'style'} ) ? $params{'style'} : 'hash';
|
||||
|
||||
require C4::Languages;
|
||||
my $language = C4::Languages::getlanguage();
|
||||
# returns a reference to a hash of references to itemtypes...
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $query = q|
|
||||
SELECT
|
||||
itemtypes.itemtype,
|
||||
itemtypes.description,
|
||||
itemtypes.rentalcharge,
|
||||
itemtypes.notforloan,
|
||||
itemtypes.imageurl,
|
||||
itemtypes.summary,
|
||||
itemtypes.checkinmsg,
|
||||
itemtypes.checkinmsgtype,
|
||||
itemtypes.sip_media_type,
|
||||
itemtypes.hideinopac,
|
||||
itemtypes.searchcategory,
|
||||
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 itemtype
|
||||
|;
|
||||
my $sth = $dbh->prepare($query);
|
||||
$sth->execute( $language );
|
||||
|
||||
if ( $style eq 'hash' ) {
|
||||
my %itemtypes;
|
||||
while ( my $IT = $sth->fetchrow_hashref ) {
|
||||
$itemtypes{ $IT->{'itemtype'} } = $IT;
|
||||
}
|
||||
return ( \%itemtypes );
|
||||
} else {
|
||||
return [ sort { lc $a->{translated_description} cmp lc $b->{translated_description} } @{ $sth->fetchall_arrayref( {} ) } ];
|
||||
}
|
||||
}
|
||||
|
||||
=head2 GetItemTypesCategorized
|
||||
|
||||
$categories = GetItemTypesCategorized();
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use Koha::DateUtils qw(dt_from_string);
|
|||
use Koha::AuthorisedValue;
|
||||
use Koha::AuthorisedValueCategories;
|
||||
|
||||
use Test::More tests => 8;
|
||||
use Test::More tests => 7;
|
||||
use DateTime::Format::MySQL;
|
||||
|
||||
BEGIN {
|
||||
|
|
@ -294,13 +294,4 @@ subtest 'GetItemTypesCategorized test' => sub{
|
|||
is_deeply(\@results,\@expected, 'GetItemTypesCategorized: grouped and ungrouped items returned as expected.');
|
||||
};
|
||||
|
||||
subtest 'GetItemTypes test' => sub {
|
||||
plan tests => 1;
|
||||
$dbh->do(q|DELETE FROM itemtypes|);
|
||||
$dbh->do(q|INSERT INTO itemtypes(itemtype, description) VALUES ('a', 'aa desc'), ('b', 'zz desc'), ('d', 'dd desc'), ('c', 'yy desc')|);
|
||||
my $itemtypes = C4::Koha::GetItemTypes( style => 'array' );
|
||||
$itemtypes = [ map { $_->{itemtype} } @$itemtypes ];
|
||||
is_deeply( $itemtypes, [ 'a', 'd', 'c', 'b' ], 'GetItemTypes(array) should return itemtypes ordered by description');
|
||||
};
|
||||
|
||||
$dbh->rollback();
|
||||
|
|
|
|||
Loading…
Reference in New Issue