From 55440916aee5af02760007fc305e17abad472ff0 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 13 Sep 2016 15:23:50 +0000 Subject: [PATCH] Bug 15869 - change framework on overlay This patch allows for selection of framework to use when overlaying records - by default it is set to keep the initial framework To test: 1 - Create some records using one framework 2 - Export the records 3 - Edit the records to add fields not in original framework 4 - Stage records using a rule that will find matches 5 - Import 6 - Note records contain new fields on display, but they are lost on edit 7 - Apply patch 8 - Stage records again 9 - Select a framework that contains the new fields on import 10 - Import records 11 - Note records now use selected framework and are displayed/edited correctly --- C4/ImportBatch.pm | 5 +++-- .../intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt | 9 +++++++++ tools/manage-marc-import.pl | 7 ++++--- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm index 88d670d..fc2c6bde 100644 --- a/C4/ImportBatch.pm +++ b/C4/ImportBatch.pm @@ -567,6 +567,7 @@ sub BatchFindDuplicates { sub BatchCommitRecords { my $batch_id = shift; my $framework = shift; + my $overlay_framework = shift; # optional callback to monitor status # of job @@ -673,8 +674,8 @@ sub BatchCommitRecords { $old_marc->delete_field($item_field); } $oldxml = $old_marc->as_xml($marc_type); - - ModBiblio($marc_record, $recordid, $oldbiblio->{'frameworkcode'}); + if ($overlay_framework == '_USE_ORIG_') { $overlay_framework = $oldbiblio->{'frameworkcode'}; } + ModBiblio($marc_record, $recordid, $overlay_framework); $query = "UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?"; if ($item_result eq 'create_new' || $item_result eq 'replace') { 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 f89ec73..5adffb6 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 @@ -364,6 +364,15 @@ $(document).ready(function(){ [% END %] +
+ When replacing records use this framework: + [% END %] diff --git a/tools/manage-marc-import.pl b/tools/manage-marc-import.pl index 83abc91..5c61fcc 100755 --- a/tools/manage-marc-import.pl +++ b/tools/manage-marc-import.pl @@ -106,7 +106,8 @@ if ($op eq "") { add_saved_job_results_to_template($template, $completedJobID); } else { my $framework = $input->param('framework'); - commit_batch($template, $import_batch_id, $framework); + my $overlay_framework = $input->param('overlay_framework'); + commit_batch($template, $import_batch_id, $framework, $overlay_framework); } import_records_list($template, $import_batch_id, $offset, $results_per_page); } elsif ($op eq "revert-batch") { @@ -237,7 +238,7 @@ sub import_batches_list { } sub commit_batch { - my ($template, $import_batch_id, $framework) = @_; + my ($template, $import_batch_id, $framework, $overlay_framework) = @_; my $job = undef; $dbh->{AutoCommit} = 0; @@ -247,7 +248,7 @@ sub commit_batch { $callback = progress_callback($job, $dbh); } my ($num_added, $num_updated, $num_items_added, $num_items_replaced, $num_items_errored, $num_ignored) = - BatchCommitRecords($import_batch_id, $framework, 50, $callback); + BatchCommitRecords($import_batch_id, $framework, $overlay_framework, 50, $callback); $dbh->commit(); my $results = { -- 2.1.4