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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search-header.inc (-1 / +1 lines)
Lines 24-30 Link Here
24
        <p><label for="searchfieldstype">Search fields:</label>
24
        <p><label for="searchfieldstype">Search fields:</label>
25
            <select name="searchfieldstype" id="searchfieldstype">
25
            <select name="searchfieldstype" id="searchfieldstype">
26
              [% pref_fields = Koha.Preference('DefaultPatronSearchFields').split(',') %]
26
              [% pref_fields = Koha.Preference('DefaultPatronSearchFields').split(',') %]
27
              [% default_fields = [ 'standard', 'surname', 'cardnumber', 'email', 'borrowernumber', 'userid', 'phone', 'address', 'dateofbirth', 'sort1', 'sort2' ] %]
27
              [% default_fields = [ 'surname,firstname,othernames,cardnumber,userid', 'surname', 'cardnumber', 'email', 'borrowernumber', 'userid', 'phone', 'address', 'dateofbirth', 'sort1', 'sort2' ] %]
28
              [% search_options = default_fields.merge(pref_fields).unique %]
28
              [% search_options = default_fields.merge(pref_fields).unique %]
29
              [% FOREACH s_o IN search_options %]
29
              [% FOREACH s_o IN search_options %]
30
                  [% display_name = PROCESS patron_fields name=s_o %]
