Bugzilla – Attachment 157694 Details for
Bug 34136
Add ability to render a report using a notice template
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34136: Add ability to render a report using a notice template
Bug-34136-Add-ability-to-render-a-report-using-a-n.patch (text/plain), 8.18 KB, created by
Katrin Fischer
on 2023-10-23 21:59:26 UTC
(
hide
)
Description:
Bug 34136: Add ability to render a report using a notice template
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2023-10-23 21:59:26 UTC
Size:
8.18 KB
patch
obsolete
>From 8cbe7f888c22cb97c20d42df7c123d79ecd2953d Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Tue, 27 Jun 2023 12:44:18 -0400 >Subject: [PATCH] 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> >--- > .../prog/en/includes/reports-toolbar.inc | 17 +++++++++++++++++ > .../en/modules/reports/guided_reports_start.tt | 4 +++- > .../prog/en/modules/tools/letter.tt | 7 +++++++ > reports/guided_reports.pl | 14 ++++++++++++++ > 4 files changed, 41 insertions(+), 1 deletion(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc >index ba5b9d3d92..de76725e8c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc >@@ -63,6 +63,23 @@ > <i class="fa fa-play"></i> Run report > </a> > </div> >+ [% IF templates.count %] >+ <div class="btn-group"> >+ <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" >+ aria-expanded="false"> >+ <i class="fa fa-code"></i> Run with template <span class="caret"></span> >+ </button> >+ <ul class="dropdown-menu"> >+ [% FOREACH t IN templates %] >+ <li> >+ <a id="runreport" class="btn btn-default" href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% id | html %]&phase=Run%20this%20report&template=[% t.id | html %][% PROCESS params %]"> >+ [% t.name | html %] >+ </a> >+ </li> >+ [% END %] >+ </ul> >+ </div> >+ [% END %] > <div class="btn-group"> > <a class="btn btn-default" href="/cgi-bin/koha/tools/scheduler.pl?id=[% id | html %]"> > <i class="fa-solid fa-clock"></i> Schedule >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt >index 98812c4420..07f18eb2a9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt >@@ -903,7 +903,9 @@ > </form> > [% END # /IF ( enter_params ) %] > >- [% IF ( execute ) %] >+ [% IF processed_notice %] >+ [% processed_notice | $raw %] >+ [% ELSIF ( execute ) %] > <h1>[% name | html %] <span class="report_heading_id"><span class="report_label">Report ID:</span> <span class="report_number">[% id | html %]</span></span></h1> > <div class="page-section"> > [% IF ( notes ) %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt >index 79e660255c..f25d9a3340 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt >@@ -172,6 +172,7 @@ > <li><a href="/cgi-bin/koha/tools/letter.pl?op=add_form&module=serial">Serials (new issue)</a></li> > <li><a href="/cgi-bin/koha/tools/letter.pl?op=add_form&module=suggestions">Suggestions</a></li> > <li><a href="/cgi-bin/koha/tools/letter.pl?op=add_form&module=pos">Point of sale</a></li> >+ <li><a href="/cgi-bin/koha/tools/letter.pl?op=add_form&module=report">Report</a></li> > </ul> > </div> > </div> <!-- /#toolbar --> >@@ -230,6 +231,7 @@ > [% CASE 'serial' %]<span>Serials (new issue)</span> > [% CASE 'suggestions' %]<span>Suggestions</span> > [% CASE 'pos' %]<span>Point of sale</span> >+ [% CASE 'report' %]<span>Report</span> > [% CASE %]<span>[% lette.module | html %]</span> > [% END %] > </td> >@@ -411,6 +413,11 @@ > [% ELSE %] > <option value="pos">Point of sale</option> > [% END %] >+ [% IF ( module == "report" ) %] >+ <option value="report" selected="selected">Report</option> >+ [% ELSE %] >+ <option value="report">Report</option> >+ [% END %] > </select> > </li> > <li> >diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl >index 46792bf88c..e8c8941d46 100755 >--- a/reports/guided_reports.pl >+++ b/reports/guided_reports.pl >@@ -37,6 +37,8 @@ use Koha::Libraries; > use Koha::Patron::Categories; > use Koha::SharedContent; > use Koha::Util::OpenDocument qw( generate_ods ); >+use Koha::Notice::Templates; >+use Koha::TemplateUtils qw( process_tt ); > use C4::ClassSource qw( GetClassSources ); > > =head1 NAME >@@ -79,6 +81,8 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( > my $session_id = $input->cookie('CGISESSID'); > my $session = $session_id ? get_session($session_id) : undef; > >+$template->param( templates => Koha::Notice::Templates->search({ module => 'report' }) ); >+ > my $filter; > if ( $input->param("filter_set") or $input->param('clear_filters') ) { > $filter = {}; >@@ -671,6 +675,7 @@ elsif ($phase eq 'Run this report'){ > my $report_id = $input->param('reports'); > my @sql_params = $input->multi_param('sql_params'); > my @param_names = $input->multi_param('param_name'); >+ my $template_id = $input->param('template'); > my $want_full_chart = $input->param('want_full_chart') || 0; > > # offset algorithm >@@ -872,6 +877,15 @@ elsif ($phase eq 'Run this report'){ > $url = join('&sql_params=', $url, map { URI::Escape::uri_escape_utf8($_) } @sql_params); > } > >+ if ($template_id) { >+ my $notice_template = Koha::Notice::Templates->find($template_id); >+ my ( $sth2, $errors2 ) = execute_query( { sql => $sql, report_id => $report_id } ); >+ my $data = $sth2->fetchall_arrayref( {} ); >+ my $notice_rendered = >+ process_tt( $notice_template->content, { data => $data, report_id => $report_id } ); >+ $template->param( processed_notice => $notice_rendered ); >+ } >+ > $template->param( > 'results' => \@rows, > 'allresults' => \@allrows, >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 34136
:
152769
|
153100
|
154153
|
154227
| 157694 |
157695
|
157696