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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc (-2 / +56 lines)
Lines 56-61 Link Here
56
                                [% END %]
56
                                [% END %]
57
                            </select>
57
                            </select>
58
                        </li>
58
                        </li>
59
                    [% CASE 'sort1' %]
60
                        <li>
61
                            <label for="sort1_filter">Sort1:</label>
62
                            <select class="select2" id="sort1_filter">
63
                                <option value="">Any</option>
64
                                [% FOREACH s1 IN sort1 %]
65
                                    <option value="[% s1 | html %]">[% s1 | html %]</option>
66
                                [% END %]
67
                            </select>
68
                        </li>
69
                    [% CASE 'sort2' %]
70
                        <li>
71
                            <label for="sort2_filter">Sort2:</label>
72
                            <select class="select2" id="sort2_filter">
73
                                <option value="">Any</option>
74
                                [% FOREACH s2 IN sort2 %]
75
                                    <option value="[% s2 | html %]">[% s2 | html %]</option>
76
                                [% END %]
77
                            </select>
78
                        </li>
59
                    [% CASE 'search_field' %]
79
                    [% CASE 'search_field' %]
60
                        <li>
80
                        <li>
61
                            <label for="searchfieldstype_filter">Search field:</label>
81
                            <label for="searchfieldstype_filter">Search field:</label>
Lines 209-214 Link Here
209
    [% IF redirect_if_one_result && !redirect_url %]
229
    [% IF redirect_if_one_result && !redirect_url %]
210
        <script>console.log("Wrong call of patron_searh_js - missing redirect_url");</script>
230
        <script>console.log("Wrong call of patron_searh_js - missing redirect_url");</script>
211
    [% END %]
231
    [% END %]
232
233
    [% INCLUDE 'select2.inc' %]
212
    <script>
234
    <script>
