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

(-)a/C4/Utils/DataTables/Members.pm (+10 lines)
Lines 11-16 sub search { Link Here
11
    my $firstletter = $params->{firstletter};
11
    my $firstletter = $params->{firstletter};
12
    my $categorycode = $params->{categorycode};
12
    my $categorycode = $params->{categorycode};
13
    my $branchcode = $params->{branchcode};
13
    my $branchcode = $params->{branchcode};
14
    my $sort1 = $params->{sort1};
15
    my $sort2 = $params->{sort2};
14
    my $searchtype = $params->{searchtype} || 'contain';
16
    my $searchtype = $params->{searchtype} || 'contain';
15
    my $searchfieldstype = $params->{searchfieldstype} || 'standard';
17
    my $searchfieldstype = $params->{searchfieldstype} || 'standard';
16
    my $has_permission = $params->{has_permission};
18
    my $has_permission = $params->{has_permission};
Lines 111-116 sub search { Link Here
111
        push @where_strs, "borrowers.branchcode IN (" . join( ',', ('?') x @restricted_branchcodes ) . ")";
113
        push @where_strs, "borrowers.branchcode IN (" . join( ',', ('?') x @restricted_branchcodes ) . ")";
112
        push @where_args, @restricted_branchcodes;
114
        push @where_args, @restricted_branchcodes;
113
    }
115
    }
116
    if(defined $sort1 and $sort1 ne '') {
117
        push @where_strs, "borrowers.sort1 = ?";
118
        push @where_args, $sort1;
119
    }
120
    if(defined $sort2 and $sort2 ne '') {
121
        push @where_strs, "borrowers.sort2 = ?";
122
        push @where_args, $sort2;
123
    }
