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

(-)a/Koha/Patron.pm (+13 lines)
Lines 107-112 sub new { Link Here
107
    return $class->SUPER::new($params);
107
    return $class->SUPER::new($params);
108
}
108
}
109
109
110
=head3 effective_name
111
112
Return the preferred name for a patron, or their firstname if no
113
preferred name is set
114
115
=cut
116
117
sub effective_name {
118
    my ( $self ) = @_;
119
120
    return $self->preferred_name || $self->firstname;
121
}
122
110
=head3 fixup_cardnumber
123
=head3 fixup_cardnumber
111
124
112
Autogenerate next cardnumber from highest value found in database
125
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 61-69 Link Here
61
    [%- IF data.category_type == 'I' -%]
70
    [%- IF data.category_type == 'I' -%]
62
        [%- data.surname | html %] [% IF data.othernames %] ([% data.othernames | html %])[% END -%]
71
        [%- data.surname | html %] [% IF data.othernames %] ([% data.othernames | html %])[% END -%]
63
    [%- ELSIF invert_name -%]
72
    [%- ELSIF invert_name -%]
64
        [% data.title | $raw %][%- data.surname | html %][% IF ( data.firstname ) %], [% data.firstname | html %][% END %][% IF data.othernames %] ([% data.othernames | html %]) [% END -%]
73
        [% data.title | $raw %][%- data.surname | html %][% IF ( data.effective_name ) %], [% data.effective_name | html %][% END %][% IF data.othernames %] ([% data.othernames | html %]) [% END -%]
65
    [%- ELSE -%]
74
    [%- ELSE -%]
66
        [% data.title | $raw %][%- data.firstname | html %] [% IF data.othernames %] ([% data.othernames | html %]) [% END %] [% data.surname | html -%]
75
        [% data.title | $raw %][%- data.effective_name | html %] [% IF data.othernames %] ([% data.othernames | html %]) [% END %] [% data.surname | html -%]
67
    [%- END -%]
76
    [%- END -%]
68
    [%- IF display_cardnumber AND data.cardnumber %] ([% data.cardnumber | html %])[% END -%]
77
    [%- IF display_cardnumber AND data.cardnumber %] ([% data.cardnumber | html %])[% END -%]
