3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 3 of the License, or (at your option) any later
10 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along
15 # with Koha; if not, write to the Free Software Foundation, Inc.,
16 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 use C4
::Koha
qw( getitemtypeinfo );
26 use C4
::Circulation
qw( GetIssuingCharges );
32 my $borrowernumber = $input->param('borrowernumber');
34 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
36 template_name
=> "members/moremember-print.tt",
40 flagsrequired
=> { circulate
=> "circulate_remaining_permissions" },
45 my $data = GetMember
( 'borrowernumber' => $borrowernumber );
47 my ( $total, $accts, $numaccts ) = GetMemberAccountRecords
($borrowernumber);
48 foreach my $accountline (@
$accts) {
49 $accountline->{amount
} = sprintf( '%.2f', $accountline->{amount
} )
50 if ( $accountline->{amount
} ) ;
51 $accountline->{amountoutstanding
} = sprintf( '%.2f', $accountline->{amountoutstanding
} )
52 if ( $accountline->{amountoutstanding
} );
54 if ( $accountline->{accounttype
} ne 'F'
55 && $accountline->{accounttype
} ne 'FU' )
57 $accountline->{printtitle
} = 1;
62 my $total_format = '';
63 $total_format = sprintf( "%.2f", $total ) if ($total);
65 my $holds_rs = Koha
::Holds
->search(
66 { borrowernumber
=> $borrowernumber },
72 borrowernumber
=> $borrowernumber,
75 totaldue
=> $total_format,
77 issues
=> build_issue_data
( GetPendingIssues
($borrowernumber) ),
78 totalprice
=> $totalprice,
80 reserves
=> build_reserve_data
( $holds_rs ),
83 output_html_with_http_headers
$input, $cookie, $template->output;
85 sub build_issue_data
{
90 my $today = DateTime
->now( time_zone
=> C4
::Context
->tz );
91 $today->truncate( to
=> 'day' );
93 foreach my $issue ( @
{$issues} ) {
96 $totalprice += $issue->{replacementprice
}
97 if ( $issue->{replacementprice
} );
99 #find the charge for an item
100 my ( $charge, $itemtype ) =
101 GetIssuingCharges
( $issue->{itemnumber
}, $borrowernumber );
103 my $itemtypeinfo = getitemtypeinfo
($itemtype);
104 $row{'itemtype_description'} = $itemtypeinfo->{description
};
106 $row{'charge'} = sprintf( "%.2f", $charge );
108 $row{date_due
} = $row{date_due_sql
};
110 push( @
{$return}, \
%row );
113 @
{$return} = sort { $a->{date_due
} eq $b->{date_due
} } @
{$return};
119 sub build_reserve_data
{
120 my $reserves = shift;
124 my $today = DateTime
->now( time_zone
=> C4
::Context
->tz );
125 $today->truncate( to
=> 'day' );
127 while ( my $reserve = $reserves->next() ) {
130 title
=> $reserve->biblio()->title(),
131 author
=> $reserve->biblio()->author(),
132 reservedate
=> $reserve->reservedate(),
133 expirationdate
=> $reserve->expirationdate(),
134 waiting_at
=> $reserve->branch()->branchname(),
137 push( @
{$return}, $row );
140 @
{$return} = sort { $a->{reservedate
} <=> $b->{reservedate
} } @
{$return};