Increment version for 3.22.6 release
[koha.git] / members / summary-print.pl
blob1544d99b325cddcbd58e49834b9f844bd7121aaf
1 #!/usr/bin/perl
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
8 # version.
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.
18 use Modern::Perl;
20 use CGI;
22 use C4::Auth;
23 use C4::Output;
24 use C4::Members;
25 use C4::Koha qw( getitemtypeinfo );
26 use C4::Circulation qw( GetIssuingCharges );
28 my $input = CGI->new;
29 my $borrowernumber = $input->param('borrowernumber');
31 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
33 template_name => "members/moremember-print.tt",
34 query => $input,
35 type => "intranet",
36 authnotrequired => 0,
37 flagsrequired => { circulate => "circulate_remaining_permissions" },
38 debug => 1,
42 my $data = GetMember( 'borrowernumber' => $borrowernumber );
44 my ( $total, $accts, $numaccts ) = GetMemberAccountRecords($borrowernumber);
45 foreach my $accountline (@$accts) {
46 $accountline->{amount} = sprintf( '%.2f', $accountline->{amount} )
47 if ( $accountline->{amount} ) ;
48 $accountline->{amountoutstanding} = sprintf( '%.2f', $accountline->{amountoutstanding} )
49 if ( $accountline->{amountoutstanding} );
51 if ( $accountline->{accounttype} ne 'F'
52 && $accountline->{accounttype} ne 'FU' )
54 $accountline->{printtitle} = 1;
58 our $totalprice = 0;
59 my $total_format = '';
60 $total_format = sprintf( "%.2f", $total ) if ($total);
62 $template->param(
63 %$data,
65 borrowernumber => $borrowernumber,
67 accounts => $accts,
68 totaldue => $total_format,
70 issues => build_issue_data( GetPendingIssues($borrowernumber) ),
71 totalprice => $totalprice,
74 output_html_with_http_headers $input, $cookie, $template->output;
76 sub build_issue_data {
77 my $issues = shift;
79 my $return = [];
81 my $today = DateTime->now( time_zone => C4::Context->tz );
82 $today->truncate( to => 'day' );
84 foreach my $issue ( @{$issues} ) {
86 my %row = %{$issue};
87 $totalprice += $issue->{replacementprice}
88 if ( $issue->{replacementprice} );
90 #find the charge for an item
91 my ( $charge, $itemtype ) =
92 GetIssuingCharges( $issue->{itemnumber}, $borrowernumber );
94 my $itemtypeinfo = getitemtypeinfo($itemtype);
95 $row{'itemtype_description'} = $itemtypeinfo->{description};
97 $row{'charge'} = sprintf( "%.2f", $charge );
99 $row{date_due} = $row{date_due_sql};
101 push( @{$return}, \%row );
104 @{$return} = sort { $a->{date_due} eq $b->{date_due} } @{$return};
106 return $return;