[Bug 38621] New: [% today %] variable unavailable in report templates
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38621 Bug ID: 38621 Summary: [% today %] variable unavailable in report templates Change sponsored?: --- Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: minor Priority: P5 - low Component: Notices Assignee: koha-bugs@lists.koha-community.org Reporter: caroline.cyr-la-rose@inlibro.com QA Contact: testopia@bugs.koha-community.org I tried adding a date to a report template, but it doesn't seem to work. I was told on MM that this is a bug. To recreate: 1. Create a report notice template with [% today %] 1.1. Go to Tools > Notices and slips 1.2. Click New notice > Reports 1.3. Enter a code and a name 1.4. Click Email 1.5. Enter a subject 1.6. In the message body, add some info with [% today %], here is what I used [% USE KohaDates %] [% today | $KohaDates %] [% FOREACH d IN data %] [% d.title %] [% END %] 1.7. Click Save 2. Create a report that works with this template 2.1. Go to Reports > Create from SQL 2.2. Enter a report name 2.3. In the SQL field, enter a report that would work with the template, this is what I used SELECT * from biblio limit 1 2.4. Click Save report 3. Click Run with template > Template name --> The date doesn't appear I also tried with a the simple [% today %] without the USE and without the KohaDates filter, but it doesn't show the date either. If I don't put the USE but use the filter, the template simply doesn't work (when you click Run with template > Template name, the report is displayed as normal in table form). -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38621 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jonathan.druart@gmail.com --- Comment #1 from Jonathan Druart <jonathan.druart@gmail.com> --- I know it can be confusing, but a workaround is to use: [% KohaDates.datetime_from_string | $KohaDates %] -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38621 Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |34136 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=34136 [Bug 34136] Add ability to render a report using a notice template -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38621 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |CONFIRMED CC| |dcook@prosentient.com.au -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38621 --- Comment #2 from Olivia Reynolds <olivia.reynolds@openfifth.co.uk> --- Created attachment 200020 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=200020&action=edit Bug 38621: Use GetPreparedLetter for report templates Previously, report templates were rendered using process_tt directly. This made the available variables inconsistent with other notices and slips. This patch switches to rendering report templates through the same function as other notices. To match the arguments to this system, this patch also makes the report system reference templates by their code rather than ID. Test plan: 1. Under Tools > Notices and Slips, create a new notice in the Reports module. Choose a code and a name, and under Email assign a subject and the following body: [% today %] [% FOREACH d IN data %] [% d.title %] [% END %] 2. Under Reports, create a new report from SQL with a name and the following query: SELECT * FROM biblio LIMIT 1 3. Create another report from SQL with a different name and the following query, specifying a runtime parameter: SELECT * FROM biblio WHERE 'a'=<<Param>> LIMIT 1 4. On the first report, select "Run with template" and choose the template created earlier. 5. Verify that the report runs successfully, and the output does not include the current date. 6. On the second report, select "Run with template" and choose the template created earlier. Choose "a" as the runtime parameter value when asked. 7. Verify that the report runs successfully, and the output does not include the current date. 8. Apply patch. 9. On the first report, select "Run with template" and choose the template created earlier. 10. Verify that the report runs successfully, and the output now includes the current date along with the fetched data. 11. Under the Download dropdown, select "Rendered template (...)". 12. Verify the downloaded file matches the report output. 13. On the second report, select "Run with template" and choose the template created earlier. Choose "a" as the runtime parameter value when asked. 14. Verify that the report runs successfully, and the output now includes the current date along with the fetched data. 15. Under the Download dropdown, select "Rendered template (...)". 16. Verify the downloaded file matches the report output. Sponsored-by: Open Fifth -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38621 Olivia Reynolds <olivia.reynolds@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|CONFIRMED |Needs Signoff CC| |olivia.reynolds@openfifth.c | |o.uk -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38621 Olivia Reynolds <olivia.reynolds@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Patch complexity|--- |Small patch -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38621 Olivia Reynolds <olivia.reynolds@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |olivia.reynolds@openfifth.c |ity.org |o.uk -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38621 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Sponsorship status|--- |Sponsored Status|Needs Signoff |Signed Off Comma delimited| |Open Fifth list of Sponsors| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38621 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #200020|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38621 --- Comment #3 from David Nind <david@davidnind.com> --- Created attachment 200036 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=200036&action=edit Bug 38621: Use GetPreparedLetter for report templates Previously, report templates were rendered using process_tt directly. This made the available variables inconsistent with other notices and slips. This patch switches to rendering report templates through the same function as other notices. To match the arguments to this system, this patch also makes the report system reference templates by their code rather than ID. Test plan: 1. Under Tools > Notices and Slips, create a new notice in the Reports module. Choose a code and a name, and under Email assign a subject and the following body: [% today %] [% FOREACH d IN data %] [% d.title %] [% END %] 2. Under Reports, create a new report from SQL with a name and the following query: SELECT * FROM biblio LIMIT 1 3. Create another report from SQL with a different name and the following query, specifying a runtime parameter: SELECT * FROM biblio WHERE 'a'=<<Param>> LIMIT 1 4. On the first report, select "Run with template" and choose the template created earlier. 5. Verify that the report runs successfully, and the output does not include the current date. 6. On the second report, select "Run with template" and choose the template created earlier. Choose "a" as the runtime parameter value when asked. 7. Verify that the report runs successfully, and the output does not include the current date. 8. Apply patch. 9. On the first report, select "Run with template" and choose the template created earlier. 10. Verify that the report runs successfully, and the output now includes the current date along with the fetched data. 11. Under the Download dropdown, select "Rendered template (...)". 12. Verify the downloaded file matches the report output. 13. On the second report, select "Run with template" and choose the template created earlier. Choose "a" as the runtime parameter value when asked. 14. Verify that the report runs successfully, and the output now includes the current date along with the fetched data. 15. Under the Download dropdown, select "Rendered template (...)". 16. Verify the downloaded file matches the report output. Sponsored-by: Open Fifth Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38621 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |david@davidnind.com --- Comment #4 from David Nind <david@davidnind.com> --- Thanks for the great test plan! Testing notes (using KTD) ========================= Report 1 -------- Before: E Street shuffle : After: 2026-06-05 21:03 E Street shuffle : Rendered report display (has a blank line between the date and title): 2026-06-05 21:05 E Street shuffle : Report 2 -------- Before: E Street shuffle : After: 2026-06-05 21:07 E Street shuffle : Rendered report display (has a blank line between the date and title): 2026-06-05 21:07 E Street shuffle : -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38621 --- Comment #5 from Jonathan Druart <jonathan.druart@gmail.com> --- I am wondering if we shouldn't also adjust C4::Reports::Guided::EmailReport -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38621 --- Comment #6 from Olivia Reynolds <olivia.reynolds@openfifth.co.uk> --- I've written a patch to make the same change to EmailReport - thanks for pointing out it's a similar case. Would that be best as an additional patch on this bug or separately? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38621 --- Comment #7 from Jonathan Druart <jonathan.druart@gmail.com> --- (In reply to Olivia Reynolds from comment #6)
I've written a patch to make the same change to EmailReport - thanks for pointing out it's a similar case.
Would that be best as an additional patch on this bug or separately?
I think it should go on this bug report as well. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38621 Olivia Reynolds <olivia.reynolds@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38621 --- Comment #8 from Olivia Reynolds <olivia.reynolds@openfifth.co.uk> --- Created attachment 200149 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=200149&action=edit Bug 38621: Use GetPreparedLetter in EmailReport As with guided reports through the admin interface, this patch switches EmailReport to use the same function for processing templates. This gives patron emails sent via cronjobs access to the same variables as other report locations. Test plan: 1. Under Tools > Notices and Slips, create a new notice in the Reports module. Choose a code and a name, and under Email assign a subject and the following body: Date: [% today %] 2. Under Reports, create a new report from SQL with a name and the following query: SELECT 1 AS borrowernumber, 'to@example.com' AS email 3. Run the following command from the base of Koha, replacing CODE with the notice code created earlier, and ID with the report ID created earlier: misc/cronjobs/patron_emailer.pl -module report -from from@example.com -notice CODE -report ID 4. Verify that the report runs successfully, and the console output includes "Date:" on a line with nothing following it. 5. Apply patch. 6. Run the following command from the base of Koha, replacing CODE with the notice code created earlier, and ID with the report ID created earlier: misc/cronjobs/patron_emailer.pl -module report -from from@example.com -notice CODE -report ID 7. Verify that the report runs successfully, and the console output includes "Date:" on a line with the current time following it. 8. Run `prove t/db_dependent/Reports/Guided.t`, and verify it passes. Sponsored-by: Open Fifth -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38621 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38621 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #200036|0 |1 is obsolete| | Attachment #200149|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38621 --- Comment #9 from David Nind <david@davidnind.com> --- Created attachment 200188 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=200188&action=edit Bug 38621: Use GetPreparedLetter for report templates Previously, report templates were rendered using process_tt directly. This made the available variables inconsistent with other notices and slips. This patch switches to rendering report templates through the same function as other notices. To match the arguments to this system, this patch also makes the report system reference templates by their code rather than ID. Test plan: 1. Under Tools > Notices and Slips, create a new notice in the Reports module. Choose a code and a name, and under Email assign a subject and the following body: [% today %] [% FOREACH d IN data %] [% d.title %] [% END %] 2. Under Reports, create a new report from SQL with a name and the following query: SELECT * FROM biblio LIMIT 1 3. Create another report from SQL with a different name and the following query, specifying a runtime parameter: SELECT * FROM biblio WHERE 'a'=<<Param>> LIMIT 1 4. On the first report, select "Run with template" and choose the template created earlier. 5. Verify that the report runs successfully, and the output does not include the current date. 6. On the second report, select "Run with template" and choose the template created earlier. Choose "a" as the runtime parameter value when asked. 7. Verify that the report runs successfully, and the output does not include the current date. 8. Apply patch. 9. On the first report, select "Run with template" and choose the template created earlier. 10. Verify that the report runs successfully, and the output now includes the current date along with the fetched data. 11. Under the Download dropdown, select "Rendered template (...)". 12. Verify the downloaded file matches the report output. 13. On the second report, select "Run with template" and choose the template created earlier. Choose "a" as the runtime parameter value when asked. 14. Verify that the report runs successfully, and the output now includes the current date along with the fetched data. 15. Under the Download dropdown, select "Rendered template (...)". 16. Verify the downloaded file matches the report output. Sponsored-by: Open Fifth Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38621 --- Comment #10 from David Nind <david@davidnind.com> --- Created attachment 200189 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=200189&action=edit Bug 38621: Use GetPreparedLetter in EmailReport As with guided reports through the admin interface, this patch switches EmailReport to use the same function for processing templates. This gives patron emails sent via cronjobs access to the same variables as other report locations. Test plan: 1. Under Tools > Notices and Slips, create a new notice in the Reports module. Choose a code and a name, and under Email assign a subject and the following body: Date: [% today %] 2. Under Reports, create a new report from SQL with a name and the following query: SELECT 1 AS borrowernumber, 'to@example.com' AS email 3. Run the following command from the base of Koha, replacing CODE with the notice code created earlier, and ID with the report ID created earlier: misc/cronjobs/patron_emailer.pl -module report -from from@example.com -notice CODE -report ID 4. Verify that the report runs successfully, and the console output includes "Date:" on a line with nothing following it. 5. Apply patch. 6. Run the following command from the base of Koha, replacing CODE with the notice code created earlier, and ID with the report ID created earlier: misc/cronjobs/patron_emailer.pl -module report -from from@example.com -notice CODE -report ID 7. Verify that the report runs successfully, and the console output includes "Date:" on a line with the current time following it. 8. Run `prove t/db_dependent/Reports/Guided.t`, and verify it passes. Sponsored-by: Open Fifth Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38621 Lisette Scheer <lisette@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact|testopia@bugs.koha-communit |lisette@bywatersolutions.co |y.org |m Status|Signed Off |Passed QA --- Comment #11 from Lisette Scheer <lisette@bywatersolutions.com> --- Works great, looking forward to this. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38621 Lisette Scheer <lisette@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #200188|0 |1 is obsolete| | Attachment #200189|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38621 --- Comment #12 from Lisette Scheer <lisette@bywatersolutions.com> --- Created attachment 201107 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=201107&action=edit Bug 38621: Use GetPreparedLetter for report templates Previously, report templates were rendered using process_tt directly. This made the available variables inconsistent with other notices and slips. This patch switches to rendering report templates through the same function as other notices. To match the arguments to this system, this patch also makes the report system reference templates by their code rather than ID. Test plan: 1. Under Tools > Notices and Slips, create a new notice in the Reports module. Choose a code and a name, and under Email assign a subject and the following body: [% today %] [% FOREACH d IN data %] [% d.title %] [% END %] 2. Under Reports, create a new report from SQL with a name and the following query: SELECT * FROM biblio LIMIT 1 3. Create another report from SQL with a different name and the following query, specifying a runtime parameter: SELECT * FROM biblio WHERE 'a'=<<Param>> LIMIT 1 4. On the first report, select "Run with template" and choose the template created earlier. 5. Verify that the report runs successfully, and the output does not include the current date. 6. On the second report, select "Run with template" and choose the template created earlier. Choose "a" as the runtime parameter value when asked. 7. Verify that the report runs successfully, and the output does not include the current date. 8. Apply patch. 9. On the first report, select "Run with template" and choose the template created earlier. 10. Verify that the report runs successfully, and the output now includes the current date along with the fetched data. 11. Under the Download dropdown, select "Rendered template (...)". 12. Verify the downloaded file matches the report output. 13. On the second report, select "Run with template" and choose the template created earlier. Choose "a" as the runtime parameter value when asked. 14. Verify that the report runs successfully, and the output now includes the current date along with the fetched data. 15. Under the Download dropdown, select "Rendered template (...)". 16. Verify the downloaded file matches the report output. Sponsored-by: Open Fifth Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Lisette Scheer <lisette@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38621 --- Comment #13 from Lisette Scheer <lisette@bywatersolutions.com> --- Created attachment 201108 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=201108&action=edit Bug 38621: Use GetPreparedLetter in EmailReport As with guided reports through the admin interface, this patch switches EmailReport to use the same function for processing templates. This gives patron emails sent via cronjobs access to the same variables as other report locations. Test plan: 1. Under Tools > Notices and Slips, create a new notice in the Reports module. Choose a code and a name, and under Email assign a subject and the following body: Date: [% today %] 2. Under Reports, create a new report from SQL with a name and the following query: SELECT 1 AS borrowernumber, 'to@example.com' AS email 3. Run the following command from the base of Koha, replacing CODE with the notice code created earlier, and ID with the report ID created earlier: misc/cronjobs/patron_emailer.pl -module report -from from@example.com -notice CODE -report ID 4. Verify that the report runs successfully, and the console output includes "Date:" on a line with nothing following it. 5. Apply patch. 6. Run the following command from the base of Koha, replacing CODE with the notice code created earlier, and ID with the report ID created earlier: misc/cronjobs/patron_emailer.pl -module report -from from@example.com -notice CODE -report ID 7. Verify that the report runs successfully, and the console output includes "Date:" on a line with the current time following it. 8. Run `prove t/db_dependent/Reports/Guided.t`, and verify it passes. Sponsored-by: Open Fifth Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Lisette Scheer <lisette@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38621 Pedro Amorim (ammopt) <pedro.amorim@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Pushed to main Version(s)| |26.11.00 released in| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38621 --- Comment #14 from Pedro Amorim (ammopt) <pedro.amorim@openfifth.co.uk> --- Thanks everyone! Pushed to main for 26.11! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38621 Lucas Gass (lukeg) <lucas@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |lucas@bywatersolutions.com Status|Pushed to main |Needs documenting --- Comment #15 from Lucas Gass (lukeg) <lucas@bywatersolutions.com> --- Enhancement will not be backported to 26.05.x -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org