Bug 16522 - Add 773 (Host item entry) to the cart and list displays and e-mails
Summary: Add 773 (Host item entry) to the cart and list displays and e-mails
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: OPAC (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Aleisha Amohia
QA Contact: Marcel de Rooy
URL:
Keywords:
: 17867 (view as bug list)
Depends on:
Blocks: 32689 33160
  Show dependency treegraph
 
Reported: 2016-05-14 10:57 UTC by Katrin Fischer
Modified: 2023-12-28 20:43 UTC (History)
12 users (show)

See Also:
Change sponsored?: Sponsored
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
This adds information from host item entry (MARC21 773) and if applicable a link to the host record in the following places: * Staff interface: list, list email, cart, cart email, and search results * OPAC: list, list email, cart, cart email, and search results
Version(s) released in:
23.05.00,22.11.03


Attachments
Bug 16522: Adding 773 to basket and cart WIP (6.64 KB, patch)
2020-12-04 03:02 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 16522: Adding 773 to cart and list displays and emails (29.00 KB, patch)
2020-12-16 03:14 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 16522: Adding 773 to cart and list displays and emails (28.72 KB, patch)
2021-05-04 03:46 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 16522: Adding 773 to cart and list displays and emails (28.46 KB, patch)
2022-02-08 00:36 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 16522: Adding 773 to cart and list displays and emails (28.28 KB, patch)
2022-04-21 01:44 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 16522: Adding 773 to cart and list displays and emails (21.60 KB, patch)
2022-05-27 03:49 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 16522: Adding 773 to cart and list displays and emails (22.00 KB, patch)
2022-07-06 04:29 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 16522: (follow-up) MARC display templates and get_marc_host fixes (41.45 KB, patch)
2022-07-06 04:29 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 16522: Adding 773 to cart and list displays and emails (22.00 KB, patch)
2022-08-16 05:31 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 16522: (follow-up) MARC display templates and get_marc_host fixes (45.07 KB, patch)
2022-08-16 05:31 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 16522: Adding 773 to cart and list displays and emails (21.94 KB, patch)
2022-08-26 16:58 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 16522: (follow-up) MARC display templates and get_marc_host fixes (44.97 KB, patch)
2022-08-26 16:58 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 16522: (follow-up) Add missing TT filters (5.86 KB, patch)
2022-08-26 16:58 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 16522: Adding 773 to cart and list displays and emails (22.00 KB, patch)
2022-09-28 14:25 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 16522: (follow-up) MARC display templates and get_marc_host fixes (45.03 KB, patch)
2022-09-28 14:25 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 16522: (follow-up) Add missing TT filters (5.92 KB, patch)
2022-09-28 14:25 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 16522: (follow-up) Rename "Host item entry" to "In" (8.67 KB, patch)
2022-09-28 14:25 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 16522: (follow-up) Fix variable in OPAC cart brief display (1.89 KB, patch)
2022-09-28 14:25 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 16522: (follow-up) Remove HTML links from email (5.16 KB, patch)
2022-09-28 14:25 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 16522: Adding 773 to cart and list displays and emails (21.93 KB, patch)
2022-10-17 22:42 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 16522: (follow-up) MARC display templates and get_marc_host fixes (45.07 KB, patch)
2022-10-17 22:42 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 16522: (follow-up) Add missing TT filters (5.93 KB, patch)
2022-10-17 22:42 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 16522: (follow-up) Rename "Host item entry" to "In" (8.69 KB, patch)
2022-10-17 22:42 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 16522: (follow-up) Fix variable in OPAC cart brief display (1.90 KB, patch)
2022-10-17 22:42 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 16522: (follow-up) Remove HTML links from email (5.17 KB, patch)
2022-10-17 22:42 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 16522: (follow-up) If no 773$w, try to return host record (6.11 KB, patch)
2022-10-17 22:42 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 16522: (follow-up) If no 773$w, try to return host record (5.88 KB, patch)
2022-10-31 22:42 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Search results screenshot showing "In.." appearing correctly in staff client (155.40 KB, image/jpeg)
2022-12-06 17:49 UTC, Heather
Details
Search results in OPAC without "In..." appearing (137.50 KB, image/jpeg)
2022-12-06 17:51 UTC, Heather
Details
Bug 16522: (follow-up) If no 773$w, try to return host record (5.93 KB, patch)
2023-01-04 19:59 UTC, ByWater Sandboxes
Details | Diff | Splinter Review
Bug 16522: Adding 773 to cart and list displays and emails (21.96 KB, patch)
2023-01-20 15:37 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 16522: (follow-up) MARC display templates and get_marc_host fixes (45.09 KB, patch)
2023-01-20 15:37 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 16522: (follow-up) Add missing TT filters (5.98 KB, patch)
2023-01-20 15:37 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 16522: (follow-up) Rename "Host item entry" to "In" (8.73 KB, patch)
2023-01-20 15:38 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 16522: (follow-up) Fix variable in OPAC cart brief display (1.95 KB, patch)
2023-01-20 15:38 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 16522: (follow-up) Remove HTML links from email (5.22 KB, patch)
2023-01-20 15:38 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 16522: (follow-up) If no 773$w, try to return host record (5.99 KB, patch)
2023-01-20 15:38 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 16522: Move 773 entries in result lists before 856 entries (2.82 KB, patch)
2023-01-20 15:38 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Katrin Fischer 2016-05-14 10:57:55 UTC
When adding an analytical record to your cart or your list, the host item entry - the serial or monograph the analytic is included in, will now show. 

Ideally this information should show in staff and OPAC
- in the brief display table
- on the more details view
- in the e-mail text

For libraries with a lot of analytical records this is quite an issue.
Comment 1 Katrin Fischer 2020-01-22 14:49:36 UTC
I am changing this to be a bug - the analytical information is useless without the source.
Comment 2 Aleisha Amohia 2020-12-04 03:02:18 UTC
Created attachment 114178 [details] [review]
Bug 16522: Adding 773 to basket and cart WIP

Not yet ready for testing.
Comment 3 Aleisha Amohia 2020-12-16 03:14:05 UTC
Created attachment 114429 [details] [review]
Bug 16522: Adding 773 to cart and list displays and emails

This patch adds a new subroutine get_host_item_entries in the
Koha::Biblio module which retrieves any 773 fields from the biblio
record. The subroutine is used to show a host item entry and a link to
the record in the following places:
- staff client list
- staff client cart
- staff client send list email
- staff client send cart email
- opac list
- opac cart
- opac send list email email
- opac send cart email

To test:

1. apply patch, restart services
2. log into the staff client and enable the syspref EasyAnalyticalRecords
3. find a record with an item. take note of the barcode.
4. go to another record (biblio 2). click Edit -> Link to host record
5. enter the barcode in the input and submit.
6. click the MARC tab and confirm the host record has been linked under
MARC field 773.
7. add biblio 2 to your cart, and to a list.
8. go to your cart. confirm you see the 'host item entry' link.
9. click on 'more details' and confirm you see the 'host item entries'
link.
10. click 'send' to email the cart. confirm the email contains the host
item entry and the link sends you to the catalogue page for the record
in the OPAC.
11. go to the list you added the record to. confirm you see the 'source'
link for the host item entry.
12. click 'send list' to email the list. confirm the email contains the
host item entry and the link sends you to the catalogue page for the
record in the OPAC.
13. log into the OPAC. repeat steps 7 to 12 on the OPAC and confirm they
all pass as expected.
14. confirm tests pass: t/db_dependent/Koha/Biblio.t

Sponsored-by: Bibliotheksservice-Zentrum Baden-Württemberg (BSZ)
Comment 4 Jonathan Druart 2020-12-17 10:55:49 UTC
Looks good, however I think the Koha::Biblio method should not return a MARC::Field set, but instead hashrefs with the info you need.
Comment 5 Katrin Fischer 2020-12-17 11:13:10 UTC
Thx Joubu for your comment!

Took a first glance at the code too, but need to spend some more time. Problem is that $0 and $9 subfields are not MARC standard, but only used for Koha's EasyAnalytics feature, which we can't use as it clashes with our union catalog workflow. I want to check how it all fits together with our 773 not having either in comparison, to give you better feedback.
Comment 6 Aleisha Amohia 2020-12-17 19:59:23 UTC
Thanks Katrin - the host item feature isn't something I've used before so some context and more specific feedback would be useful!
Comment 7 Aleisha Amohia 2021-05-04 03:46:22 UTC
Created attachment 120425 [details] [review]
Bug 16522: Adding 773 to cart and list displays and emails

This patch adds a new subroutine get_host_item_entries in the
Koha::Biblio module which retrieves any 773 fields from the biblio
record. The subroutine is used to show a host item entry and a link to
the record in the following places:
- staff client list
- staff client cart
- staff client send list email
- staff client send cart email
- opac list
- opac cart
- opac send list email email
- opac send cart email

To test:

1. apply patch, restart services
2. log into the staff client and enable the syspref EasyAnalyticalRecords
3. find a record with an item. take note of the barcode.
4. go to another record (biblio 2). click Edit -> Link to host record
5. enter the barcode in the input and submit.
6. click the MARC tab and confirm the host record has been linked under
MARC field 773.
7. add biblio 2 to your cart, and to a list.
8. go to your cart. confirm you see the 'host item entry' link.
9. click on 'more details' and confirm you see the 'host item entries'
link.
10. click 'send' to email the cart. confirm the email contains the host
item entry and the link sends you to the catalogue page for the record
in the OPAC.
11. go to the list you added the record to. confirm you see the 'source'
link for the host item entry.
12. click 'send list' to email the list. confirm the email contains the
host item entry and the link sends you to the catalogue page for the
record in the OPAC.
13. log into the OPAC. repeat steps 7 to 12 on the OPAC and confirm they
all pass as expected.
14. confirm tests pass: t/db_dependent/Koha/Biblio.t

Sponsored-by: Bibliotheksservice-Zentrum Baden-Württemberg (BSZ)
Comment 8 Aleisha Amohia 2022-02-08 00:36:58 UTC
Created attachment 130250 [details] [review]
Bug 16522: Adding 773 to cart and list displays and emails

This patch adds a new subroutine get_host_item_entries in the
Koha::Biblio module which retrieves any 773 fields from the biblio
record. The subroutine is used to show a host item entry and a link to
the record in the following places:
- staff client list
- staff client cart
- staff client send list email
- staff client send cart email
- opac list
- opac cart
- opac send list email email
- opac send cart email

To test:

1. apply patch, restart services
2. log into the staff client and enable the syspref EasyAnalyticalRecords
3. find a record with an item. take note of the barcode.
4. go to another record (biblio 2). click Edit -> Link to host record
5. enter the barcode in the input and submit.
6. click the MARC tab and confirm the host record has been linked under
MARC field 773.
7. add biblio 2 to your cart, and to a list.
8. go to your cart. confirm you see the 'host item entry' link.
9. click on 'more details' and confirm you see the 'host item entries'
link.
10. click 'send' to email the cart. confirm the email contains the host
item entry and the link sends you to the catalogue page for the record
in the OPAC.
11. go to the list you added the record to. confirm you see the 'source'
link for the host item entry.
12. click 'send list' to email the list. confirm the email contains the
host item entry and the link sends you to the catalogue page for the
record in the OPAC.
13. log into the OPAC. repeat steps 7 to 12 on the OPAC and confirm they
all pass as expected.
14. confirm tests pass: t/db_dependent/Koha/Biblio.t

Sponsored-by: Bibliotheksservice-Zentrum Baden-Württemberg (BSZ)
Comment 9 Christian Stelzenmüller 2022-04-14 08:45:08 UTC
I was testing this using a sandbox. 
Unfortunately, on step 8 and 9 i couldn't see the "host item entry" link...

In the list, i can see the source (step 11) with the title (245 $a), but no link (?)
Comment 10 Aleisha Amohia 2022-04-19 21:47:59 UTC
Thanks for testing Christian. Please mark bug as 'Failed QA' if they don't behave according to the test plan.

I'll take a look at this when I get a chance.
Comment 11 Aleisha Amohia 2022-04-21 01:44:29 UTC
Created attachment 133509 [details] [review]
Bug 16522: Adding 773 to cart and list displays and emails

This patch adds a new subroutine get_host_item_entries in the
Koha::Biblio module which retrieves any 773 fields from the biblio
record. The subroutine is used to show a host item entry and a link to
the record in the following places:
- staff client list
- staff client cart
- staff client send list email
- staff client send cart email
- opac list
- opac cart
- opac send list email email
- opac send cart email

To test:

1. apply patch, restart services
2. log into the staff client and enable the syspref EasyAnalyticalRecords
3. find a record with an item. take note of the barcode.
4. go to another record (biblio 2). click Edit -> Link to host record
5. enter the barcode in the input and submit.
6. click the MARC tab and confirm the host record has been linked under
MARC field 773.
7. add biblio 2 to your cart, and to a list.
8. go to your cart. confirm you see the 'host item entry' link.
9. click on 'more details' and confirm you see the 'host item entries'
link.
10. click 'send' to email the cart. confirm the email contains the host
item entry and the link sends you to the catalogue page for the record
in the OPAC.
11. go to the list you added the record to. confirm you see the 'source'
link for the host item entry.
12. click 'send list' to email the list. confirm the email contains the
host item entry and the link sends you to the catalogue page for the
record in the OPAC.
13. log into the OPAC. repeat steps 7 to 12 on the OPAC and confirm they
all pass as expected.
14. confirm tests pass: t/db_dependent/Koha/Biblio.t

Sponsored-by: Bibliotheksservice-Zentrum Baden-Württemberg (BSZ)
Comment 12 Martin Renvoize 2022-05-09 12:45:51 UTC
Comment on attachment 133509 [details] [review]
Bug 16522: Adding 773 to cart and list displays and emails

Review of attachment 133509 [details] [review]:
-----------------------------------------------------------------

::: Koha/Biblio.pm
@@ +1099,5 @@
> +    my @host_item_entries = $record->field('773');
> +
> +    return ( @host_item_entries > 0 ) ? \@host_item_entries : undef;
> +}
> +

