3 --create hook for actor.usr.expire_date
4 INSERT INTO action_trigger.hook (key, core_type, description, passive)
5 VALUES ('expire', 'au', 'Card is expired', 't');
7 --SQL to create event definition for 30 day card 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.
11 INSERT INTO action_trigger.event_definition (active, owner, name, hook, validator, reactor, delay, delay_field, group_field, max_delay, template)
12 VALUES ('t', '1', '30 Day Card Expiration Courtesy Notice', 'expire', 'NOOP_True', 'SendEmail', '-30 days', 'expire_date', 'usr', '-29 days',
16 [%- lib = target.home_ou -%]
17 To: [%- params.recipient_email || user.email %]
18 From: [%- helpers.get_org_setting(target.home_ou.id, 'org.bounced_emails') || lib.email || params.sender_email || default_sender %]
19 Reply-To: [%- helpers.get_org_setting(target.home_ou.id, 'org.bounced_emails') || lib.email || params.sender_email || default_sender %]
20 Errors-To: [%- helpers.get_org_setting(target.home_ou.id, 'org.bounced_emails') || lib.email || params.sender_email || default_sender %]
21 Subject: Courtesy Notice - Library Card Expiration in 30 days
23 Dear [% user.first_given_name %] [% user.family_name %],
25 Our records indicate your library card is due to expire in 30 days. Please visit your local library at your convenience to renew your card in order to avoid a disruption in access to library service.
30 Contact your library for more information:
33 [%- SET addr = lib.mailing_address -%]
34 [%- IF !addr -%] [%- SET addr = lib.billing_address -%] [%- END %]
35 [% lib.mailing_address.street1 %] [% lib.mailing_address.street2 %]
36 [% lib.mailing_address.city %], [% lib.mailing_address.state %]
37 [% lib.mailing_address.post_code %]
42 --get current value in sequence
43 SELECT currval('action_trigger.event_definition_id_seq');
45 --send from email address parameter
46 INSERT INTO action_trigger.event_params (event_def, param, value)
47 VALUES (CURRVAL('action_trigger.event_definition_id_seq'), 'sender_email', 'evergreen@example.org');
49 --insert environment values
50 INSERT INTO action_trigger.environment (event_def, path)
51 VALUES (CURRVAL('action_trigger.event_definition_id_seq'), 'home_ou.mailing_address');
53 INSERT INTO action_trigger.environment (event_def, path)
54 VALUES (CURRVAL('action_trigger.event_definition_id_seq'), 'home_ou.billing_address');