]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/XXXX.data.record_print_format_update.sql
Tpac: record detail print and email
[working/Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / XXXX.data.record_print_format_update.sql
1
2
3 UPDATE action_trigger.event_definition SET template = $$
4 <div>
5     <style> li { padding: 8px; margin 5px; }</style>
6     <ol>
7     [% FOR cbreb IN target %]
8     [% FOR item IN cbreb.items;
9         bre_id = item.target_biblio_record_entry;
10
11         bibxml = helpers.unapi_bre(bre_id, {flesh => '{mra}'});
12         FOR part IN bibxml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b"]');
13             title = title _ part.textContent;
14         END;
15
16         author = bibxml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent;
17         item_type = bibxml.findnodes('//*[local-name()="attributes"]/*[local-name()="field"][@name="item_type"]').getAttribute('coded-value');
18         publisher = bibxml.findnodes('//*[@tag="260"]/*[@code="b"]').textContent;
19         pubdate = bibxml.findnodes('//*[@tag="260"]/*[@code="c"]').textContent;
20         isbn = bibxml.findnodes('//*[@tag="020"]/*[@code="a"]').textContent;
21         issn = bibxml.findnodes('//*[@tag="022"]/*[@code="a"]').textContent;
22         upc = bibxml.findnodes('//*[@tag="024"]/*[@code="a"]').textContent;
23         %]
24
25         <li>
26             Bib ID# [% bre_id %]<br/>
27             [% IF isbn %]ISBN: [% isbn %]<br/>[% END %]
28             [% IF issn %]ISSN: [% issn %]<br/>[% END %]
29             [% IF upc  %]UPC:  [% upc %]<br/>[% END %]
30             Title: [% title %]<br />
31             Author: [% author %]<br />
32             Publication Info: [% publisher %] [% pubdate %]<br/>
33             Item Type: [% item_type %]
34         </li>
35     [% END %]
36     [% END %]
37     </ol>
38 </div>
39 $$ 
40 WHERE hook = 'biblio.format.record_entry.print' AND id < 100; -- sample data
41
42
43 UPDATE action_trigger.event_definition SET delay = '00:00:00', template = $$
44 [%- SET user = target.0.owner -%]
45 To: [%- params.recipient_email || user.email %]
46 From: [%- params.sender_email || default_sender %]
47 Subject: Bibliographic Records
48
49 [% FOR cbreb IN target %]
50 [% FOR item IN cbreb.items;
51     bre_id = item.target_biblio_record_entry;
52
53     bibxml = helpers.unapi_bre(bre_id, {flesh => '{mra}'});
54     FOR part IN bibxml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b"]');
55         title = title _ part.textContent;
56     END;
57
58     author = bibxml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent;
59     item_type = bibxml.findnodes('//*[local-name()="attributes"]/*[local-name()="field"][@name="item_type"]').getAttribute('coded-value');
60     publisher = bibxml.findnodes('//*[@tag="260"]/*[@code="b"]').textContent;
61     pubdate = bibxml.findnodes('//*[@tag="260"]/*[@code="c"]').textContent;
62     isbn = bibxml.findnodes('//*[@tag="020"]/*[@code="a"]').textContent;
63     issn = bibxml.findnodes('//*[@tag="022"]/*[@code="a"]').textContent;
64     upc = bibxml.findnodes('//*[@tag="024"]/*[@code="a"]').textContent;
65 %]
66
67 [% loop.count %]/[% loop.size %].  Bib ID# [% bre_id %] 
68 [% IF isbn %]ISBN: [% isbn _ "\n" %][% END -%]
69 [% IF issn %]ISSN: [% issn _ "\n" %][% END -%]
70 [% IF upc  %]UPC:  [% upc _ "\n" %] [% END -%]
71 Title: [% title %]
72 Author: [% author %]
73 Publication Info: [% publisher %] [% pubdate %]
74 Item Type: [% item_type %]
75
76 [% END %]
77 [% END %]
78 $$ 
79 WHERE hook = 'biblio.format.record_entry.email' AND id < 100; -- sample data
80
81 -- remove a swath of unused environment entries
82
83 DELETE FROM action_trigger.environment env 
84     USING action_trigger.event_definition def 
85     WHERE env.event_def = def.id AND 
86         env.path != 'items' AND 
87         def.hook = 'biblio.format.record_entry.print' AND 
88         def.id < 100; -- sample data
89
90 DELETE FROM action_trigger.environment env 
91     USING action_trigger.event_definition def 
92     WHERE env.event_def = def.id AND 
93         env.path != 'items' AND 
94         env.path != 'owner' AND 
95         def.hook = 'biblio.format.record_entry.email' AND 
96         def.id < 100; -- sample data
97
98