removing searchborrower from circ2.pm.
Already exists in Search.pm this fixes bug #439 and improve consistency.
This commit is contained in:
parent
a548aab083
commit
a72d9621ae
|
|
@ -61,7 +61,7 @@ returns, as well as general information about the library.
|
|||
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(&getpatroninformation
|
||||
¤tissues &getissues &getiteminformation &findborrower
|
||||
¤tissues &getissues &getiteminformation
|
||||
&issuebook &returnbook &find_reserves &transferbook &decode
|
||||
&calc_charges);
|
||||
|
||||
|
|
@ -301,54 +301,6 @@ sub getiteminformation {
|
|||
return($iteminformation);
|
||||
}
|
||||
|
||||
=item findborrower
|
||||
|
||||
$borrowers = &findborrower($env, $key);
|
||||
print $borrowers->[0]{surname};
|
||||
|
||||
Looks up patrons and returns information about them.
|
||||
|
||||
C<$env> is ignored.
|
||||
|
||||
C<$key> is either a card number or a string. C<&findborrower> tries to
|
||||
look it up as a card number first. If that fails, C<&findborrower>
|
||||
looks up all patrons whose surname begins with C<$key>.
|
||||
|
||||
C<$borrowers> is a reference-to-array. Each element is a
|
||||
reference-to-hash whose keys are the fields of the borrowers table in
|
||||
the Koha database.
|
||||
|
||||
=cut
|
||||
#'
|
||||
# If you really want to throw a monkey wrench into the works, change
|
||||
# your last name to "V10000008" :-)
|
||||
|
||||
# FIXME - This is different from &C4::Borrower::findborrower, but I
|
||||
# think that one's obsolete.
|
||||
sub findborrower {
|
||||
# returns an array of borrower hash references, given a cardnumber or a partial
|
||||
# surname
|
||||
my ($env, $key) = @_;
|
||||
my $dbh = C4::Context->dbh;
|
||||
my @borrowers;
|
||||
my $sth=$dbh->prepare("select * from borrowers where cardnumber=?");
|
||||
$sth->execute($key);
|
||||
if ($sth->rows) {
|
||||
my ($borrower)=$sth->fetchrow_hashref;
|
||||
push (@borrowers, $borrower);
|
||||
} else {
|
||||
$sth->finish;
|
||||
$sth=$dbh->prepare("select * from borrowers where surname like ?");
|
||||
$sth->execute($key."%");
|
||||
while (my $borrower = $sth->fetchrow_hashref) {
|
||||
push (@borrowers, $borrower);
|
||||
}
|
||||
}
|
||||
$sth->finish;
|
||||
return(\@borrowers);
|
||||
}
|
||||
|
||||
|
||||
=item transferbook
|
||||
|
||||
($dotransfer, $messages, $iteminformation) =
|
||||
|
|
|
|||
|
|
@ -365,7 +365,6 @@ sub _new_dbh
|
|||
my $db_host = $context->{"config"}{"hostname"};
|
||||
my $db_user = $context->{"config"}{"user"};
|
||||
my $db_passwd = $context->{"config"}{"pass"};
|
||||
|
||||
return DBI->connect("DBI:$db_driver:$db_name:$db_host",
|
||||
$db_user, $db_passwd);
|
||||
}
|
||||
|
|
|
|||
63
C4/Search.pm
63
C4/Search.pm
|
|
@ -1737,37 +1737,38 @@ C<$count> is the number of elements in C<$borrowers>.
|
|||
#used by member enquiries from the intranet
|
||||
#called by member.pl
|
||||
sub BornameSearch {
|
||||
my ($env,$searchstring,$type)=@_;
|
||||
my $dbh = C4::Context->dbh;
|
||||
$searchstring=~ s/\'/\\\'/g;
|
||||
my @data=split(' ',$searchstring);
|
||||
my $count=@data;
|
||||
my $query="Select * from borrowers
|
||||
where ((surname like \"$data[0]%\" or surname like \"% $data[0]%\"
|
||||
or firstname like \"$data[0]%\" or firstname like \"% $data[0]%\"
|
||||
or othernames like \"$data[0]%\" or othernames like \"% $data[0]%\")
|
||||
";
|
||||
for (my $i=1;$i<$count;$i++){
|
||||
$query=$query." and (surname like \"$data[$i]%\" or surname like \"% $data[$i]%\"
|
||||
or firstname like \"$data[$i]%\" or firstname like \"% $data[$i]%\"
|
||||
or othernames like \"$data[$i]%\" or othernames like \"% $data[$i]%\")";
|
||||
# FIXME - .= <<EOT;
|
||||
}
|
||||
$query=$query.") or cardnumber = \"$searchstring\"
|
||||
order by surname,firstname";
|
||||
# FIXME - .= <<EOT;
|
||||
# print $query,"\n";
|
||||
my $sth=$dbh->prepare($query);
|
||||
$sth->execute;
|
||||
my @results;
|
||||
my $cnt=0;
|
||||
while (my $data=$sth->fetchrow_hashref){
|
||||
push(@results,$data);
|
||||
$cnt ++;
|
||||
}
|
||||
# $sth->execute;
|
||||
$sth->finish;
|
||||
return ($cnt,\@results);
|
||||
my ($env,$searchstring,$type)=@_;
|
||||
my $dbh = C4::Context->dbh;
|
||||
$searchstring=~ s/\,//g;
|
||||
$searchstring=~ s/\'/\\\'/g;
|
||||
my @data=split(' ',$searchstring);
|
||||
my $count=@data;
|
||||
my $query="Select * from borrowers
|
||||
where ((surname like \"$data[0]%\" or surname like \"% $data[0]%\"
|
||||
or firstname like \"$data[0]%\" or firstname like \"% $data[0]%\"
|
||||
or othernames like \"$data[0]%\" or othernames like \"% $data[0]%\")
|
||||
";
|
||||
for (my $i=1;$i<$count;$i++){
|
||||
$query=$query." and (surname like \"$data[$i]%\" or surname like \"% $data[$i]%\"
|
||||
or firstname like \"$data[$i]%\" or firstname like \"% $data[$i]%\"
|
||||
or othernames like \"$data[$i]%\" or othernames like \"% $data[$i]%\")";
|
||||
# FIXME - .= <<EOT;
|
||||
}
|
||||
$query=$query.") or cardnumber = \"$searchstring\"
|
||||
order by surname,firstname";
|
||||
# FIXME - .= <<EOT;
|
||||
# print $query,"\n";
|
||||
my $sth=$dbh->prepare($query);
|
||||
$sth->execute;
|
||||
my @results;
|
||||
my $cnt=0;
|
||||
while (my $data=$sth->fetchrow_hashref){
|
||||
push(@results,$data);
|
||||
$cnt ++;
|
||||
}
|
||||
# $sth->execute;
|
||||
$sth->finish;
|
||||
return ($cnt,\@results);
|
||||
}
|
||||
|
||||
=item borrdata
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ my $borrowerslist;
|
|||
# if there is a list of find borrowers....
|
||||
my $findborrower = $query->param('findborrower');
|
||||
if ($findborrower) {
|
||||
my ($borrowers, $flags) = findborrower(\%env, $findborrower);
|
||||
my ($count,$borrowers)=BornameSearch(\%env,$findborrower,'web');
|
||||
my @borrowers=@$borrowers;
|
||||
if ($#borrowers == -1) {
|
||||
$query->param('findborrower', '');
|
||||
|
|
|
|||
Loading…
Reference in New Issue