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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patronfields.inc (-8 / +6 lines)
Lines 1-9 Link Here
1
[%- BLOCK patron_fields -%]
1
[%- BLOCK patron_fields -%]
2
     [%- SWITCH name -%]
2
     [%- SWITCH name -%]
3
     [%- CASE standard -%]<span>Standard</span>
3
     [%- CASE 'standard' -%]<span>Standard</span>
4
     [%- CASE full_address -%]<span>Full address</span>
4
     [%- CASE 'full_address' -%]<span>Full address</span>
5
     [%- CASE all_emails -%]<span>All emails</span>
5
     [%- CASE 'all_emails' -%]<span>All emails</span>
6
     [%- CASE all_phones -%]<span>All phones</span>
6
     [%- CASE 'all_phones' -%]<span>All phones</span>
7
     [%- CASE 'borrowernumber' -%]<span>Borrowernumber</span>
7
     [%- CASE 'borrowernumber' -%]<span>Borrowernumber</span>
8
     [%- CASE 'cardnumber' -%]<span>Card number</span>
8
     [%- CASE 'cardnumber' -%]<span>Card number</span>
9
     [%- CASE 'surname' -%]<span>Surname</span>
9
     [%- CASE 'surname' -%]<span>Surname</span>
Lines 87-96 Link Here
87
        <select name="searchfieldstype" id="searchfieldstype_filter">
87
        <select name="searchfieldstype" id="searchfieldstype_filter">
88
    [% END %]
88
    [% END %]
89
        [% SET standard = Koha.Preference('DefaultPatronSearchFields') || 'firstname|middle_name|surname|othernames|cardnumber|userid' %]
89
        [% SET standard = Koha.Preference('DefaultPatronSearchFields') || 'firstname|middle_name|surname|othernames|cardnumber|userid' %]
90
        [% SET full_address = 'streetnumber|streettype|address|address2|city|state|zipcode|country' %]
90
        [%# Above is needed for adding fields from the DefaultPatronSearchFields preference to the dropdowns %]
91
        [% SET all_emails = 'email|emailpro|B_email' %]
91
        [% default_fields = [ 'standard', 'surname', 'cardnumber', 'all_emails', 'borrowernumber', 'userid', 'all_phones', 'full_address', 'dateofbirth', 'sort1', 'sort2' ] %]
92
        [% SET all_phones = 'phone|phonepro|B_phone|altcontactphone|mobile' %]
93
        [% default_fields = [ standard, 'surname', 'cardnumber', all_emails, 'borrowernumber', 'userid', all_phones, full_address, 'dateofbirth', 'sort1', 'sort2' ] %]
94
        [% search_options = default_fields.merge(standard.split('\|')).unique %]
92
        [% search_options = default_fields.merge(standard.split('\|')).unique %]
95
        [% FOREACH s_o IN search_options %]
93
        [% FOREACH s_o IN search_options %]
96
            [% display_name = PROCESS patron_fields name=s_o %]
94
            [% display_name = PROCESS patron_fields name=s_o %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js (-3 / +21 lines)
Lines 517-522 function patron_autocomplete(node, options) { Link Here
517
        };
517
        };
518
}
518
}
519
519
520
function expandPatronSearchFields(search_fields) {
521
    switch(search_fields) {
522
        case 'standard':
523
            return defaultPatronSearchFields;
524
            break;
525
        case 'full_address':
526
            return 'streetnumber,streettype,address,address2,city,state,zipcode,country';
527
            break;
528
        case 'all_emails':
529
            return 'email,emailpro,B_email';
530
            break;
531
        case 'all_phones':
532
            return 'phone,phonepro,B_phone,altcontactphone,mobile';
533
            break;
534
        default:
535
            return search_fields;
536
    }
537
}
538
520
/**
539
/**
521
 * Build patron search query
540
 * Build patron search query
522
 * - term: The full search term input by the user
541
 * - term: The full search term input by the user
Lines 547-553 function buildPatronSearchQuery(term, options) { Link Here
547
566
548
    // Search fields: If search_fields option exists, we use that
567
    // Search fields: If search_fields option exists, we use that
549
    if (typeof options !== 'undefined' && options.search_fields) {
568
    if (typeof options !== 'undefined' && options.search_fields) {
550
        search_fields = options.search_fields;
569
        search_fields = expandPatronSearchFields(options.search_fields);
551
    // If not, we use DefaultPatronSearchFields system preference instead
570
    // If not, we use DefaultPatronSearchFields system preference instead
552
    } else {
571
    } else {
553
        search_fields = defaultPatronSearchFields;
572
        search_fields = defaultPatronSearchFields;
Lines 584-590 function buildPatronSearchQuery(term, options) { Link Here
584
    q.push({ "-or": term_subquery_or });
603
    q.push({ "-or": term_subquery_or });
585
604
586
    // Add each pattern for each extended patron attributes
605
    // Add each pattern for each extended patron attributes
587
    if (typeof options !== 'undefined' && options.extended_attribute_types && extendedPatronAttributes) {
606
    if (typeof options !== 'undefined' && options.search_fields == 'standard' && options.extended_attribute_types && extendedPatronAttributes) {
588
        extended_attribute_subquery_and = [];
607
        extended_attribute_subquery_and = [];
589
        patterns.forEach(function (pattern, i) {
608
        patterns.forEach(function (pattern, i) {
590
            let extended_attribute_sub_or = [];
609
            let extended_attribute_sub_or = [];
591
- 

Return to bug 33428