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

(-)a/C4/ImportBatch.pm (-4 / +34 lines)
Lines 169-180 sub GetImportRecordMarc { Link Here
169
    my ($import_record_id) = @_;
169
    my ($import_record_id) = @_;
170
170
171
    my $dbh = C4::Context->dbh;
171
    my $dbh = C4::Context->dbh;
172
    my $sth = $dbh->prepare("SELECT marc, encoding FROM import_records WHERE import_record_id = ?");
172
    my ( $marc, $encoding ) = $dbh->selectrow_array(q|
173
    $sth->execute($import_record_id);
173
        SELECT marc, encoding
174
    my ($marc, $encoding) = $sth->fetchrow();
174
        FROM import_records
175
    $sth->finish();
175
        WHERE import_record_id = ?
176
    |, undef, $import_record_id );
177
176
    return $marc, $encoding;
178
    return $marc, $encoding;
179
}
180
181
sub GetRecordFromImportBiblio {
182
    my ( $import_record_id, $embed_items ) = @_;
183
184
    my ($marc) = GetImportRecordMarc($import_record_id);
185
    my $record = MARC::Record->new_from_usmarc($marc);
177
186
187
    EmbedItemsInImportBiblio( $record, $import_record_id ) if $embed_items;
188
189
    return $record;
190
}
191
192
sub EmbedItemsInImportBiblio {
193
    my ( $record, $import_record_id ) = @_;
194
    my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField("items.itemnumber", '');
195
    my $dbh = C4::Context->dbh;
196
    my $import_items = $dbh->selectall_arrayref(q|
197
        SELECT import_items.marcxml
198
        FROM import_items
199
        WHERE import_record_id = ?
200
    |, { Slice => {} }, $import_record_id );
201
    my @item_fields;
202
    for my $import_item ( @$import_items ) {
203
        my $item_marc = MARC::Record::new_from_xml($import_item->{marcxml});
204
        push @item_fields, $item_marc->field($itemtag);
205
    }
206
    $record->append_fields(@item_fields);
207
    return $record;
178
}
208
}
179
209
180
=head2 GetImportRecordMarcXML
210
=head2 GetImportRecordMarcXML
(-)a/catalogue/showmarc.pl (-3 / +1 lines)
Lines 43-50 my $view= $input->param('viewas')||''; Link Here
43
43
44
my $record;
44
my $record;
45
if ($importid) {
45
if ($importid) {
46
    my ($marc) = GetImportRecordMarc($importid);
46
    $record = C4::ImportBatch::GetRecordFromImportBiblio( $importid, 'embed_items' );
47
    $record = MARC::Record->new_from_usmarc($marc);
48
}
47
}
49
else {
48
else {
50
    $record =GetMarcBiblio($biblionumber);
49
    $record =GetMarcBiblio($biblionumber);
51
- 

Return to bug 6520