Should we be using 'get_marc_host' from bug 20310 here?
Comment 13 Aleisha Amohia 2022-05-27 03:49:25 UTC
Created attachment 135416 [details] [review]
Bug 16522: Adding 773 to cart and list displays and emails

This patch adds a new subroutine get_host_item_entries in the
Koha::Biblio module which retrieves any 773 fields from the biblio
record. The subroutine is used to show a host item entry and a link to
the record in the following places:
- staff client list
- staff client cart
- staff client send list email
- staff client send cart email
- opac list
- opac cart
- opac send list email email
- opac send cart email

To test:

1. apply patch, restart services
2. log into the staff client and enable the syspref EasyAnalyticalRecords
3. find a record with an item. take note of the barcode.
4. go to another record (biblio 2). click Edit -> Link to host record
5. enter the barcode in the input and submit.
6. click the MARC tab and confirm the host record has been linked under
MARC field 773.
7. add biblio 2 to your cart, and to a list.
8. go to your cart. confirm you see the 'host item entry' link.
9. click on 'more details' and confirm you see the 'host item entries'
link.
10. click 'send' to email the cart. confirm the email contains the host
item entry and the link sends you to the catalogue page for the record
in the OPAC.
11. go to the list you added the record to. confirm you see the 'source'
link for the host item entry.
12. click 'send list' to email the list. confirm the email contains the
host item entry and the link sends you to the catalogue page for the
record in the OPAC.
13. log into the OPAC. repeat steps 7 to 12 on the OPAC and confirm they
all pass as expected.

Sponsored-by: Bibliotheksservice-Zentrum Baden-Württemberg (BSZ)
Comment 14 David Nind 2022-05-31 01:31:24 UTC
Two things from testing:

1. For the emails, is the link supposed to be to the record for the source/host item entry, or the record it is in? For me, it is linking to the record with the 773.

2. After applying the patch, flush_memcached, restart_all, I get these error traces when sending the email from the staff interface for the cart and list (I could send emails for the cart and list before the patch was applied, and I can send emails from the cart and list from the OPAC):

Cart: staff interface
~~~~~~~~~~~~~~~~~~~~~

Template process failed: file error - biblio_a_href: not found at /kohadevbox/koha/C4/Templates.pm line 127

    in C4::Templates::output at /kohadevbox/koha/C4/Templates.pm line 127

      124: 
      125:     my $data;
      126:     binmode( STDOUT, ":encoding(UTF-8)" );
      127:     $template->process( $self->filename, $vars, \$data )
      128:       || die "Template process failed: ", $template->error();
      129:     return $data;


List: staff interface
~~~~~~~~~~~~~~~~~~~~~

The method Koha::Biblio->get_host_item_entries is not covered by tests!

