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