From d1b0214b38a2b3e7f5c1c883ac14bc89c4541030 Mon Sep 17 00:00:00 2001
From: Owen Leonard <oleonard@myacpl.org>
Date: Thu, 18 Mar 2021 14:18:07 +0000
Subject: [PATCH] Bug 27982: Replace obsolete title-string sorting:
 Acquisitions templates part 1

This patch modifies several acquisitions templates to replace the use of
the "title-string" DataTables sorting method with the newer "data-order"
attribute.

To test, apply the patch and view the following pages to confirm that
columns containing dates sort correctly when using any setting of the
"dateformat" system preference:

- Acquisitions -> Vendor search
- Acquisitions -> Vendor -> Basket -> Add to basket
   -> From a staged file
   -> From existing orders (copy)
- Acquisitions -> EDIFACT messages
- Acquisitions -> Order search
- With AcqEnableFiles enabled, attach some files to an invoice:
  - Acquisitions -> Invoices
    Acquisitions -> Invoices -> Manage invoice files

https://bugs.koha-community.org/show_bug.cgi?id=27983
---
 .../prog/en/modules/acqui/addorderiso2709.tt  |  4 +-
 .../prog/en/modules/acqui/booksellers.tt      | 42 ++++++++-----------
 .../prog/en/modules/acqui/duplicate_orders.tt | 18 ++++----
 .../prog/en/modules/acqui/edifactmsgs.tt      |  7 ++--
 .../prog/en/modules/acqui/histsearch.tt       | 14 +++----
 .../prog/en/modules/acqui/invoice-files.tt    |  7 ++--
 .../prog/en/modules/acqui/invoice.tt          |  4 +-
 .../prog/en/modules/acqui/invoices.tt         | 20 +++------
 8 files changed, 45 insertions(+), 71 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt
index c730d3e1b2..1bbafd90eb 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt
@@ -398,7 +398,7 @@
                         <th>File name</th>
                         <th>Comments</th>
                         <th>Status</th>
-                        <th class="title-string">Staged</th>
+                        <th>Staged</th>
                         <th># Bibliographic records</th>
                         <th class="NoSort">&nbsp;</th>
                       </tr>
@@ -425,7 +425,7 @@
                             [% batch_lis.import_status | html %]
                           [% END %]
                         </td>
-                        <td><span title="[% batch_lis.staged_date | html %]">[% batch_lis.staged_date | $KohaDates  with_hours => 1 %]</span></td>
+                        <td data-order="[% batch_lis.staged_date | html %]">[% batch_lis.staged_date | $KohaDates  with_hours => 1 %]</td>
                         <td>[% batch_lis.num_records | html %]</td>
                         <td class="actions">
                             <a href="[% batch_lis.scriptname | url %]?import_batch_id=[% batch_lis.import_batch_id | uri %]&amp;basketno=[% basketno | uri %]&amp;booksellerid=[% booksellerid | uri %]" class="btn btn-default btn-xs"><i class="fa fa-plus"></i> Add orders</a>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/booksellers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/booksellers.tt
index 1adb7f0be9..d275e23745 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/booksellers.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/booksellers.tt
@@ -85,13 +85,13 @@
                                 <tr>
                                     <th>No.</th>
                                     <th>Name</th>
-                                    <th class="title-numeric">Item count</th>
-                                    <th class="title-numeric">Bibliographic record count</th>
+                                    <th>Item count</th>
+                                    <th>Bibliographic record count</th>
                                     <th>Items expected</th>
                                     <th>[% tp('basket created by', 'Created by') | html %]</th>
-                                    <th class="title-string">Date</th>
+                                    <th>Date</th>
                                     <th>Basket group</th>
-                                    <th class="title-string">Closed</th>
+                                    <th>Closed</th>
                                     <th class="noExport">Actions</th>
                                 </tr>
                             </thead>
@@ -104,19 +104,17 @@
                                     [% END %]
                                         <td>[% basket.basketno | html %]</td>
                                         <td><a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basket.basketno | uri %]">[% basket.basketname | html %]</a></td>
-                                        <td>
-                                            <span title="[% basket.total_items | html %]">[% basket.total_items | html %]
-                                                [% IF basket.total_items_cancelled %]
-                                                    ([% basket.total_items_cancelled | html %] cancelled)
-                                                [% END %]
-                                            </span>
+                                        <td data-order="[% basket.total_items | html %]">
+                                            [% basket.total_items | html %]
+                                            [% IF basket.total_items_cancelled %]
+                                                ([% basket.total_items_cancelled | html %] cancelled)
+                                            [% END %]
                                         </td>
-                                        <td>
-                                            <span title="[% basket.total_biblios | html %]">[% basket.total_biblios | html %]
-                                                [% IF basket.total_biblios_cancelled %]
-                                                    ([% basket.total_biblios_cancelled | html %] cancelled)
-                                                [% END %]
-                                            </span>
+                                        <td data-order="[% basket.total_biblios | html %]">
+                                            [% basket.total_biblios | html %]
+                                            [% IF basket.total_biblios_cancelled %]
+                                                ([% basket.total_biblios_cancelled | html %] cancelled)
+                                            [% END %]
                                         </td>
                                         <td>[% basket.expected_items | html %]</td>
                                         <td>