30
                  [% display_name = PROCESS patron_fields name=s_o %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc (-63 / +248 lines)
Lines 1-6 Link Here
1
[% USE Koha %]
1
[% USE Koha %]
2
[% USE I18N %]
2
[% USE Branches %]
3
[% USE Branches %]
3
[% USE raw %]
4
[% USE raw %]
5
[% USE Asset %]
4
[% USE To %]
6
[% USE To %]
5
7
6
[% BLOCK patron_search_filters_simple  %]
8
[% BLOCK patron_search_filters_simple  %]
Lines 18-29 Link Here
18
            <ol>
20
            <ol>
19
                <li>
21
                <li>
20
                    <label for="search_patron_filter">Search:</label>
22
                    <label for="search_patron_filter">Search:</label>
21
                    <div class="hint">Enter patron card number or partial name:</div>
22
                    <input type="text" id="search_patron_filter" value="[% search_filter | html %]" class="focus" />
23
                    <input type="text" id="search_patron_filter" value="[% search_filter | html %]" class="focus" />
23
                </li>
24
                </li>
24
25
25
                [% FOR column IN columns %]
26
                [% FOR f IN filters %]
26
                    [% SWITCH column %]
27
                    [% SWITCH f %]
27
                    [% CASE 'branch' %]
28
                    [% CASE 'branch' %]
28
                        <li>
29
                        <li>
29
                            <label for="branchcode_filter">Library:</label>
30
                            <label for="branchcode_filter">Library:</label>
Lines 47-57 Link Here
47
                                [% END %]
48
                                [% END %]
48
                            </select>
49
                            </select>
49
                        </li>
50
                        </li>
51
                    [% CASE 'search_field' %]
52
                        <li>
53
                            <label for="searchfieldstype_filter">Search field:</label>
54
                            <select name="searchfieldstype" id="searchfieldstype_filter">
55
                                [% pref_fields = Koha.Preference('DefaultPatronSearchFields').split(',') %]
56
                                [% default_fields = [ 'surname,firstname,othernames,cardnumber,userid', 'surname', 'cardnumber', 'email', 'borrowernumber', 'userid', 'phone', 'address', 'dateofbirth', 'sort1', 'sort2' ] %]
57
                                [% search_options = default_fields.merge(pref_fields).unique %]
58
                                [% FOREACH s_o IN search_options %]
59
                                    [% display_name = PROCESS patron_fields name=s_o %]
60
                                    [% NEXT IF !display_name %]
61
                                    [% IF searchfieldstype == s_o %]
62
                                        <option selected="selected" value=[% s_o | html %]>[% display_name | $raw %]</option>
63
                                    [% ELSE %]
64
                                        <option value=[% s_o | html %]>[% display_name | $raw %]</option>
65
                                    [% END %]
66
                                [% END %]
67
                            </select>
68
                        </li>
69
                    [% CASE 'search_type' %]
70
                        <li>
71
                            <label for="searchtype_filter">Search type:</label>
72
                            <select name="searchtype" id="searchtype_filter">
73
                              [% IF searchtype == "start_with" %]
74
                                <option value='start_with' selected="selected">Starts with</option>
75
                                <option value="contain">Contains</option>
76
                              [% ELSE %]
77
                                <option value='start_with'>Starts with</option>
78
                                <option value="contain" selected="selected">Contains</option>
79
                              [% END %]
80
                            </select>
81
                        </li>
50
                    [% END %]
82
                    [% END %]
51
                [% END %]
83
                [% END %]
52
            </ol>
84
            </ol>
53
            <fieldset class="action">
85
            <fieldset class="action">
54
                <input type="submit" value="Search" />
86
                <input type="submit" value="Search" />
87
                <input type="button" value="Clear" id="clear_search" />
55
            </fieldset>
88
            </fieldset>
56
        </fieldset>
89
        </fieldset>
57
    </form>
90
    </form>
Lines 78-89 Link Here
78
        [% END %]
111
        [% END %]
79
    </div>
112
    </div>
80
113
114
115
    <h3 style="display: none;">Patrons found for: <span id="searchpattern"></span></h3>
116
81
    <div id="[% table_id | html %]_search_results" style="display:none;">
117
    <div id="[% table_id | html %]_search_results" style="display:none;">
82
118
83
        <div id="info" class="dialog message" style="display: none;"></div>
119
        <div id="info" class="dialog message" style="display: none;"></div>
84
        <div id="error" class="dialog alert" style="display: none;"></div>
120
        <div id="error" class="dialog alert" style="display: none;"></div>
85
121
86
87
        <input type="hidden" id="firstletter_filter" value="" />
122
        <input type="hidden" id="firstletter_filter" value="" />
88
        [% IF open_on_row_click %]
123
        [% IF open_on_row_click %]
89
        <table id="[% table_id | html %]" class="selections-table">
124
        <table id="[% table_id | html %]" class="selections-table">
Lines 94-99 Link Here
94
                <tr>
129
                <tr>
95
                    [% FOR column IN columns %]
130
                    [% FOR column IN columns %]
96
                        [% SWITCH column %]
131
                        [% SWITCH column %]
132
                            [% CASE 'checkbox' %]<th class="noExport"></th>
97
                            [% CASE 'cardnumber' %]<th>Card</th>
133
                            [% CASE 'cardnumber' %]<th>Card</th>
98
                            [% CASE 'dateofbirth' %]<th>Date of birth</th>
134
                            [% CASE 'dateofbirth' %]<th>Date of birth</th>
99
                            [% CASE 'name' %]<th>Name</th>
135
                            [% CASE 'name' %]<th>Name</th>
Lines 166-182 Link Here
166
    [% INCLUDE 'js-patron-get-age.inc' %]
202
    [% INCLUDE 'js-patron-get-age.inc' %]
167
    [% INCLUDE 'js-patron-format.inc' %]
203
    [% INCLUDE 'js-patron-format.inc' %]
168
    [% INCLUDE 'js-patron-format-address.inc' %]
204
    [% INCLUDE 'js-patron-format-address.inc' %]
205
    [% IF sticky_header %]
206
        [% Asset.js("lib/hc-sticky.js") | $raw %]
207
    [% END %]
169
208
170
    <script>
209
    <script>
171
        var first_draw = 0;
210
        var first_draw = 0;
172
        let patrons_table;
211
        let patrons_table;
212
        var Sticky;
213
        var singleBranchMode = '[% singleBranchMode | html %]';
214
        let logged_in_library_id = "[% Branches.GetLoggedInBranchcode | html %]";
173
215
174
        $(document).ready(function(){
216
        /* popstate event triggered by forward and back button. Need to refresh search */
217
        window.addEventListener('popstate', (event) => {
218
            getSearchByLocation( false );
219
        });
175
220
221
        $(document).ready(function(){
176
222
177
            $("#info").hide();
223
            $("#info").hide();
178
            $("#error").hide();
224
            $("#error").hide();
179
225
226
            // Build the aLengthMenu
227
            var aLengthMenu = [
228
                [% Koha.Preference('PatronsPerPage') | html %], 10, 20, 50, 100, -1
229
            ];
230
            jQuery.unique(aLengthMenu);
231
            aLengthMenu.sort(function( a, b ){
232
                // Put "All" at the end
233
                if ( a == -1 ) {
234
                    return 1;
235
                } else if ( b == -1 ) {
236
                    return -1;
237
                }
238
                return parseInt(a) < parseInt(b) ? -1 : 1;}
239
            );
240
            var aLengthMenuLabel = [];
241
            $(aLengthMenu).each(function(){
242
                if ( this == -1 ) {
243
                    // Label for -1 is "All"
244
                    aLengthMenuLabel.push(_("All"));
245
                } else {
246
                    aLengthMenuLabel.push(this);
247
                }
248
            });
249
180
            let additional_filters = {
250
            let additional_filters = {
181
                surname: function(){
251
                surname: function(){
182
                    let start_with = $("#firstletter_filter").val()
252
                    let start_with = $("#firstletter_filter").val()
Lines 186-203 Link Here
186
                "-and": function(){
256
                "-and": function(){
187
                    let filter = $("#search_patron_filter").val();
257
                    let filter = $("#search_patron_filter").val();
188
                    if (!filter) return "";
258
                    if (!filter) return "";
189
                    [% SET search_fields = Koha.Preference('DefaultPatronSearchFields') || 'surname,firstname,othernames,cardnumber,userid' %]
259
190
                    return [
260
                    let filters = [];
191
                        [% FOR search_field IN search_fields.split(',') %]
261
                    let search_type = $("#searchtype_filter").val() || "contain";
192
                        {"me.[% search_field | html %]":{"like":"%"+filter+"%"}},
262
                    let search_fields = $("#searchfieldstype_filter").val();
193
                        [% END %]
263
                    if ( !search_fields ) {
194
                        [% IF Koha.Preference('ExtendedPatronAttributes') && extended_attribute_types %]
264
                        search_fields = "[% Koha.Preference('DefaultPatronSearchFields') || 'surname,firstname,othernames,cardnumber,userid' | html %]";
195
                        {
265
                    }
196
                            "extended_attributes.value": { "like": "%" + filter + "%" },
266
                    search_fields.split(',').forEach(function(e,i){
267
                        filters.push({["me."+e]:{"like":"%"+filter+(search_type == "contain" ? "%" : "" )}});
268
                    });
269
                    [% IF Koha.Preference('ExtendedPatronAttributes') && extended_attribute_types %]
270
                        filters.push({
271
                            "extended_attributes.value": { "like": "%" + filter + (search_type == "contain" ? "%" : "" )},
197
                            "extended_attributes.code": extended_attribute_types
272
                            "extended_attributes.code": extended_attribute_types
198
                        }
273
                        });
199
                        [% END %]
274
                    [% END %]
200
                    ];
275
                    return filters;
201
                }
276
                }
202
            };
277
            };
203
            [% UNLESS default_sort_column %]
278
            [% UNLESS default_sort_column %]
Lines 223-229 Link Here
223
                        [% IF redirect_if_one_result %]
298
                        [% IF redirect_if_one_result %]
224
                            // redirect if there is only 1 result.
299
                            // redirect if there is only 1 result.
225
                            if ( first_draw && json.recordsFiltered == 1 ) {
300
                            if ( first_draw && json.recordsFiltered == 1 ) {
226
                                document.location.href = '[% redirect_url | url %]&borrowernumber=' + json.data[0].patron_id;
301
                                let url = '[% redirect_url | url %]'.indexOf("?") != -1
302
                                    ? '[% redirect_url | url %]&borrowernumber=' + json.data[0].patron_id
303
                                    : '[% redirect_url | url %]?borrowernumber=' + json.data[0].patron_id;
304
                                document.location.href = url;
227
                                return false;
305
                                return false;
228
                            }
306
                            }
229
                            first_draw = 0;
307
                            first_draw = 0;
Lines 231-236 Link Here
231
                        return json.data;
309
                        return json.data;
232
                    }
310
                    }
233
                },
311
                },
312
                [% IF open_on_row_click OR preview_on_name_click %]
234
                "drawCallback": function( settings ) {
313
                "drawCallback": function( settings ) {
235
                    var api = this.api();
314
                    var api = this.api();
236
                    var data = api.data();
315
                    var data = api.data();
Lines 244-255 Link Here
244
                        }).addClass('clickable');
323
                        }).addClass('clickable');
245
                        $(tr).find("a.patron_name").attr('href', url);
324
                        $(tr).find("a.patron_name").attr('href', url);
246
                    });
325
                    });
247
                    [% ELSE %]
326
                    [% END %]
327
                    [% IF preview_on_name_click %]
248
                    $.each($(this).find("tbody tr"), function(index, tr) {
328
                    $.each($(this).find("tbody tr"), function(index, tr) {
249
                        $(tr).find("a.patron_name").addClass("patron_preview");
329
                        $(tr).find("a.patron_name").addClass("patron_preview");
250
                    });
330
                    });
251
                    [% END %]
331
                    [% END %]
252
                },
332
                },
333
                [% END %]
253
                "iDeferLoading": 0,
334
                "iDeferLoading": 0,
