# Created by DBIx::Class::Schema::Loader v0.07025 @ 2013-10-14 20:56:21
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:0//8OGf7OteNnwT03g4QsA
+__PACKAGE__->belongs_to(
+ "biblioitem",
+ "Koha::Schema::Result::Biblioitem",
+ { "foreign.biblionumber" => "self.biblionumber" }
+);
-# You can replace this text with custom content, and it will be preserved on regeneration
1;
{ "foreign.biblionumber" => "self.biblionumber" }
);
+__PACKAGE__->belongs_to(
+ "biblioitem",
+ "Koha::Schema::Result::Biblioitem",
+ { biblioitemnumber => "biblioitemnumber" },
+);
+
+use C4::Context;
+sub itemtype {
+ my ( $self ) = @_;
+
+ if ( C4::Context->preference('item-level_itypes') ) {
+ return $self->itype();
+ } else {
+ return $self->biblioitem()->itemtype();
+ }
+}
+
1;
use MARC::Record;
use C4::Biblio;
+use Koha::Database;
use Test::More tests => 3;
$dbh->rollback;
};
+subtest q{Test Koha::Database->schema()->resultset('Item')->itemtype()} => sub {
+
+ plan tests => 2;
+
+ # Start transaction
+ $dbh->{AutoCommit} = 0;
+ $dbh->{RaiseError} = 1;
+
+ my $schema = Koha::Database->new()->schema();
+
+ my $biblio =
+ $schema->resultset('Biblio')->create(
+ {
+ title => "Test title",
+ biblioitems => [
+ {
+ itemtype => 'BIB_LEVEL',
+ items => [ { itype => "ITEM_LEVEL" } ]
+ }
+ ]
+ }
+ );
+
+ my $biblioitem = $biblio->biblioitem();
+ my ( $item ) = $biblioitem->items();
+
+ C4::Context->set_preference( 'item-level_itypes', 0 );
+ ok( $item->itemtype() eq 'BIB_LEVEL', '$item->itemtype() returns biblioitem.itemtype when item-level_itypes is disabled' );
+
+ C4::Context->set_preference( 'item-level_itypes', 1 );
+ ok( $item->itemtype() eq 'ITEM_LEVEL', '$item->itemtype() returns items.itype when item-level_itypes is disabled' );
+
+
+ $dbh->rollback;
+};
+
# Helper method to set up a Biblio.
sub get_biblio {
my $bib = MARC::Record->new();