From 5622eb258d3384cde8f0d8379bee9161a366b985 Mon Sep 17 00:00:00 2001 From: Nick Clemens 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 %][% END %] [% IF ( subscriptionsnumber ) %]
  • Subscriptions
  • [% END %] [% IF Koha.Preference('AcquisitionDetails') %]
  • Acquisition details
  • [% END %] +[% IF Koha.Preference('ShowImportOnDetails') || 1 %]
  • Imported records
  • [% END %] [% IF suggestions.count %]
  • Suggestion details
  • [% END %] [% IF ( FRBRizeEditions ) %][% IF ( XISBNS ) %]
  • Editions
  • [% END %][% END %] [% IF ( ( Koha.Preference('CatalogConcerns') || Koha.Preference('OpacCatalogConcerns') ) && CAN_user_editcatalogue_edit_catalogue ) %]
  • Concerns ([% biblio.tickets.count | html %])
  • [% END %] @@ -920,6 +921,36 @@ [% END %] +[% IF Koha.Preference('ShowImportsOnDetails') || 1 %] +
    + [% IF import_biblios.count || 1 %] + + + + + + + + + [% FOR import_biblio IN import_biblios %] + [% SET import_record = import_biblio.import_record %] + + + + + [% END %] + +
    BatchRecord
    + [% import_record.import_batch.file_name | html %] + + [% import_biblio.title | html %] +
    + [% ELSE %] + There is no order for this bibliographic record. + [% END %] +
    +[% END %] + [% IF suggestions.count %]
    [% IF nb_archived_suggestions > 0 %] -- 2.30.2