From a7fcf293f6557fa7c7531d556f02ba6926b47d2d Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Sat, 27 Jul 2019 13:07:18 +0000 Subject: [PATCH] Bug 23390: Introduce placeholder syntax for report column names This patch adds the ability to rename columns in MySQL reports using a syntax: [[column|alias]] To test: 1 - Write a report like: SELECT cardnumber FROM borrowers WHERE cardnumber LIKE '%9' 2 - Run report 3 - Note you can batch modify the patrons 4 - Update report: SELECT cardnumber AS library_barcode FROM borrowers WHERE cardnumber LIKE '%9' 5 - Run report 6 - Note batch options are no longer present 7 - Apply patch 8 - Run report, no change 9 - Update report like: SELECT [[cardnumber|library_barcode]] FROM borrowers WHERE cardnumber LIKE '%9' 10 - Run report 11 - Batch options work! 12 - Update report like: SELECT cardnumber FROM borrowers WHERE cardnumber LIKE '%9' 13 - Verify batch options still work 14 - Set report 'public' 15 - Verify report can be run via JSON URLs: http://kohadev.mydnsname.org:8080/cgi-bin/koha/svc/report?id=1 http://kohadev.mydnsname.org:8081/cgi-bin/koha/svc/report?id=1 --- .../prog/en/modules/reports/guided_reports_start.tt | 18 +++++++++--------- opac/svc/report | 1 + reports/guided_reports.pl | 16 ++++++++++++++-- svc/report | 1 + 4 files changed, 25 insertions(+), 11 deletions(-) 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 928f47c269..49c0724502 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 @@ -738,7 +738,7 @@ canned reports and writing custom SQL reports.

[% # Preserve the whitespace of the following textarea in order to format the values correctly %] - @@ -746,7 +746,7 @@ canned reports and writing custom SQL reports.

[% # Preserve the whitespace of the following textarea in order to format the values correctly %] - @@ -755,7 +755,7 @@ canned reports and writing custom SQL reports.

[% FOREACH result IN results %] [% FOREACH cells IN result.cells %] [% place = loop.index %] - [% IF header_row.$place.cell == 'itemnumber' %] + [% IF header_row.$place.cell == 'itemnumber' || header_types.item(header_row.$place.cell) == 'itemnumber' %] [% SET batch_itemnumbers = 1 %] [% END %] @@ -769,7 +769,7 @@ canned reports and writing custom SQL reports.

[% FOREACH result IN results %] [% FOREACH cells IN result.cells %] [% place = loop.index %] - [% IF header_row.$place.cell == 'itemnumber' %] + [% IF header_row.$place.cell == 'itemnumber' || header_types.item(header_row.$place.cell) == 'itemnumber' %] [% SET batch_itemnumbers = 1 %] [% END %] @@ -781,7 +781,7 @@ canned reports and writing custom SQL reports.

[% FOREACH result IN results %] [% FOREACH cells IN result.cells %] [% place = loop.index %] - [% IF header_row.$place.cell == 'biblionumber' %] + [% IF header_row.$place.cell == 'biblionumber' || header_types.item(header_row.$place.cell) == 'biblionumber' %] [% SET batch_biblionumbers = 1 %] [% END %] @@ -792,7 +792,7 @@ canned reports and writing custom SQL reports.

[% # Preserve the whitespace of the following textarea in order to format the values correctly %] -
@@ -805,7 +805,7 @@ canned reports and writing custom SQL reports.