+[% USE AuthorisedValues %]
[% USE Branches %]
[% USE Categories %]
[% USE KohaDates %]
[% END %]
[% BLOCK display_extended_attributes %]
- [% FOREACH attr IN attributes %]
- <span>[% attr.code %]: [% IF pending %][% attr.value %][% ELSE %][% attr.attribute %][% END %]</span><br/>
+ [% IF attrs and attrs.size > 1 %]
+ <ul>
+ [% FOREACH attr IN attrs %]
+ <li>[% PROCESS display_attribute attr=attr type=type %]</li>
+ [% END %]
+ <ul>
+ [% ELSIF attrs %]
+ [% PROCESS display_attribute attr=attrs.0 type=type %]
+ [% END %]
+[% END %]
+
+[% BLOCK display_attribute %]
+ [% IF type.authorised_value_category %]
+ [% AuthorisedValues.GetByCode(type.authorised_value_category,attr.attribute) %]
+ [% ELSE %]
+ [% attr.attribute %]
[% END %]
[% END %]
<label for="ignore_modify_[% pm.borrowernumber %]">Ignore</label>
| <a target="_blank" href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% pm.borrowernumber %]" >Patron details</a>
</div>
+ [% IF !pm.extended_attributes and pm.size > 3 or
+ pm.extended_attributes and pm.size > 4 %]
+ [%# timestamp+verification_token+borrowernumber=3 %]
+ <div class="members-update-table">
<table>
<tr>
<th>Field</th>
[% FOREACH key IN pm.keys %]
- [% IF ( key != "timestamp" ) %]
+ [% IF ( key != "timestamp" and key != "extended_attributes" ) %]
[% IF ( ( pm.$key OR borrowers.$borrowernumber.$key ) && ( pm.$key != borrowers.$borrowernumber.$key ) ) %]
<tr>
<td>[% PROCESS display_names field = key %]</td>
[% 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>
[% END %]
[% END %]
</table>
+ </div>
+ [% END %]
+ [% IF borrowers.$borrowernumber.modified_attributes %]
+ <div class="members-update-table">
+ <h4>[% PROCESS display_names field='extended_attributes' %]</h4>
+ <table>
+ <tr>
+ <th>Field</th>
+ <th>Old value</th>
+ <th>New value</th>
+ </tr>
+ [% FOREACH attribute_group IN borrowers.$borrowernumber.modified_attributes %]
+ <tr>
+ <td>[% attribute_group.type.description %]</td>
+ <td>[% PROCESS display_extended_attributes attrs=attribute_group.before type=attribute_group.type %]</td>
+ <td>[% PROCESS display_extended_attributes attrs=attribute_group.after type=attribute_group.type %]</td>
+ </tr>
+ [% END %]
+ </table>
+ </div>
+ [% END %]
</div>
[% END %]
</div>
use C4::Output;
use C4::Context;
use C4::Members;
+use Koha::Patron::Attribute::Types;
use Koha::Patron::Attributes;
use Koha::Patron::Modifications;
+use Koha::Patrons;
+
+use List::MoreUtils qw( uniq );
my $query = new CGI;
my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
- {
- template_name => "members/members-update.tt",
+ { template_name => "members/members-update.tt",
query => $query,
type => "intranet",
authnotrequired => 0,
}
);
-my $branch =
- ( C4::Context->preference("IndependentBranchesPatronModifications")
- || C4::Context->preference("IndependentBranches") )
- && !$flags->{'superlibrarian'}
- ? C4::Context->userenv()->{'branch'}
- : undef;
+my $branch
+ = ( C4::Context->preference("IndependentBranchesPatronModifications")
+ || C4::Context->preference("IndependentBranches") )
+ && !$flags->{'superlibrarian'}
+ ? C4::Context->userenv()->{'branch'}
+ : undef;
-my $pending_modifications =
- Koha::Patron::Modifications->pending($branch);
+my $pending_modifications = Koha::Patron::Modifications->pending($branch);
my $borrowers;
foreach my $pm (@$pending_modifications) {
- $borrowers->{ $pm->{borrowernumber} }
- = GetMember( borrowernumber => $pm->{borrowernumber} );
- my @patron_attributes
- = grep { $_->opac_editable }
- Koha::Patron::Attributes->search(
- { borrowernumber => $pm->{borrowernumber} } );
- $borrowers->{ $pm->{'borrowernumber'} }->{extended_attributes}
- = \@patron_attributes;
+
+ my @modified_atypes = uniq( map { $_->code } @{ $pm->{extended_attributes} } );
+ my $modified_attributes;
+
+ foreach my $type (@modified_atypes) {
+ my $type_obj = Koha::Patron::Attribute::Types->find($type);
+ my @before = Koha::Patron::Attributes->search(
+ { borrowernumber => $pm->{borrowernumber}, code => $type } );
+ my @after = grep { $_->code eq $type } @{ $pm->{extended_attributes} };
+ push @{$modified_attributes}, { type => $type_obj, before => \@before, after => \@after };
+ }
+
+ $borrowers->{ $pm->{borrowernumber} } = Koha::Patrons->find($pm->{borrowernumber})->unblessed;
+ $borrowers->{ $pm->{borrowernumber} }->{modified_attributes} = $modified_attributes;
}
$template->param(