View | Details | Raw Unified | Return to bug 15252
Collapse All | Expand All

(-)a/C4/Utils/DataTables/Members.pm (-5 / +15 lines)
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
    # split into search terms
75
    my @terms;
76
    # consider coma as space
77
    $searchmember =~ s/,/ /g;
78
    if ( $searchtype eq 'contain' ) {
79
       @terms = split / /, $searchmember;
80
    } else {
81
       @terms = ($searchmember);
82
    }
83
84
    foreach my $term (@terms) {
76
        next unless $term;
85
        next unless $term;
77
        $searchmember =~ s/\*/%/g; # * is replaced with % for sql
86
87
        $term =~ s/\*/%/g; # * is replaced with % for sql
78
        $term .= '%' # end with anything
88
        $term .= '%' # end with anything
79
            if $term !~ /%$/;
89
            if $term !~ /%$/;
80
        $term = "%$term" # begin with anythin unless start_with
90
        $term = "%$term" # begin with anythin unless start_with
81
            if (defined $searchtype) && $searchtype eq "contain"
91
            if (defined $searchtype) && $searchtype eq "contain"
82
                && $term !~ /^%/;
92
                && $term !~ /^%/;
93
83
        my @where_strs_or;
94
        my @where_strs_or;
84
        for my $searchfield ( split /,/, $searchfields->{$searchfieldstype} ) {
95
        for my $searchfield ( split /,/, $searchfields->{$searchfieldstype} ) {
85
            push @where_strs_or, "borrowers." . $dbh->quote_identifier($searchfield) . " LIKE ?";
96
            push @where_strs_or, "borrowers." . $dbh->quote_identifier($searchfield) . " LIKE ?";
86
- 

Return to bug 15252