=head2 BatchStageMarcRecords
($batch_id, $num_records, $num_items, @invalid_records) =
=head2 BatchStageMarcRecords
($batch_id, $num_records, $num_items, @invalid_records) =
- BatchStageMarcRecords($marc_flavor, $marc_records, $file_name,
+ BatchStageMarcRecords($encoding, $marc_records, $file_name,
$comments, $branch_code, $parse_items,
$leave_as_staging,
$progress_interval, $progress_callback);
$comments, $branch_code, $parse_items,
$leave_as_staging,
$progress_interval, $progress_callback);
&$progress_callback($rec_num);
}
my ($marc_record, $charset_guessed, $char_errors) =
&$progress_callback($rec_num);
}
my ($marc_record, $charset_guessed, $char_errors) =
- MarcToUTF8Record($marc_blob, C4::Context->preference("marcflavour"));
+ MarcToUTF8Record($marc_blob, C4::Context->preference("marcflavour"), $encoding);
+
+ $encoding = $charset_guessed unless $encoding;
+
my $import_record_id;
if (scalar($marc_record->fields()) == 0) {
push @invalid_records, $marc_blob;
} else {
$num_valid++;
my $import_record_id;
if (scalar($marc_record->fields()) == 0) {
push @invalid_records, $marc_blob;
} else {
$num_valid++;
- $import_record_id = AddBiblioToBatch($batch_id, $rec_num, $marc_record, $marc_flavor, int(rand(99999)), 0);
+ $import_record_id = AddBiblioToBatch($batch_id, $rec_num, $marc_record, $encoding, int(rand(99999)), 0);
if ($parse_items) {
my @import_items_ids = AddItemsToImportBiblio($batch_id, $import_record_id, $marc_record, 0);
$num_items += scalar(@import_items_ids);
if ($parse_items) {
my @import_items_ids = AddItemsToImportBiblio($batch_id, $import_record_id, $marc_record, 0);
$num_items += scalar(@import_items_ids);
=head2 BatchCommitBibRecords
my ($num_added, $num_updated, $num_items_added, $num_items_errored,
=head2 BatchCommitBibRecords
my ($num_added, $num_updated, $num_items_added, $num_items_errored,
$progress_interval, $progress_callback);
=cut
sub BatchCommitBibRecords {
my $batch_id = shift;
$progress_interval, $progress_callback);
=cut
sub BatchCommitBibRecords {
my $batch_id = shift;
my $sth = $dbh->prepare_cached("UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?");
$sth->execute($biblionumber, $rowref->{'import_record_id'});
$sth->finish();
my $sth = $dbh->prepare_cached("UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?");
$sth->execute($biblionumber, $rowref->{'import_record_id'});
$sth->finish();
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare("UPDATE import_records SET marc = ?, marcxml = ?
WHERE import_record_id = ?");
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare("UPDATE import_records SET marc = ?, marcxml = ?
WHERE import_record_id = ?");
- $sth->execute($marc_record->as_usmarc(), $marc_record->as_xml(), $import_record_id);
+ $sth->execute($marc_record->as_usmarc(), $marc_record->as_xml(C4::Context->preference('marcflavour')), $import_record_id);