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

(-)a/C4/Biblio.pm (-6 / +3 lines)
Lines 1194-1199 sub GetMarcBiblio { Link Here
1194
1194
1195
        C4::Biblio::_koha_marc_update_bib_ids( $record, $frameworkcode, $biblionumber,
1195
        C4::Biblio::_koha_marc_update_bib_ids( $record, $frameworkcode, $biblionumber,
1196
            $biblioitemnumber );
1196
            $biblioitemnumber );
1197
1197
        C4::Biblio::EmbedItemsInMarcBiblio( $record, $biblionumber, undef, $opac )
1198
        C4::Biblio::EmbedItemsInMarcBiblio( $record, $biblionumber, undef, $opac )
1198
          if ($embeditems);
1199
          if ($embeditems);
1199
1200
Lines 2816-2827 sub EmbedItemsInMarcBiblio { Link Here
2816
      : ();
2817
      : ();
2817
    # Convert to a hash for quick searching
2818
    # Convert to a hash for quick searching
2818
    my %hiddenitems = map { $_ => 1 } @hiddenitems;
2819
    my %hiddenitems = map { $_ => 1 } @hiddenitems;
2819
    foreach my $itemnumber ( map { $_->{itemnumber} } @items ) {
2820
    my $item_fields = C4::Items::GetMarcItems( $biblionumber, \@hiddenitems, $itemtag );
2820
        next if $hiddenitems{$itemnumber};
2821
    $marc->append_fields(@$item_fields);
2821
        my $item_marc = C4::Items::GetMarcItem( $biblionumber, $itemnumber );
2822
        push @item_fields, $item_marc->field($itemtag);
2823
    }
2824
    $marc->append_fields(@item_fields);
2825
}
2822
}
2826
2823
2827
=head1 INTERNAL FUNCTIONS
2824
=head1 INTERNAL FUNCTIONS
(-)a/C4/Items.pm (-3 / +30 lines)
Lines 1496-1509 sub GetMarcItem { Link Here
1496
    return Item2Marc($itemrecord,$biblionumber);
1496
    return Item2Marc($itemrecord,$biblionumber);
1497
1497
1498
}
1498
}
1499
1500
=head2 GetMarcItems
1501
1502
  my @items_marc = GetMarcItems($biblionumber, \@hiddenitemnumbers);
1503
1504
Returns array of MARC::Records of the items for the biblio  passed in parameter.
1505
1506
=cut
1507
1508
sub GetMarcItems {
1509
    my ( $biblionumber, $hiddenitems, $itemtag ) = @_;
1510
    my $params;
1511
    $params->{biblionumber} = $biblionumber;
1512
    $params->{itemnumber} = {'not in' => @$hiddenitems} if defined $hiddenitems && scalar @$hiddenitems;
1513
    my $items = Koha::Items->search($params );
1514
    return unless $items;
1515
1516
    # Tack on 'items.' prefix to column names so that C4::Biblio::TransformKohaToMarc will work.
1517
    # Also, don't emit a subfield if the underlying field is blank.
1518
1519
    my $framework = Koha::Biblios->find( $biblionumber)->frameworkcode();
1520
    my @marc_items;
1521
    while ( my $this_item = $items->next() ){
1522
        push @marc_items, Item2Marc($this_item->unblessed,$biblionumber,$framework)->field($itemtag);
1523
    }
1524
    return \@marc_items;
1525
}
1526
1499
sub Item2Marc {
1527
sub Item2Marc {
1500
	my ($itemrecord,$biblionumber)=@_;
1528
	my ($itemrecord,$biblionumber, $frameworkcode)=@_;
1501
    my $mungeditem = { 
1529
    my $mungeditem = { 
1502
        map {  
1530
        map {  
1503
            defined($itemrecord->{$_}) && $itemrecord->{$_} ne '' ? ("items.$_" => $itemrecord->{$_}) : ()  
1531
            defined($itemrecord->{$_}) && $itemrecord->{$_} ne '' ? ("items.$_" => $itemrecord->{$_}) : ()  
1504
        } keys %{ $itemrecord } 
1532
        } keys %{ $itemrecord } 
1505
    };
1533
    };
1506
    my $framework = C4::Biblio::GetFrameworkCode( $biblionumber );
1534
    my $framework = $frameworkcode // C4::Biblio::GetFrameworkCode( $biblionumber );
1507
    my $itemmarc = C4::Biblio::TransformKohaToMarc(
1535
    my $itemmarc = C4::Biblio::TransformKohaToMarc(
1508
        $mungeditem, { no_split => 1},
1536
        $mungeditem, { no_split => 1},
1509
    );
1537
    );
1510
- 

Return to bug 21006