X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=svc%2Fimport_bib;h=d5727e6589665d748f57df3d13be4d4b8bd7e21c;hb=9a8b5003dc7dd2208fcd7ef0e2ae01f4232db17d;hp=c6112249f3e0e3d029d8b1f453ea335567fe4926;hpb=36c3d454262d814c2174483bec2a6a181c3fd3b0;p=koha-ffzg.git diff --git a/svc/import_bib b/svc/import_bib index c6112249f3..d5727e6589 100755 --- a/svc/import_bib +++ b/svc/import_bib @@ -18,18 +18,17 @@ # along with Koha; if not, see . # -use strict; -use warnings; +use Modern::Perl; use CGI qw ( -utf8 ); use C4::Auth qw/check_api_auth/; use C4::Context; -use C4::ImportBatch; +use C4::ImportBatch qw( GetWebserviceBatchId AddBiblioToBatch AddItemsToImportBiblio BatchFindDuplicates BatchCommitRecords ); use C4::Matcher; use XML::Simple; # use Carp::Always; -my $query = new CGI; +my $query = CGI->new; binmode STDOUT, ':encoding(UTF-8)'; my ($status, $cookie, $sessionID) = check_api_auth($query, { editcatalogue => 'edit_catalogue'} ); @@ -74,14 +73,18 @@ sub import_bib { } my $marcflavour = C4::Context->preference('marcflavour') || 'MARC21'; - my $marc_record = eval {MARC::Record::new_from_xml( $inxml, "utf8", $marcflavour)}; + my $marc_record = eval {MARC::Record::new_from_xml( $inxml, "UTF-8", $marcflavour)}; if ($@) { $result->{'status'} = "failed"; $result->{'error'} = $@; return $result; } + if(C4::Context->preference('autoControlNumber') eq 'biblionumber'){ + my @control_num = $marc_record->field('001'); + $marc_record->delete_fields(@control_num); + } - my $import_record_id = AddBiblioToBatch($batch_id, 0, $marc_record, "utf8", int(rand(99999))); + my $import_record_id = AddBiblioToBatch($batch_id, 0, $marc_record, "utf8", 1); my @import_items_ids = AddItemsToImportBiblio($batch_id, $import_record_id, $marc_record, 'UPDATE COUNTS'); my $matcher = C4::Matcher->new($params->{record_type} || 'biblio'); @@ -89,7 +92,10 @@ sub import_bib { my $number_of_matches = BatchFindDuplicates($batch_id, $matcher); # XXX we are ignoring the result of this; - BatchCommitRecords($batch_id, $framework) if lc($import_mode) eq 'direct'; + BatchCommitRecords({ + batch_id => $batch_id, + framework => $framework + }) if lc($import_mode) eq 'direct'; my $dbh = C4::Context->dbh(); my $sth = $dbh->prepare("SELECT matched_biblionumber FROM import_biblios WHERE import_record_id =?");