|
Lines 1-7
Link Here
|
| 1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
| 2 |
|
2 |
|
| 3 |
use strict; |
3 |
use Modern::Perl; |
| 4 |
use warnings; |
4 |
|
| 5 |
BEGIN { |
5 |
BEGIN { |
| 6 |
# find Koha's Perl modules |
6 |
# find Koha's Perl modules |
| 7 |
# test carefully before changing this |
7 |
# test carefully before changing this |
|
Lines 45-52
if ($list_batches) {
Link Here
|
| 45 |
# in future, probably should tie to a real user account |
45 |
# in future, probably should tie to a real user account |
| 46 |
C4::Context->set_userenv(0, 'batch', 0, 'batch', 'batch', 'batch', 'batch'); |
46 |
C4::Context->set_userenv(0, 'batch', 0, 'batch', 'batch', 'batch', 'batch'); |
| 47 |
|
47 |
|
| 48 |
my $dbh = C4::Context->dbh; |
|
|
| 49 |
$dbh->{AutoCommit} = 0; |
| 50 |
if ($batch_number =~ /^\d+$/ and $batch_number > 0) { |
48 |
if ($batch_number =~ /^\d+$/ and $batch_number > 0) { |
| 51 |
my $batch = GetImportBatch($batch_number); |
49 |
my $batch = GetImportBatch($batch_number); |
| 52 |
die "$0: import batch $batch_number does not exist in database\n" unless defined $batch; |
50 |
die "$0: import batch $batch_number does not exist in database\n" unless defined $batch; |
|
Lines 59-65
if ($batch_number =~ /^\d+$/ and $batch_number > 0) {
Link Here
|
| 59 |
unless $batch->{'import_status'} eq "staged" or $batch->{'import_status'} eq "reverted"; |
57 |
unless $batch->{'import_status'} eq "staged" or $batch->{'import_status'} eq "reverted"; |
| 60 |
process_batch($batch_number); |
58 |
process_batch($batch_number); |
| 61 |
} |
59 |
} |
| 62 |
$dbh->commit(); |
|
|
| 63 |
} else { |
60 |
} else { |
| 64 |
die "$0: please specify a numeric batch ID\n"; |
61 |
die "$0: please specify a numeric batch ID\n"; |
| 65 |
} |
62 |
} |
|
Lines 130-138
_SUMMARY_
Link Here
|
| 130 |
|
127 |
|
| 131 |
|
128 |
|
| 132 |
sub print_progress_and_commit { |
129 |
sub print_progress_and_commit { |
| 133 |
my $recs = shift; |
130 |
my ( $recs, $schema ) = @_; |
| 134 |
print "... processed $recs records\n"; |
131 |
print "... processed $recs records\n"; |
| 135 |
$dbh->commit(); |
132 |
$schema->txn_commit; |
| 136 |
} |
133 |
} |
| 137 |
|
134 |
|
| 138 |
sub print_usage { |
135 |
sub print_usage { |
| 139 |
- |
|
|