7310 Indentation followup replacing leading tabs with spaces
[koha_gimpoz] / C4 / Members.pm
index 7def77e..4aa689f 100644 (file)
@@ -95,6 +95,7 @@ BEGIN {
                &GetMessagesCount
 
         &IssueSlip
+               GetBorrowersWithEmail
        );
 
        #Modify data
@@ -472,7 +473,7 @@ sub patronflags {
         $flaginfo{'message'} = $patroninformation->{'borrowernotes'};
         $flags{'NOTES'}      = \%flaginfo;
     }
-    my ( $odues, $itemsoverdue ) = checkoverdues($patroninformation->{'borrowernumber'});
+    my ( $odues, $itemsoverdue ) = C4::Overdues::checkoverdues($patroninformation->{'borrowernumber'});
     if ( $odues && $odues > 0 ) {
         my %flaginfo;
         $flaginfo{'message'}  = "Yes";
@@ -2308,6 +2309,36 @@ sub IssueSlip {
     );
 }
 
+=head2 GetBorrowersWithEmail
+
+    ([$borrnum,$userid], ...) = GetBorrowersWithEmail('me@example.com');
+
+This gets a list of users and their basic details from their email address.
+As it's possible for multiple user to have the same email address, it provides
+you with all of them. If there is no userid for the user, there will be an
+C<undef> there. An empty list will be returned if there are no matches.
+
+=cut
+
+sub GetBorrowersWithEmail {
+    my $email = shift;
+
+    my $dbh = C4::Context->dbh;
+
+    my $query = "SELECT borrowernumber, userid FROM borrowers WHERE email=?";
+    my $sth=$dbh->prepare($query);
+    $sth->execute($email);
+    my @result = ();
+    while (my $ref = $sth->fetch) {
+        push @result, $ref;
+    }
+    die "Failure searching for borrowers by email address: $sth->errstr" if $sth->err;
+    return @result;
+}
+
+
+END { }    # module clean-up code here (global destructor)
+
 1;
 
 __END__