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

(-)a/Koha/Database/Columns.pm (+1 lines)
Lines 174-179 sub columns { Link Here
174
            "password"                    => __("Password"),
174
            "password"                    => __("Password"),
175
            "phone"                       => __("Primary phone"),
175
            "phone"                       => __("Primary phone"),
176
            "phonepro"                    => __("Secondary phone"),
176
            "phonepro"                    => __("Secondary phone"),
177
            "preferred_name"              => __("Preferred_name"),
177
            "primary_contact_method"      => __("Primary contact method"),
178
            "primary_contact_method"      => __("Primary contact method"),
178
            "privacy_guarantor_checkouts" => __("Show checkouts to guarantor"),
179
            "privacy_guarantor_checkouts" => __("Show checkouts to guarantor"),
179
            "privacy_guarantor_fines"     => __("Show fines to guarantor"),
180
            "privacy_guarantor_fines"     => __("Show fines to guarantor"),
(-)a/Koha/Patron.pm (+5 lines)
Lines 228-233 sub store { Link Here
228
            $self->surname( uc( $self->surname ) )
228
            $self->surname( uc( $self->surname ) )
229
                if C4::Context->preference("uppercasesurnames");
229
                if C4::Context->preference("uppercasesurnames");
230
230
231
            # Add preferred name unless specified
232
            unless ( $self->preferred_name ) {
233
                $self->preferred_name( $self->firstname );
234
            }
235
231
            $self->relationship(undef)    # We do not want to store an empty string in this field
236
            $self->relationship(undef)    # We do not want to store an empty string in this field
232
                if defined $self->relationship
237
                if defined $self->relationship
233
                and $self->relationship eq "";
238
                and $self->relationship eq "";
(-)a/Koha/Patron/Modification.pm (+3 lines)
Lines 103-108 sub approve { Link Here
103
        delete $data->{$key};
103
        delete $data->{$key};
104
    }
104
    }
105
105
106
    my $unwanted = C4::Context->preference('PatronSelfModificationBorrowerUnwantedField');
107
    $data->{preferred_name} = $data->{firstname} if ( $unwanted =~ 'preferred_name' && defined $data->{firstname} );
108
106
    $patron->set($data);
109
    $patron->set($data);
107
110
108
    # Take care of extended attributes
111
    # Take care of extended attributes
(-)a/api/v1/swagger/paths/patrons.yaml (+5 lines)
Lines 29-34 Link Here
29
        description: Case insensitive search on firstname
29
        description: Case insensitive search on firstname
30
        required: false
30
        required: false
31
        type: string
31
        type: string
32
      - name: preferred_name
33
        in: query
34
        description: Case insensitive search on preferred name
35
        required: false
36
        type: string
32
      - name: title
37
      - name: title
33
        in: query
38
        in: query
34
        description: Case insensitive search on title
39
        description: Case insensitive search on title
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/js-patron-format.inc (-2 / +3 lines)
Lines 20-25 Link Here
20
20
21
            var name;
21
            var name;
22
            var firstname   = escape_str(patron.firstname);
22
            var firstname   = escape_str(patron.firstname);
23
            var preferred_name = escape_str(patron.preferred_name);
23
            var surname     = escape_str(patron.surname);
24
            var surname     = escape_str(patron.surname);
24
25
25
            if ( patron.middle_name != null && patron.middle_name != '' ) {
26
            if ( patron.middle_name != null && patron.middle_name != '' ) {
Lines 30-39 Link Here
30
                firstname += ' (' + escape_str(patron.other_name) + ')';
31
                firstname += ' (' + escape_str(patron.other_name) + ')';
31
            }
32
            }
32
            if ( config && config.invert_name ) {
33
            if ( config && config.invert_name ) {
33
                name = surname + ( firstname ? ', ' + firstname : '' );
34
                name = surname + ( preferred_name ? ', ' + preferred_name : '' );
34
            }
35
            }
35
            else {
36
            else {
36
                name = firstname + ' ' + surname;
37
                name = preferred_name + ' ' + surname;
37
            }
38
            }
38
39
39
            if ( name.replace(' ', '').length == 0 ) {
40
            if ( name.replace(' ', '').length == 0 ) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc (-2 / +2 lines)
Lines 536-542 Link Here
536
                            }
536
                            }
