BEGIN;
+-- NOTE: very IDs are still correct for action_trigger event defs at merge.
+-- SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+-- copy status
+
INSERT INTO config.copy_status
(id, name, holdable, opac_visible, copy_active, restrict_copy_delete)
VALUES (16, 'Long Overdue', FALSE, FALSE, FALSE, TRUE);
+-- checkin override perm
+
INSERT INTO permission.perm_list (code, description) VALUES (
'COPY_STATUS_LONGOVERDUE.override',
oils_i18n_gettext(
)
);
+-- billing types
+
INSERT INTO config.billing_type (id, owner, name) VALUES
(10, 1, oils_i18n_gettext(
10, 'Long-Overdue Materials', 'cbt', 'name')),
(11, 1, oils_i18n_gettext(
10, 'Long-Overdue Materials Processing Fee', 'cbt', 'name'));
+-- org settings
+
INSERT INTO config.org_unit_setting_type
(name, grp, datatype, label, description) VALUES
(
-- Org unit setting "circ.charge_lost_on_zero" applies to LOST and
-- LONGOVERDUE, so it is not duplicated here.
+
+-- mark long-overdue reactor
+
+INSERT INTO action_trigger.reactor (module, description) VALUES
+( 'MarkItemLongOverdue',
+ oils_i18n_gettext(
+ 'MarkItemLongOverdue',
+ 'Marks a circulating item as long-overdue and applies configured ' ||
+ 'penalties. Also creates events for the longoverdue.auto hook',
+ 'atreact',
+ 'description'
+ )
+);
+
+INSERT INTO action_trigger.event_definition
+ (id, active, owner, name, hook, validator, reactor, delay, delay_field)
+VALUES (
+ 49, FALSE, 1, '6 Month Overdue Mark Long-Overdue',
+ 'checkout.due', 'CircIsOverdue',
+ 'MarkItemLongOverdue', '6 months', 'due_date'
+);
+
+INSERT INTO action_trigger.event_params (event_def, param, value) VALUES
+ (49, 'editor', '''1''');
+
+-- new longervdue.auto hook.
+
+INSERT INTO action_trigger.hook (key,core_type,description) VALUES (
+ 'longoverdue.auto',
+ 'circ',
+ 'Circulating Item automatically marked long-overdue'
+);
+
+-- sample longoverdue.auto notification reactor
+
+INSERT INTO action_trigger.event_definition
+ (id, active, owner, name, hook, validator, reactor, group_field, template)
+ VALUES (
+ 50, FALSE, 1, '90 Day Overdue Mark Long Overdue Notice',
+ 'longoverdue.auto', 'NOOP_True', 'SendEmail', 'usr',
+$$
+[%- 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.family_name %], [% user.first_given_name %]
+The following items are 6 months overdue and have been marked Long 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 %]
+ Shelving Location: [% circ.target_copy.location.name %]
+ Barcode: [% circ.target_copy.barcode %]
+ Due: [% date.format(helpers.format_date(circ.due_date), '%Y-%m-%d') %]
+ Item Cost: [% helpers.get_copy_price(circ.target_copy) %]
+ Total Owed For Transaction: [% circ.billable_transaction.summary.balance_owed %]
+ Library: [% circ.circ_lib.name %]
+
+[% END %]
+$$);
+
+-- ENV for above
+
+INSERT INTO action_trigger.environment (event_def, path) VALUES
+ (50, 'target_copy.call_number'),
+ (50, 'usr'),
+ (50, 'billable_transaction.summary'),
+ (50, 'circ_lib.billing_address'),
+ (50, 'target_copy.location');
+
+
ROLLBACK;
--COMMIT;