11 # command-line parameters
12 my $batch_number = "";
16 my $result = GetOptions
(
17 'batch-number:s' => \
$batch_number,
18 'list-batches' => \
$list_batches,
19 'h|help' => \
$want_help
22 if ($want_help or (not $batch_number and not $list_batches)) {
32 # FIXME dummy user so that logging won't fail
33 # in future, probably should tie to a real user account
34 C4
::Context
->set_userenv(0, 'batch', 0, 'batch', 'batch', 'batch', 'batch', 'batch');
36 if ($batch_number =~ /^\d+$/ and $batch_number > 0) {
37 my $batch = GetImportBatch
($batch_number);
38 die "$0: import batch $batch_number does not exist in database\n" unless defined $batch;
39 die "$0: import batch $batch_number status is '" . $batch->{'import_status'} . "', and therefore cannot be imported\n"
40 unless $batch->{'import_status'} eq "staged" or $batch->{'import_status'} eq "reverted";
41 process_batch
($batch_number);
43 die "$0: please specify a numeric batch ID\n";
49 my $results = GetAllImportBatches
();
50 print sprintf("%5.5s %-25.25s %-25.25s %-10.10s\n", "#", "File name", "Batch comments", "Status");
51 print '-' x
5, ' ' , '-' x
25, ' ', '-' x
25, ' ', '-' x
10, "\n" ;
52 foreach my $batch (@
{ $results}) {
53 if ($batch->{'import_status'} eq "staged" or $batch->{'import_status'} eq "reverted") {
54 print sprintf("%5.5s %-25.25s %-25.25s %-10.10s\n",
55 $batch->{'import_batch_id'},
56 $batch->{'file_name'},
58 $batch->{'import_status'});
64 my ($import_batch_id) = @_;
66 print "... importing MARC records -- please wait\n";
67 my ($num_added, $num_updated, $num_items_added, $num_ignored) = BatchCommitBibRecords
($import_batch_id, 100, \
&print_progress
);
68 print "... finished importing MARC records\n";
72 MARC record import report
73 ----------------------------------------
74 Batch number
: $import_batch_id
75 Number of new bibs added
: $num_added
76 Number of bibs replaced
: $num_updated
77 Number of bibs ignored
: $num_ignored
78 Number of items added
: $num_items_added
84 print "... processed $recs records\n";
89 $0: import a batch of staged MARC records into database
.
91 Use this batch job to complete the import of a batch of
92 MARC records that was staged either by the batch job
93 stage_biblios_file
.pl
or by the Koha Tools option
94 "Stage MARC Records for Import".
97 --batch
-number
<#> number of the record batch
99 --list
-batches
print a list of record batches
101 --help
or -h show this message
.