Bug 39298 - Runtime parameters don't work with report templates on first run
Summary: Runtime parameters don't work with report templates on first run
Status: Pushed to main
Alias: None
Product: Koha
Classification: Unclassified
Component: Reports (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: David Cook
QA Contact: Julian Maurice
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-03-11 04:48 UTC by David Cook
Modified: 2025-04-11 07:56 UTC (History)
2 users (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
25.05.00
Circulation function:


Attachments
Bug 39298: Add runtime parameter support to report templates (2.49 KB, patch)
2025-03-11 05:03 UTC, David Cook
Details | Diff | Splinter Review
Bug 39298: Add runtime parameter support to report templates (2.54 KB, patch)
2025-03-11 08:58 UTC, David Nind
Details | Diff | Splinter Review
Bug 39298: Add runtime parameter support to report templates (2.59 KB, patch)
2025-04-02 13:34 UTC, Julian Maurice
Details | Diff | Splinter Review
Bug 39298: (QA follow-up) Add missing html filter (1.35 KB, patch)
2025-04-02 13:34 UTC, Julian Maurice
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description David Cook 2025-03-11 04:48:49 UTC
If you have a SQL report with runtime parameters, and you click "Run with template", it'll prompt for runtime parameter inputs, but then it will render a normal SQL output and not the template output.

If you do the same thing again, it will work the second time, because the param_name and sql_params URL parameters are now added to the link.
Comment 1 David Cook 2025-03-11 05:03:51 UTC
Created attachment 179136 [details] [review]
Bug 39298: Add runtime parameter support to report templates

This change makes it so that you can provide runtime parameters
and use "Run with template".

Test plan:
0. Apply the patch and koha-plack --restart kohadev
1. Create a report template. For example:
<table>
<tr><th>Transformed Biblionumber</th></tr>
[% FOREACH row IN data %]
<tr><td>Biblionumber [% row.biblionumber %]</td></tr>
[% END %]
</table>
2. Create a SQL report with a runtime parameter. For example:
SELECT biblionumber
FROM biblio
WHERE biblionumber > <<biblionumber>>
3. Run the report using "Run with template"
4. Specify a biblionumber of 1
5. Click "Run the report"
6. Note that the output is the template output and not regular
SQL output
Comment 2 David Nind 2025-03-11 08:58:15 UTC
Created attachment 179145 [details] [review]
Bug 39298: Add runtime parameter support to report templates

This change makes it so that you can provide runtime parameters
and use "Run with template".

Test plan:
0. Apply the patch and koha-plack --restart kohadev
1. Create a report template. For example:
<table>
<tr><th>Transformed Biblionumber</th></tr>
[% FOREACH row IN data %]
<tr><td>Biblionumber [% row.biblionumber %]</td></tr>
[% END %]
</table>
2. Create a SQL report with a runtime parameter. For example:
SELECT biblionumber
FROM biblio
WHERE biblionumber > <<biblionumber>>
3. Run the report using "Run with template"
4. Specify a biblionumber of 1
5. Click "Run the report"
6. Note that the output is the template output and not regular
SQL output

Signed-off-by: David Nind <david@davidnind.com>
Comment 3 David Nind 2025-03-11 09:02:31 UTC
Testing notes (using KTD) - replicating the issue before applying the patch:

1. The first time you run the report using the report template option, it will look like a normal report result - with standard pagination and a column with just the biblionumber.

2. If you then go "Run with template" again, you will then get your customised output, in this case a table with all the results formatted using the template: a table heading called "Transformed Biblionumber" and then rows with "Biblionumber X" (where X = a number).
Comment 4 Julian Maurice 2025-04-02 13:34:20 UTC
Created attachment 180354 [details] [review]
Bug 39298: Add runtime parameter support to report templates

This change makes it so that you can provide runtime parameters
and use "Run with template".

Test plan:
0. Apply the patch and koha-plack --restart kohadev
1. Create a report template. For example:
<table>
<tr><th>Transformed Biblionumber</th></tr>
[% FOREACH row IN data %]
<tr><td>Biblionumber [% row.biblionumber %]</td></tr>
[% END %]
</table>
2. Create a SQL report with a runtime parameter. For example:
SELECT biblionumber
FROM biblio
WHERE biblionumber > <<biblionumber>>
3. Run the report using "Run with template"
4. Specify a biblionumber of 1
5. Click "Run the report"
6. Note that the output is the template output and not regular
SQL output

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Comment 5 Julian Maurice 2025-04-02 13:34:23 UTC
Created attachment 180355 [details] [review]
Bug 39298: (QA follow-up) Add missing html filter

Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Comment 6 Julian Maurice 2025-04-02 13:36:26 UTC
I didn't know about the report template feature, so for future references: report templates are created with the "Notices & slips" tool.
Comment 7 David Cook 2025-04-02 22:36:24 UTC
(In reply to Julian Maurice from comment #6)
> I didn't know about the report template feature, so for future references:
> report templates are created with the "Notices & slips" tool.

I only learned about it recently myself. It managed to sneak into Koha without too much advertisement I think. 

A scary feature in a number of ways, but also quite interesting. Using bug 39296 a person can use the entire MARC record for generating reports.
Comment 8 Katrin Fischer 2025-04-11 07:56:05 UTC
Pushed for 25.05!

Well done everyone, thank you!