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::Circulation qw( GetIssuingCharges );
33 my $borrowernumber = $input->param('borrowernumber');
35 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
37 template_name => "members/moremember-print.tt",
41 flagsrequired => { circulate => "circulate_remaining_permissions" },
46 my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
47 my $patron = Koha::Patrons->find( $borrowernumber );
48 output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
50 my ( $total, $accts, $numaccts ) = GetMemberAccountRecords($borrowernumber);
51 foreach my $accountline (@$accts) {
52 if ( $accountline->{accounttype} ne 'F'
53 && $accountline->{accounttype} ne 'FU' )
55 $accountline->{printtitle} = 1;
61 my $holds_rs = Koha::Holds->search(
62 { borrowernumber => $borrowernumber },
71 issues => build_issue_data( $borrowernumber ),
72 totalprice => $totalprice,
74 reserves => build_reserve_data( $holds_rs ),
77 output_html_with_http_headers $input, $cookie, $template->output;
79 sub build_issue_data {
80 my ( $borrowernumber ) = @_;
81 my $issues = GetPendingIssues( $borrowernumber );
85 my $today = DateTime->now( time_zone => C4::Context->tz );
86 $today->truncate( to => 'day' );
88 foreach my $issue ( @{$issues} ) {
91 $totalprice += $issue->{replacementprice}
92 if ( $issue->{replacementprice} );
94 #find the charge for an item
95 my ( $charge, $itemtype ) =
96 GetIssuingCharges( $issue->{itemnumber}, $borrowernumber );
98 $itemtype = Koha::ItemTypes->find( $itemtype );
99 $row{'itemtype_description'} = $itemtype->description; #FIXME Should not it be translated_description
101 $row{'charge'} = sprintf( "%.2f", $charge );
103 $row{date_due} = $row{date_due_sql};
105 push( @{$return}, \%row );
108 @{$return} = sort { $a->{date_due} eq $b->{date_due} } @{$return};
114 sub build_reserve_data {
115 my $reserves = shift;
119 my $today = DateTime->now( time_zone => C4::Context->tz );
120 $today->truncate( to => 'day' );
122 while ( my $reserve = $reserves->next() ) {
125 title => $reserve->biblio()->title(),
126 author => $reserve->biblio()->author(),
127 reservedate => $reserve->reservedate(),
128 expirationdate => $reserve->expirationdate(),
129 waiting_at => $reserve->branch()->branchname(),
132 push( @{$return}, $row );
135 @{$return} = sort { $a->{reservedate} <=> $b->{reservedate} } @{$return};