alynn26

Autorenewal Notice

Oct 1st, 2021 (edited)
129
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. Date: [% date.format(date.now, '%a, %d %b %Y %T -0000', gmt => 1) %]
  27. Subject: [% IF fcirc.size > 0 %]Some Items Were Not Auto-Renewed[% ELSE %]Auto-Renewal Notification[% END %]
  28. Auto-Submitted: auto-generated
  29.  
  30. Dear [% user.pref_first_given_name || user.first_given_name %],
  31. [% IF fcirc.size > 0 %]
  32. The following items could NOT be renewed and remain due on the original date:
  33.  
  34. [% FOR circ IN fcirc;
  35. SET idx = loop.count - 1;
  36. SET udata = fdata.$idx;
  37. SET cid = circ.target_copy.id || udata.copy;
  38. SET copy_details = helpers.get_copy_bib_basics(cid);
  39. -%]
  40. [%- msg = BLOCK -%][%- udata.reason | remove('^.*: *') -%][%- END -%]
  41. [% loop.count %]. [% copy_details.title %][% IF copy_details.author %] by [% copy_details.author %][% END %]
  42. Call number: [% circ.target_copy.call_number.label %]
  43. Barcode: [% circ.target_copy.barcode %]
  44. Could not be renewed because: [% IF msg == "" %][% udata.reason | remove(' *: *') %][% ELSE %][% msg %][% END %]
  45. Due: [% date.format(helpers.format_date(circ.due_date), '%A, %b %d, %Y') %]
  46. [% END %]
  47. [%- END %]
  48.  
  49. [% IF rcirc.size > 0 %]The following items have been renewed automatically:
  50.  
  51. [% FOR circ IN rcirc;
  52. SET idx = loop.count - 1;
  53. SET udata = rdata.$idx;
  54. NEXT UNLESS udata.is_renewed;
  55. SET cid = circ.target_copy.id || udata.copy;
  56. SET copy_details = helpers.get_copy_bib_basics(cid) -%]
  57. [% loop.count %]. [% copy_details.title %][% IF copy_details.author %] by [% copy_details.author %][% END %]
  58. Call number: [% circ.target_copy.call_number.label %]
  59. Barcode: [% circ.target_copy.barcode %]
  60. Due: [% date.format(helpers.format_date(udata.new_due_date), '%A, %b %d, %Y') %]
  61. [% END %]
  62. [%- END %]
Add Comment
Please, Sign In to add comment