View | Details | Raw Unified | Return to bug 19266
Collapse All | Expand All

(-)a/C4/Biblio.pm (-7 / +27 lines)
Lines 2907-2912 sub _koha_delete_biblio_metadata { Link Here
2907
2907
2908
=head1 UNEXPORTED FUNCTIONS
2908
=head1 UNEXPORTED FUNCTIONS
2909
2909
2910
=head2 UpdateMarcTimestamp
2911
2912
  &UpdateMarcTimestamp({ record => $record, encoding => $encoding });
2913
2914
Updates the 005 timestamp of the given record to the current time.
2915
2916
=cut
2917
2918
sub UpdateMarcTimestamp {
2919
    my $params = shift;
2920
    my $encoding = $params->{encoding};
2921
    my $record   = $params->{record};
2922
2923
    if($encoding =~ /MARC21|UNIMARC/) {
2924
        my @a= (localtime) [5,4,3,2,1,0]; $a[0]+=1900; $a[1]++;
2925
        # YY MM DD HH MM SS (update year and month)
2926
        my $f005= $record->field('005');
2927
        unless ($f005) {
2928
            $f005 = MARC::Field->new('005');
2929
            $record->insert_fields_ordered( $f005 );
2930
        }
2931
        $f005->update(sprintf("%4d%02d%02d%02d%02d%04.1f",@a));
2932
    }
2933
}
2934
2910
=head2 ModBiblioMarc
2935
=head2 ModBiblioMarc
2911
2936
2912
  &ModBiblioMarc($newrec,$biblionumber);
2937
  &ModBiblioMarc($newrec,$biblionumber);
Lines 2952-2964 sub ModBiblioMarc { Link Here
2952
        }
2977
        }
2953
    }
2978
    }
2954
2979
2955
    #enhancement 5374: update transaction date (005) for marc21/unimarc
2980
    UpdateMarcTimestamp({ record => $record, encoding => $encoding });
2956
    if($encoding =~ /MARC21|UNIMARC/) {
2981
2957
      my @a= (localtime) [5,4,3,2,1,0]; $a[0]+=1900; $a[1]++;
2958
        # YY MM DD HH MM SS (update year and month)
2959
      my $f005= $record->field('005');
2960
      $f005->update(sprintf("%4d%02d%02d%02d%02d%04.1f",@a)) if $f005;
2961
    }
