From 751051f1e73cabcf8c0491c233f8852bd551d567 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.
---
.../en/modules/reports/guided_reports_start.tt | 86 +++++++++++++++++++---
1 file changed, 75 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 153d7b7ced..644a1daee1 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
@@ -54,6 +54,7 @@
resize: vertical;
}
#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 %]
@@ -930,7 +931,7 @@
- [% IF ( batch_biblionumbers || batch_itemnumbers || batch_cardnumbers ) %]
+ [% IF ( batch_biblionumbers || batch_itemnumbers || batch_cardnumbers ) %]
+
+
+
+ Toggle data menus
+
[% END # /IF ( batch_biblionumbers || batch_itemnumbers || batch_cardnumbers ) %]
[% END # UNLESS ( errors ) %]
@@ -1006,19 +1012,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 %]
@@ -1802,6 +1822,50 @@
e.preventDefault();
addToList();
});
+
+ $(".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 addColumn() {
--
2.11.0