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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc (-65 / +250 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 filter IN filters %]
26
                    [% SWITCH column %]
27
                    [% SWITCH filter %]
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-88 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="dispay: none;"></div>
120
        <div id="error" class="dialog alert" style="display: none;"></div>
85
86
121
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 %]
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></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 184-203 Link Here
184
                    return { "like": start_with + "%" }
254
                    return { "like": start_with + "%" }
185
                },
255
                },
186
                "-and": function(){
256
                "-and": function(){
187
                    let filter = $("#searchmember_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
            patrons_table = $("#[% table_id | html %]").kohaTable({
278
            patrons_table = $("#[% table_id | html %]").kohaTable({
Lines 218-224 Link Here
218
                        [% IF redirect_if_one_result %]
293
                        [% IF redirect_if_one_result %]
219
                            // redirect if there is only 1 result.
294
                            // redirect if there is only 1 result.
220
                            if ( first_draw && json.recordsFiltered == 1 ) {
295
                            if ( first_draw && json.recordsFiltered == 1 ) {
221
                                document.location.href = '[% redirect_url | html %]&borrowernumber=' + json.data[0].patron_id;
296
                                let url = '[% redirect_url | html %]'.indexOf("?") != -1
297
                                    ? '[% redirect_url | html %]&borrowernumber=' + json.data[0].patron_id
298
                                    : '[% redirect_url | html %]?borrowernumber=' + json.data[0].patron_id;
299
                                document.location.href = url;
222
                                return false;
300
                                return false;
223
                            }
301
                            }
224
                            first_draw = 0;
302
                            first_draw = 0;
Lines 227-232 Link Here
227
                    }
305
                    }
228
                },
306
                },
229
                embed: ['extended_attributes', 'checkouts+count', 'overdues+count', 'account_balance'],
307
                embed: ['extended_attributes', 'checkouts+count', 'overdues+count', 'account_balance'],
308
                [% IF open_on_row_click OR preview_on_name_click %]
230
                "drawCallback": function( settings ) {
309
                "drawCallback": function( settings ) {
231
                    var api = this.api();
310
                    var api = this.api();
232
                    var data = api.data();
311
                    var data = api.data();
Lines 240-251 Link Here
240
                        }).addClass('clickable');
319
                        }).addClass('clickable');
241
                        $(tr).find("a.patron_name").attr('href', url);
320
                        $(tr).find("a.patron_name").attr('href', url);
242
                    });
321
                    });
243
                    [% ELSE %]
322
                    [% END %]
323
                    [% IF preview_on_name_click %]
244
                    $.each($(this).find("tbody tr"), function(index, tr) {
324
                    $.each($(this).find("tbody tr"), function(index, tr) {
245
                        $(tr).find("a.patron_name").addClass("patron_preview");
325
                        $(tr).find("a.patron_name").addClass("patron_preview");
246
                    });
326
                    });
247
                    [% END %]
327
                    [% END %]
248
                },
328
                },
329
                [% END %]
249
                "order": [[ 1, "asc" ]],
330
                "order": [[ 1, "asc" ]],
250
                "iDeferLoading": 0,
331
                "iDeferLoading": 0,