114
124
115
    my $searchfields = {
125
    my $searchfields = {
116
        standard => C4::Context->preference('DefaultPatronSearchFields') || 'surname,firstname,othernames,cardnumber,userid',
126
        standard => C4::Context->preference('DefaultPatronSearchFields') || 'surname,firstname,othernames,cardnumber,userid',
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt (+52 lines)
Lines 42-47 Link Here
42
                            [% END %]
42
                            [% END %]
43
                        </select>
43
                        </select>
44
                    </li>
44
                    </li>
45
                    <li>
46
                        <label for="sort1_filter">Sort1:</label>
47
                        <select id="sort1_filter">
48
                            <option value="">Any</option>
49
                            [% FOREACH sor IN sort1 %]
50
                                <option value="[% sor | html %]">[% sor | html %]</option>
51
                            [% END %]
52
                        </select>
53
                    </li>
54
                    <li>
55
                        <label for="sort2_filter">Sort2:</label>
56
                        <select id="sort2_filter">
57
                            <option value="">Any</option>
58
                            [% FOREACH sor IN sort2 %]
59
                                <option value="[% sor | html %]">[% sor | html %]</option>
60
                            [% END %]
61
                        </select>
62
                    </li>
45
                </ol>
63
                </ol>
46
                <fieldset class="action">
64
                <fieldset class="action">
47
                    <input type="submit" value="Search" />
65
                    <input type="submit" value="Search" />
Lines 69-79 Link Here
69
87
70
        <input type="hidden" id="firstletter_filter" value="" />
88
        <input type="hidden" id="firstletter_filter" value="" />
71
        <div id="searchresults">
89
        <div id="searchresults">
90
            <div class="searchheader fh-fixedHeader" id="searchheader">
91
                <div>
92
                    <a href="#" id="select_all"><i class="fa fa-check"></i> Select all</a>
93
                    |
94
                    <a href="#" id="clear_all"><i class="fa fa-remove"></i> Clear all</a>
95
                    |
96
                    <a href="#" class="btn btn-default btn-xs" id="add-selected">Add selected patrons</a>
97
                </div>
98
            </div>
72
            <table id="memberresultst">
99
            <table id="memberresultst">
73
                <thead>
100
                <thead>
74
                    <tr>
101
                    <tr>
75
                        [% FOR column IN columns %]
102
                        [% FOR column IN columns %]
76
                            [% SWITCH column %]
103
                            [% SWITCH column %]
104
                                [% CASE 'select' %]<th>&nbsp;</th>
77
                                [% CASE 'cardnumber' %]<th>Card</th>
105
                                [% CASE 'cardnumber' %]<th>Card</th>
78
                                [% CASE 'dateofbirth' %]<th>Date of birth</th>
106
                                [% CASE 'dateofbirth' %]<th>Date of birth</th>
79
                                [% CASE 'address' %]<th>Address</th>
107
                                [% CASE 'address' %]<th>Address</th>
Lines 150-155 Link Here
150
                    },{
178
                    },{
151
                        'name': 'branchcode',
179
                        'name': 'branchcode',
152
                        'value': $("#branchcode_filter").val()
180
                        'value': $("#branchcode_filter").val()
181
                    },{
182
                        'name': 'sort1',
183
                        'value': $("#sort1_filter").val()
184
                    },{
185
                        'name': 'sort2',
186
                        'value': $("#sort2_filter").val()
153
                    },{
187
                    },{
154
                        'name': 'name_sorton',
188
                        'name': 'name_sorton',
155
                        'value': 'borrowers.surname borrowers.firstname'
189
                        'value': 'borrowers.surname borrowers.firstname'
Lines 204-209 Link Here
204
                    [% FOR column IN columns %]
238
                    [% FOR column IN columns %]
205
                        [% IF column == 'action' %]
239
                        [% IF column == 'action' %]
206
                            { 'mDataProp': 'dt_action', 'bSortable': false, 'sClass': 'actions' }
240
                            { 'mDataProp': 'dt_action', 'bSortable': false, 'sClass': 'actions' }
241
                        [% ELSIF column == 'select' %]
242
                            { 'mDataProp': 'dt_select', 'bSortable': false, 'sClass': 'selections' }
207
                        [% ELSIF column == 'address' %]
243
                        [% ELSIF column == 'address' %]
208
                            { 'mDataProp': 'dt_address', 'bSortable': false }
244
                            { 'mDataProp': 'dt_address', 'bSortable': false }
209
                        [% ELSE %]
245
                        [% ELSE %]
Lines 225-230 Link Here
225
                e.preventDefault();
261
                e.preventDefault();
226
                filterByFirstLetterSurname($(this).text());
262
                filterByFirstLetterSurname($(this).text());
227
            });
263
            });
264
            $("#select_all").on("click",function(e){
265
                e.preventDefault();
266
                $("#searchresults .selection").prop("checked", true).change();
267
            });
268
            $("#clear_all").on("click",function(e){
269
                e.preventDefault();
270
                $("#searchresults .selection").prop("checked", false).change();
271
            });
272
            $("#add-selected").on('click', function(e){
273
                $("#searchresults .selection:checked").each(function(){
274
                    var borrowernumber = $(this).data("borrowernumber");
275
                    var firstname = $(this).data("firstname");
276
                    var surname = $(this).data("surname");
277
                    add_user( borrowernumber, firstname + " " + surname );
278
                });
279
            });
