]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/XXXX.data.bre_format_title_fix.sql
LP#1721575: Batch Actions In the Public Catalog
[working/Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / XXXX.data.bre_format_title_fix.sql
1 BEGIN;
2
3 UPDATE action_trigger.event_definition
4 SET template =
5 $$
6 [%- USE date -%]
7 [%- SET user = target.0.owner -%]
8 To: [%- params.recipient_email || user.email %]
9 From: [%- params.sender_email || default_sender %]
10 Date: [%- date.format(date.now, '%a, %d %b %Y %T -0000', gmt => 1) %]
11 Subject: Bibliographic Records
12 Auto-Submitted: auto-generated
13
14 [% FOR cbreb IN target %]
15 [% FOR item IN cbreb.items;
16     bre_id = item.target_biblio_record_entry;
17
18     bibxml = helpers.unapi_bre(bre_id, {flesh => '{mra}'});
19     title = '';
20     FOR part IN bibxml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b"]');
21         title = title _ part.textContent;
22     END;
23
24     author = bibxml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent;
25     item_type = bibxml.findnodes('//*[local-name()="attributes"]/*[local-name()="field"][@name="item_type"]').getAttribute('coded-value');
26     publisher = bibxml.findnodes('//*[@tag="260"]/*[@code="b"]').textContent;
27     pubdate = bibxml.findnodes('//*[@tag="260"]/*[@code="c"]').textContent;
28     isbn = bibxml.findnodes('//*[@tag="020"]/*[@code="a"]').textContent;
29     issn = bibxml.findnodes('//*[@tag="022"]/*[@code="a"]').textContent;
30     upc = bibxml.findnodes('//*[@tag="024"]/*[@code="a"]').textContent;
31 %]
32
33 [% loop.count %]/[% loop.size %].  Bib ID# [% bre_id %] 
34 [% IF isbn %]ISBN: [% isbn _ "\n" %][% END -%]
35 [% IF issn %]ISSN: [% issn _ "\n" %][% END -%]
36 [% IF upc  %]UPC:  [% upc _ "\n" %] [% END -%]
37 Title: [% title %]
38 Author: [% author %]
39 Publication Info: [% publisher %] [% pubdate %]
40 Item Type: [% item_type %]
41
42 [% END %]
43 [% END %]
44 $$
45 WHERE hook = 'biblio.format.record_entry.email'
46 -- from previous stock definition
47 AND MD5(template) = 'ee4e6c1b3049086c570c7a77413d46c1';
48
49 UPDATE action_trigger.event_definition
50 SET template =
51 $$
52 <div>
53     <style> li { padding: 8px; margin 5px; }</style>
54     <ol>
55     [% FOR cbreb IN target %]
56     [% FOR item IN cbreb.items;
57         bre_id = item.target_biblio_record_entry;
58
59         bibxml = helpers.unapi_bre(bre_id, {flesh => '{mra}'});
60         title = '';
61         FOR part IN bibxml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b"]');
62             title = title _ part.textContent;
63         END;
64
65         author = bibxml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent;
66         item_type = bibxml.findnodes('//*[local-name()="attributes"]/*[local-name()="field"][@name="item_type"]').getAttribute('coded-value');
67         publisher = bibxml.findnodes('//*[@tag="260"]/*[@code="b"]').textContent;
68         pubdate = bibxml.findnodes('//*[@tag="260"]/*[@code="c"]').textContent;
69         isbn = bibxml.findnodes('//*[@tag="020"]/*[@code="a"]').textContent;
70         %]
71
72         <li>
73             Bib ID# [% bre_id %] ISBN: [% isbn %]<br />
74             Title: [% title %]<br />
75             Author: [% author %]<br />
76             Publication Info: [% publisher %] [% pubdate %]<br/>
77             Item Type: [% item_type %]
78         </li>
79     [% END %]
80     [% END %]
81     </ol>
82 </div>
83 $$
84 WHERE hook = 'biblio.format.record_entry.print'
85 -- from previous stock definition
86 AND MD5(template) = '9ada7ea8417cb23f89d0dc8f15ec68d0';