[% CASE 'altcontactcountry' %]<span>Alternate contact: Country</span>
[% CASE 'altcontactphone' %]<span>Alternate contact: Phone</span>
[% CASE 'smsalertnumber' %]<span>SMS alert number</span>
+[% CASE 'extended_attributes' %]<span>Additional attributes and identifiers</span>
[% CASE %][% field %]
[% END %]
[% END %]
+[% BLOCK display_extended_attributes %]
+ [% FOREACH attr IN attributes %]
+ <span>[% attr.code %]: [% IF pending %][% attr.value %][% ELSE %][% attr.attribute %][% END %]</span><br/>
+ [% END %]
+[% END %]
+
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a> › Update patron records</div>
<div id="doc2" class="yui-t7">
[% ELSIF key == 'branchcode' %]
<td>[% Branches.GetName( borrowers.$borrowernumber.$key ) %]</td>
<td>[% Branches.GetName( pm.$key ) %]</td>
+ [% ELSIF ( key == 'extended_attributes' ) %]
+ <td>[% PROCESS display_extended_attributes attributes=borrowers.$borrowernumber.$key %]</td>
+ <td>[% PROCESS display_extended_attributes attributes=pm.$key pending=1 %]</td>
[% ELSE %]
<td>[% borrowers.$borrowernumber.$key %]</td>
<td>[% pm.$key %]</td>
[% IF ( pa.type.authorised_value_category ) %]
<select id="[% form_id %]" name="patron_attribute_value">
<option value=""></option>
- [% FOREACH auth_val IN AuthorisedValues.Get( pa.type.authorised_value_category, pa_value.value || '', 1 ) %]
- [% IF ( auth_val.selected ) %]
+ [% FOREACH auth_val IN AuthorisedValues.Get( pa.type.authorised_value_category, 1 ) %]
+ [% IF ( auth_val.authorised_value == pa_value.value ) %]
<option value="[% auth_val.authorised_value %]" selected="selected">
[%# Yes, lib; GetAuthorisedValues takes care of intelligently setting this from lib_opac %]
[% auth_val.lib %]
[% IF ( pa.type.repeatable ) %]
<a href="#" class="clone-attribute">New</a>
[% END %]
- [% IF ( pa.type.password_allowed ) %]
- </li><li><label for="[% form_id %]_password">Password:</label>
- <input type="password" maxlength="64" value="[% pa_value.password %]" id="[% form_id %]_password" name="patron_attribute_password" />
- [% ELSE %]
- [%# To keep the form inputs lined up in the POST %]
- <input type="hidden" name="patron_attribute_password" value="" />
- [% END %]
[% ELSE %]
[% IF ( pa.type.authorised_value_category ) %]
[% AuthorisedValues.GetByCode( pa.type.authorised_value, pa_value.value, 1 ) %]
[% ELSE %]
[% pa_value.value | html_line_break %]
[% END %]
- [% IF ( pa_value.password ) %]
- (Password: *******)
- [% END %]
[% END %]
</li>
[% END %]
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
-use strict;
-use warnings;
+use Modern::Perl;
use CGI qw ( -utf8 );
+
use C4::Auth;
use C4::Output;
use C4::Context;
use C4::Members;
+use C4::Members::Attributes qw( GetBorrowerAttributes );
+use Koha::Patron::Attributes;
use Koha::Patron::Modifications;
my $query = new CGI;
my $borrowers;
foreach my $pm (@$pending_modifications) {
- $borrowers->{ $pm->{'borrowernumber'} } =
- GetMember( borrowernumber => $pm->{'borrowernumber'} );
-
+ $borrowers->{ $pm->{borrowernumber} }
+ = GetMember( borrowernumber => $pm->{borrowernumber} );
+ my $patron_attributes = Koha::Patron::Attributes->search(
+ { borrowernumber => $pm->{borrowernumber} } );
+ $borrowers->{ $pm->{'borrowernumber'} }->{extended_attributes}
+ = $patron_attributes;
}
$template->param(
PendingModifications => $pending_modifications,
- borrowers => $borrowers,
+ borrowers => $borrowers
);
output_html_with_http_headers $query, $cookie, $template->output;
+
+1;
use Digest::MD5 qw( md5_base64 md5_hex );
use Encode qw( encode );
use JSON;
-use List::MoreUtils qw( each_array uniq );
+use List::MoreUtils qw( any each_array uniq );
use String::Random qw( random_string );
use C4::Auth;
use C4::Output;
use C4::Members;
+use C4::Members::Attributes qw( GetBorrowerAttributes );
use C4::Form::MessagingPreferences;
use Koha::Patrons;
use Koha::Patron::Modification;
}
else {
my %borrower_changes = DelUnchangedFields( $borrowernumber, %borrower );
- if (%borrower_changes) {
+ my $extended_attributes_changes = ExtendedAttributesMatch( $borrowernumber, $attributes );
+
+ if ( %borrower_changes || $extended_attributes_changes ) {
( $template, $borrowernumber, $cookie ) = get_template_and_user(
{
template_name => "opac-memberentry-update-submitted.tt",
action => 'edit',
nochanges => 1,
borrower => GetMember( borrowernumber => $borrowernumber ),
+ patron_attribute_classes => GeneratePatronAttributesForm( undef, $attributes ),
csrf_token => Koha::Token->new->generate_csrf({
id => Encode::encode( 'UTF-8', $borrower->{userid} ),
secret => md5_base64( Encode::encode( 'UTF-8', C4::Context->config('pass') ) ),
return %borrower;
}
+sub ExtendedAttributesMatch {
+ my ( $borrowernumber, $entered_attributes ) = @_;
+
+ my @patron_attributes_arr = GetBorrowerAttributes( $borrowernumber, 1 );
+ my $patron_attributes = $patron_attributes_arr[0];
+
+ if ( scalar @{$entered_attributes} != scalar @{$patron_attributes} ) {
+ return 1;
+ }
+
+ foreach my $attr ( @{$patron_attributes} ) {
+ next if any {
+ $_->{code} eq $attr->{code} and $_->{value} eq $attr->{value};
+ }
+ @{$entered_attributes};
+ return 1;
+ }
+
+ return 0;
+}
+
+
sub GeneratePatronAttributesForm {
my ( $borrowernumber, $entered_attributes ) = @_;
my @codes = $cgi->multi_param('patron_attribute_code');
my @values = $cgi->multi_param('patron_attribute_value');
- my @passwords = $cgi->multi_param('patron_attribute_password');
- my $ea = each_array( @codes, @values, @passwords );
+ my $ea = each_array( @codes, @values );
my @attributes;
my %dups = ();
next if exists $dups{$code}->{$value};
$dups{$code}->{$value} = 1;
- push @attributes, { code => $code, value => $value, password => $password };
+ push @attributes, { code => $code, value => $value };
}
return \@attributes;