4 #written 3rd May 2010 by kmkale@anantcorp.com adapted from boraccount.pl by chris@katipo.oc.nz
5 #script to print fee receipts
8 # Copyright Koustubha Kale
10 # This file is part of Koha.
12 # Koha is free software; you can redistribute it and/or modify it
13 # under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 3 of the License, or
15 # (at your option) any later version.
17 # Koha is distributed in the hope that it will be useful, but
18 # WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with Koha; if not, see <http://www.gnu.org/licenses>.
34 use Koha::Patron::Categories;
39 my ($template, $loggedinuser, $cookie)
40 = get_template_and_user({template_name => "members/printfeercpt.tt",
44 flagsrequired => {borrowers => 'edit_borrowers', updatecharges => 'remaining_permissions'},
48 my $borrowernumber=$input->param('borrowernumber');
49 my $action = $input->param('action') || '';
50 my $accountlines_id = $input->param('accountlines_id');
52 my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in";
53 my $patron = Koha::Patrons->find( $borrowernumber );
54 output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
56 my $category = $patron->category;
58 if ( $action eq 'print' ) {
59 # ReversePayment( $borrowernumber, $input->param('accountno') );
62 if ( $category->category_type eq 'C') {
63 my $patron_categories = Koha::Patron::Categories->search_limited({ category_type => 'A' }, {order_by => ['categorycode']});
64 $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1;
65 $template->param( 'catcode' => $patron_categories->next->categorycde ) if $patron_categories->count == 1;
69 my ($total,$accts,$numaccts)=GetMemberAccountRecords($borrowernumber);
74 my @accountrows; # this is for the tmpl-loop
77 for (my $i=0;$i<$numaccts;$i++){
78 next if ( $accts->[$i]{'accountlines_id'} ne $accountlines_id );
84 $accts->[$i]{'toggle'} = $toggle;
85 $accts->[$i]{'amount'}+=0.00;
86 if($accts->[$i]{'amount'} <= 0){
87 $accts->[$i]{'amountcredit'} = 1;
88 $accts->[$i]{'amount'}*=-1.00;
90 $accts->[$i]{'amountoutstanding'}+=0.00;
91 if($accts->[$i]{'amountoutstanding'} <= 0){
92 $accts->[$i]{'amountoutstandingcredit'} = 1;
95 my %row = ( 'date' => dt_from_string( $accts->[$i]{'date'} ),
96 'amountcredit' => $accts->[$i]{'amountcredit'},
97 'amountoutstandingcredit' => $accts->[$i]{'amountoutstandingcredit'},
98 'toggle' => $accts->[$i]{'toggle'},
99 'description' => $accts->[$i]{'description'},
100 'itemnumber' => $accts->[$i]{'itemnumber'},
101 'biblionumber' => $accts->[$i]{'biblionumber'},
102 'amount' => sprintf("%.2f",$accts->[$i]{'amount'}),
103 'amountoutstanding' => sprintf("%.2f",$accts->[$i]{'amountoutstanding'}),
104 'accountno' => $accts->[$i]{'accountno'},
105 accounttype => $accts->[$i]{accounttype},
106 'note' => $accts->[$i]{'note'},
109 if ($accts->[$i]{'accounttype'} ne 'F' && $accts->[$i]{'accounttype'} ne 'FU'){
110 $row{'printtitle'}=1;
111 $row{'title'} = $accts->[$i]{'title'};
114 push(@accountrows, \%row);
117 $template->param( adultborrower => 1 ) if ( $category->category_type eq 'A' || $category->category_type eq 'I' );
122 total => sprintf("%.2f",$total),
123 totalcredit => $totalcredit,
124 is_child => ($category->category_type eq 'C'),
125 accounts => \@accountrows );
127 output_html_with_http_headers $input, $cookie, $template->output;