From b9625919bf78919ce314b7c1531ea0b09851f570 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Fri, 16 Nov 2018 14:51:48 +0000 Subject: [PATCH] Bug 21852: Add more columns and column configuration to overdues report This patch adds some new columns to the overdue report: Patron category, item home library, item holding library, item type. Adding these columns makes available columns better match the available filter fields in the sidebar form. Column configuration is added to this DataTable, with the new columns defined as hidden by default in order to preserve current functionality. New code has been added to the global DataTables configuration to allow the locally-stored column visibility information to override the default Koha configuration for that table. This lets us take advantage of the "stateSave" option in DataTAbles. This patch also fixes a bug where the home and holding branch template variable names didn't match what was being used in the template for pre-selecting the searched-for value in the sidebar filter menu. To test, apply the patch and go to Circulation -> Overdues. - The list of overdues should look correct, with no new columns shown. - Test the column visibility button, showing the columns which are hidden by default. Confirm that the data in these columns displays correctly. - Show or hide columns in such a way that it doesn't match the default configuration. - Navigate away from this page. - Return to the page. The same set of columns should be visible. Signed-off-by: Maryse Simard Signed-off-by: Katrin Fischer --- admin/columns_settings.yml | 31 +++++++++++++++++++ circ/overdue.pl | 8 +++-- .../intranet-tmpl/prog/en/modules/circ/overdue.tt | 36 +++++++++++++++++----- koha-tmpl/intranet-tmpl/prog/js/datatables.js | 28 +++++++++++++++++ 4 files changed, 92 insertions(+), 11 deletions(-) diff --git a/admin/columns_settings.yml b/admin/columns_settings.yml index 3c5d2a9181..d0f7ca3f66 100644 --- a/admin/columns_settings.yml +++ b/admin/columns_settings.yml @@ -920,6 +920,37 @@ modules: - columnname: items_needed + overdues: + circ-overdues: + - + columname: due_date + - + columname: patron + - + columname: patron_category + is_hidden: 1 + - + columname: patron_library + - + columname: title + - + columname: home_library + is_hidden: 1 + - + columname: holding_library + is_hidden: 1 + - + columname: barcode + - + columname: call_number + - + columname: item_type + is_hidden: 1 + - + columname: price + - + columname: non-public_note + opac: biblio-detail: holdingst: diff --git a/circ/overdue.pl b/circ/overdue.pl index f5683bda22..675ecec489 100755 --- a/circ/overdue.pl +++ b/circ/overdue.pl @@ -249,7 +249,8 @@ if ($noreport) { items.itemcallnumber, items.replacementprice, items.enumchron, - items.itemnotes_nonpublic + items.itemnotes_nonpublic, + items.itype FROM issues LEFT JOIN borrowers ON (issues.borrowernumber=borrowers.borrowernumber ) LEFT JOIN items ON (issues.itemnumber=items.itemnumber) @@ -332,12 +333,13 @@ if ($noreport) { biblionumber => $data->{biblionumber}, title => $data->{title}, author => $data->{author}, - homebranchcode => $data->{homebranchcode}, - holdingbranchcode => $data->{holdingbranchcode}, + homebranchcode => $data->{homebranch}, + holdingbranchcode => $data->{holdingbranch}, itemcallnumber => $data->{itemcallnumber}, replacementprice => $data->{replacementprice}, itemnotes_nonpublic => $data->{itemnotes_nonpublic}, enumchron => $data->{enumchron}, + itemtype => $data->{itype}, patron_attr_value_loop => \@patron_attr_value_loop, }; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/overdue.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/overdue.tt index d644d45aa8..2a4bc702a4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/overdue.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/overdue.tt @@ -3,6 +3,9 @@ [% USE KohaDates %] [%- USE Branches -%] [%- USE Price -%] +[%- USE ItemTypes -%] +[%- USE Categories -%] +[%- USE ColumnsSettings -%] [% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] Koha › Circulation › Items overdue as of [% todaysdate | html %] @@ -51,10 +54,14 @@ Due date Patron - Library - Title + Patron category + Patron library + Title + Home library + Holding library Barcode Call number + Item type Price Non-public note @@ -70,10 +77,14 @@ [% IF ( overdueloo.email ) %][email][% END %] [% IF ( overdueloo.phone ) %]([% overdueloo.phone | html %])[% ELSIF ( overdueloo.mobile ) %]([% overdueloo.mobile | html %])[% ELSIF ( overdueloo.phonepro ) %]([% overdueloo.phonepro | html %])[% END %] [% END %] - [% Branches.GetName( overdueloo.patron.branchcode ) | html %] + [% Categories.GetName( overdueloo.patron.categorycode ) | html %] + [% Branches.GetName( overdueloo.homebranchcode ) | html %] [% INCLUDE 'biblio-default-view.inc' biblionumber = overdueloo.biblionumber %][% INCLUDE 'biblio-title.inc' biblio=overdueloo %] [% IF ( overdueloo.author ) %], by [% overdueloo.author | html %][% END %][% IF ( overdueloo.enumchron ) %], [% overdueloo.enumchron | html %][% END %] + [% Branches.GetName( overdueloo.holdingbranchcode ) | html %] + [% Branches.GetName( overdueloo.patron.branchcode ) | html %] [% overdueloo.barcode | html %] [% overdueloo.itemcallnumber | html %] + [% ItemTypes.GetDescription( overdueloo.itemtype ) | html %] [% overdueloo.replacementprice | $Price %] [% overdueloo.itemnotes_nonpublic | html %] @@ -213,7 +224,8 @@ [% MACRO jsinclude BLOCK %] [% INCLUDE 'calendar.inc' %] [% INCLUDE 'datatables.inc' %] - [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js index dd07ddc04d..56f12f47f1 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js +++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js @@ -604,3 +604,31 @@ function filterDataTable( table, column, term ){ table.search( term ).draw("page"); } } + +/* get_columns_saved_state checks for a DataTables configuration saved + * in the browser's local storage. If it is present, the columns + * configuration supplied by Koha is overwritten + * + * It takes two parameters: + * - localstorage_config, the DataTables saved state object from local storage + * - columns_settings, the columns settings object supplied by the template + */ + +function get_columns_saved_state( localstorage_config, columns_settings ){ + var tables = JSON.parse( localstorage_config ); + // if a table configuration was found in local storage, parse it + if( tables ){ + var stateSave_column_visibility = []; + $(tables.columns).each(function(){ + stateSave_column_visibility.push( this.visible === true ? 0 : 1 ); + }); + $.each( columns_settings, function( index, key ){ + if( stateSave_column_visibility[ index ] !== columns_settings[key] ){ + columns_settings[ index ].is_hidden = stateSave_column_visibility[ index ]; + } + }); + return columns_settings; + } else { + return columns_settings; + } +} -- 2.11.0