213
        let categories = [% To.json(categories) | $raw %].map(e => {
235
        let categories = [% To.json(categories) | $raw %].map(e => {
214
            e['_id'] = e.categorycode;
236
            e['_id'] = e.categorycode;
Lines 233-238 Link Here
233
            let extended_attribute_types = [% To.json(extended_attribute_types || []) | $raw %];
255
            let extended_attribute_types = [% To.json(extended_attribute_types || []) | $raw %];
234
        [% END %]
256
        [% END %]
235
257
258
        $(document).ready(function() {
259
            $('sort1_filter').select2({allowClear:true});
260
            $('sort2_filter').select2({allowClear:true});
261
        });
236
    </script>
262
    </script>
237
263
238
    [% INCLUDE 'datatables.inc' %]
264
    [% INCLUDE 'datatables.inc' %]
Lines 308-318 Link Here
308
                    return { "like": start_with + "%" }
334
                    return { "like": start_with + "%" }
309
                },
335
                },
310
                "-and": function(){
336
                "-and": function(){
337
                    let filters = [];
338
                    let f_sort1 = $("#sort1_filter").val();
339
                    if ( f_sort1 ) {
340
                        filters.push({
341
                            "me.sort1": f_sort1
342
                        });
343
                    }
344
                    let f_sort2 = $("#sort2_filter").val();
345
                    if ( f_sort2 ) {
346
                        filters.push({
347
                            "me.sort2": f_sort2
348
                        });
349
                    }
350
311
                    let pattern = $("#search_patron_filter").val();
351
                    let pattern = $("#search_patron_filter").val();
312
                    if (!pattern) return "";
352
                    if (!pattern) {
353
                        if ( filters.length == 0 ) {
354
                            return "";
355
                        }
356
                        else {
357
                            return filters;
358
                        }
359
                    }
313
                    let patterns = pattern.split(' ').filter(function(s){ return s.length });
360
                    let patterns = pattern.split(' ').filter(function(s){ return s.length });
314
361
315
                    let filters = [];
316
                    let search_type = $("#searchtype_filter").val() || "contain";
362
                    let search_type = $("#searchtype_filter").val() || "contain";
317
                    let search_fields = $("#searchfieldstype_filter").val();
363
                    let search_fields = $("#searchfieldstype_filter").val();
318
                    if ( !search_fields ) {
364
                    if ( !search_fields ) {
Lines 731-736 Link Here
731
            if ( $("#branchcode_filter").val() ) {
777
            if ( $("#branchcode_filter").val() ) {
732
                searched += _(" in library ") + $("#branchcode_filter").find("option:selected").text();
778
                searched += _(" in library ") + $("#branchcode_filter").find("option:selected").text();
733
            }
779
            }
780
            if ( $("#sort1_filter").val() ) {
781
                searched += _(" with sort1 ") + $("#sort1_filter").find("option:selected").text();
782
            }
783
            if ( $("#sort2_filter").val() ) {
784
                searched += _(" with sort2 ") + $("#sort2_filter").find("option:selected").text();
785
            }
734
            $("#searchpattern").text(searched);
786
            $("#searchpattern").text(searched);
735
            $("#searchpattern").parent().show();
787
            $("#searchpattern").parent().show();
736
        }
788
        }
Lines 788-793 Link Here
788
            $("#searchtype_filter option[value='contain']").prop("selected", true);
840
            $("#searchtype_filter option[value='contain']").prop("selected", true);
789
            $("#categorycode_filter option:first").prop("selected", true);
841
            $("#categorycode_filter option:first").prop("selected", true);
790
            $("#branchcode_filter option:first").prop("selected", true);
842
            $("#branchcode_filter option:first").prop("selected", true);
843
            $("#sort1_filter option:first").prop("selected", true);
844
            $("#sort2_filter option:first").prop("selected", true);
791
            $("#firstletter_filter").val('');
845
            $("#firstletter_filter").val('');
792
            $("#search_patron_filter").val('');
846
            $("#search_patron_filter").val('');
793
            /* remove any search string added by firstletter search */
847
            /* remove any search string added by firstletter search */
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tt (-1 / +44 lines)
Lines 17-26 Link Here
17
<div id="patron_search">
17
<div id="patron_search">
18
    <div class="container-fluid">
18
    <div class="container-fluid">
19
19
20
        [% PROCESS patron_search_filters categories => categories, libraries => libraries, filters => ['branch', 'category'], search_filter => searchmember %]
20
        [% PROCESS patron_search_filters categories => categories, libraries => libraries, sort1 => sort1, sort2 => sort2, filters => form_filters, search_filter => searchmember %]
21
        </form>
21
        </form>
22
22
23
        <div id="searchresults">
24
            <div class="searchheader fh-fixedHeader" id="searchheader" style="display:none;">
25
                <div>
26
                [% IF columns.grep('checkbox').size %]
27
                    <a href="#" class="btn btn-link" id="select_all"><i class="fa fa-check"></i> Select all</a>
28
                    |
29
                    <a href="#" class="btn btn-link" id="clear_all"><i class="fa fa-remove"></i> Clear all</a>
30
                    [% IF selection_type == 'add' %]
31
                    <button id="add-selected" class="btn btn-sm btn-default" type="submit">Add selected patrons</button>
32
                    [% END %]
33
                [% END %]
34
                </div>
35
            </div>
23
        [% PROCESS patron_search_table table_id => 'memberresultst' columns => columns %]
36
        [% PROCESS patron_search_table table_id => 'memberresultst' columns => columns %]
37
        </div>
24
38
25
        <div id="closewindow"><a href="#" class="btn btn-default btn-default close">Close</a></div>
39
        <div id="closewindow"><a href="#" class="btn btn-default btn-default close">Close</a></div>
26
40
Lines 28-33 Link Here
28
</div>
42
</div>
29
43
30
[% MACRO jsinclude BLOCK %]
44
[% MACRO jsinclude BLOCK %]
45
<script>
46
    $(document).ready(function() {
47
        $("#select_all").on("click",function(e){
48
            e.preventDefault();
49
            $(".selection").prop("checked", true).change();
50
        });
51
        $("#clear_all").on("click",function(e){
52
            e.preventDefault();
53
            $(".selection").prop("checked", false).change();
54
        });
55
        $("#searchheader").hide();
56
        $("#patron_search_form").on('submit', function(){$("#searchheader").show();});
57
        $("#clear_search").on("click",function(e){$("#searchheader").hide();});
58
59
        $('#add-selected').on('click', function(e) {
60
            e.preventDefault();
61
            var counter = 0;
62
            $('tr:has(.selection:checked) .add_user').each(function(){
63
                var borrowernumber = $(this).data('borrowernumber');
64
                var firstname = $(this).data('firstname');
65
                var surname = $(this).data('surname');
66
                add_user( borrowernumber, firstname + ' ' + surname );
67
                counter++;
68
            });
69
            $('#info').html(_("%s Patrons added.").format(counter));
70
        });
71
    });
72
</script>
73
31
    [% PROCESS patron_search_js table_id => 'memberresultst', categories => categories, libraries => libraries, extended_attribute_types => attribute_type_codes, columns => columns, filter => filter, actions => [selection_type], preview_on_name_click => 1, callback => callback %]
74
    [% PROCESS patron_search_js table_id => 'memberresultst', categories => categories, libraries => libraries, extended_attribute_types => attribute_type_codes, columns => columns, filter => filter, actions => [selection_type], preview_on_name_click => 1, callback => callback %]
32
[% END %]
75
[% END %]
33
76
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/edit-batch.tt (-1 / +1 lines)
Lines 190-196 Link Here
190
        function Add() {
190
        function Add() {
191
            var bor_nums = document.getElementById("bor_num_list");
191
            var bor_nums = document.getElementById("bor_num_list");
192
            if (bor_nums.value == '') {
192
            if (bor_nums.value == '') {
193
                window.open("/cgi-bin/koha/members/search.pl?columns=cardnumber,name,category,branch,dateexpiry,borrowernotes,action&selection_type=add",
193
                window.open("/cgi-bin/koha/members/search.pl?columns=checkbox,cardnumber,name,category,branch,dateexpiry,borrowernotes,action&selection_type=add&filter_sort1=1&filter_sort2=1",
194
               'PatronPopup',
194
               'PatronPopup',
195
               'width=1024,height=768,location=yes,toolbar=no,'
195
               'width=1024,height=768,location=yes,toolbar=no,'
196
               + 'scrollbars=yes,resize=yes');
196
               + 'scrollbars=yes,resize=yes');
(-)a/members/search.pl (-1 / +19 lines)
Lines 19-26 use Modern::Perl; Link Here
19
19
20
use CGI qw ( -utf8 );
20
use CGI qw ( -utf8 );
21
use C4::Context;
21
use C4::Context;
22
use List::MoreUtils qw(uniq);
22
use C4::Auth qw( get_template_and_user );
23
use C4::Auth qw( get_template_and_user );
23
use C4::Output qw( output_html_with_http_headers );
24
use C4::Output qw( output_html_with_http_headers );
25
use C4::Koha qw( GetAuthorisedValues );
24
use Koha::Patron::Attribute::Types;
26
use Koha::Patron::Attribute::Types;
25
27
26
my $input = CGI->new;
28
my $input = CGI->new;
Lines 39-44 my @columns = split ',', $input->param('columns'); Link Here
39
my $callback = $input->param('callback');
41
my $callback = $input->param('callback');
40
my $selection_type = $input->param('selection_type') || 'select';
42
my $selection_type = $input->param('selection_type') || 'select';
41
my $filter = $input->param('filter');
43
my $filter = $input->param('filter');
44
my @form_filters = ('branch','category');
45
46
my $sort_filter = { ( C4::Context->only_my_library ? (branchcode => C4::Context->userenv->{branch}) : () ) };
47
my ( @sort1, @sort2 );
48
if ( $input->param('filter_sort1') ) {
49
    @sort1 = map { $_->{lib} } @{ GetAuthorisedValues("Bsort1") };
50
    unless ( @sort1 ) { @sort1 = sort {$a cmp $b} uniq( Koha::Patrons->search($sort_filter)->get_column('sort1') ); }
51
    push @form_filters, 'sort1';
52
}
53
if ( $input->param('filter_sort2') ) {
54
    @sort2 = map { $_->{lib} } @{ GetAuthorisedValues("Bsort2") };
55
    unless ( @sort2 ) { @sort2 = sort {$a cmp $b} uniq( Koha::Patrons->search($sort_filter)->get_column('sort2') ); }
56
    push @form_filters, 'sort2';
57
}
42
58
43
$template->param(
59
$template->param(
44
    view           => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
60
    view           => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
Lines 49-53 $template->param( Link Here
49
    attribute_type_codes => ( C4::Context->preference('ExtendedPatronAttributes')
65
    attribute_type_codes => ( C4::Context->preference('ExtendedPatronAttributes')
50
        ? [ Koha::Patron::Attribute::Types->search( { staff_searchable => 1 } )->get_column('code') ]
66
        ? [ Koha::Patron::Attribute::Types->search( { staff_searchable => 1 } )->get_column('code') ]
51
        : [] ),
67
        : [] ),
68
    form_filters    => \@form_filters,
69
    sort1           => \@sort1,
70
    sort2           => \@sort2,
52
);
71
);
53
output_html_with_http_headers( $input, $cookie, $template->output );
72
output_html_with_http_headers( $input, $cookie, $template->output );
54
- 

Return to bug 28726