use warnings;
use C4::Context;
use C4::Category;
-use C4::ItemType;
use Carp qw(carp croak);
+use Koha::ItemTypes;
+
our $AUTOLOAD;
# helper function for validating \%opts
my @branch_prefs = $class->find($where);
my @default_prefs = $class->find({ branchcode => '*', notification => $where->{notification} });
my @cc = C4::Category->all;
- my @it = C4::ItemType->all;
+ my @it = Koha::ItemTypes->search;
my $notification = $where->{notification};
my %disabled = map {
my $key = $_->categorycode . "-" . $_->item_type . "-" . $notification;
use C4::ImportBatch qw/GetImportRecordMarc SetImportRecordStatus/;
use Koha::Acquisition::Bookseller;
+use Koha::ItemTypes;
our $input = new CGI;
my $booksellerid = $input->param('booksellerid'); # FIXME: else ERROR!
}
# Get the item types list, but only if item_level_itype is YES. Otherwise, it will be in the item, no need to display it in the biblio
my @itemtypes;
-@itemtypes = C4::ItemType->all unless C4::Context->preference('item-level_itypes');
+@itemtypes = Koha::ItemTypes->search unless C4::Context->preference('item-level_itypes');
if ( defined $subscriptionid ) {
my $lastOrderReceived = GetLastOrderReceivedFromSubscriptionid $subscriptionid;
use C4::Context;
use C4::Branch;
use C4::Category;
-use C4::ItemType;
use C4::ItemCirculationAlertPreference;
use C4::Output;
+use Koha::ItemTypes;
+
# shortcut for long package name
our $preferences = 'C4::ItemCirculationAlertPreference';
-# prepend "br_" to column name and replace spaces with "<br/>"
-sub br {
- my ($data, @keys) = @_;
- for (@keys) {
- my $br = $data->{$_};
- $br =~ s{\s+}{<br/>}g;
- $data->{'br_'.$_} = $br;
- }
- $data;
-}
-
# display item circulation alerts
sub show {
my ($input) = @_;
my @categories = (
C4::Category->all
);
- my @item_types = map { br($_, 'description') } (
- C4::ItemType->all
- );
+ my @item_types = Koha::ItemTypes->search;
my $grid_checkout = $preferences->grid({ branchcode => $branch, notification => 'CHECKOUT' });
my $grid_checkin = $preferences->grid({ branchcode => $branch, notification => 'CHECKIN' });
use C4::Biblio;
use C4::Branch;
use C4::Koha;
-use C4::ItemType;
use Koha::Item::Search::Field qw(GetItemSearchFields);
+use Koha::ItemTypes;
my $cgi = new CGI;
my %params = $cgi->Vars;
label => $location->{lib} // $location->{authorised_value},
};
}
- my @itemtypes = C4::ItemType->all();
- foreach my $itemtype (@itemtypes) {
- $itemtype->{value} = $itemtype->{itemtype};
- $itemtype->{label} = $itemtype->{translated_description};
+ my @itemtypes;
+ foreach my $itemtype ( Koha::ItemTypes->search ) {
+ push @itemtypes, {
+ value => $itemtype->itemtype,
+ label => $itemtype->translated_description,
+ };
}
my $ccode_avcode = GetAuthValCode('items.ccode') || 'CCODE';
my $ccodes = GetAuthorisedValues($ccode_avcode);
use C4::Koha;
use MARC::Record;
use C4::Branch;
-use C4::ItemType;
+
+use Koha::ItemTypes;
my $builder = sub {
my ( $params ) = @_;
}
);
- my @itemtypes = C4::ItemType->all;
+ my @itemtypes = Koha::ItemTypes->search;
$template->param(
itypeloop => \@itemtypes,
use C4::Koha;
use MARC::Record;
use C4::Branch; # GetBranches
-use C4::ItemType;
+
+use Koha::ItemTypes;
sub plugin_javascript {
my ( $dbh, $record, $tagslib, $field_number, $tabloop ) = @_;
}
);
- my @itemtypes = C4::ItemType->all;
+ my @itemtypes = Koha::ItemTypes->search;
$template->param( #classlist => $classlist,
itypeloop => \@itemtypes,
# Check if we should display a checkin message, based on the the item
# type of the checked in item
- my $itemtype = C4::ItemType->get( $biblio->{'itemtype'} );
- if ( $itemtype->{'checkinmsg'} ) {
+ my $itemtype = Koha::ItemTypes->find( $biblio->{'itemtype'} );
+ if ( $itemtype->checkinmsg ) {
$template->param(
- checkinmsg => $itemtype->{'checkinmsg'},
- checkinmsgtype => $itemtype->{'checkinmsgtype'},
+ checkinmsg => $itemtype->checkinmsg,
+ checkinmsgtype => $itemtype->checkinmsgtype,
);
}
# make sure return branch respects home branch circulation rules, default to homebranch
- my $hbr = GetBranchItemRule($biblio->{'homebranch'}, $itemtype->{itemtype})->{'returnbranch'} || "homebranch";
+ my $hbr = GetBranchItemRule($biblio->{'homebranch'}, $itemtype->itemtype)->{'returnbranch'} || "homebranch";
my $returnbranch = $biblio->{$hbr} ;
$template->param(
<tr>
<th> </th>
[% FOREACH item_type IN item_types %]
- <th>[% item_type.br_description %]</th>
+ <th>[% item_type.description %]</th>
[% END %]
</tr>
</thead>
<tr>
<th> </th>
[% FOREACH item_type IN item_types %]
- <th>[% item_type.br_description %]</th>
+ <th>[% item_type.description %]</th>
[% END %]
</tr>
</thead>
use Test::More tests => 23;
use C4::Branch;
-use C4::ItemType;
use C4::Members;
use Koha::Database;
use t::lib::TestBuilder;
+use Koha::ItemTypes;
+
BEGIN {
use FindBin;
use lib $FindBin::Bin;
my @branchcodes = ( $library1->{branchcode}, $library2->{branchcode}, $library3->{branchcode} );
my @other_branches = ( $library2->{branchcode}, $library3->{branchcode} );
my $least_cost_branch_code = pop @other_branches;
-my @item_types = C4::ItemType->all;
-my @for_loan = grep { $_->{notforloan} == 0 } @item_types
- or BAIL_OUT("No adequate itemtype");
-my $itemtype = $for_loan[0]->{itemtype};
+my $itemtype = Koha::ItemTypes->search({ notforloan => 1 })->next;
+$itemtype or BAIL_OUT("No adequate itemtype"); #FIXME Should be $itemtype = $itemtype->itemtype
#Set up the stage
# Sysprefs and cost matrix
C4::Context->set_preference('UseTransportCostMatrix', 0);
-( $itemtype ) = @{ $dbh->selectrow_arrayref("SELECT itemtype FROM itemtypes LIMIT 1") };
+$itemtype = Koha::ItemTypes->search->next->itemtype;
$library1 = $builder->build({
source => 'Branch',
#warn "HOLDS QUEUE: " . Data::Dumper::Dumper( $holds_queue );
# Bug 14297
-$itemtype = $item_types[0]->{itemtype};
+$itemtype = Koha::ItemTypes->search->next->itemtype;
$borrowernumber = $borrower3->{borrowernumber};
my $library_A = $library1->{branchcode};
my $library_B = $library2->{branchcode};
# End Bug 14297
# Bug 15062
-$itemtype = $item_types[0]->{itemtype};
+$itemtype = Koha::ItemTypes->search->next->itemtype;
$borrowernumber = $borrower2->{borrowernumber};
$library_A = $library1->{branchcode};
$library_B = $library2->{branchcode};