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

(-)a/C4/Utils/DataTables/Members.pm (-2 lines)
Lines 14-20 sub search { Link Here
14
    my $branchcode = $params->{branchcode};
14
    my $branchcode = $params->{branchcode};
15
    my $searchtype = $params->{searchtype} || 'contain';
15
    my $searchtype = $params->{searchtype} || 'contain';
16
    my $searchfieldstype = $params->{searchfieldstype} || 'standard';
16
    my $searchfieldstype = $params->{searchfieldstype} || 'standard';
17
    warn $searchfieldstype;
18
    my $dt_params = $params->{dt_params};
17
    my $dt_params = $params->{dt_params};
19
18
20
    unless ( $searchmember ) {
19
    unless ( $searchmember ) {
Lines 146-152 sub search { Link Here
146
145
147
    my $where;
146
    my $where;
148
    $where = " WHERE " . join (" AND ", @where_strs) if @where_strs;
147
    $where = " WHERE " . join (" AND ", @where_strs) if @where_strs;
149
    warn $where;
150
    my $orderby = dt_build_orderby($dt_params);
148
    my $orderby = dt_build_orderby($dt_params);
151
149
152
    my $limit;
150
    my $limit;
(-)a/members/member.pl (-1 lines)
Lines 65-71 if ( $quicksearch and $searchmember ) { Link Here
65
}
65
}
66
66
67
my $searchfieldstype = $input->param('searchfieldstype') || 'standard';
67
my $searchfieldstype = $input->param('searchfieldstype') || 'standard';
68
warn "script type $searchfieldstype";
69
$template->param( 'alphabet' => C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' );
68
$template->param( 'alphabet' => C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' );
70
69
71
my $view = $input->request_method() eq "GET" ? "show_form" : "show_results";
70
my $view = $input->request_method() eq "GET" ? "show_form" : "show_results";
(-)a/t/db_dependent/Utils/Datatables_Members.t (-2 / +20 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 50;
20
use Test::More tests => 51;
21
21
22
use C4::Context;
22
use C4::Context;
23
use C4::Members;
23
use C4::Members;
Lines 57-63 my $john_doe = $builder->build({ Link Here
57
            surname      => 'Doe',
57
            surname      => 'Doe',
58
            branchcode   => $branchcode,
58
            branchcode   => $branchcode,
59
            dateofbirth  => '1983-03-01',
59
            dateofbirth  => '1983-03-01',
60
            userid       => 'john.doe'
60
            userid       => 'john.doe',
61
            initials     => 'pacman'
61
        },
62
        },
62
});
63
});
63
64
Lines 113-118 my %dt_params = ( Link Here
113
    iDisplayStart    => 0
114
    iDisplayStart    => 0
114
);
115
);
115
116
117
t::lib::Mocks::mock_preference('DefaultPatronSearchFields', '');
118
116
# Search "John Doe"
119
# Search "John Doe"
117
my $search_results = C4::Utils::DataTables::Members::search({
120
my $search_results = C4::Utils::DataTables::Members::search({
118
    searchmember     => "John Doe",
121
    searchmember     => "John Doe",
Lines 461-465 subtest 'ExtendedPatronAttributes' => sub { Link Here
461
        "'Dupont' is contained in 2 surnames and a patron attribute. Patron attribute one should not be displayed if searching in specific fields (Bug 18094)");
464
        "'Dupont' is contained in 2 surnames and a patron attribute. Patron attribute one should not be displayed if searching in specific fields (Bug 18094)");
462
};
465
};
463
466
467
subtest 'Search by any borrowers field (bug 17374)' => sub {
468
    plan tests => 2;
469
470
    my $search_results = C4::Utils::DataTables::Members::search({
471
        searchmember     => "pacman",
472
        searchfieldstype => 'initials',
473
        searchtype       => 'contain',
474
        branchcode       => $branchcode,
475
        dt_params        => \%dt_params
476
    });
477
    is( $search_results->{ iTotalDisplayRecords }, 1, "We find only 1 patron when searching for initials 'pacman'" );
478
479
    is( $search_results->{ patrons }[0]->{ cardnumber }, $john_doe->{cardnumber}, "We find the correct patron when sesrching by initials" )
480
};
481
464
# End
482
# End
465
$schema->storage->txn_rollback;
483
$schema->storage->txn_rollback;
(-)a/t/db_dependent/selenium/patrons_search.t (-2 / +21 lines)
Lines 40-46 my $builder = t::lib::TestBuilder->new; Link Here
40
40
41
our @cleanup;
41
our @cleanup;
42
subtest 'Search patrons' => sub {
42
subtest 'Search patrons' => sub {
43
    plan tests => 6;
43
    plan tests => 12;
44
44
45
    my @patrons;
45
    my @patrons;
46
    my $borrowernotes           = q|<strong>just 'a" note</strong> \123 ❤|;
46
    my $borrowernotes           = q|<strong>just 'a" note</strong> \123 ❤|;
Lines 58-63 subtest 'Search patrons' => sub { Link Here
58
    my $library = $builder->build_object(
58
    my $library = $builder->build_object(
59
        { class => 'Koha::Libraries', value => { branchname => $branchname } }
59
        { class => 'Koha::Libraries', value => { branchname => $branchname } }
60
    );
60
    );
61
    my $default_patron_search_fields = C4::Context->preference('DefaultPatronSearchFields');
61
    for my $i ( 1 .. 25 ) {
62
    for my $i ( 1 .. 25 ) {
62
        push @patrons,
63
        push @patrons,
63
          $builder->build_object(
64
          $builder->build_object(
Lines 77-83 subtest 'Search patrons' => sub { Link Here
77
    }
78
    }
78
79
79
    $s->auth;
80
    $s->auth;
81
    C4::Context->set_preference('DefaultPatronSearchFields',"");
80
    $driver->get( $base_url . "/members/members-home.pl" );
82
    $driver->get( $base_url . "/members/members-home.pl" );
83
    my @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option');
84
    my @filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option');
85
    is( scalar @adv_options, 11, 'All standard fields are searchable if DefaultPatronSearchFields not set');
86
    is( scalar @filter_options, 11, 'All standard fields are searchable by filter if DefaultPatronSearchFields not set');
87
    C4::Context->set_preference('DefaultPatronSearchFields',"initials");
88
    $driver->get( $base_url . "/members/members-home.pl" );
89
    @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option');
90
    @filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option');
91
    is( scalar @adv_options, 12, 'New option added when DefaultPatronSearchFields is populated with a field');
92
    is( scalar @filter_options, 12, 'New filter option added when DefaultPatronSearchFields is populated with a field');
93
    C4::Context->set_preference('DefaultPatronSearchFields',"initials,horses");
94
    $driver->get( $base_url . "/members/members-home.pl" );
95
    @adv_options = $driver->find_elements('//select[@id="searchfieldstype"]/option');
96
    @filter_options = $driver->find_elements('//select[@id="searchfieldstype_filter"]/option');
97
    is( scalar @adv_options, 12, 'Invalid option not added when DefaultPatronSearchFields is populated with an invalid field');
98
    is( scalar @filter_options, 12, 'Invalid filter option not added when DefaultPatronSearchFields is populated with an invalid field');
99
    C4::Context->set_preference('DefaultPatronSearchFields',"");
81
    $s->fill_form( { searchmember_filter => 'test_patron' } );
100
    $s->fill_form( { searchmember_filter => 'test_patron' } );
82
    $s->submit_form;
101
    $s->submit_form;
83
    my $first_patron = $patrons[0];
102
    my $first_patron = $patrons[0];
Lines 114-119 subtest 'Search patrons' => sub { Link Here
114
    push @cleanup, $_ for @patrons;
133
    push @cleanup, $_ for @patrons;
115
    push @cleanup, $library;
134
    push @cleanup, $library;
116
    push @cleanup, $patron_category;
135
    push @cleanup, $patron_category;
136
    C4::Context->set_preference('DefaultPatronSearchFields',$default_patron_search_fields);
117
};
137
};
118
138
119
END {
139
END {
120
- 

Return to bug 17374