Browse Source

Modifying Members : Add Mod and GetMember

This update the way Member is added and editing so that import and Edition
 could be best automatized
GetMember evolves and allow ppl to serach on a hash of data

Adding SQLHelper A new package to deal with INSERT UPDATE and SELECT

Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
3.2.x
Henri-Damien LAURENT 14 years ago
parent
commit
4271bbb738
  1. 2
      C4/Accounts.pm
  2. 6
      C4/Letters.pm
  3. 163
      C4/Members.pm
  4. 2
      C4/Reports/Guided.pm
  5. 4
      C4/Reserves.pm
  6. 6
      C4/SIP/ILS/Item.pm
  7. 2
      C4/SIP/ILS/Patron.pm
  8. 6
      C4/SIP/ILS/Transaction/Hold.pm
  9. 2
      C4/SIP/ILS/Transaction/Renew.pm
  10. 2
      C4/SIP/ILS/Transaction/RenewAll.pm
  11. 2
      C4/SIP/interactive_members_dump.pl
  12. 280
      C4/SQLHelper.pm
  13. 4
      C4/VirtualShelves/Page.pm
  14. 2
      acqui/acqui-home.pl
  15. 2
      acqui/neworderempty.pl
  16. 2
      circ/branchtransfers.pl
  17. 2
      members/boraccount.pl
  18. 2
      members/borrowers_details.pl
  19. 2
      members/mancredit.pl
  20. 2
      members/maninvoice.pl
  21. 2
      members/member-password.pl
  22. 4
      members/memberentry.pl
  23. 2
      members/messaging.pl
  24. 6
      members/moremember.pl
  25. 2
      members/notices.pl
  26. 2
      members/pay.pl
  27. 2
      members/readingrec.pl
  28. 2
      members/update-child.pl
  29. 2
      misc/cronjobs/holds/build_holds_queue.pl
  30. 6
      offline_circ/process_koc.pl
  31. 2
      opac/opac-ISBDdetail.pl
  32. 2
      opac/opac-detail.pl
  33. 2
      opac/opac-main.pl
  34. 2
      reserve/placerequest.pl
  35. 2
      reviews/reviewswaiting.pl
  36. 2
      serials/routing-preview.pl
  37. 2
      serials/routing.pl
  38. 20
      t/db_dependent/SQLHelper.t
  39. 2
      t/lib/KohaTest/Acquisition.pm
  40. 2
      t/lib/KohaTest/Acquisition/GetLateOrders.pm
  41. 4
      t/lib/KohaTest/Members.pm
  42. 12
      t/lib/KohaTest/Members/GetMember.pm
  43. 2
      t/lib/KohaTest/Overdues/GetOverdues.pm
  44. 2
      t/lib/KohaTest/Scripts/longoverdue.pm
  45. 2
      tools/import_borrowers.pl
  46. 2
      tools/viewlog.pl

2
C4/Accounts.pm