228
            $("body").on("click",".add_user",function(e){
280
            $("body").on("click",".add_user",function(e){
229
                e.preventDefault();
281
                e.preventDefault();
230
                var borrowernumber = $(this).data("borrowernumber");
282
                var borrowernumber = $(this).data("borrowernumber");
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/tables/members_results.tt (+2 lines)
Lines 6-11 Link Here
6
    "aaData": [
6
    "aaData": [
7
        [% FOREACH data IN aaData %]
7
        [% FOREACH data IN aaData %]
8
            {
8
            {
9
                "dt_select":
10
                    "<input type=\"checkbox\" class=\"selection\" data-borrowernumber=\"[% data.borrowernumber | html %]\" data-firstname=\"[% data.firstname | html %]\" data-surname=\"[% data.surname | html %]\">",
9
                "dt_cardnumber":
11
                "dt_cardnumber":
10
                    "[% data.cardnumber | html %]",
12
                    "[% data.cardnumber | html %]",
11
                "dt_name":
13
                "dt_name":
(-)a/patroncards/add_user_search.pl (-1 / +7 lines)
Lines 20-25 Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use CGI qw ( -utf8 );
22
use CGI qw ( -utf8 );
23
use List::MoreUtils qw(uniq);
23
use C4::Auth qw( get_template_and_user );
24
use C4::Auth qw( get_template_and_user );
24
use C4::Output qw( output_html_with_http_headers );
25
use C4::Output qw( output_html_with_http_headers );
25
use C4::Members;
26
use C4::Members;
Lines 44-56 my $op = $input->param('op') || ''; Link Here
44
my $referer = $input->referer();
45
my $referer = $input->referer();
45
46
46
my $patron_categories = Koha::Patron::Categories->search_with_library_limits;
47
my $patron_categories = Koha::Patron::Categories->search_with_library_limits;
48
my $sort_filter = { ( C4::Context->only_my_library ? (branchcode => C4::Context->userenv->{branch}) : () ) };
49
my @sort1 = sort {$a cmp $b} uniq( Koha::Patrons->search($sort_filter)->get_column('sort1') );
50
my @sort2 = sort {$a cmp $b} uniq( Koha::Patrons->search($sort_filter)->get_column('sort2') );
47
$template->param(
51
$template->param(
48
    view            => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
52
    view            => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
49
    columns         => ['cardnumber', 'name', 'category', 'branch', 'dateexpiry', 'borrowernotes', 'action'],
53
    columns         => ['select', 'cardnumber', 'name', 'category', 'branch', 'dateexpiry', 'borrowernotes', 'action'],
50
    json_template   => 'patroncards/tables/members_results.tt',
54
    json_template   => 'patroncards/tables/members_results.tt',
51
    selection_type  => 'add',
55
    selection_type  => 'add',
52
    alphabet        => ( C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' ),
56
    alphabet        => ( C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' ),
53
    categories      => $patron_categories,
57
    categories      => $patron_categories,
58
    sort1           => \@sort1,
59
    sort2           => \@sort2,
54
    aaSorting       => 1,
60
    aaSorting       => 1,
55
);
61
);
56
output_html_with_http_headers( $input, $cookie, $template->output );
62
output_html_with_http_headers( $input, $cookie, $template->output );
(-)a/svc/members/search (-1 / +4 lines)
Lines 42-47 my $searchmember = $input->param('searchmember'); Link Here
42
my $firstletter  = $input->param('firstletter');
42
my $firstletter  = $input->param('firstletter');
43
my $categorycode = $input->param('categorycode');
43
my $categorycode = $input->param('categorycode');
44
my $branchcode = $input->param('branchcode');
44
my $branchcode = $input->param('branchcode');
45
my $sort1      = $input->param('sort1');
46
my $sort2      = $input->param('sort2');
45
my $searchtype = $input->param('searchtype');
47
my $searchtype = $input->param('searchtype');
46
my $searchfieldstype = $input->param('searchfieldstype') || 'standard';
48
my $searchfieldstype = $input->param('searchfieldstype') || 'standard';
47
my $has_permission = $input->param('has_permission');
49
my $has_permission = $input->param('has_permission');
Lines 83-88 $results = C4::Utils::DataTables::Members::search( Link Here
83
        firstletter => $firstletter,
85
        firstletter => $firstletter,
84
        categorycode => $categorycode,
86
        categorycode => $categorycode,
85
        branchcode => $branchcode,
87
        branchcode => $branchcode,
88
        sort1 => $sort1,
89
        sort2 => $sort2,
86
        searchtype => $searchtype,
90
        searchtype => $searchtype,
87
        searchfieldstype => $searchfieldstype,
91
        searchfieldstype => $searchfieldstype,
88
        dt_params => \%dt_params,
92
        dt_params => \%dt_params,
89
- 

Return to bug 28726