Lines 59-66
sub search {
Link Here
|
59 |
push @where_args, $branchcode; |
59 |
push @where_args, $branchcode; |
60 |
} |
60 |
} |
61 |
|
61 |
|
62 |
# split on coma |
|
|
63 |
$searchmember =~ s/,/ /g if $searchmember; |
64 |
my $searchfields = { |
62 |
my $searchfields = { |
65 |
standard => 'surname,firstname,othernames,cardnumber,userid', |
63 |
standard => 'surname,firstname,othernames,cardnumber,userid', |
66 |
email => 'email,emailpro,B_email', |
64 |
email => 'email,emailpro,B_email', |
Lines 72-85
sub search {
Link Here
|
72 |
sort1 => 'sort1', |
70 |
sort1 => 'sort1', |
73 |
sort2 => 'sort2', |
71 |
sort2 => 'sort2', |
74 |
}; |
72 |
}; |
75 |
foreach my $term ( split / /, $searchmember) { |
73 |
|
|
|
74 |
# * is replaced with % for sql |
75 |
$searchmember =~ s/\*/%/g; |
76 |
|
77 |
# split into search terms |
78 |
my @terms; |
79 |
# consider coma as space |
80 |
$searchmember =~ s/,/ /g; |
81 |
if ( $searchtype eq 'contain' ) { |
82 |
@terms = split / /, $searchmember; |
83 |
} else { |
84 |
@terms = ($searchmember); |
85 |
} |
86 |
|
87 |
foreach my $term (@terms) { |
76 |
next unless $term; |
88 |
next unless $term; |
77 |
$searchmember =~ s/\*/%/g; # * is replaced with % for sql |
89 |
|
78 |
$term .= '%' # end with anything |
90 |
$term .= '%' # end with anything |
79 |
if $term !~ /%$/; |
91 |
if $term !~ /%$/; |
80 |
$term = "%$term" # begin with anythin unless start_with |
92 |
$term = "%$term" # begin with anythin unless start_with |
81 |
if (defined $searchtype) && $searchtype eq "contain" |
93 |
if (defined $searchtype) && $searchtype eq "contain" |
82 |
&& $term !~ /^%/; |
94 |
&& $term !~ /^%/; |
|
|
95 |
|
83 |
my @where_strs_or; |
96 |
my @where_strs_or; |
84 |
for my $searchfield ( split /,/, $searchfields->{$searchfieldstype} ) { |
97 |
for my $searchfield ( split /,/, $searchfields->{$searchfieldstype} ) { |
85 |
push @where_strs_or, "borrowers." . $dbh->quote_identifier($searchfield) . " LIKE ?"; |
98 |
push @where_strs_or, "borrowers." . $dbh->quote_identifier($searchfield) . " LIKE ?"; |
86 |
- |
|
|