Bug 38621

Summary: [% today %] variable unavailable in report templates
Product: Koha Reporter: Caroline Cyr La Rose <caroline.cyr-la-rose>
Component: NoticesAssignee: Bugs List <koha-bugs>
Status: CONFIRMED --- QA Contact: Testopia <testopia>
Severity: minor    
Priority: P5 - low CC: dcook, jonathan.druart
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:
Bug Depends on: 34136    
Bug Blocks:    

Description Caroline Cyr La Rose 2024-12-04 14:49:50 UTC
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).
Comment 1 Jonathan Druart 2024-12-04 15:03:25 UTC
I know it can be confusing, but a workaround is to use:
  [% KohaDates.datetime_from_string | $KohaDates %]