Bug 20443: Remove SearchIdMatchingAttribute
[srvgit] / C4 / Utils / DataTables / Members.pm
index 4504bd3..b7887a8 100644 (file)
@@ -4,7 +4,6 @@ use Modern::Perl;
 use C4::Context;
 use C4::Utils::DataTables;
 use Koha::DateUtils;
-use C4::Members::Attributes qw(SearchIdMatchingAttribute );
 
 sub search {
     my ( $params ) = @_;
@@ -85,15 +84,10 @@ sub search {
 
     my $searchfields = {
         standard => C4::Context->preference('DefaultPatronSearchFields') || 'surname,firstname,othernames,cardnumber,userid',
-        surname => 'surname',
         email => 'email,emailpro,B_email',
         borrowernumber => 'borrowernumber',
-        userid => 'userid',
         phone => 'phone,phonepro,B_phone,altcontactphone,mobile',
         address => 'streetnumber,streettype,address,address2,city,state,zipcode,country',
-        dateofbirth => 'dateofbirth',
-        sort1 => 'sort1',
-        sort2 => 'sort2',
     };
 
     # * is replaced with % for sql
@@ -124,15 +118,21 @@ sub search {
         }
 
         my @where_strs_or;
-        for my $searchfield ( split /,/, $searchfields->{$searchfieldstype} ) {
-            push @where_strs_or, "borrowers." . $dbh->quote_identifier($searchfield) . " LIKE ?";
+        if ( defined $searchfields->{$searchfieldstype} ) {
+            for my $searchfield ( split /,/, $searchfields->{$searchfieldstype} ) {
+                push @where_strs_or, "borrowers." . $dbh->quote_identifier($searchfield) . " LIKE ?";
+                push @where_args, $term;
+            }
+        } else {
+            push @where_strs_or, "borrowers." . $dbh->quote_identifier($searchfieldstype) . " LIKE ?";
             push @where_args, $term;
         }
 
+
         if ( $searchfieldstype eq 'standard' and C4::Context->preference('ExtendedPatronAttributes') and $searchmember ) {
-            my $matching_borrowernumbers = C4::Members::Attributes::SearchIdMatchingAttribute($searchmember);
+            my @matching_borrowernumbers = Koha::Patrons->filter_by_attribute_value($searchmember)->get_column('borrowernumber');
 
-            for my $borrowernumber ( @$matching_borrowernumbers ) {
+            for my $borrowernumber ( @matching_borrowernumbers ) {
                 push @where_strs_or, "borrowers.borrowernumber = ?";
                 push @where_args, $borrowernumber;
             }