From 31847c7bd5a4d6fd77bf6c15e08764a44658a05e Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 22 May 2014 09:23:45 -0400 Subject: [PATCH] Bug 12309 - Add more fields to batch patron modification tool 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. Signed-off-by: cachan Signed-off-by: Jonathan Druart Signed-off-by: Tomas Cohen Arazi --- .../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 dfb21072c7..b4f4c52b05 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 @@ First name Library Category - Registration date - Expiry date + City + State + Zip code + Country + Registration date + Expiry date [% FOREACH attrh IN attributes_header %] [% attrh.attribute %] [% END %] @@ -250,6 +252,10 @@ [% borrower.firstname %] [% borrower.branchname %] [% borrower.categorycode %] + [% borrower.city %] + [% borrower.state %] + [% borrower.zipcode %] + [% borrower.country %] [% borrower.dateenrolled | $KohaDates %] [% borrower.dateexpiry | $KohaDates %] [% 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 e844a2b21b..a3f8b3f173 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, } , { @@ -186,6 +187,30 @@ if ( $op eq 'show' ) { mandatory => ( grep /categorycode/, @mandatoryFields ) ? 1 : 0, } , + { + 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", @@ -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; -- 2.20.1