Trace begun at /kohadevbox/koha/Koha/Object.pm line 875
Koha::Object::AUTOLOAD('Koha::Biblio=HASH(0x560f9c5e1470)') called at /kohadevbox/koha/virtualshelves/sendshelf.pl line 95
eval {...} at /kohadevbox/koha/virtualshelves/sendshelf.pl line 2
CGI::Compile::ROOT::kohadevbox_koha_virtualshelves_sendshelf_2epl::__ANON__('CGI::Compile=HASH(0x560f9af894f8)', '', '/kohadevbox/koha/virtualshelves/sendshelf.pl', '/kohadevbox/koha/virtualshelves', 'ARRAY(0x560f9b0ef760)') called at /usr/share/perl5/CGI/Compile.pm line 151
CGI::Compile::ROOT::kohadevbox_koha_virtualshelves_sendshelf_2epl::sendshelf_2epl at /usr/share/perl5/CGI/Emulate/PSGI.pm line 30
CGI::Emulate::PSGI::__ANON__('HASH(0x560f9c7603f8)') called at /usr/share/perl5/Plack/App/WrapCGI.pm line 95
Plack::App::WrapCGI::call('Plack::App::WrapCGI=HASH(0x560f9b22e9c0)', 'HASH(0x560f9c7603f8)') called at /usr/s
.........
Comment 15 David Nind 2022-05-31 01:34:09 UTC
Testing notes (using koha-testing-docker):

- Email sending setup by adding this to the koha-conf.xml file (where email address = gmail address and yourpassword = the app password setup for your gmail account):

  <smtp_server>
    <host>smtp.gmail.com</host>
    <port>587</port>
    <timeout>5</timeout>
    <ssl_mode>STARTTLS</ssl_mode>
    <user_name>youraddress@gmail.com</user_name>
    <password>yourpassword</password>
    <debug>1</debug>
  </smtp_server>
Comment 16 Katrin Fischer 2022-06-13 14:16:19 UTC
Hi Aleisha,

sorry for taking so long to give feedback on this patch. It took a while to wrap my head around and I hope my notes make sense.

> Thanks Katrin - the host item feature isn't something I've used before so some context and more specific feedback would be useful!

I'll try!

We'd create an analytical record a litle different than in your test plan, as we 
can't use the EasyAnalytics feature that relies on creating 773 fields in the MARC 
record. For our records the union catalog is the primary database and the link
between the record and its host item would be created there.

This would resemble our workflow a little better in Koha:

* Search for a serial or monograph record in the staff interface
* From the detail page: New > New child record
* This opens a new record in the cataloguing editor with a 773 created from the information of its 'parent' record. If you are using controlnumber for linking, the 001 of the host will be in $w of the child used for linking by ID.
* Add 773$g with information on the location of the 'child' within the 'parent' (i.e. volume, issue, pages)
  Example: $g 13(1917), 12, p. 98-104

There is sample record set on bug 11175, that's a good starting point. For testing I have added $g and removed $w in some records. 

=XSLT based displays (list view in OPAC)=

* I think currently the result page uses a copy of the 773 code from the detail page, but
they have fallen out of sync. For example missing the change from bug 20277. Could you please move the code into MARC21slimUtils.xsl as a new template, so we can use the same logic in detail and result page? Nick did something similar on bug 5927. 

* We should probably note in the test plan that the changes to the XSLT will also apply to the normal result list in the catalog and staff interface.

=TT based displays (cart detail, list detail, cart email, list email)=

You used get_marc_host for finding the host record and the include for displaying the
title here, which I think is a neat approach. I really like that it allows us to create a direct link using the biblionumber instead of the more complicated search link using $w or $a$t. But as usual, there are some caveats with libraries. :(

At the moment the 773 will only show when the library has been using $w/001 for linking, which is often not the case. We also have some cases, where an 'unlinked' 773 without $w will be added/imported in our catalogs.

* It would be nice if we could still be using get_marc_host somehow, but we might need at least a fallback to create the display using 773$atg directly. 773 should only display if there is at least a $t. I think when there is no $w just displaying the plain text without a link would be ok and still a nice improvement.

* Can you please add 773$g to display? It looks like get_marc_host will return it if called in list context.

* virtualshelves/sendshelf.pl still has $biblio->get_host_item_entries, maybe from a previous 
version of this patch?

* Release notes and test plan also mention $biblio->get_host_item_entries, but I think it was 
replaced by get_marc_host.

* The FOREACH in the templates might not be needed if we keep using get_marc_host as it only looks at the first 773.

* The 'label' for 773 is usually "In:" in the detail and other views. Can you please make the TT views match? Currently they are using 'Host item entry' or 'Host item entries' or 'Source' (XSLT results).

About comment#14 from David:

* I couldn't test the email part, apart from reading the code, but maybe you could check the the links? I'll certainly try his test plan for email next iteration :)

* I didn't have the issue with the cart in the staff interface that David noted, but I think the list issue is due to the wrong method name.
Comment 17 Aleisha Amohia 2022-07-06 04:29:22 UTC
Created attachment 137196 [details] [review]
Bug 16522: Adding 773 to cart and list displays and emails

This patch adds a new subroutine get_marc_host in the
Koha::Biblio module which retrieves any 773 fields from the biblio
record. The subroutine is used to show a host item entry and a link to
the record in the following places:
- staff client list
- staff client cart
- staff client send list email
- staff client send cart email
- staff client search results
- staff client detail page
- opac list
- opac cart
- opac send list email email
- opac send cart email
- opac search results
- opac detail page

To test:

1. apply patch, restart services
2. log into the staff client and enable the syspref EasyAnalyticalRecords
3. find a record with an item. take note of the barcode.
4. go to another record (biblio 2). click Edit -> Link to host record
5. enter the barcode in the input and submit.
6. click the MARC tab and confirm the host record has been linked under
MARC field 773.
7. add biblio 2 to your cart, and to a list.
8. go to your cart. confirm you see the 'host item entry' link.
9. click on 'more details' and confirm you see the 'host item entries'
link.
10. click 'send' to email the cart. confirm the email contains the host
item entry and the link sends you to the catalogue page for the record
in the OPAC.
11. go to the list you added the record to. confirm you see the 'source'
link for the host item entry.
12. click 'send list' to email the list. confirm the email contains the
host item entry and the link sends you to the catalogue page for the
record in the OPAC.
13. log into the OPAC. repeat steps 7 to 12 on the OPAC and confirm they
all pass as expected.
14. Confirm host item info also shows correctly on the
OPAC and staff client search results, and the OPAC and staff client
detail pages (where XSLT is used)
15. Delete the 773$w and confirm host item info still shows correctly
but no longer links to biblio
16. confirm tests pass t/db_dependent/Koha/Biblio/host_record.t

Sponsored-by: Bibliotheksservice-Zentrum Baden-Württemberg (BSZ)
Comment 18 Aleisha Amohia 2022-07-06 04:29:27 UTC
Created attachment 137197 [details] [review]
Bug 16522: (follow-up) MARC display templates and get_marc_host fixes

Also:
- Show related parts 773$g
- Normalise using 'Host item entry' as title
- Remove 'foreach' because non-xslt views only return first
- If no $w, use $atg, and related tests in
t/db_dependent/Koha/Biblio/host_record.t
Comment 19 David Nind 2022-07-12 11:19:59 UTC
1. Sending email
~~~~~~~~~~~~~~~

Sending email from staff interface - for both the cart and the list I get this error trace (note: can send email from OPAC for both the cart and list):

Template process failed: file error - biblio_a_href: not found at /kohadevbox/koha/C4/Templates.pm line 127

    in C4::Templates::output at /kohadevbox/koha/C4/Templates.pm line 127

      124: 
      125:     my $data;
      126:     binmode( STDOUT, ":encoding(UTF-8)" );
      127:     $template->process( $self->filename, $vars, \$data )
      128:       || die "Template process failed: ", $template->error();
      129:     return $data;
      130: }

    Show function arguments
    in (eval) at /kohadevbox/koha/virtualshelves/sendshelf.pl line 111

      108:     );
      109: 
      110:     # Getting template result
      111:     my $template_res = $template2->output();
      112:     my $body;
      113: 
      114:     my $subject;

    in CGI::Compile::ROOT::kohadevbox_koha_virtualshelves_sendshelf_2epl::__ANON__ at /kohadevbox/koha/virtualshelves/sendshelf.pl line 2

....

Setup to test email: see comment #15 (note: yourpassword = an app password, not the normal Gmail password)

2. OPAC - link for host item entry is wrong
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The link in OPAC record detail page to the host item entry is using the staff interface URL.

Link in OPAC detail view: 
http://127.0.0.1:8080/cgi-bin/koha/catalogue/detail.pl?biblionumber=262

Should be:
http://127.0.0.1:8080/cgi-bin/koha/opac-detail.pl?biblionumber=262

3. Step 15
~~~~~~~~~~

I deleted the 773$w, but the staff interface and OPAC are still showing the link to the host record.

4. Text 'Host item entry' vs 'In'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Have you seen bug 31106 - text in child record to host item is 'In'.

See also Katrin's comment about the 'label' for 773 in comment #16
Comment 20 Aleisha Amohia 2022-08-16 05:31:36 UTC
Created attachment 139168 [details] [review]
Bug 16522: Adding 773 to cart and list displays and emails

