Lines 1-10
Link Here
|
1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
2 |
|
2 |
|
3 |
|
|
|
4 |
#writen 3rd May 2010 by kmkale@anantcorp.com adapted from boraccount.pl by chris@katipo.oc.nz |
3 |
#writen 3rd May 2010 by kmkale@anantcorp.com adapted from boraccount.pl by chris@katipo.oc.nz |
5 |
#script to print fee receipts |
4 |
#script to print fee receipts |
6 |
|
5 |
|
7 |
|
|
|
8 |
# Copyright Koustubha Kale |
6 |
# Copyright Koustubha Kale |
9 |
# |
7 |
# |
10 |
# This file is part of Koha. |
8 |
# This file is part of Koha. |
Lines 33-142
use C4::Members;
Link Here
|
33 |
use C4::Branch; |
31 |
use C4::Branch; |
34 |
use C4::Accounts; |
32 |
use C4::Accounts; |
35 |
|
33 |
|
36 |
my $input=new CGI; |
34 |
my $input = new CGI; |
37 |
|
|
|
38 |
|
35 |
|
39 |
my ($template, $loggedinuser, $cookie) |
36 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
40 |
= get_template_and_user({template_name => "members/printinvoice.tmpl", |
37 |
{ template_name => "members/printinvoice.tmpl", |
41 |
query => $input, |
38 |
query => $input, |
42 |
type => "intranet", |
39 |
type => "intranet", |
43 |
authnotrequired => 0, |
40 |
authnotrequired => 0, |
44 |
flagsrequired => {borrowers => 1, updatecharges => 1}, |
41 |
flagsrequired => { borrowers => 1, updatecharges => 1 }, |
45 |
debug => 1, |
42 |
debug => 1, |
46 |
}); |
43 |
} |
|
|
44 |
); |
47 |
|
45 |
|
48 |
my $borrowernumber=$input->param('borrowernumber'); |
46 |
my $borrowernumber = $input->param('borrowernumber'); |
49 |
my $action = $input->param('action') || ''; |
47 |
my $action = $input->param('action') || ''; |
50 |
my $accountlines_id = $input->param('accountlines_id'); |
48 |
my $accountlines_id = $input->param('accountlines_id'); |
51 |
|
49 |
|
52 |
#get borrower details |
50 |
#get borrower details |
53 |
my $data=GetMember('borrowernumber' => $borrowernumber); |
51 |
my $data = GetMember( 'borrowernumber' => $borrowernumber ); |
54 |
|
|
|
55 |
if ( $action eq 'print' ) { |
56 |
# ReversePayment( $borrowernumber, $input->param('accountno') ); |
57 |
} |
58 |
|
52 |
|
59 |
if ( $data->{'category_type'} eq 'C') { |
53 |
if ( $data->{'category_type'} eq 'C' ) { |
60 |
my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' ); |
54 |
my ( $catcodes, $labels ) = GetborCatFromCatType( 'A', 'WHERE category_type = ?' ); |
61 |
my $cnt = scalar(@$catcodes); |
55 |
my $cnt = scalar(@$catcodes); |
62 |
$template->param( 'CATCODE_MULTI' => 1) if $cnt > 1; |
56 |
$template->param( 'CATCODE_MULTI' => 1 ) if $cnt > 1; |
63 |
$template->param( 'catcode' => $catcodes->[0]) if $cnt == 1; |
57 |
$template->param( 'catcode' => $catcodes->[0] ) if $cnt == 1; |
64 |
} |
58 |
} |
65 |
|
59 |
|
66 |
#get account details |
60 |
#get account details |
67 |
my ($total,$accts,$numaccts)=GetMemberAccountRecords($borrowernumber); |
61 |
my ( $total, $accts, $numaccts ) = GetMemberAccountRecords($borrowernumber); |
68 |
my $totalcredit; |
62 |
my $totalcredit; |
69 |
if($total <= 0){ |
63 |
if ( $total <= 0 ) { |
70 |
$totalcredit = 1; |
64 |
$totalcredit = 1; |
71 |
} |
65 |
} |
72 |
my @accountrows; # this is for the tmpl-loop |
66 |
|
|
|
67 |
my @accountrows; # this is for the tmpl-loop |
73 |
|
68 |
|
74 |
my $toggle; |
69 |
my $toggle; |
75 |
for (my $i=0;$i<$numaccts;$i++){ |
70 |
for ( my $i = 0 ; $i < $numaccts ; $i++ ) { |
76 |
next if ($accts->[$i]{'accountlines_id'} ne $accountlines_id ); |
71 |
next if ( $accts->[$i]{'accountlines_id'} ne $accountlines_id ); |
77 |
if($i%2){ |
72 |
|
78 |
$toggle = 0; |
73 |
if ( $i % 2 ) { |
|
|
74 |
$toggle = 0; |
79 |
} else { |
75 |
} else { |
80 |
$toggle = 1; |
76 |
$toggle = 1; |
81 |
} |
77 |
} |
|
|
78 |
|
82 |
$accts->[$i]{'toggle'} = $toggle; |
79 |
$accts->[$i]{'toggle'} = $toggle; |
83 |
$accts->[$i]{'amount'}+=0.00; |
80 |
$accts->[$i]{'amount'} += 0.00; |
84 |
if($accts->[$i]{'amount'} <= 0){ |
81 |
|
|
|
82 |
if ( $accts->[$i]{'amount'} <= 0 ) { |
85 |
$accts->[$i]{'amountcredit'} = 1; |
83 |
$accts->[$i]{'amountcredit'} = 1; |
86 |
} |
84 |
} |
87 |
$accts->[$i]{'amountoutstanding'}+=0.00; |
85 |
|
88 |
if($accts->[$i]{'amountoutstanding'} <= 0){ |
86 |
$accts->[$i]{'amountoutstanding'} += 0.00; |
|
|
87 |
if ( $accts->[$i]{'amountoutstanding'} <= 0 ) { |
89 |
$accts->[$i]{'amountoutstandingcredit'} = 1; |
88 |
$accts->[$i]{'amountoutstandingcredit'} = 1; |
90 |
} |
89 |
} |
91 |
my %row = ( 'date' => format_date($accts->[$i]{'date'}), |
90 |
|
92 |
'amountcredit' => $accts->[$i]{'amountcredit'}, |
91 |
my %row = ( |
93 |
'amountoutstandingcredit' => $accts->[$i]{'amountoutstandingcredit'}, |
92 |
'date' => format_date( $accts->[$i]{'date'} ), |
94 |
'toggle' => $accts->[$i]{'toggle'}, |
93 |
'amountcredit' => $accts->[$i]{'amountcredit'}, |
95 |
'description' => $accts->[$i]{'description'}, |
94 |
'amountoutstandingcredit' => $accts->[$i]{'amountoutstandingcredit'}, |
96 |
'itemnumber' => $accts->[$i]{'itemnumber'}, |
95 |
'toggle' => $accts->[$i]{'toggle'}, |
97 |
'biblionumber' => $accts->[$i]{'biblionumber'}, |
96 |
'description' => $accts->[$i]{'description'}, |
98 |
'amount' => sprintf("%.2f",$accts->[$i]{'amount'}), |
97 |
'itemnumber' => $accts->[$i]{'itemnumber'}, |
99 |
'amountoutstanding' => sprintf("%.2f",$accts->[$i]{'amountoutstanding'}), |
98 |
'biblionumber' => $accts->[$i]{'biblionumber'}, |
100 |
'accountno' => $accts->[$i]{'accountno'}, |
99 |
'amount' => sprintf( "%.2f", $accts->[$i]{'amount'} ), |
101 |
'payment' => ( $accts->[$i]{'accounttype'} eq 'Pay' ), |
100 |
'amountoutstanding' => sprintf( "%.2f", $accts->[$i]{'amountoutstanding'} ), |
102 |
|
101 |
'accountno' => $accts->[$i]{'accountno'}, |
103 |
); |
102 |
'payment' => ( $accts->[$i]{'accounttype'} eq 'Pay' ), |
104 |
|
103 |
); |
105 |
if ($accts->[$i]{'accounttype'} ne 'F' && $accts->[$i]{'accounttype'} ne 'FU'){ |
104 |
|
106 |
$row{'printtitle'}=1; |
105 |
if ( $accts->[$i]{'accounttype'} ne 'F' && $accts->[$i]{'accounttype'} ne 'FU' ) { |
107 |
$row{'title'} = $accts->[$i]{'title'}; |
106 |
$row{'printtitle'} = 1; |
|
|
107 |
$row{'title'} = $accts->[$i]{'title'}; |
108 |
} |
108 |
} |
109 |
|
109 |
|
110 |
push(@accountrows, \%row); |
110 |
push( @accountrows, \%row ); |
111 |
} |
111 |
} |
112 |
|
112 |
|
113 |
$template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' ); |
113 |
$template->param( adultborrower => 1 ) if ( $data->{'category_type'} eq 'A' ); |
114 |
|
114 |
|
115 |
my ($picture, $dberror) = GetPatronImage($data->{'cardnumber'}); |
115 |
my ( $picture, $dberror ) = GetPatronImage( $data->{'cardnumber'} ); |
116 |
$template->param( picture => 1 ) if $picture; |
116 |
$template->param( picture => 1 ) if $picture; |
117 |
|
117 |
|
118 |
$template->param( |
118 |
$template->param( |
119 |
finesview => 1, |
119 |
finesview => 1, |
120 |
firstname => $data->{'firstname'}, |
120 |
firstname => $data->{'firstname'}, |
121 |
surname => $data->{'surname'}, |
121 |
surname => $data->{'surname'}, |
122 |
borrowernumber => $borrowernumber, |
122 |
borrowernumber => $borrowernumber, |
123 |
cardnumber => $data->{'cardnumber'}, |
123 |
cardnumber => $data->{'cardnumber'}, |
124 |
categorycode => $data->{'categorycode'}, |
124 |
categorycode => $data->{'categorycode'}, |
125 |
category_type => $data->{'category_type'}, |
125 |
category_type => $data->{'category_type'}, |
126 |
# category_description => $data->{'description'}, |
126 |
categoryname => $data->{'description'}, |
127 |
categoryname => $data->{'description'}, |
127 |
address => $data->{'address'}, |
128 |
address => $data->{'address'}, |
128 |
address2 => $data->{'address2'}, |
129 |
address2 => $data->{'address2'}, |
129 |
city => $data->{'city'}, |
130 |
city => $data->{'city'}, |
130 |
zipcode => $data->{'zipcode'}, |
131 |
zipcode => $data->{'zipcode'}, |
131 |
country => $data->{'country'}, |
132 |
country => $data->{'country'}, |
132 |
phone => $data->{'phone'}, |
133 |
phone => $data->{'phone'}, |
133 |
email => $data->{'email'}, |
134 |
email => $data->{'email'}, |
134 |
branchcode => $data->{'branchcode'}, |
135 |
branchcode => $data->{'branchcode'}, |
135 |
branchname => GetBranchName( $data->{'branchcode'} ), |
136 |
branchname => GetBranchName($data->{'branchcode'}), |
136 |
total => sprintf( "%.2f", $total ), |
137 |
total => sprintf("%.2f",$total), |
137 |
totalcredit => $totalcredit, |
138 |
totalcredit => $totalcredit, |
138 |
is_child => ( $data->{'category_type'} eq 'C' ), |
139 |
is_child => ($data->{'category_type'} eq 'C'), |
139 |
accounts => \@accountrows |
140 |
accounts => \@accountrows ); |
140 |
); |
141 |
|
141 |
|
142 |
output_html_with_http_headers $input, $cookie, $template->output; |
142 |
output_html_with_http_headers $input, $cookie, $template->output; |
143 |
- |
|
|