X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=C4%2FImportBatch.pm;h=63cc60b600c0a9b531f5d7a1f3a7e64d28a3a130;hb=f446b3d03d574e145bbc8f3e241ce2711c935643;hp=f5b42a9f3778921c1a35a5de8afaef8dd78f2247;hpb=f46abf8b909257a54c9e2c1fdd999ba30c7ac0ae;p=koha_gimpoz diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm index f5b42a9f37..63cc60b600 100644 --- a/C4/ImportBatch.pm +++ b/C4/ImportBatch.pm @@ -210,7 +210,7 @@ sub ModBiblioInBatch { =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); @@ -218,7 +218,7 @@ sub ModBiblioInBatch { =cut sub BatchStageMarcRecords { - my $marc_flavor = shift; + my $encoding = shift; my $marc_records = shift; my $file_name = shift; my $comments = shift; @@ -258,13 +258,16 @@ sub BatchStageMarcRecords { &$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++; - $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); @@ -389,13 +392,14 @@ sub BatchFindBibDuplicates { =head2 BatchCommitBibRecords my ($num_added, $num_updated, $num_items_added, $num_items_errored, - $num_ignored) = BatchCommitBibRecords($batch_id, + $num_ignored) = BatchCommitBibRecords($batch_id, $framework, $progress_interval, $progress_callback); =cut sub BatchCommitBibRecords { my $batch_id = shift; + my $framework = shift; # optional callback to monitor status # of job @@ -451,7 +455,7 @@ sub BatchCommitBibRecords { if ($bib_result eq 'create_new') { $num_added++; - my ($biblionumber, $biblioitemnumber) = AddBiblio($marc_record, ''); + my ($biblionumber, $biblioitemnumber) = AddBiblio($marc_record, $framework); my $sth = $dbh->prepare_cached("UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?"); $sth->execute($biblionumber, $rowref->{'import_record_id'}); $sth->finish(); @@ -1146,7 +1150,7 @@ sub _update_import_record_marc { 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); $sth->finish(); }