537
                            [% CASE 'name-address' %]
537
                            [% CASE 'name-address' %]
538
                            {
538
                            {
539
                                "data": "me.surname:me.firstname:me.middle_name:me.othernames:me.street_number:me.address:me.address2:me.city:me.state:me.postal_code:me.country",
539
                                "data": "me.surname:me.preferred_name:me.firstname:me.middle_name:me.othernames:me.street_number:me.address:me.address2:me.city:me.state:me.postal_code:me.country",
540
                                "searchable": true,
540
                                "searchable": true,
541
                                "orderable": true,
541
                                "orderable": true,
542
                                "render": function( data, type, row, meta ) {
542
                                "render": function( data, type, row, meta ) {
Lines 561-567 Link Here
561
                            }
561
                            }
562
                            [% CASE 'name' %]
562
                            [% CASE 'name' %]
563
                            {
563
                            {
564
                                "data": "me.surname:me.firstname:me.middle_name:me.othernames",
564
                                "data": "me.surname:me.preferred_name:me.firstname:me.middle_name:me.othernames",
565
                                "searchable": true,
565
                                "searchable": true,
566
                                "orderable": true,
566
                                "orderable": true,
567
                                "render": function( data, type, row, meta ) {
567
                                "render": function( data, type, row, meta ) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-title.inc (-2 / +5 lines)
Lines 7-12 Link Here
7
    [%- SET data.surname        = patron.surname -%]
7
    [%- SET data.surname        = patron.surname -%]
8
    [%- SET data.othernames     = patron.othernames -%]
8
    [%- SET data.othernames     = patron.othernames -%]
9
    [%- SET data.firstname      = patron.firstname -%]
9
    [%- SET data.firstname      = patron.firstname -%]
10
    [%- SET data.preferred_name = patron.preferred_name -%]
10
    [%- SET data.middle_name    = patron.middle_name -%]
11
    [%- SET data.middle_name    = patron.middle_name -%]
11
    [%- SET data.cardnumber     = patron.cardnumber -%]
12
    [%- SET data.cardnumber     = patron.cardnumber -%]
12
    [%- SET data.borrowernumber = patron.borrowernumber -%]
13
    [%- SET data.borrowernumber = patron.borrowernumber -%]
Lines 16-21 Link Here
16
    [%- SET data.surname        = borrower.surname -%]
17
    [%- SET data.surname        = borrower.surname -%]
17
    [%- SET data.othernames     = borrower.othernames -%]
18
    [%- SET data.othernames     = borrower.othernames -%]
18
    [%- SET data.firstname      = borrower.firstname -%]
19
    [%- SET data.firstname      = borrower.firstname -%]
20
    [%- SET data.preferred_name = borrower.preferred_name -%]
19
    [%- SET data.middle_name    = borrower.middle_name -%]
21
    [%- SET data.middle_name    = borrower.middle_name -%]
20
    [%- SET data.cardnumber     = borrower.cardnumber -%]
22
    [%- SET data.cardnumber     = borrower.cardnumber -%]
21
    [%- SET data.borrowernumber = borrower.borrowernumber -%]
23
    [%- SET data.borrowernumber = borrower.borrowernumber -%]
Lines 25-30 Link Here
25
    [%- SET data.surname        = surname -%]
27
    [%- SET data.surname        = surname -%]
26
    [%- SET data.othernames     = othernames -%]
28
    [%- SET data.othernames     = othernames -%]
27
    [%- SET data.firstname      = firstname -%]
29
    [%- SET data.firstname      = firstname -%]
30
    [%- SET data.preferred_name = preferred_name -%]
28
    [%- SET data.middle_name    = middle_name -%]
31
    [%- SET data.middle_name    = middle_name -%]
29
    [%- SET data.cardnumber     = cardnumber -%]
32
    [%- SET data.cardnumber     = cardnumber -%]
30
    [%- SET data.borrowernumber = borrowernumber -%]
33
    [%- SET data.borrowernumber = borrowernumber -%]
Lines 66-74 Link Here
66
    [%- IF data.category_type == 'I' -%]
69
    [%- IF data.category_type == 'I' -%]
67
        [%- data.surname | html -%] [%- IF data.othernames -%] ([%- data.othernames | html -%])[%- END -%]
70
        [%- data.surname | html -%] [%- IF data.othernames -%] ([%- data.othernames | html -%])[%- END -%]
68
    [%- ELSIF invert_name -%]
71
    [%- ELSIF invert_name -%]
69
        [%- data.title | $raw -%][%- data.surname | html -%][%- IF ( data.firstname ) -%], [% data.firstname | html -%][%- END -%][%- IF data.middle_name -%] [% data.middle_name | html -%][%- END -%][%- IF data.othernames -%] ([%- data.othernames | html -%])[%- END -%]
72
        [%- data.title | $raw -%][%- data.surname | html -%][%- IF ( data.preferred_name ) -%], [% data.preferred_name | html -%][%- END -%][%- IF data.middle_name -%] [% data.middle_name | html -%][%- END -%][%- IF data.othernames -%] ([%- data.othernames | html -%])[%- END -%]
70
    [%- ELSE -%]
73
    [%- ELSE -%]
71
        [%- data.title | $raw -%][%- data.firstname | html %][%- IF data.middle_name -%] [% data.middle_name | html -%][%- END -%][%- IF data.othernames -%] ([%- data.othernames | html -%]) [%- END -%] [% data.surname | html -%]
74
        [%- data.title | $raw -%][%- data.preferred_name | html %][%- IF data.middle_name -%] [% data.middle_name | html -%][%- END -%][%- IF data.othernames -%] ([%- data.othernames | html -%]) [%- END -%] [% data.surname | html -%]
72
    [%- END -%]
75
    [%- END -%]
73
    [%- IF display_cardnumber AND data.cardnumber -%] ([%- data.cardnumber | html -%])[%- END -%]
76
    [%- IF display_cardnumber AND data.cardnumber -%] ([%- data.cardnumber | html -%])[%- END -%]
74
[%- ELSIF display_cardnumber -%]
77
[%- ELSIF display_cardnumber -%]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patronfields.inc (-1 / +2 lines)
Lines 8-13 Link Here
8
    [%- CASE 'cardnumber' -%][% t("Card number") | html %]
8
    [%- CASE 'cardnumber' -%][% t("Card number") | html %]
9
    [%- CASE 'surname' -%][% t("Surname") | html %]
9
    [%- CASE 'surname' -%][% t("Surname") | html %]
10
    [%- CASE 'firstname' -%][% t("First name") | html %]
10
    [%- CASE 'firstname' -%][% t("First name") | html %]
11
    [%- CASE 'preferred_name' -%][% t("Preferred name") | html %]
11
    [%- CASE 'middle_name' -%][% t("Middle name") | html %]
12
    [%- CASE 'middle_name' -%][% t("Middle name") | html %]
12
    [%- CASE 'title' -%][% t("Salutation") | html %]
13
    [%- CASE 'title' -%][% t("Salutation") | html %]
13
    [%- CASE 'othernames' -%][% t("Other name") | html %]
14
    [%- CASE 'othernames' -%][% t("Other name") | html %]
Lines 86-92 Link Here
86
        <label for="searchfieldstype_filter">Search field:</label>
87
        <label for="searchfieldstype_filter">Search field:</label>
87
        <select name="searchfieldstype" class="searchfieldstype_filter">
88
        <select name="searchfieldstype" class="searchfieldstype_filter">
88
    [% END %]
89
    [% END %]
89
        [% SET standard = Koha.Preference('DefaultPatronSearchFields') || 'firstname|middle_name|surname|othernames|cardnumber|userid' %]
90
        [% SET standard = Koha.Preference('DefaultPatronSearchFields') || 'firstname|preferred_name|middle_name|surname|othernames|cardnumber|userid' %]
90
        [%# Above is needed for adding fields from the DefaultPatronSearchFields preference to the dropdowns %]
91
        [%# Above is needed for adding fields from the DefaultPatronSearchFields preference to the dropdowns %]
91
        [% default_fields = [ 'standard', 'surname', 'cardnumber', 'all_emails', 'borrowernumber', 'userid', 'all_phones', 'full_address', 'dateofbirth', 'sort1', 'sort2' ] %]
92
        [% default_fields = [ 'standard', 'surname', 'cardnumber', 'all_emails', 'borrowernumber', 'userid', 'all_phones', 'full_address', 'dateofbirth', 'sort1', 'sort2' ] %]
92
        [% search_options = default_fields.merge(standard.split('\|')).unique %]
93
        [% search_options = default_fields.merge(standard.split('\|')).unique %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (-1 / +1 lines)
Lines 67-73 Patrons: Link Here
67
           type: modalselect
67
           type: modalselect
68
           source: borrowers
68
           source: borrowers
69
           exclusions: anonymized|auth_method|autorenew_checkouts|date_renewed|dateenrolled|dateexpiry|lang|lastseen|login_attempts|overdrive_auth_token|password|password_expiration_date|primary_contact_method|gonenoaddress|lost|debarred|debarredcomment|branchcode|categorycode|flags|guarantorid|relationship|privacy|privacy_guarantor_checkouts|privacy_guarantor_fines|pronouns|secret|sms_provider_id|updated_on|checkprevcheckout
69
           exclusions: anonymized|auth_method|autorenew_checkouts|date_renewed|dateenrolled|dateexpiry|lang|lastseen|login_attempts|overdrive_auth_token|password|password_expiration_date|primary_contact_method|gonenoaddress|lost|debarred|debarredcomment|branchcode|categorycode|flags|guarantorid|relationship|privacy|privacy_guarantor_checkouts|privacy_guarantor_fines|pronouns|secret|sms_provider_id|updated_on|checkprevcheckout
70
         - "If empty Koha will default to \"firstname|middle_name|surname|othernames|cardnumber|userid\". Additional fields added to this preference will be added as search options in the dropdown menu on the patron search page."
70
         - "If empty Koha will default to \"firstname|preferred_name|middle_name|surname|othernames|cardnumber|userid\". Additional fields added to this preference will be added as search options in the dropdown menu on the patron search page."
71
     -
71
     -
72
         - pref: DefaultPatronSearchMethod
72
         - pref: DefaultPatronSearchMethod
73
           choices:
73
           choices:
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (-1 / +16 lines)
Lines 296-302 legend.collapsed i.fa.fa-caret-down::before { Link Here
296
                            [% END %]
296
                            [% END %]
297
297
298
                            [% IF ( step_1 ) %]
298
                            [% IF ( step_1 ) %]
299
                                [% UNLESS notitle && nosurname && nofirstname && nomiddle_name && nodateofbirth && noinitials && noothernames &&nosex && nopronouns %]
299
                                [% UNLESS notitle && nosurname && nofirstname && nopreferred_name && nomiddle_name && nodateofbirth && noinitials && noothernames &&nosex && nopronouns %]
300
                                    <fieldset class="rows" id="memberentry_identity">
300
                                    <fieldset class="rows" id="memberentry_identity">
301
                                        <legend class="expanded" id="identity_lgd">
301
                                        <legend class="expanded" id="identity_lgd">
302
                                            <i class="fa fa-caret-down" title="Collapse this section"></i>
302
                                            <i class="fa fa-caret-down" title="Collapse this section"></i>
Lines 373-378 legend.collapsed i.fa.fa-caret-down::before { Link Here
373
                                                        [% END %]
373
                                                        [% END %]
374
                                                    </li>
374
                                                    </li>
375
                                                [% END #/UNLESS nofirstname %]
375
                                                [% END #/UNLESS nofirstname %]
376
                                                [% UNLESS nopreferred_name %]
377
                                                    <li>
378
                                                        [% IF ( mandatorypreferred_name ) %]
379
                                                            <label for="preferred_name" class="required">
380
                                                        [% ELSE %]
381
                                                            <label for="preferred_name">
382
                                                        [% END %]
383
                                                            Preferred name:
384
                                                        </label>
385
                                                        <input type="text" id="preferred_name" name="preferred_name" size="20"  value="[% borrower_data.preferred_name | html UNLESS opduplicate %]" />
386
                                                        [% IF ( mandatorypreferred_name ) %]
387
                                                            <span class="required">Required</span>
388
                                                        [% END %]
389
                                                    </li>
390
                                                [% END #/UNLESS nopreferred_name %]
376
                                                [% UNLESS nomiddle_name %]
391
                                                [% UNLESS nomiddle_name %]
377
                                                    <li>
392
                                                    <li>
378
                                                        [% IF ( mandatorymiddle_name ) %]
393
                                                        [% IF ( mandatorymiddle_name ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/members-update.tt (+1 lines)
Lines 25-30 Link Here
25
[% CASE 'branchcode'          %]<span>Home library (branchcode)</span>
25
[% CASE 'branchcode'          %]<span>Home library (branchcode)</span>
26
[% CASE 'surname'             %]<span>Surname</span>
26
[% CASE 'surname'             %]<span>Surname</span>
27
[% CASE 'firstname'           %]<span>First name</span>
27
[% CASE 'firstname'           %]<span>First name</span>
28
[% CASE 'preferred_name'      %]<span>Preferred name</span>
28
[% CASE 'middle_name'         %]<span>Middle name</span>
29
[% CASE 'middle_name'         %]<span>Middle name</span>
29
[% CASE 'title'               %]<span>Title</span>
30
[% CASE 'title'               %]<span>Title</span>
30
[% CASE 'othernames'          %]<span>Other names</span>
31
[% CASE 'othernames'          %]<span>Other names</span>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (-2 / +8 lines)
Lines 135-140 Link Here
135
135
136
                                <div class="rows">
136
                                <div class="rows">
137
                                    <ol>
137
                                    <ol>
138
                                        [% IF ( patron.preferred_name && patron.firstname ) %]
139
                                            <li id="patron_first_name">
140
                                                <span class="label patron_first_name">First name: </span>
141
                                                [% patron.firstname | html %]
142
                                            </li>
143
                                        [% END %]
138
                                        [% IF ( patron.phone ) %]
144
                                        [% IF ( patron.phone ) %]
139
                                            <li>
145
                                            <li>
140
                                                <span class="label">Primary phone: </span>
146
                                                <span class="label">Primary phone: </span>
Lines 225-231 Link Here
225
                                                        [% IF logged_in_user.can_see_patron_infos( guarantee ) %]
231
                                                        [% IF logged_in_user.can_see_patron_infos( guarantee ) %]
226
                                                            <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantee.borrowernumber | uri %]">[% guarantee.firstname | html %] [% guarantee.surname | html %]</a></li>
232
                                                            <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantee.borrowernumber | uri %]">[% guarantee.firstname | html %] [% guarantee.surname | html %]</a></li>
227
                                                        [% ELSE %]
233
                                                        [% ELSE %]
228
                                                            <li>[% guarantee.firstname | html %] [% guarantee.surname | html %]</li>
234
                                                            <li>[% guarantee.preferred_name | html %] [% guarantee.surname | html %]</li>
229
                                                        [% END %]
235
                                                        [% END %]
230
                                                    [% END %]
236
                                                    [% END %]
231
                                                </ul>
237
                                                </ul>
Lines 241-247 Link Here
241
                                                    [% FOREACH gr IN guarantor_relationships %]
247
                                                    [% FOREACH gr IN guarantor_relationships %]
242
                                                        [% SET guarantor = gr.guarantor %]
248
                                                        [% SET guarantor = gr.guarantor %]
243
                                                        [% IF logged_in_user.can_see_patron_infos( guarantor ) %]
249
                                                        [% IF logged_in_user.can_see_patron_infos( guarantor ) %]
244
                                                            <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantor.id | uri %]">[% guarantor.firstname | html %] [% guarantor.surname | html %][% IF gr.relationship %] ([% gr.relationship | html %])[% END %]</a></li>
250
                                                            <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantor.id | uri %]">[% guarantor.preferred_name | html %] [% guarantor.surname | html %][% IF gr.relationship %] ([% gr.relationship | html %])[% END %]</a></li>
245
                                                        [% END %]
251
                                                        [% END %]
246
                                                    [% END %]
252
                                                    [% END %]
247
                                                    [% IF patron.contactfirstname OR patron.contactname %]
253
                                                    [% IF patron.contactfirstname OR patron.contactname %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js (-1 / +1 lines)
Lines 709-715 function patron_autocomplete(node, options) { Link Here
709
                    (item.link ? '<a href="' + item.link + '">' : "<a>") +
709
                    (item.link ? '<a href="' + item.link + '">' : "<a>") +
710
                    (item.surname ? item.surname.escapeHtml() : "") +
710
                    (item.surname ? item.surname.escapeHtml() : "") +
711
                    ", " +
711
                    ", " +
712
                    (item.firstname ? item.firstname.escapeHtml() : "") +
712
                    (item.preferred_name ? item.preferred_name.escapeHtml() : item.firstname ? item.firstname.escapeHtml() : "") +
713
                    " " +
713
                    " " +
714
                    (item.middle_name ? item.middle_name.escapeHtml() : "") +
714
                    (item.middle_name ? item.middle_name.escapeHtml() : "") +
715
                    " " +
715
                    " " +
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/patron-title.inc (-1 / +1 lines)
Lines 4-8 Link Here
4
    [%- IF patron.title -%]
4
    [%- IF patron.title -%]
5
        <span class="patron-title">[% patron.title | html %]</span>
5
        <span class="patron-title">[% patron.title | html %]</span>
6
    [%- END -%]
6
    [%- END -%]
7
    [% patron.firstname | html %] [% patron.middle_name | html %] [% patron.surname | html %]
7
    [% patron.preferred_name | html %] [% patron.middle_name | html %] [% patron.surname | html %]
8
[%- END -%]
8
[%- END -%]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt (-3 / +12 lines)
Lines 194-200 Link Here
194
                                            Guaranteed by
194
                                            Guaranteed by
195
                                            [% FOREACH gr IN patron.guarantor_relationships %]
195
                                            [% FOREACH gr IN patron.guarantor_relationships %]
196
                                                [% SET g = gr.guarantor %]
196
                                                [% SET g = gr.guarantor %]
197
                                                [% g.firstname | html %] [% g.middle_name | html %] [% g.surname | html %]
197
                                                [% g.preferred_name | html %] [% g.middle_name | html %] [% g.surname | html %]
198
                                                [%- IF ! loop.last %], [% END %]
198
                                                [%- IF ! loop.last %], [% END %]
199
                                            [% END %]
199
                                            [% END %]
200
                                        </span>
200
                                        </span>
Lines 212-218 Link Here
212
                <form method="post" action="/cgi-bin/koha/opac-memberentry.pl" id="memberentry-form" autocomplete="off">
212
                <form method="post" action="/cgi-bin/koha/opac-memberentry.pl" id="memberentry-form" autocomplete="off">
213
                    [% INCLUDE 'csrf-token.inc' %]
213
                    [% INCLUDE 'csrf-token.inc' %]
214
214
215
                [% FOREACH field = ['streetnumber' 'streettype'  'cardnumber' 'branchcode' 'categorycode' 'title' 'surname' 'firstname' 'middle_name' 'dateofbirth' 'initials' 'pronouns' 'othernames' 'address' 'address2' 'city' 'state' 'zipcode' 'country' 'phone' 'phonepro' 'mobile' 'email' 'emailpro' 'fax' 'B_streettype' 'B_streetnumber' 'B_address' 'B_address2' 'B_city' 'B_state' 'B_zipcode' 'B_country' 'B_phone' 'B_email' 'contactnote' 'altcontactsurname' 'altcontactfirstname' 'altcontactaddress1' 'altcontactaddress2' 'altcontactaddress3' 'altcontactstate' 'altcontactzipcode' 'altcontactcountry' 'altcontactphone' 'password' 'lang' ] %]
215
                [% FOREACH field = ['streetnumber' 'streettype'  'cardnumber' 'branchcode' 'categorycode' 'title' 'surname' 'firstname' 'preferred_name' 'middle_name' 'dateofbirth' 'initials' 'pronouns' 'othernames' 'address' 'address2' 'city' 'state' 'zipcode' 'country' 'phone' 'phonepro' 'mobile' 'email' 'emailpro' 'fax' 'B_streettype' 'B_streetnumber' 'B_address' 'B_address2' 'B_city' 'B_state' 'B_zipcode' 'B_country' 'B_phone' 'B_email' 'contactnote' 'altcontactsurname' 'altcontactfirstname' 'altcontactaddress1' 'altcontactaddress2' 'altcontactaddress3' 'altcontactstate' 'altcontactzipcode' 'altcontactcountry' 'altcontactphone' 'password' 'lang' ] %]
216
                    [% IF mandatory.defined( field ) %]
216
                    [% IF mandatory.defined( field ) %]
217
                        [% SET required.$field = 'required' %]
217
                        [% SET required.$field = 'required' %]
218
                    [% END %]
218
                    [% END %]
Lines 328-334 Link Here
328
                    [% END # / defined 'branchcode' %]
328
                    [% END # / defined 'branchcode' %]
329
329
330
                    [%# Following on one line for translatability %]
330
                    [%# Following on one line for translatability %]
331
                    [% UNLESS hidden.defined('title') && hidden.defined('surname') && hidden.defined('firstname') && hidden.defined('middle_name') && hidden.defined('dateofbirth') && hidden.defined('initials') && hidden.defined('pronouns') && hidden.defined('othernames') && hidden.defined('sex') %]
331
                    [% UNLESS hidden.defined('title') && hidden.defined('surname') && hidden.defined('firstname') && hidden.defined('preferred_name') && hidden.defined('middle_name') && hidden.defined('dateofbirth') && hidden.defined('initials') && hidden.defined('pronouns') && hidden.defined('othernames') && hidden.defined('sex') %]
332
                        <div class="row">
332
                        <div class="row">
333
                            <div class="col">
333
                            <div class="col">
334
                                <fieldset class="rows" id="memberentry_identity">
334
                                <fieldset class="rows" id="memberentry_identity">
Lines 380-385 Link Here
380
                                            </li>
380
                                            </li>
381
                                        [% END %]
381
                                        [% END %]
382
382
383
                                        [% UNLESS hidden.defined('preferred_name') %]
384
                                            <li>
385
                                                <label for="borrower_preferred_name" class="[% required.preferred_name | html %]">Preferred name:</label>
386
387
                                                <input type="text" id="borrower_preferred_name" name="borrower_preferred_name" value="[% borrower.preferred_name | html %]" class="[% required.preferred_name | html %]" />
388
                                                <div class="required_label [% required.preferred_name | html %]">Required</div>
389
                                            </li>
390
                                        [% END %]
391
383
                                        [% UNLESS hidden.defined('dateofbirth') %]
392
                                        [% UNLESS hidden.defined('dateofbirth') %]
384
                                            <li>
393
                                            <li>
385
                                                <label for="borrower_dateofbirth" class="[% required.dateofbirth | html %]">Date of birth:</label>
394
                                                <label for="borrower_dateofbirth" class="[% required.dateofbirth | html %]">Date of birth:</label>
(-)a/members/memberentry.pl (+3 lines)
Lines 525-530 if ((!$nok) and $nodouble and ($op eq 'cud-insert' or $op eq 'cud-save')){ Link Here
525
525
526
        $patron = Koha::Patrons->find( $borrowernumber );
526
        $patron = Koha::Patrons->find( $borrowernumber );
527
527
528
        # Ensure preferred name is set even if not passed because of BorrowerUnwantedFields
529
        $newdata{preferred_name} = undef unless defined $newdata{preferred_name};
530
528
        if ($NoUpdateEmail) {
531
        if ($NoUpdateEmail) {
529
            delete $newdata{'email'};
532
            delete $newdata{'email'};
530
            delete $newdata{'emailpro'};
533
            delete $newdata{'emailpro'};
(-)a/opac/opac-memberentry.pl (+3 lines)
Lines 330-335 elsif ( $op eq 'cud-update' ) { Link Here
330
        $template->param( op => 'edit' );
330
        $template->param( op => 'edit' );
331
    }
331
    }
332
    else {
332
    else {
333
        # If preferred name is not included but firstname is then set preferred_name to firstname
334
        $borrower{preferred_name} = $borrower{firstname}
335
            if defined $borrower{firstname} && !defined $borrower{preferred_name};
333
        my %borrower_changes = DelUnchangedFields( $borrowernumber, %borrower );
336
        my %borrower_changes = DelUnchangedFields( $borrowernumber, %borrower );
334
        $borrower_changes{'changed_fields'} = join ',', keys %borrower_changes;
337
        $borrower_changes{'changed_fields'} = join ',', keys %borrower_changes;
335
        my $extended_attributes_changes = FilterUnchangedAttributes( $borrowernumber, $attributes );
338
        my $extended_attributes_changes = FilterUnchangedAttributes( $borrowernumber, $attributes );
(-)a/t/db_dependent/Koha/Patron.t (-1 / +59 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 36;
22
use Test::More tests => 37;
23
use Test::Exception;
23
use Test::Exception;
24
use Test::Warn;
24
use Test::Warn;
25
use Time::Fake;
25
use Time::Fake;
Lines 2620-2622 subtest 'Scrub the note fields' => sub { Link Here
2620
2620
2621
    $schema->storage->txn_rollback;
2621
    $schema->storage->txn_rollback;
2622
};
2622
};
2623
2624
subtest 'preferred_name' => sub {
2625
    plan tests => 6;
2626
2627
    $schema->storage->txn_begin;
2628
2629
    my $tmp_patron      = $builder->build_object( { class => 'Koha::Patrons' } );
2630
    my $patron_data     = $tmp_patron->unblessed;
2631
    $tmp_patron->delete;
2632
    delete $patron_data->{borrowernumber};
2633
    delete $patron_data->{preferred_name};
2634
2635
    my $patron = Koha::Patron->new(
2636
2637
        {
2638
            %$patron_data,
2639
        }
2640
    )->store;
2641
2642
    is( $patron->preferred_name, $patron->firstname, "Preferred name set to first name on creation when not defined");
2643
2644
    $patron->delete;
2645
2646
    $patron_data->{preferred_name} = "";
2647
2648
    $patron = Koha::Patron->new(
2649
2650
        {
2651
            %$patron_data,
2652
        }
2653
    )->store;
2654
2655
    is( $patron->preferred_name, $patron->firstname, "Preferred name set to first name on creation when empty string");
2656
2657
    $patron->delete;
2658
2659
    $patron_data->{preferred_name} = "Preferred";
2660
    $patron_data->{firstname} = "Not Preferred";
2661
2662
    $patron = Koha::Patron->new(
2663
2664
        {
2665
            %$patron_data,
2666
        }
2667
    )->store;
2668
2669
    is( $patron->preferred_name, "Preferred", "Preferred name set when passed on creation");
2670
2671
    $patron->preferred_name("")->store;
2672
    is( $patron->preferred_name, $patron->firstname, "Preferred name set to first name on update when empty string");
2673
2674
    $patron->preferred_name(undef)->store();
2675
    is( $patron->preferred_name, $patron->firstname, "Preferred name set to first name on update when undef");
2676
2677
    $patron->preferred_name("Preferred again")->store();
2678
    is( $patron->preferred_name, "Preferred again", "Preferred name set on update when passed");
2679
2680
};
(-)a/t/db_dependent/api/v1/patrons.t (-3 / +3 lines)
Lines 81-87 subtest 'list() tests' => sub { Link Here
81
81
82
    subtest 'librarian access tests' => sub {
82
    subtest 'librarian access tests' => sub {
83
83
84
        plan tests => 21;
84
        plan tests => 22;
85
85
86
        $schema->storage->txn_begin;
86
        $schema->storage->txn_begin;
87
87
Lines 264-270 subtest 'get() tests' => sub { Link Here
264
    $schema->storage->txn_rollback;
264
    $schema->storage->txn_rollback;
265
265
266
    subtest 'librarian access tests' => sub {
266
    subtest 'librarian access tests' => sub {
267
        plan tests => 8;
267
268
        plan tests => 9;
268
269
269
        $schema->storage->txn_begin;
270
        $schema->storage->txn_begin;
270
271
271
- 

Return to bug 28633