Summary: | Add ability to render a report using a notice template | ||
---|---|---|---|
Product: | Koha | Reporter: | Kyle M Hall (khall) <kyle> |
Component: | Reports | Assignee: | Kyle M Hall (khall) <kyle> |
Status: | RESOLVED FIXED | QA Contact: | Katrin Fischer <katrin.fischer> |
Severity: | enhancement | ||
Priority: | P5 - low | CC: | andrew, caroline.cyr-la-rose, fridolin.somers, martin.renvoize, sally.healey, samalau |
Version: | Main | ||
Hardware: | All | ||
OS: | All | ||
See Also: | https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27510 | ||
Change sponsored?: | --- | Patch complexity: | --- |
Documentation contact: | Caroline Cyr La Rose | Documentation submission: | https://gitlab.com/koha-community/koha-manual/-/merge_requests/803 |
Text to go in the release notes: |
With this feature you can use a notice template for rendering the results of a report in the reports module. As you can use Template Toolkit and HTML in notices, this gives you a lot of flexibility to create for example a nice print format for your data.
Once a notice has been created with the module 'Reports' selected, you will have the option to run your report using the template.
|
Version(s) released in: |
23.11.00
|
Circulation function: | |||
Bug Depends on: | 33030 | ||
Bug Blocks: | 36513, 34456, 36158 | ||
Attachments: |
Bug 34136: Add ability to render a report using a notice template
Bug 34136: Add ability to render a report using a notice template Bug 34136: Add ability to render a report using a notice template Bug 34136: Add ability to render a report using a notice template Bug 34136: Add ability to render a report using a notice template Bug 34136: (QA follow-up) Change Report to Reports as category in notices and slips Bug 34136: (QA follow-up) Perltidy |
Description
Kyle M Hall (khall)
2023-06-27 18:20:33 UTC
Created attachment 152769 [details] [review] Bug 34136: Add ability to render a report using a notice template Sometimes it is useful to display the results of a report in a non-table format. We should be able to create notice templates to render reports. Test Plan: 1) Apply this patch 2) Restart all the things! 3) Create a new notice template using the new "Report" option from the "New notice" pulldown. 4) In the "Print" area, paste the following template: [% FOREACH b IN data %] <div class="panel panel-default"> <div class="panel-heading">[% b.surname %], [% b.firstname %]</div> <div class="panel-body">Expiration: [% b.dateexpiry %]</div> <div class="panel-footer">ID: [% b.borrowernumber %]</div> </div> [% END %] 5) Create a report with the query: SELECT * FROM borrowers 6) Once the report is saved, use the new "Run with template" option to select the template you just created. 7) Note that instead of the results being a paged table, you instead see the results rendered as cards! After I created the new notice template using the report option when I try to go to Reports and then select 'create from SQL', the page did not load and I'm left with this error: Could not compile /kohadevbox/koha/reports/guided_reports.pl: Can't locate Koha/TemplateUtils.pm in @INC (you may need to install the Koha::TemplateUtils module) (@INC contains: /kohadevbox/koha /kohadevbox/koha/lib /kohadevbox/koha/installer /kohadevbox/koha/lib/installer /etc/perl /usr/local/lib/aarch64-linux-gnu/perl/5.32.1 /usr/local/share/perl/5.32.1 /usr/lib/aarch64-linux-gnu/perl5/5.32 /usr/share/perl5 /usr/lib/aarch64-linux-gnu/perl-base /usr/lib/aarch64-linux-gnu/perl/5.32 /usr/share/perl/5.32 /usr/local/lib/site_perl /var/lib/koha/kohadev/plugins) at /kohadevbox/koha/reports/guided_reports.pl line 41. BEGIN failed--compilation aborted at /kohadevbox/koha/reports/guided_reports.pl line 41. at /usr/share/perl5/CGI/Compile.pm line 144 It is also important to note that before creating a new notice template, the report page loads perfectly fine. (In reply to Sam Lau from comment #2) > After I created the new notice template using the report option when I try > to go to Reports and then select 'create from SQL', the page did not load > and I'm left with this error: My bad! I forgot to add the dependent bug on bugzilla. Created attachment 153100 [details] [review] Bug 34136: Add ability to render a report using a notice template Sometimes it is useful to display the results of a report in a non-table format. We should be able to create notice templates to render reports. Test Plan: 1) Apply this patch 2) Restart all the things! 3) Create a new notice template using the new "Report" option from the "New notice" pulldown. 4) In the "Print" area, paste the following template: [% FOREACH b IN data %] <div class="panel panel-default"> <div class="panel-heading">[% b.surname %], [% b.firstname %]</div> <div class="panel-body">Expiration: [% b.dateexpiry %]</div> <div class="panel-footer">ID: [% b.borrowernumber %]</div> </div> [% END %] 5) Create a report with the query: SELECT * FROM borrowers 6) Once the report is saved, use the new "Run with template" option to select the template you just created. 7) Note that instead of the results being a paged table, you instead see the results rendered as cards! Signed-off-by: Sam Lau <samalau@gmail.com> Created attachment 154153 [details] [review] Bug 34136: Add ability to render a report using a notice template Sometimes it is useful to display the results of a report in a non-table format. We should be able to create notice templates to render reports. Test Plan: 1) Apply this patch 2) Restart all the things! 3) Create a new notice template using the new "Report" option from the "New notice" pulldown. 4) In the "Print" area, paste the following template: [% FOREACH b IN data %] <div class="panel panel-default"> <div class="panel-heading">[% b.surname %], [% b.firstname %]</div> <div class="panel-body">Expiration: [% b.dateexpiry %]</div> <div class="panel-footer">ID: [% b.borrowernumber %]</div> </div> [% END %] 5) Create a report with the query: SELECT * FROM borrowers 6) Once the report is saved, use the new "Run with template" option to select the template you just created. 7) Note that instead of the results being a paged table, you instead see the results rendered as cards! Signed-off-by: Sam Lau <samalau@gmail.com> This is a brilliant development - can't wait to see this in Koha. Created attachment 154227 [details] [review] Bug 34136: Add ability to render a report using a notice template Sometimes it is useful to display the results of a report in a non-table format. We should be able to create notice templates to render reports. Test Plan: 1) Apply this patch 2) Restart all the things! 3) Create a new notice template using the new "Report" option from the "New notice" pulldown. 4) In the "Print" area, paste the following template: [% FOREACH b IN data %] <div class="panel panel-default"> <div class="panel-heading">[% b.surname %], [% b.firstname %]</div> <div class="panel-body">Expiration: [% b.dateexpiry %]</div> <div class="panel-footer">ID: [% b.borrowernumber %]</div> </div> [% END %] 5) Create a report with the query: SELECT * FROM borrowers 6) Once the report is saved, use the new "Run with template" option to select the template you just created. 7) Note that instead of the results being a paged table, you instead see the results rendered as cards! Signed-off-by: Sam Lau <samalau@gmail.com> I absolutely love the idea of this. But I worry a little about usability: * The templates are likely to work only with specific reports. The list of templates could grow really long. This will create a situation where you have a long list of templates you could apply and a need to 'guess' which would work or belongs to the report. I wonder if we should not create some link between template and report that works/goes with it. * We absolutely need documentation for this: Needs to be added to print, uses a 'data' object with the db columns etc. Created attachment 157694 [details] [review] Bug 34136: Add ability to render a report using a notice template Sometimes it is useful to display the results of a report in a non-table format. We should be able to create notice templates to render reports. Test Plan: 1) Apply this patch 2) Restart all the things! 3) Create a new notice template using the new "Report" option from the "New notice" pulldown. 4) In the "Print" area, paste the following template: [% FOREACH b IN data %] <div class="panel panel-default"> <div class="panel-heading">[% b.surname %], [% b.firstname %]</div> <div class="panel-body">Expiration: [% b.dateexpiry %]</div> <div class="panel-footer">ID: [% b.borrowernumber %]</div> </div> [% END %] 5) Create a report with the query: SELECT * FROM borrowers 6) Once the report is saved, use the new "Run with template" option to select the template you just created. 7) Note that instead of the results being a paged table, you instead see the results rendered as cards! Signed-off-by: Sam Lau <samalau@gmail.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Created attachment 157695 [details] [review] Bug 34136: (QA follow-up) Change Report to Reports as category in notices and slips Looking at the other entries for the module in notices we most often use the actual module name: patrons, suggestions, holds, etc. So I updated "Report" to "Reports" to match that pattern. Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Created attachment 157696 [details] [review] Bug 34136: (QA follow-up) Perltidy Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Pushed to master for 23.11. Nice work everyone, thanks! Depends on Bug 33030 not in 23.05.x This is a very interesting feature! Thank you all. (In reply to Katrin Fischer from comment #8) > > * We absolutely need documentation for this: Needs to be added to print, > uses a 'data' object with the db columns etc. For the manual, I only reproduced the example that was here as I don't know a lot of TT except the very basic basics. We should definitely have a wiki page about this... (In reply to Caroline Cyr La Rose from comment #15) > (In reply to Katrin Fischer from comment #8) > > > > > * We absolutely need documentation for this: Needs to be added to print, > > uses a 'data' object with the db columns etc. > > For the manual, I only reproduced the example that was here as I don't know > a lot of TT except the very basic basics. We should definitely have a wiki > page about this... Agreed. A library of report/template combos would be very useful. The only times I've used this feature so far are so specific as to be useless to other libraries. I do wonder if we should have an optional template section on the existing reports library wiki page, or if we should start a separate page. |