Bug 20966: Add column configuration to table of orders in a basket
authorOwen Leonard <oleonard@myacpl.org>
Tue, 19 Jun 2018 17:02:14 +0000 (17:02 +0000)
committerNick Clemens <nick@bywatersolutions.com>
Tue, 13 Nov 2018 16:29:45 +0000 (16:29 +0000)
This patch adds column configuration to the table of orders in a basket.
It replaces the "Show all details" checkbox which previously was used to
show the hidden "tax included" columns. Now those columns are hidden by
default in the columns configuration file.

To test, apply the patch and view a basket with multiple orders. Test
all DataTables functionality (paging, sorting, filtering) including
showing and hiding columns.

Test with both an open and a closed basket.

Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

https://bugs.koha-community.org/show_bug.cgi?id=20996

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

admin/columns_settings.yml
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt

index 1480019..a372fc1 100644 (file)
@@ -59,6 +59,45 @@ modules:
           columnname: claims_count
         -
           columnname: claimed_date
+    basket:
+      orders:
+        -
+          columnname: basket_number
+        -
+          columnname: order_information
+        -
+          columnname: recommended_retail_price_tax_excluded
+        -
+          columnname: ecost_tax_excluded
+        -
+          columnname: recommended_retail_price_tax_included
+          is_hidden: 1
+        -
+          columnname: ecost_tax_included
+          is_hidden: 1
+        -
+          columnname: quantity
+        -
+          columnname: total_tax_excluded
+        -
+          columnname: total_tax_included
+          is_hidden: 1
+        -
+          columnname: goods_and_services_tax_percentage
+        -
+          columnname: goods_and_services_tax
+        -
+          columnname: fund
+        -
+          columnname: supplier_report
+        -
+          columnname: modify
+          cannot_be_toggled: 1
+          cannot_be_modified: 1
+        -
+          columnname: cancel
+          cannot_be_toggled: 1
+          cannot_be_modified: 1
 
   admin:
     currency:
index f1be321..f7048b2 100644 (file)
@@ -18,6 +18,7 @@
 [% USE Branches %]
 [% USE Price %]
 [% USE AuthorisedValues %]
