From 42c99a10a7cfd64d2a1829cbdec50962239f5f9f Mon Sep 17 00:00:00 2001
From: Josef Moravec <josef.moravec@gmail.com>
Date: Wed, 16 Nov 2016 10:02:34 +0000
Subject: [PATCH] Bug 17700: Add columns setting to fines tables

Test plan:
0) Apply the patch
1) Go to adminitration -> Configure columns and confirm there is new
table configuration with id=account-fines in Patrons section available
2) play with table setting to ensure it works as expected
3) go to to boraccount page for some patron with both fines - payed and
owed
4) Note there is new button "Columns visibility" in top paginator panel, try to use it
5) Play with the datatable, sort filter and so on
---
 admin/columns_settings.yml                          | 21 +++++++++++++++++++++
 .../prog/en/modules/members/boraccount.tt           |  9 ++++++---
 2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/admin/columns_settings.yml b/admin/columns_settings.yml
index 7ef4d35..ee73b1e 100644
--- a/admin/columns_settings.yml
+++ b/admin/columns_settings.yml
@@ -155,6 +155,27 @@ modules:
           columnname: stocknumber
 
   members:
+    fines:
+      account-fines:
+        -
+          columnname: date
+        -
+          columnname: description
+        -
+          columnname: note
+        -
+          columnname: amount
+          cannot_be_toggled: 1
+          cannot_be_modified: 1
+        -
+          columnname: amountoutstanding
+          cannot_be_toggled: 1
+          cannot_be_modified: 1
+        -
+          columnname: actions
+          cannot_be_toggled: 1
+          cannot_be_modified: 1
+
     member:
       memberresultst:
         -
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt
index ca0a804..90e8a48 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt
@@ -1,23 +1,26 @@
 [% USE Koha %]
 [% USE KohaDates %]
+[% USE ColumnsSettings %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Patrons &rsaquo; Account for [% INCLUDE 'patron-title.inc' %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
 [% INCLUDE 'datatables.inc' %]
+[% INCLUDE 'columns_settings.inc' %]
 <script type="text/javascript">
 $(document).ready(function() {
     var txtActivefilter = _("Filter paid transactions");
     var txtInactivefilter = _("Show all transactions");
-    var table_account_fines = $("#table_account_fines").dataTable($.extend(true, {}, dataTablesDefaults, {
+    var columns_settings = [% ColumnsSettings.GetColumns('members', 'fines', 'account-fines', 'json') %];
+    var table_account_fines = KohaTable("#table_account_fines", {
         "sPaginationType": "four_button",
         'aaSorting': [[0, 'desc']],
-        "sDom": 'C<"top pager"ilpf><"#filter_c">tr<"bottom pager"ip>',
+        "sDom": 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>',
         "aoColumnDefs": [
             { "sType": "title-string", "aTargets" : [ "title-string" ] },
             { "bSortable": false, "bSearchable": false, "aTargets": [-1] }
         ]
-    }));
+    }, columns_settings);
     $("#filter_c").html('<p><a href="#" id="filter_transacs"><i class="fa fa-filter"></i> '+txtActivefilter+'</a>');
     $('#filter_transacs').click(function(e) {
         e.preventDefault();
-- 
2.1.4