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 |