3 #writen 3rd May 2010 by kmkale@anantcorp.com adapted from boraccount.pl by chris@katipo.oc.nz
4 #script to print fee receipts
6 # Copyright Koustubha Kale
8 # This file is part of Koha.
10 # Koha is free software; you can redistribute it and/or modify it under the
11 # terms of the GNU General Public License as published by the Free Software
12 # Foundation; either version 2 of the License, or (at your option) any later
15 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
16 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License along
20 # with Koha; if not, write to the Free Software Foundation, Inc.,
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 use C4
::Dates qw
/format_date/;
36 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
37 { template_name
=> "members/printinvoice.tt",
41 flagsrequired
=> { borrowers
=> 1, updatecharges
=> 'remaining_permissions' },
46 my $borrowernumber = $input->param('borrowernumber');
47 my $action = $input->param('action') || '';
48 my $accountlines_id = $input->param('accountlines_id');
51 my $data = GetMember
( 'borrowernumber' => $borrowernumber );
53 if ( $data->{'category_type'} eq 'C' ) {
54 my ( $catcodes, $labels ) = GetborCatFromCatType
( 'A', 'WHERE category_type = ?' );
55 my $cnt = scalar(@
$catcodes);
56 $template->param( 'CATCODE_MULTI' => 1 ) if $cnt > 1;
57 $template->param( 'catcode' => $catcodes->[0] ) if $cnt == 1;
61 my ( $total, $accts, $numaccts ) = GetMemberAccountRecords
($borrowernumber);
67 my @accountrows; # this is for the tmpl-loop
70 for ( my $i = 0 ; $i < $numaccts ; $i++ ) {
71 next if ( $accts->[$i]{'accountlines_id'} ne $accountlines_id );
79 $accts->[$i]{'toggle'} = $toggle;
80 $accts->[$i]{'amount'} += 0.00;
82 if ( $accts->[$i]{'amount'} <= 0 ) {
83 $accts->[$i]{'amountcredit'} = 1;
86 $accts->[$i]{'amountoutstanding'} += 0.00;
87 if ( $accts->[$i]{'amountoutstanding'} <= 0 ) {
88 $accts->[$i]{'amountoutstandingcredit'} = 1;
92 'date' => format_date
( $accts->[$i]{'date'} ),
93 'amountcredit' => $accts->[$i]{'amountcredit'},
94 'amountoutstandingcredit' => $accts->[$i]{'amountoutstandingcredit'},
95 'toggle' => $accts->[$i]{'toggle'},
96 'description' => $accts->[$i]{'description'},
97 'itemnumber' => $accts->[$i]{'itemnumber'},
98 'biblionumber' => $accts->[$i]{'biblionumber'},
99 'amount' => sprintf( "%.2f", $accts->[$i]{'amount'} ),
100 'amountoutstanding' => sprintf( "%.2f", $accts->[$i]{'amountoutstanding'} ),
101 'accountno' => $accts->[$i]{'accountno'},
102 'payment' => ( $accts->[$i]{'accounttype'} =~ /^Pay/ ),
105 if ( $accts->[$i]{'accounttype'} ne 'F' && $accts->[$i]{'accounttype'} ne 'FU' ) {
106 $row{'printtitle'} = 1;
107 $row{'title'} = $accts->[$i]{'title'};
110 push( @accountrows, \
%row );
113 $template->param( adultborrower
=> 1 ) if ( $data->{'category_type'} eq 'A' );
115 my ( $picture, $dberror ) = GetPatronImage
( $data->{'borrowernumber'} );
116 $template->param( picture
=> 1 ) if $picture;
120 firstname
=> $data->{'firstname'},
121 surname
=> $data->{'surname'},
122 borrowernumber
=> $borrowernumber,
123 cardnumber
=> $data->{'cardnumber'},
124 categorycode
=> $data->{'categorycode'},
125 category_type
=> $data->{'category_type'},
126 categoryname
=> $data->{'description'},
127 address
=> $data->{'address'},
128 address2
=> $data->{'address2'},
129 city
=> $data->{'city'},
130 zipcode
=> $data->{'zipcode'},
131 country
=> $data->{'country'},
132 phone
=> $data->{'phone'},
133 email
=> $data->{'email'},
134 branchcode
=> $data->{'branchcode'},
135 branchname
=> GetBranchName
( $data->{'branchcode'} ),
136 total
=> sprintf( "%.2f", $total ),
137 totalcredit
=> $totalcredit,
138 is_child
=> ( $data->{'category_type'} eq 'C' ),
139 accounts
=> \
@accountrows
142 output_html_with_http_headers
$input, $cookie, $template->output;