3 #written 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
11 # under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 3 of the License, or
13 # (at your option) any later version.
15 # Koha is distributed in the hope that it will be useful, but
16 # WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with Koha; if not, see <http://www.gnu.org/licenses>.
33 use Koha
::Patron
::Categories
;
37 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
38 { template_name
=> "members/printinvoice.tt",
42 flagsrequired
=> { borrowers
=> 'edit_borrowers', updatecharges
=> 'remaining_permissions' },
47 my $borrowernumber = $input->param('borrowernumber');
48 my $action = $input->param('action') || '';
49 my $accountlines_id = $input->param('accountlines_id');
51 my $logged_in_user = Koha
::Patrons
->find( $loggedinuser ) or die "Not logged in";
52 my $patron = Koha
::Patrons
->find( $borrowernumber );
53 output_and_exit_if_error
( $input, $cookie, $template, { module
=> 'members', logged_in_user
=> $logged_in_user, current_patron
=> $patron } );
55 if ( $patron->is_child ) {
56 my $patron_categories = Koha
::Patron
::Categories
->search_limited({ category_type
=> 'A' }, {order_by
=> ['categorycode']});
57 $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1;
58 $template->param( 'catcode' => $patron_categories->next->categorycode ) if $patron_categories->count == 1;
62 my ( $total, $accts, $numaccts ) = GetMemberAccountRecords
($borrowernumber);
68 my @accountrows; # this is for the tmpl-loop
71 for ( my $i = 0 ; $i < $numaccts ; $i++ ) {
72 next if ( $accts->[$i]{'accountlines_id'} ne $accountlines_id );
80 $accts->[$i]{'toggle'} = $toggle;
81 $accts->[$i]{'amount'} += 0.00;
83 if ( $accts->[$i]{'amount'} <= 0 ) {
84 $accts->[$i]{'amountcredit'} = 1;
87 $accts->[$i]{'amountoutstanding'} += 0.00;
88 if ( $accts->[$i]{'amountoutstanding'} <= 0 ) {
89 $accts->[$i]{'amountoutstandingcredit'} = 1;
93 'date' => output_pref
({ dt
=> dt_from_string
( $accts->[$i]{'date'} ), dateonly
=> 1 }),
94 'amountcredit' => $accts->[$i]{'amountcredit'},
95 'amountoutstandingcredit' => $accts->[$i]{'amountoutstandingcredit'},
96 'toggle' => $accts->[$i]{'toggle'},
97 'description' => $accts->[$i]{'description'},
98 'itemnumber' => $accts->[$i]{'itemnumber'},
99 'biblionumber' => $accts->[$i]{'biblionumber'},
100 'amount' => sprintf( "%.2f", $accts->[$i]{'amount'} ),
101 'amountoutstanding' => sprintf( "%.2f", $accts->[$i]{'amountoutstanding'} ),
102 'accountno' => $accts->[$i]{'accountno'},
103 accounttype
=> $accts->[$i]{accounttype
},
104 'note' => $accts->[$i]{'note'},
107 if ( $accts->[$i]{'accounttype'} ne 'F' && $accts->[$i]{'accounttype'} ne 'FU' ) {
108 $row{'printtitle'} = 1;
109 $row{'title'} = $accts->[$i]{'title'};
112 push( @accountrows, \
%row );
118 total
=> sprintf( "%.2f", $total ),
119 totalcredit
=> $totalcredit,
120 accounts
=> \
@accountrows
123 output_html_with_http_headers
$input, $cookie, $template->output;