Created
January 30, 2023 19:55
-
-
Save HitScan/281b64ee93c90c413be6db413c7b8ae6 to your computer and use it in GitHub Desktop.
AutorenewNotification template with sorting and conditional subject
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[%- USE date; | |
user = target.0.usr; | |
fcirc = []; | |
fdata = []; | |
rcirc = []; | |
rdata = []; | |
FOR circ IN target; | |
SET idx = loop.count - 1; | |
SET udata = user_data.$idx; | |
IF udata.is_renewed; | |
rcirc.push(circ); | |
rdata.push(udata); | |
ELSE; | |
fcirc.push(circ); | |
fdata.push(udata); | |
END; | |
END; | |
-%] | |
To: [% params.recipient_email || user.email %] | |
From: noreply@your-server-org | |
Date: [% date.format(date.now, '%a, %d %b %Y %T -0000', gmt => 1) %] | |
Subject: [% IF fcirc.size > 0 %]Some Items Were Not Auto-Renewed[% ELSE %]Auto-Renewal Notification[% END %] | |
Auto-Submitted: auto-generated | |
Dear [% user.pref_first_given_name || user.first_given_name %], | |
[% IF fcirc.size > 0 %] | |
The following items could NOT be renewed and remain due on the original date: | |
[% FOR circ IN fcirc; | |
SET idx = loop.count - 1; | |
SET udata = fdata.$idx; | |
SET cid = circ.target_copy.id || udata.copy; | |
SET copy_details = helpers.get_copy_bib_basics(cid); | |
-%] | |
[%- msg = BLOCK -%][%- udata.reason | remove('^.*: *') -%][%- END -%] | |
[% loop.count %]. [% copy_details.title %][% IF copy_details.author %] by [% copy_details.author %][% END %] | |
Call number: [% circ.target_copy.call_number.label %] | |
Barcode: [% circ.target_copy.barcode %] | |
Could not be renewed because: [% IF msg == "" %][% udata.reason | remove(' *: *') %][% ELSE %][% msg %][% END %] | |
Due: [% date.format(helpers.format_date(circ.due_date), '%A, %b %d, %Y') %] | |
[% END %] | |
[%- END %] | |
[% IF rcirc.size > 0 %]The following items have been renewed automatically: | |
[% FOR circ IN rcirc; | |
SET idx = loop.count - 1; | |
SET udata = rdata.$idx; | |
NEXT UNLESS udata.is_renewed; | |
SET cid = circ.target_copy.id || udata.copy; | |
SET copy_details = helpers.get_copy_bib_basics(cid) -%] | |
[% loop.count %]. [% copy_details.title %][% IF copy_details.author %] by [% copy_details.author %][% END %] | |
Call number: [% circ.target_copy.call_number.label %] | |
Barcode: [% circ.target_copy.barcode %] | |
Due: [% date.format(helpers.format_date(udata.new_due_date), '%A, %b %d, %Y') %] | |
[% END %] | |
[%- END %] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment