Initial revision
[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     my $amount=$input->param($names[$i+4]);
38     my $bornum=$input->param($names[$i+5]);
39     my $accountno=$input->param($names[$i+6]);
40     makepayment($bornum,$accountno,$amount,$user);
41     $check=2;
42   }
43 }
44 my %env;
45 my $total=$input->param('total');
46 if ($check ==0){
47   if ($total ne ''){
48     recordpayment(\%env,$bornum,$total);
49   }
50 my ($numaccts,$accts,$total)=getboracctrecord('',\%bor);     
51 print $input->header;
52 print startpage();
53 print startmenu('member');
54 print <<printend
55 <FONT SIZE=6><em>Pay Fines for $data->{'firstname'} $data->{'surname'}</em></FONT><P>
56 <center>
57 <p>
58 <TABLE  CELLSPACING=0  CELLPADDING=5 border=1 >
59 <TR VALIGN=TOP>
60 <td  bgcolor="99cc33" background="/images/background-mem.gif" colspan=4><B>FINES & CHARGES</TD>
61 <td  bgcolor="99cc33" background="/images/background-mem.gif" colspan=4><B>AMOUNT OWING</TD>
62 </TR>
63 <form action=/cgi-bin/koha/pay.pl method=post>
64 <input type=hidden name=bornum value=$bornum>
65 printend
66 ;
67 for (my $i=0;$i<$numaccts;$i++){
68 if ($accts->[$i]{'amountoutstanding'} > 0){
69 $accts->[$i]{'amount'}+=0.00;
70 $accts->[$i]{'amountoutstanding'}+=0.00;
71 print <<printend
72 <tr VALIGN=TOP  >
73 <TD><input type=radio name=payfine$i value=no checked>Unpaid
74 <input type=radio name=payfine$i value=yes>Pay
75 <input type=radio name=payfine$i value=wo>Writeoff
76 <input type=hidden name=itemnumber$i value=$accts->[$i]{'itemnumber'}>
77 <input type=hidden name=accounttype$i value=$accts->[$i]{'accounttype'}>
78 <input type=hidden name=amount$i value=$accts->[$i]{'amount'}>
79 <input type=hidden name=out$i value=$accts->[$i]{'amountoutstanding'}>
80 <input type=hidden name=bornum$i value=$bornum>
81 <input type=hidden name=accountno$i value=$accts->[$i]{'accountno'}>
82 </td>
83 <TD>$accts->[$i]{'description'} $accts->[$i]{'title'}</td>
84 <TD>$accts->[$i]{'accounttype'}</td>
85 <td>$accts->[$i]{'amount'}</td>
86 <TD>$accts->[$i]{'amountoutstanding'}</td>
87
88 </tr>
89 printend
90 ;
91 }
92 }
93 print <<printend
94 <tr VALIGN=TOP  >
95 <TD></td>
96 <TD colspan=2><b>Total Due</b></td>
97
98 <TD><b>$total</b></td>
99
100 </tr>
101
102
103
104 <tr VALIGN=TOP  >
105 <TD></td>
106 <TD colspan=3><b>AMOUNT PAID</b></td>
107 <TD><input type=text name=total value="" SIZE=7></td>
108 </tr>
109 <tr VALIGN=TOP  >
110 <TD colspan=5 align=right>
111 <INPUT TYPE="image" name="submit"  VALUE="pay" height=42  WIDTH=187 BORDER=0 src="/images/pay-fines.gif"></td>
112 </tr>
113 </form>
114 </table>
115
116
117
118
119
120
121 <br clear=all>
122 <p> &nbsp; </p>
123
124 printend
125 ;
126 print endmenu('member');
127 print endpage();
128
129 } else {
130   my $quety=$input->query_string;
131   print $input->redirect("/cgi-bin/koha/sec/writeoff.pl?$quety");
132 }