From 3a4c648f4af1a905b41c9b8e2fbe9a606a47cdd4 Mon Sep 17 00:00:00 2001
From: Owen Leonard <oleonard@myacpl.org>
Date: Wed, 7 Jan 2015 08:26:57 -0500
Subject: [PATCH] [PASSED QA] Bug 13525 - Date sorting on accounts (fines) tab
 doesn't work correctly

Date sorting of charges under Patron -> Fines -> Account is done based
on formatted dates, so sorting is broken depending on your dateformat
system preference. This patch implements the standard "title-string"
date sorting method.

To test, apply the patch and view the Account tab. Test sorting of
charges under various settings of the dateformat system preference. Date
sorting should work correctly in all cases.

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Works as described and fixes sorting problem.
---
 koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt | 10 +++++++---
 members/boraccount.pl                                         |  2 --
 2 files changed, 7 insertions(+), 5 deletions(-)

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 f87c475..109bdfc 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt
@@ -1,3 +1,4 @@
+[% USE KohaDates %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Patrons &rsaquo; Account for [% INCLUDE 'patron-title.inc' %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
@@ -10,7 +11,10 @@ $(document).ready(function() {
     var table_account_fines = $("#table_account_fines").dataTable($.extend(true, {}, dataTablesDefaults, {
         "sPaginationType": "four_button",
         'aaSorting': [[0, 'desc']],
-        "sDom": 'C<"top pager"ilpf><"#filter_c">tr<"bottom pager"ip>'
+        "sDom": 'C<"top pager"ilpf><"#filter_c">tr<"bottom pager"ip>',
+        "aoColumnDefs": [
+            { "sType": "title-string", "aTargets" : [ "title-string" ] }
+        ]
     }));
     $("#filter_c").html('<p><a href="#" id="filter_transacs">'+txtActivefilter+'</a>');
     $('#filter_transacs').click(function(e) {
@@ -55,7 +59,7 @@ $(document).ready(function() {
 <table id="table_account_fines">
     <thead>
       <tr>
-          <th>Date</th>
+          <th class="title-string">Date</th>
           <th>Description of charges</th>
           <th>Note</th>
           <th>Amount</th>
@@ -71,7 +75,7 @@ $(document).ready(function() {
   [% FOREACH account IN accounts %]
 
    [% IF ( loop.odd ) %]<tr>[% ELSE %]<tr class="highlight">[% END %]
-      <td>[% account.date %]</td>
+   <td><span title="[% account.date %]">[% account.date |$KohaDates %]</span></td>
       <td>
         [% SWITCH account.accounttype %]
           [% CASE 'Pay' %]Payment, thanks
diff --git a/members/boraccount.pl b/members/boraccount.pl
index d3b5240..b9eaad6 100755
--- a/members/boraccount.pl
+++ b/members/boraccount.pl
@@ -27,7 +27,6 @@ use warnings;
 
 use C4::Auth;
 use C4::Output;
-use C4::Dates qw/format_date/;
 use CGI qw ( -utf8 );
 use C4::Members;
 use C4::Branch;
@@ -84,7 +83,6 @@ foreach my $accountline ( @{$accts}) {
         $accountline->{amountoutstandingcredit} = 1;
     }
 
-    $accountline->{date} = format_date($accountline->{date});
     $accountline->{amount} = sprintf '%.2f', $accountline->{amount};
     $accountline->{amountoutstanding} = sprintf '%.2f', $accountline->{amountoutstanding};
     if ($accountline->{accounttype} =~ /^Pay/) {
-- 
1.9.1