@@ -125,7 +123,7 @@
                                                 [% basket.authorisedby.surname | html %]
                                             [% END %]
                                         </td>
-                                        <td><span title="[% basket.creationdate | html %]">[% basket.creationdate | $KohaDates %]</span></td>
+                                        <td data-order="[% basket.creationdate | html %]">[% basket.creationdate | $KohaDates %]</td>
                                         <td>
                                           [% IF basket.basketgroup %]
                                             [% basketgroup = basket.basketgroup %]
@@ -136,12 +134,8 @@
                                             [% END %]
                                           [% END %]
                                         </td>
-                                        <td>
-                                            [% IF ( basket.closedate ) %]
-                                                <span title="[% basket.closedate | html %]">[% basket.closedate | $KohaDates %]</span>
-                                            [% ELSE %]
-                                                <span title="9999-99-99"></span>
-                                            [% END %]
+                                        <td data-order="[% basket.closedate | html %]">
+                                            [% basket.closedate | $KohaDates %]
                                         </td>
                                         <td class="actions">
                                         [% IF not basket.closedate and supplier.active %]
@@ -215,8 +209,6 @@
                 'bInfo': false,
                 "aaSorting": [[ 1, "asc" ]],
                 "aoColumnDefs": [
-                    { "sType": "title-string", "aTargets" : [ "title-string" ] },
-                    { "sType": "title-numeric", "aTargets" : [ "title-numeric" ] },
                     { 'aTargets': [-1], 'bSortable': false }
                 ]
             }));
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/duplicate_orders.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/duplicate_orders.tt
index 1ed05775ef..f233c2f316 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/duplicate_orders.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/duplicate_orders.tt
@@ -110,13 +110,9 @@ Basket [% basket.basketno | html %] &rsaquo; Duplicate existing orders
             <br />[% order.author | html %] <br /> [% order.isbn | html %]
         </td>
         <td><a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% order.id | uri %]">[% order.name | html %]</a></td>
-        <td><span title="[% order.creationdate | html %]">[% order.creationdate | $KohaDates %]</span></td>
-        <td>
-            [% IF order.datereceived %]
-                <span title="[% order.datereceived | html %]">[% order.datereceived | $KohaDates %]</span>
-            [% ELSE %]
-                <span title="0000-00-00"></span>
-            [% END %]
+        <td data-order="[% order.creationdate | html %]">[% order.creationdate | $KohaDates %]</td>
+        <td data-order="[% order.datereceived | html %]">
+            [% order.datereceived | $KohaDates %]
         </td>
         <td>[% order.quantityreceived | html %]</td>
         <td>[% order.quantity | html %]</td>
@@ -145,8 +141,8 @@ Basket [% basket.basketno | html %] &rsaquo; Duplicate existing orders
                     <th>Invoice number</th>
                     <th class="anti-the">Summary</th>
                     <th>Vendor</th>
-                    <th class="title-string">Placed on</th>
-                    <th class="title-string">Received on</th>
+                    <th>Placed on</th>
+                    <th>Received on</th>
                     <th>Quantity received</th>
                     <th>Quantity ordered</th>
                     <th>Unit cost</th>
@@ -266,8 +262,8 @@ Basket [% basket.basketno | html %] &rsaquo; Duplicate existing orders
                     <th>Invoice number</th>
                     <th class="anti-the">Summary</th>
                     <th>Vendor</th>
-                    <th class="title-string">Placed on</th>
-                    <th class="title-string">Received on</th>
+                    <th>Placed on</th>
+                    <th>Received on</th>
                     <th>Quantity received</th>
                     <th>Quantity ordered</th>
                     <th>Unit cost</th>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/edifactmsgs.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/edifactmsgs.tt
index 12797d7d97..0376b7b731 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/edifactmsgs.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/edifactmsgs.tt
@@ -33,7 +33,7 @@
 <thead>
 <tr>
 <th>Type</th>
-<th class="title-string">Transferred</th>
+<th>Transferred</th>
 <th>Status</th>
 <th>Vendor</th>
 <th>Details</th>
@@ -45,7 +45,7 @@
 [% FOREACH msg IN messages %]
 <tr>
 <td>[% msg.message_type | html %]</td>
-<td><span title="[% msg.transfer_date | html %]">[% msg.transfer_date | $KohaDates %]</span></td>
+<td data-order="[% msg.transfer_date | html %]">[% msg.transfer_date | $KohaDates %]</td>
 <td>[% msg.status | html %]</td>
 <td>
     <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% msg.vendor_id | uri %]">
@@ -124,8 +124,7 @@
                 'aaSorting': [[1, "desc" ]],
                 'sPaginationType': "full",
                 "aoColumnDefs": [
-                    { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
-                    { "sType": "title-string", "aTargets" : [ "title-string" ] }
+                    { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false }
                 ]
             }));
 
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt
index e43000df35..f9f2625198 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt
@@ -44,8 +44,8 @@
                 <th>Invoice number</th>
                 <th class="anti-the">Summary</th>
 				<th>Vendor</th>
