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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc (+1 lines)
Lines 71-76 Link Here
71
[% IF ( PatronAutoComplete ) %]
71
[% IF ( PatronAutoComplete ) %]
72
    <script>
72
    <script>
73
    // PatronAutoComplete
73
    // PatronAutoComplete
74
    var defaultPatronSearchFields = "[% Koha.Preference('DefaultPatronSearchFields') || 'firstname,middle_name,surname,othernames,cardnumber,userid' | html %]";
74
    var loggedInLibrary = '[% Branches.GetLoggedInBranchcode | html %]';
75
    var loggedInLibrary = '[% Branches.GetLoggedInBranchcode | html %]';
75
    var singleBranchMode = '[% singleBranchMode | html %]';
76
    var singleBranchMode = '[% singleBranchMode | html %]';
76
    var loggedInClass = "";
77
    var loggedInClass = "";
(-)a/koha-tmpl/intranet-tmpl/prog/js/patron-autocomplete.js (-9 / +7 lines)
Lines 13-32 function patron_autocomplete(node, options) { Link Here
13
            on_select_callback = options['on-select-callback'];
13
            on_select_callback = options['on-select-callback'];
14
        }
14
        }
15
    }
15
    }
16
    const search_fields = ['me.surname', 'me.firstname', 'me.cardnumber'];
17
    return node.autocomplete({
16
    return node.autocomplete({
18
        source: function( request, response ) {
17
        source: function( request, response ) {
19
            let subquery_and = [];
18
            let subquery_and = [];
20
            request.term.split(' ')
19
            request.term.split(' ')
21
                .filter(function(s){ return s.length })
20
                .filter(function(s){ return s.length })
22
                .forEach(function(pattern,i){
21
                .forEach(function(pattern,i){
23
                    subquery_and.push(
22
                    let subquery_or = [];
24
                        [
23
                    defaultPatronSearchFields.split(',').forEach(function(field,i){
25
                            {'me.surname':    {'like': '%' + pattern + '%'}},
24
                        subquery_or.push(
26
                            {'me.firstname':  {'like': '%' + pattern + '%'}},
25
                            {["me."+field]: {'like': '%' + pattern + '%'}}
27
                            {'me.cardnumber': {'like': pattern + '%'}},
26
                        );
28
                        ]
27
                    });
29
                    );
28
                    subquery_and.push(subquery_or);
30
                });
29
                });
31
            let q = {"-and": subquery_and};
30
            let q = {"-and": subquery_and};
32
            let params = {
31
            let params = {
33
- 

Return to bug 32520