Bug 23354: Add ability to remove items
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Tue, 13 Aug 2019 10:16:25 +0000 (11:16 +0100)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Mon, 13 Jan 2020 14:04:18 +0000 (14:04 +0000)
This patch adds the ability to remove items from a transactions on the
new Point of Sale pay page.

Test plan:
1) Populate a transaction with at least one item.
2) Note the new button to 'Remove item' on the items table.
3) Click the button and confirm the item is removed
4) Signoff

Sponsored-by: PTFS Europe
Sponsored-by: Cheshire Libraries Shared Services
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
koha-tmpl/intranet-tmpl/prog/en/modules/pos/pay.tt

index 1946646..163d64f 100644 (file)
@@ -39,6 +39,7 @@
                                     <th>Cost</th>
                                     <th>Quantity</th>
                                     <th>Total</th>
+                                    <th>Action</th>
                                 </tr>
                             </thead>
                             <tbody>
@@ -47,6 +48,7 @@
                                 <tr>
                                     <td colspan="3">Total payable:</td>
                                     <td></td>
+                                    <td></td>
                                 </tr>
                             </tfoot>
                         </table>
         invoiceTitle,
         invoicePrice,
         1,
-        null
+        null,
+        '<button class="drop"><i class="fa fa-trash"></i> Remove</button>'
          ]
       );
     }
                 "bSortable": false,
                 "bSearchable": false,
             }, {
-                "aTargets": [-1],
+                "aTargets": [-2],
                 "mRender": function ( data, type, full ) {
                     var price = Number.parseFloat(data).toFixed(2);
                     return '£'+price;
             }
         }));
 
+        $("#sale").on("click", "button.drop", function(){
+                sale_table.DataTable().row($(this).parents('tr')).remove().draw(false);
+        });
+
         var items_table = $("#invoices").dataTable($.extend(true,{}, dataTablesDefaults, {
                "aoColumnDefs": [
                   { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable":false },