+[% USE ColumnsSettings %]
 [% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Acquisitions &rsaquo; [% UNLESS ( basketno ) %]New [% END %]Basket [% basketname | html %] ([% basketno | html %]) for [% booksellername | html %]</title>
 
         <div id="acqui_basket_content" class="yui-g">
         [% IF ( books_loop ) %]
-        <h2>Orders</h2>
-        <label for="show_all_details">
-            <input type="checkbox" style="vertical-align: middle;" id="show_all_details" />
-            Show all details
-        </label>
+            <h2>Orders</h2>
             <table id="orders">
                 <thead>
                     <tr>
                         <th>No.</th>
-                        <th class="anti-the">Order</th>
-                        <th class="tax_excluded">RRP tax exc.</th>
-                        <th class="tax_excluded">ecost tax exc.</th>
-                        <th class="tax_included">RRP tax inc.</th>
-                        <th class="tax_included">ecost tax inc.</th>
-                        <th class="replacementprice">Replacement price</th>
+                        <th>Order</th>
+                        <th>RRP tax exc.</th>
+                        <th>ecost tax exc.</th>
+                        <th>RRP tax inc.</th>
+                        <th>ecost tax inc.</th>
+                        <th>Replacement price</th>
                         <th>Qty.</th>
-                        <th class="tax_excluded">Total tax exc. ([% currency | html %])</th>
-                        <th class="tax_included">Total tax inc. ([% currency | html %])</th>
+                        <th>Total tax exc. ([% currency | html %])</th>
+                        <th>Total tax inc. ([% currency | html %])</th>
                         <th>GST %</th>
                         <th>GST</th>
                         <th>Fund</th>
                         <th>Supplier report</th>
                         [% IF ( active ) %]
                             [% UNLESS ( closedate ) %]
-                                <th>Modify</th>
-                                <th>Cancel order</th>
+                                <th class="NoSort">Modify</th>
+                                <th class="NoSort">Cancel order</th>
                             [% END %]
                         [% END %]
                     </tr>
                     <tr>
                         <th></th>
                         <th>Total (GST [% foot_loo.tax_rate * 100 | html %])</th>
-                        <th class="tax_excluded">&nbsp;</th>
-                        <th class="tax_excluded">&nbsp;</th>
-                        <th class="tax_included">&nbsp;</th>
-                        <th class="tax_included">&nbsp;</th>
-                        <th class="replacementprice">&nbsp;</th>
+                        <th>&nbsp;</th>
+                        <th>&nbsp;</th>
+                        <th>&nbsp;</th>
+                        <th>&nbsp;</th>
+                        <th>&nbsp;</th>
                         <th>[% foot_loo.quantity | html %]</th>
-                        <th class="tax_excluded">[% foot_loo.total_tax_excluded | $Price %]</th>
-                        <th class="tax_included">[% foot_loo.total_tax_included | $Price %]</th>
+                        <th>[% foot_loo.total_tax_excluded | $Price %]</th>
+                        <th>[% foot_loo.total_tax_included | $Price %]</th>
                         <th>&nbsp;</th>
                         <th>[% foot_loo.tax_value | $Price %]</th>
                         <th>&nbsp;</th>
                 <tr>
                     <th></th>
                     <th>Total ([% currency | html %])</th>
-                    <th class="tax_excluded">&nbsp;</th>
-                    <th class="tax_excluded">&nbsp;</th>
-                    <th class="tax_included">&nbsp;</th>
-                    <th class="tax_included">&nbsp;</th>
-                    <th class="replacementprice">&nbsp;</th>
+                    <th>&nbsp;</th>
+                    <th>&nbsp;</th>
+                    <th>&nbsp;</th>
+                    <th>&nbsp;</th>
+                    <th>&nbsp;</th>
                     <th>[% total_quantity | html %]</th>
-                    <th class="tax_excluded">[% total_tax_excluded | $Price %]</th>
-                    <th class="tax_included">[% total_tax_included | $Price %]</th>
+                    <th>[% total_tax_excluded | $Price %]</th>
+                    <th>[% total_tax_included | $Price %]</th>
                     <th>&nbsp;</th>
                     <th>[% total_tax_value | $Price %]</th>
                     <th>&nbsp;</th>
                         </td>
                         [% SET zero_regex = "^0{1,}\.?0{1,}[^1-9]" %] [%# 0 or 0.0 or 0.00 or 00 or 00.0 or 00.00 or 0.000 ... %]
                         [%# FIXME: use of a regexp is not ideal; bugs 9410 and 10929 suggest better way of handling this %]
-                        <td class="number tax_excluded [% IF books_loo.rrp_tax_excluded.search(zero_regex) %]error[% END %]">[% books_loo.rrp_tax_excluded | $Price %]</td>
-                        <td class="number tax_excluded [% IF books_loo.ecost_tax_excluded.search(zero_regex) %]error[% END %]">[% books_loo.ecost_tax_excluded | $Price %]</td>
-                        <td class="number tax_included [% IF books_loo.rrp_tax_included.search(zero_regex) %]error[% END %]">[% books_loo.rrp_tax_included | $Price %]</td>
-                        <td class="number tax_included [% IF books_loo.ecost_tax_included.search(zero_regex) %]error[% END %]">[% books_loo.ecost_tax_included | $Price %]</td>
-                        <td class="number replacementprice [% IF books_loo.replacementprice.search(zero_regex) %]error[% END %]">[% books_loo.replacementprice | $Price %]</td>
+                        <td class="number [% IF books_loo.rrp_tax_excluded.search(zero_regex) %]error[% END %]">[% books_loo.rrp_tax_excluded | $Price | html %]</td>
+                        <td class="number [% IF books_loo.ecost_tax_excluded.search(zero_regex) %]error[% END %]">[% books_loo.ecost_tax_excluded | $Price | html %]</td>
+                        <td class="number [% IF books_loo.rrp_tax_included.search(zero_regex) %]error[% END %]">[% books_loo.rrp_tax_included | $Price | html %]</td>
+                        <td class="number [% IF books_loo.ecost_tax_included.search(zero_regex) %]error[% END %]">[% books_loo.ecost_tax_included | $Price | html %]</td>
+                        <td class="number [% IF books_loo.replacementprice.search(zero_regex) %]error[% END %]">[% books_loo.replacementprice | $Price %]</td>
                         <td class="number [% IF books_loo.quantity.search(zero_regex) %]error[% END %]">[% books_loo.quantity | html %]</td>
-                        <td class="number tax_excluded [% IF books_loo.total_tax_excluded.search(zero_regex) %]error[% END %]">[% books_loo.total_tax_excluded | $Price %]</td>
-                        <td class="number tax_included [% IF books_loo.total_tax_included.search(zero_regex) %]error[% END %]">[% books_loo.total_tax_included | $Price %]</td>
+                        <td class="number [% IF books_loo.total_tax_excluded.search(zero_regex) %]error[% END %]">[% books_loo.total_tax_excluded | $Price | html %]</td>
+                        <td class="number [% IF books_loo.total_tax_included.search(zero_regex) %]error[% END %]">[% books_loo.total_tax_included | $Price | html %]</td>
                         <td class="number">[% books_loo.tax_rate * 100 | html %]</td>
                         <td class="number [% IF books_loo.tax_value.search(zero_regex) %]error[% END %]">[% books_loo.tax_value | $Price %]</td>
                         <td>[% books_loo.budget_name | html %]</td>
                         </p>
                       [% END %]
                     </td>
-                    <td class="number tax_excluded">[% order.rrp_tax_excluded | $Price %]</td>
-                    <td class="number tax_excluded">[% order.ecost_tax_excluded | $Price %]</td>
-                    <td class="number tax_included">[% order.rrp_tax_included | $Price %]</td>
-                    <td class="number tax_included">[% order.ecost_tax_included | $Price %]</td>
-                    <td class="number replacementprice">[% order.replacementprice | $Price %]</td>
+                    <td class="number">[% order.rrp_tax_excluded | $Price | html %]</td>
+                    <td class="number">[% order.ecost_tax_excluded | $Price | html %]</td>
+                    <td class="number">[% order.rrp_tax_included | $Price | html %]</td>
+                    <td class="number">[% order.ecost_tax_included | $Price | html %]</td>
+                    <td class="number">[% order.replacementprice | $Price %]</td>
                     <td class="number">[% order.quantity | html %]</td>
-                    <td class="number tax_excluded">[% order.total_tax_excluded | $Price %]</td>
-                    <td class="number tax_included">[% order.total_tax_included | $Price %]</td>
+                    <td class="number">[% order.total_tax_excluded | $Price | html %]</td>
+                    <td class="number">[% order.total_tax_included | $Price | html %]</td>
                     <td class="number">[% order.tax_rate * 100 | html %]</td>
                     <td class="number">[% order.tax_value | $Price %]</td>
                     <td>[% order.budget_name | html %]
 [% MACRO jsinclude BLOCK %]
     [% Asset.js("js/acquisitions-menu.js") | $raw %]
     [% INCLUDE 'datatables.inc' %]
+    [% INCLUDE 'columns_settings.inc' %]
     [% Asset.js("lib/jquery/plugins/jquery.fixFloat.js") | $raw %]
     <script>
         function updateColumnsVisibility(visible) {
 
         $(document).ready(function() {
             if ( $('#toolbar').length ) {$('#toolbar').fixFloat();}
-            $("#show_all_details").click(function(){
-                updateColumnsVisibility($(this).is(":checked"));
-            });
-
-            $("#show_all_details").prop('checked', false);
-            updateColumnsVisibility(false);
             [% UNLESS ( closedate ) %]
                 $('#addtoBasket').on('show', function () {
                    $(this).find(".modal-body").html($(".acqui_basket_add")[0].outerHTML);
         [% END %]
     [% END %]
     <script>
+<<<<<<< HEAD
+=======
+        var columns_settings = [% ColumnsSettings.GetColumns( 'acqui', 'basket', 'orders', 'json' ) %];
+>>>>>>> Bug 20966: Add column configuration to table of orders in a basket
         $(document).ready(function() {
-            var orderst = $("#orders").dataTable($.extend(true, {}, dataTablesDefaults, {
-                "sPaginationType": "four_button",
+            KohaTable("orders", {
                 [% IF ( active ) %]
                     "aoColumnDefs": [
-                        [% UNLESS ( closedate ) %]
-                            { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
-                        [% END %]
+                        { "bSortable": false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
                         { "sType": "anti-the", "aTargets": [ "anti-the" ] }
                     ],
                 [% END %]
-            } ) );
+                "sPaginationType": "four_button",
+                "autoWidth": false
+            }, columns_settings);
+
             var cancelledorderst = $("#cancelledorderst").dataTable($.extend(true, {}, dataTablesDefaults, {
                 "sPaginationType": "four_button"
             } ) );