Bugzilla – Attachment 60164 Details for
Bug 14578
Allow merging of records upon import match
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14578: Allow manual merging of import records on match
Bug-14578-Allow-manual-merging-of-import-records-o.patch (text/plain), 33.98 KB, created by
Kyle M Hall (khall)
on 2017-02-13 16:56:30 UTC
(
hide
)
Description:
Bug 14578: Allow manual merging of import records on match
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2017-02-13 16:56:30 UTC
Size:
33.98 KB
patch
obsolete
>From 424082651140d58c1b9583c6a87011d535ba181f Mon Sep 17 00:00:00 2001 >From: Jesse Weaver <jweaver@bywatersolutions.com> >Date: Wed, 9 Mar 2016 17:01:25 -0700 >Subject: [PATCH] Bug 14578: Allow manual merging of import records on match > >Test plan: > 1) Ensure that normal record merging still correctly functions. > 2) Import a record that matches an existing record (exporting an > existing record and reimporting it is an easy way to test this). > 3) On the manage import batch page, there should now be a link to > Merge. > 4) Clicking this and going through the merge process should leave both > records in place but update the import record. > >Sponsored-by: Rutgers School of Law > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >Signed-off-by: Heather Mitchell <hlm@camden.rutgers.edu> >--- > C4/ImportBatch.pm | 2 +- > cataloguing/merge.pl | 275 +++++++++++++++------ > koha-tmpl/intranet-tmpl/prog/css/merge-record.css | 61 +++++ > .../prog/en/includes/authorities_js.inc | 2 +- > .../prog/en/includes/merge-record.inc | 9 +- > .../prog/en/modules/cataloguing/addbooks.tt | 2 +- > .../prog/en/modules/cataloguing/merge.tt | 25 +- > .../prog/en/modules/tools/manage-marc-import.tt | 5 +- > .../prog/en/modules/virtualshelves/shelves.tt | 2 +- > koha-tmpl/intranet-tmpl/prog/js/merge-record.js | 58 +++++ > tools/batch_records_ajax.pl | 7 +- > 11 files changed, 343 insertions(+), 105 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/css/merge-record.css > >diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm >index 88d670d..ec01c0e 100644 >--- a/C4/ImportBatch.pm >+++ b/C4/ImportBatch.pm >@@ -1125,7 +1125,7 @@ sub GetImportRecordsRange { > > $order_by .= " $order_by_direction, authorized_heading" if $order_by eq 'title'; > >- my $query = "SELECT title, author, isbn, issn, authorized_heading, import_records.import_record_id, >+ my $query = "SELECT title, author, isbn, issn, authorized_heading, import_records.import_record_id, import_records.import_batch_id, > record_sequence, status, overlay_status, > matched_biblionumber, matched_authid, record_type > FROM import_records >diff --git a/cataloguing/merge.pl b/cataloguing/merge.pl >index ee9f1fa..0e5ae08 100755 >--- a/cataloguing/merge.pl >+++ b/cataloguing/merge.pl >@@ -29,12 +29,12 @@ use C4::Serials; > use C4::Koha; > use C4::Reserves qw/MergeHolds/; > use C4::Acquisition qw/ModOrder GetOrdersByBiblionumber/; >- >+use C4::ImportBatch; > use Koha::BiblioFrameworks; > use Koha::MetadataRecord; > > my $input = new CGI; >-my @biblionumbers = $input->multi_param('biblionumber'); >+my @record_paths = $input->multi_param('record'); > my $merge = $input->param('merge'); > > my @errors; >@@ -49,17 +49,41 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > } > ); > >+my $sources = { >+ catalog => { >+ delete => \&_delete_catalog, >+ fetch => \&_fetch_catalog, >+ get_link => \&_get_link_catalog, >+ get_preview_link => \&_get_preview_link_catalog, >+ merge_other => \&_merge_other_catalog, >+ update => \&_update_catalog, >+ }, >+ batch => { >+ fetch => \&_fetch_import_batch, >+ get_link => \&_get_preview_link_import_batch, >+ get_preview_link => \&_get_preview_link_import_batch, >+ update => \&_update_import_batch, >+ }, >+}; >+ >+sub split_record_path { >+ my ($source, $num) = split /\//, shift, 2; >+ $source =~ s/-.*//; >+ >+ return ( $source, $num ); >+} >+ > #------------------------ > # Merging > #------------------------ > if ($merge) { > >- my $dbh = C4::Context->dbh; >- > # Creating a new record from the html code >- my $record = TransformHtmlToMarc( $input, 1 ); >- my $ref_biblionumber = $input->param('ref_biblionumber'); >- @biblionumbers = grep { $_ != $ref_biblionumber } @biblionumbers; >+ my $record = TransformHtmlToMarc( $input ); >+ my $ref_record_path = $input->param('ref_record'); >+ >+ my ( $ref_record_source, $ref_record_num ) = split_record_path $ref_record_path; >+ my @other_record_paths = map +[ split_record_path $_ ], grep { $_ ne $ref_record_path } @record_paths; > > # prepare report > my @report_records; >@@ -77,46 +101,46 @@ if ($merge) { > } > > # Rewriting the leader >- $record->leader(GetMarcBiblio($ref_biblionumber)->leader()); >+ my $orig_ref_record = $sources->{$ref_record_source}->{fetch}($ref_record_num); >+ $record->leader( $orig_ref_record->leader() ); > > my $frameworkcode = $input->param('frameworkcode'); > my @notmoveditems; > > # Modifying the reference record >- ModBiblio($record, $ref_biblionumber, $frameworkcode); >- >- # Moving items from the other record to the reference record >- foreach my $biblionumber (@biblionumbers) { >- my $itemnumbers = get_itemnumbers_of($biblionumber); >- foreach my $itemnumber (@{ $itemnumbers->{$biblionumber} }) { >- my $res = MoveItemFromBiblio($itemnumber, $biblionumber, $ref_biblionumber); >- if (not defined $res) { >- push @notmoveditems, $itemnumber; >+ $sources->{$ref_record_source}->{update}( $record, $ref_record_num, $frameworkcode ); >+ >+ # Are all the records from the same source? >+ my $all_records_same_source = 1; >+ >+ # Merging in information from other records >+ foreach my $record_path (@other_record_paths) { >+ my ( $record_source, $record_num ) = @$record_path; >+ >+ if ( $record_source eq $ref_record_source ) { >+ # We only want to merge in information from the other records if they're the same kind. >+ # >+ # We can't merge serials from an import bib to a catalog bib, for instance. >+ my @record_errors = $sources->{$record_source}->{merge_other}( $record_num, $ref_record_num ); >+ >+ if ( @record_errors ) { >+ push @errors, @record_errors; >+ } else { >+ push @errors, $sources->{$record_source}->{delete}( $record_num ); >+ } >+ } else { >+ $all_records_same_source = 0; > } > } >- } >- # If some items could not be moved : >- if (scalar(@notmoveditems) > 0) { >- my $itemlist = join(' ',@notmoveditems); >- push @errors, { code => "CANNOT_MOVE", value => $itemlist }; >- } >- >- my $sth_subscription = $dbh->prepare(" >- UPDATE subscription SET biblionumber = ? WHERE biblionumber = ? >- "); >- my $sth_subscriptionhistory = $dbh->prepare(" >- UPDATE subscriptionhistory SET biblionumber = ? WHERE biblionumber = ? >- "); >- my $sth_serial = $dbh->prepare(" >- UPDATE serial SET biblionumber = ? WHERE biblionumber = ? >- "); > > my $report_header = {}; >- foreach my $biblionumber ($ref_biblionumber, @biblionumbers) { >+ foreach my $record_path ( [ $ref_record_source, $ref_record_num ], @other_record_paths ) { >+ my ( $record_source, $record_num ) = @$record_path; >+ > # build report >- my $marcrecord = GetMarcBiblio($biblionumber); >+ my $marcrecord = $sources->{$record_source}->{fetch}($record_num); > my %report_record = ( >- biblionumber => $biblionumber, >+ record_num => $record_num, > fields => {}, > ); > foreach my $field (@report_fields) { >@@ -145,53 +169,29 @@ if ($merge) { > push @report_records, \%report_record; > } > >- foreach my $biblionumber (@biblionumbers) { >- # Moving subscriptions from the other record to the reference record >- my $subcount = CountSubscriptionFromBiblionumber($biblionumber); >- if ($subcount > 0) { >- $sth_subscription->execute($ref_biblionumber, $biblionumber); >- $sth_subscriptionhistory->execute($ref_biblionumber, $biblionumber); >- } >- >- # Moving serials >- $sth_serial->execute($ref_biblionumber, $biblionumber); >- >- # Moving orders (orders linked to items of frombiblio have already been moved by MoveItemFromBiblio) >- my @allorders = GetOrdersByBiblionumber($biblionumber); >- my @tobiblioitem = GetBiblioItemByBiblioNumber ($ref_biblionumber); >- my $tobiblioitem_biblioitemnumber = $tobiblioitem [0]-> {biblioitemnumber }; >- foreach my $myorder (@allorders) { >- $myorder->{'biblionumber'} = $ref_biblionumber; >- ModOrder ($myorder); >- # TODO : add error control (in ModOrder?) >- } >- >- # Deleting the other records >- if (scalar(@errors) == 0) { >- # Move holds >- MergeHolds($dbh, $ref_biblionumber, $biblionumber); >- my $error = DelBiblio($biblionumber); >- push @errors, $error if ($error); >- } >-} >- > # Parameters > $template->param( >+ all_records_same_source => $all_records_same_source, > result => 1, > report_records => \@report_records, > report_header => $report_header, >- ref_biblionumber => scalar $input->param('ref_biblionumber') >+ ref_record_path => scalar $input->param('ref_record'), >+ ref_record_id => "$ref_record_source-$ref_record_num", >+ ref_record_link => $sources->{$ref_record_source}->{get_link}($ref_record_num), > ); > > #------------------------- > # Show records to merge > #------------------------- > } else { >- my $ref_biblionumber = $input->param('ref_biblionumber'); >+ my $ref_record_path = $input->param('ref_record'); >+ >+ if ($ref_record_path) { >+ my ( $ref_record_source, $ref_record_num ) = split_record_path $ref_record_path; > >- if ($ref_biblionumber) { > my $framework = $input->param('frameworkcode'); >- $framework //= GetFrameworkCode($ref_biblionumber); >+ $framework //= GetFrameworkCode($ref_record_num) if $ref_record_source eq 'catalog'; >+ $framework //= ''; > > # Getting MARC Structure > my $tagslib = GetMarcStructure(1, $framework); >@@ -200,19 +200,24 @@ if ($merge) { > > # Creating a loop for display > my @records; >- foreach my $biblionumber (@biblionumbers) { >- my $marcrecord = GetMarcBiblio($biblionumber); >- my $frameworkcode = GetFrameworkCode($biblionumber); >+ foreach my $record_path ( $input->param('record') ) { >+ my ( $record_source, $record_num ) = split_record_path $record_path; >+ my $marcrecord = $sources->{$record_source}->{fetch}($record_num); >+ # FIXME: We assume the default framework for import records. >+ my $frameworkcode = $record_source eq 'catalog' ? GetFrameworkCode($record_num) : ''; > my $recordObj = new Koha::MetadataRecord({'record' => $marcrecord, schema => $marcflavour}); > my $record = { >- recordid => $biblionumber, >+ record_path => $record_path, >+ recordid => "$record_source-$record_num", >+ record_source => $record_source, >+ record_num => $record_num, > record => $marcrecord, > frameworkcode => $frameworkcode, > display => $recordObj->createMergeHash($tagslib), > }; >- if ($ref_biblionumber and $ref_biblionumber == $biblionumber) { >+ if ($ref_record_path and $ref_record_path eq $record_path) { > $record->{reference} = 1; >- $template->param(ref_record => $record); >+ $template->param(ref_record_path => $record); > unshift @records, $record; > } else { > push @records, $record; >@@ -223,7 +228,8 @@ if ($merge) { > > # Parameters > $template->param( >- ref_biblionumber => $ref_biblionumber, >+ ref_record_path => $ref_record_path, >+ ref_recordid => "$ref_record_source-$ref_record_num", > records => \@records, > ref_record => $records[0], > framework => $framework, >@@ -232,11 +238,19 @@ if ($merge) { > ); > } else { > my @records; >- foreach my $biblionumber (@biblionumbers) { >- my $frameworkcode = GetFrameworkCode($biblionumber); >+ foreach my $record_path ( $input->multi_param('record') ) { >+ my ( $record_source, $record_num ) = split_record_path $record_path; >+ >+ my $marcrecord = $sources->{$record_source}->{fetch}($record_num); >+ # FIXME: We assume the default framework for import records. >+ my $frameworkcode = $record_source eq 'catalog' ? GetFrameworkCode($record_num) : ''; > my $record = { >- biblionumber => $biblionumber, >- data => GetBiblioData($biblionumber), >+ record_path => $record_path, >+ recordid => "$record_path-$record_num", >+ record_source => $record_source, >+ record_num => $record_num, >+ preview_link => $sources->{$record_source}->{get_preview_link}($record_num), >+ data => TransformMarcToKoha( $marcrecord, $frameworkcode ), > frameworkcode => $frameworkcode, > }; > push @records, $record; >@@ -258,4 +272,101 @@ if (@errors) { > } > > output_html_with_http_headers $input, $cookie, $template->output; >-exit; >+ >+sub _delete_catalog { >+ my ( $biblionumber ) = @_; >+ return DelBiblio($biblionumber); >+} >+ >+sub _fetch_catalog { >+ my ( $biblionumber ) = @_; >+ >+ return GetMarcBiblio( $biblionumber ); >+} >+ >+sub _get_link_catalog { >+ my ( $biblionumber ) = @_; >+ >+ return "/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=$biblionumber"; >+} >+ >+sub _get_preview_link_catalog { >+ my ( $biblionumber ) = @_; >+ >+ return "/cgi-bin/koha/catalogue/showmarc.pl?id=$biblionumber"; >+} >+ >+sub _merge_other_catalog { >+ my ( $biblionumber, $ref_biblionumber ) = @_; >+ >+ my $dbh = C4::Context->dbh; >+ my @errors; >+ >+ my @notmoveditems; >+ my $itemnumbers = get_itemnumbers_of($biblionumber); >+ foreach my $itemnumber (@{ $itemnumbers->{$biblionumber} }) { >+ if ( !MoveItemFromBiblio( $itemnumber, $biblionumber, $ref_biblionumber ) ) { >+ push @notmoveditems, $itemnumber; >+ } >+ } >+ >+ # If some items could not be moved : >+ if (scalar(@notmoveditems) > 0) { >+ my $itemlist = join(' ',@notmoveditems); >+ push @errors, { code => "CANNOT_MOVE", value => $itemlist }; >+ } >+ >+ my $sth_subscription = $dbh->prepare(" >+ UPDATE subscription SET biblionumber = ? WHERE biblionumber = ? >+ "); >+ my $sth_subscriptionhistory = $dbh->prepare(" >+ UPDATE subscriptionhistory SET biblionumber = ? WHERE biblionumber = ? >+ "); >+ my $sth_serial = $dbh->prepare(" >+ UPDATE serial SET biblionumber = ? WHERE biblionumber = ? >+ "); >+ >+ # Moving subscriptions from the other record to the reference record >+ my $subcount = CountSubscriptionFromBiblionumber($biblionumber); >+ if ($subcount > 0) { >+ $sth_subscription->execute($ref_biblionumber, $biblionumber); >+ $sth_subscriptionhistory->execute($ref_biblionumber, $biblionumber); >+ } >+ >+ # Moving serials >+ $sth_serial->execute($ref_biblionumber, $biblionumber); >+ >+ # Moving orders (orders linked to items of frombiblio have already been moved by MoveItemFromBiblio) >+ foreach my $myorder( GetOrdersByBiblionumber($biblionumber) ) { >+ $myorder->{'biblionumber'} = $ref_biblionumber; >+ ModOrder ($myorder); >+ # TODO : add error control (in ModOrder?) >+ } >+ >+ if (scalar(@errors) == 0) { >+ MergeHolds($dbh, $ref_biblionumber, $biblionumber); >+ } >+ >+ return @errors; >+} >+ >+sub _update_catalog { >+ my ( $record, $biblionumber, $frameworkcode ) = @_; >+ ModBiblio( $record, $biblionumber, $frameworkcode ); >+} >+ >+sub _fetch_import_batch { >+ my ( $import_recordid ) = @_; >+ return C4::ImportBatch::GetRecordFromImportBiblio( $import_recordid ); >+} >+ >+sub _get_preview_link_import_batch { >+ my ( $import_recordid ) = @_; >+ >+ return "/cgi-bin/koha/catalogue/showmarc.pl?importid=$import_recordid"; >+} >+ >+sub _update_import_batch { >+ my ( $record, $import_recordid ) = @_; >+ ModBiblioInBatch( $import_recordid, $record ); >+} >diff --git a/koha-tmpl/intranet-tmpl/prog/css/merge-record.css b/koha-tmpl/intranet-tmpl/prog/css/merge-record.css >new file mode 100644 >index 0000000..a6c3a47 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/css/merge-record.css >@@ -0,0 +1,61 @@ >+.merge-record-fixed-contents { >+ display: inline-block; >+} >+ >+.merge-record-fixed-contents, .merge-record-subfield { >+ padding: 2px; >+} >+ >+.merge-record-unique-0, #tabs .merge-record-unique-0 { >+ background-color: #005AC8; >+ color: white; >+} >+ >+.merge-record-unique-1, #tabs .merge-record-unique-1 { >+ background-color: #AA0A3C; >+ color: white; >+} >+ >+.merge-record-unique-2, #tabs .merge-record-unique-2 { >+ background-color: #F0F032; >+} >+ >+.merge-record-unique-3, #tabs .merge-record-unique-3 { >+ background-color: #00A0FA; >+ color: white; >+} >+ >+.merge-record-unique-4, #tabs .merge-record-unique-4 { >+ background-color: #FA78FA; >+} >+ >+.merge-record-unique-5, #tabs .merge-record-unique-5 { >+ background-color: #14D2DC; >+} >+ >+.merge-record-unique-6, #tabs .merge-record-unique-6 { >+ background-color: #8214A0; >+ color: white; >+} >+ >+.merge-record-unique-7, #tabs .merge-record-unique-7 { >+ background-color: #FA7850; >+} >+ >+.merge-record-unique-8, #tabs .merge-record-unique-8 { >+ background-color: #0AB45A; >+ color: white; >+} >+ >+.merge-record-unique-9, #tabs .merge-record-unique-9 { >+ background-color: #006E82; >+ color: white; >+} >+ >+.merge-record-unique-10, #tabs .merge-record-unique-10 { >+ background-color: #A0FA82; >+} >+ >+.merge-record-unique-11, #tabs .merge-record-unique-11 { >+ background-color: #F9E5BD; >+} >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/authorities_js.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/authorities_js.inc >index cf4a072..eb9d6d5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/authorities_js.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/authorities_js.inc >@@ -9,7 +9,7 @@ function mergeAuth(authid, summary) { > if (typeof alreadySelected.mergereference !== 'undefined') { > refstring = "&mergereference=" + alreadySelected.mergereference; > } >- window.location.href = "/cgi-bin/koha/authorities/merge.pl?authid=" + authid + "&authid=" + alreadySelected.authid + refstring; >+ window.location.href = "/cgi-bin/koha/authorities/merge.pl?record=catalog/" + authid + "&record=catalog/" + alreadySelected.authid + refstring; > } else { > $.cookie('auth_to_merge', JSON.stringify({ 'authid': authid, 'summary': summary }), { 'path' : '/' }); > showMergingInProgress(); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/merge-record.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/merge-record.inc >index df79d8e..6748d73 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/merge-record.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/merge-record.inc >@@ -4,7 +4,7 @@ > <ul id="ulrecord[% record.recordid %]"> > [% FOREACH field IN record.display %] > [% IF field.tag != biblionumbertag %] >- <li id="k[% field.key %]"> >+ <li id="k[% field.key %]" class="merge-record-field"> > [% IF (tabrecord.reference) %] > <input type="checkbox" checked="checked" class="fieldpick" id="rec_[% record.recordid %]_[% field.key %]" /> > [% ELSE %] >@@ -15,7 +15,7 @@ > <input type="hidden" name="tag_[% field.tag %]_indicator1_[% field.key %]" value="[% field.indicator1 %]" /> > <input type="hidden" name="tag_[% field.tag %]_indicator2_[% field.key %]" value="[% field.indicator2 %]" /> > [% IF ( field.value ) %] >- / [% field.value %] >+ / <span class="merge-record-fixed-contents">[% field.value %]</span> > <input type="hidden" name="tag_[% field.tag %]_code_00_[% field.key %]" value="00" /> > <input type="hidden" name="tag_[% field.tag %]_subfield_00_[% field.key %]" value="[% field.value %]" /> > [% END %] >@@ -23,7 +23,7 @@ > [% IF ( field.subfield.size ) %] > <ul> > [% FOREACH subfield IN field.subfield %] >- <li id="k[% subfield.subkey %]"> >+ <li id="k[% subfield.subkey %]" class="merge-record-subfield"> > [% IF (tabrecord.reference) %] > <input type="checkbox" checked="checked" class="subfieldpick" id="rec_[% record.recordid %]_[% subfield.subkey %]" /> > [% ELSE %] >@@ -51,7 +51,8 @@ > [% FOREACH record IN sourcerecords %] > <li> > <a href="#tabrecord[% record.recordid %]"> >- [% record.recordid %] >+ [% IF record.record_source == 'batch' %]import[% END %] >+ #[% record.record_num %] > [% IF record.reference %](ref)[% END %] > </a> > </li> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt >index d6d39d8..d2ab563 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt >@@ -69,7 +69,7 @@ > } else { > var params = []; > $(checkboxes).each(function() { >- params.push('biblionumber=' + $(this).val()); >+ params.push('record=catalog/' + $(this).val()); > }); > var url = '/cgi-bin/koha/cataloguing/merge.pl?' + params.join('&'); > location.href = url; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/merge.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/merge.tt >index 464d763..ddffa27 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/merge.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/merge.tt >@@ -2,6 +2,7 @@ > > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Cataloging › Merging records</title> >+<link rel="stylesheet" href="[% interface %]/[% theme %]/css/merge-record.css"> > [% INCLUDE 'doc-head-close.inc' %] > <script type="text/javascript" src="[% interface %]/[% theme %]/js/merge-record.js"></script> > [% INCLUDE 'merge-record-strings.inc' %] >@@ -111,8 +112,8 @@ $(document).ready(function(){ > > // Check all checkboxes in first tab, and uncheck all others to avoid > // inconsistencies from a page refresh. >- $('#tabs div#tabrecord[% ref_biblionumber %]').find('input[type="checkbox"]').prop('checked', true); >- $('#tabs > div:not("#tabrecord[% ref_biblionumber %]")').find('input[type="checkbox"]').prop('checked', false); >+ $('#tabs div#tabrecord[% ref_recordid %]').find('input[type="checkbox"]').prop('checked', true); >+ $('#tabs > div:not("#tabrecord[% ref_recordid %]")').find('input[type="checkbox"]').prop('checked', false); > > //Set focus to cataloging search > $("input[name=q]:eq(0)").focus(); >@@ -150,12 +151,12 @@ $(document).ready(function(){ > [% END %] > > [% ELSE %] >- <p>The merge was successful. <a href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=[% ref_biblionumber %]">Click here to see the merged record.</a></p> >+ <p>The merge was successful. <a href="[% ref_record_link %]">Click here to see the merged record.</a></p> > <h3>Report</h3> > <table> > <thead> > <tr> >- <th>Biblionumber</th> >+ <th>Record #</th> > [% FOREACH key IN report_header.keys.sort %] > [% tag = key.substr(0, 3) %] > [% code = key.substr(3, 1) %] >@@ -172,7 +173,7 @@ $(document).ready(function(){ > [% FOREACH record IN report_records %] > <tr> > <td> >- [% record.biblionumber %] >+ [% record.record_num %] > [% IF loop.first %] > (record kept) > [% END %] >@@ -205,16 +206,16 @@ $(document).ready(function(){ > [% FOREACH record IN records %] > <li class="radio"> > [% IF loop.first %] >- <input type="radio" value="[% record.biblionumber %]" checked="checked" id="ref_biblionumber[% record.biblionumber %]" name="ref_biblionumber" onclick="changeFramework('[% record.frameworkcode %]')" /> >+ <input type="radio" value="[% record.record_path %]" checked="checked" id="ref_record[% record.recordid %]" name="ref_record" onclick="changeFramework('[% record.frameworkcode %]')" /> > [% ELSE %] >- <input type="radio" value="[% record.biblionumber %]" id="ref_biblionumber[% record.biblionumber %]" name="ref_biblionumber" onclick="changeFramework('[% record.frameworkcode %]')" /> >+ <input type="radio" value="[% record.record_path %]" id="ref_record[% record.recordid %]" name="ref_record" onclick="changeFramework('[% record.frameworkcode %]')" /> > [% END %] >- <label for="ref_biblionumber[% record.biblionumber %]"> >+ <label for="ref_record[% record.recordid %]"> > [% record.data.title %] > [% FOREACH subtitle IN record.subtitles %] > [% subtitle.subfield %] > [% END %] >- ([% record.biblionumber %]) <a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% record.biblionumber %]" class="previewData">View MARC</a> >+ ([% IF record.record_source == 'batch' %]import [% END %]#[% record.record_num %]) <a href="[% record.preview_link %]" class="previewData">View MARC</a> > </label> > </li> > [% END %] >@@ -231,7 +232,7 @@ $(document).ready(function(){ > </ol> > > [% FOREACH record IN records %] >- <input type="hidden" name="biblionumber" value="[% record.biblionumber %]" /> >+ <input type="hidden" name="record" value="[% record.record_path %]" /> > [% END %] > <fieldset class="action"> > <input type="submit" value="Next" /> >@@ -274,9 +275,9 @@ $(document).ready(function(){ > [% PROCESS mergetarget %] > </div> <!-- .yui-u --> > >-<input type="hidden" name="ref_biblionumber" value="[% ref_biblionumber %]" /> >+<input type="hidden" name="ref_record" value="[% ref_record_path %]" /> > [% FOREACH record IN records %] >- <input type="hidden" name="biblionumber" value="[% record.recordid %]" /> >+ <input type="hidden" name="record" value="[% record.record_path %]" /> > [% END %] > <input type="hidden" name="frameworkcode" value="[% framework %]" /> > >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 53ad39f..4b91ae1 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 >@@ -12,8 +12,8 @@ > [% IF ( record.record_type == 'biblio' ) %] > <td colspan="5">Matches biblio [% record_lis.match_id %] (score = [% record_lis.match_score %]): <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% record_lis.match_id %]">[% record_lis.match_citation %]</a></td> > [% ELSIF ( record.record_type == 'auth' ) %] >- <td colspan="5">Matches authority [% record_lis.match_id %] (score = [% record_lis.match_score %]): <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% record_lis.match_id %]">[% record_lis.match_citation %]</a> | >- <a href="/cgi-bin/koha/authorities/merge.pl?mergereference=breeding&authid=[% record_lis.match_id %]&authid=[% record_lis.import_record_id %]">Merge</a> >+ <td class="highlight" colspan="5">Matches authority [% record_lis.match_id %] (score = [% record_lis.match_score %]): <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% record_lis.match_id %]">[% record_lis.match_citation %]</a> | >+ <a href="/cgi-bin/koha/authorities/merge.pl?ref_record=batch-[% import_batch_id %]/[% record_lis.import_record_id %]&record=catalog/[% record_lis.match_id %]&record=batch-[% import_batch_id %]/[% record_lis.import_record_id %]">Merge</a> > </td> > [% END %] > </tr> >@@ -121,6 +121,7 @@ $(document).ready(function(){ > } > if (aData['diff_url']){ > $('td:eq(5)', nRow).html( >+ (aData['merge_url'] ? '<a href="'+aData['merge_url']+'">Merge</a> ' : '') + > '<a href="'+aData['diff_url']+'">View</a>' > ); > } >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt >index a276236..39c8a6e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt >@@ -207,7 +207,7 @@ $(document).ready(function(){ > } else { > var params = []; > $(checkboxes).each(function() { >- params.push('biblionumber=' + $(this).val()); >+ params.push('record=catalog/' + $(this).val()); > }); > var url = '/cgi-bin/koha/cataloguing/merge.pl?' + params.join('&'); > location.href = url; >diff --git a/koha-tmpl/intranet-tmpl/prog/js/merge-record.js b/koha-tmpl/intranet-tmpl/prog/js/merge-record.js >index d8938b9..7e9877b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/merge-record.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/merge-record.js >@@ -181,4 +181,62 @@ $(document).ready(function(){ > } > rebuild_target($('#tabs'), $('#resultul')); > }); >+ >+ // Keep track of all the class names added; easier than finding the right one to remove later. >+ var record_class_names = ''; >+ >+ // Start by marking subfield as unique to its record. >+ $('.record').each( function(i) { >+ var record_class = 'merge-record-unique-' + i; >+ record_class_names += record_class + ' '; >+ >+ $(this).find('.merge-record-fixed-contents, .merge-record-subfield').addClass( record_class ); >+ } ); >+ >+ // Mark the tabs the same color as the subfields. >+ $(window).load( function() { $('#tabs a.ui-tabs-anchor').addClass( function(i) { return 'merge-record-unique-' + i } ) } ); >+ >+ // We iterate through every subfield of every field of the first record, and check to see if it >+ // exists in every other record. >+ // >+ // I'm sorry if this leaves you feeling... loopy. >+ $('.record').eq(0).find('.merge-record-field').each( function() { >+ var field = $(this).find('.field').text(); >+ >+ $(this).find('.merge-record-fixed-contents, .merge-record-subfield').each( function() { >+ var text = field + $(this).text().replace(/\s+/g, ' '); >+ var $matching_subfields = $(this); >+ var common_subfield = true; >+ >+ $('.record').slice(1).each( function() { >+ var found = false; >+ $(this).find('.merge-record-field').each( function() { >+ var other_field = $(this).find('.field').text(); >+ $(this).find('.merge-record-fixed-contents, .merge-record-subfield').each( function() { >+ var other_text = field + $(this).text().replace(/\s+/g, ' '); >+ >+ if (other_text == text) { >+ // Little jQueryism to build up a custom set of elements that we can later remove >+ // classes from all at once. >+ $matching_subfields = $matching_subfields.add(this); >+ found = true; >+ return false; >+ } >+ } ); >+ >+ if (found == true) return false; >+ } ); >+ >+ if (found == false) { >+ common_subfield = false; >+ return false; >+ } >+ } ); >+ >+ if (common_subfield) { >+ // If the subfield exists in all records, remove the "unique" class from all of them. >+ $matching_subfields.removeClass(record_class_names); >+ } >+ } ); >+ } ); > }); >diff --git a/tools/batch_records_ajax.pl b/tools/batch_records_ajax.pl >index c8c6198..c2c62cd 100755 >--- a/tools/batch_records_ajax.pl >+++ b/tools/batch_records_ajax.pl >@@ -78,6 +78,7 @@ foreach my $record (@$records) { > my $match = GetImportRecordMatches( $record->{'import_record_id'}, 1 ); > my $match_citation = ''; > my $match_id; >+ my $script_name; > if ( $#$match > -1 ) { > if ( $match->[0]->{'record_type'} eq 'biblio' ) { > $match_citation .= $match->[0]->{'title'} >@@ -85,12 +86,15 @@ foreach my $record (@$records) { > $match_citation .= ' ' . $match->[0]->{'author'} > if defined( $match->[0]->{'author'} ); > $match_id = $match->[0]->{'biblionumber'}; >+ $script_name = 'cataloguing/merge.pl'; > } > elsif ( $match->[0]->{'record_type'} eq 'auth' ) { > if ( defined( $match->[0]->{'authorized_heading'} ) ) { > $match_citation .= $match->[0]->{'authorized_heading'}; > $match_id = $match->[0]->{'candidate_match_id'}; > } >+ # Uncomment this when support for merging authorities is ready >+ #$script_name = 'authorities/merge.pl'; > } > } > >@@ -107,7 +111,8 @@ foreach my $record (@$records) { > || q{}, > score => $#$match > -1 ? $match->[0]->{'score'} : 0, > match_id => $match_id, >- diff_url => $match_id ? "/cgi-bin/koha/tools/showdiffmarc.pl?batchid=$import_batch_id&importid=$record->{import_record_id}&id=$match_id" : undef >+ diff_url => $match_id ? "/cgi-bin/koha/tools/showdiffmarc.pl?batchid=$import_batch_id&importid=$record->{import_record_id}&id=$match_id" : undef, >+ merge_url => ($match_id && $script_name) ? "/cgi-bin/koha/$script_name?ref_record=batch-$record->{import_batch_id}/$record->{import_record_id}&record=catalog/$match_id&record=batch-$record->{import_batch_id}/$record->{import_record_id}" : undef > }; > } > >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14578
:
53502
|
53596
|
60164
|
91933