[Koha-patches] [PATCH] Bug 12018 - add table sorting to patron card batches

Owen Leonard oleonard at myacpl.org
Wed Apr 2 16:47:06 CEST 2014


When viewing batches of patrons in the patron card creator module the
table is not sortable. This patch adds table sorting.

The patch also makes some corrections of invalid markup and moves
informational/error messages to the top of the page rather than in a
sidebar. This change lets the table and sorting controls expand into a
wider space.

This patch also corrects a translation issue with table headers
identical to that addressed by Bug 11505.

To test, go to Tools -> Patron card creator -> Manage batches.
View an existing batch or create a new batch and populate it with
patrons. Table sorting controls should work correctly. Batch management
operations should work correctly.
---
 .../prog/en/modules/patroncards/edit-batch.tt      |   92 ++++++++++++--------
 1 file changed, 56 insertions(+), 36 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt
index ac4e051..60806f1 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt
@@ -2,6 +2,8 @@
     <title>Koha › Tools › Patron card creator › Manage patron card batches</title>
     [% INCLUDE 'doc-head-close.inc' %]
     [% INCLUDE 'greybox.inc' %]
+    <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
+    [% INCLUDE 'datatables.inc' %]
     <script type="text/javascript">
         //<![CDATA[
            function DeleteConfirm() {
@@ -99,6 +101,13 @@
             };
 
          $(document).ready(function() {
+            $("#batcht").dataTable($.extend(true, {}, dataTablesDefaults, {
+                "aoColumnDefs": [
+                    { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false }
+                ],
+                "aaSorting": [[ 1, "asc" ]],
+                "sPaginationType": "four_button"
+            }));
             $("#additems").click(function(){
                 Add();
                 return false;
@@ -151,47 +160,59 @@
                     <a class="btn btn-small" id="exportbatch" href="#">Export batch</a>[% END %]
                 </div>
 
+                [% IF ( duplicate_message ) %]
+                    <div class="dialog message">
+                        <strong>[% duplicate_count %] duplicate item(s) found</strong> and removed from batch [% batch_id %].
+                    </div>
+                [% END %]
 
                     [% INCLUDE 'patroncards-errors.inc' %]
-                    <div class="yui-g">
-                        <div class="yui-u first" id="manage-patroncard-batches">
-                            <div class="hint">Current library: [% LoginBranchname %]</div>
-                                [% IF ( table_loop ) %]
-                                <form name="items" class="checkboxed">
-                                    <h2>Items in batch number [% batch_id %]</h2>
-                                    <table>
-                                        [% FOREACH table_loo IN table_loop %]
+                    <div id="manage-patroncard-batches">
+                        <div class="hint">Current library: [% LoginBranchname %]</div>
+                            [% IF ( table_loop ) %]
+                            <form name="items" class="checkboxed">
+                                <h2>Items in batch number [% batch_id %]</h2>
+                                <table id="batcht">
+                                    [% FOREACH table_loo IN table_loop %]
                                         [% IF ( table_loo.header_fields ) %]
-                                        <tr>
-                                        [% FOREACH header_field IN table_loo.header_fields %]
-                                            <th>[% header_field.field_label %]</th>
-                                        [% END %]
-                                        </tr>
-                                        [% ELSE %]
-                                        <tr>
-                                        [% FOREACH text_field IN table_loo.text_fields %]
-                                        [% IF ( text_field.select_field ) %]
-                                            <td align="center"><input type="checkbox" name="action" value="[% text_field.field_value %]"></td>
+                                            <thead>
+                                                <tr>
+                                                    [% FOREACH header_field IN table_loo.header_fields %]
+                                                        [% SWITCH header_field.field_label -%]
+                                                            [% CASE "Card Number" -%]
+                                                                <th>Card number</th>
+                                                            [% CASE "Summary" -%]
+                                                                <th>Summary</th>
+                                                            [% CASE "Borrower Number" %]
+                                                                <th>Borrower number</th>
+                                                            [% CASE "Select" -%]
+                                                                <th>Select</th>
+                                                            [% CASE %]
+                                                                <th>[% header_field.field_label %]</th>
+                                                        [% END -%]
+                                                    [% END %]
+                                                </tr>
+                                            </thead>
+                                            <tbody>
                                         [% ELSE %]
-                                            <td>[% text_field.field_value %]</td>
-                                        [% END %]
-                                        [% END %]
-                                        </tr>
-                                        [% END %]
+                                            <tr>
+                                                [% FOREACH text_field IN table_loo.text_fields %]
+                                                    [% IF ( text_field.select_field ) %]
+                                                        <td><input type="checkbox" name="action" value="[% text_field.field_value %]" /></td>
+                                                    [% ELSE %]
+                                                        <td>[% text_field.field_value %]</td>
+                                                    [% END %]
+                                                [% END %]
+                                            </tr>
                                         [% END %]
-                                    </table>
-                                </form>
-                                [% ELSE %]
-                                    <div class="dialog message"><h4>There are no items in batch [% batch_id %] yet</h4>
-                                    <p>Use the toolbar above to add items.</p></div>
-                                [% END %]
-                            </div>
-                            [% IF ( duplicate_message ) %]
-                            <div class="yui-u">
+                                    [% END %]
+                                    </tbody>
+                                </table>
+                            </form>
+                            [% ELSE %]
                                 <div class="dialog message">
-                                    <strong>[% duplicate_count %] duplicate item(s) found</strong> and removed from batch [% batch_id %].
-                                </div>
-                            </div>
+                                <h4>There are no items in batch [% batch_id %] yet</h4>
+                                <p>Use the toolbar above to add items.</p></div>
                             [% END %]
                         </div>
                     </div>
@@ -200,5 +221,4 @@
                     [% INCLUDE 'patroncards-menu.inc' %]
                 </div>
             </div>
-        </div>
     [% INCLUDE 'intranet-bottom.inc' %]
-- 
1.7.9.5


More information about the Koha-patches mailing list