X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=misc%2Fcommit_file.pl;h=1e1dd3f4fe35b254eb9241909c3896d7d960bb7e;hb=21bc236e57bfaa46b80602e3d34f0f6f2175d14a;hp=9c1089ad2c9841e84cceb29b95920e225d63cde8;hpb=1fd99527bd947a6d2d86822fb9fd964fc35cc582;p=koha-ffzg.git diff --git a/misc/commit_file.pl b/misc/commit_file.pl index 9c1089ad2c..1e1dd3f4fe 100755 --- a/misc/commit_file.pl +++ b/misc/commit_file.pl @@ -2,16 +2,11 @@ use strict; use warnings; -BEGIN { - # find Koha's Perl modules - # test carefully before changing this - use FindBin; - eval { require "$FindBin::Bin/kohalib.pl" }; -} +use Koha::Script; use C4::Context; -use C4::ImportBatch; -use Getopt::Long; +use C4::ImportBatch qw( GetAllImportBatches GetImportBatch BatchCommitRecords BatchRevertRecords ); +use Getopt::Long qw( GetOptions ); $| = 1; @@ -20,10 +15,12 @@ my $batch_number = ""; my $list_batches = 0; my $revert = 0; my $want_help = 0; +my $framework = ''; my $result = GetOptions( 'batch-number:s' => \$batch_number, 'list-batches' => \$list_batches, + 'framework:s' => \$framework, 'revert' => \$revert, 'h|help' => \$want_help ); @@ -40,7 +37,7 @@ if ($list_batches) { # FIXME dummy user so that logging won't fail # in future, probably should tie to a real user account -C4::Context->set_userenv(0, 'batch', 0, 'batch', 'batch', 'batch', 'batch', 'batch'); +C4::Context->set_userenv(0, 'batch', 0, 'batch', 'batch', 'batch', 'batch'); my $dbh = C4::Context->dbh; $dbh->{AutoCommit} = 0; @@ -82,8 +79,8 @@ sub process_batch { my ($import_batch_id) = @_; print "... importing MARC records -- please wait\n"; - my ($num_added, $num_updated, $num_items_added, $num_items_errored, $num_ignored) = - BatchCommitRecords($import_batch_id, '', 100, \&print_progress_and_commit); + my ($num_added, $num_updated, $num_items_added, $num_items_replaced, $num_items_errored, $num_ignored) = + BatchCommitRecords($import_batch_id, $framework, 100, \&print_progress_and_commit); print "... finished importing MARC records\n"; print <<_SUMMARY_; @@ -95,6 +92,7 @@ Number of new records added: $num_added Number of records replaced: $num_updated Number of records ignored: $num_ignored Number of items added: $num_items_added +Number of items replaced: $num_items_replaced Number of items ignored: $num_items_errored Note: an item is ignored if its barcode is a @@ -143,6 +141,8 @@ stage_file.pl or by the Koha Tools option Parameters: --batch-number <#> number of the record batch to import + --framework add new records using this framework. If + omitted, the default framework is used. --list-batches print a list of record batches available to commit --revert revert a batch instead of importing it