This patch adds a new subroutine get_marc_host in the
Koha::Biblio module which retrieves any 773 fields from the biblio
record. The subroutine is used to show a host item entry and a link to
the record in the following places:
- staff client list
- staff client cart
- staff client send list email
- staff client send cart email
- staff client search results
- staff client detail page
- opac list
- opac cart
- opac send list email email
- opac send cart email
- opac search results
- opac detail page

To test:

1. apply patch, restart services
2. log into the staff client and enable the syspref EasyAnalyticalRecords
3. find a record with an item. take note of the barcode.
4. go to another record (biblio 2). click Edit -> Link to host record
5. enter the barcode in the input and submit.
6. click the MARC tab and confirm the host record has been linked under
MARC field 773.
7. add biblio 2 to your cart, and to a list.
8. go to your cart. confirm you see the 'host item entry' link.
9. click on 'more details' and confirm you see the 'host item entries'
link.
10. click 'send' to email the cart. confirm the email contains the host
item entry and the link sends you to the catalogue page for the record
in the OPAC.
11. go to the list you added the record to. confirm you see the 'source'
link for the host item entry.
12. click 'send list' to email the list. confirm the email contains the
host item entry and the link sends you to the catalogue page for the
record in the OPAC.
13. log into the OPAC. repeat steps 7 to 12 on the OPAC and confirm they
all pass as expected.
14. Confirm host item info also shows correctly on the
OPAC and staff client search results, and the OPAC and staff client
detail pages (where XSLT is used)
15. Delete the 773$w and confirm host item info still shows correctly
but no longer links to biblio
16. confirm tests pass t/db_dependent/Koha/Biblio/host_record.t

Sponsored-by: Bibliotheksservice-Zentrum Baden-Württemberg (BSZ)
Comment 21 Aleisha Amohia 2022-08-16 05:31:41 UTC
Created attachment 139169 [details] [review]
Bug 16522: (follow-up) MARC display templates and get_marc_host fixes

Also:
- Show related parts 773$g
- Normalise using 'Host item entry' as title
- Remove 'foreach' because non-xslt views only return first
- If no $w, use $atg, and related tests in
t/db_dependent/Koha/Biblio/host_record.t
Comment 22 Aleisha Amohia 2022-08-16 05:32:09 UTC
Have rebased the patches, will now work on addressing the other bits
Comment 23 Aleisha Amohia 2022-08-16 05:54:09 UTC
(In reply to David Nind from comment #19)
> 1. Sending email
> ~~~~~~~~~~~~~~~
> 

Hi David, I couldn't reproduce this, can you please retest?

> 
> 2. OPAC - link for host item entry is wrong
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 

Should be fixed with my rebase

> 
> 3. Step 15
> ~~~~~~~~~~
> 
> I deleted the 773$w, but the staff interface and OPAC are still showing the
> link to the host record.

Cannot reproduce, can you please tell me what steps you took to get this?

> 
> 4. Text 'Host item entry' vs 'In'
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Have you seen bug 31106 - text in child record to host item is 'In'.
> 
> See also Katrin's comment about the 'label' for 773 in comment #16

I addressed this in my latest follow-up

Ready to test please
Comment 24 Katrin Fischer 2022-08-26 16:58:28 UTC
Created attachment 139846 [details] [review]
Bug 16522: Adding 773 to cart and list displays and emails

This patch adds a new subroutine get_marc_host in the
Koha::Biblio module which retrieves any 773 fields from the biblio
record. The subroutine is used to show a host item entry and a link to
the record in the following places:
- staff client list
- staff client cart
- staff client send list email
- staff client send cart email
- staff client search results
- staff client detail page
- opac list
- opac cart
- opac send list email email
- opac send cart email
- opac search results
- opac detail page

To test:

1. apply patch, restart services
2. log into the staff client and enable the syspref EasyAnalyticalRecords
3. find a record with an item. take note of the barcode.
4. go to another record (biblio 2). click Edit -> Link to host record
5. enter the barcode in the input and submit.
6. click the MARC tab and confirm the host record has been linked under
MARC field 773.
7. add biblio 2 to your cart, and to a list.
8. go to your cart. confirm you see the 'host item entry' link.
9. click on 'more details' and confirm you see the 'host item entries'
link.
10. click 'send' to email the cart. confirm the email contains the host
item entry and the link sends you to the catalogue page for the record
in the OPAC.
11. go to the list you added the record to. confirm you see the 'source'
link for the host item entry.
12. click 'send list' to email the list. confirm the email contains the
host item entry and the link sends you to the catalogue page for the
record in the OPAC.
13. log into the OPAC. repeat steps 7 to 12 on the OPAC and confirm they
all pass as expected.
14. Confirm host item info also shows correctly on the
OPAC and staff client search results, and the OPAC and staff client
detail pages (where XSLT is used)
15. Delete the 773$w and confirm host item info still shows correctly
but no longer links to biblio
16. confirm tests pass t/db_dependent/Koha/Biblio/host_record.t

Sponsored-by: Bibliotheksservice-Zentrum Baden-Württemberg (BSZ)
Comment 25 Katrin Fischer 2022-08-26 16:58:34 UTC
Created attachment 139847 [details] [review]
Bug 16522: (follow-up) MARC display templates and get_marc_host fixes

Also:
- Show related parts 773$g
- Normalise using 'Host item entry' as title
- Remove 'foreach' because non-xslt views only return first
- If no $w, use $atg, and related tests in
t/db_dependent/Koha/Biblio/host_record.t
Comment 26 Katrin Fischer 2022-08-26 16:58:39 UTC
Created attachment 139848 [details] [review]
Bug 16522: (follow-up) Add missing TT filters
Comment 27 Katrin Fischer 2022-08-26 17:02:41 UTC
Rebased and provided a follow-up to make the QA test tools pass.
Comment 28 Katrin Fischer 2022-08-26 17:06:07 UTC
(In reply to Katrin Fischer from comment #27)
> Rebased and provided a follow-up to make the QA test tools pass.

Conflict was limited to sendbasket.pl and the change to this line:
$dat->{ITEM_RESULTS}   = $biblio->items->search_ordered;
Comment 29 Christian Stelzenmüller 2022-08-29 06:39:24 UTC
On step 10 in the test plan.

"Template process failed: file error - biblio_a_href: not found at /kohadevbox/koha/C4/Templates.pm line 127

    in C4::Templates::output at /kohadevbox/koha/C4/Templates.pm line 127

      124: 
      125:     my $data;
      126:     binmode( STDOUT, ":encoding(UTF-8)" );
      127:     $template->process( $self->filename, $vars, \$data )
      128:       || die "Template process failed: ", $template->error();
      129:     return $data;
      130: }

    Show function arguments
    in (eval) at /kohadevbox/koha/basket/sendbasket.pl line 105

      102:     );
      103: 
      104:     # Getting template result
      105:     my $template_res = $template2->output();
      106:     my $body;
      107: 
      108:     my $subject; 

