From 6ab9df7aa2b4e6acc3b44a32d9df0c74672bf2f0 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Fri, 4 Dec 2020 16:00:31 +1300 Subject: [PATCH] Bug 16522: Adding 773 to basket and cart WIP Not yet ready for testing. --- Koha/Biblio.pm | 19 +++++++++++++++ basket/basket.pl | 2 ++ .../intranet-tmpl/prog/en/modules/basket/basket.tt | 28 ++++++++++++++++++++++ virtualshelves/sendshelf.pl | 2 ++ 4 files changed, 51 insertions(+) diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index 4d335e2c23..76a9e40a91 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -813,6 +813,25 @@ sub to_api { return { %$response, %$biblioitem }; } +=head2 get_host_item_entries + + my @host_item_entries = $biblio->get_host_item_entries; + +Returns a list of MARC::Field objects of the 773 tag which contain host item entry information. +Returns undef if no 773 defined. + +=cut + +sub get_host_item_entries { + my ( $self ) = @_; + + my $record = $self->metadata->record; + + my @host_item_entries = $record->field('773'); + + return ( @host_item_entries > 0 ) ? \@host_item_entries : undef; +} + =head3 to_api_mapping This method returns the mapping for representing a Koha::Biblio object diff --git a/basket/basket.pl b/basket/basket.pl index aa4cd97dcf..aa5b356646 100755 --- a/basket/basket.pl +++ b/basket/basket.pl @@ -61,6 +61,7 @@ foreach my $biblionumber ( @bibs ) { my $dat = &GetBiblioData($biblionumber); next unless $dat; + my $biblio = Koha::Biblios->find($biblionumber); my $record = &GetMarcBiblio({ biblionumber => $biblionumber }); my $marcnotesarray = GetMarcNotes( $record, $marcflavour ); my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour ); @@ -101,6 +102,7 @@ foreach my $biblionumber ( @bibs ) { $dat->{MARCSERIES} = $marcseriesarray; $dat->{MARCURLS} = $marcurlsarray; $dat->{HASAUTHORS} = $hasauthors; + $dat->{HOSTITEMENTRIES} = $biblio->get_host_item_entries; if ( C4::Context->preference("IntranetBiblioDefaultView") eq "normal" ) { $dat->{dest} = "/cgi-bin/koha/catalogue/detail.pl"; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt index a68c3b7292..c51bab64d4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt @@ -217,6 +217,23 @@ [% END %] + [% IF BIBLIO_RESULT.HOSTITEMENTRIES %] + + Host item entries + + [% FOREACH entry IN BIBLIO_RESULT.HOSTITEMENTRIES %] +

+ [% IF entry.subfield('0') %] + [% entry.subfield('t') | html %] + [% ELSE %] + [% entry.subfield('t') | html %] + [% END %] +

+ [% END %] + + + [% END %] + Location(s) @@ -281,6 +298,17 @@ [% IF ( BIBLIO_RESULT.notes ) %]

[% BIBLIO_RESULT.notes | html %]

[% END %] + [% IF BIBLIO_RESULT.HOSTITEMENTRIES %] + [% FOREACH entry IN BIBLIO_RESULT.HOSTITEMENTRIES %] +

Host item entry: + [% IF entry.subfield('0') %] + [% entry.subfield('t') | html %] + [% ELSE %] + [% entry.subfield('t') | html %] + [% END %] +

+ [% END %] + [% END %] diff --git a/virtualshelves/sendshelf.pl b/virtualshelves/sendshelf.pl index f15e2c9f64..1080c3ffed 100755 --- a/virtualshelves/sendshelf.pl +++ b/virtualshelves/sendshelf.pl @@ -67,6 +67,7 @@ if ($to_address) { while ( my $content = $contents->next ) { my $biblionumber = $content->biblionumber; + my $biblio = Koha::Biblios->find($biblionumber); my $dat = GetBiblioData($biblionumber); my $record = GetMarcBiblio({ biblionumber => $biblionumber, @@ -82,6 +83,7 @@ if ($to_address) { $dat->{'biblionumber'} = $biblionumber; $dat->{ITEM_RESULTS} = \@items; $dat->{HASAUTHORS} = $dat->{'author'} || @$marcauthorsarray; + $dat->{HOSTITEMENTRIES} = $biblio->get_host_item_entries; $iso2709 .= $record->as_usmarc(); -- 2.11.0