]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/0285.data.history_format.sql
Stamped upgrade script for "lp 823496: do not fail to index personal names that have...
[Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / 0285.data.history_format.sql
1 BEGIN;
2
3 INSERT INTO config.upgrade_log (version) VALUES ('0285'); -- phasefx
4
5 INSERT INTO action_trigger.hook (key,core_type,description,passive) VALUES (
6         'circ.format.history.email',
7         'circ', 
8         oils_i18n_gettext(
9             'circ.format.history.email',
10             'An email has been requested for a circ history.',
11             'ath',
12             'description'
13         ), 
14         FALSE
15     )
16     ,(
17         'circ.format.history.print',
18         'circ', 
19         oils_i18n_gettext(
20             'circ.format.history.print',
21             'A circ history needs to be formatted for printing.',
22             'ath',
23             'description'
24         ), 
25         FALSE
26     )
27     ,(
28         'ahr.format.history.email',
29         'ahr', 
30         oils_i18n_gettext(
31             'ahr.format.history.email',
32             'An email has been requested for a hold request history.',
33             'ath',
34             'description'
35         ), 
36         FALSE
37     )
38     ,(
39         'ahr.format.history.print',
40         'ahr', 
41         oils_i18n_gettext(
42             'ahr.format.history.print',
43             'A hold request history needs to be formatted for printing.',
44             'ath',
45             'description'
46         ), 
47         FALSE
48     )
49
50 ;
51
52 INSERT INTO action_trigger.event_definition (
53         id,
54         active,
55         owner,
56         name,
57         hook,
58         validator,
59         reactor,
60         group_field,
61         granularity,
62         template
63     ) VALUES (
64         25,
65         TRUE,
66         1,
67         'circ.history.email',
68         'circ.format.history.email',
69         'NOOP_True',
70         'SendEmail',
71         'usr',
72         NULL,
73 $$
74 [%- USE date -%]
75 [%- SET user = target.0.usr -%]
76 To: [%- params.recipient_email || user.email %]
77 From: [%- params.sender_email || default_sender %]
78 Subject: Circulation History
79
80     [% FOR circ IN target %]
81             [% helpers.get_copy_bib_basics(circ.target_copy.id).title %]
82             Barcode: [% circ.target_copy.barcode %]
83             Checked Out: [% date.format(helpers.format_date(circ.xact_start), '%Y-%m-%d') %]
84             Due Date: [% date.format(helpers.format_date(circ.due_date), '%Y-%m-%d') %]
85             Returned: [% date.format(helpers.format_date(circ.checkin_time), '%Y-%m-%d') %]
86     [% END %]
87 $$
88     )
89     ,(
90         26,
91         TRUE,
92         1,
93         'circ.history.print',
94         'circ.format.history.print',
95         'NOOP_True',
96         'ProcessTemplate',
97         'usr',
98         'print-on-demand',
99 $$
100 [%- USE date -%]
101 <div>
102     <style> li { padding: 8px; margin 5px; }</style>
103     <div>[% date.format %]</div>
104     <br/>
105
106     [% user.family_name %], [% user.first_given_name %]
107     <ol>
108     [% FOR circ IN target %]
109         <li>
110             <div>[% helpers.get_copy_bib_basics(circ.target_copy.id).title %]</div>
111             <div>Barcode: [% circ.target_copy.barcode %]</div>
112             <div>Checked Out: [% date.format(helpers.format_date(circ.xact_start), '%Y-%m-%d') %]</div>
113             <div>Due Date: [% date.format(helpers.format_date(circ.due_date), '%Y-%m-%d') %]</div>
114             <div>Returned: [% date.format(helpers.format_date(circ.checkin_time), '%Y-%m-%d') %]</div>
115         </li>
116     [% END %]
117     </ol>
118 </div>
119 $$
120     )
121     ,(
122         27,
123         TRUE,
124         1,
125         'ahr.history.email',
126         'ahr.format.history.email',
127         'NOOP_True',
128         'SendEmail',
129         'usr',
130         NULL,
131 $$
132 [%- USE date -%]
133 [%- SET user = target.0.usr -%]
134 To: [%- params.recipient_email || user.email %]
135 From: [%- params.sender_email || default_sender %]
136 Subject: Hold Request History
137
138     [% FOR hold IN target %]
139             [% helpers.get_copy_bib_basics(hold.current_copy.id).title %]
140             Requested: [% date.format(helpers.format_date(hold.request_time), '%Y-%m-%d') %]
141             [% IF hold.fulfillment_time %]Fulfilled: [% date.format(helpers.format_date(hold.fulfillment_time), '%Y-%m-%d') %][% END %]
142     [% END %]
143 $$
144     )
145     ,(
146         28,
147         TRUE,
148         1,
149         'ahr.history.print',
150         'ahr.format.history.print',
151         'NOOP_True',
152         'ProcessTemplate',
153         'usr',
154         'print-on-demand',
155 $$
156 [%- USE date -%]
157 <div>
158     <style> li { padding: 8px; margin 5px; }</style>
159     <div>[% date.format %]</div>
160     <br/>
161
162     [% user.family_name %], [% user.first_given_name %]
163     <ol>
164     [% FOR hold IN target %]
165         <li>
166             <div>[% helpers.get_copy_bib_basics(hold.current_copy.id).title %]</div>
167             <div>Requested: [% date.format(helpers.format_date(hold.request_time), '%Y-%m-%d') %]</div>
168             [% IF hold.fulfillment_time %]<div>Fulfilled: [% date.format(helpers.format_date(hold.fulfillment_time), '%Y-%m-%d') %]</div>[% END %]
169         </li>
170     [% END %]
171     </ol>
172 </div>
173 $$
174     )
175
176 ;
177
178 INSERT INTO action_trigger.environment (
179         event_def,
180         path
181     ) VALUES 
182          ( 25, 'target_copy')
183         ,( 25, 'usr' )
184         ,( 26, 'target_copy' )
185         ,( 26, 'usr' )
186         ,( 27, 'current_copy' )
187         ,( 27, 'usr' )
188         ,( 28, 'current_copy' )
189         ,( 28, 'usr' )
190 ;
191
192 -- DELETE FROM action_trigger.environment WHERE event_def IN (25,26,27,28); DELETE FROM action_trigger.event where event_def IN (25,26,27,28); DELETE FROM action_trigger.event_definition WHERE id IN (25,26,27,28); DELETE FROM action_trigger.hook WHERE key IN ('circ.format.history.email','circ.format.history.print','ahr.format.history.email','ahr.format.history.print'); DELETE FROM config.upgrade_log WHERE version = 'test'; -- from testing, this sql will remove these events, etc.
193
194 COMMIT;
195