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>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
David Cook 2025-03-11 05:00:18 +00:00 committed by Katrin Fischer
parent e1372bacdf
commit 4daf0b7982
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
2 changed files with 4 additions and 0 deletions

View File

@ -926,6 +926,9 @@
<!-- /.rows -->
<fieldset class="action">
<input type="hidden" name="op" value="run" />
[% IF ( template_id ) %]
<input type="hidden" name="template" value="[% template_id %]" />
[% END %]
<button type="submit" class="btn btn-primary">Run the report</button>
</fieldset>
</form>

View File

@ -971,6 +971,7 @@ if ( $op eq 'run' ) {
'auth_val_errors' => \@authval_errors,
'enter_params' => 1,
'id' => $report_id,
'template_id' => $template_id,
);
} else {
my ( $sql, $header_types ) = $report->prep_report( \@param_names, \@sql_params );