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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc (-3 / +51 lines)
Lines 55-66 Link Here
55
                                [% END %]
55
                                [% END %]
56
                            </select>
56
                            </select>
57
                        </li>
57
                        </li>
58
                    [% CASE 'sort1' %]
59
                        <li>
60
                            <label for="sort1_filter">Sort1:</label>
61
                            <select id="sort1_filter">
62
                                <option value="">Any</option>
63
                                [% FOREACH s1 IN sort1 %]
64
                                    <option value="[% s1 | html %]">[% s1 | html %]</option>
65
                                [% END %]
66
                            </select>
67
                        </li>
68
                    [% CASE 'sort2' %]
69
                        <li>
70
                            <label for="sort2_filter">Sort2:</label>
71
                            <select id="sort2_filter">
72
                                <option value="">Any</option>
73
                                [% FOREACH s2 IN sort2 %]
74
                                    <option value="[% s2 | html %]">[% s2 | html %]</option>
75
                                [% END %]
76
                            </select>
77
                        </li>
58
                    [% CASE 'search_field' %]
78
                    [% CASE 'search_field' %]
59
                        <li>
79
                        <li>
60
                            <label for="searchfieldstype_filter">Search field:</label>
80
                            <label for="searchfieldstype_filter">Search field:</label>
61
                            <select name="searchfieldstype" id="searchfieldstype_filter">
81
                            <select name="searchfieldstype" id="searchfieldstype_filter">
62
                                [% pref_fields = Koha.Preference('DefaultPatronSearchFields').split(',') %]
82
                                [% pref_fields = Koha.Preference('DefaultPatronSearchFields').split(',') %]
63
                                [% default_fields = [ 'firstname,surname,othernames,cardnumber,userid', 'surname', 'cardnumber', 'email', 'borrowernumber', 'userid', 'phone', 'address', 'dateofbirth', 'sort1', 'sort2' ] %]
83
                                [% default_fields = [ 'firstname,surname,othernames,cardnumber,userid', 'surname', 'cardnumber', 'email', 'borrowernumber', 'userid', 'phone', 'address', 'dateofbirth' ] %]
64
                                [% search_options = default_fields.merge(pref_fields).unique %]
84
                                [% search_options = default_fields.merge(pref_fields).unique %]
65
                                [% FOREACH s_o IN search_options %]
85
                                [% FOREACH s_o IN search_options %]
66
                                    [% display_name = PROCESS patron_fields name=s_o %]
86
                                    [% display_name = PROCESS patron_fields name=s_o %]
Lines 295-304 Link Here
295
                    return { "like": start_with + "%" }
315
                    return { "like": start_with + "%" }
296
                },
316
                },
297
                "-and": function(){
317
                "-and": function(){
318
                    let filters = [];
319
                    let f_sort1 = $("#sort1_filter").val();
320
                    if ( f_sort1 ) {
321
                        filters.push({
322
                            "me.sort1": f_sort1
323
                        });
324
                    }
325
                    let f_sort2 = $("#sort2_filter").val();
326
                    if ( f_sort2 ) {
327
                        filters.push({
328
                            "me.sort2": f_sort2
329
                        });
330
                    }
331
298
                    let filter = $("#search_patron_filter").val();
332
                    let filter = $("#search_patron_filter").val();
299
                    if (!filter) return "";
333
                    if (!filter) {
334
                        if ( filters.length == 0 ) {
335
                            return "";
336
                        }
337
                        else {
338
                            return filters;
339
                        }
340
                    }
300
341
301
                    let filters = [];
302
                    let search_type = $("#searchtype_filter").val() || "contain";
342
                    let search_type = $("#searchtype_filter").val() || "contain";
303
                    let search_fields = $("#searchfieldstype_filter").val();
343
                    let search_fields = $("#searchfieldstype_filter").val();
304
                    if ( !search_fields ) {
344
                    if ( !search_fields ) {
Lines 710-715 Link Here
710
            if ( $("#branchcode_filter").val() ) {
750
            if ( $("#branchcode_filter").val() ) {
711
                searched += _(" in library ") + $("#branchcode_filter").find("option:selected").text();
751
                searched += _(" in library ") + $("#branchcode_filter").find("option:selected").text();
712
            }
752
            }
753
            if ( $("#sort1_filter").val() ) {
754
                searched += _(" with sort1 ") + $("#sort1_filter").find("option:selected").text();
755
            }
756
            if ( $("#sort2_filter").val() ) {
757
                searched += _(" with sort2 ") + $("#sort2_filter").find("option:selected").text();
758
            }
713
            $("#searchpattern").text(searched);
759
            $("#searchpattern").text(searched);
714
            $("#searchpattern").parent().show();
760
            $("#searchpattern").parent().show();
715
        }
761
        }
Lines 745-750 Link Here
745
            $("#searchtype_filter option[value='contain']").prop("selected", true);
791
            $("#searchtype_filter option[value='contain']").prop("selected", true);
746
            $("#categorycode_filter option:first").prop("selected", true);
792
            $("#categorycode_filter option:first").prop("selected", true);
747
            $("#branchcode_filter option:first").prop("selected", true);
793
            $("#branchcode_filter option:first").prop("selected", true);
794
            $("#sort1_filter option:first").prop("selected", true);
795
            $("#sort2_filter option:first").prop("selected", true);
748
            $("#firstletter_filter").val('');
796
            $("#firstletter_filter").val('');
749
            $("#search_patron_filter").val('');
797
            $("#search_patron_filter").val('');
750
            /* remove any search string added by firstletter search */
798
            /* 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" class="yui-t7">
17
<div id="patron_search" class="yui-t7">
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 185-191 Link Here
185
        function Add() {
185
        function Add() {
186
            var bor_nums = document.getElementById("bor_num_list");
186
            var bor_nums = document.getElementById("bor_num_list");
187
            if (bor_nums.value == '') {
187
            if (bor_nums.value == '') {
188
                window.open("/cgi-bin/koha/members/search.pl?columns=cardnumber,name,category,branch,dateexpiry,borrowernotes,action&selection_type=add",
188
                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",
189
               'PatronPopup',
189
               'PatronPopup',
190
               'width=1024,height=768,location=yes,toolbar=no,'
190
               'width=1024,height=768,location=yes,toolbar=no,'
191
               + 'scrollbars=yes,resize=yes');
191
               + '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