3 #wrriten 11/1/2000 by chris@katipo.oc.nz
4 #part of the koha library system, script to facilitate paying off fines
7 # Copyright 2000-2002 Katipo Communications
9 # This file is part of Koha.
11 # Koha is free software; you can redistribute it and/or modify it under the
12 # terms of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
16 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
17 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License along with
21 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
22 # Suite 330, Boston, MA 02111-1307 USA
34 #print $input->header;
35 my $bornum=$input->param('bornum');
37 $bornum=$input->param('bornum0');
40 my $data=borrdata('',$bornum);
41 my $user=$input->remote_user;
45 $bor{'borrowernumber'}=$bornum;
48 my @names=$input->param;
51 for (my $i=0;$i<@names;$i++){
52 my$temp=$input->param($names[$i]);
54 $inp{$names[$i]}=$temp;
60 $user=~ s/Shannon/S/i;
61 my $amount=$input->param($names[$i+4]);
62 my $bornum=$input->param($names[$i+5]);
63 my $accountno=$input->param($names[$i+6]);
64 makepayment($bornum,$accountno,$amount,$user);
71 $user=~ s/Shannon/S/i;
73 $env{'branchcode'}=$user;
74 my $total=$input->param('total');
78 recordpayment(\%env,$bornum,$total);
80 my ($numaccts,$accts,$total)=getboracctrecord('',\%bor);
83 print startmenu('member');
85 <FONT SIZE=6><em>Pay Fines for $data->{'firstname'} $data->{'surname'}</em></FONT><P>
88 <TABLE CELLSPACING=0 CELLPADDING=5 border=1 >
90 <td bgcolor="99cc33" background="/images/background-mem.gif" colspan=4><B>FINES & CHARGES</TD>
91 <td bgcolor="99cc33" background="/images/background-mem.gif" colspan=4><B>AMOUNT OWING</TD>
93 <form action=/cgi-bin/koha/pay.pl method=post>
94 <input type=hidden name=bornum value=$bornum>
97 for (my $i=0;$i<$numaccts;$i++){
98 if ($accts->[$i]{'amountoutstanding'} > 0){
99 $accts->[$i]{'amount'}+=0.00;
100 $accts->[$i]{'amountoutstanding'}+=0.00;
103 <TD><input type=radio name=payfine$i value=no checked>Unpaid
104 <input type=radio name=payfine$i value=yes>Pay
105 <input type=radio name=payfine$i value=wo>Writeoff
106 <input type=hidden name=itemnumber$i value=$accts->[$i]{'itemnumber'}>
107 <input type=hidden name=accounttype$i value=$accts->[$i]{'accounttype'}>
108 <input type=hidden name=amount$i value=$accts->[$i]{'amount'}>
109 <input type=hidden name=out$i value=$accts->[$i]{'amountoutstanding'}>
110 <input type=hidden name=bornum$i value=$bornum>
111 <input type=hidden name=accountno$i value=$accts->[$i]{'accountno'}>
113 <TD>$accts->[$i]{'description'} $accts->[$i]{'title'}</td>
114 <TD>$accts->[$i]{'accounttype'}</td>
115 <td>$accts->[$i]{'amount'}</td>
116 <TD>$accts->[$i]{'amountoutstanding'}</td>
126 <TD colspan=2><b>Total Due</b></td>
127 <TD><b>$total</b></td>
130 <TD colspan=5 align=right>
131 <INPUT TYPE="image" name="submit" VALUE="pay" height=42 WIDTH=187 BORDER=0 src="/images/pay-fines.gif"></td>
140 print endmenu('member');
144 # my $quety=$input->query_string;
145 # print $input->redirect("/cgi-bin/koha/sec/writeoff.pl?$quety");
147 my @name=$input->param;
148 for (my $i=0;$i<@name;$i++){
149 my $test=$input->param($name[$i]);
153 $inp{$name[$i]}=$temp;
157 while ( my ($key, $value) = each %inp){
159 my $accounttype=$input->param("accounttype$value");
160 $bornum=$input->param("bornum$value");
161 my $itemno=$input->param("itemnumber$value");
162 my $amount=$input->param("amount$value");
163 if ($accounttype eq 'Res'){
164 my $accountno=$input->param("accountno$value");
165 writeoff($bornum,$accountno,$itemno,$accounttype,$amount);
167 writeoff($bornum,'',$itemno,$accounttype,$amount);
170 $bornum=$input->param('bornum');
171 print $input->redirect("/cgi-bin/koha/pay.pl?bornum=$bornum");
176 my ($bornum,$accountnum,$itemnum,$accounttype,$amount)=@_;
177 my $user=$input->remote_user;
180 $user=~ s/Shannon/S/;
183 my $query="Update accountlines set amountoutstanding=0 where ";
184 if ($accounttype eq 'Res'){
185 $query.="accounttype='Res' and accountno='$accountnum' and borrowernumber='$bornum'";
187 $query.="accounttype='$accounttype' and itemnumber='$itemnum' and borrowernumber='$bornum'";
189 my $sth=$dbh->prepare($query);
193 $query="select max(accountno) from accountlines";
194 $sth=$dbh->prepare($query);
196 my $account=$sth->fetchrow_hashref;
198 $account->{'max(accountno)'}++;
199 $query="insert into accountlines (borrowernumber,accountno,itemnumber,date,amount,description,accounttype)
200 values ('$bornum','$account->{'max(accountno)'}','$itemnum',now(),'$amount','Writeoff','W')";
201 $sth=$dbh->prepare($query);
206 UpdateStats($env,$user,'writeoff',$amount,'','','',$bornum);