From 075d3400a1923986d08519819e4db87b8c807436 Mon Sep 17 00:00:00 2001 From: Art Rhyno Date: Wed, 26 Sep 2012 22:34:48 -0400 Subject: [PATCH] Add call number and location info to TPAC e-mail and print option I haven't figured out how to get the hostname properly, I am guessing it needs to be passed as a parameter somehow. I also need to test URIs but this is a start. --- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 170 ++++++++++++++++++++++++++- 1 file changed, 166 insertions(+), 4 deletions(-) diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index a8ddf6a09f..e4266a3eb8 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -8791,7 +8791,8 @@ INSERT INTO action_trigger.event_definition ( NULL, '00:00:00', $$ -[%- SET user = target.0.owner -%] +[%- SET user = target.0.owner; + SET print_limit = 500; #this is to limit the no. of copies, set to 0 for unlimited %] To: [%- params.recipient_email || user.email %] From: [%- params.sender_email || default_sender %] Subject: Bibliographic Records @@ -8801,6 +8802,8 @@ Subject: Bibliographic Records bre_id = item.target_biblio_record_entry; bibxml = helpers.unapi_bre(bre_id, {flesh => '{mra}'}); + holdingsxml = helpers.unapi_bre(bre_id, {flesh => '{holdings_xml,acp}'}); + FOR part IN bibxml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b"]'); title = title _ part.textContent; END; @@ -8812,9 +8815,65 @@ Subject: Bibliographic Records isbn = bibxml.findnodes('//*[@tag="020"]/*[@code="a"]').textContent; issn = bibxml.findnodes('//*[@tag="022"]/*[@code="a"]').textContent; upc = bibxml.findnodes('//*[@tag="024"]/*[@code="a"]').textContent; + + uris = []; + holdings = []; + part_label=''; + FOR volume IN holdingsxml.findnodes('//*[local-name()="volumes"]/*[local-name()="volume"]'); + # Check volume visibility - could push this into XPath + vol.label = volume.getAttribute('label'); + + # Prepend prefix, if any + prefix = volume.findnodes('./*[local-name()="call_number_prefix"][@ident!="-1"]'); + IF prefix.getAttribute('label') != ''; + vol.label = prefix.getAttribute('label') _ " " _ vol.label; + END; + + # Append prefix, if any + suffix = volume.findnodes('./*[local-name()="call_number_suffix"][@ident!="-1"]'); + IF suffix.getAttribute('label') != ''; + vol.label = vol.label _ " " _ suffix.getAttribute('label'); + END; + IF vol.label == '##URI##'; + FOR uri IN volume.findnodes('./*[local-name()="uris"]/*[local-name()="uri"]'); + res = {}; + res.href = uri.getAttribute('href'); + res.link = uri.getAttribute('label'); + res.note = uri.getAttribute('use_restriction'); + uris.push(res); + END; + NEXT; + ELSE; + copies = volume.findnodes('./*[local-name()="copies"]/*[local-name()="copy"]'); + FOR copy IN copies; + parts = copy.findnodes('./*[local-name()="monograph_parts"]/*[local-name()="monograph_part"]'); + FOREACH part IN parts; + part_label = part.getAttribute('label'); + LAST IF part_label != ''; + END; + + NEXT IF (copy.getAttribute('deleted') == 'true' OR copy.getAttribute('opac_visible') == 'false'); + loc = copy.findnodes('./*[local-name()="location"]'); + circlib = copy.findnodes('./*[local-name()="circlib"]'); + status = copy.findnodes('./*[local-name()="status"]'); + holding = { + label => vol.label, + part_label => part_label, + library => circlib.textContent, + location => loc.textContent, + status => status.textContent + barcode => copy.getAttribute('barcode') + }; + holdings.push(holding); + part_label = ''; + END; + END; + END; + %] -[% loop.count %]/[% loop.size %]. Bib ID# [% bre_id %] +[% loop.count %]/[% loop.size %]. Bib ID# [% bre_id %] +URL: [% params.hostname %]/eg/opac/record/[% bre_id %] [% IF isbn %]ISBN: [% isbn _ "\n" %][% END -%] [% IF issn %]ISSN: [% issn _ "\n" %][% END -%] [% IF upc %]UPC: [% upc _ "\n" %] [% END -%] @@ -8823,6 +8882,22 @@ Author: [% author %] Publication Info: [% publisher %] [% pubdate %] Item Type: [% item_type %] +[% IF holdings.size > 0 %] + [% IF holdings.size > print_limit AND print_limit > 0 %] + Showing [% print_limit %] of [% holdings.size %], use URL for full list of copies... + [% END %] + [% FOR holding IN holdings %] + Location: [% holding.library %] - [% holding.location _ "\n" %] + Call Number: [% holding.label _ "\n" %][% IF holding.part_label %][% holding.part_label _ "\n" %][% END -%] + Status: [% holding.status _ "\n" %] + [% END %] +[% END %] +[% IF uris.size > 0 %] + [% FOR uri IN uris %] + URL: [% uri.href _ "\n" %] + [% END %] +[% END %] + [% END %] [% END %] $$ @@ -8844,11 +8919,13 @@ $$
    + [% SET print_limit = 500; #this is to limit the no. of copies, set to 0 for unlimited %] [% FOR cbreb IN target %] [% FOR item IN cbreb.items; bre_id = item.target_biblio_record_entry; bibxml = helpers.unapi_bre(bre_id, {flesh => '{mra}'}); + holdingsxml = helpers.unapi_bre(bre_id, {flesh => '{holdings_xml,acp}'}); FOR part IN bibxml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b"]'); title = title _ part.textContent; END; @@ -8858,14 +8935,99 @@ $$ publisher = bibxml.findnodes('//*[@tag="260"]/*[@code="b"]').textContent; pubdate = bibxml.findnodes('//*[@tag="260"]/*[@code="c"]').textContent; isbn = bibxml.findnodes('//*[@tag="020"]/*[@code="a"]').textContent; + issn = bibxml.findnodes('//*[@tag="022"]/*[@code="a"]').textContent; + + uris = []; + holdings = []; + part_label=''; + FOR volume IN holdingsxml.findnodes('//*[local-name()="volumes"]/*[local-name()="volume"]'); + vol.label = volume.getAttribute('label'); + + prefix = volume.findnodes('./*[local-name()="call_number_prefix"][@ident!="-1"]'); + IF prefix.getAttribute('label') != ''; + vol.label = prefix.getAttribute('label') _ " " _ vol.label; + END; + + # Append prefix, if any + suffix = volume.findnodes('./*[local-name()="call_number_suffix"][@ident!="-1"]'); + IF suffix.getAttribute('label') != ''; + vol.label = vol.label _ " " _ suffix.getAttribute('label'); + END; + IF vol.label == '##URI##'; + FOR uri IN volume.findnodes('./*[local-name()="uris"]/*[local-name()="uri"]'); + res = {}; + res.href = uri.getAttribute('href'); + res.link = uri.getAttribute('label'); + res.note = uri.getAttribute('use_restriction'); + uris.push(res); + END; + NEXT; + ELSE; + copies = volume.findnodes('./*[local-name()="copies"]/*[local-name()="copy"]'); + FOR copy IN copies; + parts = copy.findnodes('./*[local-name()="monograph_parts"]/*[local-name()="monograph_part"]'); + FOREACH part IN parts; + part_label = part.getAttribute('label'); + LAST IF part_label != ''; + END; + + NEXT IF (copy.getAttribute('deleted') == 'true' OR copy.getAttribute('opac_visible') == 'false'); + loc = copy.findnodes('./*[local-name()="location"]'); + circlib = copy.findnodes('./*[local-name()="circlib"]'); + status = copy.findnodes('./*[local-name()="status"]'); + holding = { + label => vol.label, + part_label => part_label, + library => circlib.textContent, + location => loc.textContent, + status => status.textContent + barcode => copy.getAttribute('barcode') + }; + holdings.push(holding); + part_label = ''; + END; + END; + END; + %]
  1. - Bib ID# [% bre_id %] ISBN: [% isbn %]
    + Bib ID# [% bre_id %] [% IF isbn %]ISBN: [% isbn | html %]
    [% END -%] [% IF issn %]ISSN: [% issn | html %]
    [% END -%]
    Title: [% title %]
    Author: [% author %]
    Publication Info: [% publisher %] [% pubdate %]
    - Item Type: [% item_type %] + Item Type: [% item_type %]
    + + [% IF upc %]UPC: [% upc | html %]
    [% END -%] + [% IF holdings.size > 0 %] + [% IF holdings.size > print_limit AND print_limit > 0 %] + Showing [% print_limit %] of [% holdings.size %]...
    + [% END %] + +
      + [% FOR holding IN holdings %] + [% IF loop.count() > print_limit; LAST; END %] +
    • Location: [% holding.library | html %] - [% holding.location | html %]
      + Barcode: [% holding.barcode | html %]
      + Call Number: [% holding.label | html %][% holding.part_label | html %]
      + Status: [% holding.status | html %]
    • + [% END %] +
    + [% END %] + [% IF uris.size > 0 %] +
      + [% FOR uri IN uris %] +
    • URL: [% uri.href | html %]
      + [% IF uri.link.length > 0 %] + Label: [% uri.href | html %]
      + [% END %] + [% IF uri.note.length > 0 %] + Note: [% uri.note | html %]
      + [% END %] +
    • + [% END %] +
    + [% END %]
  2. [% END %] [% END %] -- 2.11.0