Adding a function in C4/Members/Attributes.pm
authorHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Fri, 18 Sep 2009 14:31:07 +0000 (16:31 +0200)
committerHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Wed, 30 Sep 2009 09:30:37 +0000 (11:30 +0200)
Adding a function to search an retrieve attributes

C4/Members/Attributes.pm

index 88c6c09..55e255c 100644 (file)
@@ -32,7 +32,8 @@ BEGIN {
     $VERSION = 3.01;
     @ISA = qw(Exporter);
     @EXPORT_OK = qw(GetBorrowerAttributes CheckUniqueness SetBorrowerAttributes
-                    extended_attributes_code_value_arrayref extended_attributes_merge);
+                    extended_attributes_code_value_arrayref extended_attributes_merge
+                                       SearchIdMatchingAttribute);
     %EXPORT_TAGS = ( all => \@EXPORT_OK );
 }
 
@@ -101,6 +102,32 @@ sub GetBorrowerAttributes {
     return \@results;
 }
 
+=head2 SearchIdMatchingAttribute
+
+=over 4
+
+my $matching_records = C4::Members::Attributes::SearchIdMatchingAttribute($filter);
+
+=back
+
+
+=cut
+
+sub SearchIdMatchingAttribute{
+    my $filter = shift;
+
+    my $dbh = C4::Context->dbh();
+    my $query = qq{
+SELECT borrowernumber
+FROM borrower_attributes
+JOIN borrower_attribute_types USING (code)
+WHERE staff_searchable = 1
+AND attribute like ?};
+    my $sth = $dbh->prepare_cached($query);
+    $sth->execute($filter);
+       return $sth->fetchall_arrayref;
+}
+
 =head2 CheckUniqueness
 
 =over 4