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

(-)a/Koha/Patron.pm (+17 lines)
Lines 31-36 use Koha::Database; Link Here
31
use Koha::DateUtils;
31
use Koha::DateUtils;
32
use Koha::Holds;
32
use Koha::Holds;
33
use Koha::Old::Checkouts;
33
use Koha::Old::Checkouts;
34
use Koha::Patron::Attributes;
34
use Koha::Patron::Categories;
35
use Koha::Patron::Categories;
35
use Koha::Patron::HouseboundProfile;
36
use Koha::Patron::HouseboundProfile;
36
use Koha::Patron::HouseboundRole;
37
use Koha::Patron::HouseboundRole;
Lines 1032-1037 sub generate_userid { Link Here
1032
1033
1033
}
1034
}
1034
1035
1036
=head3 attributes
1037
1038
my $attributes = $patron->attributes
1039
1040
Return object of Koha::Patron::Attributes type with all attributes set for this patron
1041
1042
=cut
1043
1044
sub attributes {
1045
    my ( $self ) = @_;
1046
    return Koha::Patron::Attributes->search({
1047
        borrowernumber => $self->borrowernumber,
1048
        branchcode     => $self->branchcode,
1049
    });
1050
}
1051
1035
=head2 Internal methods
1052
=head2 Internal methods
1036
1053
1037
=head3 _type
1054
=head3 _type
(-)a/Koha/Patron/Attribute.pm (+52 lines)
Lines 20-25 use Modern::Perl; Link Here
20
use Koha::Database;
20
use Koha::Database;
21
use Koha::Exceptions::Patron::Attribute;
21
use Koha::Exceptions::Patron::Attribute;
22
use Koha::Patron::Attribute::Types;
22
use Koha::Patron::Attribute::Types;
23
use Koha::AuthorisedValues;
23
24
24
use base qw(Koha::Object);
25
use base qw(Koha::Object);
25
26
Lines 79-84 sub opac_editable { Link Here
79
    return Koha::Patron::Attribute::Types->find( $self->code )->opac_editable;
80
    return Koha::Patron::Attribute::Types->find( $self->code )->opac_editable;
80
}
81
}
81
82
83
=head3 display_checkout
84
85
    my $attribute = Koha::Patron::Attribute->new({ code => 'a_code', ... });
86
    if ( $attribute->display_checkout ) { ... }
87
88
=cut
89
90
sub display_checkout {
91
92
    my $self = shift;
93
94
    return $self->type->display_checkout;
95
}
96
97
=head3 value_description
98
99
    my $description = $attribute->value_description
100
101
    Return authorised value description or free text based on attribute type settings
102
103
=cut
104
105
sub value_description {
106
107
    my $self = shift;
108
109
    if ( $self->type->authorised_value_category ) {
110
        my $av = Koha::AuthorisedValues->search({
111
            category => $self->type->authorised_value_category,
112
            authorised_value => $self->attribute,
113
        });
114
        return $av->next->lib if $av->count
115
    }
116
    return $self->attribute;
117
}
118
119
=head3 type_description
120
121
    my $description = $attribute->type_description
122
123
    Return description of attribute type
124
125
=cut
126
127
sub type_description {
128
129
    my $self = shift;
130
131
    return $self->type->description;
132
}
133
82
=head3 type
134
=head3 type
83
135
84
    my $attribute_type = $attribute->type;
136
    my $attribute_type = $attribute->type;
