Bug 7154: Modification in borrower attributes
[koha_gimpoz] / members / moremember.pl
index c477100..b9d0c8f 100755 (executable)
@@ -51,7 +51,6 @@ use C4::Reserves;
 use C4::Branch; # GetBranchName
 use C4::Overdues qw/CheckBorrowerDebarred/;
 use C4::Form::MessagingPreferences;
-use C4::NewsChannels; #get slip news
 use List::MoreUtils qw/uniq/;
 use C4::Members::Attributes qw(GetBorrowerAttributes);
 
@@ -252,7 +251,6 @@ my $issuecount     = @{$issue};
 my $relissuecount  = @{$relissue};
 my $roaddetails = &GetRoadTypeDetails( $data->{'streettype'} );
 my $today       = POSIX::strftime("%Y-%m-%d", localtime);      # iso format
-my @issuedata;
 my @borrowers_with_issues;
 my $overdues_exist = 0;
 my $totalprice = 0;
@@ -432,11 +430,29 @@ my $branch=C4::Context->userenv->{'branch'};
 $template->param(%$data);
 
 if (C4::Context->preference('ExtendedPatronAttributes')) {
-    my $attributes = GetBorrowerAttributes($borrowernumber);
+    my $attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber);
+    my @classes = uniq( map {$_->{class}} @$attributes );
+    @classes = sort @classes;
+
+    my @attributes_loop;
+    for my $class (@classes) {
+        my @items;
+        for my $attr (@$attributes) {
+            push @items, $attr if $attr->{class} eq $class
+        }
+        my $lib = GetAuthorisedValueByCode( 'PA_CLASS', $class ) || $class;
+        push @attributes_loop, {
+            class => $class,
+            items => \@items,
+            lib   => $lib,
+        };
+    }
+
     $template->param(
         ExtendedPatronAttributes => 1,
-        extendedattributes => $attributes
+        attributes_loop => \@attributes_loop
     );
+
     my @types = C4::Members::AttributeTypes::GetAttributeTypes();
     if (scalar(@types) == 0) {
         $template->param(no_patron_attribute_types => 1);
@@ -484,13 +500,4 @@ $template->param(
        activeBorrowerRelationship => (C4::Context->preference('borrowerRelationship') ne ''),
 );
 
-#Get the slip news items
-my $all_koha_news   = &GetNewsToDisplay("slip");
-my $koha_news_count = scalar @$all_koha_news;
-
-$template->param(
-    koha_news       => $all_koha_news,
-    koha_news_count => $koha_news_count
-);
-
 output_html_with_http_headers $input, $cookie, $template->output;