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

(-)a/C4/Utils/DataTables/Members.pm (-1 / +1 lines)
Lines 113-119 sub search { Link Here
113
    }
113
    }
114
114
115
    my $searchfields = {
115
    my $searchfields = {
116
        standard => C4::Context->preference('DefaultPatronSearchFields') || 'surname,firstname,othernames,cardnumber,userid',
116
        standard => C4::Context->preference('DefaultPatronSearchFields') || 'surname,firstname,preferred_name,othernames,cardnumber,userid',
117
        email => 'email,emailpro,B_email',
117
        email => 'email,emailpro,B_email',
118
        borrowernumber => 'borrowernumber',
118
        borrowernumber => 'borrowernumber',
119
        phone => 'phone,phonepro,B_phone,altcontactphone,mobile',
119
        phone => 'phone,phonepro,B_phone,altcontactphone,mobile',
(-)a/Koha/Patron.pm (+13 lines)
Lines 103-108 sub new { Link Here
103
    return $class->SUPER::new($params);
103
    return $class->SUPER::new($params);
104
}
104
}
105
105
106
=head3 effective_name
107
108
Return the preferred name for a patron, or their firstname if no
109
preferred name is set
110
111
=cut
112
113
sub effective_name {
114
    my ( $self ) = @_;
115
116
    return $self->preferred_name || $self->firstname;
117
}
118
106
=head3 fixup_cardnumber
119
=head3 fixup_cardnumber
107
120
108
Autogenerate next cardnumber from highest value found in database
121
Autogenerate next cardnumber from highest value found in database
(-)a/circ/ysearch.pl (-1 / +1 lines)
Lines 84-90 while ( my $b = $borrowers_rs->next ) { Link Here
84
    push @borrowers,
84
    push @borrowers,
85
      { borrowernumber => $b->borrowernumber,
85
      { borrowernumber => $b->borrowernumber,
86
        surname        => $b->surname    // '',
86
        surname        => $b->surname    // '',
87
        firstname      => $b->firstname  // '',
87
        firstname      => $b->effective_name  // '',
88
        cardnumber     => $b->cardnumber // '',
88
        cardnumber     => $b->cardnumber // '',
89
        dateofbirth    => format_sqldatetime($b->dateofbirth, undef, undef, 1) // '',
89
        dateofbirth    => format_sqldatetime($b->dateofbirth, undef, undef, 1) // '',
90
        age            => $b->get_age    // '',
90
        age            => $b->get_age    // '',
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-title.inc (-2 / +11 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 -%]
11
    [%- SET data.effective_name = patron.effective_name -%]
10
    [%- SET data.cardnumber     = patron.cardnumber -%]
12
    [%- SET data.cardnumber     = patron.cardnumber -%]
11
    [%- SET data.borrowernumber = patron.borrowernumber -%]
13
    [%- SET data.borrowernumber = patron.borrowernumber -%]
12
    [%- SET data.title          = patron.title -%]
14
    [%- SET data.title          = patron.title -%]
Lines 15-20 Link Here
15
    [%- SET data.surname        = borrower.surname -%]
17
    [%- SET data.surname        = borrower.surname -%]
16
    [%- SET data.othernames     = borrower.othernames -%]
18
    [%- SET data.othernames     = borrower.othernames -%]
17
    [%- SET data.firstname      = borrower.firstname -%]
19
    [%- SET data.firstname      = borrower.firstname -%]
20
    [%- SET data.preferred_name = borrower.preferred_name -%]
21
    [%- SET data.effective_name = borrower.effective_name -%]
18
    [%- SET data.cardnumber     = borrower.cardnumber -%]
22
    [%- SET data.cardnumber     = borrower.cardnumber -%]
19
    [%- SET data.borrowernumber = borrower.borrowernumber -%]
23
    [%- SET data.borrowernumber = borrower.borrowernumber -%]
20
    [%- SET data.title          = borrower.title -%]
24
    [%- SET data.title          = borrower.title -%]
Lines 23-32 Link Here
23
    [%- SET data.surname        = surname -%]
27
    [%- SET data.surname        = surname -%]
24
    [%- SET data.othernames     = othernames -%]
28
    [%- SET data.othernames     = othernames -%]
25
    [%- SET data.firstname      = firstname -%]
29
    [%- SET data.firstname      = firstname -%]
30
    [%- SET data.preferred_name = preferred_name -%]
31
    [%- SET data.effective_name = effective_name -%]
26
    [%- SET data.cardnumber     = cardnumber -%]
32
    [%- SET data.cardnumber     = cardnumber -%]
27
    [%- SET data.borrowernumber = borrowernumber -%]
33
    [%- SET data.borrowernumber = borrowernumber -%]
28
    [%- SET data.title          = title -%]
34
    [%- SET data.title          = title -%]
29
[%- END -%]
35
[%- END -%]
36
[%- UNLESS data.effective_name -%]
37
    [%- SET data.effective_name = data.preferred_name || data.firstname -%]
38
[%- END -%]
30
[%# Parameter no_html - if 1, the html tags are NOT generated %]
39
[%# Parameter no_html - if 1, the html tags are NOT generated %]
31
[%- IF no_title %][% SET data.title = "" %][% END -%]
40
[%- IF no_title %][% SET data.title = "" %][% END -%]
32
[%- IF data.title %]
41
[%- IF data.title %]
Lines 60-68 Link Here
60
    [%- IF data.category_type == 'I' -%]
69
    [%- IF data.category_type == 'I' -%]
61
        [%- data.surname | html %] [% IF data.othernames %] ([% data.othernames | html %])[% END -%]
70
        [%- data.surname | html %] [% IF data.othernames %] ([% data.othernames | html %])[% END -%]
62
    [%- ELSIF invert_name -%]
71
    [%- ELSIF invert_name -%]
63
        [% data.title | $raw %][%- data.surname | html %][% IF ( data.firstname ) %], [% data.firstname | html %][% END %][% IF data.othernames %] ([% data.othernames | html %]) [% END -%]
72
        [% data.title | $raw %][%- data.surname | html %][% IF ( data.effective_name ) %], [% data.effective_name | html %][% END %][% IF data.othernames %] ([% data.othernames | html %]) [% END -%]
64
    [%- ELSE -%]
73
    [%- ELSE -%]
65
        [% data.title | $raw %][%- data.firstname | html %] [% IF data.othernames %] ([% data.othernames | html %]) [% END %] [% data.surname | html -%]
74
        [% data.title | $raw %][%- data.effective_name | html %] [% IF data.othernames %] ([% data.othernames | html %]) [% END %] [% data.surname | html -%]
66
    [%- END -%]
75
    [%- END -%]
67
    [%- IF display_cardnumber AND data.cardnumber %] ([% data.cardnumber | html %])[% END -%]
76
    [%- IF display_cardnumber AND data.cardnumber %] ([% data.cardnumber | html %])[% END -%]
68
[%- ELSIF display_cardnumber -%]
77
[%- ELSIF display_cardnumber -%]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patronfields.inc (+1 lines)
Lines 5-10 Link Here
5
     [%- CASE 'cardnumber' -%]<span>Card number</span>
5
     [%- CASE 'cardnumber' -%]<span>Card number</span>
6
     [%- CASE 'surname' -%]<span>Surname</span>
6
     [%- CASE 'surname' -%]<span>Surname</span>
7
     [%- CASE 'firstname' -%]<span>First name</span>
7
     [%- CASE 'firstname' -%]<span>First name</span>
8
     [%- CASE 'preferred_name' -%]<span>Preferred name</span>
8
     [%- CASE 'title' -%]<span>Salutation</span>
9
     [%- CASE 'title' -%]<span>Salutation</span>
9
     [%- CASE 'othernames' -%]<span>Other name</span>
10
     [%- CASE 'othernames' -%]<span>Other name</span>
10
     [%- CASE 'initials' -%]<span>Initials</span>
11
     [%- CASE 'initials' -%]<span>Initials</span>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/borrowers.json (+1 lines)
Lines 2-7 Link Here
2
    "cardnumber": "cardnumber",
2
    "cardnumber": "cardnumber",
3
    "surname": "surname",
3
    "surname": "surname",
4
    "firstname": "firstname",
4
    "firstname": "firstname",
5
    "preferred_name": "preferred_name",
5
    "title": "title",
6
    "title": "title",
6
    "othernames": "othernames",
7
    "othernames": "othernames",
7
    "initials": "initials",
8
    "initials": "initials",
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (-1 / +1 lines)
Lines 48-54 Patrons: Link Here
48
         - "Comma separated list defining the default fields to be used during a patron search using the \"standard\" option:"
48
         - "Comma separated list defining the default fields to be used during a patron search using the \"standard\" option:"
49
         - pref: DefaultPatronSearchFields
49
         - pref: DefaultPatronSearchFields
50
           class: multi
50
           class: multi
51
         - "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."
51
         - "If empty Koha will default to \"surname,firstname,preferred_name,othernames,cardnumber,userid\". Additional fields added to this preference will be added as search options in the dropdown menu on the patron search page."
52
     -
52
     -
53
         - "Show the following fields from the items database table as columns on the statistics tab on the patron record: "
53
         - "Show the following fields from the items database table as columns on the statistics tab on the patron record: "
54
         - pref: StatisticsFields
54
         - pref: StatisticsFields
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (-1 / +16 lines)
Lines 264-270 legend:hover { Link Here
264
                            [% END %]
264
                            [% END %]
265
265
266
                            [% IF ( step_1 ) %]
266
                            [% IF ( step_1 ) %]
267
                                [% UNLESS notitle && nosurname && nofirstname && nodateofbirth && noinitials && noothernames &&nosex %]
267
                                [% UNLESS notitle && nosurname && nofirstname && nopreferred_name && nodateofbirth && noinitials && noothernames &&nosex %]
268
                                    <fieldset class="rows" id="memberentry_identity">
268
                                    <fieldset class="rows" id="memberentry_identity">
269
                                        <legend id="identity_lgd">[% IF ( I ) %]Organization [% ELSE %]Patron [% END %]identity</legend>
269
                                        <legend id="identity_lgd">[% IF ( I ) %]Organization [% ELSE %]Patron [% END %]identity</legend>
270
                                        <ol>
270
                                        <ol>
Lines 338-343 legend:hover { Link Here
338
                                                        [% END %]
338
                                                        [% END %]
339
                                                    </li>
339
                                                    </li>
340
                                                [% END #/UNLESS nofirstname %]
340
                                                [% END #/UNLESS nofirstname %]
341
                                                [% UNLESS nopreferred_name %]
342
                                                    <li>
343
                                                        [% IF ( mandatorypreferred_name ) %]
344
                                                            <label for="preferred_name" class="required">
345
                                                        [% ELSE %]
346
                                                            <label for="preferred_name">
347
                                                        [% END %]
348
                                                            Preferred name:
349
                                                        </label>
350
                                                        <input type="text" id="preferred_name" name="preferred_name" size="20"  value="[% preferred_name | html UNLESS opduplicate %]" />
351
                                                        [% IF ( mandatorypreferred_name ) %]
352
                                                            <span class="required">Required</span>
353
                                                        [% END %]
354
                                                    </li>
355
                                                [% END #/UNLESS nopreferred_name %]
341
                                                [% UNLESS nodateofbirth %]
356
                                                [% UNLESS nodateofbirth %]
342
                                                    <li>
357
                                                    <li>
343
                                                        [% IF ( mandatorydateofbirth ) %]
358
                                                        [% IF ( mandatorydateofbirth ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/members-update.tt (+1 lines)
Lines 19-24 Link Here
19
[% CASE 'branchcode'          %]<span>Home library (branchcode)</span>
19
[% CASE 'branchcode'          %]<span>Home library (branchcode)</span>
20
[% CASE 'surname'             %]<span>Surname</span>
20
[% CASE 'surname'             %]<span>Surname</span>
21
[% CASE 'firstname'           %]<span>First name</span>
21
[% CASE 'firstname'           %]<span>First name</span>
22
[% CASE 'preferred_name'      %]<span>Preferred name</span>
22
[% CASE 'title'               %]<span>Title</span>
23
[% CASE 'title'               %]<span>Title</span>
23
[% CASE 'othernames'          %]<span>Other names</span>
24
[% CASE 'othernames'          %]<span>Other names</span>
24
[% CASE 'initials'            %]<span>Initials</span>
25
[% CASE 'initials'            %]<span>Initials</span>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (-1 / +7 lines)
Lines 87-93 Link Here
87
87
88
                        <h3>
88
                        <h3>
89
                            [% UNLESS ( I ) %]
89
                            [% UNLESS ( I ) %]
90
                                [% patron.title | html %] [% patron.firstname | html %]
90
                                [% patron.title | html %] [% patron.effective_name | html %]
91
                            [% END %]
91
                            [% END %]
92
                            [% patron.surname | html %] ([% patron.cardnumber | html %])
92
                            [% patron.surname | html %] ([% patron.cardnumber | html %])
93
                        </h3>
93
                        </h3>
Lines 125-130 Link Here
125
125
126
                                <div class="rows">
126
                                <div class="rows">
127
                                    <ol>
127
                                    <ol>
128
                                        [% IF ( patron.preferred_name && patron.firstname ) %]
129
                                            <li id="patron_first_name">
130
                                                <span class="label patron_first_name">First name: </span>
131
                                                [% patron.firstname | html %]
132
                                            </li>
133
                                        [% END %]
128
                                        [% IF ( patron.phone ) %]
134
                                        [% IF ( patron.phone ) %]
129
                                            <li>
135
                                            <li>
130
                                                <span class="label">Primary phone: </span>
136
                                                <span class="label">Primary phone: </span>
(-)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.surname | html %]
7
    [% patron.effective_name | html %] [% patron.surname | html %]
8
[%- END -%]
8
[%- END -%]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt (-3 / +12 lines)
Lines 176-182 Link Here
176
                                            Guaranteed by
176
                                            Guaranteed by
177
                                            [% FOREACH gr IN patron.guarantor_relationships %]
177
                                            [% FOREACH gr IN patron.guarantor_relationships %]
178
                                                [% SET g = gr.guarantor %]
178
                                                [% SET g = gr.guarantor %]
179
                                                [% g.firstname | html %] [% g.surname | html %]
179
                                                [% g.effective_name | html %] [% g.surname | html %]
180
                                                [%- IF ! loop.last %], [% END %]
180
                                                [%- IF ! loop.last %], [% END %]
181
                                            [% END %]
181
                                            [% END %]
182
                                        </span>
182
                                        </span>
Lines 193-199 Link Here
193
193
194
                <form method="post" action="/cgi-bin/koha/opac-memberentry.pl" id="memberentry-form" autocomplete="off">
194
                <form method="post" action="/cgi-bin/koha/opac-memberentry.pl" id="memberentry-form" autocomplete="off">
195
195
196
                [% FOREACH field = ['streetnumber' 'streettype'  'cardnumber' 'branchcode' 'categorycode' 'title' 'surname' 'firstname' 'dateofbirth' 'initials' 'othernames' 'address' 'address2' 'city' 'state' 'zipcode' 'country' 'phone' 'phonepro' 'mobile' 'email' 'emailpro' 'fax' 'B_streettype' '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' ] %]
196
                [% FOREACH field = ['streetnumber' 'streettype'  'cardnumber' 'branchcode' 'categorycode' 'title' 'surname' 'firstname' 'preferred_name' 'dateofbirth' 'initials' 'othernames' 'address' 'address2' 'city' 'state' 'zipcode' 'country' 'phone' 'phonepro' 'mobile' 'email' 'emailpro' 'fax' 'B_streettype' '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' ] %]
197
                    [% IF mandatory.defined( field ) %]
197
                    [% IF mandatory.defined( field ) %]
198
                        [% SET required.$field = 'required' %]
198
                        [% SET required.$field = 'required' %]
199
                    [% END %]
199
                    [% END %]
Lines 297-303 Link Here
297
                    [% END # / defined 'branchcode' %]
297
                    [% END # / defined 'branchcode' %]
298
298
299
                    [%# Following on one line for translatability %]
299
                    [%# Following on one line for translatability %]
300
                    [% UNLESS hidden.defined('title') && hidden.defined('surname') && hidden.defined('firstname') && hidden.defined('dateofbirth') && hidden.defined('initials') && hidden.defined('othernames') && hidden.defined('sex') %]
300
                    [% UNLESS hidden.defined('title') && hidden.defined('surname') && hidden.defined('firstname') && hidden.defined('preferred_name') && hidden.defined('dateofbirth') && hidden.defined('initials') && hidden.defined('othernames') && hidden.defined('sex') %]
301
                        <div class="row">
301
                        <div class="row">
302
                            <div class="col">
302
                            <div class="col">
303
                                <fieldset class="rows" id="memberentry_identity">
303
                                <fieldset class="rows" id="memberentry_identity">
Lines 340-345 Link Here
340
                                            </li>
340
                                            </li>
341
                                        [% END %]
341
                                        [% END %]
342
342
343
                                        [% UNLESS hidden.defined('preferred_name') %]
344
                                            <li>
345
                                                <label for="borrower_preferred_name" class="[% required.preferred_name | html %]">Preferrred name:</label>
346
347
                                                <input type="text" id="borrower_preferred_name" name="borrower_preferred_name" value="[% borrower.preferred_name | html %]" class="[% required.preferred_name | html %]" />
348
                                                <div class="required_label [% required.preferred_name | html %]">Required</div>
349
                                            </li>
350
                                        [% END %]
351
343
                                        [% UNLESS hidden.defined('dateofbirth') %]
352
                                        [% UNLESS hidden.defined('dateofbirth') %]
344
                                            <li>
353
                                            <li>
345
                                                <label for="borrower_dateofbirth" class="[% required.dateofbirth | html %]">Date of birth:</label>
354
                                                <label for="borrower_dateofbirth" class="[% required.dateofbirth | html %]">Date of birth:</label>
(-)a/t/db_dependent/Koha/Patron.t (-2 / +24 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 10;
22
use Test::More tests => 11;
23
use Test::Exception;
23
use Test::Exception;
24
use Test::Warn;
24
use Test::Warn;
25
25
Lines 846-848 subtest 'article_requests() tests' => sub { Link Here
846
846
847
    $schema->storage->txn_rollback;
847
    $schema->storage->txn_rollback;
848
};
848
};
849
- 
849
850
subtest 'effective_name() tests' => sub {
851
852
    plan tests => 2;
853
854
    $schema->storage->txn_begin;
855
856
    my $patron_1 = $builder->build_object({ class => 'Koha::Patrons', value => {
857
            firstname => 'John',
858
            preferred_name => 'Jacob',
859
        }
860
    });
861
    my $patron_2 = $builder->build_object({ class => 'Koha::Patrons', value=> {
862
            firstname => "Bob",
863
            preferred_name => undef,
864
        }
865
    });
866
867
    is( $patron_1->effective_name, "Jacob", 'Preferred name correctly chosen' );
868
    is( $patron_2->effective_name, "Bob", 'First name correctly chosen if no preferred name' );
869
870
    $schema->storage->txn_rollback;
871
};

Return to bug 28633