From: Mike Rylander Date: Wed, 24 Aug 2016 22:01:33 +0000 (-0400) Subject: Stamping upgrade for email receipts X-Git-Tag: sprint4-merge-nov22~87 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=c820aa492739c544e09a7b646a09b8507ae3993b;p=working%2FEvergreen.git Stamping upgrade for email receipts Signed-off-by: Mike Rylander --- diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index d0fc23aeb2..7e098c0d6c 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -91,7 +91,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 ('0995', :eg_version); -- kmlussier/miker +INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0996', :eg_version); -- gmcharlt/miker CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/upgrade/0996.data.email-checkout-receipt.sql b/Open-ILS/src/sql/Pg/upgrade/0996.data.email-checkout-receipt.sql new file mode 100644 index 0000000000..961c87bc02 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0996.data.email-checkout-receipt.sql @@ -0,0 +1,105 @@ +BEGIN; + +SELECT evergreen.upgrade_deps_block_check('0996', :eg_version); + +INSERT INTO config.usr_setting_type ( + name, + opac_visible, + label, + description, + datatype +) VALUES ( + 'circ.send_email_checkout_receipts', + TRUE, + oils_i18n_gettext('circ.send_email_checkout_receipts', 'Email checkout receipts by default?', 'cust', 'label'), + oils_i18n_gettext('circ.send_email_checkout_receipts', 'Email checkout receipts by default?', 'cust', 'description'), + 'bool' +); + +INSERT INTO action_trigger.hook (key, core_type, description, passive) +VALUES ( + 'circ.checkout.batch_notify', + 'circ', + oils_i18n_gettext( + 'circ.checkout.batch_notify', + 'Notification of a group of circs', + 'ath', + 'description' + ), + FALSE +); + +INSERT INTO action_trigger.hook (key, core_type, description, passive) +VALUES ( + 'circ.checkout.batch_notify.session', + 'circ', + oils_i18n_gettext( + 'circ.checkout.batch_notify.session', + 'Notification of a group of circs at the end of a checkout session', + 'ath', + 'description' + ), + FALSE +); + +INSERT INTO action_trigger.event_definition ( + active, + owner, + name, + hook, + validator, + reactor, + usr_field, + opt_in_setting, + group_field, + template +) VALUES ( + TRUE, + 1, + 'Email Checkout Receipt', + 'circ.checkout.batch_notify.session', + 'NOOP_True', + 'SendEmail', + 'usr', + 'circ.send_email_checkout_receipts', + 'usr', + $$[%- USE date -%] +[%- user = target.0.usr -%] +To: [%- params.recipient_email || user.email %] +From: [%- helpers.get_org_setting(target.0.circ_lib.id, 'org.bounced_emails') || params.sender_email || default_sender %] +Subject: Checkout Receipt +Auto-Submitted: auto-generated + +You checked out the following items: + +[% FOR circ IN target %] + [%- copy_details = helpers.get_copy_bib_basics(circ.target_copy.id) -%] + Title: [% copy_details.title %] + Author: [% copy_details.author %] + Call Number: [% circ.target_copy.call_number.label %] + Barcode: [% circ.target_copy.barcode %] + Due: [% date.format(helpers.format_date(circ.due_date), '%Y-%m-%d') %] + Library: [% circ.circ_lib.name %] + +[% END %] +$$); + +INSERT INTO action_trigger.environment ( + event_def, + path +) VALUES ( + currval('action_trigger.event_definition_id_seq'), + 'target_copy.call_number' +), ( + currval('action_trigger.event_definition_id_seq'), + 'target_copy.location' +), ( + currval('action_trigger.event_definition_id_seq'), + 'usr' +), ( + currval('action_trigger.event_definition_id_seq'), + 'circ_lib' +); + +COMMIT; + diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.email-checkout-receipt.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.email-checkout-receipt.sql deleted file mode 100644 index eaeaf367a7..0000000000 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.email-checkout-receipt.sql +++ /dev/null @@ -1,103 +0,0 @@ -BEGIN; - -INSERT INTO config.usr_setting_type ( - name, - opac_visible, - label, - description, - datatype -) VALUES ( - 'circ.send_email_checkout_receipts', - TRUE, - oils_i18n_gettext('circ.send_email_checkout_receipts', 'Email checkout receipts by default?', 'cust', 'label'), - oils_i18n_gettext('circ.send_email_checkout_receipts', 'Email checkout receipts by default?', 'cust', 'description'), - 'bool' -); - -INSERT INTO action_trigger.hook (key, core_type, description, passive) -VALUES ( - 'circ.checkout.batch_notify', - 'circ', - oils_i18n_gettext( - 'circ.checkout.batch_notify', - 'Notification of a group of circs', - 'ath', - 'description' - ), - FALSE -); - -INSERT INTO action_trigger.hook (key, core_type, description, passive) -VALUES ( - 'circ.checkout.batch_notify.session', - 'circ', - oils_i18n_gettext( - 'circ.checkout.batch_notify.session', - 'Notification of a group of circs at the end of a checkout session', - 'ath', - 'description' - ), - FALSE -); - -INSERT INTO action_trigger.event_definition ( - active, - owner, - name, - hook, - validator, - reactor, - usr_field, - opt_in_setting, - group_field, - template -) VALUES ( - TRUE, - 1, - 'Email Checkout Receipt', - 'circ.checkout.batch_notify.session', - 'NOOP_True', - 'SendEmail', - 'usr', - 'circ.send_email_checkout_receipts', - 'usr', - $$[%- USE date -%] -[%- user = target.0.usr -%] -To: [%- params.recipient_email || user.email %] -From: [%- helpers.get_org_setting(target.0.circ_lib.id, 'org.bounced_emails') || params.sender_email || default_sender %] -Subject: Checkout Receipt -Auto-Submitted: auto-generated - -You checked out the following items: - -[% FOR circ IN target %] - [%- copy_details = helpers.get_copy_bib_basics(circ.target_copy.id) -%] - Title: [% copy_details.title %] - Author: [% copy_details.author %] - Call Number: [% circ.target_copy.call_number.label %] - Barcode: [% circ.target_copy.barcode %] - Due: [% date.format(helpers.format_date(circ.due_date), '%Y-%m-%d') %] - Library: [% circ.circ_lib.name %] - -[% END %] -$$); - -INSERT INTO action_trigger.environment ( - event_def, - path -) VALUES ( - currval('action_trigger.event_definition_id_seq'), - 'target_copy.call_number' -), ( - currval('action_trigger.event_definition_id_seq'), - 'target_copy.location' -), ( - currval('action_trigger.event_definition_id_seq'), - 'usr' -), ( - currval('action_trigger.event_definition_id_seq'), - 'circ_lib' -); - -COMMIT; -