Bug 27443

Summary: Add an item loop mechanism to patron_emailer.pl cron
Product: Koha Reporter: Andrew Fuerste-Henry <andrew>
Component: NoticesAssignee: Bugs List <koha-bugs>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: bwsdonna, kelly, kyle, nick, r.delahunty
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:

Description Andrew Fuerste-Henry 2021-01-15 18:27:39 UTC
It'd be great if the patron emailer provided an easy way to replicate something like the <item></item> section of an overdue notice of the <<items.content>> section of DUE notice. Perhaps we teach the emailer that if the report contains a column of comma-separated itemnumers named "items_content", we could iterate through something like the existing items.content functionality for every itemnumber included?
Comment 1 Katrin Fischer 2021-01-16 19:56:04 UTC
Afaik the patron emailer is a plugin (even if I'd like it to be a feature in Koha :) ). So we probably should close that here?
Comment 2 Andrew Fuerste-Henry 2021-01-16 20:00:25 UTC
I meant the cron: https://github.com/Koha-Community/Koha/blob/master/misc/cronjobs/patron_emailer.pl

The cron is essentially just a commandline version of the plugin. If we teach the cron to do cool things, we should also hassle Nick into teaching the same things to the plugin :)
Comment 3 Katrin Fischer 2021-01-16 20:01:17 UTC
Could we also hassle him to move the GUI for it into core? :)
Comment 4 Andrew Fuerste-Henry 2021-01-16 20:07:36 UTC
We can try! ¯\_(ツ)_/¯
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27452
Comment 5 Katrin Fischer 2023-07-01 16:13:45 UTC
Looking at some of the examples on the Bywater Blog it seemed like listing items was possible with TT syntax (but it seems posts might no longer be available?)

What should we do with this bug? WONTFIX?
Comment 6 Ray Delahunty 2023-08-10 07:18:17 UTC
We are using the Koha patron emailer (introduced in 19.05) rather than the Bywater plugin for our leavers (chasing them before they leave for items on loan to be returned) and have been trying to use template toolkit inside the notice so it can send different wordings to different patron groups (like we have it doing for MEMBERSHIP_EXPIRY, for example), but the testing has failed. Had it worked, our plan was to try the [% FOREACH checkout IN checkouts %] loop from the AUTO_RENEWAL_DGST to improve the horrid word-wrapped list of items on loan, pulled from the report. Our support company said: "the patron emailer doesn't yet support HTML, and I highly doubt that it would support template toolkit either". Might the answer be to improve the patron emailer so it accepts TT (and also html)?
Comment 7 Katrin Fischer 2023-10-28 19:17:41 UTC
(In reply to Ray Delahunty from comment #6)
> word-wrapped list of items on loan, pulled from the report. Our support
> company said: "the patron emailer doesn't yet support HTML, and I highly
> doubt that it would support template toolkit either". Might the answer be to
> improve the patron emailer so it accepts TT (and also html)?

It seems strange that the cron should be so different from the in-built functionality?
Comment 8 Ray Delahunty 2023-12-06 07:13:00 UTC
Apologies- on 22.11 I have notices being sent by the patron_emailer.pl script working perfectly with html, and the fields pulled in from the report must use TT notation so html and at least some TT is supported. All I can assume from earlier failures (ages back) must be down to specific objects/ variables that either aren’t fully supported (or more likely!) I had syntax errors in my TT code.
Comment 9 Ray Delahunty 2024-06-02 08:54:23 UTC
While we wait for the patron emailer to have something like an <item></item> feature addded, so titles on a loan list (for example) will appear on separate lines, we are using a SEPARATOR with a GROUP CONCAT to improve the the horrid word-wrapped list in our leavers emails. We feed the list to a notice using the loans field:       
(SELECT  GROUP_CONCAT(
 ExtractValue(metadata,'//datafield[@tag="245"]/subfield[@code>="a"]') SEPARATOR '<br/>')
 FROM [...] AS 'loans'
Works OK.