Bug 12001: Move GetMemberAccountRecords to the Koha namespace
[srvgit] / members / summary-print.pl
index a6a0e36..03e9d89 100755 (executable)
@@ -43,24 +43,15 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     }
 );
 
-my $patron = Koha::Patrons->find( $borrowernumber );
-unless ( $patron ) {
-    print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
-    exit;
-}
-my $category = $patron->category;
-my $data = $patron->unblessed;
-$data->{description} = $category->description;
-$data->{category_type} = $category->category_type;
-
-my ( $total, $accts, $numaccts ) = GetMemberAccountRecords($borrowernumber);
-foreach my $accountline (@$accts) {
-    if (   $accountline->{accounttype} ne 'F'
-        && $accountline->{accounttype} ne 'FU' )
-    {
-        $accountline->{printtitle} = 1;
-    }
-}
+my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
+my $patron         = Koha::Patrons->find( $borrowernumber );
+output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
+
+my $total = $patron->account->balance;
+my $accts = Koha::Account::Lines->search(
+    { borrowernumber => $patron->borrowernumber },
+    { order_by       => { -desc => 'accountlines_id' } }
+);
 
 our $totalprice = 0;
 
@@ -69,9 +60,7 @@ my $holds_rs = Koha::Holds->search(
 );
 
 $template->param(
-    %$data,
-
-    borrowernumber => $borrowernumber,
+    patron => $patron,
 
     accounts => $accts,
     totaldue => $total,