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

(-)a/Koha/Patron.pm (+13 lines)
Lines 102-107 sub new { Link Here
102
    return $class->SUPER::new($params);
102
    return $class->SUPER::new($params);
103
}
103
}
104
104
105
=head3 effective_name
106
107
Return the preferred name for a patron, or their firstname if no
108
preferred name is set
109
110
=cut
111
112
sub effective_name {
113
    my ( $self ) = @_;
114
115
    return $self->preferredname || $self->firstname;
116
}
117
105
=head3 fixup_cardnumber
118
=head3 fixup_cardnumber
106
119
107
Autogenerate next cardnumber from highest value found in database
120
Autogenerate next cardnumber from highest value found in database
(-)a/installer/data/mysql/kohastructure.sql (+3 lines)
Lines 1244-1249 CREATE TABLE `borrower_modifications` ( Link Here
1244
  `cardnumber` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1244
  `cardnumber` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1245
  `surname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1245
  `surname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1246
  `firstname` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1246
  `firstname` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1247
  `preferredname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s preferred name',
1247
  `title` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1248
  `title` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1248
  `othernames` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1249
  `othernames` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1249
  `initials` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1250
  `initials` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
Lines 1362-1367 CREATE TABLE `borrowers` ( Link Here
1362
  `cardnumber` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'unique key, library assigned ID number for patrons/borrowers',
1363
  `cardnumber` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'unique key, library assigned ID number for patrons/borrowers',
1363
  `surname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s last name (surname)',
1364
  `surname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s last name (surname)',
1364
  `firstname` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s first name',
1365
  `firstname` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s first name',
1366
  `preferredname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s preferred name',
1365
  `title` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s title, for example: Mr. or Mrs.',
1367
  `title` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s title, for example: Mr. or Mrs.',
1366
  `othernames` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'any other names associated with the patron/borrower',
1368
  `othernames` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'any other names associated with the patron/borrower',
1367
  `initials` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'initials for your patron/borrower',
1369
  `initials` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'initials for your patron/borrower',
Lines 2369-2374 CREATE TABLE `deletedborrowers` ( Link Here
2369
  `cardnumber` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'unique key, library assigned ID number for patrons/borrowers',
2371
  `cardnumber` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'unique key, library assigned ID number for patrons/borrowers',
2370
  `surname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s last name (surname)',
2372
  `surname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s last name (surname)',
2371
  `firstname` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s first name',
2373
  `firstname` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s first name',
2374
  `preferredname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s preferred name',
2372
  `title` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s title, for example: Mr. or Mrs.',
2375
  `title` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s title, for example: Mr. or Mrs.',
2373
  `othernames` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'any other names associated with the patron/borrower',
2376
  `othernames` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'any other names associated with the patron/borrower',
2374
  `initials` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'initials for your patron/borrower',
2377
  `initials` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'initials for your patron/borrower',
(-)a/koha-tmpl/intranet-tmpl/prog/en/columns.def (+1 lines)
Lines 2-7 Link Here
2
<field name="borrowers.title">Salutation</field>
2
<field name="borrowers.title">Salutation</field>
3
<field name="borrowers.surname">Surname</field>
3
<field name="borrowers.surname">Surname</field>
4
<field name="borrowers.firstname">First name</field>
4
<field name="borrowers.firstname">First name</field>
5
<field name="borrowers.preferredname">Preferred name</field>
5
<field name="borrowers.dateofbirth">Date of birth</field>
6
<field name="borrowers.dateofbirth">Date of birth</field>
6
<field name="borrowers.initials">Initials</field>
7
<field name="borrowers.initials">Initials</field>
7
<field name="borrowers.othernames">Other name</field>
8
<field name="borrowers.othernames">Other name</field>
(-)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.preferredname  = patron.preferredname -%]
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.preferredname  = borrower.preferredname -%]
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.preferredname  = preferredname -%]
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.preferredname || 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.preferredname ) %], [% data.preferredname | 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.preferredname | 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 'firstname' -%]<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
    "preferredname": "preferredname",
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/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 && nopreferredname && 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 nopreferredname %]
342
                                                    <li>
343
                                                        [% IF ( mandatorypreferredname ) %]
344
                                                            <label for="preferredname" class="required">
345
                                                        [% ELSE %]
346
                                                            <label for="preferredname">
347
                                                        [% END %]
348
                                                            Preferred name:
349
                                                        </label>
350
                                                        <input type="text" id="preferredname" name="preferredname" size="20"  value="[% preferredname | html UNLESS opduplicate %]" />
351
                                                        [% IF ( mandatorypreferredname ) %]
352
                                                            <span class="required">Required</span>
353
                                                        [% END %]
354
                                                    </li>
355
                                                [% END #/UNLESS nopreferredname %]
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 'preferredname'       %]<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 / +1 lines)
Lines 86-92 Link Here
86
86
87
                        <h3>
87
                        <h3>
88
                            [% UNLESS ( I ) %]
88
                            [% UNLESS ( I ) %]
89
                                [% patron.title | html %] [% patron.firstname | html %]
89
                                [% patron.title | html %] [% patron.effective_name | html %]
90
                            [% END %]
90
                            [% END %]
91
                            [% patron.surname | html %] ([% patron.cardnumber | html %])
91
                            [% patron.surname | html %] ([% patron.cardnumber | html %])
92
                        </h3>
92
                        </h3>
(-)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 173-179 Link Here
173
                                            Guaranteed by
173
                                            Guaranteed by
174
                                            [% FOREACH gr IN patron.guarantor_relationships %]
174
                                            [% FOREACH gr IN patron.guarantor_relationships %]
175
                                                [% SET g = gr.guarantor %]
175
                                                [% SET g = gr.guarantor %]
176
                                                [% g.firstname | html %] [% g.surname | html %]
176
                                                [% g.effective_name | html %] [% g.surname | html %]
177
                                                [%- IF ! loop.last %], [% END %]
177
                                                [%- IF ! loop.last %], [% END %]
178
                                            [% END %]
178
                                            [% END %]
179
                                        </span>
179
                                        </span>
Lines 190-196 Link Here
190
190
191
                <form method="post" action="/cgi-bin/koha/opac-memberentry.pl" id="memberentry-form" autocomplete="off">
191
                <form method="post" action="/cgi-bin/koha/opac-memberentry.pl" id="memberentry-form" autocomplete="off">
192
192
193
                [% 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' ] %]
193
                [% FOREACH field = ['streetnumber' 'streettype'  'cardnumber' 'branchcode' 'categorycode' 'title' 'surname' 'firstname' 'preferredname' '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' ] %]
194
                    [% IF mandatory.defined( field ) %]
194
                    [% IF mandatory.defined( field ) %]
195
                        [% SET required.$field = 'required' %]
195
                        [% SET required.$field = 'required' %]
196
                    [% END %]
196
                    [% END %]
Lines 294-300 Link Here
294
                    [% END # / defined 'branchcode' %]
294
                    [% END # / defined 'branchcode' %]
295
295
296
                    [%# Following on one line for translatability %]
296
                    [%# Following on one line for translatability %]
297
                    [% UNLESS hidden.defined('title') && hidden.defined('surname') && hidden.defined('firstname') && hidden.defined('dateofbirth') && hidden.defined('initials') && hidden.defined('othernames') && hidden.defined('sex') %]
297
                    [% UNLESS hidden.defined('title') && hidden.defined('surname') && hidden.defined('firstname') && hidden.defined('preferredname') && hidden.defined('dateofbirth') && hidden.defined('initials') && hidden.defined('othernames') && hidden.defined('sex') %]
298
                        <div class="row">
298
                        <div class="row">
299
                            <div class="col">
299
                            <div class="col">
300
                                <fieldset class="rows" id="memberentry_identity">
300
                                <fieldset class="rows" id="memberentry_identity">
Lines 337-342 Link Here
337
                                            </li>
337
                                            </li>
338
                                        [% END %]
338
                                        [% END %]
339
339
340
                                        [% UNLESS hidden.defined('preferredname') %]
341
                                            <li>
342
                                                <label for="borrower_preferredname" class="[% required.preferredname | html %]">Preferrred name:</label>
343
344
                                                <input type="text" id="borrower_preferredname" name="borrower_preferredname" value="[% borrower.preferredname | html %]" class="[% required.preferredname | html %]" />
345
                                                <div class="required_label [% required.preferredname | html %]">Required</div>
346
                                            </li>
347
                                        [% END %]
348
340
                                        [% UNLESS hidden.defined('dateofbirth') %]
349
                                        [% UNLESS hidden.defined('dateofbirth') %]
341
                                            <li>
350
                                            <li>
342
                                                <label for="borrower_dateofbirth" class="[% required.dateofbirth | html %]">Date of birth:</label>
351
                                                <label for="borrower_dateofbirth" class="[% required.dateofbirth | html %]">Date of birth:</label>
(-)a/t/db_dependent/Koha/Patron.t (-2 / +25 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 8;
22
use Test::More tests => 9;
23
use Test::Exception;
23
use Test::Exception;
24
use Test::Warn;
24
use Test::Warn;
25
25
Lines 716-718 subtest 'can_log_into() tests' => sub { Link Here
716
716
717
    $schema->storage->txn_rollback;
717
    $schema->storage->txn_rollback;
718
};
718
};
719
- 
719
720
subtest 'effective_name() tests' => sub {
721
722
    plan tests => 2;
723
724
    $schema->storage->txn_begin;
725
726
    my $patron_1 = $builder->build_object({ class => 'Koha::Patrons', value => {
727
            firstname => 'John',
728
            preferredname => 'Jacob',
729
        }
730
    });
731
    my $patron_2 = $builder->build_object({ class => 'Koha::Patrons', value=> {
732
            firstname => "Bob",
733
            preferredname => undef,
734
        }
735
    });
736
737
    is( $patron_1->effective_name, "Jacob", 'Preferred name correctly chosen' );
738
    is( $patron_2->effective_name, "Bob", 'First name correctly chosen if no preferred name' );
739
740
    $schema->storage->txn_rollback;
741
};
742

Return to bug 28633