251
                "columns": [
332
                "columns": [
Lines 253-272 Link Here
253
                        [% SWITCH column %]
334
                        [% SWITCH column %]
254
                            [% CASE 'checkbox' %]
335
                            [% CASE 'checkbox' %]
255
                            {
336
                            {
256
                                "data": "borrowernumber",
337
                                "data": "patron_id",
257
                                "searchable": true,
338
                                "searchable": false,
258
                                "orderable": true,
339
                                "orderable": false,
259
                                "render": function( data, type, row, meta ) {
340
                                "render": function( data, type, row, meta ) {
260
                                    return "<input type=\"checkbox\" name="data ? escape_str($date(data) + " (" + _("%s years").format($get_age(data)) + ")") : "";
341
                                    return "<label for='check" + data + "' class='content_hidden'>" + _("Select patron") + "</label><input type='checkbox' id='check" + data + "' class='selection' name='borrowernumber' value='" + data + "' />";
261
262
                                    return "<label for='check" + data + "' class='content_hidden'>" + _("Select patron") + "</label><input type='checkbox' id='check" + data + "' class='selection' name='borrowernumber' value='" + data + "' />",
263
                                }
342
                                }
264
                            }
343
                            }
265
                            [% CASE 'cardnumber' %]
344
                            [% CASE 'cardnumber' %]
266
                            {
345
                            {
267
                                "data": "cardnumber",
346
                                "data": "cardnumber",
268
                                "searchable": true,
347
                                "searchable": true,
269
                                "orderable": true
348
                                "orderable": true,
349
                                "render": function( data, type, row, meta ) {
350
                                    let patron_id = encodeURIComponent(row.patron_id);
351
                                    [% IF !open_on_row_click AND CAN_user_circulate_circulate_remaining_permissions %]
352
                                        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>";
353
                                    [% ELSE %]
354
                                        return escape_str(data);
355
                                    [% END %]
356
                                }
357
270
                            }
358
                            }
271
                            [% CASE 'dateofbirth' %]
359
                            [% CASE 'dateofbirth' %]
272
                            {
360
                            {
Lines 334-340 Link Here
334
                                "orderable": true,
422
                                "orderable": true,
335
                                "render": function( data, type, row, meta ) {
423
                                "render": function( data, type, row, meta ) {
336
                                    let patron_id = encodeURIComponent(row.patron_id);
424
                                    let patron_id = encodeURIComponent(row.patron_id);
425
                                    [% IF ! open_on_row_click %]
337
                                    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>";
426
                                    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>";
427
                                    [% ELSE %]
428
                                    return $patron_to_html(row, { invert_name: 1 });
429
                                    [% END %]
338
                                }
430
                                }
339
                            }
431
                            }
340
                            [% CASE 'branch' %]
432
                            [% CASE 'branch' %]
Lines 343-349 Link Here
343
                                "searchable": true,
435
                                "searchable": true,
344
                                "orderable": true,
436
                                "orderable": true,
345
                                "render": function( data, type, row, meta ) {
437
                                "render": function( data, type, row, meta ) {
346
                                    return escape_str(libraries_map[data].branchname);
438
                                    let library_name = libraries_map[data].branchname
439
                                    if( !singleBranchMode && data == logged_in_library_id ) {
440
                                        return "<span class=\"currentlibrary\">" + escape_str(library_name) + "</span>";
441
                                    } else {
442
                                        return escape_str(library_name);
443
                                    }
347
                                }
444
                                }
348
                            }
445
                            }
349
                            [% CASE 'category' %]
446
                            [% CASE 'category' %]
Lines 420-430 Link Here
420
                                "data": function( row, type, val, meta ) {
517
                                "data": function( row, type, val, meta ) {
421
518
422
                                    let patron_id = encodeURIComponent(row.patron_id);
519
                                    let patron_id = encodeURIComponent(row.patron_id);
423
                                    [% IF selection_type == 'select' %]
520
                                    let action_node = "";
424
                                        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)+'\' />';
521
                                    [% FOR action IN actions %]
425
                                    [% ELSE %]
522
                                    [% SWITCH action %]
426
                                        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 + '" />';
523
                                    [% CASE 'select' %]
524
                                        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)+'\' />';
525
                                    [% CASE 'add' %]
526
                                        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 + '" />';
527
                                    [% CASE 'edit' %]
528
                                        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>';
529
                                    [% CASE 'checkout' %]
530
                                        [% IF CAN_user_circulate_circulate_remaining_permissions %]
531
                                            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>';
532
                                        [% END %]
533
                                    [% END %]
427
                                    [% END %]
534
                                    [% END %]
535
                                    return action_node;
428
                                },
536
                                },
429
                                "searchable": false,
537
                                "searchable": false,
430
                                "orderable": false
538
                                "orderable": false
Lines 434-447 Link Here
434
                    [% END %]
542
                    [% END %]
435
                ],
543
                ],
436
                'bAutoWidth': false,
544
                'bAutoWidth': false,
545
                'lengthMenu': [aLengthMenu, aLengthMenuLabel],
437
                'sPaginationType': 'full_numbers',
546
                'sPaginationType': 'full_numbers',
438
                "iDisplayLength": [% Koha.Preference('PatronsPerPage') | html %],
547
                "pageLength": [% Koha.Preference('PatronsPerPage') | html %],
548
                [% IF sticky_header %]