254
                "columns": [
335
                "columns": [
255
                    [% FOR column IN columns %]
336
                    [% FOR column IN columns %]
Lines 259-278 Link Here
259
                        [% SWITCH column %]
340
                        [% SWITCH column %]
260
                            [% CASE 'checkbox' %]
341
                            [% CASE 'checkbox' %]
261
                            {
342
                            {
262
                                "data": "borrowernumber",
343
                                "data": "patron_id",
263
                                "searchable": true,
344
                                "searchable": false,
264
                                "orderable": true,
345
                                "orderable": false,
265
                                "render": function( data, type, row, meta ) {
346
                                "render": function( data, type, row, meta ) {
266
                                    return "<input type=\"checkbox\" name="data ? escape_str($date(data) + " (" + _("%s years").format($get_age(data)) + ")") : "";
347
                                    return "<label for='check" + data + "' class='content_hidden'>" + _("Select patron") + "</label><input type='checkbox' id='check" + data + "' class='selection' name='borrowernumber' value='" + data + "' />";
267
268
                                    return "<label for='check" + data + "' class='content_hidden'>" + _("Select patron") + "</label><input type='checkbox' id='check" + data + "' class='selection' name='borrowernumber' value='" + data + "' />",
269
                                }
348
                                }
270
                            }
349
                            }
271
                            [% CASE 'cardnumber' %]
350
                            [% CASE 'cardnumber' %]
272
                            {
351
                            {
273
                                "data": "cardnumber",
352
                                "data": "cardnumber",
274
                                "searchable": true,
353
                                "searchable": true,
275
                                "orderable": true
354
                                "orderable": true,
355
                                "render": function( data, type, row, meta ) {
356
                                    let patron_id = encodeURIComponent(row.patron_id);
357
                                    [% IF !open_on_row_click AND CAN_user_circulate_circulate_remaining_permissions %]
358
                                        return "<a href=\"/cgi-bin/koha/circ/circulation.pl?borrowernumber=" + patron_id + "\" title=\"[% I18N.t("Check out") | html %]\" class=\"patron_name\" data-borrowernumber=\"" + patron_id + "\" style=\"white-space:nowrap\">" + escape_str(data) + "</a>";
359
                                    [% ELSE %]
360
                                        return escape_str(data);
361
                                    [% END %]
362
                                }
363
276
                            }
364
                            }
277
                            [% CASE 'dateofbirth' %]
365
                            [% CASE 'dateofbirth' %]
278
                            {
366
                            {
Lines 340-346 Link Here
340
                                "orderable": true,
428
                                "orderable": true,
341
                                "render": function( data, type, row, meta ) {
429
                                "render": function( data, type, row, meta ) {
342
                                    let patron_id = encodeURIComponent(row.patron_id);
430
                                    let patron_id = encodeURIComponent(row.patron_id);
431
                                    [% IF ! open_on_row_click %]
343
                                    return "<a href=\"/cgi-bin/koha/members/moremember.pl?borrowernumber=" + patron_id + "\" class=\"patron_name\" data-borrowernumber=\"" + patron_id + "\" style=\"white-space:nowrap\">" + $patron_to_html(row, { invert_name: 1 }) + "</a>";
432
                                    return "<a href=\"/cgi-bin/koha/members/moremember.pl?borrowernumber=" + patron_id + "\" class=\"patron_name\" data-borrowernumber=\"" + patron_id + "\" style=\"white-space:nowrap\">" + $patron_to_html(row, { invert_name: 1 }) + "</a>";
433
                                    [% ELSE %]
434
                                    return $patron_to_html(row, { invert_name: 1 });
435
                                    [% END %]
344
                                }
436
                                }
345
                            }
437
                            }
346
                            [% CASE 'branch' %]
438
                            [% CASE 'branch' %]
Lines 349-355 Link Here
349
                                "searchable": true,
441
                                "searchable": true,
350
                                "orderable": true,
442
                                "orderable": true,
351
                                "render": function( data, type, row, meta ) {
443
                                "render": function( data, type, row, meta ) {
352
                                    return escape_str(libraries_map[data].branchname);
444
                                    let library_name = libraries_map[data].branchname
445
                                    if( !singleBranchMode && data == logged_in_library_id ) {
446
                                        return "<span class=\"currentlibrary\">" + escape_str(library_name) + "</span>";
447
                                    } else {
448
                                        return escape_str(library_name);
449
                                    }
353
                                }
450
                                }
354
                            }
451
                            }
355
                            [% CASE 'category' %]
452
                            [% CASE 'category' %]
Lines 426-436 Link Here
426
                                "data": function( row, type, val, meta ) {
523
                                "data": function( row, type, val, meta ) {
427
524
428
                                    let patron_id = encodeURIComponent(row.patron_id);
525
                                    let patron_id = encodeURIComponent(row.patron_id);
429
                                    [% IF selection_type == 'select' %]
526
                                    let action_node = "";
430
                                        return '<a href="#" class="btn btn-default btn-xs select_user" data-borrowernumber="' + patron_id + '">Select</a><input type="hidden" id="borrower_data' + patron_id + '" name="borrower_data'+ patron_id + '" value=\''+JSON.stringify(row)+'\' />';
527
                                    [% FOR action IN actions %]
431
                                    [% ELSE %]
528
                                    [% SWITCH action %]
432
                                        return '<a href="#" class="btn btn-default btn-xs add_user" data-borrowernumber="' + patron_id + '" data-firstname="' + encodeURIComponent(row.firstname) + '" data-surname="' + encodeURIComponent(row.surname) + '">Add</a><input type="hidden" id="borrower_data' + patron_id + '" name="borrower_data'+ patron_id + '" />';
529
                                    [% CASE 'select' %]
530
                                        action_node += '<a href="#" class="btn btn-default btn-xs select_user" data-borrowernumber="' + patron_id + '">Select</a><input type="hidden" id="borrower_data' + patron_id + '" name="borrower_data'+ patron_id + '" value=\''+JSON.stringify(row)+'\' />';
531
                                    [% CASE 'add' %]
532
                                        action_node += '<a href="#" class="btn btn-default btn-xs add_user" data-borrowernumber="' + patron_id + '" data-firstname="' + encodeURIComponent(row.firstname) + '" data-surname="' + encodeURIComponent(row.surname) + '">Add</a><input type="hidden" id="borrower_data' + patron_id + '" name="borrower_data'+ patron_id + '" />';
533
                                    [% CASE 'edit' %]
534
                                        action_node += '<a href="/cgi-bin/koha/members/memberentry.pl?op=modify&amp;destination=circ&amp;borrowernumber=' + patron_id + '" class="btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</a>';
535
                                    [% CASE 'checkout' %]
536
                                        [% IF CAN_user_circulate_circulate_remaining_permissions %]
537
                                            action_node += '<a class="btn btn-default btn-xs" href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=' + patron_id + '"><i class="fa fa-barcode"></i> ' + _("Check out") + '</a>';
538
                                        [% END %]
539
                                    [% END %]
433
                                    [% END %]
540
                                    [% END %]
541
                                    return action_node;
434
                                },
542
                                },
435
                                "searchable": false,
543
                                "searchable": false,
436
                                "orderable": false
544
                                "orderable": false
Lines 442-455 Link Here
442
                'embed': [% To.json(embed) | $raw %],
550
                'embed': [% To.json(embed) | $raw %],
443
                "order": [[ [% order_column_index | html %], "asc" ]],
551
                "order": [[ [% order_column_index | html %], "asc" ]],
444
                'bAutoWidth': false,
552
                'bAutoWidth': false,
553
                'lengthMenu': [aLengthMenu, aLengthMenuLabel],
