Bug 16852: Remove GetBorrowerCategorycode
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 4 Jul 2016 12:38:45 +0000 (13:38 +0100)
committerKyle M Hall <kyle@bywatersolutions.com>
Wed, 2 Nov 2016 10:56:39 +0000 (10:56 +0000)
And use Koha::Patron->categorycode instead

Test plan:
- Restrict a patron attribute to a patron category
- Use the batch patron modification tool to update a patron of this
  category
You should not see the the patron attribute

Signed-off-by: Claire Gravely <claire_gravely@hotmail.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
C4/Members.pm
tools/modborrowers.pl

index 8d3c3cf..8953d85 100644 (file)
@@ -78,8 +78,6 @@ BEGIN {
         &GetMemberAccountRecords
         &GetBorNotifyAcctRecord
 
-        GetBorrowerCategorycode
-
         &GetBorrowersToExpunge
         &GetBorrowersWhoHaveNeverBorrowed
         &GetBorrowersWithIssuesHistoryOlderThan
@@ -522,7 +520,7 @@ sub ModMember {
         }
     }
 
-    my $old_categorycode = GetBorrowerCategorycode( $data{borrowernumber} );
+    my $old_categorycode = Koha::Patrons->find( $data{borrowernumber} )->categorycode;
 
     # get only the columns of a borrower
     my $schema = Koha::Database->new()->schema;
@@ -1213,26 +1211,6 @@ sub GetUpcomingMembershipExpires {
     return $results;
 }
 
-=head2 GetBorrowerCategorycode
-
-    $categorycode = &GetBorrowerCategoryCode( $borrowernumber );
-
-Given the borrowernumber, the function returns the corresponding categorycode
-
-=cut
-
-sub GetBorrowerCategorycode {
-    my ( $borrowernumber ) = @_;
-    my $dbh = C4::Context->dbh;
-    my $sth = $dbh->prepare( qq{
-        SELECT categorycode
-        FROM borrowers
-        WHERE borrowernumber = ?
-    } );
-    $sth->execute( $borrowernumber );
-    return $sth->fetchrow;
-}
-
 =head2 GetAge
 
   $dateofbirth,$date = &GetAge($date);
index 31e4ec1..8f0a567 100755 (executable)
@@ -38,6 +38,7 @@ use Koha::DateUtils qw( dt_from_string );
 use Koha::List::Patron;
 use Koha::Libraries;
 use Koha::Patron::Categories;
+use Koha::Patrons;
 
 my $input = new CGI;
 my $op = $input->param('op') || 'show_form';
@@ -294,8 +295,7 @@ if ( $op eq 'do' ) {
             }
         }
 
-        #
-        my $borrower_categorycode = GetBorrowerCategorycode $borrowernumber;
+        my $borrower_categorycode = Koha::Patrons->find( $borrowernumber )->categorycode;
         my $i=0;
         for ( @attributes ) {
             my $attribute;