|
Lines 9-20
use C4::Members::Attributes qw(SearchIdMatchingAttribute );
Link Here
|
| 9 |
sub search { |
9 |
sub search { |
| 10 |
my ( $params ) = @_; |
10 |
my ( $params ) = @_; |
| 11 |
my $searchmember = $params->{searchmember}; |
11 |
my $searchmember = $params->{searchmember}; |
|
|
12 |
my $firstquery = $params->{firstquery}; |
| 12 |
my $firstletter = $params->{firstletter}; |
13 |
my $firstletter = $params->{firstletter}; |
| 13 |
my $categorycode = $params->{categorycode}; |
14 |
my $categorycode = $params->{categorycode}; |
| 14 |
my $branchcode = $params->{branchcode}; |
15 |
my $branchcode = $params->{branchcode}; |
| 15 |
my $searchtype = $params->{searchtype} || 'contain'; |
16 |
my $searchtype = $params->{searchtype} || 'contain'; |
| 16 |
my $searchfieldstype = $params->{searchfieldstype} || 'standard'; |
17 |
my $searchfieldstype = $params->{searchfieldstype} || 'standard'; |
| 17 |
my $dt_params = $params->{dt_params}; |
18 |
my $dt_params = $params->{dt_params}; |
|
|
19 |
my $searchfiltering = $params->{search_filter}; |
| 18 |
|
20 |
|
| 19 |
unless ( $searchmember ) { |
21 |
unless ( $searchmember ) { |
| 20 |
$searchmember = $dt_params->{sSearch} // ''; |
22 |
$searchmember = $dt_params->{sSearch} // ''; |
|
Lines 55-100
sub search {
Link Here
|
| 55 |
}; |
57 |
}; |
| 56 |
} |
58 |
} |
| 57 |
} |
59 |
} |
| 58 |
|
60 |
my $select = "SELECT |
| 59 |
my $select = "SELECT |
61 |
borrowers.borrowernumber, borrowers.surname, borrowers.firstname, |
| 60 |
borrowers.borrowernumber, borrowers.surname, borrowers.firstname, |
62 |
borrowers.streetnumber, borrowers.streettype, borrowers.address, |
| 61 |
borrowers.streetnumber, borrowers.streettype, borrowers.address, |
63 |
borrowers.address2, borrowers.city, borrowers.state, borrowers.zipcode, |
| 62 |
borrowers.address2, borrowers.city, borrowers.state, borrowers.zipcode, |
64 |
borrowers.country, cardnumber, borrowers.dateexpiry, |
| 63 |
borrowers.country, cardnumber, borrowers.dateexpiry, |
65 |
borrowers.borrowernotes, borrowers.branchcode, borrowers.email, |
| 64 |
borrowers.borrowernotes, borrowers.branchcode, borrowers.email, |
66 |
borrowers.userid, borrowers.dateofbirth, borrowers.categorycode, |
| 65 |
borrowers.userid, borrowers.dateofbirth, borrowers.categorycode, |
67 |
categories.description AS category_description, categories.category_type, |
| 66 |
categories.description AS category_description, categories.category_type, |
68 |
branches.branchname"; |
| 67 |
branches.branchname"; |
69 |
my $from = "FROM borrowers |
| 68 |
my $from = "FROM borrowers |
70 |
LEFT JOIN branches ON borrowers.branchcode = branches.branchcode |
| 69 |
LEFT JOIN branches ON borrowers.branchcode = branches.branchcode |
71 |
LEFT JOIN categories ON borrowers.categorycode = categories.categorycode"; |
| 70 |
LEFT JOIN categories ON borrowers.categorycode = categories.categorycode"; |
72 |
my @where_args; |
| 71 |
my @where_args; |
73 |
my @where_strs; |
| 72 |
my @where_strs; |
74 |
if(defined $firstletter and $firstletter ne '') { |
| 73 |
if(defined $firstletter and $firstletter ne '') { |
75 |
push @where_strs, "borrowers.surname LIKE ?"; |
| 74 |
push @where_strs, "borrowers.surname LIKE ?"; |
76 |
push @where_args, "$firstletter%"; |
| 75 |
push @where_args, "$firstletter%"; |
77 |
} |
| 76 |
} |
78 |
if(defined $categorycode and $categorycode ne '') { |
| 77 |
if(defined $categorycode and $categorycode ne '') { |
79 |
push @where_strs, "borrowers.categorycode = ?"; |
| 78 |
push @where_strs, "borrowers.categorycode = ?"; |
80 |
push @where_args, $categorycode; |
| 79 |
push @where_args, $categorycode; |
81 |
} |
| 80 |
} |
82 |
if(@restricted_branchcodes ) { |
| 81 |
if(@restricted_branchcodes ) { |
83 |
push @where_strs, "borrowers.branchcode IN (" . join( ',', ('?') x @restricted_branchcodes ) . ")"; |
| 82 |
push @where_strs, "borrowers.branchcode IN (" . join( ',', ('?') x @restricted_branchcodes ) . ")"; |
84 |
push @where_args, @restricted_branchcodes; |
| 83 |
push @where_args, @restricted_branchcodes; |
85 |
} |
| 84 |
} |
86 |
my $searchfields = { |
| 85 |
|
87 |
standard => C4::Context->preference('DefaultPatronSearchFields') || 'surname,firstname,othernames,cardnumber,userid', |
| 86 |
my $searchfields = { |
88 |
surname => 'surname', |
| 87 |
standard => C4::Context->preference('DefaultPatronSearchFields') || 'surname,firstname,othernames,cardnumber,userid', |
89 |
email => 'email,emailpro,B_email', |
| 88 |
surname => 'surname', |
90 |
borrowernumber => 'borrowernumber', |
| 89 |
email => 'email,emailpro,B_email', |
91 |
userid => 'userid', |
| 90 |
borrowernumber => 'borrowernumber', |
92 |
phone => 'phone,phonepro,B_phone,altcontactphone,mobile', |
| 91 |
userid => 'userid', |
93 |
address => 'streettype,address,address2,city,state,zipcode,country', |
| 92 |
phone => 'phone,phonepro,B_phone,altcontactphone,mobile', |
94 |
dateofbirth => 'dateofbirth', |
| 93 |
address => 'streettype,address,address2,city,state,zipcode,country', |
95 |
sort1 => 'sort1', |
| 94 |
dateofbirth => 'dateofbirth', |
96 |
sort2 => 'sort2', |
| 95 |
sort1 => 'sort1', |
97 |
}; |
| 96 |
sort2 => 'sort2', |
|
|
| 97 |
}; |
| 98 |
|
98 |
|
| 99 |
# * is replaced with % for sql |
99 |
# * is replaced with % for sql |
| 100 |
$searchmember =~ s/\*/%/g; |
100 |
$searchmember =~ s/\*/%/g; |