445
                'sPaginationType': 'full_numbers',
554
                'sPaginationType': 'full_numbers',
446
                "iDisplayLength": [% Koha.Preference('PatronsPerPage') | html %],
555
                "pageLength": [% Koha.Preference('PatronsPerPage') | html %],
556
                [% IF sticky_header %]
557
                "initComplete": function(settings, json) {
558
                    Sticky = $("#[% sticky_header | html %]");
559
                    Sticky.hcSticky({
560
                        stickTo: "#[% sticky_to | html %]",
561
                        stickyClass: "floating"
562
                    });
563
                },
564
                [% END %]
447
            }, typeof table_settings !== 'undefined' ? table_settings : null, 1, additional_filters);
565
            }, typeof table_settings !== 'undefined' ? table_settings : null, 1, additional_filters);
448
566
449
            $("#patron_search_form").on('submit', filter);
567
            $("#patron_search_form").on('submit', filter);
450
            $(".filterByLetter").on("click",function(e){
568
            $(".filterByLetter").on("click",function(e){
451
                e.preventDefault();
569
                e.preventDefault();
452
                filterByFirstLetterSurname($(this).text());
570
                filterByFirstLetterSurname($(this).text(), true);
453
            });
571
            });
454
            $("body").on("click",".add_user",function(e){
572
            $("body").on("click",".add_user",function(e){
455
                e.preventDefault();
573
                e.preventDefault();
Lines 478-485 Link Here
478
                $("#patronPreview .modal-body").html("<img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> Loading");
596
                $("#patronPreview .modal-body").html("<img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> Loading");
479
            });
597
            });
480
598
599
            $("#clear_search").on("click",function(e){
600
                e.preventDefault();
601
                clearFilters();
602
                $("#searchpattern").parent().hide();
603
            });
604
605
            if ( $("#search_patron_filter").val().length > 0 ) {
606
                $("#patron_search_form").submit();
607
            }
608
609
            /* Initial page load does not trigger the popstate event, so we explicitly call this */
610
            getSearchByLocation( false );
611
481
        });
612
        });
482
613
614
        function getSearchByLocation( setstate ){
615
            /* Check to see if the URL contains a search parameter */
616
            if( location.search != ""){
617
                var params = new URLSearchParams( location.search );
618
                var firstletter = params.get("firstletter");
619
                /* Check to see if search is a first letter param */
620
                if( firstletter ){
621
                    /* Trigger function to return search results by letter */
622
                    filterByFirstLetterSurname( firstletter, setstate );
623
                }
624
            }
625
        }
626
627
        function update_search_description(){
628
            var searched = $("#searchfieldstype_filter").find("option:selected").text();
629
            if ( $("#search_patron_filter").val() ) {
630
                if ( $("#searchtype_filter").val() == 'start_with' ) {
631
                    searched += _(" starting with ");
632
                } else {
633
                    searched += _(" containing ");
634
                }
635
                searched += "'" + $("#search_patron_filter").val() + "'";
636
            }
637
            if ( $("#firstletter_filter").val() ) {
638
                searched += _(" begins with ") + "'" + $("#firstletter_filter").val() +"'";
639
            }
640
            if ( $("#categorycode_filter").val() ) {
641
                searched += _(" with category ") + "'" + $("#categorycode_filter").find("option:selected").text() + "'";
642
            }
643
            if ( $("#branchcode_filter").val() ) {
644
                searched += _(" in library ") + $("#branchcode_filter").find("option:selected").text();
645
            }
646
            $("#searchpattern").text(searched);
647
            $("#searchpattern").parent().show();
648
        }
649
483
        function filter() {
650
        function filter() {
484
            $("#firstletter_filter").val('');
651
            $("#firstletter_filter").val('');
485
            $("#[% table_id | html %]_search_results").show();
652
            $("#[% table_id | html %]_search_results").show();
Lines 500-549 Link Here
500
            table_dt.search("");
667
            table_dt.search("");
501
            first_draw = 1; // Only redirect if we are coming from here
668
            first_draw = 1; // Only redirect if we are coming from here
502
            table_dt.draw();
669
            table_dt.draw();
670
            update_search_description();
503
            return false;
671
            return false;
504
        }
672
        }
505
673
674
        function clearFilters() {
675
            $("#searchfieldstype_filter option:first").prop("selected", true);
676
            $("#searchtype_filter option[value='contain']").prop("selected", true);
677
            $("#categorycode_filter option:first").prop("selected", true);
678
            $("#branchcode_filter option:first").prop("selected", true);
679
            $("#firstletter_filter").val('');
680
            $("#search_patron_filter").val('');
681
            /* remove any search string added by firstletter search */
682
            history.pushState( {}, null, window.location.href.split("?" )[0]);
683
            $("#[% table_id | html %]_search_results").hide();
684
            update_search_description();
685
        }
686
506
        // User has clicked on a letter
687
        // User has clicked on a letter
507
        function filterByFirstLetterSurname(letter) {
688
        function filterByFirstLetterSurname(letter, setstate ) {
508
            $("#firstletter_filter").val(letter);
689
            $("#firstletter_filter").val(letter);
690
509
            $("#[% table_id | html %]_search_results").show();
691
            $("#[% table_id | html %]_search_results").show();
692
693
            if ( setstate ) {
694
                history.pushState( null, null, "?firstletter=" + letter );
695
            }
696
510
            patrons_table.DataTable().draw();
697
            patrons_table.DataTable().draw();
698
            update_search_description();
511
        }
699
        }
512
700
513
        // modify parent window owner element
701
        // modify parent window owner element
514
        [% IF selection_type == 'add' %]
