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>.
35 use Koha
::Patron
::Categories
;
40 my ($template, $loggedinuser, $cookie)
41 = get_template_and_user
({template_name
=> "members/printfeercpt.tt",
45 flagsrequired
=> {borrowers
=> 1, updatecharges
=> 'remaining_permissions'},
49 my $borrowernumber=$input->param('borrowernumber');
50 my $action = $input->param('action') || '';
51 my $accountlines_id = $input->param('accountlines_id');
53 my $patron = Koha
::Patrons
->find( $borrowernumber );
54 my $category = $patron->category;
55 my $data = $patron->unblessed;
56 $data->{description
} = $category->description;
57 $data->{category_type
} = $category->category_type;
59 if ( $action eq 'print' ) {
60 # ReversePayment( $borrowernumber, $input->param('accountno') );
63 if ( $data->{'category_type'} eq 'C') {
64 my $patron_categories = Koha
::Patron
::Categories
->search_limited({ category_type
=> 'A' }, {order_by
=> ['categorycode']});
65 $template->param( 'CATCODE_MULTI' => 1) if $patron_categories->count > 1;
66 $template->param( 'catcode' => $patron_categories->next ) if $patron_categories->count == 1;
70 my ($total,$accts,$numaccts)=GetMemberAccountRecords
($borrowernumber);
75 my @accountrows; # this is for the tmpl-loop
78 for (my $i=0;$i<$numaccts;$i++){
79 next if ( $accts->[$i]{'accountlines_id'} ne $accountlines_id );
85 $accts->[$i]{'toggle'} = $toggle;
86 $accts->[$i]{'amount'}+=0.00;
87 if($accts->[$i]{'amount'} <= 0){
88 $accts->[$i]{'amountcredit'} = 1;
89 $accts->[$i]{'amount'}*=-1.00;
91 $accts->[$i]{'amountoutstanding'}+=0.00;
92 if($accts->[$i]{'amountoutstanding'} <= 0){
93 $accts->[$i]{'amountoutstandingcredit'} = 1;
96 my %row = ( 'date' => dt_from_string
( $accts->[$i]{'date'} ),
97 'amountcredit' => $accts->[$i]{'amountcredit'},
98 'amountoutstandingcredit' => $accts->[$i]{'amountoutstandingcredit'},
99 'toggle' => $accts->[$i]{'toggle'},
100 'description' => $accts->[$i]{'description'},
101 'itemnumber' => $accts->[$i]{'itemnumber'},
102 'biblionumber' => $accts->[$i]{'biblionumber'},
103 'amount' => sprintf("%.2f",$accts->[$i]{'amount'}),
104 'amountoutstanding' => sprintf("%.2f",$accts->[$i]{'amountoutstanding'}),
105 'accountno' => $accts->[$i]{'accountno'},
106 accounttype
=> $accts->[$i]{accounttype
},
107 'note' => $accts->[$i]{'note'},
110 if ($accts->[$i]{'accounttype'} ne 'F' && $accts->[$i]{'accounttype'} ne 'FU'){
111 $row{'printtitle'}=1;
112 $row{'title'} = $accts->[$i]{'title'};
115 push(@accountrows, \
%row);
118 $template->param( adultborrower
=> 1 ) if ( $data->{'category_type'} eq 'A' || $data->{'category_type'} eq 'I' );
120 $template->param( picture
=> 1 ) if $patron->image;
124 firstname
=> $data->{'firstname'},
125 surname
=> $data->{'surname'},
126 borrowernumber
=> $borrowernumber,
127 cardnumber
=> $data->{'cardnumber'},
128 categorycode
=> $data->{'categorycode'},
129 category_type
=> $data->{'category_type'},
130 # category_description => $data->{'description'},
131 categoryname
=> $data->{'description'},
132 address
=> $data->{'address'},
133 address2
=> $data->{'address2'},
134 city
=> $data->{'city'},
135 zipcode
=> $data->{'zipcode'},
136 country
=> $data->{'country'},
137 phone
=> $data->{'phone'},
138 email
=> $data->{'email'},
139 branchcode
=> $data->{'branchcode'},
140 total
=> sprintf("%.2f",$total),
141 totalcredit
=> $totalcredit,
142 is_child
=> ($data->{'category_type'} eq 'C'),
143 accounts
=> \
@accountrows );
145 output_html_with_http_headers
$input, $cookie, $template->output;