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