@@ -, +, @@
circ-menu
- Replace getting preference ExtendedPatronAttributes by Koha.Preference
- Add Koha::Patron->attributes for getting patrons extended attributes
- Use this method in circ-menu.inc
- Remove getting attributes from members perl scripts
limited by libraries...
---
Koha/Patron.pm | 17 +++++++
Koha/Patron/Attribute.pm | 52 ++++++++++++++++++++++
Koha/Patron/Attributes.pm | 32 +++++++++++++
circ/circulation.pl | 8 ----
.../intranet-tmpl/prog/en/includes/circ-menu.inc | 10 ++---
.../prog/en/modules/members/memberentrygen.tt | 2 +-
.../prog/en/modules/members/moremember.tt | 2 +-
.../prog/en/modules/reports/borrowers_stats.tt | 3 +-
members/boraccount.pl | 9 ----
members/files.pl | 9 ----
members/housebound.pl | 10 -----
members/mancredit.pl | 11 +----
members/maninvoice.pl | 9 ----
members/member-flags.pl | 9 ----
members/member-password.pl | 9 ----
members/memberentry.pl | 1 -
members/moremember.pl | 1 -
members/notices.pl | 9 ----
members/pay.pl | 19 --------
members/paycollect.pl | 19 --------
members/purchase-suggestions.pl | 9 ----
members/readingrec.pl | 9 ----
members/routing-lists.pl | 9 ----
members/statistics.pl | 9 ----
reports/borrowers_stats.pl | 1 -
tools/viewlog.pl | 9 ----
26 files changed, 111 insertions(+), 176 deletions(-)
--- a/Koha/Patron.pm
+++ a/Koha/Patron.pm
@@ -34,6 +34,7 @@ use Koha::DateUtils;
use Koha::Exceptions::Password;
use Koha::Holds;
use Koha::Old::Checkouts;
+use Koha::Patron::Attributes;
use Koha::Patron::Categories;
use Koha::Patron::HouseboundProfile;
use Koha::Patron::HouseboundRole;
@@ -1290,6 +1291,22 @@ sub generate_userid {
}
+=head3 attributes
+
+my $attributes = $patron->attributes
+
+Return object of Koha::Patron::Attributes type with all attributes set for this patron
+
+=cut
+
+sub attributes {
+ my ( $self ) = @_;
+ return Koha::Patron::Attributes->search({
+ borrowernumber => $self->borrowernumber,
+ branchcode => $self->branchcode,
+ });
+}
+
=head2 Internal methods
=head3 _type
--- a/Koha/Patron/Attribute.pm
+++ a/Koha/Patron/Attribute.pm
@@ -20,6 +20,7 @@ use Modern::Perl;
use Koha::Database;
use Koha::Exceptions::Patron::Attribute;
use Koha::Patron::Attribute::Types;
+use Koha::AuthorisedValues;
use base qw(Koha::Object);
@@ -79,6 +80,57 @@ sub opac_editable {
return Koha::Patron::Attribute::Types->find( $self->code )->opac_editable;
}
+=head3 display_checkout
+
+ my $attribute = Koha::Patron::Attribute->new({ code => 'a_code', ... });
+ if ( $attribute->display_checkout ) { ... }
+
+=cut
+
+sub display_checkout {
+
+ my $self = shift;
+
+ return $self->type->display_checkout;
+}
+
+=head3 value_description
+
+ my $description = $attribute->value_description
+
+ Return authorised value description or free text based on attribute type settings
+
+=cut
+
+sub value_description {
+
+ my $self = shift;
+
+ if ( $self->type->authorised_value_category ) {
+ my $av = Koha::AuthorisedValues->search({
+ category => $self->type->authorised_value_category,
+ authorised_value => $self->attribute,
+ });
+ return $av->next->lib if $av->count;
+ }
+ return $self->attribute;
+}
+
+=head3 type_description
+
+ my $description = $attribute->type_description
+
+ Return description of attribute type
+
+=cut
+
+sub type_description {
+
+ my $self = shift;
+
+ return $self->type->description;
+}
+
=head3 type
my $attribute_type = $attribute->type;
--- a/Koha/Patron/Attributes.pm
+++ a/Koha/Patron/Attributes.pm
@@ -31,6 +31,38 @@ Koha::Patron::Attributes - Koha Patron Attributes Object set class
=cut
+=head3 search
+
+my $attributes-> Koha::Patron::Attributes->search( $params );
+
+=cut
+
+sub search {
+ my ( $self, $params, $attributes ) = @_;
+
+ my $branchcode = $params->{branchcode};
+ delete( $params->{branchcode} );
+
+ my $or =
+ $branchcode
+ ? {
+ '-or' => [
+ 'borrower_attribute_types_branches.b_branchcode' => undef,
+ 'borrower_attribute_types_branches.b_branchcode' => $branchcode,
+ ]
+ } : {};
+
+ my $join =
+ $branchcode
+ ? {
+ join => {
+ 'borrower_attribute_types' => 'borrower_attribute_types_branches'
+ },
+ } : {};
+ $attributes //= {};
+ return $self->SUPER::search( { %$params, %$or }, { %$attributes, %$join } );
+}
+
=head3 _type
=cut
--- a/circ/circulation.pl
+++ a/circ/circulation.pl
@@ -43,7 +43,6 @@ use C4::Reserves;
use Koha::Holds;
use C4::Context;
use CGI::Session;
-use C4::Members::Attributes qw(GetBorrowerAttributes);
use Koha::AuthorisedValues;
use Koha::CsvProfiles;
use Koha::Patrons;
@@ -552,13 +551,6 @@ if ( Koha::BiblioFrameworks->find('FA') ) {
$fast_cataloging = 1
}
-if (C4::Context->preference('ExtendedPatronAttributes')) {
- my $attributes = GetBorrowerAttributes($borrowernumber);
- $template->param(
- ExtendedPatronAttributes => 1,
- extendedattributes => $attributes
- );
-}
my $view = $batch
?'batch_checkout_view'
: 'circview';
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc
+++ a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc
@@ -68,13 +68,13 @@
[% END %]
[% END %]
- [% IF ( ExtendedPatronAttributes ) %][% FOREACH extendedattribute IN extendedattributes %]
- [% IF ( extendedattribute.display_checkout ) %]
- [% IF ( extendedattribute.value ) %]
-
[% extendedattribute.description | html %] : [% IF ( extendedattribute.value_description ) %][% extendedattribute.value_description | html %][% ELSE %][% extendedattribute.value | html %][% END %]
+ [% IF Koha.Preference('ExtendedPatronAttributes') %]
+ [% FOREACH extendedattribute IN patron.attributes %]
+ [% IF ( extendedattribute.display_checkout ) %]
+
[% extendedattribute.type_description | html %] : [% IF ( extendedattribute.value_description ) %][% extendedattribute.value_description | html %][% ELSE %][% extendedattribute.attribute | html %][% END %]
[% END %]
[% END %]
- [% END %][% END %]
+ [% END %]
Category: [% patron.category.description | html %] ([% patron.categorycode | html %])
Home library: [% Branches.GetName( patron.branchcode ) | html %]
Borrowernumber: [% patron.borrowernumber | html %]
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt
@@ -1041,7 +1041,7 @@
[% END # IF step_7 %]
[% IF ( step_4 ) %]
-[% IF ( ExtendedPatronAttributes ) %][% UNLESS ( no_patron_attribute_types ) %]
+[% IF Koha.Preference('ExtendedPatronAttributes') %][% UNLESS ( no_patron_attribute_types ) %]