702
        function add_user(borrowernumber, borrowername) {
515
            function add_user(borrowernumber, borrowername) {
703
            var p = window.opener;
516
                var p = window.opener;
704
            // In one place (serials/routing.tt), the page is reload on every add
517
                // In one place (serials/routing.tt), the page is reload on every add
705
            // We have to wait for the page to be there
518
                // We have to wait for the page to be there
706
            function wait_for_opener () {
519
                function wait_for_opener () {
707
                if ( ! $(opener.document).find('body').size() ) {
520
                    if ( ! $(opener.document).find('body').size() ) {
708
                    setTimeout(wait_for_opener, 500);
521
                        setTimeout(wait_for_opener, 500);
709
                } else {
710
                    [%# Note that add_user could sent data instead of borrowername too %]
711
                    $("#info").hide();
712
                    $("#error").hide();
713
                    if ( p.add_user(borrowernumber, borrowername) < 0 ) {
714
                        $("#error").html(_("Patron '%s' is already in the list.").format(borrowername));
715
                        $("#error").show();
522
                    } else {
716
                    } else {
523
                        [%# Note that add_user could sent data instead of borrowername too %]
717
                        $("#info").html(_("Patron '%s' added.").format(borrowername));
524
                        $("#info").hide();
718
                        $("#info").show();
525
                        $("#error").hide();
526
                        if ( p.add_user(borrowernumber, borrowername) < 0 ) {
527
                            $("#error").html(_("Patron '%s' is already in the list.").format(borrowername));
528
                            $("#error").show();
529
                        } else {
530
                            $("#info").html(_("Patron '%s' added.").format(borrowername));
531
                            $("#info").show();
532
                        }
533
                    }
719
                    }
534
                }
720
                }
535
                wait_for_opener();
536
            }
721
            }
537
        [% ELSIF selection_type == 'select' %]
722
            wait_for_opener();
538
            function select_user(borrowernumber, data) {
723
        }
539
                var p = window.opener;
724
        function select_user(borrowernumber, data) {
540
                [%  IF callback %]
725
            var p = window.opener;
541
                    p.[% callback | html %](borrowernumber, data);
726
            [%  IF callback %]
542
                [%  ELSE %]
727
                p.[% callback | html %](borrowernumber, data);
543
                    p.select_user(borrowernumber, data);
728
            [%  ELSE %]
544
                [%  END %]
729
                p.select_user(borrowernumber, data);
545
                window.close();
730
            [%  END %]
546
            }
731
            window.close();
547
        [% END %]
732
        }
548
    </script>
733
    </script>
549
[% END %]
734
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patronfields.inc (-1 / +1 lines)
Lines 1-6 Link Here
1
[%- BLOCK patron_fields -%]
1
[%- BLOCK patron_fields -%]
2
     [%- SWITCH name -%]
2
     [%- SWITCH name -%]
3
     [%- CASE 'standard' -%]<span>Standard</span>
3
     [%- CASE 'surname,firstname,othernames,cardnumber,userid' -%]<span>Standard</span>
4
     [%- CASE 'borrowernumber' -%]<span>Borrowernumber</span>
4
     [%- CASE 'borrowernumber' -%]<span>Borrowernumber</span>
5
     [%- CASE 'cardnumber' -%]<span>Card number</span>
5
     [%- CASE 'cardnumber' -%]<span>Card number</span>
6
     [%- CASE 'surname' -%]<span>Surname</span>
6
     [%- CASE 'surname' -%]<span>Surname</span>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt (-340 / +36 lines)
Lines 6-11 Link Here
6
[% USE Categories %]
6
[% USE Categories %]
7
[% SET footerjs = 1 %]
7
[% SET footerjs = 1 %]
8
[% PROCESS 'patronfields.inc' %]
8
[% PROCESS 'patronfields.inc' %]
9
[% SET libraries = Branches.all %]
10
[% SET categories = Categories.all.unblessed %]
11
[% SET columns = ['cardnumber', 'name', 'dateofbirth', 'branch', 'category', 'dateexpiry', 'checkouts', 'account_balance', 'borrowernotes', 'action'] %]
12
[% PROCESS 'patron-search.inc' %]
9
[% INCLUDE 'doc-head-open.inc' %]
13
[% INCLUDE 'doc-head-open.inc' %]
10
<title>Patrons[% IF ( searching ) %] &rsaquo; Search results[% END %] &rsaquo; Koha</title>
14
<title>Patrons[% IF ( searching ) %] &rsaquo; Search results[% END %] &rsaquo; Koha</title>
11
[% INCLUDE 'doc-head-close.inc' %]
15
[% INCLUDE 'doc-head-close.inc' %]
Lines 53-65 Link Here
53
          [% INCLUDE 'patron-toolbar.inc' %]
57
          [% INCLUDE 'patron-toolbar.inc' %]
54
          [% INCLUDE 'noadd-warnings.inc' %]
58
          [% INCLUDE 'noadd-warnings.inc' %]
55
59
56
          <div class="browse">
57
            Browse by last name:
58
            [% FOREACH letter IN alphabet.split(' ') %]
59
                <a href="#" class="filterByLetter">[% letter | html %]</a>
60
            [% END %]
61
          </div>
62
63
          [% IF CAN_user_borrowers_edit_borrowers && pending_borrower_modifications %]
60
          [% IF CAN_user_borrowers_edit_borrowers && pending_borrower_modifications %]
64
            <div class="pending-info" id="patron_updates_pending">
61
            <div class="pending-info" id="patron_updates_pending">
65
              <a href="/cgi-bin/koha/members/members-update.pl">Patrons requesting modifications</a>:
62
              <a href="/cgi-bin/koha/members/members-update.pl">Patrons requesting modifications</a>:
Lines 67-76 Link Here
67
            </div>
64
            </div>
68
          [% END %]
65
          [% END %]
69
66
70
          <div id="searchresults">
67
          <div id="patron_search_results">
71
            <h3>Patrons found for: <span id="searchpattern">[% IF searchmember %] for '[% searchmember | html %]'[% END %]</span></h3>
72
            [% IF CAN_user_tools_manage_patron_lists || CAN_user_borrowers_edit_borrowers %]
68
            [% IF CAN_user_tools_manage_patron_lists || CAN_user_borrowers_edit_borrowers %]
73
              <div class="searchheader fh-fixedHeader" id="searchheader">
69
              <div class="searchheader fh-fixedHeader" id="searchheader" style="display:none;">
74
                  <div>
70
                  <div>
75
                      <a href="#" class="btn btn-link" id="select_all"><i class="fa fa-check"></i> Select all</a>
71
                      <a href="#" class="btn btn-link" id="select_all"><i class="fa fa-check"></i> Select all</a>
76
                      |
72
                      |
Lines 103-128 Link Here
103
                </div>
99
                </div>
104
            [% END %]
100
            [% END %]
105
101
106
            <table id="memberresultst">
102
            [% IF CAN_user_borrowers_edit_borrowers || CAN_user_tools_manage_patron_lists %]
107
              <thead>
103
                [% columns.unshift('checkbox') | html %]
108
                <tr>
104
            [% END %]
109
                [% IF CAN_user_borrowers_edit_borrowers || CAN_user_tools_manage_patron_lists %]
105
            [% PROCESS patron_search_table table_id => 'memberresultst' columns => columns %]
110
                  <th class="noExport">&nbsp;</th>
111
                [% END %]
112
                  <th>Card</th>
113
                  <th>Name</th>
114
                  <th>Date of birth</th>
115
                  <th>Category</th>
116
                  <th>Library</th>
117
                  <th>Expires on</th>
118
                  <th>OD/Checkouts</th>
119
                  <th>Fines</th>
120
                  <th>Circ note</th>
121
                  <th class="noExport">&nbsp;</th>
122
                </tr>
123
              </thead>
124
              <tbody></tbody>
125
            </table>
126
          </div>
106
          </div>
127
107
128
            </main>
108
            </main>
Lines 130-205 Link Here
130
110
131
        <div class="col-sm-2 col-sm-pull-10">
111
        <div class="col-sm-2 col-sm-pull-10">
132
            <aside>
112
            <aside>
133
                <form method="get" id="searchform">
113
                [% PROCESS patron_search_filters categories => categories, libraries => libraries, filters => ['search_field', 'search_type', 'category', 'branch'], search_filter => searchmember %]
134
                  <input type="hidden" id="firstletter_filter" value="" />
135
                  <fieldset class="brief">
136
                    <h3>Search patrons</h3>
137
                    <ol>
138
                      <li>
139
                        <label for="searchmember_filter">Search for:</label>
140
                        <input type="text" id="searchmember_filter" value="[% searchmember | html %]"/>
141
                      </li>
142
                      <li>
143
                        <label for="searchfieldstype_filter">Search field:</label>
144
                        <select name="searchfieldstype" id="searchfieldstype_filter">
145
                            [% pref_fields = Koha.Preference('DefaultPatronSearchFields').split(',') %]
146
                            [% default_fields = [ 'standard', 'surname', 'cardnumber', 'email', 'borrowernumber', 'userid', 'phone', 'address', 'dateofbirth', 'sort1', 'sort2' ] %]
147
                            [% search_options = default_fields.merge(pref_fields).unique %]
148
                            [% FOREACH s_o IN search_options %]
149
                                [% display_name = PROCESS patron_fields name=s_o %]
150
                                [% NEXT IF !display_name %]
151
                                [% IF searchfieldstype == s_o %]
152
                                    <option selected="selected" value=[% s_o | html %]>[% display_name | $raw %]</option>
153
                                [% ELSE %]
154
                                    <option value=[% s_o | html %]>[% display_name | $raw %]</option>
155
                                [% END %]
156
                            [% END %]
157
                        </select>
158
                      </li>
159
                      <li>
160
                        <label for="searchtype_filter">Search type:</label>
161
                        <select name="searchtype" id="searchtype_filter">
162
                          [% IF searchtype == "start_with" %]
163
                            <option value='start_with' selected="selected">Starts with</option>
164
                            <option value="contain">Contains</option>
165
                          [% ELSE %]
166
                            <option value='start_with'>Starts with</option>
167
                            <option value="contain" selected="selected">Contains</option>
168
                          [% END %]
169
                        </select>
170
                      </li>
171
                      <li>
172
                        <label for="categorycode_filter">Patron category:</label>
173
                        [% SET categories = Categories.all() %]
174
                        <select id="categorycode_filter">
175
                          <option value="">Any</option>
176
                          [% FOREACH cat IN categories %]
177
                            [% IF cat.categorycode == categorycode_filter %]
178
                    <option selected="selected" value="[% cat.categorycode | html %]">[% cat.description | html %]</option>
179
                            [% ELSE %]
180
                    <option value="[% cat.categorycode | html %]">[% cat.description | html %]</option>
181
182
                            [% END %]
183
                          [% END %]
184
                        </select>
185
                      </li>
186
                      <li>
187
                        <label for="branchcode_filter">Library:</label>
188
                        [% SET branches = Branches.all( selected => branchcode_filter, only_from_group => 1 ) %]
189
                        <select id="branchcode_filter">
190
                          [% IF branches.size != 1 %]
191
                            <option value="">Any</option>
192
                          [% END %]
193
                          [% PROCESS options_for_libraries libraries => branches %]
194
                        </select>
195
                      </li>
196
                    </ol>
197
                    <fieldset class="action">
198
                      <input type="submit" value="Search" />
199
                      <input type="button" value="Clear" id="clear_search" />
200
                    </fieldset>
201
                  </fieldset>
202
                </form>
203
            </aside>
114
            </aside>
204
        </div> <!-- /.col-sm-2.col-sm-pull-10 -->
115
        </div> <!-- /.col-sm-2.col-sm-pull-10 -->
205
    </div> <!-- /.row -->
116
    </div> <!-- /.row -->
Lines 234-249 Link Here
234
    [% INCLUDE 'datatables.inc' %]
145
    [% INCLUDE 'datatables.inc' %]
235
    [% INCLUDE 'columns_settings.inc' %]
146
    [% INCLUDE 'columns_settings.inc' %]
236
    [% INCLUDE 'str/members-menu.inc' %]
147
    [% INCLUDE 'str/members-menu.inc' %]
237
    [% Asset.js("lib/hc-sticky.js") | $raw %]
238
    [% Asset.js("js/members-menu.js") | $raw %]
148
    [% Asset.js("js/members-menu.js") | $raw %]
239
    <script>
149
    <script>
240
        var singleBranchMode = '[% singleBranchMode | html %]';
241
        var dtMemberResults;
242
        var search = 1;
243
        /* popstate event triggered by forward and back button. Need to refresh search */
244
        window.addEventListener('popstate', (event) => {
245
            getSearchByLocation( false );
246
        });
247
150
248
        $(document).ready(function() {
151
        $(document).ready(function() {
249
            $('#merge-patrons').prop('disabled', true);
152
            $('#merge-patrons').prop('disabled', true);
Lines 313-322 Link Here
313
                patronListAdd();
216
                patronListAdd();
314
            });
217
            });
315
218
316
            $(".filterByLetter").on("click",function(e){
317
                e.preventDefault();
318
                filterByFirstLetterSurname( $(this).text(), true );
319
            });
320
            $("#select_all").on("click",function(e){
219
            $("#select_all").on("click",function(e){
321
                e.preventDefault();
220
                e.preventDefault();
322
                $(".selection").prop("checked", true).change();
221
                $(".selection").prop("checked", true).change();
Lines 325-335 Link Here
325
                e.preventDefault();
224
                e.preventDefault();
326
                $(".selection").prop("checked", false).change();
225
                $(".selection").prop("checked", false).change();
327
            });
226
            });
328
            $("#clear_search").on("click",function(e){
329
                e.preventDefault();
330
                clearFilters(true);
331
            });
332
            $("#searchform").on("submit", filter);
333
227
334
            [% IF searchmember %]
228
            [% IF searchmember %]
335
                $("#searchmember_filter").val("[% searchmember | html %]");
229
                $("#searchmember_filter").val("[% searchmember | html %]");
Lines 347-507 Link Here
347
                $("#branchcode_filter").val("[% branchcode_filter | html %]");
241
                $("#branchcode_filter").val("[% branchcode_filter | html %]");
348
            [% END %]
242
            [% END %]
349
243
350
            [% IF view != "show_results" %]
244
            $("#searchheader").hide();
351
                search = 0;
245
            $("#patron_search_form").on('submit', function(){$("#searchheader").show();});
352
            [% ELSE %]
246
            $("#clear_search").on("click",function(e){$("#searchheader").hide();});
353
                $("#searchresults").show();
354
            [% END %]
355
356
            // Build the aLengthMenu
357
            var aLengthMenu = [
358
                [% PatronsPerPage | html %], 10, 20, 50, 100, -1
359
            ];
360
            jQuery.unique(aLengthMenu);
361
            aLengthMenu.sort(function( a, b ){
362
                // Put "All" at the end
363
                if ( a == -1 ) {
364
                    return 1;
365
                } else if ( b == -1 ) {
366
                    return -1;
367
                }
368
                return parseInt(a) < parseInt(b) ? -1 : 1;}
369
            );
370
            var aLengthMenuLabel = [];
371
            $(aLengthMenu).each(function(){
372
                if ( this == -1 ) {
373
                    // Label for -1 is "All"
374
                    aLengthMenuLabel.push(_("All"));
375
                } else {
376
                    aLengthMenuLabel.push(this);
377
                }
378
            });
379
247
380
            // Apply DataTables on the results table
248
            // Apply DataTables on the results table
381
            var columns_settings = [% TablesSettings.GetColumns( 'members', 'member', 'memberresultst', 'json' ) | $raw %];
249
            var table_settings = [% TablesSettings.GetColumns( 'members', 'member', 'memberresultst', 'json' ) | $raw %];
382
            [% UNLESS CAN_user_borrowers_edit_borrowers OR CAN_user_tools_manage_patron_lists %]
250
            [% UNLESS CAN_user_borrowers_edit_borrowers OR CAN_user_tools_manage_patron_lists %]
383
                [%# Remove the first column if we do not display the checkbox %]
251
                [%# Remove the first column if we do not display the checkbox %]
384
                columns_settings.splice(0, 1);
252
                table_settings.splice(0, 1);
385
            [% END %]
253
            [% END %]
386
            dtMemberResults = KohaTable("memberresultst", {
387
                'bServerSide': true,
388
                'sAjaxSource': "/cgi-bin/koha/svc/members/search",
389
                'fnServerData': function(sSource, aoData, fnCallback) {
390
                    if ( ! search ) {
391
                        return;
392
                    }
393
                    aoData.push({
394
                        'name': 'searchmember',
395
                        'value': $("#searchmember_filter").val()
396
                    },{
397
                        'name': 'firstletter',
398
                        'value': $("#firstletter_filter").val()
399
                    },{
400
                        'name': 'searchfieldstype',
401
                        'value': $("#searchfieldstype_filter").val()
402
                    },{
403
                        'name': 'searchtype',
404
                        'value': $("#searchtype_filter").val()
405
                    },{
406
                        'name': 'categorycode',
407
                        'value': $("#categorycode_filter").val()
408
                    },{
409
                        'name': 'branchcode',
410
                        'value': $("#branchcode_filter").val()
411
                    },{
412
                        'name': 'name_sorton',
413
                        'value': 'borrowers.surname borrowers.firstname'
414
                    },{
415
                        'name': 'cardnumber_sorton',
416
                        'value': 'borrowers.cardnumber',
417
                    },{
418
                        'name': 'dateofbirth_sorton',
419
                        'value': 'borrowers.dateofbirth',
420
                    },{
421
                        'name': 'dateexpiry_sorton',
422
                        'value': 'borrowers.dateexpiry',
423
                    },{
424
                        'name': 'category_sorton',
425
                        'value': 'categories.description',
426
                    },{
427
                        'name': 'branch_sorton',
428
                        'value': 'branches.branchname'
429
                    },{
430
                        'name': 'borrowernotes_sorton',
431
                        'value': 'borrowers.borrowernotes'
432
                    },{
433
                        'name': 'template_path',
434
                        'value': 'members/tables/members_results.tt',
435
                    });
436
                    $.ajax({
437
                        'dataType': 'json',
438
                        'type': 'POST',
439
                        'url': sSource,
440
                        'data': aoData,
441
                        'success': function(json){
442
                            // redirect if there is only 1 result.
443
                            if ( json.iTotalDisplayRecords == 1 ) {
444
                                var borrowernumber = json.aaData[0].borrowernumber;
445
                                /* Overwrite history state of firstletter search since only one result was returned; This prevents a loop upon clicking back */
446
                                history.replaceState( {}, null, window.location.href.split("?" )[0]);
447
                                [% IF circsearch == 1 %]
448
                                    [% SET redirect = "circ/circulation" %]
449
                                [% ELSE %]
450
                                    [% SET redirect = "members/moremember" %]
451
                                [% END %]
452
                                document.location.href="/cgi-bin/koha/[% redirect | $raw %].pl?borrowernumber="+borrowernumber;
453
                                return false;
454
                            }
455
                            fnCallback(json);
456
                        }
457
                    });
458
                },
459
                'aoColumns':[
460
                    [% IF CAN_user_borrowers_edit_borrowers || CAN_user_tools_manage_patron_lists %]
461
                      { 'mDataProp': 'dt_borrowernumber', 'bSortable': false },
462
                    [% END %]
463
                    { 'mDataProp': 'dt_cardnumber' },
464
                    { 'mDataProp': 'dt_name' },
465
                    { 'mDataProp': 'dt_dateofbirth' },
466
                    { 'mDataProp': 'dt_category' },
467
                    {
468
                        'mDataProp': function ( oObj ) {
469
                            if( !singleBranchMode &&  oObj.dt_branch == "[% Branches.GetLoggedInBranchname | html %]" ){
470
                                return "<span class=\"currentlibrary\">" + oObj.dt_branch + "</span>";
471
                            } else {
472
                                return oObj.dt_branch;
473
                            }
474
                        }
475
                    },
476
                    { 'mDataProp': 'dt_dateexpiry' },
477
                    { 'mDataProp': 'dt_od_checkouts', 'bSortable': false },
478
                    { 'mDataProp': 'dt_fines', 'bSortable': false },
479
                    { 'mDataProp': 'dt_borrowernotes' },
480
                    { 'mDataProp': 'dt_action', 'bSortable': false, 'sClass': 'actions' }
481
                ],
482
                'bFilter': false,
483
                'bAutoWidth': false,
484
                [% IF CAN_user_borrowers_edit_borrowers || CAN_user_tools_manage_patron_lists %]
485
                    'aaSorting': [[2, 'asc']],
486
                [% ELSE %]
487
                    'aaSorting': [[1, 'asc']],
488
                [% END %]
489
                "aLengthMenu": [aLengthMenu, aLengthMenuLabel],
490
                'sPaginationType': 'full_numbers',
491
                "iDisplayLength": [% PatronsPerPage | html %],
492
                "bProcessing": true,
493
                "initComplete": function(settings, json) {
494
                    Sticky = $("#searchheader");
495
                    Sticky.hcSticky({
496
                        stickTo: "#searchresults",
497
                        stickyClass: "floating"
498
                    });
499
                }
500
            }, columns_settings);
501
            update_searched();
502
            /* Initial page load doesn't trigger the popstate event, so we explicitly call this */
503
            getSearchByLocation( false );
504
505
        });
254
        });
