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

(-)a/C4/Utils/DataTables/Members.pm (-7 / +8 lines)
Lines 85-99 sub search { Link Here
85
85
86
    my $searchfields = {
86
    my $searchfields = {
87
        standard => C4::Context->preference('DefaultPatronSearchFields') || 'surname,firstname,othernames,cardnumber,userid',
87
        standard => C4::Context->preference('DefaultPatronSearchFields') || 'surname,firstname,othernames,cardnumber,userid',
88
        surname => 'surname',
89
        email => 'email,emailpro,B_email',
88
        email => 'email,emailpro,B_email',
90
        borrowernumber => 'borrowernumber',
89
        borrowernumber => 'borrowernumber',
91
        userid => 'userid',
92
        phone => 'phone,phonepro,B_phone,altcontactphone,mobile',
90
        phone => 'phone,phonepro,B_phone,altcontactphone,mobile',
93
        address => 'streetnumber,streettype,address,address2,city,state,zipcode,country',
91
        address => 'streetnumber,streettype,address,address2,city,state,zipcode,country',
94
        dateofbirth => 'dateofbirth',
95
        sort1 => 'sort1',
96
        sort2 => 'sort2',
97
    };
92
    };
98
93
99
    # * is replaced with % for sql
94
    # * is replaced with % for sql
Lines 124-134 sub search { Link Here
124
        }
119
        }
125
120
126
        my @where_strs_or;
121
        my @where_strs_or;
127
        for my $searchfield ( split /,/, $searchfields->{$searchfieldstype} ) {
122
        if ( defined $searchfields->{$searchfieldstype} ) {
128
            push @where_strs_or, "borrowers." . $dbh->quote_identifier($searchfield) . " LIKE ?";
123
            for my $searchfield ( split /,/, $searchfields->{$searchfieldstype} ) {
124
                push @where_strs_or, "borrowers." . $dbh->quote_identifier($searchfield) . " LIKE ?";
125
                push @where_args, $term;
126
            }
127
        } else {
128
            push @where_strs_or, "borrowers." . $dbh->quote_identifier($searchfieldstype) . " LIKE ?";
129
            push @where_args, $term;
129
            push @where_args, $term;
130
        }
130
        }