(-)a/Koha/Patron/Attributes.pm (+32 lines)
Lines 31-36 Koha::Patron::Attributes - Koha Patron Attributes Object set class Link Here
31
31
32
=cut
32
=cut
33
33
34
=head3 search
35
36
my $attributes-> Koha::Patron::Attributes->search( $params );
37
38
=cut
39
40
sub search {
41
    my ( $self, $params, $attributes ) = @_;
42
43
    my $branchcode = $params->{branchcode};
44
    delete( $params->{branchcode} );
45
46
    my $or =
47
        $branchcode
48
        ? {
49
            '-or' => [
50
                'borrower_attribute_types_branches.b_branchcode' => undef,
51
                'borrower_attribute_types_branches.b_branchcode' => $branchcode,
52
            ]
53
        } : {};
54
55
    my $join =
56
        $branchcode
57
        ? {
58
            join => {
59
                'borrower_attribute_types' => 'borrower_attribute_types_branches'
60
            },
61
        } : {};
62
    $attributes //= {};
63
    return $self->SUPER::search( { %$params, %$or }, { %$attributes, %$join } );
64
}
65
34
=head3 _type
66
=head3 _type
35
67
36
=cut
68
=cut
(-)a/Koha/Schema/Result/BorrowerAttribute.pm (+16 lines)
Lines 109-114 __PACKAGE__->belongs_to( Link Here
109
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-12-08 04:41:27
109
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-12-08 04:41:27
110
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:EarETnedFsmRmAAJAUrKGg
110
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:EarETnedFsmRmAAJAUrKGg
111
111
112
=head2 borrower_attribute_types
113
114
Type: belongs_to
115
116
Related object: L<Koha::Schema::Result::BorrowerAttributeType>
117
118
=cut
119
120
__PACKAGE__->belongs_to(
121
    "borrower_attribute_types",
122
    "Koha::Schema::Result::BorrowerAttributeType",
123
    { "foreign.code" => "self.code" },
124
    { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },);
125
126
127
112
128
113
# You can replace this text with custom content, and it will be preserved on regeneration
129
# You can replace this text with custom content, and it will be preserved on regeneration
114
1;
130
1;
(-)a/circ/circulation.pl (-8 lines)
Lines 43-49 use C4::Reserves; Link Here
43
use Koha::Holds;
43
use Koha::Holds;
44
use C4::Context;
44
use C4::Context;
45
use CGI::Session;
45
use CGI::Session;
46
use C4::Members::Attributes qw(GetBorrowerAttributes);
47
use Koha::AuthorisedValues;
46
use Koha::AuthorisedValues;
48
use Koha::CsvProfiles;
47
use Koha::CsvProfiles;
49
use Koha::Patrons;
48
use Koha::Patrons;
Lines 559-571 if ( Koha::BiblioFrameworks->find('FA') ) { Link Here
559
    $fast_cataloging = 1 
558
    $fast_cataloging = 1 
560
}
559
}
561
560
562
if (C4::Context->preference('ExtendedPatronAttributes')) {
563
    my $attributes = GetBorrowerAttributes($borrowernumber);
564
    $template->param(
565
        ExtendedPatronAttributes => 1,
566
        extendedattributes => $attributes
567
    );
568
}
569
my $view = $batch
561
my $view = $batch
570
    ?'batch_checkout_view'
562
    ?'batch_checkout_view'
571
    : 'circview';
563
    : 'circview';
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc (-5 / +5 lines)
Lines 56-68 Link Here
56
        <li> <span class="empty">No email stored.</span></li>
56
        <li> <span class="empty">No email stored.</span></li>
57
    [% END %]
57
    [% END %]
58
58
59
    [% IF ( ExtendedPatronAttributes ) %][% FOREACH extendedattribute IN extendedattributes %]
59
    [% IF Koha.Preference('ExtendedPatronAttributes') %]
60
        [% IF ( extendedattribute.display_checkout ) %]
60
        [% FOREACH extendedattribute IN patron.attributes %]
61
            [% IF ( extendedattribute.value ) %]
61
            [% IF ( extendedattribute.display_checkout ) %]
62
                <li class="patronattribute"><span class="patronattributelabel">[% extendedattribute.description %]</span> : [% IF ( extendedattribute.value_description ) %][% extendedattribute.value_description %][% ELSE %][% extendedattribute.value %][% END %]</li>
62
                <li class="patronattribute"><span class="patronattributelabel">[% extendedattribute.type_description %]</span> : [% IF ( extendedattribute.value_description ) %][% extendedattribute.value_description %][% ELSE %][% extendedattribute.attribute %][% END %]</li>
63
            [% END %]
63
            [% END %]
64
        [% END %]
64
        [% END %]
65
    [% END %][% END %]
65
    [% END %]
66
    <li class="patroncategory">Category: [% patron.category.description %] ([% patron.categorycode %])</li>
66
    <li class="patroncategory">Category: [% patron.category.description %] ([% patron.categorycode %])</li>
67
    <li class="patronlibrary">Home library: [% Branches.GetName( patron.branchcode ) %]</li>
67
    <li class="patronlibrary">Home library: [% Branches.GetName( patron.branchcode ) %]</li>
68
    <li class="patronborrowernumber">Borrowernumber: [% patron.borrowernumber %]</li>
68
    <li class="patronborrowernumber">Borrowernumber: [% patron.borrowernumber %]</li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (-1 / +1 lines)
Lines 1018-1024 Link Here
1018
    </ol>
1018
    </ol>
1019
  </fieldset>
1019
  </fieldset>