@ -266,7 +266,7 @@ EOT
sub returnlost{
my ( $borrowernumber, $itemnum ) = @_;
C4::Circulation::MarkIssueReturned( $borrowernumber, $itemnum );
my $borrower = C4::Members::GetMember( $borrowernumber, 'borrowernumber' );
my $borrower = C4::Members::GetMember( 'borrowernumber'=>$borrowernumber );
my @datearr = localtime(time);
my $date = ( 1900 + $datearr[5] ) . "-" . ( $datearr[4] + 1 ) . "-" . $datearr[3];
my $bor = "$borrower->{'firstname'} $borrower->{'surname'} $borrower->{'cardnumber'}";

6
C4/Letters.pm

@ -271,7 +271,7 @@ sub SendAlerts {
# and parse borrower ...
my $innerletter = $letter;
my $borinfo = GetMember( $_->{'borrowernumber'}, 'borrowernumber' );
my $borinfo = GetMember( 'borrowernumber' => $_->{'borrowernumber'});
parseletter( $innerletter, 'borrowers', $_->{'borrowernumber'} );
# ... then send mail
@ -773,7 +773,7 @@ sub _send_message_by_email ($) {
my $to_address = $message->{to_address};
unless ($to_address) {
my $member = C4::Members::GetMember( $message->{'borrowernumber'} );
my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} );
unless ($member) {
warn "FAIL: No 'to_address' and INVALID borrowernumber ($message->{borrowernumber})";
_set_message_status( { message_id => $message->{'message_id'},
@ -817,7 +817,7 @@ sub _send_message_by_email ($) {
sub _send_message_by_sms ($) {
my $message = shift or return undef;
my $member = C4::Members::GetMember( $message->{'borrowernumber'} );
my $member = C4::Members::GetMember( 'borrowernumber' => $message->{'borrowernumber'} );
return unless $member->{'smsalertnumber'};
my $success = C4::SMS->send_sms( { destination => $member->{'smsalertnumber'},

163
C4/Members.pm

@ -28,6 +28,7 @@ use C4::Overdues;
use C4::Reserves;
use C4::Accounts;
use C4::Biblio;
use C4::SQLHelper qw(InsertInTable UpdateInTable);
our ($VERSION,@ISA,@EXPORT,@EXPORT_OK,$debug);
@ -470,7 +471,7 @@ sub patronflags {
=head2 GetMember
$borrower = &GetMember($information, $type);
$borrower = &GetMember(%information);
Looks up information about a patron (borrower) by either card number
,firstname, or borrower number, depending on $type value.
@ -485,7 +486,7 @@ the C<borrowers> table in the Koha database.
#'
sub GetMember {
my ( $information, $type ) = @_;
my ( %information ) = @_;
my $dbh = C4::Context->dbh;
my $sth;
my $select = "
@ -493,25 +494,18 @@ SELECT borrowers.*, categories.category_type, categories.description
FROM borrowers
LEFT JOIN categories on borrowers.categorycode=categories.categorycode
";
if (defined($type) and ( $type eq 'cardnumber' || $type eq 'firstname'|| $type eq 'userid'|| $type eq 'borrowernumber' ) ){
$information = uc $information;
$sth = $dbh->prepare("$select WHERE $type=?");
} else {
$sth = $dbh->prepare("$select WHERE borrowernumber=?");
}
$sth->execute($information);
my $data = $sth->fetchrow_hashref;
($data) and return ($data);
if (defined($type) and ($type eq 'cardnumber' || $type eq 'firstname')) { # otherwise, try with firstname
$sth = $dbh->prepare("$select WHERE firstname like ?");
$sth->execute($information);
$data = $sth->fetchrow_hashref;
($data) and return ($data);
}
return undef;
$select.=" WHERE ".join(" AND ",map {"$_ = ?"}keys %information);
$select=~s/AND $//;
$debug && warn $select, " ",values %information;
$sth = $dbh->prepare("$select");
$sth->execute(map{$information{$_}} keys %information);
my $data = $sth->fetchall_arrayref({});
return undef if (scalar(@$data)==0);
if (scalar(@$data)==1) {return $$data[0];}
($data) and return $data;
}
=head2 IsMemberBlocked
=over 4
@ -641,32 +635,8 @@ true on success, or false on failure
=back
=cut
sub ModMember {
my (%data) = @_;
my $dbh = C4::Context->dbh;
my $iso_re = C4::Dates->new()->regexp('iso');
foreach (qw(dateofbirth dateexpiry dateenrolled)) {
if (my $tempdate = $data{$_}) { # assignment, not comparison
($tempdate =~ /$iso_re/) and next; # Congatulations, you sent a valid ISO date.
warn "ModMember given $_ not in ISO format ($tempdate)";
my $tempdate2 = format_date_in_iso($tempdate);
if (!$tempdate2 or $tempdate2 eq '0000-00-00') {
warn "ModMember cannot convert '$tempdate' (from syspref to ISO)";
next;
}
$data{$_} = $tempdate2;
}
}
if (!$data{'dateofbirth'}){
delete $data{'dateofbirth'};
}
my @columns = &columns;
my %hashborrowerfields = (map {$_=>1} @columns);
my $query = "UPDATE borrowers SET \n";
my $sth;
my @parameters;
# test to know if you must update or not the borrower password
if (exists $data{password}) {
if ($data{password} eq '****' or $data{password} eq '') {
@ -675,26 +645,7 @@ sub ModMember {
$data{password} = md5_base64($data{password});
}
}
my @badkeys;
foreach (keys %data) {
next if ($_ eq 'borrowernumber' or $_ eq 'flags');
if ($hashborrowerfields{$_}){
$query .= " $_=?, ";
push @parameters,$data{$_};
} else {
push @badkeys, $_;
delete $data{$_};
}
}
(@badkeys) and warn scalar(@badkeys) . " Illegal key(s) passed to ModMember: " . join(',',@badkeys);
$query =~ s/, $//;
$query .= " WHERE borrowernumber=?";
push @parameters, $data{'borrowernumber'};
$debug and print STDERR "$query (executed w/ arg: $data{'borrowernumber'})";
$sth = $dbh->prepare($query);
my $execute_success = $sth->execute(@parameters);
$sth->finish;
my $execute_success=UpdateInTable("borrowers",\%data);
# ok if its an adult (type) it may have borrowers that depend on it as a guarantor
# so when we update information for an adult we should check for guarantees and update the relevant part
# of their records, ie addresses and phone numbers
@ -703,7 +654,7 @@ sub ModMember {
# is adult check guarantees;
UpdateGuarantees(%data);
}
logaction("MEMBERS", "MODIFY", $data{'borrowernumber'}, "$query (executed w/ arg: $data{'borrowernumber'})")
logaction("MEMBERS", "MODIFY", $data{'borrowernumber'}, "UPDATE (executed w/ arg: $data{'borrowernumber'})")
if C4::Context->preference("BorrowersLog");
return $execute_success;
@ -727,88 +678,12 @@ sub AddMember {
my $dbh = C4::Context->dbh;
$data{'userid'} = '' unless $data{'password'};
$data{'password'} = md5_base64( $data{'password'} ) if $data{'password'};
# WE SHOULD NEVER PASS THIS SUBROUTINE ANYTHING OTHER THAN ISO DATES
# IF YOU UNCOMMENT THESE LINES YOU BETTER HAVE A DARN COMPELLING REASON
# $data{'dateofbirth'} = format_date_in_iso( $data{'dateofbirth'} );
# $data{'dateenrolled'} = format_date_in_iso( $data{'dateenrolled'});
# $data{'dateexpiry'} = format_date_in_iso( $data{'dateexpiry'} );
# This query should be rewritten to use "?" at execute.
if (!$data{'dateofbirth'}){
undef ($data{'dateofbirth'});
}
my $query =
"insert into borrowers set cardnumber=" . $dbh->quote( $data{'cardnumber'} )
. ",surname=" . $dbh->quote( $data{'surname'} )
. ",firstname=" . $dbh->quote( $data{'firstname'} )
. ",title=" . $dbh->quote( $data{'title'} )
. ",othernames=" . $dbh->quote( $data{'othernames'} )
. ",initials=" . $dbh->quote( $data{'initials'} )
. ",streetnumber=". $dbh->quote( $data{'streetnumber'} )
. ",streettype=" . $dbh->quote( $data{'streettype'} )
. ",address=" . $dbh->quote( $data{'address'} )
. ",address2=" . $dbh->quote( $data{'address2'} )
. ",zipcode=" . $dbh->quote( $data{'zipcode'} )
. ",country=" . $dbh->quote( $data{'country'} )
. ",city=" . $dbh->quote( $data{'city'} )
. ",phone=" . $dbh->quote( $data{'phone'} )
. ",email=" . $dbh->quote( $data{'email'} )
. ",mobile=" . $dbh->quote( $data{'mobile'} )
. ",phonepro=" . $dbh->quote( $data{'phonepro'} )
. ",opacnote=" . $dbh->quote( $data{'opacnote'} )
. ",guarantorid=" . $dbh->quote( $data{'guarantorid'} )
. ",dateofbirth=" . $dbh->quote( $data{'dateofbirth'} )
. ",branchcode=" . $dbh->quote( $data{'branchcode'} )
. ",categorycode=" . $dbh->quote( $data{'categorycode'} )
. ",dateenrolled=" . $dbh->quote( $data{'dateenrolled'} )
. ",contactname=" . $dbh->quote( $data{'contactname'} )
. ",borrowernotes=" . $dbh->quote( $data{'borrowernotes'} )
. ",dateexpiry=" . $dbh->quote( $data{'dateexpiry'} )
. ",contactnote=" . $dbh->quote( $data{'contactnote'} )
. ",B_address=" . $dbh->quote( $data{'B_address'} )
. ",B_address2=" . $dbh->quote( $data{'B_address2'} )
. ",B_zipcode=" . $dbh->quote( $data{'B_zipcode'} )
. ",B_country=" . $dbh->quote( $data{'B_country'} )
. ",B_city=" . $dbh->quote( $data{'B_city'} )
. ",B_phone=" . $dbh->quote( $data{'B_phone'} )
. ",B_email=" . $dbh->quote( $data{'B_email'} )
. ",password=" . $dbh->quote( $data{'password'} )
. ",userid=" . $dbh->quote( $data{'userid'} )
. ",sort1=" . $dbh->quote( $data{'sort1'} )
. ",sort2=" . $dbh->quote( $data{'sort2'} )
. ",contacttitle=" . $dbh->quote( $data{'contacttitle'} )
. ",emailpro=" . $dbh->quote( $data{'emailpro'} )
. ",contactfirstname=" . $dbh->quote( $data{'contactfirstname'} )
. ",sex=" . $dbh->quote( $data{'sex'} )
. ",fax=" . $dbh->quote( $data{'fax'} )
. ",relationship=" . $dbh->quote( $data{'relationship'} )
. ",B_streetnumber=" . $dbh->quote( $data{'B_streetnumber'} )
. ",B_streettype=" . $dbh->quote( $data{'B_streettype'} )
. ",gonenoaddress=" . $dbh->quote( $data{'gonenoaddress'} )
. ",lost=" . $dbh->quote( $data{'lost'} )
. ",debarred=" . $dbh->quote( $data{'debarred'} )
. ",ethnicity=" . $dbh->quote( $data{'ethnicity'} )
. ",ethnotes=" . $dbh->quote( $data{'ethnotes'} )
. ",altcontactsurname=" . $dbh->quote( $data{'altcontactsurname'} )
. ",altcontactfirstname=" . $dbh->quote( $data{'altcontactfirstname'} )
. ",altcontactaddress1=" . $dbh->quote( $data{'altcontactaddress1'} )
. ",altcontactaddress2=" . $dbh->quote( $data{'altcontactaddress2'} )
. ",altcontactaddress3=" . $dbh->quote( $data{'altcontactaddress3'} )
. ",altcontactzipcode=" . $dbh->quote( $data{'altcontactzipcode'} )
. ",altcontactcountry=" . $dbh->quote( $data{'altcontactcountry'} )
. ",altcontactphone=" . $dbh->quote( $data{'altcontactphone'} ) ;
$debug and print STDERR "AddMember SQL: ($query)\n";
my $sth = $dbh->prepare($query);
# print "Executing SQL: $query\n";
$sth->execute();
$sth->finish;
$data{'borrowernumber'} = $dbh->{'mysql_insertid'}; # unneeded w/ autoincrement ?
$data{'borrowernumber'}=InsertInTable("borrowers",\%data);
# mysql_insertid is probably bad. not necessarily accurate and mysql-specific at best.
logaction("MEMBERS", "CREATE", $data{'borrowernumber'}, "") if C4::Context->preference("BorrowersLog");
# check for enrollment fee & add it if needed
$sth = $dbh->prepare("SELECT enrolmentfee FROM categories WHERE categorycode=?");
my $sth = $dbh->prepare("SELECT enrolmentfee FROM categories WHERE categorycode=?");
$sth->execute($data{'categorycode'});
my ($enrolmentfee) = $sth->fetchrow;
if ($enrolmentfee && $enrolmentfee > 0) {
@ -818,6 +693,7 @@ sub AddMember {
return $data{'borrowernumber'};
}
sub Check_Userid {
my ($uid,$member) = @_;
my $dbh = C4::Context->dbh;
@ -1754,10 +1630,9 @@ Returns ISO date.
sub ExtendMemberSubscriptionTo {
my ( $borrowerid,$date) = @_;
my $dbh = C4::Context->dbh;
my $borrower = GetMember($borrowerid,'borrowernumber');
my $borrower = GetMember('borrowernumber'=>$borrowerid);
unless ($date){
$date=POSIX::strftime("%Y-%m-%d",localtime());
my $borrower = GetMember($borrowerid,'borrowernumber');
$date = GetExpiryDate( $borrower->{'categorycode'}, $date );
}
my $sth = $dbh->do(<<EOF);

2
C4/Reports/Guided.pm

@ -523,7 +523,7 @@ sub get_saved_reports {
foreach (@$result){
$_->{date_created} = format_date($_->{date_created});
my $member = C4::Members::GetMember($_->{borrowernumber});
my $member = C4::Members::GetMember(borrowernumber=>$_->{borrowernumber});
$_->{borrowerfirstname} = $member->{firstname};
$_->{borrowersurname} = $member->{surname};
}

4
C4/Reserves.pm

@ -340,7 +340,7 @@ sub CanBookBeReserved{
my $dbh = C4::Context->dbh;
my $biblio = GetBiblioData($biblionumber);
my $borrower = C4::Members::GetMember($borrowernumber);
my $borrower = C4::Members::GetMember(borrowernumber=>$borrowernumber);
my $controlbranch = C4::Context->preference('ReservesControlBranch');
my $itype = C4::Context->preference('item-level_itypes');
my $reservesrights= 0;
@ -431,7 +431,7 @@ sub CanItemBeReserved{
# we retrieve borrowers and items informations #
my $item = GetItem($itemnumber);
my $borrower = C4::Members::GetMember($borrowernumber);
my $borrower = C4::Members::GetMember('borrowernumber'=>$borrowernumber);
# we retrieve user rights on this itemtype and branchcode
my $sth = $dbh->prepare("SELECT categorycode, itemtype, branchcode, reservesallowed

6
C4/SIP/ILS/Item.pm

@ -97,7 +97,7 @@ sub new {
# check if its on issue and if so get the borrower
my $issue = GetItemIssue($item->{'itemnumber'});
my $borrower = GetMember($issue->{'borrowernumber'},'borrowernumber');
my $borrower = GetMember(borrowernumber=>$issue->{'borrowernumber'});
$item->{patron} = $borrower->{'cardnumber'};
my ($whatever, $arrayref) = GetReservesFromBiblionumber($item->{biblionumber});
$item->{hold_queue} = [ sort priority_sort @$arrayref ];
@ -160,7 +160,7 @@ sub hold_patron_name {
my $self = shift or return;
# return $self->{hold_patron_name} if $self->{hold_patron_name}; TODO: consider caching
my $borrowernumber = (@_ ? shift: $self->hold_patron_id()) or return;
my $holder = GetMember($borrowernumber, 'borrowernumber');
my $holder = GetMember(borrowernumber=>$borrowernumber);
unless ($holder) {
syslog("LOG_ERR", "While checking hold, GetMember failed for borrowernumber '$borrowernumber'");
return;
@ -335,7 +335,7 @@ sub available {
sub _barcode_to_borrowernumber ($) {
my $known = shift;
(defined($known)) or return undef;
my $member = GetMember($known,'cardnumber') or return undef;
my $member = GetMember(cardnumber=>$known) or return undef;
return $member->{borrowernumber};
}
sub barcode_is_borrowernumber ($$$) { # because hold_queue only has borrowernumber...

2
C4/SIP/ILS/Patron.pm

@ -38,7 +38,7 @@ sub new {
my ($class, $patron_id) = @_;
my $type = ref($class) || $class;
my $self;
$kp = GetMember($patron_id,'cardnumber');
$kp = GetMember(cardnumber=>$patron_id);
$debug and warn "new Patron (GetMember): " . Dumper($kp);
unless (defined $kp) {
syslog("LOG_DEBUG", "new ILS::Patron(%s): no such patron", $patron_id);

6
C4/SIP/ILS/Transaction/Hold.pm

@ -49,7 +49,7 @@ sub do_hold {
$self->ok(0);
return $self;
}
my $borrower = GetMember( $self->{patron}->id, 'cardnumber');
my $borrower = GetMember( 'cardnumber'=>$self->{patron}->id);
unless ($borrower) {
$self->screen_msg('No borrower matches cardnumber "' . $self->{patron}->id . '".');
$self->ok(0);
@ -82,7 +82,7 @@ sub drop_hold {
$self->ok(0);
return $self;
}
my $borrower = GetMember( $self->{patron}->id, 'cardnumber');
my $borrower = GetMember( 'cardnumber'=>$self->{patron}->id);
unless ($borrower) {
$self->screen_msg('No borrower matches cardnumber "' . $self->{patron}->id . '".');
$self->ok(0);
@ -104,7 +104,7 @@ sub change_hold {
$self->ok(0);
return $self;
}
my $borrower = GetMember( $self->{patron}->id, 'cardnumber');
my $borrower = GetMember( 'cardnumber'=>$self->{patron}->id);
unless ($borrower) {
$self->screen_msg('No borrower matches cardnumber "' . $self->{patron}->id . '".');
$self->ok(0);

2
C4/SIP/ILS/Transaction/Renew.pm

@ -51,7 +51,7 @@ sub do_renew_for ($$) {
sub do_renew {
my $self = shift;
my $borrower = GetMember( $self->{patron}->id, 'cardnumber');
my $borrower = GetMember( 'cardnumber'=>$self->{patron}->id);
return $self->do_renew_for($borrower);
}

2
C4/SIP/ILS/Transaction/RenewAll.pm

@ -36,7 +36,7 @@ sub new {
sub do_renew_all {
my $self = shift;
my $patron = $self->{patron}; # SIP's patron
my $borrower = GetMember($patron->id, 'cardnumber'); # Koha's patron
my $borrower = GetMember('cardnumber'=>$patron->id); # Koha's patron
my $all_ok = 1;
foreach my $itemx (@{$patron->{items}}) {
my $item_id = $itemx->{barcode};

2
C4/SIP/interactive_members_dump.pl

@ -13,7 +13,7 @@ while (1) {
defined($in) or last;
chomp($in);
last unless $in;
print "GetMember : \n", Dumper(GetMember($in, 'cardnumber'));
print "GetMember : \n", Dumper(GetMember('cardnumber'=>$in));
my ($member) = GetMemberDetails(undef, $in);
my $flags = $member->{authflags};
print "GetMemberDetails (member) : \n", Dumper($member);

280
C4/SQLHelper.pm

@ -0,0 +1,280 @@
package C4::SQLHelper;
# Copyright 2009 Biblibre SARL
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
use List::MoreUtils qw(first_value);
use C4::Context;
use C4::Dates qw(format_date_in_iso);
use C4::Debug;
use strict;
use warnings;
require Exporter;
use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS);
BEGIN {
# set the version for version checking
$VERSION = 0.5;
require Exporter;
@ISA = qw(Exporter);
@EXPORT_OK=qw(
InsertInTable
SearchInTable
UpdateInTable
GetPrimaryKey
);
%EXPORT_TAGS = ( all =>[qw( InsertInTable SearchInTable UpdateInTable GetPrimaryKey)]
);
}
my $tablename;
my $hash;
=head1 NAME
C4::SQLHelper - Perl Module containing convenience functions for SQL Handling
=head1 SYNOPSIS
use C4::SQLHelper;
=head1 DESCRIPTION
This module contains routines for adding, modifying and Searching Data in MysqlDB
=head1 FUNCTIONS
=over 2
=back
=head2 SearchInTable
=over 4
$hashref = &SearchInTable($tablename,$data, $orderby);
=back
$data may contain
- string
- data_hashref : will be considered as an AND of all the data searched
- data_array_ref on hashrefs : Will be considered as an OR of Datahasref elements
$orderby is a hashref with fieldnames as key and 0 or 1 as values (ASCENDING or DESCENDING order)
=cut
sub SearchInTable{
my ($tablename,$filters,$orderby) = @_;
my $dbh = C4::Context->dbh;
my $sql = "SELECT * from $tablename";
my $row;
my $sth;
my ($keys,$values)=_filter_fields($filters,$tablename, "search");
if ($filters) {
$sql.= do { local $"=' AND ';
qq{ WHERE @$keys }
};
}
if ($orderby){
my @orders=map{ "$_".($$orderby{$_}? " DESC" : "") } keys %$orderby;
$sql.= do { local $"=', ';
qq{ ORDER BY @orders}
};
}
$debug && warn $sql," ",join(",",@$values);
$sth = $dbh->prepare($sql);
$sth->execute(@$values);
my $results = $sth->fetchall_arrayref( {} );
return $results;
}
=head2 InsertInTable
=over 4
$data_id_in_table = &InsertInTable($tablename,$data_hashref);
=back
Insert Data in table
and returns the id of the row inserted
=cut
sub InsertInTable{
my ($tablename,$data) = @_;
my $dbh = C4::Context->dbh;
my ($keys,$values)=_filter_fields($data,$tablename);
my $query = do { local $"=',';
qq{
INSERT $tablename
SET @$keys
};
};
$debug && warn $query, join(",",@$values);
my $sth = $dbh->prepare($query);
$sth->execute( @$values);
return $dbh->last_insert_id(undef, undef, $tablename, undef);
}
=head2 UpdateInTable
=over 4
$status = &UpdateInTable($tablename,$data_hashref);
=back
Update Data in table
and returns the status of the operation
=cut
sub UpdateInTable{
my ($tablename,$data) = @_;
my $field_id=GetPrimaryKey($tablename);
my $id=$$data{$field_id};
my $dbh = C4::Context->dbh;
my ($keys,$values)=_filter_fields($data,$tablename);
my $query = do { local $"=',';
qq{
UPDATE $tablename
SET @$keys
WHERE $field_id=?
};
};
$debug && warn $query, join(",",@$values,$id);
my $sth = $dbh->prepare($query);
return $sth->execute( @$values,$id);
}
=head2 GetPrimaryKey
=over 4
$primarykeyname = &GetPrimaryKey($tablename)
=back
Get the Primary Key field name of the table
=cut
sub GetPrimaryKey($) {
my $tablename=shift;
my $hash_columns=_columns($tablename);
return first_value { $$hash_columns{$_}{'Key'} =~/PRI/} keys %$hash_columns;
}
=head2 _get_columns
=over 4
_get_columns($tablename)
=back
Given a tablename
Returns a hashref of all the fieldnames of the table
With
Key
Type
Default
=cut
sub _columns($) {
my $tablename=shift;
$debug && warn $tablename;
my $dbh=C4::Context->dbh;
my $sth=$dbh->prepare(qq{SHOW COLUMNS FROM $tablename });
$sth->execute;
return $sth->fetchall_hashref(qw(Field));
}
=head2 _filter_fields
=over 4
_filter_fields
=back
Given
- a tablename
- a hashref of data
- an indicator on operation
Returns a ref of key array to use in SQL functions
and a ref to value array
=cut
sub _filter_fields{
my ($data_to_filter,$tablename,$research)=@_;
warn "$tablename";
my @keys;
my @values;
my $columns= _columns($tablename);
#Filter Primary Keys of table
my $elements=join "|",grep {$$columns{$_}{'Key'} ne "PRI"} keys %$columns;
if (ref($data_to_filter) eq "HASH"){
foreach my $field (grep {/\b($elements)\b/} keys %$data_to_filter){
## supposed to be a hash of simple values, hashes of arrays could be implemented
$$data_to_filter{$field}=format_date_in_iso($$data_to_filter{$field}) if ($$columns{$field}{Type}=~/date/ && $$data_to_filter{$field} !~C4::Dates->regexp("iso"));
my $strkeys= " $field = ? ";
if ($field=~/code/ && $research){
$strkeys="( $strkeys OR $field='' OR $field IS NULL) ";
}
push @values, $$data_to_filter{$field};
push @keys, $strkeys;
}
} elsif (ref($data_to_filter) eq "ARRAY"){
foreach my $element (@$data_to_filter){
my (@localkeys,@localvalues)=_filter_fields($element);
push @keys, join(' AND ',@localkeys);
push @values, @localvalues;
}
}
else{
my @operands=split / /,$data_to_filter;
foreach my $operand (@operands){
my @localvalues=($operand,"\%$operand\%") ;
foreach my $field (keys %$columns){
my $strkeys= " ( $field = ? OR $field LIKE ? )";
if ($field=~/code/){
$strkeys="( $strkeys OR $field='' OR $field IS NULL) ";
}
push @values, @localvalues;
push @keys, $strkeys;
}
}
}
return (\@keys,\@values);
}
1;

4
C4/VirtualShelves/Page.pm

@ -151,7 +151,7 @@ SWITCH: {
} elsif ( $op eq 'modif' ) {
my ( $shelfnumber2, $shelfname, $owner, $category, $sortfield ) =GetShelf( $shelfnumber );
my $member = GetMember($owner,'borrowernumber');
my $member = GetMember('borrowernumber'=>$owner);
my $ownername = defined($member) ? $member->{firstname} . " " . $member->{surname} : '';
$template->param(
edit => 1,
@ -290,7 +290,7 @@ foreach my $element (sort { lc($shelflist->{$a}->{'shelfname'}) cmp lc($shelflis
if ($owner eq $loggedinuser or $canmanage) {
$shelflist->{$element}->{'mine'} = 1;
}
my $member = GetMember($owner,'borrowernumber');
my $member = GetMember('borrowernumber' => $owner);
$shelflist->{$element}->{ownername} = defined($member) ? $member->{firstname} . " " . $member->{surname} : '';
$numberCanManage++ if $canmanage; # possibly outmoded
if ($shelflist->{$element}->{'category'} eq '1') {

2
acqui/acqui-home.pl

@ -63,7 +63,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
);
# budget
my $borrower= GetMember($loggedinuser);
my $borrower= GetMember('borrowernumber' => $loggedinuser);
my ( $flags, $homebranch )= ($borrower->{'flags'},$borrower->{'branchcode'});
my @results = GetBookFunds($homebranch);

2
acqui/neworderempty.pl

@ -167,7 +167,7 @@ foreach my $thisbranch ( sort {$branches->{$a}->{'branchname'} cmp $branches->{$
$template->param( branchloop => \@branchloop , itypeloop => \@itemtypesloop );
# build bookfund list
my $borrower= GetMember($loggedinuser);
my $borrower= GetMember('borrowernumber' => $loggedinuser);
my ( $flags, $homebranch )= ($borrower->{'flags'},$borrower->{'branchcode'});
my @select_bookfund;

2
circ/branchtransfers.pl

@ -209,7 +209,7 @@ foreach my $code ( keys %$messages ) {
elsif ( $code eq 'WasReturned' ) {
$err{errwasreturned} = 1;
$err{borrowernumber} = $messages->{'WasReturned'};
my $borrower = GetMember($messages->{'WasReturned'},'borrowernumber');
my $borrower = GetMember('borrowernumber'=>$messages->{'WasReturned'});
$err{title} = $borrower->{'title'};
$err{firstname} = $borrower->{'firstname'};
$err{surname} = $borrower->{'surname'};

2
members/boraccount.pl

@ -49,7 +49,7 @@ my $borrowernumber=$input->param('borrowernumber');
my $action = $input->param('action') || '';
#get borrower details
my $data=GetMember($borrowernumber,'borrowernumber');
my $data=GetMember('borrowernumber' => $borrowernumber);
if ( $action eq 'reverse' ) {
ReversePayment( $borrowernumber, $input->param('accountno') );

2
members/borrowers_details.pl

@ -53,7 +53,7 @@ my $borrowernumber=$input->param('borrowernumber');
my $description=$input->param('description');
my $category_type=$input->param('category_type');
$data=GetMember($borrowernumber,'borrowernumber');
$data=GetMember('borrowernumber' => $borrowernumber);
$template->param( borrowernumber => $borrowernumber,#register number
#transform value in capital or capital for first letter of the word

2
members/mancredit.pl

@ -38,7 +38,7 @@ my $input=new CGI;
my $borrowernumber=$input->param('borrowernumber');
#get borrower details
my $data=GetMember($borrowernumber,'borrowernumber');
my $data=GetMember('borrowernumber' => $borrowernumber);
my $add=$input->param('add');
if ($add){

2
members/maninvoice.pl

@ -38,7 +38,7 @@ my $borrowernumber=$input->param('borrowernumber');
# get borrower details
my $data=GetMember($borrowernumber,'borrowernumber');
my $data=GetMember('borrowernumber'=>$borrowernumber);
my $add=$input->param('add');
if ($add){
# print $input->header;

2
members/member-password.pl

@ -40,7 +40,7 @@ my $member=$input->param('member');
my $cardnumber = $input->param('cardnumber');
my $destination = $input->param('destination');
my $errormsg;
my ($bor)=GetMember($member);
my ($bor)=GetMember('borrowernumber' => $member);
if(( $member ne $loggedinuser ) && ($bor->{'category_type'} eq 'S' ) ) {
$errormsg = 'NOPERMISSION' unless($staffflags->{'superlibrarian'} || $staffflags->{'staffaccess'} );
# need superlibrarian for koha-conf.xml fakeuser.

4
members/memberentry.pl

@ -101,7 +101,7 @@ foreach (@field_check) {
}
$template->param("add"=>1) if ($op eq 'add');
$template->param("checked" => 1) if (defined($nodouble) && $nodouble eq 1);
($borrower_data = GetMember($borrowernumber,'borrowernumber')) if ($op eq 'modify' or $op eq 'save');
($borrower_data = GetMember( 'borrowernumber'=>$borrowernumber )) if ($op eq 'modify' or $op eq 'save');
my $categorycode = $input->param('categorycode') || $borrower_data->{'categorycode'};
my $category_type = $input->param('category_type');
my $new_c_type = $category_type; #if we have input param, then we've already chosen the cat_type.
@ -202,7 +202,7 @@ if ( defined($guarantorid) and
( $category_type eq 'C' || $category_type eq 'P' ) and
$guarantorid ne '' and
$guarantorid ne '0' ) {
if (my $guarantordata=GetMember($guarantorid)) {
if (my $guarantordata=GetMember(borrowernumber => $guarantorid)) {
$guarantorinfo=$guarantordata->{'surname'}." , ".$guarantordata->{'firstname'};
if ( !defined($data{'contactname'}) or $data{'contactname'} eq '' or
$data{'contactname'} ne $guarantordata->{'surname'} ) {

2
members/messaging.pl

@ -59,7 +59,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
}
);
my $borrowernumber = $query->param('borrowernumber');
my $borrower = GetMember( $borrowernumber ,'borrowernumber');
my $borrower = GetMember( 'borrowernumber' => $borrowernumber );
my $branch = C4::Context->userenv->{'branch'};
$template->param( $borrower );

6
members/moremember.pl

@ -93,7 +93,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
my $borrowernumber = $input->param('borrowernumber');
#start the page and read in includes
my $data = GetMember( $borrowernumber ,'borrowernumber');
my $data = GetMember( 'borrowernumber' => $borrowernumber );
my $reregistration = $input->param('reregistration');
if ( not defined $data ) {
@ -138,7 +138,7 @@ $data->{ "sex_".$data->{'sex'}."_p" } = 1;
my $catcode;
if ( $category_type eq 'C') {
if ($data->{'guarantorid'} ne '0' ) {
my $data2 = GetMember( $data->{'guarantorid'} ,'borrowernumber');
my $data2 = GetMember( 'borrowernumber' => $data->{'guarantorid'} );
foreach (qw(address city B_address B_city phone mobile zipcode country B_country)) {
$data->{$_} = $data2->{$_};
}
@ -178,7 +178,7 @@ if ( $category_type eq 'A' ) {
}
else {
if ($data->{'guarantorid'}){
my ($guarantor) = GetMember( $data->{'guarantorid'},'biblionumber');
my ($guarantor) = GetMember( 'borrowernumber' =>$data->{'guarantorid'});
$template->param(guarantor => 1);
foreach (qw(borrowernumber cardnumber firstname surname)) {
$template->param("guarantor$_" => $guarantor->{$_});

2
members/notices.pl

@ -33,7 +33,7 @@ my $input=new CGI;
my $borrowernumber = $input->param('borrowernumber');
#get borrower details
my $borrower = GetMember(borrowernumber=>$borrowernumber);
my $borrower = GetMember(borrowernumber => $borrowernumber);
my ($template, $loggedinuser, $cookie)
= get_template_and_user({template_name => "members/notices.tmpl",

2
members/pay.pl

@ -58,7 +58,7 @@ if ( $borrowernumber eq '' ) {
}
# get borrower details
my $data = GetMember( $borrowernumber,'borrowernumber' );
my $data = GetMember( borrowernumber => $borrowernumber );
my $user = $input->remote_user;
# get account details

2
members/readingrec.pl

@ -35,7 +35,7 @@ my $input=new CGI;
my $borrowernumber=$input->param('borrowernumber');
#get borrower details
my $data=GetMember($borrowernumber,'borrowernumber');
my $data=GetMember('borrowernumber'=>$borrowernumber);
my $order=$input->param('order') || '';
my $order2=$order;
if ($order2 eq ''){

2
members/update-child.pl

@ -79,7 +79,7 @@ if ( $op eq 'multi' ) {
}
elsif ( $op eq 'update' ) {
my $member = GetMember($borrowernumber);
my $member = GetMember('borrowernumber'=>$borrowernumber);
$member->{'guarantorid'} = '0';
$member->{'categorycode'} = $catcode;
my $borcat = GetBorrowercategory($catcode);

2
misc/cronjobs/holds/build_holds_queue.pl

@ -354,7 +354,7 @@ sub CreatePicklistFromItemMap {
my $barcode = $item->{barcode};
my $itemcallnumber = $item->{itemcallnumber};
my $borrower = GetMember($borrowernumber);
my $borrower = GetMember('borrowernumber'=>$borrowernumber);
my $cardnumber = $borrower->{'cardnumber'};
my $surname = $borrower->{'surname'};
my $firstname = $borrower->{'firstname'};

6
offline_circ/process_koc.pl

@ -239,7 +239,7 @@ sub kocIssueItem {
$circ->{ 'barcode' } = barcodedecode($circ->{'barcode'}) if( $circ->{'barcode'} && C4::Context->preference('itemBarcodeInputFilter'));
my $branchcode = C4::Context->userenv->{branch};
my $borrower = GetMember( $circ->{ 'cardnumber' }, 'cardnumber' );
my $borrower = GetMember( 'cardnumber'=>$circ->{ 'cardnumber' } );
my $item = GetBiblioFromItemNumber( undef, $circ->{ 'barcode' } );
my $issue = GetItemIssue( $item->{'itemnumber'} );
@ -327,7 +327,7 @@ sub kocReturnItem {
#warn( Data::Dumper->Dump( [ $circ, $item ], [ qw( circ item ) ] ) );
my $borrowernumber = _get_borrowernumber_from_barcode( $circ->{'barcode'} );
if ( $borrowernumber ) {
my $borrower = GetMember( $borrowernumber, 'borrowernumber' );
my $borrower = GetMember( 'borrowernumber' =>$borrowernumber );
C4::Circulation::MarkIssueReturned( $borrowernumber,
$item->{'itemnumber'},
undef,
@ -354,7 +354,7 @@ sub kocReturnItem {
sub kocMakePayment {
my ( $circ ) = @_;
my $borrower = GetMember( $circ->{ 'cardnumber' }, 'cardnumber' );
my $borrower = GetMember( 'cardnumber'=>$circ->{ 'cardnumber' } );
recordpayment( $borrower->{'borrowernumber'}, $circ->{'amount'} );
push( @output, { payment => 1,
amount => $circ->{'amount'},

2
opac/opac-ISBDdetail.pl

@ -127,7 +127,7 @@ my $res = GetISBDView($biblionumber);
my $reviews = getreviews( $biblionumber, 1 );
foreach ( @$reviews ) {
my $borrower_number_review = $_->{borrowernumber};
my $borrowerData = GetMember($borrower_number_review,'borrowernumber');
my $borrowerData = GetMember('borrowernumber' =>$borrower_number_review);
# setting some borrower info into this hash
$_->{title} = $borrowerData->{'title'};
$_->{surname} = $borrowerData->{'surname'};

2
opac/opac-detail.pl

@ -238,7 +238,7 @@ $template->param(
my $reviews = getreviews( $biblionumber, 1 );
my $loggedincommenter;
foreach ( @$reviews ) {
my $borrowerData = GetMember($_->{borrowernumber},'borrowernumber');
my $borrowerData = GetMember('borrowernumber' => $_->{borrowernumber});
# setting some borrower info into this hash
$_->{title} = $borrowerData->{'title'};
$_->{surname} = $borrowerData->{'surname'};

2
opac/opac-main.pl

@ -40,7 +40,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
}
);
my $borrower = GetMember( $borrowernumber, 'borrowernumber' );
my $borrower = GetMember( 'borrowernumber'=> $borrowernumber );
$template->param(
textmessaging => $borrower->{textmessaging},
);

2
reserve/placerequest.pl

@ -49,7 +49,7 @@ my $startdate=$input->param('reserve_date') || '';
my @rank=$input->param('rank-request');
my $type=$input->param('type');
my $title=$input->param('title');
my $borrowernumber=GetMember($borrower,'cardnumber');
my $borrowernumber=GetMember('cardnumber'=>$borrower);
my $checkitem=$input->param('checkitem');
my $multi_hold = $input->param('multi_hold');

2
reviews/reviewswaiting.pl

@ -52,7 +52,7 @@ my $reviews = getallreviews(0);
foreach ( @$reviews ) {
my $borrowernumber = $_->{borrowernumber};
my $borrowerData = GetMember($borrowernumber,'borrowernumber');
my $borrowerData = GetMember('borrowernumber' => $borrowernumber);
my $biblioData = GetBiblioData($_->{biblionumber});
# setting some borrower info into this hash
$_->{bibliotitle} = $biblioData->{'title'};

2
serials/routing-preview.pl

@ -100,7 +100,7 @@ if($ok){
my @results;
my $data;
for(my $i=0;$i<$routing;$i++){
$data=GetMember($routinglist[$i]->{'borrowernumber'},'borrowernumber');
$data=GetMember('borrowernumber' => $routinglist[$i]->{'borrowernumber'});
$data->{'location'}=$data->{'branchcode'};
$data->{'name'}="$data->{'firstname'} $data->{'surname'}";
$data->{'routingid'}=$routinglist[$i]->{'routingid'};

2
serials/routing.pl

@ -109,7 +109,7 @@ my ($template, $loggedinuser, $cookie)
my @results;
my $data;
for(my $i=0;$i<$routing;$i++){
$data=GetMember($routinglist[$i]->{'borrowernumber'},'borrowernumber');
$data=GetMember('borrowernumber' => $routinglist[$i]->{'borrowernumber'});
$data->{'location'}=$data->{'branchcode'};
if ($data->{firstname} ) {
$data->{name} = $data->{firstname} . q| |;

20
t/db_dependent/SQLHelper.t

@ -0,0 +1,20 @@
#!/usr/bin/perl
#
# This Koha test module is a stub!
# Add more tests here!!!
use strict;
use warnings;
use Data::Dumper;
use C4::SQLHelper qw(:all);
use Test::More tests => 3;
BEGIN {
use_ok('C4::SQLHelper');
}
my $borrid=InsertInTable("borrowers",{firstname=>"Jean",surname=>"Valjean",city=>" ",zipcode=>" ",email=>"email",categorycode=>"EL"});
my $status=UpdateInTable("borrowers",{borrowernumber=>$borrid,firstname=>"Jean",surname=>"Valjean",city=>"ma6tVaCracker ",zipcode=>" ",email=>"email"});
my $borrowers=SearchInTable("borrowers",{firstname=>"Jean"});

2
t/lib/KohaTest/Acquisition.pm

@ -110,7 +110,7 @@ sub create_new_basket {
sub enable_independant_branches {
my $self = shift;
my $member = GetMember( $self->{'memberid'} );
my $member = GetMember( 'borrowernumber' =>$self->{'memberid'} );
C4::Context::set_userenv( 0, # usernum
$self->{'memberid'}, # userid

2
t/lib/KohaTest/Acquisition/GetLateOrders.pm

@ -67,7 +67,7 @@ sub one_order : Test( 29 ) {
}
# provide some branch information
my $member = GetMember( $self->{'memberid'} );
my $member = GetMember( borrowernumber=>$self->{'memberid'} );
# diag( Data::Dumper->Dump( [ $member ], [ 'member' ] ) );
{
my @orders = GetLateOrders( 0, $self->{'booksellerid'}, $member->{'branchcode'} );

4
t/lib/KohaTest/Members.pm

@ -41,17 +41,13 @@ sub methods : Test( 1 ) {
GetAge
get_institutions
add_member_orgs
GetCities
GetSortDetails
MoveMemberToDeleted
DelMember
ExtendMemberSubscriptionTo
GetRoadTypes
GetTitles
GetPatronImage
PutPatronImage
RmPatronImage
GetRoadTypeDetails
GetBorrowersWhoHaveNotBorrowedSince
GetBorrowersWhoHaveNeverBorrowed
GetBorrowersWithIssuesHistoryOlderThan

12
t/lib/KohaTest/Members/GetMember.pm

@ -30,8 +30,8 @@ sub startup_create_borrower : Test( startup => 1 ) {
address => 'address' . $self->random_string(),
city => 'city' . $self->random_string(),
cardnumber => 'card' . $self->random_string(),
branchcode => 'CPL',
categorycode => 'B', # B => Board
branchcode => 'U1BCG',
categorycode => 'D', # B => Board
dateexpiry => '2020-01-01',
password => 'testpassword',
userid => 'testuser',
@ -66,7 +66,7 @@ sub borrowernumber_get : Test( 6 ) {
#search by borrowernumber
my $results =
C4::Members::GetMember( $self->{get_new_borrowernumber}, 'borrowernumber' );
C4::Members::GetMember( borrowernumber=>$self->{get_new_borrowernumber});
ok( $results, 'we successfully called GetMember searching by borrowernumber' );
ok( exists $results->{borrowernumber},
@ -93,7 +93,7 @@ sub cardnumber_get : Test( 6 ) {
"we have a valid cardnumber $self->{get_new_cardnumber} to test with" );
#search by cardnumber
my $results = C4::Members::GetMember( $self->{get_new_cardnumber}, 'cardnumber' );
my $results = C4::Members::GetMember( 'cardnumber'=>$self->{get_new_cardnumber} );
ok( $results, 'we successfully called GetMember searching by cardnumber' );
ok( exists $results->{cardnumber}, 'member details has a "cardnumber" attribute' );
@ -120,7 +120,7 @@ sub firstname_get : Test( 6 ) {
"we have a valid firstname $self->{get_new_firstname} to test with" );
##search by firstname
my $results = C4::Members::GetMember( $self->{get_new_firstname}, 'firstname' );
my $results = C4::Members::GetMember( 'firstname'=>$self->{get_new_firstname} );
ok( $results, 'we successfully called GetMember searching by firstname' );
ok( exists $results->{firstname}, 'member details has a "firstname" attribute' );
@ -146,7 +146,7 @@ sub userid_get : Test( 6 ) {
"we have a valid userid $self->{get_new_userid} to test with" );
#search by userid
my $results = C4::Members::GetMember( $self->{get_new_userid}, 'userid' );
my $results = C4::Members::GetMember( 'userid'=>$self->{get_new_userid} );
ok( $results, 'we successfully called GetMember searching by userid' );
ok( exists $results->{'userid'}, 'member details has a "userid" attribute' );

2
t/lib/KohaTest/Overdues/GetOverdues.pm

@ -44,7 +44,7 @@ sub startup_60_create_overdue_item : Test( startup => 17 ) {
# diag( Data::Dumper->Dump( [ $item_from_barcode ], [ 'item_from_barcode' ] ) );
ok( $self->{'memberid'}, 'memberid' );
my $borrower = C4::Members::GetMember( $self->{'memberid'} );
my $borrower = C4::Members::GetMember( borrowernumber=>$self->{'memberid'} );
ok( $borrower->{'borrowernumber'}, 'borrowernumber' );
my ( $issuingimpossible, $needsconfirmation ) = C4::Circulation::CanBookBeIssued( $borrower, $item->{'barcode'}, $duedate, 0 );

2
t/lib/KohaTest/Scripts/longoverdue.pm

@ -60,7 +60,7 @@ sub set_overdue_item_lost : Test( 13 ) {
# my $item_from_barcode = C4::Items::GetItem( undef, $item->{'barcode'} );
# diag( Data::Dumper->Dump( [ $item_from_barcode ], [ 'item_from_barcode' ] ) );
my $borrower = C4::Members::GetMember( $self->{'memberid'} );
my $borrower = C4::Members::GetMember( borrowernumber => $self->{'memberid'} );
ok( $borrower->{'borrowernumber'}, 'borrowernumber' );
my ( $issuingimpossible, $needsconfirmation ) = C4::Circulation::CanBookBeIssued( $borrower, $item->{'barcode'}, $duedate, 0 );

2
tools/import_borrowers.pl

@ -212,7 +212,7 @@ if ( $uploadborrowers && length($uploadborrowers) > 0 ) {
my $borrowernumber;
my $member;
if ( ($matchpoint eq 'cardnumber') && ($borrower{'cardnumber'}) ) {
$member = GetMember( $borrower{'cardnumber'}, 'cardnumber' );
$member = GetMember( 'cardnumber' => $borrower{'cardnumber'} );
if ($member) {
$borrowernumber = $member->{'borrowernumber'};
}

2
tools/viewlog.pl