C4::Members::SearchMember - support attributes
authorGalen Charlton <galen.charlton@liblime.com>
Mon, 12 May 2008 13:32:52 +0000 (08:32 -0500)
committerJoshua Ferraro <jmf@liblime.com>
Mon, 12 May 2008 14:03:04 +0000 (09:03 -0500)
Modified SearchMember() so that if the patron attributes
feature is on (i.e., ExtendedPatronAttributes is ON), it
is possible to search for patrons on any attributes whose
type is set as staff searchable.

Signed-off-by: Joshua Ferraro <jmf@liblime.com>
C4/Members.pm

index 18ca449..a1ca507 100644 (file)
@@ -215,9 +215,19 @@ sub SearchMember {
 
             # FIXME - .= <<EOT;
         }
-        $query = $query . ") OR cardnumber LIKE ?
-        order by $orderby";
+        $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;
     }