From d1eb73149ee700b918cff15102dd7a54f4b99474 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
Rebased-on: 2019-02-20 - Alex Arnaud
Signed-off-by: Alex Arnaud
---
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 b2d53ae..521b9fd 100644
--- a/C4/ImportBatch.pm
+++ b/C4/ImportBatch.pm
@@ -380,21 +380,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 9b58229..228a88a 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
@@ -343,7 +343,7 @@
[% IF import_batch_id %]
-
+
@@ -650,6 +650,10 @@
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){
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 e169bcd..f8531a6 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
@@ -63,6 +63,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 %]
- Select a MARC file to stage in the import reservoir. It will be parsed, and each valid record staged for later import into the catalog.
- You can enter a name for this import. It may be useful, when creating a record, to remember where the suggested MARC data comes from!
@@ -102,6 +103,7 @@
+
-
diff --git a/tools/stage-marc-import.pl b/tools/stage-marc-import.pl
index d76c35a..a602f74 100755
--- a/tools/stage-marc-import.pl
+++ b/tools/stage-marc-import.pl
@@ -58,6 +58,7 @@ my $record_type = $input->param('record_type');
my $encoding = $input->param('encoding') || 'UTF-8';
my $format = $input->param('format') || 'ISO2709';
my $marc_modification_template = $input->param('marc_modification_template_id');
+my $existing_batch_id = $input->param('existing_batch_id');
my $basketno = $input->param('basketno');
my $booksellerid = $input->param('booksellerid');
@@ -149,7 +150,8 @@ if ($completedJobID) {
$marc_modification_template,
$comments, '',
$parse_items, 0,
- 50, staging_progress_callback( $job, $dbh )
+ 50, staging_progress_callback( $job, $dbh ),
+ $existing_batch_id
);
my $num_with_matches = 0;
@@ -226,6 +228,13 @@ if ($completedJobID) {
});
$template->param( plugins => \@plugins );
}
+
+ if ($existing_batch_id) {
+ $template->param(
+ existing_batch_id => $existing_batch_id,
+ existing_batch => GetImportBatch($existing_batch_id),
+ );
+ }
}
output_html_with_http_headers $input, $cookie, $template->output;
--
2.7.4