[Koha-patches] [PATCH] Bug 12309 - Add more fields to batch patron modification tool

Owen Leonard oleonard at myacpl.org
Thu May 22 16:03:29 CEST 2014


It would be helpful to be able to use the batch patron modification tool
to update city, state, zipcode, and country. This patch adds this
functionality.

This patch corrects an error in the batch modification script which
would have incorrectly marked first name as required if surname was
required.

This patch also converts the table sorting configuration to use table
header class names instead of index-based sorting for columns containing
dates.

To test, apply the patch and submit a batch of patrons to the batch
patron modification tool (Tools -> Batch patron modification).

In the list of patrons which will be modified you should see columns for
city, state, zipcode, and country. Table sorting should work correctly
without errors, including the registration and expiry date columns.

In the list of fields which can be batch modified you should see inputs
for city, state zipcode, and country. These fields should correctly
reflect mandatory/not mandatory based on the BorrowerMandatoryField
system preference.

Submit batch changes to a variety of fields and confirm that changes are
applied correctly. On the page of results the table should correctly
show all fields and be sorted correctly.
---
 .../prog/en/modules/tools/modborrowers.tt          |   28 +++++++++++++-----
 tools/modborrowers.pl                              |   31 ++++++++++++++++++--
 2 files changed, 49 insertions(+), 10 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt
index dfb2107..b4f4c52 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt
@@ -14,15 +14,13 @@
                 $("#borrowerst").dataTable($.extend(true, {}, dataTablesDefaults, {
                     "sDom": 't',
                     [% IF ( op == 'show_results' ) %]
-                        "aoColumns": [
-                            null,null,null,null,null,{ "sType": "title-string" },{ "sType": "title-string" }[% FOREACH attrh IN attributes_header %],null[% END %]
+                        "aoColumnDefs": [
+                            { 'sType': "title-string", 'aTargets' : [ 'title-string'] }
                         ],
                     [% ELSE %]
                         "aoColumnDefs": [
                             { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
-                        ],
-                        "aoColumns": [
-                            null,null,null,null,null,null,{ "sType": "title-string" },{ "sType": "title-string" }[% FOREACH attrh IN attributes_header %],null[% END %]
+                            { 'sType': "title-string", 'aTargets' : [ 'title-string'] }
                         ],
                     [% END %]
                     "bPaginate": false
@@ -232,8 +230,12 @@
                                                 <th>First name</th>
                                                 <th>Library</th>
                                                 <th>Category</th>
-                                                <th>Registration date</th>
-                                                <th>Expiry date</th>
+                                                <th>City</th>
+                                                <th>State</th>
+                                                <th>Zip code</th>
+                                                <th>Country</th>
+                                                <th class="title-string">Registration date</th>
+                                                <th class="title-string">Expiry date</th>
                                                 [% FOREACH attrh IN attributes_header %]
                                                     <th>[% attrh.attribute %]</th>
                                                 [% END %]
@@ -250,6 +252,10 @@
                                                     <td>[% borrower.firstname %]</td>
                                                     <td>[% borrower.branchname %]</td>
                                                     <td>[% borrower.categorycode %]</td>
+                                                    <td>[% borrower.city %]</td>
+                                                    <td>[% borrower.state %]</td>
+                                                    <td>[% borrower.zipcode %]</td>
+                                                    <td>[% borrower.country %]</td>
                                                     <td><span title="[% borrower.dateenrolled %]">[% borrower.dateenrolled | $KohaDates %]</span></td>
                                                     <td><span title="[% borrower.dateexpiry %]">[% borrower.dateexpiry | $KohaDates %]</span></td>
                                                     [% FOREACH pa IN borrower.patron_attributes %]
@@ -288,6 +294,14 @@
                                                 Library:
                                                 [% CASE 'categorycode' %]
                                                 Category
+                                                [% CASE 'city' %]
+                                                City
+                                                [% CASE 'state' %]
+                                                State
+                                                [% CASE 'zipcode' %]
+                                                Zip code
+                                                [% CASE 'country' %]
+                                                Country
                                                 [% CASE 'sort1' %]
                                                 Sort 1:
                                                 [% CASE 'sort2' %]
diff --git a/tools/modborrowers.pl b/tools/modborrowers.pl
index 5bd2103..3b7808b 100755
--- a/tools/modborrowers.pl
+++ b/tools/modborrowers.pl
@@ -21,7 +21,8 @@
 #
 # Batch Edit Patrons
 # Modification for patron's fields:
-# surname firstname branchcode categorycode sort1 sort2 dateenrolled dateexpiry borrowernotes
+# surname firstname branchcode categorycode city state zipcode country sort1
+# sort2 dateenrolled dateexpiry borrowernotes
 # And for patron attributes.
 
 use Modern::Perl;
@@ -169,7 +170,7 @@ if ( $op eq 'show' ) {
         {
             name => "firstname",
             type => "text",
-            mandatory => ( grep /surname/, @mandatoryFields ) ? 1 : 0,
+            mandatory => ( grep /firstname/, @mandatoryFields ) ? 1 : 0,
         }
         ,
         {
@@ -187,6 +188,30 @@ if ( $op eq 'show' ) {
         }
         ,
         {
+            name => "city",
+            type => "text",
+            mandatory => ( grep /city/, @mandatoryFields ) ? 1 : 0,
+        }
+        ,
+        {
+            name => "state",
+            type => "text",
+            mandatory => ( grep /state/, @mandatoryFields ) ? 1 : 0,
+        }
+        ,
+        {
+            name => "zipcode",
+            type => "text",
+            mandatory => ( grep /zipcode/, @mandatoryFields ) ? 1 : 0,
+        }
+        ,
+        {
+            name => "country",
+            type => "text",
+            mandatory => ( grep /country/, @mandatoryFields ) ? 1 : 0,
+        }
+        ,
+        {
             name => "sort1",
             type => @sort1_option ? "select" : "text",
             option => \@sort1_option,
@@ -230,7 +255,7 @@ if ( $op eq 'do' ) {
 
     my @disabled = $input->param('disable_input');
     my $infos;
-    for my $field ( qw/surname firstname branchcode categorycode sort1 sort2 dateenrolled dateexpiry borrowernotes/ ) {
+    for my $field ( qw/surname firstname branchcode categorycode city state zipcode country sort1 sort2 dateenrolled dateexpiry borrowernotes/ ) {
         my $value = $input->param($field);
         $infos->{$field} = $value if $value;
         $infos->{$field} = "" if grep { /^$field$/ } @disabled;
-- 
1.7.9.5


More information about the Koha-patches mailing list