From: McCanna Date: Thu, 20 Jul 2017 19:44:28 +0000 (-0400) Subject: LP#1668734 Action Trigger for SMS Preminder X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=6e019d8d159701100cad43fdff336d28259297d5;p=evergreen%2Fpines.git LP#1668734 Action Trigger for SMS Preminder New optional SMS text notification to be sent 3 days prior to the due date of any circulating item for patrons who have an SMS text number and carrier stored in their accounts. This action trigger is disabled by default and can be enabled in Admin > Local Administration > Notifications / Action Triggers. Signed-off-by: McCanna Signed-off-by: Chris Sharp Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index 89097b7dcd..3c505b8e2b 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -14722,6 +14722,39 @@ INSERT INTO vandelay.merge_profile (id, owner, name, preserve_spec, update_bib_s SELECT SETVAL('vandelay.merge_profile_id_seq'::TEXT, 100); +-- 3 Day Courtesy Notice by SMS +INSERT INTO action_trigger.event_definition (id, active, owner, name, hook, + validator, reactor, delay, delay_field, group_field, template) + VALUES (XXXX, FALSE, 1, + '3 Day Courtesy Notice by SMS', + 'checkout.due', + 'CircIsOpen', 'SendSMS', '-3 days', 'due_date', 'usr', +$$ +[%- USE date -%] +[%- user = target.0.usr -%] +[%- homelib = user.home_ou -%] +[%- sms_number = helpers.get_user_setting(user.id, 'opac.default_sms_notify') -%] +[%- sms_carrier = helpers.get_user_setting(user.id, 'opac.default_sms_carrier') -%] +From: [%- helpers.get_org_setting(homelib.id, 'org.bounced_emails') || homelib.email || params.sender_email || default_sender %] +To: [%- helpers.get_sms_gateway_email(sms_carrier,sms_number) %] +Subject: Library Materials Due Soon + +You have items due soon: + +[% FOR circ IN target %] +[%- copy_details = helpers.get_copy_bib_basics(circ.target_copy.id) -%] +[% copy_details.title FILTER ucfirst %] by [% copy_details.author FILTER ucfirst %] due on [% date.format(helpers.format_date(circ.due_date), '%m-%d-%Y') %] + +[% END %] + +$$); + +INSERT INTO action_trigger.environment (event_def, path) VALUES + (XXXX, 'circ_lib.billing_address'), + (XXXX, 'target_copy.call_number'), + (XXXX, 'usr'), + (XXXX, 'usr.home_ou'); + -- user activity seed data -- INSERT INTO config.usr_activity_type (id, ewho, ewhat, ehow, egroup, label) VALUES diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.action-trigger.event_definition.sms_preminder.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.action-trigger.event_definition.sms_preminder.sql new file mode 100644 index 0000000000..b03a993d1e --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.action-trigger.event_definition.sms_preminder.sql @@ -0,0 +1,42 @@ +-- Evergreen DB patch XXXX.schema.action-trigger.event_definition.sms_preminder.sql +-- +-- New action trigger event definition: 3 Day Courtesy Notice by SMS +-- +BEGIN; + +-- check whether patch can be applied +SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); + +INSERT INTO action_trigger.event_definition (id, active, owner, name, hook, + validator, reactor, delay, delay_field, group_field, template) + VALUES (XXXX, FALSE, 1, + '3 Day Courtesy Notice by SMS', + 'checkout.due', + 'CircIsOpen', 'SendSMS', '-3 days', 'due_date', 'usr', +$$ +[%- USE date -%] +[%- user = target.0.usr -%] +[%- homelib = user.home_ou -%] +[%- sms_number = helpers.get_user_setting(user.id, 'opac.default_sms_notify') -%] +[%- sms_carrier = helpers.get_user_setting(user.id, 'opac.default_sms_carrier') -%] +From: [%- helpers.get_org_setting(homelib.id, 'org.bounced_emails') || homelib.email || params.sender_email || default_sender %] +To: [%- helpers.get_sms_gateway_email(sms_carrier,sms_number) %] +Subject: Library Materials Due Soon + +You have items due soon: + +[% FOR circ IN target %] +[%- copy_details = helpers.get_copy_bib_basics(circ.target_copy.id) -%] +[% copy_details.title FILTER ucfirst %] by [% copy_details.author FILTER ucfirst %] due on [% date.format(helpers.format_date(circ.due_date), '%m-%d-%Y') %] + +[% END %] + +$$); + +INSERT INTO action_trigger.environment (event_def, path) VALUES + (XXXX, 'circ_lib.billing_address'), + (XXXX, 'target_copy.call_number'), + (XXXX, 'usr'), + (XXXX, 'usr.home_ou'); + +COMMIT; diff --git a/docs/RELEASE_NOTES_NEXT/Administration/action_trigger_preminder.adoc b/docs/RELEASE_NOTES_NEXT/Administration/action_trigger_preminder.adoc new file mode 100644 index 0000000000..04d8d1134e --- /dev/null +++ b/docs/RELEASE_NOTES_NEXT/Administration/action_trigger_preminder.adoc @@ -0,0 +1,10 @@ +3 Day Courtesy Notice by SMS +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +New optional SMS text notification to be sent out 3 days prior to the due +date of any circulating item for patrons who have an SMS text number and +carrier stored in their accounts. This action trigger is disabled by default, +but can be enabled and modified by going into Admin > Local Administration > +Notifications / Action Triggers. + +You may wish to make use of granularity so that these messages are batched +and sent at the same time each day.