69
[%- ELSIF display_cardnumber -%]
78
[%- 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 (+60 lines)
Line 0 Link Here
1
{
2
    "cardnumber": "cardnumber",
3
    "surname": "surname",
4
    "firstname": "firstname",
5
    "preferred_name": "preferred_name",
6
    "title": "title",
7
    "othernames": "othernames",
8
    "initials": "initials",
9
    "streetnumber": "streetnumber",
10
    "streettype": "streettype",
11
    "address": "address",
12
    "address2": "address2",
13
    "city": "city",
14
    "state": "state",
15
    "zipcode": "zipcode",
16
    "country": "country",
17
    "email": "email",
18
    "phone": "phone",
19
    "mobile": "mobile",
20
    "fax": "fax",
21
    "emailpro": "emailpro",
22
    "phonepro": "phonepro",
23
    "B_streetnumber": "B_streetnumber",
24
    "B_streettype": "B_streettype",
25
    "B_address": "B_address",
26
    "B_address2": "B_address2",
27
    "B_city": "B_city",
28
    "B_state": "B_state",
29
    "B_zipcode": "B_zipcode",
30
    "B_country": "B_country",
31
    "B_email": "B_email",
32
    "B_phone": "B_phone",
33
    "dateofbirth": "dateofbirth",
34
    "dateenrolled": "dateenrolled",
35
    "dateexpiry": "dateexpiry",
36
    "branchcode": "branchcode",
37
    "categorycode": "categorycode",
38
    "contactname": "contactname",
39
    "contactfirstname": "contactfirstname",
40
    "borrowernotes": "borrowernotes",
41
    "sex": "sex",
42
    "password": "password",
43
    "userid": "userid",
44
    "opacnote": "opacnote",
45
    "contactnote": "contactnote",
46
    "altcontactfirstname": "altcontactfirstname",
47
    "altcontactsurname": "altcontactsurname",
48
    "altcontactaddress1": "altcontactaddress1",
49
    "altcontactaddress2": "altcontactaddress2",
50
    "altcontactaddress3": "altcontactaddress3",
51
    "altcontactstate": "altcontactstate",
52
    "altcontactzipcode": "altcontactzipcode",
53
    "altcontactcountry": "altcontactcountry",
54
    "altcontactphone": "altcontactphone",
55
    "smsalertnumber": "smsalertnumber",
56
    "autorenew_checkouts": "autorenew_checkouts",
57
    "primary_contact_method": "primary_contact_method",
58
    "sort1": "sort1",
59
    "sort2": "sort2"
60
}
(-)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 \"firstname,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."
51
         - "If empty Koha will default to \"firstname,surname,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="[% borrower_data.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 97-103 Link Here
97
97
98
                        <h1>
98
                        <h1>
99
                            [% UNLESS ( I ) %]
99
                            [% UNLESS ( I ) %]
100
                                [% patron.title | html %] [% patron.firstname | html %]
100
                                [% patron.title | html %] [% patron.effective_name | html %]
101
                            [% END %]
101
                            [% END %]
102
                            [% patron.surname | html %] ([% patron.cardnumber | html %])
102
                            [% patron.surname | html %] ([% patron.cardnumber | html %])
103
                        </h1>
103
                        </h1>
Lines 124-129 Link Here
124
124
125
                                <div class="rows">
125
                                <div class="rows">
126
                                    <ol>
126
                                    <ol>
127
                                        [% IF ( patron.preferred_name && patron.firstname ) %]
128
                                            <li id="patron_first_name">
129
                                                <span class="label patron_first_name">First name: </span>
130
                                                [% patron.firstname | html %]
131
                                            </li>
132
                                        [% END %]
127
                                        [% IF ( patron.phone ) %]
133
                                        [% IF ( patron.phone ) %]
128
                                            <li>
134
                                            <li>
129
                                                <span class="label">Primary phone: </span>
135
                                                <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 300-306 Link Here
300
                    [% END # / defined 'branchcode' %]
300
                    [% END # / defined 'branchcode' %]
301
301
302
                    [%# Following on one line for translatability %]
302
                    [%# Following on one line for translatability %]
303
                    [% UNLESS hidden.defined('title') && hidden.defined('surname') && hidden.defined('firstname') && hidden.defined('dateofbirth') && hidden.defined('initials') && hidden.defined('othernames') && hidden.defined('sex') %]
303
                    [% 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') %]
304
                        <div class="row">
304
                        <div class="row">
305
                            <div class="col">
305
                            <div class="col">
306
                                <fieldset class="rows" id="memberentry_identity">
306
                                <fieldset class="rows" id="memberentry_identity">
Lines 343-348 Link Here
343
                                            </li>
343
                                            </li>
344
                                        [% END %]
344
                                        [% END %]
345
345
346
                                        [% UNLESS hidden.defined('preferred_name') %]
347
                                            <li>
348
                                                <label for="borrower_preferred_name" class="[% required.preferred_name | html %]">Preferrred name:</label>
349
350
                                                <input type="text" id="borrower_preferred_name" name="borrower_preferred_name" value="[% borrower.preferred_name | html %]" class="[% required.preferred_name | html %]" />
351
                                                <div class="required_label [% required.preferred_name | html %]">Required</div>
352
                                            </li>
353
                                        [% END %]
354
346
                                        [% UNLESS hidden.defined('dateofbirth') %]
355
                                        [% UNLESS hidden.defined('dateofbirth') %]
347
                                            <li>
356
                                            <li>
348
                                                <label for="borrower_dateofbirth" class="[% required.dateofbirth | html %]">Date of birth:</label>
357
                                                <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 => 16;
22
use Test::More tests => 17;
23
use Test::Exception;
23
use Test::Exception;
24
use Test::Warn;
24
use Test::Warn;
25
25
Lines 1137-1139 subtest 'recalls() tests' => sub { Link Here
1137
1137
1138
    $schema->storage->txn_rollback;
1138
    $schema->storage->txn_rollback;
1139
};
1139
};
1140
- 
1140
1141
subtest 'effective_name() tests' => sub {
1142
1143
    plan tests => 2;
1144
1145
    $schema->storage->txn_begin;
1146
1147
    my $patron_1 = $builder->build_object({ class => 'Koha::Patrons', value => {
1148
            firstname => 'John',
1149
            preferred_name => 'Jacob',
1150
        }
1151
    });
1152
    my $patron_2 = $builder->build_object({ class => 'Koha::Patrons', value=> {
1153
            firstname => "Bob",
1154
            preferred_name => undef,
1155
        }
1156
    });
1157
1158
    is( $patron_1->effective_name, "Jacob", 'Preferred name correctly chosen' );
1159
    is( $patron_2->effective_name, "Bob", 'First name correctly chosen if no preferred name' );
1160
1161
    $schema->storage->txn_rollback;
1162
};

Return to bug 28633