]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/XXXX.data.email-checkout-receipt.sql
LP#1356477: release notes for email checkout receipts
[Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / XXXX.data.email-checkout-receipt.sql
1 BEGIN;
2
3 INSERT INTO config.usr_setting_type (
4     name,
5     opac_visible,
6     label,
7     description,
8     datatype
9 ) VALUES (
10     'circ.send_email_checkout_receipts',
11     TRUE,
12     oils_i18n_gettext('circ.send_email_checkout_receipts', 'Email checkout receipts by default?', 'cust', 'label'),
13     oils_i18n_gettext('circ.send_email_checkout_receipts', 'Email checkout receipts by default?', 'cust', 'description'),
14     'bool'
15 );
16
17 INSERT INTO action_trigger.hook (key, core_type, description, passive)
18 VALUES (
19     'circ.checkout.batch_notify',
20     'circ',
21     oils_i18n_gettext(
22         'circ.checkout.batch_notify',
23         'Notification of a group of circs',
24         'ath',
25         'description'
26     ),
27     FALSE
28 );
29
30 INSERT INTO action_trigger.hook (key, core_type, description, passive)
31 VALUES (
32     'circ.checkout.batch_notify.session',
33     'circ',
34     oils_i18n_gettext(
35         'circ.checkout.batch_notify.session',
36         'Notification of a group of circs at the end of a checkout session',
37         'ath',
38         'description'
39     ),
40     FALSE
41 );
42
43 INSERT INTO action_trigger.event_definition (
44     active,
45     owner,
46     name,
47     hook,
48     validator,
49     reactor,
50     usr_field,
51     opt_in_setting,
52     group_field,
53     template
54 ) VALUES (
55     TRUE,
56     1,
57     'Email Checkout Receipt',
58     'circ.checkout.batch_notify.session',
59     'NOOP_True',
60     'SendEmail',
61     'usr',
62     'circ.send_email_checkout_receipts',
63     'usr',
64     $$[%- USE date -%]
65 [%- user = target.0.usr -%]
66 To: [%- params.recipient_email || user.email %]
67 From: [%- helpers.get_org_setting(target.0.circ_lib.id, 'org.bounced_emails') || params.sender_email || default_sender %]
68 Subject: Checkout Receipt
69 Auto-Submitted: auto-generated
70
71 You checked out the following items:
72
73 [% FOR circ IN target %]
74     [%- copy_details = helpers.get_copy_bib_basics(circ.target_copy.id) -%]
75     Title: [% copy_details.title %]
76     Author: [% copy_details.author %]
77     Call Number: [% circ.target_copy.call_number.label %]
78     Barcode: [% circ.target_copy.barcode %]
79     Due: [% date.format(helpers.format_date(circ.due_date), '%Y-%m-%d') %]
80     Library: [% circ.circ_lib.name %]
81
82 [% END %]
83 $$);
84
85 INSERT INTO action_trigger.environment (
86     event_def,
87     path
88 ) VALUES (
89     currval('action_trigger.event_definition_id_seq'),
90     'target_copy.call_number'
91 ), (
92     currval('action_trigger.event_definition_id_seq'),
93     'target_copy.location'
94 ), (
95     currval('action_trigger.event_definition_id_seq'),
96     'usr'
97 ), (
98     currval('action_trigger.event_definition_id_seq'),
99     'circ_lib'
100 );
101
102 COMMIT;
103