alynn26

Autorenewal Notice

Oct 1st, 2021 (edited)
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. [%- USE date;
  2. user = target.0.usr;
  3. fcirc = [];
  4. fdata = [];
  5. rcirc = [];
  6. rdata = [];
  7.  
  8. FOR circ IN target;
  9. ddate = date.format(helpers.format_date(circ.due_date), '%s');
  10. IF '00:59' == date.format(ddate, '%H:%M');
  11. ddate = ddate - 3600;
  12. circ.due_date = date.format(ddate, '%Y-%m-%dT%H:%M:%S-0400');
  13. END;
  14. SET idx = loop.count - 1;
  15. SET udata = user_data.$idx;
  16. IF udata.is_renewed;
  17. rcirc.push(circ);
  18. rdata.push(udata);
  19. ELSE;
  20. fcirc.push(circ);
  21. fdata.push(udata);
  22. END;
  23. END;
  24. -%]
  25. To: [% params.recipient_email || user.email %]
  26. From: noreply@evergreen.lib.in.us
  27. Date: [% date.format(date.now, '%a, %d %b %Y %T -0000', gmt => 1) %]
  28. Subject: [% IF fcirc.size > 0 %]Some Items Were Not Auto-Renewed[% ELSE %]Auto-Renewal Notification[% END %]
  29. Auto-Submitted: auto-generated
  30.  
  31. Dear [% user.pref_first_given_name || user.first_given_name %],
  32. [% IF fcirc.size > 0 %]
  33. The following items could NOT be renewed and remain due on the original date:
  34.  
  35. [% FOR circ IN fcirc;
  36. SET idx = loop.count - 1;
  37. SET udata = fdata.$idx;
  38. SET cid = circ.target_copy.id || udata.copy;
  39. SET copy_details = helpers.get_copy_bib_basics(cid);
  40. -%]
  41. [%- msg = BLOCK -%][%- udata.reason | remove('^.*: *') -%][%- END -%]
  42. [% loop.count %]. [% copy_details.title %][% IF copy_details.author %] by [% copy_details.author %][% END %]
  43. Call number: [% circ.target_copy.call_number.label %]
  44. Barcode: [% circ.target_copy.barcode %]
  45. Could not be renewed because: [% IF msg == "" %][% udata.reason | remove(' *: *') %][% ELSE %][% msg %][% END %]
  46. Due: [% date.format(helpers.format_date(circ.due_date), '%A, %b %d, %Y') %]
  47. [% END %]
  48. [%- END %]
  49.  
  50. [% IF rcirc.size > 0 %]The following items have been renewed automatically:
  51.  
  52. [% FOR circ IN rcirc;
  53. SET idx = loop.count - 1;
  54. SET udata = rdata.$idx;
  55. NEXT UNLESS udata.is_renewed;
  56. SET cid = circ.target_copy.id || udata.copy;
  57. SET copy_details = helpers.get_copy_bib_basics(cid) -%]
  58. [% loop.count %]. [% copy_details.title %][% IF copy_details.author %] by [% copy_details.author %][% END %]
  59. Call number: [% circ.target_copy.call_number.label %]
  60. Barcode: [% circ.target_copy.barcode %]
  61. Due: [% date.format(helpers.format_date(udata.new_due_date), '%A, %b %d, %Y') %]
  62. [% END %]
  63. [%- END %]
Add Comment
Please, Sign In to add comment