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

(-)a/C4/ImportBatch.pm (-5 / +36 lines)
Lines 166-180 sub GetWebserviceBatchId { Link Here
166
=cut
166
=cut
167
167
168
sub GetImportRecordMarc {
168
sub GetImportRecordMarc {
169
    my ($import_record_id) = @_;
169
    my ($import_record_id, $embeditems) = @_;
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
    #my ($marc, $encoding) = ( $import_record->{marc}, $import_record->{encoding} );
178
176
    return $marc, $encoding;
179
    return $marc, $encoding;
180
}
181
182
sub GetRecordFromImportBiblio {
183
    my ( $import_record_id, $embed_items ) = @_;
184
185
    my ($marc) = GetImportRecordMarc($import_record_id);
186
    my $record = MARC::Record->new_from_usmarc($marc);
177
187
188
    EmbedItemsInImportBiblio( $record, $import_record_id ) if $embed_items;
189
190
    return $record;
191
}
192
193
sub EmbedItemsInImportBiblio {
194
    my ( $record, $import_record_id ) = @_;
195
    my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField("items.itemnumber", '');
196
    my $dbh = C4::Context->dbh;
197
    my $import_items = $dbh->selectall_arrayref(q|
198
        SELECT import_items.marcxml
199
        FROM import_items
200
        WHERE import_record_id = ?
201
    |, { Slice => {} }, $import_record_id );
202
    my @item_fields;
203
    for my $import_item ( @$import_items ) {
204
        my $item_marc = MARC::Record::new_from_xml($import_item->{marcxml});
205
        push @item_fields, $item_marc->field($itemtag);
206
    }
207
    $record->append_fields(@item_fields);
208
    return $record;
178
}
209
}
179
210
180
=head2 GetImportRecordMarcXML
211
=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