From 5622eb258d3384cde8f0d8379bee9161a366b985 Mon Sep 17 00:00:00 2001 From: Nick Clemens <nick@bywatersolutions.com> Date: Tue, 5 Dec 2023 19:11:37 +0000 Subject: [PATCH] Bug 35497: WIP This patch adds a new tab to the record details page called 'Imported records' This tab contains a table linking to the import batches for any imports or overlays of this biblio Some questions: 1 - Do we need a syspref for this? Or should it just be included? 2 - What info is useful? date/time of import? Import settings? A diff view? 3 - Other thoughts? --- Koha/Import/Record.pm | 15 +++++++++ Koha/Import/Record/Biblio.pm | 17 ++++++++++ catalogue/detail.pl | 14 +++++++++ .../prog/en/modules/catalogue/detail.tt | 31 +++++++++++++++++++ 4 files changed, 77 insertions(+) diff --git a/Koha/Import/Record.pm b/Koha/Import/Record.pm index ea238e62548..aa2e9051f82 100644 --- a/Koha/Import/Record.pm +++ b/Koha/Import/Record.pm @@ -24,6 +24,7 @@ use C4::Context; use C4::Biblio qw(ModBiblio); use C4::AuthoritiesMarc qw(GuessAuthTypeCode ModAuthority); use Koha::Database; +use Koha::ImportBatch; use Koha::Import::Record::Biblios; use Koha::Import::Record::Auths; use Koha::Import::Record::Matches; @@ -61,6 +62,20 @@ sub get_marc_record { return $record; } +=head3 import_batch + +Returns the import batch object for this import record + + my $import_batch = $import_record->import_batch() + +=cut + +sub import_batch { + my ( $self ) = @_; + my $import_batch_rs = $self->_result->import_batch; + return Koha::ImportBatch->_new_from_dbic( $import_batch_rs ); +} + =head3 import_biblio Returns the import biblio object for this import record diff --git a/Koha/Import/Record/Biblio.pm b/Koha/Import/Record/Biblio.pm index 16d3f0eeba1..d279cbea790 100644 --- a/Koha/Import/Record/Biblio.pm +++ b/Koha/Import/Record/Biblio.pm @@ -20,6 +20,7 @@ use Modern::Perl; use Carp; use Koha::Database; +use Koha::Import::Record; use base qw(Koha::Object); @@ -29,6 +30,22 @@ Koha::Import::Record::Biblio - Koha Import Record Biblio Object class =head1 API +=head2 Class methods + +=head3 import_record + +Returns the import record object for this import biblio + + my $import_record = $import_biblio->import_record() + +=cut + +sub import_record { + my ( $self ) = @_; + my $import_record_rs = $self->_result->import_record; + return Koha::Import::Record->_new_from_dbic( $import_record_rs ); +} + =head2 Internal methods =head3 _type diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 9edaf3f3bbf..d75a3fe00b7 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -51,6 +51,7 @@ use Koha::Biblio::ItemGroups; use Koha::CoverImages; use Koha::DateUtils; use Koha::Illrequests; +use Koha::Import::Record::Biblios; use Koha::Items; use Koha::ItemTypes; use Koha::Patrons; @@ -303,6 +304,19 @@ if ( C4::Context->preference('AcquisitionDetails') ) { ); } +if ( C4::Context->preference('ShowImportsOnDetails') || 1 ){ + my $import_biblios = Koha::Import::Record::Biblios->search( + { + matched_biblionumber => $biblionumber, + }, + { prefetch => 'import_record' } + ); + + $template->param( + import_biblios => $import_biblios, + ); +} + if ( C4::Context->preference('suggestion') ) { my $suggestions = Koha::Suggestions->search( { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index 05da5acf56f..bdb02b41e35 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -303,6 +303,7 @@ [% IF ComponentParts && ComponentParts.size %]<li id="components_tab" role="presentation"><a href="#components" aria-controls="components" role="tab" data-toggle="tab">Components ([% ComponentParts.size | html %])</a></li>[% END %] [% IF ( subscriptionsnumber ) %]<li role="presentation"><a href="#subscriptions" aria-controls="subscriptions" role="tab" data-toggle="tab">Subscriptions</a></li>[% END %] [% IF Koha.Preference('AcquisitionDetails') %]<li role="presentation"><a href="#acq_details" aria-controls="acq_details" role="tab" data-toggle="tab">Acquisition details</a></li>[% END %] +[% IF Koha.Preference('ShowImportOnDetails') || 1 %]<li role="presentation"><a href="#import_biblios" aria-controls="import_biblios" role="tab" data-toggle="tab">Imported records</a></li>[% END %] [% IF suggestions.count %]<li role="presentation"><a href="#suggestion_details" aria-controls="suggestion_details" role="tab" data-toggle="tab">Suggestion details</a></li>[% END %] [% IF ( FRBRizeEditions ) %][% IF ( XISBNS ) %]<li role="presentation"><a href="#editions" aria-controls="editions" role="tab" data-toggle="tab">Editions</a></li>[% END %][% END %] [% IF ( ( Koha.Preference('CatalogConcerns') || Koha.Preference('OpacCatalogConcerns') ) && CAN_user_editcatalogue_edit_catalogue ) %]<li role="presentation"><a href="#concerns" aria-controls="concerns" role="tab" data-toggle="tab">Concerns ([% biblio.tickets.count | html %])</a></li>[% END %] @@ -920,6 +921,36 @@ </div> [% END %] +[% IF Koha.Preference('ShowImportsOnDetails') || 1 %] +<div role="tabpanel" class="tab-pane" id="import_biblios"> + [% IF import_biblios.count || 1 %] + <table id="impots"> + <thead> + <tr> + <th>Batch</th> + <th>Record</th> + </tr> + </thead> + <tbody> + [% FOR import_biblio IN import_biblios %] + [% SET import_record = import_biblio.import_record %] + <tr> + <td> + <a href="/cgi-bin/koha/tools/manage-marc-import.pl?import_batch_id=[% import_record.import_batch_id | uri %]" title="Import batch">[% import_record.import_batch.file_name | html %]</a> + </td> + <td> + [% import_biblio.title | html %] + </td> + </tr> + [% END %] + </tbody> + </table> + [% ELSE %] + <span class="noorder">There is no order for this bibliographic record.</span> + [% END %] +</div> +[% END %] + [% IF suggestions.count %] <div role="tabpanel" class="tab-pane" id="suggestion_details"> [% IF nb_archived_suggestions > 0 %] -- 2.30.2