549
                "initComplete": function(settings, json) {
550
                    Sticky = $("#[% sticky_header | html %]x");
551
                    Sticky.hcSticky({
552
                        stickTo: "#[% sticky_to | html %]",
553
                        stickyClass: "floating"
554
                    });
555
                },
556
                [% END %]
439
            }, typeof table_settings !== 'undefined' ? table_settings : null, 1, additional_filters);
557
            }, typeof table_settings !== 'undefined' ? table_settings : null, 1, additional_filters);
440
558
441
            $("#patron_search_form").on('submit', filter);
559
            $("#patron_search_form").on('submit', filter);
442
            $(".filterByLetter").on("click",function(e){
560
            $(".filterByLetter").on("click",function(e){
443
                e.preventDefault();
561
                e.preventDefault();
444
                filterByFirstLetterSurname($(this).text());
562
                filterByFirstLetterSurname($(this).text(), true);
445
            });
563
            });
446
            $("body").on("click",".add_user",function(e){
564
            $("body").on("click",".add_user",function(e){
447
                e.preventDefault();
565
                e.preventDefault();
Lines 470-477 Link Here
470
                $("#patronPreview .modal-body").html("<img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> Loading");
588
                $("#patronPreview .modal-body").html("<img src=\"[% interface | html %]/[% theme | html %]/img/spinner-small.gif\" alt=\"\" /> Loading");
471
            });
589
            });
472
590
591
            $("#clear_search").on("click",function(e){
592
                e.preventDefault();
593
                clearFilters();
594
                $("#searchpattern").parent().hide();
595
            });
596
597
            if ( $("#search_patron_filter").val().length > 0 ) {
598
                $("#patron_search_form").submit();
599
            }
600
601
            /* Initial page load does not trigger the popstate event, so we explicitly call this */
602
            getSearchByLocation( false );
603
473
        });
604
        });
474
605
606
        function getSearchByLocation( setstate ){
607
            /* Check to see if the URL contains a search parameter */
608
            if( location.search != ""){
609
                var params = new URLSearchParams( location.search );
610
                var firstletter = params.get("firstletter");
611
                /* Check to see if search is a first letter param */
612
                if( firstletter ){
613
                    /* Trigger function to return search results by letter */
614
                    filterByFirstLetterSurname( firstletter, setstate );
615
                }
616
            }
617
        }
618
619
        function update_search_description(){
620
            var searched = $("#searchfieldstype_filter").find("option:selected").text();
621
            if ( $("#search_patron_filter").val() ) {
622
                if ( $("#searchtype_filter").val() == 'start_with' ) {
623
                    searched += _(" starting with ");
624
                } else {
625
                    searched += _(" containing ");
626
                }
627
                searched += "'" + $("#search_patron_filter").val() + "'";
628
            }
629
            if ( $("#firstletter_filter").val() ) {
630
                searched += _(" begins with ") + "'" + $("#firstletter_filter").val() +"'";
631
            }
632
            if ( $("#categorycode_filter").val() ) {
633
                searched += _(" with category ") + "'" + $("#categorycode_filter").find("option:selected").text() + "'";
634
            }
635
            if ( $("#branchcode_filter").val() ) {
636
                searched += _(" in library ") + $("#branchcode_filter").find("option:selected").text();
637
            }
638
            $("#searchpattern").text(searched);
639
            $("#searchpattern").parent().show();
640
        }
641
475
        function filter() {
642
        function filter() {
476
            $("#firstletter_filter").val('');
643
            $("#firstletter_filter").val('');
477
            $("#[% table_id | html %]_search_results").show();
644
            $("#[% table_id | html %]_search_results").show();
Lines 492-541 Link Here
492
            table_dt.search("");
659
            table_dt.search("");
493
            first_draw = 1; // Only redirect if we are coming from here
660
            first_draw = 1; // Only redirect if we are coming from here
494
            table_dt.draw();
661
            table_dt.draw();
662
            update_search_description();
495
            return false;
663
            return false;
496
        }
664
        }
497
665
666
        function clearFilters() {
667
            $("#searchfieldstype_filter option:first").prop("selected", true);
668
            $("#searchtype_filter option[value='contain']").prop("selected", true);
669
            $("#categorycode_filter option:first").prop("selected", true);
670
            $("#branchcode_filter option:first").prop("selected", true);
671
            $("#firstletter_filter").val('');
672
            $("#search_patron_filter").val('');
673
            /* remove any search string added by firstletter search */
674
            history.pushState( {}, null, window.location.href.split("?" )[0]);
675
            $("#[% table_id | html %]_search_results").hide();
676
            update_search_description();
677
        }
