upgrade script for A/T event def: Hold Cancelled (No Target) Email Notification
authorJason Etheridge <jason@esilibrary.com>
Fri, 24 Jun 2011 15:13:41 +0000 (11:13 -0400)
committerJason Etheridge <jason@esilibrary.com>
Fri, 24 Jun 2011 15:16:20 +0000 (11:16 -0400)
Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/upgrade/0565.schema.action-trigger.event_definition.hold-cancel-no-target-notification.sql [new file with mode: 0644]

index aebecc3..d1a1417 100644 (file)
@@ -86,7 +86,7 @@ CREATE TRIGGER no_overlapping_deps
     BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
     FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
 
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0564', :eg_version); -- berick via phasefx
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0565', :eg_version); -- berick via phasefx
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/0565.schema.action-trigger.event_definition.hold-cancel-no-target-notification.sql b/Open-ILS/src/sql/Pg/upgrade/0565.schema.action-trigger.event_definition.hold-cancel-no-target-notification.sql
new file mode 100644 (file)
index 0000000..63a99c5
--- /dev/null
@@ -0,0 +1,39 @@
+-- Evergreen DB patch 0565.schema.action-trigger.event_definition.hold-cancel-no-target-notification.sql
+--
+-- New action trigger event definition: Hold Cancelled (No Target) Email Notification
+--
+BEGIN;
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('0565', :eg_version);
+
+INSERT INTO action_trigger.event_definition (id, active, owner, name, hook, validator, reactor, delay, delay_field, group_field, template)
+    VALUES (38, FALSE, 1, 
+        'Hold Cancelled (No Target) Email Notification', 
+        'hold_request.cancel.expire_no_target', 
+        'HoldIsCancelled', 'SendEmail', '30 minutes', 'cancel_time', 'usr',
+$$
+[%- USE date -%]
+[%- user = target.0.usr -%]
+To: [%- params.recipient_email || user.email %]
+From: [%- params.sender_email || default_sender %]
+Subject: Hold Request Cancelled
+
+Dear [% user.family_name %], [% user.first_given_name %]
+The following holds were cancelled because no items were found to fullfil the hold.
+
+[% FOR hold IN target %]
+    Title: [% hold.bib_rec.bib_record.simple_record.title %]
+    Author: [% hold.bib_rec.bib_record.simple_record.author %]
+    Library: [% hold.pickup_lib.name %]
+    Request Date: [% date.format(helpers.format_date(hold.rrequest_time), '%Y-%m-%d') %]
+[% END %]
+
+$$);
+
+INSERT INTO action_trigger.environment (event_def, path) VALUES
+    (38, 'usr'),
+    (38, 'pickup_lib'),
+    (38, 'bib_rec.bib_record.simple_record');
+
+COMMIT;