Bug 10725: Add filters on the pending orders table
authorJonathan Druart <jonathan.druart@biblibre.com>
Thu, 25 Apr 2013 14:57:07 +0000 (16:57 +0200)
committerGalen Charlton <gmc@esilibrary.com>
Wed, 30 Oct 2013 05:10:11 +0000 (05:10 +0000)
Since the parcel.pl script get *all* pending orders, there is no reason
not to display all of them.

Like that, DataTable manages pagination and sorting correctly (on all
data).
This patch adds filters on the table header (using columnFilter).

Test plan:
Try filters on the left of the screen and filters on the table header.

Signed-off-by: Pierre Angot <tredok.pierre@gmail.com>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Passes all tests and QA script.
Searching and sorting the table works correctly.
Larger result sets are a performance problem on this page,
I have filed bug 10595 for that.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>

acqui/parcel.pl
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt

index 42f2960..839c2a9 100755 (executable)
@@ -203,7 +203,7 @@ for my $item ( @parcelitems ) {
 push @book_foot_loop, map { $_ } values %foot;
 
 my @loop_orders = ();
-if(!defined $invoice->{closedate}) {
+unless( defined $invoice->{closedate} ) {
     my $pendingorders;
     if($op eq "search"){
         my $search   = $input->param('summaryfilter') || '';
index 250cc96..fef72dc 100644 (file)
@@ -4,6 +4,7 @@
 <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
 [% INCLUDE 'doc-head-close.inc' %]
 [% INCLUDE 'datatables.inc' %]
+<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.columnFilter.js"></script>
 [% INCLUDE 'greybox.inc' %]
 <script type="text/javascript">
 //<![CDATA[
@@ -15,7 +16,7 @@
         var pendingt = $("#pendingt").dataTable($.extend(true, {}, dataTablesDefaults, {
             "bStateSave": true,
             "iCookieDuration": 60*60*24*1000, // 1000 days
-            "aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
+            "aLengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, "All"]],
             "aoColumnDefs": [
                 { "aTargets": [ 3, 8, 9 ], "bSortable": false, "bSearchable": false },
             ],
                 null,
                 null,
             ],
+            'bAutoWidth': false,
             "sPaginationType": "four_button"
-        } ) );
+        } )
+        ).columnFilter({
+            sPlaceHolder: "head:after",
+            aoColumns: [
+                { type: "text" },
+                { type: "text" },
+                { type: "text" },
+                null,
+                { type: "text" },
+                { type: "text" },
+                { type: "text" },
+                { type: "text" },
+                null,
+                null
+            ]
+        });
       }
+
       if ( $("#receivedt").length ) {
         var receivedt = $("#receivedt").dataTable($.extend(true, {}, dataTablesDefaults, {
             "bStateSave": true,
             "iCookieDuration": 60*60*24*1000, // 1000 days
-            "aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
+            "aLengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, "All"]],
             "aoColumnDefs": [
                 { "aTargets": [ 3, -1 ], "bSortable": false, "bSearchable": false },
             ],
 <p><strong>Invoice number:</strong> [% invoice %] <strong>Received by:</strong> [% loggedinusername %] <strong>On:</strong> [% formatteddatereceived %]</p>
 </div>
 [% UNLESS (invoiceclosedate) %]
-<div id="acqui_receive_search">
+  <div id="acqui_receive_search">
     <h3>Pending orders</h3>
 
- [% IF ( loop_orders ) %]<table id="pendingt">
-    <thead>
-        <tr>
+    [% IF ( loop_orders ) %]
+      <table id="pendingt">
+        <thead>
+          <tr>
+            <th>Basket search</th>
+            <th>Order line search</th>
+            <th>Summary search</th>
+            <th>&nbsp;</th>
+            <th>Quantity search</th>
+            <th>Unit cost search</th>
+            <th>Order cost search</th>
+            <th>Fund search</th>
+            <th>&nbsp;</th>
+            <th>&nbsp;</th>
+          </tr>
+          <tr>
             <th>Basket</th>
             <th>Order line</th>
             <th>Summary</th>
             <th>Fund</th>
             <th>&nbsp;</th>
             <th>&nbsp;</th>
-        </tr>
-    </thead>
-    <tbody class="filterclass">
+          </tr>
+        </thead>
+        <tbody class="filterclass">
         [% FOREACH loop_order IN loop_orders %]
             <tr>
                 <td class="basketfilterclass">[% loop_order.basketname %] (<a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% loop_order.basketno %]">[% loop_order.basketno %]</a>)</td>
                         [% END %]
                     </td>
                 </tr>
-            [% END %]
+        [% END %]
         </tbody>
-        </table>
-        [% ELSE %]There are no pending orders.[% END %]
-    </div>
+      </table>
+    [% ELSE %]There are no pending orders.[% END %]
+  </div>
 [% ELSE %]
     <p>
         Invoice is closed, so you can't receive orders anymore.