Lines 54-60
sub search {
Link Here
|
54 |
|
54 |
|
55 |
# split on coma |
55 |
# split on coma |
56 |
$searchmember =~ s/,/ /g if $searchmember; |
56 |
$searchmember =~ s/,/ /g if $searchmember; |
57 |
my @where_strs_or; |
|
|
58 |
my $searchfields = { |
57 |
my $searchfields = { |
59 |
standard => 'surname,firstname,othernames,cardnumber', |
58 |
standard => 'surname,firstname,othernames,cardnumber', |
60 |
email => 'email,emailpro,B_email', |
59 |
email => 'email,emailpro,B_email', |
Lines 65-85
sub search {
Link Here
|
65 |
sort1 => 'sort1', |
64 |
sort1 => 'sort1', |
66 |
sort2 => 'sort2', |
65 |
sort2 => 'sort2', |
67 |
}; |
66 |
}; |
68 |
for my $searchfield ( split /,/, $searchfields->{$searchfieldstype} ) { |
67 |
foreach my $term ( split / /, $searchmember) { |
69 |
foreach my $term ( split / /, $searchmember) { |
68 |
next unless $term; |
70 |
next unless $term; |
69 |
$searchmember =~ s/\*/%/g; # * is replaced with % for sql |
71 |
$searchmember =~ s/\*/%/g; # * is replaced with % for sql |
70 |
$term .= '%' # end with anything |
72 |
$term .= '%' # end with anything |
71 |
if $term !~ /%$/; |
73 |
if $term !~ /%$/; |
72 |
$term = "%$term" # begin with anythin unless start_with |
74 |
$term = "%$term" # begin with anythin unless start_with |
73 |
if $term !~ /^%/ |
75 |
if $term !~ /^%/ |
74 |
and $searchtype eq "contain"; |
76 |
and $searchtype eq "contain"; |
75 |
my @where_strs_or; |
|
|
76 |
for my $searchfield ( split /,/, $searchfields->{$searchfieldstype} ) { |
77 |
push @where_strs_or, "borrowers." . $dbh->quote_identifier($searchfield) . " LIKE ?"; |
77 |
push @where_strs_or, "borrowers." . $dbh->quote_identifier($searchfield) . " LIKE ?"; |
78 |
push @where_args, $term; |
78 |
push @where_args, $term; |
79 |
} |
79 |
} |
|
|
80 |
|
81 |
push @where_strs, '('. join (' OR ', @where_strs_or) . ')' |
82 |
if @where_strs_or; |
80 |
} |
83 |
} |
81 |
push @where_strs, '('. join (' OR ', @where_strs_or) . ')' |
|
|
82 |
if @where_strs_or; |
83 |
|
84 |
|
84 |
my $where; |
85 |
my $where; |
85 |
$where = " WHERE " . join (" AND ", @where_strs) if @where_strs; |
86 |
$where = " WHERE " . join (" AND ", @where_strs) if @where_strs; |
86 |
- |
|
|