Bug 11929: patron modification error shows borrowernumber
authorMarc Véron <veron@veron.ch>
Sun, 26 Apr 2015 19:36:25 +0000 (21:36 +0200)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Mon, 1 Jun 2015 17:28:04 +0000 (14:28 -0300)
If an error occurs in patron batch modification, a message similar to the following is displayed:
Can not update patron with borrowernumber 7055

It would be useful to have the cardnumber as well.

This patch adds the card number to the lists of errors.

It is not easy to trigger an error (see comments).
For testing, I tweaked the sub ModMember in C4/Members.pm to always return false.

TEST PLAN
---------
1) Log in as a superlibrarian and create a test user
2) Change the cardnumber to a number differing from the
   borrower number.
3) Home -> Tools -> Batch patron modification
4) Type in the cardnumber of that test user
5) Check the Library checkbox.
6) Click Save
   -- nice error, but it is borrower number instead of
      the card number which was entered.
7) Apply the patch
8) Repeat steps 3-6
   -- nice error, but it is now more informative.
9) run koha qa test tools.

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt
tools/modborrowers.pl

index 66680c9..65ce440 100644 (file)
                             <ul class="warnings">
                             [% FOREACH error IN errors %]
                                 [% IF ( error.error == 'can_not_update' ) %]
-                                    <li>Can not update patron with borrowernumber [% error.borrowernumber %]</li>
+                                    <li>Can not update patron.
+                                    [% IF ( error.cardnumber ) %] Cardnumber:  [% error.cardnumber %] [% END %]
+                                    (Borrowernumber: [% error.borrowernumber %])
+                                    </li>
                                 [% ELSE %]
                                     <li>[% error.error %]</li>
                                 [% END %]
                 [% INCLUDE 'tools-menu.inc' %]
             </div>
         </div>
-[% INCLUDE 'intranet-bottom.inc' %]
\ No newline at end of file
+[% INCLUDE 'intranet-bottom.inc' %]
index 894b632..4172bc3 100755 (executable)
@@ -272,7 +272,11 @@ if ( $op eq 'do' ) {
         if ( defined $infos ) {
             $infos->{borrowernumber} = $borrowernumber;
             my $success = ModMember(%$infos);
-            push @errors, { error => "can_not_update", borrowernumber => $infos->{borrowernumber} } if not $success;
+            if (!$success) {
+                my $borrowerinfo = GetBorrowerInfos( borrowernumber => $borrowernumber );
+                $infos->{cardnumber} = $borrowerinfo->{cardnumber} || '';
+                push @errors, { error => "can_not_update", borrowernumber => $infos->{borrowernumber}, cardnumber => $infos->{cardnumber} };
+            }
         }
 
         #