-                <th class="title-string">Placed on</th>
-                <th class="title-string">Received on</th>
+                <th>Placed on</th>
+                <th>Received on</th>
                 <th>Quantity received</th>
                 <th>Quantity ordered</th>
 				<th>Unit cost</th>
@@ -90,13 +90,9 @@
                         <br />[% order.author | html %] <br /> [% order.isbn | html %]
                     </td>
                     <td><a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% order.id | uri %]">[% order.name | html %]</a></td>
-                    <td><span title="[% order.creationdate | html %]">[% order.creationdate | $KohaDates %]</span></td>
-                    <td>
-                        [% IF order.datereceived %]
-                            <span title="[% order.datereceived | html %]">[% order.datereceived | $KohaDates %]</span>
-                        [% ELSE %]
-                            <span title="0000-00-00"></span>
-                        [% END %]
+                    <td data-order="[% order.creationdate | html %]">[% order.creationdate | $KohaDates %]</td>
+                    <td data-order="[% order.datereceived | html %]">
+                        [% order.datereceived | $KohaDates %]
                     </td>
                     <td>[% order.quantityreceived | html %]</td>
                     <td>[% order.quantity | html %]</td>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice-files.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice-files.tt
index f28cfd6c17..aad2223b6d 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice-files.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice-files.tt
@@ -47,8 +47,8 @@
                       <td><a href="?invoiceid=[% invoiceid | uri %]&amp;op=download&amp;view=1&amp;file_id=[% f.file_id | uri %]">[% f.file_name | html %]</a></td>
                       <td>[% f.file_type | html %]</td>
                       <td>[% f.file_description | html %]</td>
-                      <td class="title-string">
-                        <span title="[% f.date_uploaded | html %]">[% f.date_uploaded | $KohaDates %]</span>
+                      <td data-order="[% f.date_uploaded | html %]">
+                        [% f.date_uploaded | $KohaDates %]
                       </td>
                       <td>[% f.file_size | html %]</td>
                       <td><a class="delete_file" href="?invoiceid=[% invoiceid | html %]&amp;op=delete&amp;file_id=[% f.file_id | html %]">Delete</a></td>
@@ -95,8 +95,7 @@
         $(document).ready(function() {
             $("#invoice_files_details_table").dataTable($.extend(true, {}, dataTablesDefaults, {
                 "aoColumnDefs": [
-                    { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
-                    { "aTargets": [ "title-string" ], "sType": "title-string" }
+                    { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false }
                 ],
                 bInfo: false,
                 bPaginate: false,
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt
index 6638449a4b..b37d64c3f2 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt
@@ -435,8 +435,8 @@
                          <td><a href="/cgi-bin/koha/acqui/invoice-files.pl?invoiceid=[% invoiceid | uri %]&amp;op=download&amp;view=1&amp;file_id=[% f.file_id | uri %]">[% f.file_name | html %]</a></td>
                          <td>[% f.file_type | html %]</td>
                          <td>[% f.file_description | html %]</td>
-                         <td class="title-string">
-                           <span title="[% f.date_uploaded | html %]">[% f.date_uploaded | $KohaDates %]</span>
+                         <td data-order="[% f.date_uploaded | html %]">
+                            [% f.date_uploaded | $KohaDates %]
                          </td>
                     </tr>
                 [% END %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt
index 4536842f41..08889f2727 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt
@@ -38,8 +38,8 @@
                 <th>&nbsp;</th>
                 <th>Invoice no.</th>
                 <th>Vendor</th>
-                <th class="title-string">Shipment date</th>
-                <th class="title-string">Billing date</th>
+                <th>Shipment date</th>
+                <th>Billing date</th>
                 <th>Received bibliographic records</th>
                 <th>Received items</th>
                 <th>Status</th>
@@ -55,19 +55,11 @@
                   <td><input type="checkbox" class="select-invoice" value="[% invoice.invoiceid | html %]" /></td>
                   <td><a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% invoice.invoiceid | uri %]">[% invoice.invoicenumber | html %]</a></td>
                   <td><a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% invoice.booksellerid | uri %]">[% invoice.suppliername | html %]</a></td>
-                  <td>
-                    [% IF invoice.shipmentdate %]
-                      <span title="[% invoice.shipmentdate | html %]">[% invoice.shipmentdate | $KohaDates %]</span>
-                    [% ELSE %]
-                      <span title="0000-00-00"></span>
-                    [% END %]
+                  <td data-order="[% invoice.shipmentdate | html %]">
+                      [% invoice.shipmentdate | $KohaDates %]
                   </td>
-                  <td>
-                    [% IF invoice.billingdate %]
-                      <span title="[% invoice.billingdate | html %]">[% invoice.billingdate | $KohaDates %]</span>
-                    [% ELSE %]
-                      <span title="0000-00-00"></span>
-                    [% END %]
+                  <td data-order="[% invoice.billingdate | html %]">
+                      [% invoice.billingdate | $KohaDates %]
                   </td>
                   <td>[% invoice.receivedbiblios | html %]</td>
                   <td>[% invoice.receiveditems | html %]</td>
-- 
2.20.1