From db4dc7d29a5b9328d430adb9c08385c38a1f7ed1 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 3 Feb 2017 15:22:57 -0300 Subject: [PATCH] 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 Signed-off-by: Jonathan Druart --- koha-tmpl/intranet-tmpl/prog/css/staff-global.css | 4 ++ .../prog/en/modules/members/members-update.tt | 49 +++++++++++++++++++--- members/members-update.pl | 44 +++++++++++-------- 3 files changed, 73 insertions(+), 24 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/css/staff-global.css index e281e3e..35479c8 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/staff-global.css +++ b/koha-tmpl/intranet-tmpl/prog/css/staff-global.css @@ -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"); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/members-update.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/members-update.tt index cf5bc86..fecf80d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/members-update.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/members-update.tt @@ -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 %] - [% attr.code %]: [% IF pending %][% attr.value %][% ELSE %][% attr.attribute %][% END %]
+ [% IF attrs and attrs.size > 1 %] +
    + [% FOREACH attr IN attrs %] +
  • [% PROCESS display_attribute attr=attr type=type %]
  • + [% END %] +
      + [% 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 @@ | Patron details + [% IF !pm.extended_attributes and pm.size > 3 or + pm.extended_attributes and pm.size > 4 %] + [%# timestamp+verification_token+borrowernumber=3 %] +
      @@ -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 ) ) %] @@ -118,9 +137,6 @@ [% ELSIF key == 'branchcode' %] - [% ELSIF ( key == 'extended_attributes' ) %] - - [% ELSE %] @@ -130,6 +146,27 @@ [% END %] [% END %]
      Field
      [% PROCESS display_names field = key %][% Branches.GetName( borrowers.$borrowernumber.$key ) %] [% Branches.GetName( pm.$key ) %][% PROCESS display_extended_attributes attributes=borrowers.$borrowernumber.$key %][% PROCESS display_extended_attributes attributes=pm.$key pending=1 %][% borrowers.$borrowernumber.$key %] [% pm.$key %]
      +
      + [% END %] + [% IF borrowers.$borrowernumber.modified_attributes %] +
      +

      [% PROCESS display_names field='extended_attributes' %]

      + + + + + + + [% FOREACH attribute_group IN borrowers.$borrowernumber.modified_attributes %] + + + + + + [% END %] +
      FieldOld valueNew value
      [% attribute_group.type.description %][% PROCESS display_extended_attributes attrs=attribute_group.before type=attribute_group.type %][% PROCESS display_extended_attributes attrs=attribute_group.after type=attribute_group.type %]
      +
      + [% END %] [% END %] diff --git a/members/members-update.pl b/members/members-update.pl index 851af14..23d14c7 100755 --- a/members/members-update.pl +++ b/members/members-update.pl @@ -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( -- 2.9.3