..."
Comment 30 Aleisha Amohia 2022-09-07 01:37:34 UTC
Hi Christian, I wasn't able to reproduce that error. Are you sure you're testing on the latest upstream version?
Comment 31 Martin Renvoize 2022-09-07 07:14:31 UTC
Doesn't bug 3150 negate the need for this at all?
Comment 32 Aleisha Amohia 2022-09-07 20:58:42 UTC
(In reply to Martin Renvoize from comment #31)
> Doesn't bug 3150 negate the need for this at all?

Bug 3150 would only address some of the email part for this bug? This also handles the display in the cart and list within Koha.
Comment 33 Katrin Fischer 2022-09-28 14:25:09 UTC
Created attachment 141058 [details] [review]
Bug 16522: Adding 773 to cart and list displays and emails

This patch adds a new subroutine get_marc_host in the
Koha::Biblio module which retrieves any 773 fields from the biblio
record. The subroutine is used to show a host item entry and a link to
the record in the following places:
- staff client list
- staff client cart
- staff client send list email
- staff client send cart email
- staff client search results
- staff client detail page
- opac list
- opac cart
- opac send list email email
- opac send cart email
- opac search results
- opac detail page

To test:

1. apply patch, restart services
2. log into the staff client and enable the syspref EasyAnalyticalRecords
3. find a record with an item. take note of the barcode.
4. go to another record (biblio 2). click Edit -> Link to host record
5. enter the barcode in the input and submit.
6. click the MARC tab and confirm the host record has been linked under
MARC field 773.
7. add biblio 2 to your cart, and to a list.
8. go to your cart. confirm you see the 'host item entry' link.
9. click on 'more details' and confirm you see the 'host item entries'
link.
10. click 'send' to email the cart. confirm the email contains the host
item entry and the link sends you to the catalogue page for the record
in the OPAC.
11. go to the list you added the record to. confirm you see the 'source'
link for the host item entry.
12. click 'send list' to email the list. confirm the email contains the
host item entry and the link sends you to the catalogue page for the
record in the OPAC.
13. log into the OPAC. repeat steps 7 to 12 on the OPAC and confirm they
all pass as expected.
14. Confirm host item info also shows correctly on the
OPAC and staff client search results, and the OPAC and staff client
detail pages (where XSLT is used)
15. Delete the 773$w and confirm host item info still shows correctly
but no longer links to biblio
16. confirm tests pass t/db_dependent/Koha/Biblio/host_record.t

Sponsored-by: Bibliotheksservice-Zentrum Baden-Württemberg (BSZ)

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 34 Katrin Fischer 2022-09-28 14:25:14 UTC
Created attachment 141059 [details] [review]
Bug 16522: (follow-up) MARC display templates and get_marc_host fixes

Also:
- Show related parts 773$g
- Normalise using 'Host item entry' as title
- Remove 'foreach' because non-xslt views only return first
- If no $w, use $atg, and related tests in
t/db_dependent/Koha/Biblio/host_record.t

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 35 Katrin Fischer 2022-09-28 14:25:23 UTC
Created attachment 141060 [details] [review]
Bug 16522: (follow-up) Add missing TT filters

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 36 Katrin Fischer 2022-09-28 14:25:29 UTC
Created attachment 141061 [details] [review]
Bug 16522: (follow-up) Rename "Host item entry" to "In"

We already use In: as label for 773 on the result lists and
detail pages and it's also recommended in the MARC documentation.
With this patch the label is the same everywhere.

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 37 Katrin Fischer 2022-09-28 14:25:33 UTC
Created attachment 141062 [details] [review]
Bug 16522: (follow-up) Fix variable in OPAC cart brief display

Without this change records 773 entries with links in $w would
not display the title information, but just "No title".
With the variable fixed, now the host's title displays.

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 38 Katrin Fischer 2022-09-28 14:25:38 UTC
Created attachment 141063 [details] [review]
Bug 16522: (follow-up) Remove HTML links from email

The emails sent for cart and list are plain text and any
<a> tag will be scrubbed by HtmlToText. So we can remove
those links.

This also solves an issue with the original patch set,
where the error below would appear on sending a cart or
list email from the staff interface:

Template process failed: file error - biblio_a_href: not found at /kohadevbox/koha/C4/Templates.pm line 127

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 39 Katrin Fischer 2022-09-28 14:26:51 UTC
I have changed the test plan slightly to account for our cataloguing use case as we are not using EasyAnalytics:

1. apply patch, restart services 

Original test plan:
2. log into the staff client and enable the syspref EasyAnalyticalRecords
3. find a record with an item. take note of the barcode.
4. go to another record (biblio 2). click Edit -> Link to host record
5. enter the barcode in the input and submit.
6. click the MARC tab and confirm the host record has been linked under
MARC field 773.

Adapted test plan:
2. log into the staff interface and enable the syspref UseControlNumber 
3. Download analytical records and their host records from one of our catalogs :)
4. Import records into Koha, view them and verify the 773 links work correctly
5. Remove 773$w from one of the records, as sometimes records might not be linked.

In the staff interface:

7. add biblio 2 to your cart, and to a list.
8. go to your cart. confirm you see the 'host item entry' link.
9. click on 'more details' and confirm you see the 'host item entries'
link.
10. click 'send' to email the cart. confirm the email contains the host
item entry and the link sends you to the catalogue page for the record in the OPAC.
11. go to the list you added the record to. confirm you see the 'source'
link for the host item entry.
12. click 'send list' to email the list. confirm the email contains the
host item entry and the link sends you to the catalogue page for the
record in the OPAC.


CART
* Brief view: OK with the provided follow-up
* More view: OK
* E-mail: Exploded with the error mentioned by David and Christian:

Template process failed: file error - biblio_a_href: not found at /kohadevbox/koha/C4/Templates.pm line 127

The reason is, that the file is missing [% PROCESS 'html_helpers.inc' %].
But: The html links get removed by the HTMLToText Process and don't show in the
text based email. So I have decided to remove the links here.
Also: we don't want to link to the staff interface, so the email can still
be send to users. The staff email currently only includes a link to the record
in the OPAC. -> Follow-up provided


LIST
* Result list: OK
* E-mail: Same issue as for the cart mail, same fix. -> Follow-up provided


In the OPAC:

13. log into the OPAC. repeat steps 7 to 12 on the OPAC and confirm they
all pass as expected.

CART
* Brief view: OK with the provided follow-up
* More view: OK
* E-mail: OK

LIST
* Result list: OK
* E-mail: OK

14. Confirm host item info also shows correctly on the
OPAC and staff client search results, and the OPAC and staff client
detail pages (where XSLT is used)

OPAC: 
* Results: OK
* Detail: OK

Staff interface:
* Results: OK
* Detail: OK

15. Delete the 773$w and confirm host item info still shows correctly
but no longer links to biblio

773$w link missing: OK! Tested with a separate record in the steps above.

SIGNED OFF!
Comment 40 Martin Renvoize 2022-10-13 16:24:57 UTC
Added Marcel to CC list.. this patchset changes get_marc_host.. I know you're close to that sub.. any chance you could validate the change here.. I'm afraid my knowledge of that area has dropped away somewhat.
Comment 41 Marcel de Rooy 2022-10-14 06:06:01 UTC
(In reply to Martin Renvoize from comment #40)
> Added Marcel to CC list.. this patchset changes get_marc_host.. I know
> you're close to that sub.. any chance you could validate the change here..
> I'm afraid my knowledge of that area has dropped away somewhat.

Its on my list now ;)
Comment 42 Marcel de Rooy 2022-10-17 12:32:24 UTC
    if ( !$hostfld and $record->subfield('773','t') ) {
        # not linked using $w so just return plaintext
        my $unlinkedf = $record->field('773');
        my $host = join( ", ", $unlinkedf->subfield('a'), $unlinkedf->subfield('t'), $unlinkedf->subfield('g') );
        return wantarray ? ( $host, $unlinkedf->subfield('g') ) : $host;
    }

The user of this routine expects a Koha object returned first.
You return a concatenation of strings.
Would be better to not disturb existing returns but find a way to return new alternative data.

And change POD accordingly in the end.
Comment 43 Marcel de Rooy 2022-10-17 12:35:58 UTC
-                [% INCLUDE 'biblio-title.inc' link = 1 biblio=BIBLIO_RESULT.HOSTITEMENTRIES %] [% BIBLIO_RESULT.RELATEDPARTS | $raw %]
+                    [% INCLUDE 'biblio-title.inc' biblio=BIBLIO_RESULT.HOSTITEMENTRIES %] [% BIBLIO_RESULT.RELATEDPARTS | $raw %]

Please clarify why you remove link = 1. Should this have been link=1 without spaces??
Comment 44 Marcel de Rooy 2022-10-17 12:38:02 UTC
Please update release notes/commit message.
The routine get_marc_host exists already :)
Comment 45 Katrin Fischer 2022-10-17 18:53:01 UTC
(In reply to Marcel de Rooy from comment #43)
> -                [% INCLUDE 'biblio-title.inc' link = 1
> biblio=BIBLIO_RESULT.HOSTITEMENTRIES %] [% BIBLIO_RESULT.RELATEDPARTS | $raw
> %]
> +                    [% INCLUDE 'biblio-title.inc'
> biblio=BIBLIO_RESULT.HOSTITEMENTRIES %] [% BIBLIO_RESULT.RELATEDPARTS | $raw
> %]
> 
> Please clarify why you remove link = 1. Should this have been link=1 without
> spaces??

I did clarify :) See comment#39:

The html links get removed by the HTMLToText Process and don't show in the
text based email. So I have decided to remove the links here.
Also: we don't want to link to the staff interface, so the email can still
be send to users. The staff email currently only includes a link to the record
in the OPAC. -> Follow-up provided
Comment 46 Katrin Fischer 2022-10-17 18:58:16 UTC
(In reply to Marcel de Rooy from comment #44)
> Please update release notes/commit message.
> The routine get_marc_host exists already :)

Updated the release notes description.
Comment 47 Aleisha Amohia 2022-10-17 22:42:18 UTC
Created attachment 142036 [details] [review]
Bug 16522: Adding 773 to cart and list displays and emails

This enhancement adds information from a host item entry and a link if
applicable to the host record in the following places:
- staff client list
- staff client cart
- staff client send list email
- staff client send cart email
- staff client search results
- staff client detail page
- opac list
- opac cart
- opac send list email email
- opac send cart email
- opac search results
- opac detail page

To test:

1. apply patch, restart services
2. log into the staff client and enable the syspref EasyAnalyticalRecords
3. find a record with an item. take note of the barcode.
4. go to another record (biblio 2). click Edit -> Link to host record
5. enter the barcode in the input and submit.
6. click the MARC tab and confirm the host record has been linked under
MARC field 773.
7. add biblio 2 to your cart, and to a list.
8. go to your cart. confirm you see the 'host item entry' link.
9. click on 'more details' and confirm you see the 'host item entries'
link.
10. click 'send' to email the cart. confirm the email contains the host
item entry and the link sends you to the catalogue page for the record
in the OPAC.
11. go to the list you added the record to. confirm you see the 'source'
link for the host item entry.
12. click 'send list' to email the list. confirm the email contains the
host item entry and the link sends you to the catalogue page for the
record in the OPAC.
13. log into the OPAC. repeat steps 7 to 12 on the OPAC and confirm they
all pass as expected.
14. Confirm host item info also shows correctly on the
OPAC and staff client search results, and the OPAC and staff client
detail pages (where XSLT is used)
15. Delete the 773$w and confirm host item info still shows correctly
but no longer links to biblio
16. confirm tests pass t/db_dependent/Koha/Biblio/host_record.t

Sponsored-by: Bibliotheksservice-Zentrum Baden-Württemberg (BSZ)

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 48 Aleisha Amohia 2022-10-17 22:42:24 UTC
Created attachment 142037 [details] [review]
Bug 16522: (follow-up) MARC display templates and get_marc_host fixes

Also:
- Show related parts 773$g
- Normalise using 'Host item entry' as title
- Remove 'foreach' because non-xslt views only return first
- If no $w, use $atg, and related tests in
t/db_dependent/Koha/Biblio/host_record.t

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 49 Aleisha Amohia 2022-10-17 22:42:30 UTC
Created attachment 142038 [details] [review]
Bug 16522: (follow-up) Add missing TT filters

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 50 Aleisha Amohia 2022-10-17 22:42:36 UTC
Created attachment 142039 [details] [review]
Bug 16522: (follow-up) Rename "Host item entry" to "In"

We already use In: as label for 773 on the result lists and
detail pages and it's also recommended in the MARC documentation.
With this patch the label is the same everywhere.

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 51 Aleisha Amohia 2022-10-17 22:42:42 UTC
Created attachment 142040 [details] [review]
Bug 16522: (follow-up) Fix variable in OPAC cart brief display

Without this change records 773 entries with links in $w would
not display the title information, but just "No title".
With the variable fixed, now the host's title displays.

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 52 Aleisha Amohia 2022-10-17 22:42:47 UTC
Created attachment 142041 [details] [review]
Bug 16522: (follow-up) Remove HTML links from email

The emails sent for cart and list are plain text and any
<a> tag will be scrubbed by HtmlToText. So we can remove
those links.

This also solves an issue with the original patch set,
where the error below would appear on sending a cart or
list email from the staff interface:

Template process failed: file error - biblio_a_href: not found at /kohadevbox/koha/C4/Templates.pm line 127

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 53 Aleisha Amohia 2022-10-17 22:42:53 UTC
Created attachment 142042 [details] [review]
Bug 16522: (follow-up) If no 773$w, try to return host record