2962
2982
2963
    my $metadata = {
2983
    my $metadata = {
2964
        biblionumber => $biblionumber,
2984
        biblionumber => $biblionumber,
(-)a/C4/ImportBatch.pm (-28 / +107 lines)
Lines 48-53 BEGIN { Link Here
48
    AddItemsToImportBiblio
48
    AddItemsToImportBiblio
49
    ModAuthorityInBatch
49
    ModAuthorityInBatch
50
    ModBiblioInBatch
50
    ModBiblioInBatch
51
    CheckRecordControlNumberInBatch
51
52
52
    BatchStageMarcRecords
53
    BatchStageMarcRecords
53
    BatchFindDuplicates
54
    BatchFindDuplicates
Lines 309-314 sub ModBiblioInBatch { Link Here
309
310
310
}
311
}
311
312
313
=head2 CheckRecordControlNumberInBatch
314
315
  CheckRecordControlNumberInBatch( $marc_record, $batch_id[, $import_record_id] );
316
317
Check to see if the given record's control number is already in use in the given batch. If provided,
318
will check only for conflicts in records besides the given C<$import_batch_id>.
319
320
If a record with the given control number in the given batch exists, will return its C<import_record_id>.
321
322
=cut
323
324
sub CheckRecordControlNumberInBatch {
325
    my ( $marc_record, $batch_id, $import_record_id ) = @_;
326
327
    return unless ( $marc_record->field('001') );
328
329
    my %extra_conditions;
330
331
    $extra_conditions{'import_record.import_record_id'} = { '!=', $import_record_id } if ( $import_record_id );
332
333
    my $control_number = $marc_record->field('001')->data;
334
335
    my $schema = Koha::Database->new()->schema();
336
    return $schema->resultset('ImportBiblio')->search(
337
        {
338
            control_number => $control_number,
339
            'import_record.import_batch_id' => $batch_id,
340
            %extra_conditions
341
        },
342
        {
343
            join => 'import_record',
344
        }
345
    )->get_column('import_record.import_batch_id')->first();
346
}
347
312
=head2 AddAuthToBatch
348
=head2 AddAuthToBatch
313
349
314
  my $import_record_id = AddAuthToBatch($batch_id, $record_sequence,
350
  my $import_record_id = AddAuthToBatch($batch_id, $record_sequence,
Lines 348-354 sub ModAuthInBatch { Link Here
348
384
349
=head2 BatchStageMarcRecords
385
=head2 BatchStageMarcRecords
350
386
351
( $batch_id, $num_records, $num_items, @invalid_records ) =
387
{
388
    batch_id => $batch_id,
389
    num_records => $num_records,
390
    num_items => $num_items,
391
    invalid_record => \@invalid_records 
392
} = BatchStageMarcRecords({
393
        record_type => $record_type,
394
        encoding => $encoding,
395
        marc_records => $marc_records,
396
        file_name => $file_name,
397
        comments => $comments,
398
        [ control_number_handling => 'preserve' | 'overwrite' ],
399
        [ leave_as_staging => 1 ]
400
        [ marc_modification_template => $marc_modification_template, ]
401
        [ parse_items => 1 ]
402
        [ progress_interval => $progress_interval,
403
        progress_callback => \&progress_callback, ]
404
        [ timestamp_update => 'now' ],
405
    });
406
407
Any optional parameters are assumed to be no / off if omitted. If C<progress_interval> is specified, C<progress_callback> must be as well.
408
352
  BatchStageMarcRecords(
409
  BatchStageMarcRecords(
353
    $record_type,                $encoding,
410
    $record_type,                $encoding,
354
    $marc_records,               $file_name,
411
    $marc_records,               $file_name,
Lines 361-383 sub ModAuthInBatch { Link Here
361
=cut
418
=cut
362
419
363
sub BatchStageMarcRecords {
420
sub BatchStageMarcRecords {
364
    my $record_type = shift;
421
    my $params = shift;
365
    my $encoding = shift;
366
    my $marc_records = shift;
367
    my $file_name = shift;
368
    my $marc_modification_template = shift;
369
    my $comments = shift;
370
    my $branch_code = shift;
371
    my $parse_items = shift;
372
    my $leave_as_staging = shift;
373
422
374
    # optional callback to monitor status 
423
    # optional callback to monitor status 
375
    # of job
424
    # of job
376
    my $progress_interval = 0;
425
    my $progress_interval = 0;
377
    my $progress_callback = undef;
426
    my $progress_callback = undef;
378
    if ($#_ == 1) {
427
    if ( $params->{progress_interval} ) {
379
        $progress_interval = shift;
428
        $progress_interval = $params->{progress_interval};
380
        $progress_callback = shift;
429
        $progress_callback = $params->{progress_callback};
381
        $progress_interval = 0 unless $progress_interval =~ /^\d+$/ and $progress_interval > 0;
430
        $progress_interval = 0 unless $progress_interval =~ /^\d+$/ and $progress_interval > 0;
382
        $progress_interval = 0 unless 'CODE' eq ref $progress_callback;
431
        $progress_interval = 0 unless 'CODE' eq ref $progress_callback;
383
    } 
432
    } 
Lines 386-404 sub BatchStageMarcRecords { Link Here
386
            overlay_action => 'create_new',
435
            overlay_action => 'create_new',
387
            import_status => 'staging',
436
            import_status => 'staging',
388
            batch_type => 'batch',
437
            batch_type => 'batch',
389
            file_name => $file_name,
438
            file_name => $params->{file_name},
390
            comments => $comments,
439
            comments => $params->{comments},
391
            record_type => $record_type,
440
            record_type => $params->{record_type},
392
        } );
441
        } );
393
    if ($parse_items) {
442
    if ($params->{parse_items}) {
394
        SetImportBatchItemAction($batch_id, 'always_add');
443
        SetImportBatchItemAction($batch_id, 'always_add');
395
    } else {
444
    } else {
396
        SetImportBatchItemAction($batch_id, 'ignore');
445
        SetImportBatchItemAction($batch_id, 'ignore');
397
    }
446
    }
398
447
399
400
    my $marc_type = C4::Context->preference('marcflavour');
448
    my $marc_type = C4::Context->preference('marcflavour');
401
    $marc_type .= 'AUTH' if ($marc_type eq 'UNIMARC' && $record_type eq 'auth');
449
    $marc_type .= 'AUTH' if ($marc_type eq 'UNIMARC' && $params->{record_type} eq 'auth');
402
    my @invalid_records = ();
450
    my @invalid_records = ();
403
    my $num_valid = 0;
451
    my $num_valid = 0;
404
    my $num_items = 0;
452
    my $num_items = 0;
Lines 410-416 sub BatchStageMarcRecords { Link Here
410
            &$progress_callback($rec_num);
458
            &$progress_callback($rec_num);
411
        }
459
        }
412
460
413
        ModifyRecordWithTemplate( $marc_modification_template, $marc_record ) if ( $marc_modification_template );
461
        ModifyRecordWithTemplate( $params->{marc_modification_template}, $marc_record ) if ( $params->{marc_modification_template} );
414
462
415
        my $import_record_id;
463
        my $import_record_id;
416
        if (scalar($marc_record->fields()) == 0) {
464
        if (scalar($marc_record->fields()) == 0) {
Lines 419-443 sub BatchStageMarcRecords { Link Here
419
467
420
            # Normalize the record so it doesn't have separated diacritics
468
            # Normalize the record so it doesn't have separated diacritics
421
            SetUTF8Flag($marc_record);
469
            SetUTF8Flag($marc_record);
422
423
            $num_valid++;
470
            $num_valid++;
424
            if ($record_type eq 'biblio') {
471
425
                $import_record_id = AddBiblioToBatch($batch_id, $rec_num, $marc_record, $encoding, int(rand(99999)), 0);
472
            C4::Biblio::UpdateMarcTimestamp( $marc_record ) if ( $params->{timestamp_update} eq 'now' );
426
                if ($parse_items) {
473
            my $existing_import_record_id;
474
475
            if ( $params->{control_number_handling} ) {
476
                $existing_import_record_id = CheckRecordControlNumberInBatch( $marc_record, $batch_id );
477
478
                if ( $existing_import_record_id ) {
479
                    $num_matched_control_number++;
480
481
                    next if ( $params->{control_number_handling} eq 'preserve' );
482
                }
483
            }
484
485
            if ($params->{record_type} eq 'biblio') {
486
                if ( $existing_import_record_id ) {
487
                    $import_record_id = $existing_import_record_id;
488
                    ModBiblioInBatch( $import_record_id, $marc_record );
489
                } else {
490
                    $import_record_id = AddBiblioToBatch($batch_id, $rec_num, $marc_record, $params->{encoding}, int(rand(99999)), 0);
491
                }
492
493
                if ($params->{parse_items}) {
427
                    my @import_items_ids = AddItemsToImportBiblio($batch_id, $import_record_id, $marc_record, 0);
494
                    my @import_items_ids = AddItemsToImportBiblio($batch_id, $import_record_id, $marc_record, 0);
428
                    $num_items += scalar(@import_items_ids);
495
                    $num_items += scalar(@import_items_ids);
429
                }
496
                }
430
            } elsif ($record_type eq 'auth') {
497
            } elsif ($params->{record_type} eq 'auth') {
431
                $import_record_id = AddAuthToBatch($batch_id, $rec_num, $marc_record, $encoding, int(rand(99999)), 0, $marc_type);
498
                if ( $existing_import_record_id ) {
499
                    $import_record_id = $existing_import_record_id;
500
                    ModAuthInBatch( $import_record_id, $marc_record );
501
                } else {
502
                    $import_record_id = AddAuthToBatch($batch_id, $rec_num, $marc_record, $params->{encoding}, int(rand(99999)), 0, $marc_type);
503
                }
432
            }
504
            }
433
        }
505
        }
434
    }
506
    }
435
    unless ($leave_as_staging) {
507
    unless ($params->{leave_as_staging}) {
436
        SetImportBatchStatus($batch_id, 'staged');
508
        SetImportBatchStatus($batch_id, 'staged');
437
    }
509
    }
438
    # FIXME branch_code, number of bibs, number of items
510
    # FIXME branch_code, number of bibs, number of items
439
    _update_batch_record_counts($batch_id);
511
    _update_batch_record_counts($batch_id);
440
    return ($batch_id, $num_valid, $num_items, @invalid_records);
512
    return {
513
        batch_id => $batch_id,
514
        num_items => $num_items,
515
        num_valid => $num_valid,
516
        num_matched_control_number => $num_matched_control_number,
517
        invalid_records => \@invalid_records
518
    };
441
}
519
}
442
520
443
=head2 AddItemsToImportBiblio
521
=head2 AddItemsToImportBiblio
Lines 456-461 sub AddItemsToImportBiblio { Link Here
456
    my @import_items_ids = ();
534
    my @import_items_ids = ();
457
   
535
   
458
    my $dbh = C4::Context->dbh; 
536
    my $dbh = C4::Context->dbh; 
537
    $dbh->do( "DELETE FROM import_items WHERE import_record_id = ?", undef, $import_record_id );
459
    my ($item_tag,$item_subfield) = &GetMarcFromKohaField( "items.itemnumber" );
538
    my ($item_tag,$item_subfield) = &GetMarcFromKohaField( "items.itemnumber" );
460
    foreach my $item_field ($marc_record->field($item_tag)) {
539
    foreach my $item_field ($marc_record->field($item_tag)) {
461
        my $item_marc = MARC::Record->new();
540
        my $item_marc = MARC::Record->new();
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt (+30 lines)
Lines 68-73 Link Here
68
	<li>[% total | html %]  records in file</li>
68
	<li>[% total | html %]  records in file</li>
69
	<li>[% import_errors | html %] records not staged because of MARC error</li>
69
	<li>[% import_errors | html %] records not staged because of MARC error</li>
70
	<li>[% staged | html %] records staged</li>
70
	<li>[% staged | html %] records staged</li>
71
    [% IF control_number_handling %]
72
        <li>
73
            [% num_matched_control_number | html %] records with matching control number
74
            [% IF control_number_handling == 'preserve' %]
75
                (preserved)
76
            [% ELSIF control_number_handling == 'overwrite' %]
77
                (overwritten)
78
            [% END %]
79
        </li>
80
    [% END %]
71
    [% IF ( checked_matches ) %]
81
    [% IF ( checked_matches ) %]
72
	<li>[% matched | html %] records with at least one match in catalog per matching rule 
82
	<li>[% matched | html %] records with at least one match in catalog per matching rule 
73
        &quot;[% matcher_code | html %]&quot;</li>
83
        &quot;[% matcher_code | html %]&quot;</li>
Lines 216-221 Link Here
216
      </li>
226
      </li>
217
    </ol>
227
    </ol>
218
  </fieldset>
228
  </fieldset>
229
  <fieldset class="rows" id="record-update">
230
    <legend>Automatically update records?</legend>
231
    <ol>
232
        [% IF existing_batch_id %]
233
            <li><label for="control_number_handling">How to process 001:</label>
234
            <select name="control_number_handling" id="control_number_handling">
235
               <option value="">Ignore</option>
236
               <option value="overwrite">Overwrite existing records with same 001</option>
237
               <option value="preserve">Preserve existing records with same 001</option>
238
            </select>
239
            </li>
240
        [% END %]
241
        <li><label for="timestamp_update">How to process 005:</label>
242
        <select name="timestamp_update" id="timestamp_update">
243
           <option value="">Do not update 005</option>
244
           <option value="now">Set 005 to current date and time</option>
245
        </select>
246
        </li>
247
    </ol>
248
  </fieldset>
219
  <fieldset class="rows" id="items">
249
  <fieldset class="rows" id="items">
220
    <legend>Check for embedded item record data?</legend>
250
    <legend>Check for embedded item record data?</legend>
221
    <ol>
251
    <ol>
(-)a/misc/stage_file.pl (-19 / +21 lines)
Lines 142-163 sub process_batch { Link Here
142
142
143
    print "... staging MARC records -- please wait\n";
143
    print "... staging MARC records -- please wait\n";
144
    #FIXME: We should really allow the use of marc modification frameworks and to_marc plugins here if possible
144
    #FIXME: We should really allow the use of marc modification frameworks and to_marc plugins here if possible
145
    my ( $batch_id, $num_valid_records, $num_items, @import_errors ) =
145
    my (@import_errors) =
146
      BatchStageMarcRecords(
146
    my $stage_results = BatchStageMarcRecords( {
147
        $record_type,                      $params->{encoding},
147
        record_type => $record_type,
148
        $marc_records,                     $params->{input_file},
148
        encoding => $encoding,
149
        $params->{'marc_mod_template_id'}, $params->{batch_comment},
149
        marc_records => $marc_records,
150
        '',                                $params->{add_items},
150
        file_name => $input_file,
151
        0,                                 100,
151
        comments => $batch_comment,
152
        \&print_progress_and_commit
152
        parse_items => $add_items,
153
      );
153
        progress_interval => 100,
154
        progress_callback => \&print_progress_and_commit
155
    } );
154
    print "... finished staging MARC records\n";
156
    print "... finished staging MARC records\n";
155
157
156
    my $num_with_matches = 0;
158
    my $num_with_matches = 0;
157
    if ( $params->{match} ) {
159
    if ( $params->{match} ) {
158
        my $matcher = C4::Matcher->fetch( $params->{match} );
160
        my $matcher = C4::Matcher->fetch( $params->{match} );
159
        if (defined $matcher) {
161
        if (defined $matcher) {
160
            SetImportBatchMatcher( $batch_id, $params->{match} );
162
            SetImportBatchMatcher($stage_results->{batch_id}, $params->{match});
161
        } elsif ($record_type eq 'biblio')  {
163
        } elsif ($record_type eq 'biblio')  {
162
            $matcher = C4::Matcher->new($record_type);
164
            $matcher = C4::Matcher->new($record_type);
163
            $matcher->add_simple_matchpoint('isbn', 1000, '020', 'a', -1, 0, '');
165
            $matcher->add_simple_matchpoint('isbn', 1000, '020', 'a', -1, 0, '');
Lines 165-179 sub process_batch { Link Here
165
                                            '245', 'a', -1, 0, '');
167
                                            '245', 'a', -1, 0, '');
166
        }
168
        }
167
        # set default record overlay behavior
169
        # set default record overlay behavior
168
        SetImportBatchOverlayAction( $batch_id, $params->{no_replace} ? 'ignore' : 'replace' );
170
        SetImportBatchOverlayAction($stage_results->{batch_id}, $params->{no_replace} ? 'ignore' : 'replace');
169
        SetImportBatchNoMatchAction( $batch_id, $params->{no_create} ? 'ignore' : 'create_new' );
171
        SetImportBatchNoMatchAction($stage_results->{batch_id}, $params->{no_create} ? 'ignore' : 'create_new');
170
        SetImportBatchItemAction( $batch_id, $params->{item_action} );
172
        SetImportBatchItemAction($stage_results->{batch_id}, $params->{item_action} );
171
        print "... looking for matches with records already in database\n";
173
        print "... looking for matches with records already in database\n";
172
        $num_with_matches = BatchFindDuplicates($batch_id, $matcher, 10, 100, \&print_progress_and_commit);
174
        $num_with_matches = BatchFindDuplicates($stage_results->{batch_id}, $matcher, 10, 100, \&print_progress_and_commit);
173
        print "... finished looking for matches\n";
175
        print "... finished looking for matches\n";
174
    }
176
    }
175
177
176
    my $num_invalid_records = scalar(@import_errors);
178
    my $num_invalid_records = scalar( @{ $stage_results->{invalid_records} } );
177
    print <<_SUMMARY_;
179
    print <<_SUMMARY_;
178
180
179
MARC record staging report
181
MARC record staging report
Lines 181-187 MARC record staging report Link Here
181
Input file:                 $params->{input_file}
183
Input file:                 $params->{input_file}
182
Record type:                $record_type
184
Record type:                $record_type
183
Number of input records:    $num_input_records
185
Number of input records:    $num_input_records
184
Number of valid records:    $num_valid_records
186
Number of valid records:    $stage_results->{num_valid}
185
Number of invalid records:  $num_invalid_records
187
Number of invalid records:  $num_invalid_records
186
_SUMMARY_
188
_SUMMARY_
187
    if( $params->{match} ) {
189
    if( $params->{match} ) {
Lines 190-204 _SUMMARY_ Link Here
190
        print "Incoming records not matched against existing records (--match option not supplied)\n";
192
        print "Incoming records not matched against existing records (--match option not supplied)\n";
191
    }
193
    }
192
    if ($record_type eq 'biblio') {
194
    if ($record_type eq 'biblio') {
193
        if ( $params->{add_items} ) {
195
        if ($params->{add_items} ) {
194
            print "Number of items parsed:  $num_items\n";
196
            print "Number of items parsed:  $stage_results->{num_items}\n";
195
        } else {
197
        } else {
196
            print "No items parsed (--add-items option not supplied)\n";
198
            print "No items parsed (--add-items option not supplied)\n";
197
        }
199
        }
198
    }
200
    }
199
201
200
    print "\n";
202
    print "\n";
201
    print "Batch number assigned:  $batch_id\n";
203
    print "Batch number assigned:  $stage_results->{batch_id}\n";
202
    print "\n";
204
    print "\n";
203
}
205
}
204
206
(-)a/tools/stage-marc-import.pl (-33 / +28 lines)
Lines 142-156 if ($completedJobID) { Link Here
142
    $schema->storage->txn_begin;
142
    $schema->storage->txn_begin;
143
143
144
    # FIXME branch code
144
    # FIXME branch code
145
    my ( $batch_id, $num_valid, $num_items, @import_errors ) =
145
    my $stage_results = BatchStageMarcRecords( {
146
      BatchStageMarcRecords(
146
        record_type => $record_type,
147
        $record_type,    $encoding,
147
        encoding => $encoding,
148
        $marcrecords,    $filename,
148
        marc_records => $marcrecords,
149
        $marc_modification_template,
149
        file_name => $filename,
150
        $comments,       '',
150
        marc_modification_template => $marc_modification_template,
151
        $parse_items,    0,
151
        comments => $comments,
152
        50, staging_progress_callback( $job )
152
        parse_items => $parse_items,
153
      );
153
        progress_interval => 50,
154
        progress_callback => staging_progress_callback( $job ),
155
        existing_batch_id => $existing_batch_id,
156
        control_number_handling => $control_number_handling,
157
        timestamp_update => $timestamp_update,
158
    } );
154
159
155
    if($profile_id) {
160
    if($profile_id) {
156
        my $ibatch = Koha::ImportBatches->find($batch_id);
161
        my $ibatch = Koha::ImportBatches->find($batch_id);
Lines 167-178 if ($completedJobID) { Link Here
167
            $checked_matches = 1;
172
            $checked_matches = 1;
168
            $matcher_code = $matcher->code();
173
            $matcher_code = $matcher->code();
169
            $num_with_matches =
174
            $num_with_matches =
170
              BatchFindDuplicates( $batch_id, $matcher, 10, 50,
175
              BatchFindDuplicates( $stage_results->{batch_id}, $matcher, 10, 50,
171
                matching_progress_callback($job) );
176
                matching_progress_callback($job) );
172
            SetImportBatchMatcher($batch_id, $matcher_id);
177
            SetImportBatchMatcher($stage_results->{batch_id}, $matcher_id);
173
            SetImportBatchOverlayAction($batch_id, $overlay_action);
178
            SetImportBatchOverlayAction($stage_results->{batch_id}, $overlay_action);
174
            SetImportBatchNoMatchAction($batch_id, $nomatch_action);
179
            SetImportBatchNoMatchAction($stage_results->{batch_id}, $nomatch_action);
175
            SetImportBatchItemAction($batch_id, $item_action);
180
            SetImportBatchItemAction($stage_results->{batch_id}, $item_action);
176
            $schema->storage->txn_commit;
181
            $schema->storage->txn_commit;
177
        } else {
182
        } else {
178
            $matcher_failed = 1;
183
            $matcher_failed = 1;
Lines 183-216 if ($completedJobID) { Link Here
183
    }
188
    }
184
189
185
    my $results = {
190
    my $results = {
186
        staged          => $num_valid,
191
        staged          => $stage_results->{num_valid},
187
        matched         => $num_with_matches,
192
        matched         => $num_with_matches,
188
        num_items       => $num_items,
193
        num_items       => $stage_results->{num_items},
189
        import_errors   => scalar(@import_errors),
194
        import_errors   => scalar( @{ $stage_results->{invalid_records} } ),
190
        total           => $num_valid + scalar(@import_errors),
195
        total           => $stage_results->{num_valid} + scalar( @{ $stage_results->{invalid_records} } ),
191
        checked_matches => $checked_matches,
196
        checked_matches => $checked_matches,
192
        matcher_failed  => $matcher_failed,
197
        matcher_failed  => $matcher_failed,
193
        matcher_code    => $matcher_code,
198
        matcher_code    => $matcher_code,
194
        import_batch_id => $batch_id,
199
        import_batch_id => $stage_results->{batch_id},
195
        booksellerid    => $booksellerid,
200
        booksellerid    => $booksellerid,
196
        basketno        => $basketno
201
        basketno        => $basketno,
202
        control_number_handling => $control_number_handling,
203
        num_matched_control_number => $stage_results->{num_matched_control_number},
197
    };
204
    };
198
    if ($runinbackground) {
205
    if ($runinbackground) {
199
        $job->finish($results);
206
        $job->finish($results);
200
        exit 0;
207
        exit 0;
201
    } else {
208
    } else {
202
	    $template->param(staged => $num_valid,
209
        $template->param( %$results );
203
 	                     matched => $num_with_matches,
204
                         num_items => $num_items,
205
                         import_errors => scalar(@import_errors),
206
                         total => $num_valid + scalar(@import_errors),
207
                         checked_matches => $checked_matches,
208
                         matcher_failed => $matcher_failed,
209
                         matcher_code => $matcher_code,
210
                         import_batch_id => $batch_id,
211
                         booksellerid => $booksellerid,
212
                         basketno => $basketno
213
                        );
214
    }
210
    }
215
211
216
} else {
212
} else {
217
- 

Return to bug 19266