506
255
507
        function patronListAdd(){
256
        function patronListAdd(){
Lines 536-587 Link Here
536
            return true;
285
            return true;
537
        }
286
        }
538
287
539
        function getSearchByLocation( setstate ){
540
            /* Check to see if the URL contains a search parameter */
541
            if( location.search != ""){
542
                var params = new URLSearchParams( location.search );
543
                var firstletter = params.get("firstletter");
544
                /* Check to see if search is a first letter param */
545
                if( firstletter ){
546
                    /* Trigger function to return search results by letter */
547
                    filterByFirstLetterSurname( firstletter, setstate );
548
                }
549
            }
550
        }
551
552
        // Update the string "Results found ..."
553
        function update_searched(){
554
            var searched = $("#searchfieldstype_filter").find("option:selected").text();
555
            if ( $("#searchmember_filter").val() ) {
556
                if ( $("#searchtype_filter").val() == 'start_with' ) {
557
                    searched += _(" starting with ");
558
                } else {
559
                    searched += _(" containing ");
560
                }
561
                searched += "'" + $("#searchmember_filter").val() + "'";
562
            }
563
            if ( $("#firstletter_filter").val() ) {
564
                searched += _(" begins with ") + "'" + $("#firstletter_filter").val() +"'";
565
            }
566
            if ( $("#categorycode_filter").val() ) {
567
                searched += _(" with category ") + "'" + $("#categorycode_filter").find("option:selected").text() + "'";
568
            }
569
            if ( $("#branchcode_filter").val() ) {
570
                searched += _(" in library ") + $("#branchcode_filter").find("option:selected").text();
571
            }
572
            $("#searchpattern").text(searched);
573
        }
