@EXPORT = qw(
&GetPrinters &GetPrinter
&GetItemTypes &getitemtypeinfo
- &GetItemTypesCategorized &GetItemTypesByCategory
+ &GetItemTypesCategorized
&getallthemes
&getFacets
&getnbpages
return ($dbh->selectall_hashref($query,'itemtype'));
}
-=head2 GetItemTypesByCategory
-
- @results = GetItemTypesByCategory( $searchcategory );
-
-Returns the itemtype code of all itemtypes included in a searchcategory.
-
-=cut
-
-sub GetItemTypesByCategory {
- my ($category) = @_;
- my $count = 0;
- my @results;
- my $dbh = C4::Context->dbh;
- my $query = qq|SELECT itemtype FROM itemtypes WHERE searchcategory=?|;
- my $tmp=$dbh->selectcol_arrayref($query,undef,$category);
- return @$tmp;
-}
-
=head2 getitemtypeinfo
$itemtype = &getitemtypeinfo($itemtype, [$interface]);
if (@searchCategories > 0) {
my @tabcat;
foreach my $typecategory (@searchCategories) {
- push (@tabcat, GetItemTypesByCategory($typecategory));
+ my @itemtypes = Koha::ItemTypes->search({ searchcategory => $typecategory });
+ push @tabcat, $_->itemtype for @itemtypes;
}
foreach my $itemtypeInCategory (@tabcat) {
use DateTime::Format::MySQL;
BEGIN {
- use_ok('C4::Koha', qw( :DEFAULT GetDailyQuote GetItemTypesByCategory GetItemTypesCategorized));
+ use_ok('C4::Koha', qw( :DEFAULT GetDailyQuote GetItemTypesCategorized));
use_ok('C4::Members');
}
};
-subtest 'GetItemTypesByCategory GetItemTypesCategorized test' => sub{
+subtest 'GetItemTypesCategorized test' => sub{
plan tests => 7;
my $avc = Koha::AuthorisedValueCategories->find('ITEMTYPECAT');
$insertSth->execute('BKghjklo3', 'Yet another type of book', 'Qwertyware', 0);
# Azertyware should not exist.
- my @results = GetItemTypesByCategory('Azertyware');
- is(scalar @results, 0, 'GetItemTypesByCategory: Invalid category returns nothing');
+ my @itemtypes = Koha::ItemTypes->search({ searchcategory => 'Azertyware' });
+ is( @itemtypes, 0, 'Search item types by searchcategory: Invalid category returns nothing');
- @results = GetItemTypesByCategory('Qwertyware');
+ @itemtypes = Koha::ItemTypes->search({ searchcategory => 'Qwertyware' });
+ my @got = map { $_->itemtype } @itemtypes;
my @expected = ( 'BKghjklo2', 'BKghjklo3' );
- is_deeply(\@results,\@expected,'GetItemTypesByCategory: valid category returns itemtypes');
+ is_deeply(\@got,\@expected,'Search item types by searchcategory: valid category returns itemtypes');
# add more data since GetItemTypesCategorized's search is more subtle
$insertGroup = Koha::AuthorisedValue->new(
ok(exists $hrCat->{Qwertyware}, 'GetItemTypesCategorized: partially visible category exists');
my @only = ( 'BKghjklo1', 'BKghjklo2', 'BKghjklo3', 'BKghjklo4', 'BKghjklo5', 'Qwertyware', 'Veryheavybook' );
- @results = ();
+ my @results = ();
foreach my $key (@only) {
push @results, $key if exists $hrCat->{$key};
}