Use host biblionumber or host itemnumber to return a host record, or use
title and author to search for a host record, or return an undef record
and a string of host information when get_marc_host is called in list
context.
Comment 54 David Cook 2022-10-17 23:19:40 UTC
I think I had someone asking for this the other day. I'll come back...
Comment 55 David Cook 2022-10-20 02:19:52 UTC
(In reply to David Cook from comment #54)
> I think I had someone asking for this the other day. I'll come back...

Actually, I think this might be much much more complicated than what we were wanting to do.

We just want to show the 773 information rather than fetching data from a record linked via the 773...
Comment 56 Katrin Fischer 2022-10-20 07:50:05 UTC
Subfields 0 and 9 are only used with EasyAnalytics and might be used differently by other libraries as these are not standard MARC - I think we should wrap that part into a preference check. Otherwise it could cause issues if either of them is used locally with a numerical value.

For our use case 0 and 9 would never be set with any Koha IDs.
Comment 57 Katrin Fischer 2022-10-20 07:59:35 UTC
Thinking about the search fallback too: I don't think it will work reliably enough and we should remove it.

Most of the time 773 are used with articles from serials. And there are a lot of serials with very similar names and subseries in $b etc. Thinking about the serial "Pädagogik" or "Natur" for examples. Even an exact field search would turn up many results there and not only the one you were looking for. Also serials usually don't have authors, so the search is quite limited.

I really think using the IDs is ok'ish with the caveat of it checking EasyAnalytics, but trying to link otherwise won't work well enough and there are records where the host is just not in the catalog and then we just need to display 773 information directly from the record.
Comment 58 Marcel de Rooy 2022-10-28 07:39:09 UTC
(In reply to Katrin Fischer from comment #57)
> Thinking about the search fallback too: I don't think it will work reliably
> enough and we should remove it.
> 
> Most of the time 773 are used with articles from serials. And there are a
> lot of serials with very similar names and subseries in $b etc. Thinking
> about the serial "Pädagogik" or "Natur" for examples. Even an exact field
> search would turn up many results there and not only the one you were
> looking for. Also serials usually don't have authors, so the search is quite
> limited.
> 
> I really think using the IDs is ok'ish with the caveat of it checking
> EasyAnalytics, but trying to link otherwise won't work well enough and there
> are records where the host is just not in the catalog and then we just need
> to display 773 information directly from the record.

Yes, I tend to agree.
Looked at the follow-up too. Looks better, more consistent now. Thanks.
Comment 59 Aleisha Amohia 2022-10-31 22:42:20 UTC
Created attachment 142843 [details] [review]
Bug 16522: (follow-up) If no 773$w, try to return host record

Use host biblionumber or host itemnumber to return a host record if
EasyAnalyticalRecords is enabled, or return an undef record and a string
of host information when get_marc_host is called in list context.

Confirm tests pass:
- t/db_dependent/Koha/Biblio/host_record.t
Comment 60 Heather 2022-12-05 18:00:44 UTC
I tried signing off on this bug and ran into trouble with this step:
"10. click 'send' to email the cart. confirm the email contains the host
item entry and the link sends you to the catalogue page for the record
in the OPAC."

This is the email from the email logs (with some spaces deleted to save space):
Date: Mon, 5 Dec 2022 17:47:21 +0000
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
   Hi,
   Here is your cart, sent from our online catalog.
   Please note that the attached file is a MARC bibliographic records
   file which can be imported into personal bibliographic software like
   EndNote, Reference Manager or ProCite.
   ---------------------------------------------------------------------
   testing emailing
   ---------------------------------------------------------------------
     1.  Four metaphysical poets : an anthology of poetry by Donne,
       Herbert, Marvell, and Vaughan /
       Author(s): Donne, John, --1572-1631. ; Wilmott, Richard.
       Copyright year: 1985
       Notes : Includes index.
       In: Li Po and Tu Fu
       In online catalog:
       http://h2sandboxes.biblibre.eu:8080/cgi-bin/koha/opac-detail.pl?bibl=
ionumber=3D16
       Items:
         *  Centerville GEN 39999000000719
         *  Fairview GEN 39999000000696
       -----------------------------------------------------------------
---End quoted email

And the record it should be linking to is this one:
https://staff-h2.sandboxes.biblibre.eu/cgi-bin/koha/catalogue/detail.pl?biblionumber=16

But the link in the email has an extraneous equals sign: bibl=
ionumber

But if you take that out and make the link this one:
http://h2sandboxes.biblibre.eu:8080/cgi-bin/koha/opac-detail.pl?bibl
ionumber=3D16
It's still incorrect, a broken link.

If you put in record number 3D16 into a correct record link, i.e.:
https://staff-h2.sandboxes.biblibre.eu/cgi-bin/koha/catalogue/detail.pl?biblionumber=3D16

You get the wrong record ("Introduction to Attic Greek").  It should be this link, to "Four metaphysical poets:"
https://staff-h2.sandboxes.biblibre.eu/cgi-bin/koha/catalogue/detail.pl?biblionumber=16

So there's an extraneous "3D" before the record number "16."

Are the extraneous "=" and "3D" being inserted into the log transcript of the email, or are they really in a sent email?

Cheerio!
--h2
Comment 61 Victor Grousset/tuxayo 2022-12-05 23:19:17 UTC
> Are the extraneous "=" and "3D" being inserted into the log transcript of the email, or are they really in a sent email?

It's something about having to replace some characters before sending them via email: https://en.wikipedia.org/wiki/Quoted-printable#Quoted-printable_encoding

It's under the hood so users don't see this. But on sandboxes, koha mail log shows raw data.

So = becomes =3D

So this part of the link is valid! It's biblionumber=16 as expected.


The bibl= is a way to represent going to the next line. So it's biblionumber, as expected.

The beginning of the link looks wrong because h2sandboxes.biblibre.eu:8080 isn't what you have in the browser. But it looks like to be the internal address of the OPAC. So just replace with the OPAC address and it should work.

So if I understand correctly the link is valid! So you can retry and use the bellow link (or do adapt it yourself from the email logs) and it should work :)

http://opac-h2sandboxes.biblibre.eu:8080/cgi-bin/koha/opac-detail.pl?biblionumber=16
Comment 62 Victor Grousset/tuxayo 2022-12-05 23:28:48 UTC
Here is a decoder:

https://www.motobit.com/util/quoted-printable-decoder.asp

Paste the email and click decode. And then the *first/top* text area contains the result:


       In online catalog:
       http://h2sandboxes.biblibre.eu:8080/cgi-bin/koha/opac-detail.pl?biblionumber=16
       Items:
         *  Centerville GEN 39999000000719
         *  Fairview GEN 39999000000696


And the link is right! (except for the address because that's the previous problem)

errata: on the previous comment:

> http://opac-h2sandboxes.biblibre.eu:8080/cgi-bin/koha/opac-detail.pl?biblionumber=16

It's http://opac-h2sandboxes.biblibre.eu/cgi-bin/koha/opac-detail.pl?biblionumber=16
Comment 63 Heather 2022-12-06 15:36:23 UTC
Thank you so much for all this, Victor!  I will try signing off on this bug again today.

Would it be good to add this information about sandbox email to the wiki?  Maybe here:
https://wiki.koha-community.org/wiki/Sandboxes#Testing_sending_emails
(For librarians and sign-off newbies like me?)

More later!!
--h2
Comment 64 Heather 2022-12-06 17:49:07 UTC
Created attachment 144455 [details]
Search results screenshot showing "In.." appearing correctly in staff client

I got as far as step 14 in the test plan, and am uploading this screenshot to show that the "In..." is appearing correctly in the staff client, so this is what I was looking for in the OPAC.  (I'll upload an OPAC screenshot next.)
Comment 65 Heather 2022-12-06 17:51:07 UTC
Created attachment 144456 [details]
Search results in OPAC without "In..." appearing

In step 14 in the test plan, I expected to see "In..." appearing in the search results for this record here in the OPAC, as I did in the staff client, but I don't see it there.  The test plan implies that I should?
Comment 66 Victor Grousset/tuxayo 2022-12-28 04:25:06 UTC
(In reply to Heather from comment #63)
> Would it be good to add this information about sandbox email to the wiki? 
> Maybe here:
> https://wiki.koha-community.org/wiki/Sandboxes#Testing_sending_emails
> (For librarians and sign-off newbies like me?)

Good idea! I missed there was already a section about that.

Here is a completed version: https://wiki.koha-community.org/wiki/Sandboxes#Testing_sending_emails

Can you proofread to confirm if it's good enough for beginners? And email me if there are things unclear or ideas to improve phrasing.
Comment 67 Victor Grousset/tuxayo 2022-12-28 04:27:46 UTC
(In reply to Heather from comment #65)
> In step 14 in the test plan, I expected to see "In..." appearing in the
> search results for this record here in the OPAC, as I did in the staff
> client, but I don't see it there.  The test plan implies that I should?

Let's switch the ticket to failed QA, as the test plan need clarification. (it seems also to me the test plan says you should see the same thing in the OPAC)
And to remove it from the list of tickets ready to be tested.
Comment 68 Katrin Fischer 2023-01-04 14:11:03 UTC
(In reply to Heather from comment #65)
> Created attachment 144456 [details]
> Search results in OPAC without "In..." appearing
> 
> In step 14 in the test plan, I expected to see "In..." appearing in the
> search results for this record here in the OPAC, as I did in the staff
> client, but I don't see it there.  The test plan implies that I should?

Hi Heather, I see the In: in your screenshot right below the title. Can you confirm maybe?
Comment 69 Heather 2023-01-04 15:29:19 UTC
Ah, Katrin--yes!  Thank you!  It *is* there right below the title and authors, but shouldn't it be near the "Online access..." at the bottom of the display, like in the staff client?  I don't think users will look for it or notice it if it's near the title/authors--they are going to be looking near "Online access..." and "Availability..." as I did.  I confess that I completely missed seeing it tucked under the authors, and I was looking for it.
Comment 70 Heather 2023-01-04 16:41:09 UTC
Hi, Victor!  This is great--very helpful for a newbie!  Thank you!!  --h2
Comment 71 Heather 2023-01-04 16:58:08 UTC
Hi, Katrin--

I went through the test plan again:

--I still think that the "In:..." link should be moved in the OPAC, down to the "Online access..." and "Availability..." area, as it is in the staff client.

--I did this step:
"15. Delete the 773$w and confirm host item info still shows correctly
but no longer links to biblio"
And the host item info does still show correctly, but the record does still link to the host biblio.  It can be seen in my sandbox here:
https://staff-bug16522.sandbox.bywatersolutions.com/cgi-bin/koha/catalogue/detail.pl?biblionumber=16&searchid=

Could this be because there is a subfield 0 (zero) in the 773 field ("Host biblionumber") which is not actually a valid MARC21 subfield?
(c.f. https://www.loc.gov/marc/bibliographic/bd773.html)

--Also, there is a subfield 9 in the 773 to "Host itemnumber," which is nonsense (according to this cataloger)--analytic relationships should only exist at the title level/biblionumber level.  If you have variation in contents at the item level, the items should not be on the same biblio (says the cataloger).

These are minor quibbles, but I think it would be best for them to be fixed before going into master:
--Move the "In:..." in the OPAC near the "Online access..." and/or "Availability:..." so users are more likely to notice it.
--Don't use an invalid 773 subfield 0 (zero) with a biblionumber in the 773, but actually use the valid $w field to contain the biblionumber
--Don't retain/have an invalid itemnumber in the 773 field, since it's unnecessary and nonsense for this type of relationship, and really use the 773$w.

If these quibbles are too minor, no problem--of course, I rely on y'all's expertise for such decisions!  It's a great development!!
--h2
Comment 72 Katrin Fischer 2023-01-04 18:23:09 UTC

> These are minor quibbles, but I think it would be best for them to be fixed
> before going into master:
> --Move the "In:..." in the OPAC near the "Online access..." and/or
> "Availability:..." so users are more likely to notice it.

This could be done, although I the current placement also makes sense to me. Having the article and journal information close together. But moving it would be more consistent with other pages, I understand that argument.

> --Don't use an invalid 773 subfield 0 (zero) with a biblionumber in the 773,
> but actually use the valid $w field to contain the biblionumber
> --Don't retain/have an invalid itemnumber in the 773 field, since it's
> unnecessary and nonsense for this type of relationship, and really use the
> 773$w.

This is out of scope here. I'll explain:

These subfields are added because you used EasyAnalytics:
_0163
_9354

When you remove to $w there is a fallback to the biblionumber in these subfields. But we didn't add that - it's always been in the XSLTs. We would break things for people using EasyAnalytics changing this behaviour. But I think we can assume that libraries using $w won't have EasyAnalytics turned on, they are known to be incompatible.

Try cataloguing things manually with UseControlNumber activated and EasyAnalytics turned off, all should work as you expect it then with $w used. Make sure your host has a 001. Then from the detail page use New > New child record and it should create a nice standard 773 for you.

I wrote an adapted test plan that should cover that if you ignore the first paragraph:
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16522#c39

> If these quibbles are too minor, no problem--of course, I rely on y'all's
> expertise for such decisions!  It's a great development!!
> --h2

Thanks for testing this - very happy to see it get attention!
Comment 73 Heather 2023-01-04 19:58:04 UTC
Thank you SO much for all of this, Katrin!  I'm going to go ahead and sign off because everything you say makes a lot of sense.

Also, I followed the adapted test plan here:
> https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16522#c39

I imported an analytic record and its parent/host record; the child was linked to the parent (with the generated search using the record number in the $w of the child record to the 001 of the parent record).  I deleted the $w from the 773 and the child remained linked to the parent because Koha then used the data in the 773 $t of the child record which retrieved the data in the 245 $a of the parent record.  It does this even with the syspref "UseControlNumber" set to "Use" and "EasyAnalyticalRecords" set to "Don't Show."

Maybe it shouldn't do this, but I like it--I like the fact that there is a fallback behavior when there is no Control Number (i.e. no $w) to use for searching.

(And I will keep arguing that the "In:..." in the OPAC should be moved down to be consistent with other displays, but more folks in the community like it up near the title and author(s), then I'll probably start arguing to move it up there in the staff client!)

I think this is a GREAT development, not at all minor, and will be of service to many libraries in getting to their users articles, chapters, papers, songs...all those great things that analytic records are used for.
Comment 74 ByWater Sandboxes 2023-01-04 19:59:22 UTC
Created attachment 145047 [details] [review]
Bug 16522: (follow-up) If no 773$w, try to return host record

Use host biblionumber or host itemnumber to return a host record if
EasyAnalyticalRecords is enabled, or return an undef record and a string
of host information when get_marc_host is called in list context.

Confirm tests pass:
- t/db_dependent/Koha/Biblio/host_record.t

Signed-off-by: Heather Hernandez <heather_hernandez@nps.gov>
Comment 75 Victor Grousset/tuxayo 2023-01-13 23:42:36 UTC
Thanks Heather for testing :)
Thanks Katrin for spotting the "In...", I missed it also! And the for clarifications on the other points.
Comment 76 Katrin Fischer 2023-01-20 15:19:13 UTC
First of all - thanks Heather! Your 'stamp of approval' means a lot to us!

(In reply to Heather from comment #73)
> I deleted the
> $w from the 773 and the child remained linked to the parent because Koha
> then used the data in the 773 $t of the child record which retrieved the
> data in the 245 $a of the parent record.  It does this even with the syspref
> "UseControlNumber" set to "Use" and "EasyAnalyticalRecords" set to "Don't
> Show."
> 
> Maybe it shouldn't do this, but I like it--I like the fact that there is a
> fallback behavior when there is no Control Number (i.e. no $w) to use for
> searching.

We actually asked for it, because we have both cases getting imported from the union catalog, linked and unlinked. It's not perfect, but it's a nice fallback.

> (And I will keep arguing that the "In:..." in the OPAC should be moved down
> to be consistent with other displays, but more folks in the community like
> it up near the title and author(s), then I'll probably start arguing to move
> it up there in the staff client!)

I'll take care of that in a follow-up now.

> I think this is a GREAT development, not at all minor, and will be of
> service to many libraries in getting to their users articles, chapters,
> papers, songs...all those great things that analytic records are used for.

+100 :)
Comment 77 Katrin Fischer 2023-01-20 15:24:02 UTC
Looking at the diff of this patch set in full made me realize that we didn't change the posiition of the 773 display in results, neither did we add it. It only displayed as Source: before this patch. I'll move it anyway and leave it up to next instance to use the patch or move to separate bug.
Comment 78 Katrin Fischer 2023-01-20 15:37:45 UTC
Created attachment 145521 [details] [review]
Bug 16522: Adding 773 to cart and list displays and emails

This enhancement adds information from a host item entry and a link if
applicable to the host record in the following places:
- staff client list
- staff client cart
- staff client send list email
- staff client send cart email
- staff client search results
- staff client detail page
- opac list
- opac cart
- opac send list email email
- opac send cart email
- opac search results
- opac detail page

To test:

1. apply patch, restart services
2. log into the staff client and enable the syspref EasyAnalyticalRecords
3. find a record with an item. take note of the barcode.
4. go to another record (biblio 2). click Edit -> Link to host record
5. enter the barcode in the input and submit.
6. click the MARC tab and confirm the host record has been linked under
MARC field 773.
7. add biblio 2 to your cart, and to a list.
8. go to your cart. confirm you see the 'host item entry' link.
9. click on 'more details' and confirm you see the 'host item entries'
link.
10. click 'send' to email the cart. confirm the email contains the host
item entry and the link sends you to the catalogue page for the record
in the OPAC.
11. go to the list you added the record to. confirm you see the 'source'
link for the host item entry.
12. click 'send list' to email the list. confirm the email contains the
host item entry and the link sends you to the catalogue page for the
record in the OPAC.
13. log into the OPAC. repeat steps 7 to 12 on the OPAC and confirm they
all pass as expected.
14. Confirm host item info also shows correctly on the
OPAC and staff client search results, and the OPAC and staff client
detail pages (where XSLT is used)
15. Delete the 773$w and confirm host item info still shows correctly
but no longer links to biblio
16. confirm tests pass t/db_dependent/Koha/Biblio/host_record.t

Sponsored-by: Bibliotheksservice-Zentrum Baden-Württemberg (BSZ)

Signed-off-by: Heather Hernandez <heather_hernandez@nps.gov>

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 79 Katrin Fischer 2023-01-20 15:37:51 UTC
Created attachment 145522 [details] [review]
Bug 16522: (follow-up) MARC display templates and get_marc_host fixes

Also:
- Show related parts 773$g
- Normalise using 'Host item entry' as title
- Remove 'foreach' because non-xslt views only return first
- If no $w, use $atg, and related tests in
t/db_dependent/Koha/Biblio/host_record.t

Signed-off-by: Heather Hernandez <heather_hernandez@nps.gov>

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 80 Katrin Fischer 2023-01-20 15:37:56 UTC
Created attachment 145523 [details] [review]
Bug 16522: (follow-up) Add missing TT filters

Signed-off-by: Heather Hernandez <heather_hernandez@nps.gov>

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 81 Katrin Fischer 2023-01-20 15:38:02 UTC
Created attachment 145524 [details] [review]
Bug 16522: (follow-up) Rename "Host item entry" to "In"

We already use In: as label for 773 on the result lists and
detail pages and it's also recommended in the MARC documentation.
With this patch the label is the same everywhere.

Signed-off-by: Heather Hernandez <heather_hernandez@nps.gov>

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 82 Katrin Fischer 2023-01-20 15:38:08 UTC
Created attachment 145525 [details] [review]
Bug 16522: (follow-up) Fix variable in OPAC cart brief display

Without this change records 773 entries with links in $w would
not display the title information, but just "No title".
With the variable fixed, now the host's title displays.

Signed-off-by: Heather Hernandez <heather_hernandez@nps.gov>

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 83 Katrin Fischer 2023-01-20 15:38:14 UTC
Created attachment 145526 [details] [review]
Bug 16522: (follow-up) Remove HTML links from email

The emails sent for cart and list are plain text and any
<a> tag will be scrubbed by HtmlToText. So we can remove
those links.

This also solves an issue with the original patch set,
where the error below would appear on sending a cart or
list email from the staff interface:

Template process failed: file error - biblio_a_href: not found at /kohadevbox/koha/C4/Templates.pm line 127

Signed-off-by: Heather Hernandez <heather_hernandez@nps.gov>

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 84 Katrin Fischer 2023-01-20 15:38:20 UTC
Created attachment 145527 [details] [review]
Bug 16522: (follow-up) If no 773$w, try to return host record

Use host biblionumber or host itemnumber to return a host record if
EasyAnalyticalRecords is enabled, or return an undef record and a string
of host information when get_marc_host is called in list context.

Confirm tests pass:
- t/db_dependent/Koha/Biblio/host_record.t

Signed-off-by: Heather Hernandez <heather_hernandez@nps.gov>

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 85 Katrin Fischer 2023-01-20 15:38:26 UTC
Created attachment 145528 [details] [review]
Bug 16522: Move 773 entries in result lists before 856 entries

This moves the display of 773 In: displays to right before the
856 Online resource: as suggested by Heather in order to make it
more consistent with the display in the detail pages.

Everything should be unchanged, but the position of the
In: line :)

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 86 Heather 2023-01-20 16:11:30 UTC
I'm happy-dancing about all the latest on this bug--thank you thank you!!  #HappyLibrarian #KohaDevelopersRock #CommunityPower #KatrinHasSuperpowers
Comment 87 Tomás Cohen Arazi 2023-01-30 15:15:25 UTC
Pushed to master for 23.05.

Nice work everyone, thanks!
Comment 88 Jacob O'Mara 2023-01-31 17:19:15 UTC
Nice work, thanks everyone!

Pushed to 22.11.x for the next release.
Comment 89 Lucas Gass 2023-02-01 19:19:08 UTC
This patchset doesn't apply cleanly to 22.05.x, no backport.
Comment 90 Katrin Fischer 2023-03-07 16:18:47 UTC
15. Delete the 773$w and confirm host item info still shows correctly
but no longer links to biblio

This no longer appears to work in my testing, but I am not sure what happened. The information for unlinked 773 (no $w) is missing from cart display in staff and OPAC.
Comment 91 Katrin Fischer 2023-03-07 16:47:39 UTC
(In reply to Katrin Fischer from comment #90)
> 15. Delete the 773$w and confirm host item info still shows correctly
> but no longer links to biblio
> 
> This no longer appears to work in my testing, but I am not sure what
> happened. The information for unlinked 773 (no $w) is missing from cart
> display in staff and OPAC.

Will be fixed on:

Bug 33160 - Make sure 773 (host item entry) displays in the cart when not linked by $w
Comment 92 Katrin Fischer 2023-05-14 12:10:05 UTC
*** Bug 17867 has been marked as a duplicate of this bug. ***