574
575
        // Redraw the table
576
        function filter() {
577
            $("#firstletter_filter").val('');
578
            update_searched();
579
            search = 1;
580
            $("#searchresults").show();
581
            dtMemberResults.fnDraw();
582
            return false;
583
        }
584
585
        $('#memberresultst tbody').on('click','td',function(e){
288
        $('#memberresultst tbody').on('click','td',function(e){
586
            var $checkbox = $(this).find("input[type=checkbox]");
289
            var $checkbox = $(this).find("input[type=checkbox]");
587
            if (e.target.type != "checkbox") {
290
            if (e.target.type != "checkbox") {
Lines 590-623 Link Here
590
            }
293
            }
591
        });
294
        });
592
295
593
        // User has clicked on the Clear button
594
        function clearFilters(redraw) {
595
            $("#searchform select").val('');
596
            $("#firstletter_filter").val('');
597
            $("#searchmember_filter").val('');
598
            if(redraw) {
599
                /* remove any search string added by firstletter search */
600
                history.pushState( {}, null, window.location.href.split("?" )[0]);
601
                update_searched();
602
                search = 0;
603
                $("#searchresults").hide();
604
                dtMemberResults.fnDraw();
605
            }
606
        }
607
608
        // User has clicked on a letter
609
        function filterByFirstLetterSurname( letter, setstate ) {
610
            clearFilters(false);
611
            $("#firstletter_filter").val(letter);
612
            if( setstate ){
613
                history.pushState( null, null, "?firstletter=" + letter );
614
            }
615
            update_searched();
616
            search = 1;
617
            $("#searchresults").show();
618
            dtMemberResults.fnDraw();
619
        }
