From 9ab234b02e2227010d6a70cded4268ddc1614147 Mon Sep 17 00:00:00 2001
From: Owen Leonard
Date: Thu, 24 Sep 2020 14:23:11 +0000
Subject: [PATCH] Bug 5697: Automatic linking in guided reports
This patch modifies the output of reports so that if certain columns are
returned the data in the colums automatically offer menus of actions:
- borrowernumber: View, edit, check out
- cardnumber: Check out
- itemnumber: View, edit
- biblionumber: View, edit
Like the menu of batch operations, this functionality is available only
if the column is returned with its original name (e.g. biblionumber, not
"biblionumber AS `Biblio number`).
To test, apply the patch and run a report which will return examples of
each kind of data. I used:
SELECT biblio.biblionumber , biblio.title, items.itemnumber,
items.itemcallnumber, items.barcode, borrowers.firstname,
borrowers.surname, borrowers.borrowernumber, borrowers.cardnumber
FROM issues
LEFT JOIN borrowers ON borrowers.borrowernumber=issues.borrowernumber
LEFT JOIN items ON issues.itemnumber=items.itemnumber
LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber
ORDER BY RAND() LIMIT 50
When the report runs you should see that the data in each affected
column is displayed as a link, each of which should trigger the correct
menu. Test each case to confirm that the correct page is opened.
Test the "toggle data menus" control. Clicking it should hide and show
the menus in the report results.
Signed-off-by: Lisette Scheer
---
.../en/modules/reports/guided_reports_start.tt | 84 +++++++++++++++++++---
1 file changed, 74 insertions(+), 10 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 c2c3138d94..b91f2d2445 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
@@ -57,6 +57,7 @@
color: #11917B;
}
#mana_search_errortext { font-family: monospace; font-weight: bold; }
+ .data-plain { display: none; }
[% Asset.css("css/reports.css") | $raw %]
[% Asset.css("lib/d3c3/c3.min.css") | $raw %]
@@ -1005,6 +1006,11 @@
[% END %]
+
+
+
+ Toggle data menus
+
[% END # /IF ( batch_biblionumbers || batch_itemnumbers || batch_cardnumbers ) %]
[% END # UNLESS ( errors ) %]
@@ -1036,19 +1042,33 @@
[% pagination_bar | $raw %]
[% UNLESS ( errors ) %]
-
-
- [% FOREACH header_ro IN header_row %]
- [% header_ro.cell | html %] |
- [% END %]
-
- [% FOREACH result IN results %]
+
+
- [% FOREACH cells IN result.cells %]
- [% cells.cell | $raw %] |
+ [% FOREACH header_ro IN header_row %]
+ [% IF header_ro.has_itemnumbers && ( header_ro.cell == 'itemnumber' || header_types.item( header_ro.cell ) == 'itemnumber' ) %]
+ [% header_ro.cell | html %] |
+ [% ELSIF header_ro.has_biblionumbers && ( header_ro.cell == 'biblionumber' || header_types.item( header_ro.cell ) == 'biblionumber' ) %]
+ [% header_ro.cell | html %] |
+ [% ELSIF header_ro.cell == 'cardnumber' || header_types.item( header_ro.cell ) == 'cardnumber' %]
+ [% header_ro.cell | html %] |
+ [% ELSIF header_ro.cell == 'borrowernumber' || header_types.item( header_ro.cell ) == 'borrowernumber' %]
+ [% header_ro.cell | html %] |
+ [% ELSE %]
+ [% header_ro.cell | html %] |
+ [% END %]
[% END %]
- [% END %]
+
+
+ [% FOREACH result IN results %]
+
+ [% FOREACH cells IN result.cells %]
+ [% cells.cell | $raw %] |
+ [% END %]
+
+ [% END %]
+
[% END %]
[% pagination_bar | $raw %]
@@ -1841,6 +1861,50 @@
var reportid = $(this).data("reportid");
previewSql( reportid );
});
+
+ $(".limitselect").on("click", function(){
+ var limit = $(this).data("limit");
+ $("#limit").val( limit );
+ $("#limitselect").submit();
+ });
+
+ if( $("#report_results").length > 0 ){
+ $("#report_results").dataTable($.extend(true, {}, dataTablesDefaults, {
+ "dom": 't',
+ "paginate": false,
+ "ordering": false,
+ "columnDefs": [
+ {
+ targets: "biblionumber",
+ render: function ( data ) {
+ return '' + data + '';
+ }
+ },
+ {
+ targets: "itemnumber",
+ render: function ( data ) {
+ return '' + data + '';
+ }
+ },
+ {
+ targets: "borrowernumber",
+ render: function ( data ) {
+ return '' + data + '';
+ }
+ },
+ {
+ targets: "cardnumber",
+ render: function ( data ) {
+ return '' + data + '';
+ }
+ },
+ ]
+ }));
+ }
+ $("#toggle_auto_links").on("click", function(e){
+ e.preventDefault();
+ $(".data-plain,.autolink").toggle();
+ });
});
function tabsInit( ui, rtable ){
--
2.11.0