678
498
        // User has clicked on a letter
679
        // User has clicked on a letter
499
        function filterByFirstLetterSurname(letter) {
680
        function filterByFirstLetterSurname(letter, setstate ) {
500
            $("#firstletter_filter").val(letter);
681
            $("#firstletter_filter").val(letter);
682
501
            $("#[% table_id | html %]_search_results").show();
683
            $("#[% table_id | html %]_search_results").show();
684
685
            if ( setstate ) {
686
                history.pushState( null, null, "?firstletter=" + letter );
687
            }
688
502
            patrons_table.DataTable().draw();
689
            patrons_table.DataTable().draw();
690
            update_search_description();
503
        }
691
        }
504
692
505
        // modify parent window owner element
693
        // modify parent window owner element
506
        [% IF selection_type == 'add' %]
694
        function add_user(borrowernumber, borrowername) {
507
            function add_user(borrowernumber, borrowername) {
695
            var p = window.opener;
508
                var p = window.opener;
696
            // In one place (serials/routing.tt), the page is reload on every add
509
                // In one place (serials/routing.tt), the page is reload on every add
697
            // We have to wait for the page to be there
510
                // We have to wait for the page to be there
698
            function wait_for_opener () {
511
                function wait_for_opener () {
699
                if ( ! $(opener.document).find('body').size() ) {
512
                    if ( ! $(opener.document).find('body').size() ) {
700
                    setTimeout(wait_for_opener, 500);
513
                        setTimeout(wait_for_opener, 500);
701
                } else {
702
                    [%# Note that add_user could sent data instead of borrowername too %]
703
                    $("#info").hide();
704
                    $("#error").hide();
705
                    if ( p.add_user(borrowernumber, borrowername) < 0 ) {
706
                        $("#error").html(_("Patron '%s' is already in the list.").format(borrowername));
707
                        $("#error").show();
514
                    } else {
708
                    } else {
515
                        [%# Note that add_user could sent data instead of borrowername too %]
709
                        $("#info").html(_("Patron '%s' added.").format(borrowername));
516
                        $("#info").hide();
710
                        $("#info").show();
517
                        $("#error").hide();
518
                        if ( p.add_user(borrowernumber, borrowername) < 0 ) {
519
                            $("#error").html(_("Patron '%s' is already in the list.").format(borrowername));
520
                            $("#error").show();
521
                        } else {
522
                            $("#info").html(_("Patron '%s' added.").format(borrowername));
523
                            $("#info").show();
524
                        }
525
                    }
711
                    }
526
                }
712
                }
527
                wait_for_opener();
528
            }
713
            }
529
        [% ELSIF selection_type == 'select' %]
714
            wait_for_opener();
530
            function select_user(borrowernumber, data) {
715
        }
531
                var p = window.opener;
716
        function select_user(borrowernumber, data) {
532
                [%  IF callback %]
717
            var p = window.opener;
533
                    p.[% callback | html %](borrowernumber, data);
718
            [%  IF callback %]
534
                [%  ELSE %]
719
                p.[% callback | html %](borrowernumber, data);
535
                    p.select_user(borrowernumber, data);
720
            [%  ELSE %]
536
                [%  END %]
721
                p.select_user(borrowernumber, data);
537
                window.close();
722
            [%  END %]
538
            }
723
            window.close();
539
        [% END %]
724
        }
540
    </script>
725
    </script>
541
[% END %]
726
[% 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>&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>&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.aaData.length == 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 / +3 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 35-41 Link Here
35
        extended_attribute_types => attribute_type_codes,
35
        extended_attribute_types => attribute_type_codes,
36
        columns     => columns,
36
        columns     => columns,
37
        filter      => filter,
37
        filter      => filter,
38
        selection_type => selection_type,
38
        actions     => [selection_type],
39
        preview_on_name_click => 1,
39
        callback    => callback
40
        callback    => callback
40
    %]
41
    %]
41
[% END %]
42
[% END %]
(-)a/members/member.pl (-1 / +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;
85
- 

Return to bug 30063