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