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

(-)a/C4/Utils/DataTables/Members.pm (-14 / +9 lines)
Lines 88-109 sub search { Link Here
88
    foreach my $term (@terms) {
88
    foreach my $term (@terms) {
89
        next unless $term;
89
        next unless $term;
90
90
91
        my $termsearchfieldstype;
91
        my $term_dt = eval { local $SIG{__WARN__} = {}; output_pref( { str => $term, dateonly => 1, dateformat => 'sql' } ); };
92
        my $term_is_dt = eval { local $SIG{__WARN__}={}; Koha::DateUtils::output_pref( { str=>$term, dateonly=>1, dateformat=>'sql' } ); };
93
92
94
        if ( $term_is_dt ){
93
        if ($term_dt) {
95
            $termsearchfieldstype = 'dateofbirth' ;
94
            $searchfieldstype = 'dateofbirth';
96
            $term = $term_is_dt;
95
            $term                 = $term_dt;
97
        } else {
96
        } else {
98
            $termsearchfieldstype = $searchfieldstype;
97
            $term .= '%'    # end with anything
99
        $term .= '%' # end with anything
98
              if $term !~ /%$/;
100
            if $term !~ /%$/;
99
            $term = "%$term"    # begin with anythin unless start_with
101
        $term = "%$term" # begin with anythin unless start_with
100
              if $searchtype eq 'contain' && $term !~ /^%/;
102
            if $searchtype eq 'contain' && $term !~ /^%/;
103
        }
101
        }
104
102
105
        my @where_strs_or;
103
        my @where_strs_or;
106
        for my $searchfield ( split /,/, $searchfields->{$termsearchfieldstype} ) {
104
        for my $searchfield ( split /,/, $searchfields->{$searchfieldstype} ) {
107
            push @where_strs_or, "borrowers." . $dbh->quote_identifier($searchfield) . " LIKE ?";
105
            push @where_strs_or, "borrowers." . $dbh->quote_identifier($searchfield) . " LIKE ?";
108
            push @where_args, $term;
106
            push @where_args, $term;
109
        }
107
        }
Lines 145-152 sub search { Link Here
145
        ($limit ? $limit : "")
143
        ($limit ? $limit : "")
146
    );
144
    );
147
    my $sth = $dbh->prepare($query);
145
    my $sth = $dbh->prepare($query);
148
    warn Data::Dumper::Dumper( $query );
149
    warn Data::Dumper::Dumper( @where_args );
150
146
151
    $sth->execute(@where_args);
147
    $sth->execute(@where_args);
152
    my $patrons = $sth->fetchall_arrayref({});
148
    my $patrons = $sth->fetchall_arrayref({});
153
- 

Return to bug 14874