5 # find Koha's Perl modules
6 # test carefully before changing this
8 eval { require "$FindBin::Bin/kohalib.pl" };
17 # command-line parameters
18 my $batch_number = "";
22 my $result = GetOptions
(
23 'batch-number:s' => \
$batch_number,
24 'list-batches' => \
$list_batches,
25 'h|help' => \
$want_help
28 if ($want_help or (not $batch_number and not $list_batches)) {
38 # FIXME dummy user so that logging won't fail
39 # in future, probably should tie to a real user account
40 C4
::Context
->set_userenv(0, 'batch', 0, 'batch', 'batch', 'batch', 'batch', 'batch');
42 if ($batch_number =~ /^\d+$/ and $batch_number > 0) {
43 my $batch = GetImportBatch
($batch_number);
44 die "$0: import batch $batch_number does not exist in database\n" unless defined $batch;
45 die "$0: import batch $batch_number status is '" . $batch->{'import_status'} . "', and therefore cannot be imported\n"
46 unless $batch->{'import_status'} eq "staged" or $batch->{'import_status'} eq "reverted";
47 process_batch
($batch_number);
49 die "$0: please specify a numeric batch ID\n";
55 my $results = GetAllImportBatches
();
56 print sprintf("%5.5s %-25.25s %-25.25s %-10.10s\n", "#", "File name", "Batch comments", "Status");
57 print '-' x
5, ' ' , '-' x
25, ' ', '-' x
25, ' ', '-' x
10, "\n" ;
58 foreach my $batch (@
{ $results}) {
59 if ($batch->{'import_status'} eq "staged" or $batch->{'import_status'} eq "reverted") {
60 print sprintf("%5.5s %-25.25s %-25.25s %-10.10s\n",
61 $batch->{'import_batch_id'},
62 $batch->{'file_name'},
64 $batch->{'import_status'});
70 my ($import_batch_id) = @_;
72 print "... importing MARC records -- please wait\n";
73 my ($num_added, $num_updated, $num_items_added, $num_items_errored, $num_ignored) =
74 BatchCommitBibRecords
($import_batch_id, 100, \
&print_progress
);
75 print "... finished importing MARC records\n";
79 MARC record import report
80 ----------------------------------------
81 Batch number
: $import_batch_id
82 Number of new bibs added
: $num_added
83 Number of bibs replaced
: $num_updated
84 Number of bibs ignored
: $num_ignored
85 Number of items added
: $num_items_added
86 Number of items ignored
: $num_items_errored
88 Note
: an item is ignored
if its barcode is a
89 duplicate of one already
in the database
.
95 print "... processed $recs records\n";
100 $0: import a batch of staged MARC records into database
.
102 Use this batch job to complete the import of a batch of
103 MARC records that was staged either by the batch job
104 stage_biblios_file
.pl
or by the Koha Tools option
105 "Stage MARC Records for Import".
108 --batch
-number
<#> number of the record batch
110 --list
-batches
print a list of record batches
112 --help
or -h show this message
.