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;
}
+=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
use Koha::Database;
use Koha::Exceptions::Patron::Attribute;
use Koha::Patron::Attribute::Types;
+use Koha::AuthorisedValues;
use base qw(Koha::Object);
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;
=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
use Koha::Holds;
use C4::Context;
use CGI::Session;
-use C4::Members::Attributes qw(GetBorrowerAttributes);
use Koha::AuthorisedValues;
use Koha::CsvProfiles;
use Koha::Patrons;
$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';
[% END %]
[% END %]
- [% IF ( ExtendedPatronAttributes ) %][% FOREACH extendedattribute IN extendedattributes %]
- [% IF ( extendedattribute.display_checkout ) %]
- [% IF ( extendedattribute.value ) %]
- <li class="patronattribute"><span class="patronattributelabel">[% extendedattribute.description | html %]</span> : [% IF ( extendedattribute.value_description ) %][% extendedattribute.value_description | html %][% ELSE %][% extendedattribute.value | html %][% END %]</li>
+ [% IF Koha.Preference('ExtendedPatronAttributes') %]
+ [% FOREACH extendedattribute IN patron.attributes %]
+ [% IF ( extendedattribute.display_checkout ) %]
+ <li class="patronattribute"><span class="patronattributelabel">[% extendedattribute.type_description | html %]</span> : [% IF ( extendedattribute.value_description ) %][% extendedattribute.value_description | html %][% ELSE %][% extendedattribute.attribute | html %][% END %]</li>
[% END %]
[% END %]
- [% END %][% END %]
+ [% END %]
<li class="patroncategory">Category: [% patron.category.description | html %] ([% patron.categorycode | html %])</li>
<li class="patronlibrary">Home library: [% Branches.GetName( patron.branchcode ) | html %]</li>
<li class="patronborrowernumber">Borrowernumber: [% patron.borrowernumber | html %]</li>
[% END # IF step_7 %]
[% IF ( step_4 ) %]
-[% IF ( ExtendedPatronAttributes ) %][% UNLESS ( no_patron_attribute_types ) %]
+[% IF Koha.Preference('ExtendedPatronAttributes') %][% UNLESS ( no_patron_attribute_types ) %]
<fieldset class="rows" id="memberentry_patron_attributes">
<legend id="patron_attributes_lgd">Additional attributes and identifiers</legend>
<input type="hidden" name="setting_extended_patron_attributes" value="1" />
</div> [% #/ div#houseboundroles %]
[% END %]
- [% IF ( ExtendedPatronAttributes ) %]
+ [% IF Koha.Preference('ExtendedPatronAttributes') %]
[% UNLESS ( no_patron_attribute_types ) %]
<div id="patron-extended-attributes" class="patroninfo-section">
[% IF ( attributes_loop ) %]
[% USE Branches %]
+[% USE Koha %]
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha › Reports [% IF ( do_it ) %]› Patrons statistics › Results[% ELSE %]› Patrons statistics[% END %]</title>
[% ELSE %]
<input type="hidden" name="Filter" />
[% END %]
- [% IF ( ExtendedPatronAttributes ) %]
+ [% IF Koha.Preference('ExtendedPatronAttributes') %]
<tr>
<th colspan="4">Patron attributes</th>
</tr>
use CGI qw ( -utf8 );
use C4::Members;
use C4::Accounts;
-use C4::Members::Attributes qw(GetBorrowerAttributes);
use Koha::Patrons;
use Koha::Patron::Categories;
$totalcredit = 1;
}
-if (C4::Context->preference('ExtendedPatronAttributes')) {
- my $attributes = GetBorrowerAttributes($borrowernumber);
- $template->param(
- ExtendedPatronAttributes => 1,
- extendedattributes => $attributes
- );
-}
-
$template->param(
patron => $patron,
finesview => 1,
use C4::Auth;
use C4::Output;
use C4::Members;
-use C4::Members::Attributes qw(GetBorrowerAttributes);
use C4::Debug;
use Koha::DateUtils;
$bf->DelFile( id => scalar $cgi->param('file_id') );
}
- if (C4::Context->preference('ExtendedPatronAttributes')) {
- my $attributes = GetBorrowerAttributes($borrowernumber);
- $template->param(
- ExtendedPatronAttributes => 1,
- extendedattributes => $attributes
- );
- }
-
$template->param(
files => Koha::Patron::Files->new( borrowernumber => $borrowernumber )
->GetFilesInfo(),
use CGI;
use C4::Auth;
use C4::Context;
-use C4::Members::Attributes qw(GetBorrowerAttributes);
use C4::Output;
use DateTime;
use Koha::DateUtils;
# Ensure template has all patron details.
$template->param( patron => $patron );
-# Load extended patron attributes if necessary (taken from members/files.pl).
-if ( C4::Context->preference('ExtendedPatronAttributes') and $patron ) {
- my $attributes = GetBorrowerAttributes($patron->borrowernumber);
- $template->param(
- ExtendedPatronAttributes => 1,
- extendedattributes => $attributes
- );
-}
-
$template->param(
housebound_profile => $houseboundprofile,
visit => $houseboundvisit,
use C4::Members;
use C4::Accounts;
use C4::Items;
-use C4::Members::Attributes qw(GetBorrowerAttributes);
+use Koha::Patrons;
use Koha::Items;
use Koha::Patrons;
print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
} else {
-
- if (C4::Context->preference('ExtendedPatronAttributes')) {
- my $attributes = GetBorrowerAttributes($borrowernumber);
- $template->param(
- ExtendedPatronAttributes => 1,
- extendedattributes => $attributes
- );
- }
-
$template->param(
patron => $patron,
finesview => 1,
use C4::Members;
use C4::Accounts;
use C4::Items;
-use C4::Members::Attributes qw(GetBorrowerAttributes);
use Koha::Token;
use Koha::Items;
}
$template->param( invoice_types_loop => \@invoice_types );
- if (C4::Context->preference('ExtendedPatronAttributes')) {
- my $attributes = GetBorrowerAttributes($borrowernumber);
- $template->param(
- ExtendedPatronAttributes => 1,
- extendedattributes => $attributes
- );
- }
-
$template->param(
csrf_token => Koha::Token->new->generate_csrf({ session_id => scalar $input->cookie('CGISESSID') }),
patron => $patron,
use C4::Auth qw(:DEFAULT :EditPermissions);
use C4::Context;
use C4::Members;
-use C4::Members::Attributes qw(GetBorrowerAttributes);
#use C4::Acquisitions;
use Koha::Patron::Categories;
push @loop, \%row;
}
-if (C4::Context->preference('ExtendedPatronAttributes')) {
- my $attributes = GetBorrowerAttributes($bor->{'borrowernumber'});
- $template->param(
- ExtendedPatronAttributes => 1,
- extendedattributes => $attributes
- );
-}
-
$template->param(
patron => $patron,
loop => \@loop,
use C4::Members;
use C4::Circulation;
use CGI qw ( -utf8 );
-use C4::Members::Attributes qw(GetBorrowerAttributes);
use Koha::AuthUtils;
use Koha::Token;
};
}
-if ( C4::Context->preference('ExtendedPatronAttributes') ) {
- my $attributes = GetBorrowerAttributes( $patron_id );
- $template->param(
- ExtendedPatronAttributes => 1,
- extendedattributes => $attributes
- );
-}
-
$template->param(
patron => $patron,
destination => $destination,
}
if (C4::Context->preference('ExtendedPatronAttributes')) {
- $template->param(ExtendedPatronAttributes => 1);
patron_attributes_form($template, $borrowernumber);
}
}
$template->param(
- ExtendedPatronAttributes => 1,
attributes_loop => \@attributes_loop
);
use CGI qw ( -utf8 );
use C4::Members;
use C4::Letters;
-use C4::Members::Attributes qw(GetBorrowerAttributes);
use Koha::Patrons;
use Koha::Patron::Categories;
# Getting the messages
my $queued_messages = C4::Letters::GetQueuedMessages({borrowernumber => $borrowernumber});
-if (C4::Context->preference('ExtendedPatronAttributes')) {
- my $attributes = GetBorrowerAttributes($borrowernumber);
- $template->param(
- ExtendedPatronAttributes => 1,
- extendedattributes => $attributes
- );
-}
-
$template->param(
patron => $patron,
QUEUED_MESSAGES => $queued_messages,
use C4::Stats;
use C4::Koha;
use C4::Overdues;
-use C4::Members::Attributes qw(GetBorrowerAttributes);
use Koha::Patrons;
use Koha::Patron::Categories;
while ( my $account_line = $account_lines->next ) {
push @accounts, $account_line;
}
- borrower_add_additional_fields($patron);
$template->param(
patron => $patron,
return;
}
-sub borrower_add_additional_fields {
- my $patron = shift;
-
-# some borrower info is not returned in the standard call despite being assumed
-# in a number of templates. It should not be the business of this script but in lieu of
-# a revised api here it is ...
- if (C4::Context->preference('ExtendedPatronAttributes')) {
- my $extendedattributes = GetBorrowerAttributes($patron->borrowernumber);
- $template->param(
- extendedattributes => $extendedattributes,
- ExtendedPatronAttributes => 1,
- );
- }
-
- return;
-}
-
sub payselected {
my $parameters = shift;
use C4::Auth;
use C4::Output;
use C4::Members;
-use C4::Members::Attributes qw(GetBorrowerAttributes);
use C4::Accounts;
use C4::Koha;
$total_paid = '0.00'; #TODO not right with pay_individual
}
-borrower_add_additional_fields($patron, $template);
-
$template->param(%$borrower);
if ( $input->param('error_over') ) {
borrowernumber => $borrowernumber, # some templates require global
patron => $patron,
total => $total_due,
- ExtendedPatronAttributes => C4::Context->preference('ExtendedPatronAttributes'),
csrf_token => Koha::Token->new->generate_csrf({ session_id => scalar $input->cookie('CGISESSID') }),
);
output_html_with_http_headers $input, $cookie, $template->output;
-
-sub borrower_add_additional_fields {
- my ( $patron, $template ) = @_;
-
-# some borrower info is not returned in the standard call despite being assumed
-# in a number of templates. It should not be the business of this script but in lieu of
-# a revised api here it is ...
-
- if (C4::Context->preference('ExtendedPatronAttributes')) {
- my $extendedattributes = GetBorrowerAttributes($patron->borrowernumber);
- $template->param( extendedattributes => $extendedattributes );
- }
-
- return;
-}
use C4::Context;
use C4::Output;
use C4::Members;
-use C4::Members::Attributes qw(GetBorrowerAttributes);
use C4::Suggestions;
use Koha::Patrons;
suggestionsview => 1,
);
-if (C4::Context->preference('ExtendedPatronAttributes')) {
- my $attributes = GetBorrowerAttributes($borrowernumber);
- $template->param(
- ExtendedPatronAttributes => 1,
- extendedattributes => $attributes
- );
-}
-
my $suggestions = SearchSuggestion( { suggestedby => $borrowernumber } );
$template->param( suggestions => $suggestions );
use C4::Members;
use List::MoreUtils qw/any uniq/;
use Koha::DateUtils;
-use C4::Members::Attributes qw(GetBorrowerAttributes);
use Koha::Patrons;
use Koha::Patron::Categories;
$limit = 'full';
}
-if (C4::Context->preference('ExtendedPatronAttributes')) {
- my $attributes = GetBorrowerAttributes($patron->borrowernumber);
- $template->param(
- ExtendedPatronAttributes => 1,
- extendedattributes => $attributes
- );
-}
-
$template->param(
patron => $patron,
readingrecordview => 1,
use C4::Output;
use C4::Auth qw/:DEFAULT/;
use C4::Members;
-use C4::Members::Attributes qw(GetBorrowerAttributes);
use C4::Context;
use C4::Serials;
use Koha::Patrons;
routinglistview => 1,
);
-if (C4::Context->preference('ExtendedPatronAttributes')) {
- my $attributes = GetBorrowerAttributes($borrowernumber);
- $template->param(
- ExtendedPatronAttributes => 1,
- extendedattributes => $attributes
- );
-}
-
output_html_with_http_headers $query, $cookie, $template->output;
use C4::Context;
use C4::Members;
use C4::Members::Statistics;
-use C4::Members::Attributes qw(GetBorrowerAttributes);
use C4::Output;
use Koha::Patrons;
use Koha::Patron::Categories;
my $count_total_issues_returned = $total->{count_total_issues_returned_today} || 0;
my $count_total_actual_state = ($count_total_precedent_state - $count_total_issues_returned + $count_total_issues);
-if (C4::Context->preference('ExtendedPatronAttributes')) {
- my $attributes = GetBorrowerAttributes($borrowernumber);
- $template->param(
- ExtendedPatronAttributes => 1,
- extendedattributes => $attributes
- );
-}
-
$template->param(
patron => $patron,
statisticsview => 1,
CGIsepChoice => $CGIsepChoice,
);
if (C4::Context->preference('ExtendedPatronAttributes')) {
- $template->param(ExtendedPatronAttributes => 1);
patron_attributes_form($template);
}
}
if ( $src eq 'circ' ) {
- # if we were called from circulation, use the circulation menu and get data to populate it -fbcit
- use C4::Members::Attributes qw(GetBorrowerAttributes);
my $borrowernumber = $object;
my $patron = Koha::Patrons->find( $borrowernumber );
my $circ_info = 1;
unless ( $patron ) {
$circ_info = 0;
}
- if ( C4::Context->preference('ExtendedPatronAttributes') ) {
- my $attributes = GetBorrowerAttributes( $borrowernumber );
- $template->param(
- ExtendedPatronAttributes => 1,
- extendedattributes => $attributes
- );
- }
$template->param(
patron => $patron,