]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/XXXX.30day.expiration.prenotice.sql
LP#1124498 - Made a few format changes just to better match how other sql is formatted.
[Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / XXXX.30day.expiration.prenotice.sql
1 BEGIN;
2
3 --create hook for actor.usr.expire_date
4 INSERT INTO action_trigger.hook (key, core_type, description, passive)
5     VALUES ('expire', 'au', 'Account is expired', 't');
6         
7 --SQL to create event definition for 30 day account pre-expiration notice
8 --Inactive, owned by top of org tree by default.  Modify to suit needs.
9 --Can set reactor to 'ProcessTemplate' for testing.  Will generate emails in DB, but not actually send.
10
11 INSERT INTO action_trigger.event_definition (
12     active, owner, name, hook, 
13     validator, reactor, delay, delay_field,
14     max_delay, repeat_delay, template
15 )  VALUES (
16     'f', '1', '30 Day Account Expiration Courtesy Notice', 'expire',
17     'NOOP_True', 'SendEmail', '-30 days', 'expire_date',
18     '-29 days', '30 days',
19 $$
20 [%- USE date -%]
21 [%- user = target -%]
22 [%- lib = target.home_ou -%]
23 To: [%- params.recipient_email || user.email %]
24 From: [%- helpers.get_org_setting(target.home_ou.id, 'org.bounced_emails') || lib.email || params.sender_email || default_sender %]
25 Reply-To: [%- helpers.get_org_setting(target.home_ou.id, 'org.bounced_emails') || lib.email || params.sender_email || default_sender %]
26 Subject: Courtesy Notice - Library Account Expiration in 30 days
27 Auto-Submitted: auto-generated
28
29 Dear [% user.first_given_name %] [% user.family_name %],
30
31 Our records indicate your library account is due to expire in 30 days.  Please visit your local library at your convenience to renew your account in order to avoid a disruption in access to library service.
32
33 Sincerely,
34 [% lib.name %]
35
36 Contact your library for more information:
37
38 [% lib.name %]
39 [%- SET addr = lib.mailing_address -%]
40 [%- IF !addr -%] [%- SET addr = lib.billing_address -%] [%- END %]
41 [% addr.street1 %] [% addr.street2 %]
42 [% addr.city %], [% addr.state %]
43 [% addr.post_code %]
44 [% lib.phone %]
45
46 $$);
47         
48 --insert environment values
49 INSERT INTO action_trigger.environment (event_def, path) VALUES
50     (CURRVAL('action_trigger.event_definition_id_seq'), 'home_ou.mailing_address'),
51     (CURRVAL('action_trigger.event_definition_id_seq'), 'home_ou.billing_address');
52         
53 COMMIT;