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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc (-2 / +50 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 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 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 308-318 Link Here
308
                    return { "like": start_with + "%" }
328
                    return { "like": start_with + "%" }
309
                },
329
                },
310
                "-and": function(){
330
                "-and": function(){
331
                    let filters = [];
332
                    let f_sort1 = $("#sort1_filter").val();
333
                    if ( f_sort1 ) {
334
                        filters.push({
335
                            "me.sort1": f_sort1
336
                        });
337
                    }
338
                    let f_sort2 = $("#sort2_filter").val();
339
                    if ( f_sort2 ) {
340
                        filters.push({
341
                            "me.sort2": f_sort2
342
                        });
343
                    }
344
311
                    let pattern = $("#search_patron_filter").val();
345
                    let pattern = $("#search_patron_filter").val();
312
                    if (!pattern) return "";
346
                    if (!pattern) {
347
                        if ( filters.length == 0 ) {
348
                            return "";
349
                        }
350
                        else {
351
                            return filters;
352
                        }
353
                    }
313
                    let patterns = pattern.split(' ').filter(function(s){ return s.length });
354
                    let patterns = pattern.split(' ').filter(function(s){ return s.length });
314
355
315
                    let filters = [];
316
                    let search_type = $("#searchtype_filter").val() || "contain";
356
                    let search_type = $("#searchtype_filter").val() || "contain";
317
                    let search_fields = $("#searchfieldstype_filter").val();
357
                    let search_fields = $("#searchfieldstype_filter").val();
318
                    if ( !search_fields ) {
358
                    if ( !search_fields ) {
Lines 728-733 Link Here
728
            if ( $("#branchcode_filter").val() ) {
768
            if ( $("#branchcode_filter").val() ) {
729
                searched += _(" in library ") + $("#branchcode_filter").find("option:selected").text();
769
                searched += _(" in library ") + $("#branchcode_filter").find("option:selected").text();
730
            }
770
            }
771
            if ( $("#sort1_filter").val() ) {
772
                searched += _(" with sort1 ") + $("#sort1_filter").find("option:selected").text();
773
            }
774
            if ( $("#sort2_filter").val() ) {
775
                searched += _(" with sort2 ") + $("#sort2_filter").find("option:selected").text();
776
            }
731
            $("#searchpattern").text(searched);
777
            $("#searchpattern").text(searched);
732
            $("#searchpattern").parent().show();
778
            $("#searchpattern").parent().show();
733
        }
779
        }
Lines 785-790 Link Here
785
            $("#searchtype_filter option[value='contain']").prop("selected", true);
831
            $("#searchtype_filter option[value='contain']").prop("selected", true);
786
            $("#categorycode_filter option:first").prop("selected", true);
832
            $("#categorycode_filter option:first").prop("selected", true);
787
            $("#branchcode_filter option:first").prop("selected", true);
833
            $("#branchcode_filter option:first").prop("selected", true);
834
            $("#sort1_filter option:first").prop("selected", true);
835
            $("#sort2_filter option:first").prop("selected", true);
788
            $("#firstletter_filter").val('');
836
            $("#firstletter_filter").val('');
789
            $("#search_patron_filter").val('');
837
            $("#search_patron_filter").val('');
790
            /* remove any search string added by firstletter search */
838
            /* 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 / +16 lines)
Lines 19-24 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 );
24
use Koha::Patron::Attribute::Types;
25
use Koha::Patron::Attribute::Types;
Lines 39-44 my @columns = split ',', $input->param('columns'); Link Here
39
my $callback = $input->param('callback');
40
my $callback = $input->param('callback');
40
my $selection_type = $input->param('selection_type') || 'select';
41
my $selection_type = $input->param('selection_type') || 'select';
41
my $filter = $input->param('filter');
42
my $filter = $input->param('filter');
43
my @form_filters = ('branch','category');
44
45
my $sort_filter = { ( C4::Context->only_my_library ? (branchcode => C4::Context->userenv->{branch}) : () ) };
46
my ( @sort1, @sort2 );
47
if ( $input->param('filter_sort1') ) {
48
    @sort1 = sort {$a cmp $b} uniq( Koha::Patrons->search($sort_filter)->get_column('sort1') );
49
    push @form_filters, 'sort1';
50
}
51
if ( $input->param('filter_sort2') ) {
52
    @sort2 = sort {$a cmp $b} uniq( Koha::Patrons->search($sort_filter)->get_column('sort2') );
53
    push @form_filters, 'sort2';
54
}
42
55
43
$template->param(
56
$template->param(
44
    view           => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
57
    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')
62
    attribute_type_codes => ( C4::Context->preference('ExtendedPatronAttributes')
50
        ? [ Koha::Patron::Attribute::Types->search( { staff_searchable => 1 } )->get_column('code') ]
63
        ? [ Koha::Patron::Attribute::Types->search( { staff_searchable => 1 } )->get_column('code') ]
51
        : [] ),
64
        : [] ),
65
    form_filters    => \@form_filters,
66
    sort1           => \@sort1,
67
    sort2           => \@sort2,
52
);
68
);
53
output_html_with_http_headers( $input, $cookie, $template->output );
69
output_html_with_http_headers( $input, $cookie, $template->output );
54
- 

Return to bug 28726