use C4::Reserves;
use C4::Accounts;
use C4::Biblio;
-use C4::SQLHelper qw(InsertInTable UpdateInTable);
+use C4::SQLHelper qw(InsertInTable UpdateInTable SearchInTable);
+use C4::Members::Attributes qw(SearchIdMatchingAttribute);
our ($VERSION,@ISA,@EXPORT,@EXPORT_OK,$debug);
@ISA = qw(Exporter);
#Get data
push @EXPORT, qw(
+ &Search
&SearchMember
&GetMemberDetails
&GetMember
#'
#used by member enquiries from the intranet
-#called by member.pl and circ/circulation.pl
sub SearchMember {
my ($searchstring, $orderby, $type,$category_type,$filter,$showallbranches ) = @_;
my $dbh = C4::Context->dbh;
if (@$data){
return ( scalar(@$data), $data );
}
- $sth->finish;
if ( $type eq "simple" ) # simple search for one letter only
{
}
$query = $query . ") OR cardnumber LIKE ? ";
push( @bind, $searchstring );
- if (C4::Context->preference('ExtendedPatronAttributes')) {
- $query .= "OR borrowernumber IN (
-SELECT borrowernumber
-FROM borrower_attributes
-JOIN borrower_attribute_types USING (code)
-WHERE staff_searchable = 1
-AND attribute like ?
-)";
- push (@bind, $searchstring);
- }
$query .= "order by $orderby";
# FIXME - .= <<EOT;
my @results;
$data = $sth->fetchall_arrayref({});
- $sth->finish;
return ( scalar(@$data), $data );
}
+sub Search {
+ my ($filter,$orderby, $limit, $columns_out, $search_on_fields,$searchtype) = @_;
+ my @filters;
+ if (ref($filter) eq "ARRAY"){
+ push @filters,@$filter;
+ }
+ else {
+ push @filters,$filter;
+ }
+ if (C4::Context->preference('ExtendedPatronAttributes')) {
+ my $matching_records = C4::Members::Attributes::SearchIdMatchingAttribute($filter);
+ push @filters,@$matching_records;
+ }
+ $searchtype||="start_with";
+ my $data=SearchInTable("borrowers",\@filters,$orderby,$limit,$columns_out,$search_on_fields,$searchtype);
+
+ return ( $data );
+}
+
=head2 GetMemberDetails
($borrower) = &GetMemberDetails($borrowernumber, $cardnumber);
$accessflagshash->{$flag} = 1;
}
}
- $sth->finish;
$borrower->{'flags'} = $flags;
$borrower->{'authflags'} = $accessflagshash;
my $sth = $dbh->prepare($query);
$sth->execute($borrowernumber);
my $issue_count = $sth->fetchrow_arrayref->[0];
- $sth->finish;
$sth = $dbh->prepare(
"SELECT COUNT(*) FROM issues
);
$sth->execute($borrowernumber);
my $overdue_count = $sth->fetchrow_arrayref->[0];
- $sth->finish;
$sth = $dbh->prepare("SELECT SUM(amountoutstanding) FROM accountlines WHERE borrowernumber = ?");
$sth->execute($borrowernumber);
my $total_fines = $sth->fetchrow_arrayref->[0];
- $sth->finish;
return ($overdue_count, $issue_count, $total_fines);
}
my @dat;
my $data = $sth->fetchall_arrayref({});
- $sth->finish;
return ( scalar(@$data), $data );
}
|;
my $sth3 = $dbh->prepare($guaquery);
$sth3->execute;
- $sth3->finish;
}
}
=head2 GetPendingIssues
$result[$i] = $data2;
$i++;
}
- $sth2->finish;
}
- $sth->finish;
return ( $i, \@result );
}
$total += int(1000 * $data->{'amountoutstanding'}); # convert float to integer to avoid round-off errors
}
$total /= 1000;
- $sth->finish;
return ( $total, \@acctlines,$numlines);
}
$total += int(100 * $data->{'amountoutstanding'});
}
$total /= 100;
- $sth->finish;
return ( $total, \@acctlines, $numlines );
}
$sth->execute( uc($surname), ucfirst($firstname));
}
my @data = $sth->fetchrow;
- $sth->finish;
( $data[0] ) and return $data[0], $data[1];
return 0;
}
else {
return 0;
}
- $sth->finish();
}
push @codes, $data->{'categorycode'};
$labels{ $data->{'categorycode'} } = $data->{'description'};
}
- $sth->finish;
return ( \@codes, \%labels );
}
$sth->execute($catcode);
my $data =
$sth->fetchrow_hashref;
- $sth->finish();
return $data;
}
return;
$sth->execute;
my $data =
$sth->fetchall_arrayref({});
- $sth->finish();
return $data;
} # sub getborrowercategory
push @codes, $data->{'code'};
$labels{ $data->{'code'} } = $data->{'name'};
}
- $sth->finish;
return ( \@codes, \%labels );
}
my $sth = $dbh->prepare("Select name from ethnicity where code = ?");
$sth->execute($ethnicity);
my $data = $sth->fetchrow_hashref;
- $sth->finish;
return $data->{'name'};
} # sub fixEthnicity
while ( my $data = $sth->fetchrow_hashref() ) {
$orgs{ $data->{'borrowernumber'} } = $data;
}
- $sth->finish();
return ( \%orgs );
} # sub get_institutions
foreach my $otherborrowernumber (@$otherborrowers) {
$sth->execute( $borrowernumber, $otherborrowernumber );
}
- $sth->finish();
} # sub add_member_orgs
#test to know if the table contain some records if no the function return nothing
my $id = @id;
- $sth->finish;
if ( $id == 1 ) {
# all we have is the one blank row
return ();
WHERE borrowernumber=?|;
my $sth = $dbh->prepare($query);
$sth->execute($borrowernumber);
- $sth->finish;
$query = "
DELETE
FROM borrowers
";
$sth = $dbh->prepare($query);
$sth->execute($borrowernumber);
- $sth->finish;
logaction("MEMBERS", "DELETE", $borrowernumber, "") if C4::Context->preference("BorrowersLog");
return $sth->rows;
}
#test to know if the table contain some records if no the function return nothing
my $id = @id;
- $sth->finish;
if ( $id eq 0 ) {
return ();
}