From f67aaba41d64fc07476758081efe24c64b1ff2be Mon Sep 17 00:00:00 2001 From: Chris Sharp Date: Tue, 5 Jan 2016 14:57:24 -0500 Subject: [PATCH] Adding post-upgrade datawork script --- .../sql/Pg/version-upgrade/pines-post-upgrade.sql | 328 +++++++++++++++++++++ 1 file changed, 328 insertions(+) create mode 100644 Open-ILS/src/sql/Pg/version-upgrade/pines-post-upgrade.sql diff --git a/Open-ILS/src/sql/Pg/version-upgrade/pines-post-upgrade.sql b/Open-ILS/src/sql/Pg/version-upgrade/pines-post-upgrade.sql new file mode 100644 index 0000000000..f79d64f4a1 --- /dev/null +++ b/Open-ILS/src/sql/Pg/version-upgrade/pines-post-upgrade.sql @@ -0,0 +1,328 @@ +-- update notification wording for A/T notices as we enable them +begin; +-- 10-day overdue notice + +update action_trigger.event_definition + set template = +$$ +[%- USE date -%] +[%- user = target.0.usr -%] +To: [%- params.recipient_email || user.email %] +From: [%- params.sender_email || default_sender %] +Subject: Overdue Notification + +Dear [% user.first_given_name %] [% user.family_name %], + +Our records indicate the following items are 10 days or more overdue: + +[% FOR circ IN target %] + Title: [% circ.target_copy.call_number.record.simple_record.title %] + Barcode: [% circ.target_copy.barcode %] + Due: [% date.format(helpers.format_date(circ.due_date), '%m-%d-%Y') %] + Total Owed For Transaction: [% circ.billable_transaction.summary.total_owed %] + Checkout Library: [% circ.circ_lib.name %] +[% END %] +Please return the above items to avoid additional fines. + +Please log in to your account at http://gapines.org/login or contact your library for more information: + +[% lib.name %] +[% lib.mailing_address.street1 %] [% lib.mailing_address.street2 %] +[% lib.mailing_address.city %], [% lib.mailing_address.state %] +[% lib.mailing_address.post_code %] +[% lib.phone %] + +Please do not respond to this email. This notice was sent from an address that cannot accept incoming mail. + +$$, + active = true, + granularity = 'overdue' +where name = '10 Day Overdue Email Notification'; + +-- 30-day overdue notice + +insert into action_trigger.event_definition (active, owner, name, hook, validator, reactor, delay, max_delay, delay_field, group_field, template, granularity) + values (true, + 1, + '30 Day Overdue Email Notification', + 'checkout.due', + 'CircIsOverdue', + 'SendEmail', + '30 days', + '31 days', + 'due_date', + 'usr', +$$ +[%- USE date -%] +[%- user = target.0.usr -%] +To: [%- params.recipient_email || user.email %] +From: [%- params.sender_email || default_sender %] +Subject: Overdue Notification + +Dear [% user.first_given_name %] [% user.family_name %], + +Our records indicate the following items are 30 days or more overdue: + +[% FOR circ IN target %] + Title: [% circ.target_copy.call_number.record.simple_record.title %] + Barcode: [% circ.target_copy.barcode %] + Due: [% date.format(helpers.format_date(circ.due_date), '%m-%d-%Y') %] + Total Owed For Transaction: [% circ.billable_transaction.summary.total_owed %] + Checkout Library: [% circ.circ_lib.name %] +[% END %] +Please return the above items to avoid additional fines. + +Please log in to your account at http://gapines.org/login or contact your library for more information: + +[% lib.name %] +[% lib.mailing_address.street1 %] [% lib.mailing_address.street2 %] +[% lib.mailing_address.city %], [% lib.mailing_address.state %] +[% lib.mailing_address.post_code %] +[% lib.phone %] + +Please do not respond to this email. This notice was sent from an address that cannot accept incoming mail. + +$$, + 'overdue'); + +-- 30-day account expiration notice + +update action_trigger.event_definition + set active = true, + template = +$$ +[%- USE date -%] +[%- user = target -%] +[%- lib = target.home_ou -%] +To: [%- params.recipient_email || user.email %] +From: [%- helpers.get_org_setting(target.home_ou.id, 'org.bounced_emails') || lib.email || params.sender_email || default_sender %] +Reply-To: [%- helpers.get_org_setting(target.home_ou.id, 'org.bounced_emails') || lib.email || params.sender_email || default_sender %] +Subject: Courtesy Notice - Library Account Expiration in 30 days +Auto-Submitted: auto-generated + +Dear [% user.first_given_name %] [% user.family_name %], + +Our records indicate your library account is due to expire in 30 days. Please visit your local library with your picture ID and proof of address to renew your account in order to avoid a disruption in library service. Any outstanding fines or fees must be paid in order to renew your account. + +Sincerely, +[% lib.name %] + +Please contact your library for more information: + +[% lib.name %] +[%- SET addr = lib.mailing_address -%] +[%- IF !addr -%] [%- SET addr = lib.billing_address -%] [%- END %] +[% addr.street1 %] [% addr.street2 %] +[% addr.city %], [% addr.state %] +[% addr.post_code %] +[% lib.phone %] + +Please do not respond to this email. This notice was sent from an address that cannot accept incoming mail + +$$, + granularity = 'accountexpire' +where name = '30 Day Account Expiration Courtesy Notice'; + +-- Long-overdue notice + +update action_trigger.event_definition + set template = +$$ +[%- USE date -%] +[%- user = target.0.usr -%] +To: [%- params.recipient_email || user.email %] +From: [%- params.sender_email || default_sender %] +Subject: Overdue Items Marked Long Overdue + +Dear [% user.first_given_name %] [% user.family_name %], + +The following items are 6 months or more overdue: + +[% FOR circ IN target %] + [%- copy_details = helpers.get_copy_bib_basics(circ.target_copy.id) -%] + Title: [% copy_details.title %], by [% 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), '%m-%d-%Y') %] + Total Owed For Transaction: [% circ.billable_transaction.summary.balance_owed %] + Checkout Library: [% circ.circ_lib.name %] + +[% END %] + +Your account has been charged item cost and a non-refundable processing fee for each item. + +Please log in to your account at http://gapines.org/login or contact your library for more information: + +[% lib.name %] +[% lib.mailing_address.street1 %] [% lib.mailing_address.street2 %] +[% lib.mailing_address.city %], [% lib.mailing_address.state %] +[% lib.mailing_address.post_code %] +[% lib.phone %] + +Please do not respond to this email. This notice was sent from an address that cannot accept incoming mail. + +$$ +where name = '6 Month Long Overdue Notice'; + +-- Hold ready for pickup email notification + +update action_trigger.event_definition + set template = +$$ +[%- USE date -%] +[%- user = target.0.usr -%] +[%- lib = target.0.pickup_lib -%] +To: [%- params.recipient_email || user.email %] +From: [%- helpers.get_org_setting(target.0.pickup_lib.id, 'org.bounced_emails') || lib.email || params.sender_email || default_sender %] +Subject: Hold Available Notification + +Dear [% user.first_given_name %] [% user.family_name %], + +The item(s) you requested are available for pickup at your library: + +[% FOR hold IN target %] +[%- copy_details = helpers.get_copy_bib_basics(hold.current_copy.id) -%] + Title: [% helpers.escape_xml(copy_details.title) %] + Author: [% helpers.escape_xml(copy_details.author) %] + Call Number: [% hold.current_copy.call_number.label %] + Barcode: [% hold.current_copy.barcode %] + Pickup Library: [% hold.pickup_lib.name %] + +[% END %] + +You can log in and manage your holds at http://gapines.org/login or contact your library for more information. + +Please do not respond to this email. This notice was sent from an address that cannot accept incoming mail. + +$$ +where name = 'Hold Ready for Pickup Email Notification'; + +-- Hold ready for pickup SMS notification + +update action_trigger.event_definition + set template = +$$ +[%- USE date -%] +[%- user = target.0.usr -%] +From: [%- params.sender_email || default_sender %] +To: [%- params.recipient_email || helpers.get_sms_gateway_email(target.0.sms_carrier,target.0.sms_notify) %] +Subject: [% target.size %] hold(s) ready for pickup + +[% FOR hold IN target %][%- + bibxml = helpers.xml_doc( hold.current_copy.call_number.record.marc ); + title = ""; + FOR part IN bibxml.findnodes('//*[@tag="245"]/*[@code="a"]'); + title = title _ part.textContent; + END; + author = bibxml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent; +%][% title %] / [% author %] @ [% hold.pickup_lib.name %] +[% END %] + +$$ +where name = 'Hold Ready for Pickup SMS Notification'; + +-- PINES Preminders +update action_trigger.event_definition + set active = true, + template = +$$ +[%- USE date -%] +[%- SET user = circ_list.0.usr -%] +[%- SET lib = circ_list.0.circ_lib -%] +To: [% user.email %] +From: [% smtp_sender %] +Reply-To: [% smtp_sender %] +Errors-To: [% smtp_sender %] +Subject: Courtesy Notice + +[% user.first_given_name %] [% user.family_name %], + +[%- return_date = parse_due_date(circ_list.0) -%] + +This is a courtesy reminder from the library that the following item(s) will be due on : [% date.format(return_date, '%A, %B %d, %Y') %] + +[% FOREACH circ = circ_list %] + [% get_bib_attr(circ, 'title') %], by [% get_bib_attr(circ, 'author') %] + Call Number: [% circ.target_copy.call_number.label %] + [%- SET due_date = parse_due_date(circ) %] + Due Date: [% date.format(due_date, '%m-%d-%Y') %] + Barcode: [% circ.target_copy.barcode %] +[% END %] + +You may request renewal online at http://gapines.org/login, or by contacting your library: + +[% lib.name %] +[%- SET addr = lib.mailing_address -%] +[%- IF !addr -%] [%- SET addr = lib.billing_address -%] [%- END %] +[% lib.mailing_address.street1 %] [% lib.mailing_address.street2 %] +[% lib.mailing_address.city %], [% lib.mailing_address.state %] +[% lib.mailing_address.post_code %] +[% lib.phone %] + +[Note: Not all items can be renewed. Items returned after the due date may be subject to fines.] + +Please do not reply to this message. This notice was sent from an address that cannot accept incoming mail. + +$$, + delay = '-2 days', + max_delay = '-3 days', + granularity = 'predue' +where name = 'PINES Preminders'; + +-- SMS Call Number + +update action_trigger.event_definition + set template = +$$ +[%- USE date -%] +From: [%- params.sender_email || default_sender %] +To: [%- params.recipient_email || helpers.get_sms_gateway_email(user_data.sms_carrier,user_data.sms_notify) %] +Subject: Call Number + +[%- + bibxml = helpers.xml_doc( target.record.marc ); + title = ""; + FOR part IN bibxml.findnodes('//*[@tag="245"]/*[@code="a" or @code="b"]'); + title = title _ part.textContent; + END; + author = bibxml.findnodes('//*[@tag="100"]/*[@code="a"]').textContent; +%] +[%- IF title %] +Title: [% title %] +[%- END %] +[%- IF author %] +Author: [% author %] +[%- END %] +Call Number: [% target.label %] +Location: [% helpers.get_most_populous_location( target.id ).name %] +Library: [% target.owning_lib.name %] + +$$ +where name = 'SMS Call Number'; + +-- Password Reset notification + +update action_trigger.event_definition + set template = +$$ +[%- USE date -%] +[%- user = target.usr -%] +To: [%- params.recipient_email || user.email %] +From: [%- params.sender_email || user.home_ou.email || default_sender %] +Subject: Library account password reset request + +You have received this message because you, or somebody else, requested a reset of your library system password. If you did not request a reset of your library system password, you may ignore this message and your current password will continue to work. + +To reset your password: + +1. Go to https://[% params.hostname %]/eg/opac/password_reset/[% target.uuid %] + +2. Complete the password reset form. + +If you need further assistance, please contact your library at [% user.home_ou.phone %]. + +Please do not reply to this message. This notice was sent from an address that cannot accept incoming mail. + +$$ +where name = 'Password reset request notification'; +commit; -- 2.11.0