Reworking statistics for payments and writeoffs
[koha.git] / pay.pl
1 #!/usr/bin/perl
2
3 #wrriten 11/1/2000 by chris@katipo.oc.nz
4 #part of the koha library system, script to facilitate paying off fines
5
6 use strict;
7 use C4::Output;
8 use CGI;
9 use C4::Search;
10 use C4::Accounts2;
11 my $input=new CGI;
12
13
14 my $bornum=$input->param('bornum');
15 if ($bornum eq ''){
16   $bornum=$input->param('bornum0');
17 }
18 #get borrower details
19 my $data=borrdata('',$bornum);
20 my $user=$input->remote_user;
21
22 #get account details
23 my %bor;
24 $bor{'borrowernumber'}=$bornum;                            
25
26
27 my @names=$input->param;
28 my %inp;
29 my $check=0;
30 for (my $i=0;$i<@names;$i++){
31   my$temp=$input->param($names[$i]);
32   if ($temp eq 'wo'){
33     $inp{$names[$i]}=$temp;
34     $check=1;
35   }
36   if ($temp eq 'yes'){
37     $user=~ s/Levin/C/i;
38     $user=~ s/Foxton/F/i;
39     $user=~ s/Shannon/S/i;
40     my $amount=$input->param($names[$i+4]);
41     my $bornum=$input->param($names[$i+5]);
42     my $accountno=$input->param($names[$i+6]);
43     makepayment($bornum,$accountno,$amount,$user);
44     $check=2;
45   }
46 }
47 my %env;
48     $user=~ s/Levin/C/i;
49     $user=~ s/Foxton/F/i;
50     $user=~ s/Shannon/S/i;
51
52 $env{'branchcode'}=$user;
53 my $total=$input->param('total');
54 if ($check ==0){
55   if ($total ne ''){
56     recordpayment(\%env,$bornum,$total);
57   }
58 my ($numaccts,$accts,$total)=getboracctrecord('',\%bor);     
59 print $input->header;
60 print startpage();
61 print startmenu('member');
62 print <<printend
63 <FONT SIZE=6><em>Pay Fines for $data->{'firstname'} $data->{'surname'}</em></FONT><P>
64 <center>
65 <p>
66 <TABLE  CELLSPACING=0  CELLPADDING=5 border=1 >
67 <TR VALIGN=TOP>
68 <td  bgcolor="99cc33" background="/images/background-mem.gif" colspan=4><B>FINES & CHARGES</TD>
69 <td  bgcolor="99cc33" background="/images/background-mem.gif" colspan=4><B>AMOUNT OWING</TD>
70 </TR>
71 <form action=/cgi-bin/koha/pay.pl method=post>
72 <input type=hidden name=bornum value=$bornum>
73 printend
74 ;
75 for (my $i=0;$i<$numaccts;$i++){
76 if ($accts->[$i]{'amountoutstanding'} > 0){
77 $accts->[$i]{'amount'}+=0.00;
78 $accts->[$i]{'amountoutstanding'}+=0.00;
79 print <<printend
80 <tr VALIGN=TOP  >
81 <TD><input type=radio name=payfine$i value=no checked>Unpaid
82 <input type=radio name=payfine$i value=yes>Pay
83 <input type=radio name=payfine$i value=wo>Writeoff
84 <input type=hidden name=itemnumber$i value=$accts->[$i]{'itemnumber'}>
85 <input type=hidden name=accounttype$i value=$accts->[$i]{'accounttype'}>
86 <input type=hidden name=amount$i value=$accts->[$i]{'amount'}>
87 <input type=hidden name=out$i value=$accts->[$i]{'amountoutstanding'}>
88 <input type=hidden name=bornum$i value=$bornum>
89 <input type=hidden name=accountno$i value=$accts->[$i]{'accountno'}>
90 </td>
91 <TD>$accts->[$i]{'description'} $accts->[$i]{'title'}</td>
92 <TD>$accts->[$i]{'accounttype'}</td>
93 <td>$accts->[$i]{'amount'}</td>
94 <TD>$accts->[$i]{'amountoutstanding'}</td>
95
96 </tr>
97 printend
98 ;
99 }
100 }
101 print <<printend
102 <tr VALIGN=TOP  >
103 <TD></td>
104 <TD colspan=2><b>Total Due</b></td>
105
106 <TD><b>$total</b></td>
107
108 </tr>
109
110
111
112 <tr VALIGN=TOP  >
113 <TD></td>
114 <TD colspan=3><b>AMOUNT PAID</b></td>
115 <TD><input type=text name=total value="" SIZE=7></td>
116 </tr>
117 <tr VALIGN=TOP  >
118 <TD colspan=5 align=right>
119 <INPUT TYPE="image" name="submit"  VALUE="pay" height=42  WIDTH=187 BORDER=0 src="/images/pay-fines.gif"></td>
120 </tr>
121 </form>
122 </table>
123
124
125
126
127
128
129 <br clear=all>
130 <p> &nbsp; </p>
131
132 printend
133 ;
134 print endmenu('member');
135 print endpage();
136
137 } else {
138   my $quety=$input->query_string;
139   print $input->redirect("/cgi-bin/koha/sec/writeoff.pl?$quety");
140 }