]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/0165.data.acq.patron_requests.sql
email A/T templates for Acquisition User Requests, supporting ML tweaks, and testing...
[working/Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / 0165.data.acq.patron_requests.sql
1 BEGIN;
2
3 INSERT INTO config.upgrade_log (version) VALUES ('0165'); -- phasefx
4
5 INSERT INTO action_trigger.hook (
6         key,
7         core_type,
8         description,
9         passive
10     ) VALUES (
11         'aur.ordered',
12         'aur',
13         'A patron acquisition request has been marked On-Order.',
14         TRUE
15     ), (
16         'aur.received',
17         'aur',
18         'A patron acquisition request has been marked Received.',
19         TRUE
20     ), (
21         'aur.cancelled',
22         'aur',
23         'A patron acquisition request has been marked Cancelled.',
24         TRUE
25     );
26
27 INSERT INTO action_trigger.validator (module,description) VALUES (
28         'Acq::UserRequestOrdered',
29         'Tests to see if the corresponding Line Item has a state of "on-order".'
30     ), (
31         'Acq::UserRequestReceived',
32         'Tests to see if the corresponding Line Item has a state of "received".'
33     ), (
34         'Acq::UserRequestCancelled',
35         'Tests to see if the corresponding Line Item has a state of "cancelled".'
36     );
37
38 INSERT INTO action_trigger.event_definition (
39         id,
40         active,
41         owner,
42         name,
43         hook,
44         validator,
45         reactor,
46         template
47     ) VALUES (
48         15,
49         FALSE,
50         1,
51         'Email Notice: Patron Acquisition Request marked On-Order.',
52         'aur.ordered',
53         'Acq::UserRequestOrdered',
54         'SendEmail',
55 $$
56 [%- USE date -%]
57 [%- SET li = target.lineitem; -%]
58 [%- SET user = target.usr -%]
59 [%- SET title = helpers.get_li_attr("title", "", li.attributes) %]
60 [%- SET author = helpers.get_li_attr("author", "", li.attributes) %]
61 [%- SET edition = helpers.get_li_attr("edition", "", li.attributes) %]
62 [%- SET isbn = helpers.get_li_attr("isbn", "", li.attributes) %]
63 [%- SET publisher = helpers.get_li_attr("publisher", "", li.attributes) -%]
64 [%- SET pubdate = helpers.get_li_attr("pubdate", "", li.attributes) -%]
65
66 To: [%- params.recipient_email || user.email %]
67 From: [%- params.sender_email || default_sender %]
68 Subject: Acquisition Request Notification
69
70 Dear [% user.family_name %], [% user.first_given_name %]
71 Our records indicate the following acquisition request has been placed on order.
72
73 Title: [% title %]
74 [% IF author %]Author: [% author %][% END %]
75 [% IF edition %]Edition: [% edition %][% END %]
76 [% IF isbn %]ISBN: [% isbn %][% END %]
77 [% IF publisher %]Publisher: [% publisher %][% END %]
78 [% IF pubdate %]Publication Date: [% pubdate %][% END %]
79 Lineitem ID: [% li.id %]
80 $$
81     ), (
82         16,
83         FALSE,
84         1,
85         'Email Notice: Patron Acquisition Request marked Received.',
86         'aur.received',
87         'Acq::UserRequestReceived',
88         'SendEmail',
89 $$
90 [%- USE date -%]
91 [%- SET li = target.lineitem; -%]
92 [%- SET user = target.usr -%]
93 [%- SET title = helpers.get_li_attr("title", "", li.attributes) %]
94 [%- SET author = helpers.get_li_attr("author", "", li.attributes) %]
95 [%- SET edition = helpers.get_li_attr("edition", "", li.attributes) %]
96 [%- SET isbn = helpers.get_li_attr("isbn", "", li.attributes) %]
97 [%- SET publisher = helpers.get_li_attr("publisher", "", li.attributes) -%]
98 [%- SET pubdate = helpers.get_li_attr("pubdate", "", li.attributes) -%]
99
100 To: [%- params.recipient_email || user.email %]
101 From: [%- params.sender_email || default_sender %]
102 Subject: Acquisition Request Notification
103
104 Dear [% user.family_name %], [% user.first_given_name %]
105 Our records indicate the materials for the following acquisition request have been received.
106
107 Title: [% title %]
108 [% IF author %]Author: [% author %][% END %]
109 [% IF edition %]Edition: [% edition %][% END %]
110 [% IF isbn %]ISBN: [% isbn %][% END %]
111 [% IF publisher %]Publisher: [% publisher %][% END %]
112 [% IF pubdate %]Publication Date: [% pubdate %][% END %]
113 Lineitem ID: [% li.id %]
114 $$
115     ), (
116         17,
117         FALSE,
118         1,
119         'Email Notice: Patron Acquisition Request marked Cancelled.',
120         'aur.cancelled',
121         'Acq::UserRequestCancelled',
122         'SendEmail',
123 $$
124 [%- USE date -%]
125 [%- SET li = target.lineitem; -%]
126 [%- SET user = target.usr -%]
127 [%- SET title = helpers.get_li_attr("title", "", li.attributes) %]
128 [%- SET author = helpers.get_li_attr("author", "", li.attributes) %]
129 [%- SET edition = helpers.get_li_attr("edition", "", li.attributes) %]
130 [%- SET isbn = helpers.get_li_attr("isbn", "", li.attributes) %]
131 [%- SET publisher = helpers.get_li_attr("publisher", "", li.attributes) -%]
132 [%- SET pubdate = helpers.get_li_attr("pubdate", "", li.attributes) -%]
133
134 To: [%- params.recipient_email || user.email %]
135 From: [%- params.sender_email || default_sender %]
136 Subject: Acquisition Request Notification
137
138 Dear [% user.family_name %], [% user.first_given_name %]
139 Our records indicate the following acquisition request has been cancelled.
140
141 Title: [% title %]
142 [% IF author %]Author: [% author %][% END %]
143 [% IF edition %]Edition: [% edition %][% END %]
144 [% IF isbn %]ISBN: [% isbn %][% END %]
145 [% IF publisher %]Publisher: [% publisher %][% END %]
146 [% IF pubdate %]Publication Date: [% pubdate %][% END %]
147 Lineitem ID: [% li.id %]
148 $$
149     );
150
151 INSERT INTO action_trigger.environment (
152         event_def,
153         path
154     ) VALUES 
155         ( 15, 'lineitem' ),
156         ( 15, 'lineitem.attributes' ),
157         ( 15, 'usr' ),
158
159         ( 16, 'lineitem' ),
160         ( 16, 'lineitem.attributes' ),
161         ( 16, 'usr' ),
162
163         ( 17, 'lineitem' ),
164         ( 17, 'lineitem.attributes' ),
165         ( 17, 'usr' )
166     ;
167
168 COMMIT;
169