620
    </script>
296
    </script>
297
298
    [% IF circsearch == 1 %]
299
        [% SET redirect_url = '/cgi-bin/koha/circ/circulation.pl' %]
300
    [% ELSE %]
301
        [% SET redirect_url = '/cgi-bin/koha/members/moremember.pl' %]
302
    [% END %]
303
    [% PROCESS patron_search_js
304
        table_id    => 'memberresultst',
305
        categories  => categories,
306
        libraries   => libraries,
307
        extended_attribute_types => attribute_type_codes,
308
        columns     => columns,
309
        actions     => ['edit', 'checkout'],
310
        redirect_if_one_result => 1,
311
        redirect_url           => redirect_url,
312
        sticky_header => "searchheader",
313
        sticky_to     => "patron_search_results",
314
    %]
315
316
621
[% END %]
317
[% END %]
622
318
623
[% INCLUDE 'intranet-bottom.inc' %]
319
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tt (-2 / +2 lines)
Lines 17-23 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, columns => columns, search_filter => searchmember %]
20
        [% PROCESS patron_search_filters categories => categories, libraries => libraries, filters => ['branch', 'category'], search_filter => searchmember %]
21
        </form>
21
        </form>
22
22
23
        [% PROCESS patron_search_table table_id => 'memberresultst' columns => columns %]
23
        [% PROCESS patron_search_table table_id => 'memberresultst' columns => columns %]
Lines 28-34 Link Here
28
</div>
28
</div>
29
29
30
[% MACRO jsinclude BLOCK %]
30
[% MACRO jsinclude BLOCK %]
31
    [% PROCESS patron_search_js table_id => 'memberresultst', categories => categories, libraries => libraries, extended_attribute_types => attribute_type_codes, columns => columns, filter => filter, selection_type => selection_type, callback => callback %]
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 %]
32
[% END %]
32
[% END %]
33
33
34
[% SET popup_window = 1 %]
34
[% SET popup_window = 1 %]
(-)a/members/member.pl (+4 lines)
Lines 29-34 use C4::Output qw( output_html_with_http_headers ); Link Here
29
use CGI qw( -utf8 );
29
use CGI qw( -utf8 );
30
use Koha::List::Patron qw( GetPatronLists );
30
use Koha::List::Patron qw( GetPatronLists );
31
use Koha::Patrons;
31
use Koha::Patrons;
32
use Koha::Patron::Attribute::Types;
32
33
33
my $input = CGI->new;
34
my $input = CGI->new;
34
35
Lines 79-84 $template->param( Link Here
79
    PatronsPerPage      => C4::Context->preference("PatronsPerPage") || 20,
80
    PatronsPerPage      => C4::Context->preference("PatronsPerPage") || 20,
80
    view                => $view,
81
    view                => $view,
81
    circsearch          => $circsearch,
82
    circsearch          => $circsearch,
83
    attribute_type_codes => ( C4::Context->preference('ExtendedPatronAttributes')
84
        ? [ Koha::Patron::Attribute::Types->search( { staff_searchable => 1 } )->get_column('code') ]
85
        : [] ),
82
);
86
);
83
87
84
output_html_with_http_headers $input, $cookie, $template->output;
88
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/members/members-home.pl (-1 / +4 lines)
Lines 27-32 use Koha::Patron::Modifications; Link Here
27
use Koha::Libraries;
27
use Koha::Libraries;
28
use Koha::List::Patron qw( GetPatronLists );
28
use Koha::List::Patron qw( GetPatronLists );
29
use Koha::Patron::Categories;
29
use Koha::Patron::Categories;
30
use Koha::Patron::Attribute::Types;
30
31
31
my $query = CGI->new;
32
my $query = CGI->new;
32
33
Lines 72-77 $template->param( Link Here
72
    PatronAutoComplete => C4::Context->preference('PatronAutoComplete'),
73
    PatronAutoComplete => C4::Context->preference('PatronAutoComplete'),
73
    patron_lists => [ GetPatronLists() ],
74
    patron_lists => [ GetPatronLists() ],
74
    PatronsPerPage => C4::Context->preference("PatronsPerPage") || 20,
75
    PatronsPerPage => C4::Context->preference("PatronsPerPage") || 20,
76
    attribute_type_codes => ( C4::Context->preference('ExtendedPatronAttributes')
77
        ? [ Koha::Patron::Attribute::Types->search( { staff_searchable => 1 } )->get_column('code') ]
78
        : [] ),
75
);
79
);
76
80
77
output_html_with_http_headers $query, $cookie, $template->output;
81
output_html_with_http_headers $query, $cookie, $template->output;
78
- 

Return to bug 30063