From 54021304856e344fd1e1e371f5095cbff3d4a43c Mon Sep 17 00:00:00 2001 From: Jesse Weaver Date: Tue, 24 Nov 2015 14:53:11 -0700 Subject: [PATCH] Bug 19265: Rancor - import records into existing batch To test: 1 - Manage some staged records 2 - Note that there is now an 'Import additional records' button 3 - Click it 4 - You sould be able to import as usual, but note the target batch is specified 5 - Complete the import 6 - Verify all previous functionality works --- C4/ImportBatch.pm | 28 ++++++++++++++-------- .../prog/en/modules/tools/manage-marc-import.tt | 6 ++++- .../prog/en/modules/tools/stage-marc-import.tt | 2 ++ tools/stage-marc-import.pl | 11 ++++++++- 4 files changed, 35 insertions(+), 12 deletions(-) diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm index de72b13..721f893 100644 --- a/C4/ImportBatch.pm +++ b/C4/ImportBatch.pm @@ -379,21 +379,29 @@ sub BatchStageMarcRecords { # of job my $progress_interval = 0; my $progress_callback = undef; - if ($#_ == 1) { + if ($#_ >= 1) { $progress_interval = shift; $progress_callback = shift; $progress_interval = 0 unless $progress_interval =~ /^\d+$/ and $progress_interval > 0; $progress_interval = 0 unless 'CODE' eq ref $progress_callback; - } + } + my $existing_batch_id = shift; - my $batch_id = AddImportBatch( { - overlay_action => 'create_new', - import_status => 'staging', - batch_type => 'batch', - file_name => $file_name, - comments => $comments, - record_type => $record_type, - } ); + my $batch_id; + + if ( $existing_batch_id ) { + $batch_id = $existing_batch_id; + } else { + $batch_id = AddImportBatch( { + overlay_action => 'create_new', + import_status => 'staging', + batch_type => 'batch', + file_name => $file_name, + comments => $comments, + record_type => $record_type, + } ); + } + if ($parse_items) { SetImportBatchItemAction($batch_id, 'always_add'); } else { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt index e9d171a..8a69bb3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt @@ -150,6 +150,10 @@ $(document).ready(function(){ window.open( '/cgi-bin/koha/svc/cataloguing/import_batches/' + [% import_batch_id %] + '?download=1&' + $.param( options ) ); return false; }); + $('#import-additional').click( function() { + window.open( '/cgi-bin/koha/tools/stage-marc-import.pl?existing_batch_id=' + [% import_batch_id %] ); + return false; + }); [% END %] $("body").on("click",".previewMARC", function(e){ e.preventDefault(); @@ -510,7 +514,7 @@ $(document).ready(function(){ [% IF import_batch_id %]
- +
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt index 29a49a8..67a48c7 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stage-marc-import.tt @@ -58,6 +58,7 @@ [% END %] [% ELSE %] +[% IF ( existing_batch_id ) %]

Importing records into existing batch

Records will be added to the existing batch "[% existing_batch.file_name %]" (#[% existing_batch_id %]).

[% END %]