1020
[% END # hide fieldset %]
1020
[% END # hide fieldset %]
1021
[% IF ( ExtendedPatronAttributes ) %][% UNLESS ( no_patron_attribute_types ) %]
1021
[% IF Koha.Preference('ExtendedPatronAttributes') %][% UNLESS ( no_patron_attribute_types ) %]
1022
  <fieldset class="rows" id="memberentry_patron_attributes">
1022
  <fieldset class="rows" id="memberentry_patron_attributes">
1023
    <legend id="patron_attributes_lgd">Additional attributes and identifiers</legend>
1023
    <legend id="patron_attributes_lgd">Additional attributes and identifiers</legend>
1024
    <input type="hidden" name="setting_extended_patron_attributes" value="1" />
1024
    <input type="hidden" name="setting_extended_patron_attributes" value="1" />
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (-1 / +1 lines)
Lines 248-254 Link Here
248
<div class="action"><a href="memberentry.pl?op=modify&amp;borrowernumber=[% patron.borrowernumber %]&amp;step=4">Edit</a></div>
248
<div class="action"><a href="memberentry.pl?op=modify&amp;borrowernumber=[% patron.borrowernumber %]&amp;step=4">Edit</a></div>
249
[% END %]
249
[% END %]
250
250
251
[% IF ( ExtendedPatronAttributes ) %]
251
[% IF Koha.Preference('ExtendedPatronAttributes') %]
252
[% UNLESS ( no_patron_attribute_types ) %]
252
[% UNLESS ( no_patron_attribute_types ) %]
253
<div id="patron-extended-attributes" style="padding-top: 1em;">
253
<div id="patron-extended-attributes" style="padding-top: 1em;">
254
<h3>Additional attributes and identifiers</h3>
254
<h3>Additional attributes and identifiers</h3>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/borrowers_stats.tt (-1 / +2 lines)
Lines 1-4 Link Here
1
[% USE Branches %]
1
[% USE Branches %]
2
[% USE Koha %]
2
[% SET footerjs = 1 %]
3
[% SET footerjs = 1 %]
3
[% INCLUDE 'doc-head-open.inc' %]
4
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Koha &rsaquo; Reports [% IF ( do_it ) %]&rsaquo; Patrons statistics &rsaquo; Results[% ELSE %]&rsaquo; Patrons statistics[% END %]</title>
5
<title>Koha &rsaquo; Reports [% IF ( do_it ) %]&rsaquo; Patrons statistics &rsaquo; Results[% ELSE %]&rsaquo; Patrons statistics[% END %]</title>
Lines 203-209 Link Here
203
            [% ELSE %]
204
            [% ELSE %]
204
                <input type="hidden" name="Filter" />
205
                <input type="hidden" name="Filter" />
205
			[% END %]
206
			[% END %]
206
            [% IF ( ExtendedPatronAttributes ) %]
207
            [% IF Koha.Preference('ExtendedPatronAttributes') %]
207
                <tr>
208
                <tr>
208
                    <th colspan="4">Patron attributes</th>
209
                    <th colspan="4">Patron attributes</th>
209
                </tr>
210
                </tr>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/import_borrowers.tt (-1 / +1 lines)
Lines 259-265 Link Here
259
            </ul>
259
            </ul>
260
        </li>
260
        </li>
261
261
262
        [% IF ( ExtendedPatronAttributes ) %]
262
        [% IF Koha.Preference('ExtendedPatronAttributes') %]
263
            <li>
263
            <li>
264
                If loading patron attributes, the 'patron_attributes' field should contain a comma-separated list of attribute types and values. The attribute type code and a colon should precede each value. For example: <b>INSTID:12345,LANG:fr</b> or <b>STARTDATE:January 1 2010,TRACK:Day</b>. If an input record has more than one attribute, the fields should either be entered as an unquoted string (previous examples), or with each field wrapped in separate double quotes and delimited by a comma: <b>&quot;STARTDATE:January 1, 2010&quot;,&quot;TRACK:Day&quot;</b>.  The second syntax would be required if the data might have a comma in it, like a date string.
264
                If loading patron attributes, the 'patron_attributes' field should contain a comma-separated list of attribute types and values. The attribute type code and a colon should precede each value. For example: <b>INSTID:12345,LANG:fr</b> or <b>STARTDATE:January 1 2010,TRACK:Day</b>. If an input record has more than one attribute, the fields should either be entered as an unquoted string (previous examples), or with each field wrapped in separate double quotes and delimited by a comma: <b>&quot;STARTDATE:January 1, 2010&quot;,&quot;TRACK:Day&quot;</b>.  The second syntax would be required if the data might have a comma in it, like a date string.
265
            </li>
265
            </li>
(-)a/members/boraccount.pl (-9 lines)
Lines 29-35 use C4::Output; Link Here
29
use CGI qw ( -utf8 );
29
use CGI qw ( -utf8 );
30
use C4::Members;
30
use C4::Members;
31
use C4::Accounts;
31
use C4::Accounts;
32
use C4::Members::Attributes qw(GetBorrowerAttributes);
33
use Koha::Patrons;
32
use Koha::Patrons;
34
use Koha::Patron::Categories;
33
use Koha::Patron::Categories;
35
34
Lines 116-129 while ( my $line = $accts->next ) { Link Here
116
    push @accountlines, $accountline;
115
    push @accountlines, $accountline;
117
}
116
}
118
117
119
if (C4::Context->preference('ExtendedPatronAttributes')) {
120
    my $attributes = GetBorrowerAttributes($borrowernumber);
121
    $template->param(
122
        ExtendedPatronAttributes => 1,
123
        extendedattributes => $attributes
124
    );
125
}
126
127
$template->param(
118
$template->param(
128
    patron              => $patron,
119
    patron              => $patron,
129
    finesview           => 1,
120
    finesview           => 1,
(-)a/members/files.pl (-9 lines)
Lines 24-30 use CGI qw ( -utf8 ); Link Here
24
use C4::Auth;
24
use C4::Auth;
25
use C4::Output;
25
use C4::Output;
26
use C4::Members;
26
use C4::Members;
27
use C4::Members::Attributes qw(GetBorrowerAttributes);
28
use C4::Debug;
27
use C4::Debug;
29
28
30
use Koha::DateUtils;
29
use Koha::DateUtils;
Lines 106-119 else { Link Here
106
        $bf->DelFile( id => scalar $cgi->param('file_id') );
105
        $bf->DelFile( id => scalar $cgi->param('file_id') );
107
    }
106
    }
108
107
109
    if (C4::Context->preference('ExtendedPatronAttributes')) {
110
        my $attributes = GetBorrowerAttributes($borrowernumber);
111
        $template->param(
112
            ExtendedPatronAttributes => 1,
113
            extendedattributes => $attributes
114
        );
115
    }
116
117
    $template->param(
108
    $template->param(
118
        files => Koha::Patron::Files->new( borrowernumber => $borrowernumber )
109
        files => Koha::Patron::Files->new( borrowernumber => $borrowernumber )
119
          ->GetFilesInfo(),
110
          ->GetFilesInfo(),
(-)a/members/housebound.pl (-10 lines)
Lines 28-34 use Modern::Perl; Link Here
28
use CGI;
28
use CGI;
29
use C4::Auth;
29
use C4::Auth;
30
use C4::Context;
30
use C4::Context;
31
use C4::Members::Attributes qw(GetBorrowerAttributes);
32
use C4::Output;
31
use C4::Output;
33
use DateTime;
32
use DateTime;
34
use Koha::DateUtils;
33
use Koha::DateUtils;
Lines 157-171 $method = 'update_or_create' if ( !$houseboundprofile ); Link Here
157
# Ensure template has all patron details.
156
# Ensure template has all patron details.
158
$template->param( patron => $patron );
157
$template->param( patron => $patron );
159
158
160
# Load extended patron attributes if necessary (taken from members/files.pl).
161
if ( C4::Context->preference('ExtendedPatronAttributes') and $patron ) {
162
    my $attributes = GetBorrowerAttributes($patron->borrowernumber);
163
    $template->param(
164
        ExtendedPatronAttributes => 1,
165
        extendedattributes => $attributes
166
    );
167
}
168
169
$template->param(
159
$template->param(
170
    housebound_profile => $houseboundprofile,
160
    housebound_profile => $houseboundprofile,
171
    visit              => $houseboundvisit,
161
    visit              => $houseboundvisit,
(-)a/members/mancredit.pl (-9 lines)
Lines 31-37 use CGI qw ( -utf8 ); Link Here
31
use C4::Members;
31
use C4::Members;
32
use C4::Accounts;
32
use C4::Accounts;
33
use C4::Items;
33
use C4::Items;
34
use C4::Members::Attributes qw(GetBorrowerAttributes);
35
use Koha::Patrons;
34
use Koha::Patrons;
36
35
37
use Koha::Patron::Categories;
36
use Koha::Patron::Categories;
Lines 93-106 if ($add){ Link Here
93
        $template->param( 'catcode' => $patron_categories->next->categorycode )  if $patron_categories->count == 1;
92
        $template->param( 'catcode' => $patron_categories->next->categorycode )  if $patron_categories->count == 1;
94
    }
93
    }
95
94
96
    if (C4::Context->preference('ExtendedPatronAttributes')) {
97
        my $attributes = GetBorrowerAttributes($borrowernumber);
98
        $template->param(
99
            ExtendedPatronAttributes => 1,
100
            extendedattributes => $attributes
101
        );
102
    }
103
104
    $template->param(
95
    $template->param(
105
        patron     => $patron,
96
        patron     => $patron,
106
        finesview  => 1,
97
        finesview  => 1,
(-)a/members/maninvoice.pl (-9 lines)
Lines 30-36 use CGI qw ( -utf8 ); Link Here
30
use C4::Members;
30
use C4::Members;
31
use C4::Accounts;
31
use C4::Accounts;
32
use C4::Items;
32
use C4::Items;
33
use C4::Members::Attributes qw(GetBorrowerAttributes);
34
use Koha::Token;
33
use Koha::Token;
35
34
36
use Koha::Patrons;
35
use Koha::Patrons;
Lines 120-133 if ($add){ Link Here
120
        $template->param( 'catcode' => $patron_categories->next->categorycode )  if $patron_categories->count == 1;
119
        $template->param( 'catcode' => $patron_categories->next->categorycode )  if $patron_categories->count == 1;
121
    }
120
    }
122
121
123
    if (C4::Context->preference('ExtendedPatronAttributes')) {
124
        my $attributes = GetBorrowerAttributes($borrowernumber);
125
        $template->param(
126
            ExtendedPatronAttributes => 1,
127
            extendedattributes => $attributes
128
        );
129
    }
130
131
    $template->param(
122
    $template->param(
132
        csrf_token => Koha::Token->new->generate_csrf({ session_id => scalar $input->cookie('CGISESSID') }),
123
        csrf_token => Koha::Token->new->generate_csrf({ session_id => scalar $input->cookie('CGISESSID') }),
133
        patron         => $patron,
124
        patron         => $patron,
(-)a/members/member-flags.pl (-9 lines)
Lines 11-17 use C4::Output; Link Here
11
use C4::Auth qw(:DEFAULT :EditPermissions);
11
use C4::Auth qw(:DEFAULT :EditPermissions);
12
use C4::Context;
12
use C4::Context;
13
use C4::Members;
13
use C4::Members;
14
use C4::Members::Attributes qw(GetBorrowerAttributes);
15
#use C4::Acquisitions;
14
#use C4::Acquisitions;
16
15
17
use Koha::Patron::Categories;
16
use Koha::Patron::Categories;
Lines 188-201 if ($input->param('newflags')) { Link Here
188
        $template->param( 'catcode' => $patron_categories->next->categorycode )  if $patron_categories->count == 1;
187
        $template->param( 'catcode' => $patron_categories->next->categorycode )  if $patron_categories->count == 1;
189
    }
188
    }
190
189
191
if (C4::Context->preference('ExtendedPatronAttributes')) {
192
    my $attributes = GetBorrowerAttributes($bor->{'borrowernumber'});
193
    $template->param(
194
        ExtendedPatronAttributes => 1,
195
        extendedattributes => $attributes
196
    );
197
}
198
199
$template->param(
190
$template->param(
200
    patron         => $patron,
191
    patron         => $patron,
201
    loop           => \@loop,
192
    loop           => \@loop,
(-)a/members/member-password.pl (-9 lines)
Lines 13-19 use C4::Context; Link Here
13
use C4::Members;
13
use C4::Members;
14
use C4::Circulation;
14
use C4::Circulation;
15
use CGI qw ( -utf8 );
15
use CGI qw ( -utf8 );
16
use C4::Members::Attributes qw(GetBorrowerAttributes);
17
use Koha::AuthUtils;
16
use Koha::AuthUtils;
18
use Koha::Token;
17
use Koha::Token;
19
18
Lines 101-114 if ( $patron->is_child ) { Link Here
101
    $template->param( 'catcode' => $patron_categories->next->categorycode )  if $patron_categories->count == 1;
100
    $template->param( 'catcode' => $patron_categories->next->categorycode )  if $patron_categories->count == 1;
102
}
101
}
103
102
104
if ( C4::Context->preference('ExtendedPatronAttributes') ) {
105
    my $attributes = GetBorrowerAttributes( $bor->{'borrowernumber'} );
106
    $template->param(
107
        ExtendedPatronAttributes => 1,
108
        extendedattributes       => $attributes
109
    );
110
}
111
112
$template->param(
103
$template->param(
113
    patron                     => $patron,
104
    patron                     => $patron,
114
    destination                => $destination,
105
    destination                => $destination,
(-)a/members/memberentry.pl (-1 lines)
Lines 734-740 foreach (qw(dateenrolled dateexpiry dateofbirth)) { Link Here
734
}
734
}
735
735
736
if (C4::Context->preference('ExtendedPatronAttributes')) {
736
if (C4::Context->preference('ExtendedPatronAttributes')) {
737
    $template->param(ExtendedPatronAttributes => 1);
738
    patron_attributes_form($template, $borrowernumber);
737
    patron_attributes_form($template, $borrowernumber);
739
}
738
}
740
739
(-)a/members/moremember.pl (-1 lines)
Lines 287-293 if (C4::Context->preference('ExtendedPatronAttributes')) { Link Here
287
    }
287
    }
288
288
289
    $template->param(
289
    $template->param(
290
        ExtendedPatronAttributes => 1,
291
        attributes_loop => \@attributes_loop
290
        attributes_loop => \@attributes_loop
292
    );
291
    );
293
292
(-)a/members/notices.pl (-9 lines)
Lines 25-31 use C4::Output; Link Here
25
use CGI qw ( -utf8 );
25
use CGI qw ( -utf8 );
26
use C4::Members;
26
use C4::Members;
27
use C4::Letters;
27
use C4::Letters;
28
use C4::Members::Attributes qw(GetBorrowerAttributes);
29
use Koha::Patrons;
28
use Koha::Patrons;
30
29
31
my $input=new CGI;
30
my $input=new CGI;
Lines 66-79 if ( $op eq 'resend_notice' ) { Link Here
66
# Getting the messages
65
# Getting the messages
67
my $queued_messages = C4::Letters::GetQueuedMessages({borrowernumber => $borrowernumber});
66
my $queued_messages = C4::Letters::GetQueuedMessages({borrowernumber => $borrowernumber});
68
67
69
if (C4::Context->preference('ExtendedPatronAttributes')) {
70
    my $attributes = GetBorrowerAttributes($borrowernumber);
71
    $template->param(
72
        ExtendedPatronAttributes => 1,
73
        extendedattributes => $attributes
74
    );
75
}
76
77
$template->param(
68
$template->param(
78
    patron             => $patron,
69
    patron             => $patron,
79
    QUEUED_MESSAGES    => $queued_messages,
70
    QUEUED_MESSAGES    => $queued_messages,
(-)a/members/pay.pl (-24 / +5 lines)
Lines 38-44 use C4::Accounts; Link Here
38
use C4::Stats;
38
use C4::Stats;
39
use C4::Koha;
39
use C4::Koha;
40
use C4::Overdues;
40
use C4::Overdues;
41
use C4::Members::Attributes qw(GetBorrowerAttributes);
42
use Koha::Patrons;
41
use Koha::Patrons;
43
42
44
use Koha::Patron::Categories;
43
use Koha::Patron::Categories;
Lines 138-144 sub add_accounts_to_template { Link Here
138
        }
137
        }
139
        push @accounts, $account_line;
138
        push @accounts, $account_line;
140
    }
139
    }
141
    borrower_add_additional_fields($patron->unblessed);
140
    if ( $patron->is_child ) {
141
        my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']} );
142
        $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1;
143
        $template->param( 'catcode' => $patron_categories->next->categorycode )  if $patron_categories->count == 1;
144
    }
142
145
143
    $template->param(
146
    $template->param(
144
        patron   => $patron,
147
        patron   => $patron,
Lines 215-242 sub writeoff_all { Link Here
215
    return;
218
    return;
216
}
219
}
217
220
218
sub borrower_add_additional_fields {
219
    my $b_ref = shift;
220
221
# some borrower info is not returned in the standard call despite being assumed
222
# in a number of templates. It should not be the business of this script but in lieu of
223
# a revised api here it is ...
224
    if ( $b_ref->{category_type} eq 'C' ) {
225
        my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
226
        $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1;
227
        $template->param( 'catcode' => $patron_categories->next->categorycode )  if $patron_categories->count == 1;
228
    }
229
230
    if (C4::Context->preference('ExtendedPatronAttributes')) {
231
        $b_ref->{extendedattributes} = GetBorrowerAttributes($borrowernumber);
232
        $template->param(
233
            ExtendedPatronAttributes => 1,
234
        );
235
    }
236
237
    return;
238
}
239
240
sub payselected {
221
sub payselected {
241
    my @params = @_;
222
    my @params = @_;
242
    my $amt    = 0;
223
    my $amt    = 0;
(-)a/members/paycollect.pl (-21 / +5 lines)
Lines 25-31 use C4::Context; Link Here
25
use C4::Auth;
25
use C4::Auth;
26
use C4::Output;
26
use C4::Output;
27
use C4::Members;
27
use C4::Members;
28
use C4::Members::Attributes qw(GetBorrowerAttributes);
29
use C4::Accounts;
28
use C4::Accounts;
30
use C4::Koha;
29
use C4::Koha;
31
30
Lines 178-184 if ( $total_paid and $total_paid ne '0.00' ) { Link Here
178
    $total_paid = '0.00';    #TODO not right with pay_individual
177
    $total_paid = '0.00';    #TODO not right with pay_individual
179
}
178
}
180
179
181
borrower_add_additional_fields($borrower, $template);
180
if ( $patron->is_child ) {
181
    my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']}    );
182
    $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1;
183
    $template->param( 'catcode' => $patron_categories->next->categorycode )  if $patron_categories->count == 1;
184
}
182
185
183
$template->param(%$borrower);
186
$template->param(%$borrower);
184
187
Lines 186-213 $template->param( Link Here
186
    borrowernumber => $borrowernumber,    # some templates require global
189
    borrowernumber => $borrowernumber,    # some templates require global
187
    patron        => $patron,
190
    patron        => $patron,
188
    total         => $total_due,
191
    total         => $total_due,
189
    ExtendedPatronAttributes => C4::Context->preference('ExtendedPatronAttributes'),
190
192
191
    csrf_token => Koha::Token->new->generate_csrf({ session_id => scalar $input->cookie('CGISESSID') }),
193
    csrf_token => Koha::Token->new->generate_csrf({ session_id => scalar $input->cookie('CGISESSID') }),
192
);
194
);
193
195
194
output_html_with_http_headers $input, $cookie, $template->output;
196
output_html_with_http_headers $input, $cookie, $template->output;
195
197
196
sub borrower_add_additional_fields {
197
    my ( $b_ref, $template ) = @_;
198
199
# some borrower info is not returned in the standard call despite being assumed
200
# in a number of templates. It should not be the business of this script but in lieu of
201
# a revised api here it is ...
202
    if ( $b_ref->{category_type} eq 'C' ) {
203
        my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
204
        $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1;
205
        $template->param( 'catcode' => $patron_categories->next->categorycode )  if $patron_categories->count == 1;
206
    }
207
208
    if (C4::Context->preference('ExtendedPatronAttributes')) {
209
        $b_ref->{extendedattributes} = GetBorrowerAttributes($b_ref->{borrowernumber});
210
    }
211
212
    return;
213
}
(-)a/members/purchase-suggestions.pl (-9 lines)
Lines 24-30 use C4::Auth; Link Here
24
use C4::Context;
24
use C4::Context;
25
use C4::Output;
25
use C4::Output;
26
use C4::Members;
26
use C4::Members;
27
use C4::Members::Attributes qw(GetBorrowerAttributes);
28
use C4::Suggestions;
27
use C4::Suggestions;
29
use Koha::Patrons;
28
use Koha::Patrons;
30
29
Lines 52-65 $template->param( Link Here
52
    suggestionsview  => 1,
51
    suggestionsview  => 1,
53
);
52
);
54
53
55
if (C4::Context->preference('ExtendedPatronAttributes')) {
56
    my $attributes = GetBorrowerAttributes($borrowernumber);
57
    $template->param(
58
        ExtendedPatronAttributes => 1,
59
        extendedattributes => $attributes
60
    );
61
}
62
63
my $suggestions = SearchSuggestion( { suggestedby => $borrowernumber } );
54
my $suggestions = SearchSuggestion( { suggestedby => $borrowernumber } );
64
55
65
$template->param( suggestions => $suggestions );
56
$template->param( suggestions => $suggestions );
(-)a/members/readingrec.pl (-9 lines)
Lines 29-35 use C4::Output; Link Here
29
use C4::Members;
29
use C4::Members;
30
use List::MoreUtils qw/any uniq/;
30
use List::MoreUtils qw/any uniq/;
31
use Koha::DateUtils;
31
use Koha::DateUtils;
32
use C4::Members::Attributes qw(GetBorrowerAttributes);
33
32
34
use Koha::Patrons;
33
use Koha::Patrons;
35
use Koha::Patron::Categories;
34
use Koha::Patron::Categories;
Lines 102-115 if (! $limit){ Link Here
102
	$limit = 'full';
101
	$limit = 'full';
103
}
102
}
104
103
105
if (C4::Context->preference('ExtendedPatronAttributes')) {
106
    my $attributes = GetBorrowerAttributes($patron->borrowernumber);
107
    $template->param(
108
        ExtendedPatronAttributes => 1,
109
        extendedattributes => $attributes
110
    );
111
}
112
113
$template->param(
104
$template->param(
114
    patron            => $patron,
105
    patron            => $patron,
115
    readingrecordview => 1,
106
    readingrecordview => 1,
(-)a/members/routing-lists.pl (-9 lines)
Lines 22-28 use CGI qw ( -utf8 ); Link Here
22
use C4::Output;
22
use C4::Output;
23
use C4::Auth qw/:DEFAULT/;
23
use C4::Auth qw/:DEFAULT/;
24
use C4::Members;
24
use C4::Members;
25
use C4::Members::Attributes qw(GetBorrowerAttributes);
26
use C4::Context;
25
use C4::Context;
27
use C4::Serials;
26
use C4::Serials;
28
use Koha::Patrons;
27
use Koha::Patrons;
Lines 76-87 $template->param( Link Here
76
    branch            => $branch, # FIXME This is confusing
75
    branch            => $branch, # FIXME This is confusing
77
);
76
);
78
77
79
if (C4::Context->preference('ExtendedPatronAttributes')) {
80
    my $attributes = GetBorrowerAttributes($borrowernumber);
81
    $template->param(
82
        ExtendedPatronAttributes => 1,
83
        extendedattributes => $attributes
84
    );
85
}
86
87
output_html_with_http_headers $query, $cookie, $template->output;
78
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/members/statistics.pl (-9 lines)
Lines 29-35 use C4::Auth; Link Here
29
use C4::Context;
29
use C4::Context;
30
use C4::Members;
30
use C4::Members;
31
use C4::Members::Statistics;
31
use C4::Members::Statistics;
32
use C4::Members::Attributes qw(GetBorrowerAttributes);
33
use C4::Output;
32
use C4::Output;
34
use Koha::Patrons;
33
use Koha::Patrons;
35
34
Lines 76-89 my $count_total_issues = $total->{count_total_issues_today} || 0; Link Here
76
my $count_total_issues_returned = $total->{count_total_issues_returned_today} || 0;
75
my $count_total_issues_returned = $total->{count_total_issues_returned_today} || 0;
77
my $count_total_actual_state = ($count_total_precedent_state - $count_total_issues_returned + $count_total_issues);
76
my $count_total_actual_state = ($count_total_precedent_state - $count_total_issues_returned + $count_total_issues);
78
77
79
if (C4::Context->preference('ExtendedPatronAttributes')) {
80
    my $attributes = GetBorrowerAttributes($borrowernumber);
81
    $template->param(
82
        ExtendedPatronAttributes => 1,
83
        extendedattributes => $attributes
84
    );
85
}
86
87
$template->param(
78
$template->param(
88
    patron             => $patron,
79
    patron             => $patron,
89
    statisticsview     => 1,
80
    statisticsview     => 1,
(-)a/reports/borrowers_stats.pl (-1 lines)
Lines 137-143 if ($do_it) { Link Here
137
		CGIsepChoice => $CGIsepChoice,
137
		CGIsepChoice => $CGIsepChoice,
138
    );
138
    );
139
    if (C4::Context->preference('ExtendedPatronAttributes')) {
139
    if (C4::Context->preference('ExtendedPatronAttributes')) {
140
        $template->param(ExtendedPatronAttributes => 1);
141
        patron_attributes_form($template);
140
        patron_attributes_form($template);
142
    }
141
    }
143
}
142
}
(-)a/tools/viewlog.pl (-10 lines)
Lines 69-89 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
69
69
70
if ( $src eq 'circ' ) {
70
if ( $src eq 'circ' ) {
71
71
72
    # if we were called from circulation, use the circulation menu and get data to populate it -fbcit
73
    use C4::Members::Attributes qw(GetBorrowerAttributes);
74
    my $borrowernumber = $object;
72
    my $borrowernumber = $object;
75
    my $patron = Koha::Patrons->find( $borrowernumber );
73
    my $patron = Koha::Patrons->find( $borrowernumber );
76
    unless ( $patron ) {
74
    unless ( $patron ) {
77
        print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
75
        print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
78
        exit;
76
        exit;
79
    }
77
    }
80
    if ( C4::Context->preference('ExtendedPatronAttributes') ) {
81
        my $attributes = GetBorrowerAttributes( $borrowernumber );
82
        $template->param(
83
            ExtendedPatronAttributes => 1,
84
            extendedattributes       => $attributes
85
        );
86
    }
87
78
88
    $template->param(
79
    $template->param(
89
        patron      => $patron,
80
        patron      => $patron,
90
- 

Return to bug 12159