Bug 13757: Better display for attr changes in members-update.pl

This patch changes the way changed attributes are displayed for the
staff user to make the decision to approve (or not) the changes.

Regards

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
Tomas Cohen Arazi 2017-02-03 15:22:57 -03:00 committed by Kyle M Hall
parent f9a5fd005e
commit afb7b7dc2d
3 changed files with 73 additions and 24 deletions

View File

@ -152,6 +152,10 @@ label input[type="radio"],
font-weight : bold;
}
.members-update-table {
padding-top: 10px;
}
#navmenulist li {
padding : .2em 0;
list-style-image : url("../img/arrow-bullet.gif");

View File

@ -1,3 +1,4 @@
[% USE AuthorisedValues %]
[% USE Branches %]
[% USE Categories %]
[% USE KohaDates %]
@ -68,8 +69,22 @@
[% 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 %]
@ -99,6 +114,10 @@
<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>
@ -108,7 +127,7 @@
[% 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>
@ -118,9 +137,6 @@
[% 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>
@ -130,6 +146,27 @@
[% 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>

View File

@ -24,14 +24,17 @@ use C4::Auth;
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,
@ -40,26 +43,31 @@ my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
}
);
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(