Bugzilla – Attachment 91933 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), 32.68 KB, created by
Nick Clemens (kidclamp)
on 2019-08-02 17:43:45 UTC
(
hide
)
Description:
Bug 14578: Allow manual merging of import records on match
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2019-08-02 17:43:45 UTC
Size:
32.68 KB
patch
obsolete
>From ea13bcdda352cfb13a4c8d258a6ea56a4ed11176 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 | 277 ++++++++++++++------- > koha-tmpl/intranet-tmpl/prog/css/merge-record.css | 61 +++++ > .../prog/en/includes/authorities_js.inc | 2 +- > .../prog/en/includes/merge-record.inc | 11 +- > .../prog/en/modules/cataloguing/addbooks.tt | 2 +- > .../prog/en/modules/cataloguing/merge.tt | 17 +- > .../prog/en/modules/tools/manage-marc-import.tt | 3 +- > .../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, 338 insertions(+), 104 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/css/merge-record.css > >diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm >index 8d39ed2034..f25c5b80c1 100644 >--- a/C4/ImportBatch.pm >+++ b/C4/ImportBatch.pm >@@ -1121,7 +1121,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 146e88e598..5193edc699 100755 >--- a/cataloguing/merge.pl >+++ b/cataloguing/merge.pl >@@ -29,13 +29,13 @@ 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::Items; > 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; >@@ -50,17 +50,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; >@@ -78,49 +102,46 @@ if ($merge) { > } > > # Rewriting the leader >- $record->leader(GetMarcBiblio({ biblionumber => $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 $items = Koha::Items->search({ biblionumber => $biblionumber }); >- while ( my $item = $items->next) { >- my $res = MoveItemFromBiblio( $item->itemnumber, $biblionumber, $ref_biblionumber ); >- if ( not defined $res ) { >- push @notmoveditems, $item->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 $sth_suggestions = $dbh->prepare(" >- UPDATE suggestions 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 => $biblionumber }); >+ my $marcrecord = $sources->{$record_source}->{fetch}($record_num); > my %report_record = ( >- biblionumber => $biblionumber, >+ record_num => $record_num, > fields => {}, > ); > foreach my $field (@report_fields) { >@@ -149,54 +170,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 suggestions >- $sth_suggestions->execute($ref_biblionumber, $biblionumber); >- >- # Moving orders (orders linked to items of frombiblio have already been moved by MoveItemFromBiblio) >- my @allorders = GetOrdersByBiblionumber($biblionumber); >- 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); >@@ -205,19 +201,24 @@ if ($merge) { > > # Creating a loop for display > my @records; >- foreach my $biblionumber (@biblionumbers) { >- my $marcrecord = GetMarcBiblio({ biblionumber => $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; >@@ -228,7 +229,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, >@@ -237,11 +239,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; >@@ -263,4 +273,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 => $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 0000000000..a6c3a479db >--- /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 7109dc94ca..615e1eeb50 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 6d14015916..dc93ad3e33 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/merge-record.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/merge-record.inc >@@ -4,8 +4,8 @@ > <ul id="ulrecord[% record.recordid | html %]"> > [% FOREACH field IN record.display %] > [% IF field.tag != biblionumbertag %] >- <li id="k[% field.key | html %]"> >- [% IF (tabrecord.reference) %] >+ <li id="k[% field.key | html %]" class="merge-record-field"> >+ [% IF (record.reference) %] > <input type="checkbox" checked="checked" class="fieldpick" id="rec_[% record.recordid | html %]_[% field.key | html %]" /> > [% ELSE %] > <input type="checkbox" class="fieldpick" id="rec_[% record.recordid | html %]_[% field.key | html %]" /> >@@ -15,7 +15,7 @@ > <input type="hidden" name="tag_[% field.tag | html %]_indicator1_[% field.key | html %]" value="[% field.indicator1 | html %]" /> > <input type="hidden" name="tag_[% field.tag | html %]_indicator2_[% field.key | html %]" value="[% field.indicator2 | html %]" /> > [% IF ( field.value ) %] >- / [% field.value | html %] >+ / <span class="merge-record-fixed-contents">[% field.value | html %]</span> > <input type="hidden" name="tag_[% field.tag | html %]_code_00_[% field.key | html %]" value="00" /> > <input type="hidden" name="tag_[% field.tag | html %]_subfield_00_[% field.key | html %]" value="[% field.value | html %]" /> > [% END %] >@@ -23,7 +23,7 @@ > [% IF ( field.subfield.size ) %] > <ul> > [% FOREACH subfield IN field.subfield %] >- <li id="k[% subfield.subkey | html %]"> >+ <li id="k[% subfield.subkey | html %]" class="merge-record-subfield"> > [% IF (tabrecord.reference) %] > <input type="checkbox" checked="checked" class="subfieldpick" id="rec_[% record.recordid | html %]_[% subfield.subkey | html %]" /> > [% ELSE %] >@@ -51,7 +51,8 @@ > [% FOREACH record IN sourcerecords %] > <li> > <a href="#tabrecord[% record.recordid | uri %]"> >- [% record.recordid | html %] >+ [% IF record.record_source == 'batch' %]import[% END %] >+ #[% record.record_num | html %] > [% 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 46157389b8..8afacc2e1c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tt >@@ -281,7 +281,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 c21baca652..f1d7e25958 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/merge.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/merge.tt >@@ -5,6 +5,7 @@ > > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Cataloging › Merging records</title> >+[% Asset.css("css/merge-record.css") | $raw %] > [% INCLUDE 'doc-head-close.inc' %] > <style> > div.record ul, div.record li { float:none; display:block; } >@@ -44,7 +45,7 @@ div#result { margin-top: 1em; } > <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) %] >@@ -94,16 +95,16 @@ div#result { margin-top: 1em; } > [% FOREACH record IN records %] > <li class="radio"> > [% IF loop.first %] >- <input type="radio" value="[% record.biblionumber | html %]" checked="checked" id="ref_biblionumber[% record.biblionumber | html %]" name="ref_biblionumber" onclick="changeFramework('[% record.frameworkcode | html %]')" /> >+ <input type="radio" value="[% record.record_source | html %]/[% record.record_num | html %]" checked="checked" id="ref_recorf[% record.record_source | html %]/[% record.record_num | html %]" name="ref_record" onclick="changeFramework('[% record.frameworkcode | html %]')" /> > [% ELSE %] >- <input type="radio" value="[% record.biblionumber | html %]" id="ref_biblionumber[% record.biblionumber | html %]" name="ref_biblionumber" onclick="changeFramework('[% record.frameworkcode | html %]')" /> >+ <input type="radio" value="[% record.record_source | html %]/[% record.record_num | html %]" id="ref_record[% record.record_source | html %]/[% record.record_num | html %]" name="ref_record" onclick="changeFramework('[% record.frameworkcode | html %]')" /> > [% END %] >- <label for="ref_biblionumber[% record.biblionumber | html %]"> >+ <label for="ref_record[% record.record_source | html %]/[% record.record_num | html %]"> > [% record.data.title | html %] > [% FOREACH subtitle IN record.subtitles %] > [% subtitle.subfield | html %] > [% END %] >- ([% record.biblionumber | uri %]) <a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% record.biblionumber | uri %]" class="previewData">View MARC</a> >+ ([% record.record_source | uri %]/[% record.record_num | uri %]) <a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% record.record_source | uri %]/[% record.record_num | uri %]" class="previewData">View MARC</a> > </label> > </li> > [% END %] >@@ -120,7 +121,7 @@ div#result { margin-top: 1em; } > </ol> > > [% FOREACH record IN records %] >- <input type="hidden" name="biblionumber" value="[% record.biblionumber | html %]" /> >+ <input type="hidden" name="record" value="[% record.record_source | html %]/[% record.record_num | html %]" /> > [% END %] > <fieldset class="action"> > <input type="submit" value="Next" /> >@@ -284,8 +285,8 @@ div#result { margin-top: 1em; } > > // Check all checkboxes in first tab, and uncheck all others to avoid > // inconsistencies from a page refresh. >- $('#tabs div#tabrecord[% ref_biblionumber | html %]').find('input[type="checkbox"]').prop('checked', true); >- $('#tabs > div:not("#tabrecord[% ref_biblionumber | html %]")').find('input[type="checkbox"]').prop('checked', false); >+ $('#tabs div#tabrecord[% ref_record_path | html %]').find('input[type="checkbox"]').prop('checked', true); >+ $('#tabs > div:not("#tabrecord[% ref_record_path | html %]")').find('input[type="checkbox"]').prop('checked', false); > > //Set focus to cataloging search > $("input[name=q]:eq(0)").focus(); >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 277e1bfe24..d7912b47a2 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 >@@ -508,6 +508,7 @@ > } > 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>' > ); > } >@@ -576,4 +577,4 @@ > [% END %] > </ul> > </nav> >-[% END %] >\ No newline at end of file >+[% END %] >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 023922a873..a04045a5ab 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt >@@ -644,7 +644,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/js/merge-record.js b/koha-tmpl/intranet-tmpl/prog/js/merge-record.js >index d8938b99b9..7e9877bb18 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 17e8236d32..7281348187 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&type=$record->{record_type}" : undef >+ diff_url => $match_id ? "/cgi-bin/koha/tools/showdiffmarc.pl?batchid=$import_batch_id&importid=$record->{import_record_id}&id=$match_id&type=$record->{record_type}" : 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.11.0
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