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

(-)a/koha-tmpl/intranet-tmpl/prog/js/patron-autocomplete.js (-10 / +9 lines)
Lines 13-34 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'];
16
    const search_fields = ['surname', 'firstname', 'cardnumber'];
17
    return node.autocomplete({
17
    return node.autocomplete({
18
        source: function( request, response ) {
18
        source: function( request, response ) {
19
            let subquery_and = [];
19
            let subquery_and = [];
20
            request.term.split(' ')
20
            request.term.split(' ')
21
                .filter(function(s){ return s.length })
21
                .filter(function(s){ return s.length })
22
                .forEach(function(pattern,i){
22
                .forEach(function(pattern,i){
23
                    subquery_and.push(
23
                    let subquery_or = [];
24
                        [
24
                    search_fields.forEach(function(field,i){
25
                            {'me.surname':    {'like': '%' + pattern + '%'}},
25
                        subquery_or.push(
26
                            {'me.firstname':  {'like': '%' + pattern + '%'}},
26
                            {["me."+field]: {'like': '%' + pattern + '%'}}
27
                            {'me.cardnumber': {'like': pattern + '%'}},
27
                        );
28
                        ]
28
                    });
29
                    );
29
                    subquery_and.push(subquery_or);
30
                });
30
                });
31
            let q = {"-and": subquery_and};
31
            let q = {"-and": subquery_and };
32
            let params = {
32
            let params = {
33
                '_page': 1,
33
                '_page': 1,
34
                '_per_page': 10,
34
                '_per_page': 10,
35
- 

Return to bug 32520