From 807cc1cfbad9e2965e510bf460d8aacecb56c452 Mon Sep 17 00:00:00 2001
From: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Date: Wed, 20 Nov 2019 09:30:48 +0000
Subject: [PATCH] Bug 23354: (follow-up) Fix for sending code instead of
 description

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
---
 koha-tmpl/intranet-tmpl/prog/en/modules/pos/pay.tt | 25 ++++++++++++++--------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/pay.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/pay.tt
index 398459d570..b662285f6b 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/pay.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/pay.tt
@@ -72,6 +72,7 @@
                                     <th>Quantity</th>
                                     <th>Total</th>
                                     <th>Action</th>
+                                    <th>CODE</th>
                                 </tr>
                             </thead>
                             <tbody>
@@ -81,6 +82,7 @@
                                     <td colspan="3">Total payable:</td>
                                     <td></td>
                                     <td></td>
+                                    <td></td>
                                 </tr>
                             </tfoot>
                         </table>
@@ -181,14 +183,15 @@
     [% INCLUDE 'datatables.inc' %]
     [% Asset.js("lib/jquery/plugins/jquery.jeditable.mini.js") | $raw %]
     <script>
-    function fnClickAddRow( table, invoiceTitle, invoicePrice ) {
+    function fnClickAddRow( table, invoiceCode, invoiceTitle, invoicePrice ) {
       table.fnAddData( [
         invoiceTitle,
         invoicePrice,
         1,
         null,
-        '<button class="drop"><i class="fa fa-trash"></i> Remove</button>'
-         ]
+        '<button class="drop"><i class="fa fa-trash"></i> Remove</button>',
+        invoiceCode
+        ]
       );
     }
 
@@ -263,21 +266,25 @@
             "bInfo": false,
             "bAutoWidth": false,
             "aoColumnDefs": [{
-                "aTargets": [-2],
+                "aTargets": [-3],
                 "bSortable": false,
                 "bSearchable": false,
             }, {
-                "aTargets": [-2],
+                "aTargets": [-3],
                 "mRender": function ( data, type, full ) {
                     var price = Number.parseFloat(data);
                     return price.format_price();
                 }
             }, {
-                "aTargets": [-4],
+                "aTargets": [-5],
                 "sClass" : "editable",
             }, {
-                "aTargets": [-3],
+                "aTargets": [-4],
                 "sClass" : "editable_int",
+            }, {
+                "targets": [-1],
+                "visible": false,
+                "searchable": false
             }],
             "aaSorting": [
                 [1, "asc"]
@@ -335,7 +342,7 @@
 
         $(".add_button").on("click", function(e) {
             e.preventDefault();
-            fnClickAddRow(sale_table, $( this ).data('invoiceTitle'), $( this ).data('invoicePrice') );
+            fnClickAddRow(sale_table, $( this ).data('invoiceCode'), $( this ).data('invoiceTitle'), $( this ).data('invoicePrice') );
             items_table.fnFilter( '' );
         });
 
@@ -362,7 +369,7 @@
                 var rows = sale_table.fnGetData();
                 rows.forEach(function (row, index) {
                     var sale = {
-                        code: row[0],
+                        code: row[5],
                         price: row[1],
                         quantity: row[2]
                     };
-- 
2.11.0