View | Details | Raw Unified | Return to bug 11518
Collapse All | Expand All

(-)a/Koha/Schema/Result/Biblio.pm (-1 / +5 lines)
Lines 331-336 __PACKAGE__->many_to_many("sets", "oai_sets_biblios", "set"); Link Here
331
# Created by DBIx::Class::Schema::Loader v0.07025 @ 2013-10-14 20:56:21
331
# Created by DBIx::Class::Schema::Loader v0.07025 @ 2013-10-14 20:56:21
332
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:0//8OGf7OteNnwT03g4QsA
332
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:0//8OGf7OteNnwT03g4QsA
333
333
334
__PACKAGE__->belongs_to(
335
    "biblioitem",
336
    "Koha::Schema::Result::Biblioitem",
337
    { "foreign.biblionumber" => "self.biblionumber" }
338
);
334
339
335
# You can replace this text with custom content, and it will be preserved on regeneration
336
1;
340
1;
(-)a/Koha/Schema/Result/Item.pm (+17 lines)
Lines 618-621 __PACKAGE__->belongs_to( Link Here
618
    { "foreign.biblionumber" => "self.biblionumber" }
618
    { "foreign.biblionumber" => "self.biblionumber" }
619
);
619
);
620
620
621
__PACKAGE__->belongs_to(
622
  "biblioitem",
623
  "Koha::Schema::Result::Biblioitem",
624
  { biblioitemnumber => "biblioitemnumber" },
625
);
626
627
use C4::Context;
628
sub itemtype {
629
    my ( $self ) = @_;
630
631
    if ( C4::Context->preference('item-level_itypes') ) {
632
        return $self->itype();
633
    } else {
634
        return $self->biblioitem()->itemtype();
635
    }
636
}
637
621
1;
638
1;
(-)a/t/db_dependent/Items.t (-1 / +37 lines)
Lines 20-25 use Modern::Perl; Link Here
20
20
21
use MARC::Record;
21
use MARC::Record;
22
use C4::Biblio;
22
use C4::Biblio;
23
use Koha::Database;
23
24
24
use Test::More tests => 3;
25
use Test::More tests => 3;
25
26
Lines 142-147 subtest 'GetHiddenItemnumbers tests' => sub { Link Here
142
    $dbh->rollback;
143
    $dbh->rollback;
143
};
144
};
144
145
146
subtest q{Test Koha::Database->schema()->resultset('Item')->itemtype()} => sub {
147
148
    plan tests => 2;
149
150
    # Start transaction
151
    $dbh->{AutoCommit} = 0;
152
    $dbh->{RaiseError} = 1;
153
154
    my $schema = Koha::Database->new()->schema();
155
156
    my $biblio =
157
    $schema->resultset('Biblio')->create(
158
        {
159
            title       => "Test title",
160
            biblioitems => [
161
                {
162
                    itemtype => 'BIB_LEVEL',
163
                    items    => [ { itype => "ITEM_LEVEL" } ]
164
                }
165
            ]
166
        }
167
    );
168
169
    my $biblioitem = $biblio->biblioitem();
170
    my ( $item ) = $biblioitem->items();
171
172
    C4::Context->set_preference( 'item-level_itypes', 0 );
173
    ok( $item->itemtype() eq 'BIB_LEVEL', '$item->itemtype() returns biblioitem.itemtype when item-level_itypes is disabled' );
174
175
    C4::Context->set_preference( 'item-level_itypes', 1 );
176
    ok( $item->itemtype() eq 'ITEM_LEVEL', '$item->itemtype() returns items.itype when item-level_itypes is disabled' );
177
178
179
    $dbh->rollback;
180
};
181
145
# Helper method to set up a Biblio.
182
# Helper method to set up a Biblio.
146
sub get_biblio {
183
sub get_biblio {
147
    my $bib = MARC::Record->new();
184
    my $bib = MARC::Record->new();
148
- 

Return to bug 11518