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

(-)a/C4/Utils/DataTables/Members.pm (-6 / +2 lines)
Lines 59-65 sub search { Link Here
59
    }
59
    }
60
60
61
    my $searchfields = {
61
    my $searchfields = {
62
        standard => 'surname,firstname,othernames,cardnumber,userid',
62
        standard => C4::Context->preference('DefaultPatronSearchFields'),
63
        surname => 'surname',
63
        surname => 'surname',
64
        email => 'email,emailpro,B_email',
64
        email => 'email,emailpro,B_email',
65
        borrowernumber => 'borrowernumber',
65
        borrowernumber => 'borrowernumber',
Lines 87-101 sub search { Link Here
87
    foreach my $term (@terms) {
87
    foreach my $term (@terms) {
88
        next unless $term;
88
        next unless $term;
89
89
90
        my $termsearchfieldstype;
91
92
        my $term_dt = eval { local $SIG{__WARN__} = {}; output_pref( { str => $term, dateonly => 1, dateformat => 'sql' } ); };
90
        my $term_dt = eval { local $SIG{__WARN__} = {}; output_pref( { str => $term, dateonly => 1, dateformat => 'sql' } ); };
93
91
94
        if ($term_dt) {
92
        if ($term_dt) {
95
            $termsearchfieldstype = 'dateofbirth';
96
            $term                 = $term_dt;
93
            $term                 = $term_dt;
97
        } else {
94
        } else {
98
            $termsearchfieldstype = $searchfieldstype;
99
            $term .= '%'    # end with anything
95
            $term .= '%'    # end with anything
100
              if $term !~ /%$/;
96
              if $term !~ /%$/;
101
            $term = "%$term"    # begin with anythin unless start_with
97
            $term = "%$term"    # begin with anythin unless start_with
Lines 103-109 sub search { Link Here
103
        }
99
        }
104
100
105
        my @where_strs_or;
101
        my @where_strs_or;
106
        for my $searchfield ( split /,/, $searchfields->{$termsearchfieldstype} ) {
102
        for my $searchfield ( split /,/, $searchfields->{$searchfieldstype} ) {
107
            push @where_strs_or, "borrowers." . $dbh->quote_identifier($searchfield) . " LIKE ?";
103
            push @where_strs_or, "borrowers." . $dbh->quote_identifier($searchfield) . " LIKE ?";
108
            push @where_args, $term;
104
            push @where_args, $term;
109
        }
105
        }
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 116-121 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
116
('DefaultLongOverdueChargeValue', '', NULL, "Charge a lost item to the borrower's account when the LOST value of the item changes to n.", 'integer'),
116
('DefaultLongOverdueChargeValue', '', NULL, "Charge a lost item to the borrower's account when the LOST value of the item changes to n.", 'integer'),
117
('DefaultLongOverdueDays', '', NULL, "Set the LOST value of an item when the item has been overdue for more than n days.", 'integer'),
117
('DefaultLongOverdueDays', '', NULL, "Set the LOST value of an item when the item has been overdue for more than n days.", 'integer'),
118
('DefaultLongOverdueLostValue', '', NULL, "Set the LOST value of an item to n when the item has been overdue for more than defaultlongoverduedays days.", 'integer'),
118
('DefaultLongOverdueLostValue', '', NULL, "Set the LOST value of an item to n when the item has been overdue for more than defaultlongoverduedays days.", 'integer'),
119
('DefaultPatronSearchFields',    'surname,firstname,othernames,cardnumber,userid',NULL,'Comma separated list defining the default fields to be used during a patron search','free');
119
('defaultSortField','relevance','relevance|popularity|call_number|pubdate|acqdate|title|author','Specify the default field used for sorting','Choice'),
120
('defaultSortField','relevance','relevance|popularity|call_number|pubdate|acqdate|title|author','Specify the default field used for sorting','Choice'),
120
('defaultSortOrder','dsc','asc|dsc|az|za','Specify the default sort order','Choice'),
121
('defaultSortOrder','dsc','asc|dsc|az|za','Specify the default sort order','Choice'),
121
('DefaultToLoggedInLibraryCircRules',  '0', NULL ,  'If enabled, circ rules editor will default to the logged in library''s rules, rather than the ''all libraries'' rules.',  'YesNo'),
122
('DefaultToLoggedInLibraryCircRules',  '0', NULL ,  'If enabled, circ rules editor will default to the logged in library''s rules, rather than the ''all libraries'' rules.',  'YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (+4 lines)
Lines 109-114 Patrons: Link Here
109
           class: integer
109
           class: integer
110
         - results per page in the staff client.
110
         - results per page in the staff client.
111
     -
111
     -
112
         - pref: DefaultPatronSearchFields
113
           class: multi
114
         - "Comma separated list defining the default fields to be used during a patron search"
115
     -
112
         - pref: PatronQuickAddFields
116
         - pref: PatronQuickAddFields
113
           class: multi
117
           class: multi
114
         - (separate columns with |)
118
         - (separate columns with |)
(-)a/t/db_dependent/Utils/Datatables_Members.t (-4 / +4 lines)
Lines 355-360 my %dates_in_pref = ( Link Here
355
        );
355
        );
356
foreach my $dateformloo (@datetimeprefs){
356
foreach my $dateformloo (@datetimeprefs){
357
    t::lib::Mocks::mock_preference('dateformat', $dateformloo);
357
    t::lib::Mocks::mock_preference('dateformat', $dateformloo);
358
    t::lib::Mocks::mock_preference('DefaultPatronSearchFields', 'surname,firstname,othernames,userid,dateofbirth');
358
    $search_results = C4::Utils::DataTables::Members::search({
359
    $search_results = C4::Utils::DataTables::Members::search({
359
        searchmember     => $dates_in_pref{$dateformloo}[0],
360
        searchmember     => $dates_in_pref{$dateformloo}[0],
360
        searchfieldstype => 'standard',
361
        searchfieldstype => 'standard',
Lines 364-370 foreach my $dateformloo (@datetimeprefs){ Link Here
364
    });
365
    });
365
366
366
    is( $search_results->{ iTotalDisplayRecords }, 2,
367
    is( $search_results->{ iTotalDisplayRecords }, 2,
367
        "dateformat: $dateformloo Two borrowers have dob $dates_in_pref{$dateformloo}[0], standard search fields overriden");
368
        "dateformat: $dateformloo Two borrowers have dob $dates_in_pref{$dateformloo}[0], standard search fields plus dob works");
368
369
369
    $search_results = C4::Utils::DataTables::Members::search({
370
    $search_results = C4::Utils::DataTables::Members::search({
370
        searchmember     => $dates_in_pref{$dateformloo}[2],
371
        searchmember     => $dates_in_pref{$dateformloo}[2],
Lines 375-381 foreach my $dateformloo (@datetimeprefs){ Link Here
375
    });
376
    });
376
377
377
    is( $search_results->{ iTotalDisplayRecords }, 1,
378
    is( $search_results->{ iTotalDisplayRecords }, 1,
378
        "dateformat: $dateformloo One borrower has dob $dates_in_pref{$dateformloo}[2], standard search fields overriden");
379
        "dateformat: $dateformloo One borrower has dob $dates_in_pref{$dateformloo}[2], standard search fields plus dob works");
379
380
380
    $search_results = C4::Utils::DataTables::Members::search({
381
    $search_results = C4::Utils::DataTables::Members::search({
381
        searchmember     => $dates_in_pref{$dateformloo}[1],
382
        searchmember     => $dates_in_pref{$dateformloo}[1],
Lines 408-414 foreach my $dateformloo (@datetimeprefs){ Link Here
408
    });
409
    });
409
410
410
    is( $search_results->{ iTotalDisplayRecords }, 0,
411
    is( $search_results->{ iTotalDisplayRecords }, 0,
411
        "dateformat: $dateformloo No borrowers have dob $dates_in_pref{$dateformloo}[3], standard search field overridden");
412
        "dateformat: $dateformloo No borrowers have dob $dates_in_pref{$dateformloo}[3], standard search fields p[lus dob works");
412
}
413
}
413
414
414
# End
415
# End
415
- 

Return to bug 14874