131
131
132
132
        if ( $searchfieldstype eq 'standard' and C4::Context->preference('ExtendedPatronAttributes') and $searchmember ) {
133
        if ( $searchfieldstype eq 'standard' and C4::Context->preference('ExtendedPatronAttributes') and $searchmember ) {
133
            my $matching_borrowernumbers = C4::Members::Attributes::SearchIdMatchingAttribute($searchmember);
134
            my $matching_borrowernumbers = C4::Members::Attributes::SearchIdMatchingAttribute($searchmember);
134
135
(-)a/installer/data/mysql/atomicupdate/bug17374_update_DefaultPatronSearchFields_description.perl (+7 lines)
Line 0 Link Here
1
$DBversion = 'XXX';  # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
3
    $dbh->do( "UPDATE systempreferences SET  explanation = 'Comma separated list defining the default fields to be used during a patron search using the \"standard\" option. If empty Koha will default to \"surname,firstname,othernames,cardnumber,userid\". Additional fields added to this preference will be added as search options in the dropdown menu on the patron search page.' WHERE variable='DefaultPatronSearchFields' " );
4
5
    SetVersion( $DBversion );
6
    print "Upgrade to $DBversion done (Bug 17374 - update description of DefaultPatronSearchFields)\n";
7
}
(-)a/installer/data/mysql/sysprefs.sql (-1 / +1 lines)
Lines 147-153 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
147
('DefaultLongOverdueChargeValue', '', NULL, "Charge a lost item to the borrower's account when the LOST value of the item changes to n.", 'integer'),
147
('DefaultLongOverdueChargeValue', '', NULL, "Charge a lost item to the borrower's account when the LOST value of the item changes to n.", 'integer'),
148
('DefaultLongOverdueDays', '', NULL, "Set the LOST value of an item when the item has been overdue for more than n days.", 'integer'),
148
('DefaultLongOverdueDays', '', NULL, "Set the LOST value of an item when the item has been overdue for more than n days.", 'integer'),
149
('DefaultLongOverdueLostValue', '', NULL, "Set the LOST value of an item to n when the item has been overdue for more than defaultlongoverduedays days.", 'integer'),
149
('DefaultLongOverdueLostValue', '', NULL, "Set the LOST value of an item to n when the item has been overdue for more than defaultlongoverduedays days.", 'integer'),
150
('DefaultPatronSearchFields',    'surname,firstname,othernames,cardnumber,userid',NULL,'Comma separated list defining the default fields to be used during a patron search','free'),
150
('DefaultPatronSearchFields',    'surname,firstname,othernames,cardnumber,userid',NULL,'Comma separated list defining the default fields to be used during a patron search using the "standard" option. If empty Koha will default to "surname,firstname,othernames,cardnumber,userid". Additional fields added to this preference will be added as search options in the dropdown menu on the patron search page.','free'),
151
('defaultSortField','relevance','relevance|popularity|call_number|pubdate|acqdate|title|author','Specify the default field used for sorting','Choice'),
151
('defaultSortField','relevance','relevance|popularity|call_number|pubdate|acqdate|title|author','Specify the default field used for sorting','Choice'),
152
('defaultSortOrder','dsc','asc|dsc|az|za','Specify the default sort order','Choice'),
152
('defaultSortOrder','dsc','asc|dsc|az|za','Specify the default sort order','Choice'),
153
('DefaultToLoggedInLibraryCircRules',  '0', NULL ,  'If enabled, circ rules editor will default to the logged in library''s rules, rather than the ''all libraries'' rules.',  'YesNo'),
153
('DefaultToLoggedInLibraryCircRules',  '0', NULL ,  'If enabled, circ rules editor will default to the logged in library''s rules, rather than the ''all libraries'' rules.',  'YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc (-50 / +14 lines)
Lines 1-7 Link Here
1
[% USE Koha %]
1
[% USE Koha %]
2
[% USE Branches %]
2
[% USE Branches %]
3
[% USE Categories %]
3
[% USE Categories %]
4
[% USE raw %]
4
[% PROCESS 'html_helpers.inc' %]
5
[% PROCESS 'html_helpers.inc' %]
6
[% PROCESS 'patronfields.inc' %]
5
<div class="gradient">
7
<div class="gradient">
6
<h1 id="logo"><a href="/cgi-bin/koha/mainpage.pl">[% LibraryName | html %]</a></h1><!-- Begin Patrons Resident Search Box -->
8
<h1 id="logo"><a href="/cgi-bin/koha/mainpage.pl">[% LibraryName | html %]</a></h1><!-- Begin Patrons Resident Search Box -->
7
<div id="header_search">
9
<div id="header_search">
Lines 17-78 Link Here
17
    </div>
19
    </div>
18
20
19
21
22
20
    <div id="filters">
23
    <div id="filters">
21
        <p><label for="searchfieldstype">Search fields:</label>
24
        <p><label for="searchfieldstype">Search fields:</label>
22
            <select name="searchfieldstype" id="searchfieldstype">
25
            <select name="searchfieldstype" id="searchfieldstype">
23
              [% IF searchfieldstype == "standard" %]
26
              [% pref_fields = Koha.Preference('DefaultPatronSearchFields').split(',') %]
24
                <option selected="selected" value='standard'>Standard</option>
27
              [% default_fields = [ 'standard', 'surname', 'cardnumber', 'email', 'borrowernumber', 'userid', 'phone', 'address', 'dateofbirth', 'sort1', 'sort2' ] %]
25
              [% ELSE %]
28
              [% search_options = default_fields.merge(pref_fields).unique %]
26
                <option value='standard'>Standard</option>
29
              [% FOREACH s_o IN search_options %]
27
              [% END %]
30
                  [% display_name = PROCESS patron_fields name=s_o %]
28
              [% IF searchfieldstype == "surname" %]
31
                  [% NEXT IF display_name.length == 5 %]
29
                <option selected="selected" value='surname'>Surname</option>
32
                  [% IF searchfieldstype == s_o %]
30
              [% ELSE %]
33
                      <option selected="selected" value=[% s_o | html %]>[% display_name | $raw %]</option>
31
                <option value='surname'>Surname</option>
34
                  [% ELSE %]
32
              [% END %]
35
                      <option value=[% s_o | html %]>[% display_name | $raw %]</option>
33
              [% IF searchfieldstype == "email" %]
36
                  [% END %]
34
                <option selected="selected" value='email'>Email</option>
35
              [% ELSE %]
36
                <option value='email'>Email</option>
37
              [% END %]
38
              [% IF searchfieldstype == "borrowernumber" %]
39
                <option selected="selected" value='borrowernumber'>Borrower number</option>
40
              [% ELSE %]
41
                <option value='borrowernumber'>Borrower number</option>
42
              [% END %]
43
              [% IF searchfieldstype == "userid" %]
44
                <option selected="selected" value='userid'>Username</option>
45
              [% ELSE %]
46
                <option value='userid'>Username</option>
47
              [% END %]
48
              [% IF searchfieldstype == "phone" %]
49
                <option selected="selected" value='phone'>Phone number</option>
50
              [% ELSE %]
51
                <option value='phone'>Phone number</option>
52
              [% END %]
53
              [% IF searchfieldstype == "address" %]
54
                <option selected="selected" value='address'>Street address</option>
55
              [% ELSE %]
56
                <option value='address'>Street address</option>
57
              [% END %]
58
              [% IF searchfieldstype == "dateofbirth" %]
59
                <option selected="selected" value='dateofbirth'>Date of birth</option>
60
              [% ELSE %]
61
                <option value='dateofbirth'>Date of birth</option>
62
              [% END %]
63
              [% IF searchfieldstype == "sort1" %]
64
                <option selected="selected" value='sort1'>Sort field 1</option>
65
              [% ELSE %]
66
                <option value='sort1'>Sort field 1</option>
67
              [% END %]
68
              [% IF searchfieldstype == "sort2" %]
69
                <option selected="selected" value='sort2'>Sort field 2</option>
70
              [% ELSE %]
71
                <option value='sort2'>Sort field 2</option>
72
              [% END %]
37
              [% END %]
73
            </select>
38
            </select>
74
        </p>
39
        </p>
75
76
        <p>
40
        <p>
77
            <label for="searchtype">Search type:</label>
41
            <label for="searchtype">Search type:</label>
78
            <select name="searchtype" id="searchtype">
42
            <select name="searchtype" id="searchtype">
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patronfields.inc (+75 lines)
Line 0 Link Here
1
[%- BLOCK patron_fields -%]
2
     [%- SWITCH name -%]
3
     [%- CASE 'standard' -%]<span>Standard</span>
4
     [%- CASE 'borrowernumber' -%]<span>Borrower number</span>
5
     [%- CASE 'cardnumber' -%]<span>Card number</span>
6
     [%- CASE 'surname' -%]<span>Surname</span>
7
     [%- CASE 'firstname' -%]<span>First name</span>
8
     [%- CASE 'title' -%]<span>Title</span>
9
     [%- CASE 'othernames' -%]<span>Other names</span>
10
     [%- CASE 'initials' -%]<span>Initials</span>
11
     [%- CASE 'streetnumber' -%]<span>Street number</span>
12
     [%- CASE 'streettype' -%]<span>Street type</span>
13
     [%- CASE 'address' -%]<span>Address</span>
14
     [%- CASE 'address2' -%]<span>Address line 2</span>
15
     [%- CASE 'city' -%]<span>City</span>
16
     [%- CASE 'state' -%]<span>State</span>
17
     [%- CASE 'zipcode' -%]<span>Zip code</span>
18
     [%- CASE 'country' -%]<span>Country</span>
19
     [%- CASE 'email' -%]<span>Email</span>
20
     [%- CASE 'phone' -%]<span>Phone</span>
21
     [%- CASE 'mobile' -%]<span>Mobile phone</span>
22
     [%- CASE 'fax' -%]<span>Fax</span>
23
     [%- CASE 'emailpro' -%]<span>Secondary email</span>
24
     [%- CASE 'phonepro' -%]<span>Secondary phone</span>
25
     [%- CASE 'B_streetnumber' -%]<span>Alternate street number</span>
26
     [%- CASE 'B_streettype' -%]<span>Alternate street type</span>
27
     [%- CASE 'B_address' -%]<span>Alternate address</span>
28
     [%- CASE 'B_address2' -%]<span>Alternate address line 2</span>
29
     [%- CASE 'B_city' -%]<span>Alternate city</span>
30
     [%- CASE 'B_state' -%]<span>Alternate state</span>
31
     [%- CASE 'B_zipcode' -%]<span>Alternate zip code</span>
32
     [%- CASE 'B_country' -%]<span>Alternate Country</span>
33
     [%- CASE 'B_email' -%]<span>Alternate email</span>
34
     [%- CASE 'B_phone' -%]<span>Alternate phone</span>
35
     [%- CASE 'dateofbirth' -%]<span>Date of birth</span>
36
     [%- CASE 'branchcode' -%]<span>Branch code</span>
37
     [%- CASE 'categorycode' -%]<span>Category code</span>
38
     [%- CASE 'dateenrolled' -%]<span>Registration date</span>
39
     [%- CASE 'dateexpiry' -%]<span>Expiration date</span>
40
     [%- CASE 'gonenoaddress' -%]<span>Gone no address</span>
41
     [%- CASE 'lost' -%]<span>Lost card</span>
42
     [%- CASE 'debarred' -%]<span>Restricted</span>
43
     [%- CASE 'debarredcomment' -%]<span>Restriction reason</span>
44
     [%- CASE 'contactname' -%]<span>Guarantor surname</span>
45
     [%- CASE 'contactfirstname' -%]<span>Guarantor firstname</span>
46
     [%- CASE 'contacttitle' -%]<span>Guarantor title</span>
47
     [%- CASE 'guarantorid' -%]<span>Guarantor ID</span>
48
     [%- CASE 'borrowernotes' -%]<span>Circulation Note</span>
49
     [%- CASE 'relationship' -%]<span>Guarantor relationship</span>
50
     [%- CASE 'sex' -%]<span>Sex</span>
51
     [%- CASE 'flags' -%]<span>Permissions (code)</span>
52
     [%- CASE 'userid' -%]<span>User name</span>
53
     [%- CASE 'opacnote' -%]<span>OPAC note</span>
54
     [%- CASE 'contactnote' -%]<span>Contact note</span>
55
     [%- CASE 'sort1' -%]<span>Sort field 1</span>
56
     [%- CASE 'sort2' -%]<span>Sort field 2</span>
57
     [%- CASE 'altcontactfirstname' -%]<span>Alternate contact first name</span>
58
     [%- CASE 'altcontactsurname' -%]<span>Alternate contact surname</span>
59
     [%- CASE 'altcontactaddress1' -%]<span>Alternate contact address</span>
60
     [%- CASE 'altcontactaddress2' -%]<span>Alternate contact address line 2</span>
61
     [%- CASE 'altcontactaddress3' -%]<span>Alternate contact city</span>
62
     [%- CASE 'altcontactstate' -%]<span>Alternate contact state</span>
63
     [%- CASE 'altcontactzipcode' -%]<span>Alternate contact zip code</span>
64
     [%- CASE 'altcontactcountry' -%]<span>Alternate contact country</span>
65
     [%- CASE 'altcontactphone' -%]<span>Alternate contact phone</span>
66
     [%- CASE 'smsalertnumber' -%]<span>SMS alert number</span>
67
     [%- CASE 'sms_provider_id' -%]<span>SMS provider</span>
68
     [%- CASE 'privacy' -%]<span>Privacy (code)</span>
69
     [%- CASE 'privacy_guarantor_checkouts' -%]<span>Guarantor can view checkouts</span>
70
     [%- CASE 'updated_on' -%]<span>Last updated</span>
71
     [%- CASE 'lastseen' -%]<span>Last seen</span>
72
     [%- CASE 'checkprevcheckout' -%]<span>Check previous checkout</span>
73
     [%- CASE DEFAULT -%]
74
     [%- END -%]
75
[%- END -%]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (-1 / +1 lines)
Lines 129-135 Patrons: Link Here
129
     -
129
     -
130
         - pref: DefaultPatronSearchFields
130
         - pref: DefaultPatronSearchFields
131
           class: multi
131
           class: multi
132
         - "Comma separated list defining the default fields to be used during a patron search"
132
         - "Comma separated list defining the default fields to be used during a patron search using the \"standard\" option. If empty Koha will default to \"surname,firstname,othernames,cardnumber,userid\". Additional fields added to this preference will be added as search options in the dropdown menu on the patron search page."
133
     -
133
     -
134
         - pref: PatronQuickAddFields
134
         - pref: PatronQuickAddFields
135
           class: multi
135
           class: multi
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt (-51 / +13 lines)
Lines 5-10 Link Here
5
[% USE Branches %]
5
[% USE Branches %]
6
[% USE Categories %]
6
[% USE Categories %]
7
[% SET footerjs = 1 %]
7
[% SET footerjs = 1 %]
8
[% PROCESS 'patronfields.inc' %]
8
[% INCLUDE 'doc-head-open.inc' %]
9
[% INCLUDE 'doc-head-open.inc' %]
9
<title>Koha &rsaquo; Patrons [% IF ( searching ) %]&rsaquo; Search results[% END %]</title>
10
<title>Koha &rsaquo; Patrons [% IF ( searching ) %]&rsaquo; Search results[% END %]</title>
10
[% INCLUDE 'doc-head-close.inc' %]
11
[% INCLUDE 'doc-head-close.inc' %]
Lines 127-182 Link Here
127
                      <li>
128
                      <li>
128
                        <label for="searchfieldstype_filter">Search fields:</label>
129
                        <label for="searchfieldstype_filter">Search fields:</label>
129
                        <select name="searchfieldstype" id="searchfieldstype_filter">
130
                        <select name="searchfieldstype" id="searchfieldstype_filter">
130
                          [% IF searchfieldstype == "standard" %]
131
                            [% pref_fields = Koha.Preference('DefaultPatronSearchFields').split(',') %]
131
                            <option selected="selected" value='standard'>Standard</option>
132
                            [% default_fields = [ 'standard', 'surname', 'cardnumber', 'email', 'borrowernumber', 'userid', 'phone', 'address', 'dateofbirth', 'sort1', 'sort2' ] %]
132
                          [% ELSE %]
133
                            [% search_options = default_fields.merge(pref_fields).unique %]
133
                            <option value='standard'>Standard</option>
134
                            [% FOREACH s_o IN search_options %]
134
                          [% END %]
135
                                [% display_name = PROCESS patron_fields name=s_o %]
135
                          [% IF searchfieldstype == "surname" %]
136
                                [% NEXT IF display_name.length == 5 %]
136
                            <option selected="selected" value='surname'>Surname</option>
137
                                [% IF searchfieldstype == s_o %]
137
                          [% ELSE %]
138
                                    <option selected="selected" value=[% s_o | html %]>[% display_name | $raw %]</option>
138
                            <option value='surname'>Surname</option>
139
                                [% ELSE %]
139
                          [% END %]
140
                                    <option value=[% s_o | html %]>[% display_name | $raw %]</option>
140
                          [% IF searchfieldstype == "email" %]
141
                                [% END %]
141
                            <option selected="selected" value='email'>Email</option>
142
                            [% END %]
142
                          [% ELSE %]
143
                            <option value='email'>Email</option>
144
                          [% END %]
145
                          [% IF searchfieldstype == "borrowernumber" %]
146
                            <option selected="selected" value='borrowernumber'>Borrower number</option>
147
                          [% ELSE %]
148
                            <option value='borrowernumber'>Borrower number</option>
149
                          [% END %]
150
                          [% IF searchfieldstype == "userid" %]
151
                            <option selected="selected" value='userid'>Username</option>
152
                          [% ELSE %]
153
                            <option value='userid'>Username</option>
154
                          [% END %]
155
                          [% IF searchfieldstype == "phone" %]
156
                            <option selected="selected" value='phone'>Phone number</option>
157
                          [% ELSE %]
158
                            <option value='phone'>Phone number</option>
159
                          [% END %]
160
                          [% IF searchfieldstype == "address" %]
161
                            <option selected="selected" value='address'>Street address</option>
162
                          [% ELSE %]
163
                            <option value='address'>Street address</option>
164
                          [% END %]
165
                          [% IF searchfieldstype == "dateofbirth" %]
166
                            <option selected="selected" value='dateofbirth'>Date of birth</option>
167
                          [% ELSE %]
168
                            <option value='dateofbirth'>Date of birth</option>
169
                          [% END %]
170
                          [% IF searchfieldstype == "sort1" %]
171
                            <option selected="selected" value='sort1'>Sort field 1</option>
172
                          [% ELSE %]
173
                            <option value='sort1'>Sort field 1</option>
174
                          [% END %]
175
                          [% IF searchfieldstype == "sort2" %]
176
                            <option selected="selected" value='sort2'>Sort field 2</option>
177
                          [% ELSE %]
178
                            <option value='sort2'>Sort field 2</option>
179
                          [% END %]
180
                        </select>
143
                        </select>
181
                      </li>
144
                      </li>
182
                      <li>
145
                      <li>
183
- 

Return to bug 17374