5 #written 11/1/2000 by chris@katipo.oc.nz
6 #part of the koha library system, script to facilitate paying off fines
9 # Copyright 2000-2002 Katipo Communications
11 # This file is part of Koha.
13 # Koha is free software; you can redistribute it and/or modify it under the
14 # terms of the GNU General Public License as published by the Free Software
15 # Foundation; either version 2 of the License, or (at your option) any later
18 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
19 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
20 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License along with
23 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
24 # Suite 330, Boston, MA 02111-1307 USA
37 #print $input->header;
38 my $bornum=$input->param('bornum');
40 $bornum=$input->param('bornum0');
43 my $data=borrdata('',$bornum);
44 my $user=$input->remote_user;
48 $bor{'borrowernumber'}=$bornum;
51 my @names=$input->param;
54 for (my $i=0;$i<@names;$i++){
55 my$temp=$input->param($names[$i]);
57 $inp{$names[$i]}=$temp;
63 $user=~ s/Shannon/S/i;
64 my $amount=$input->param($names[$i+4]);
65 my $bornum=$input->param($names[$i+5]);
66 my $accountno=$input->param($names[$i+6]);
67 makepayment($bornum,$accountno,$amount,$user);
74 $user=~ s/Shannon/S/i;
76 $env{'branchcode'}=$user;
77 my $total=$input->param('total');
79 my $template = gettemplate("members/pay.tmpl");
81 recordpayment(\%env,$bornum,$total);
83 my ($numaccts,$accts,$total)=getboracctrecord('',\%bor);
86 for (my $i=0;$i<$numaccts;$i++){
87 if ($accts->[$i]{'amountoutstanding'} > 0){
88 $accts->[$i]{'amount'}+=0.00;
89 $accts->[$i]{'amountoutstanding'}+=0.00;
92 $line{itemnumber} = $accts->[$i]{'itemnumber'};
93 $line{accounttype} = $accts->[$i]{'accounttype'};
94 $line{amount} = $accts->[$i]{'amount'};
95 $line{amountoutstanding} = $accts->[$i]{'amountoutstanding'};
96 $line{bornum} = $bornum;
97 $line{accountno} = $accts->[$i]{'accountno'};
98 $line{description} = $accts->[$i]{'description'};
99 $line{title} = $accts->[$i]{'title'};
100 push(@loop_pay, \%line);
103 $template->param(firstname => $data->{'firstname'},
104 surname => $data->{'surname'},
106 loop_pay => \@loop_pay,
108 print "Content-Type: text/html\n\n", $template->output;
111 # my $quety=$input->query_string;
112 # print $input->redirect("/cgi-bin/koha/sec/writeoff.pl?$quety");
114 my @name=$input->param;
115 for (my $i=0;$i<@name;$i++){
116 my $test=$input->param($name[$i]);
120 $inp{$name[$i]}=$temp;
124 while ( my ($key, $value) = each %inp){
126 my $accounttype=$input->param("accounttype$value");
127 $bornum=$input->param("bornum$value");
128 my $itemno=$input->param("itemnumber$value");
129 my $amount=$input->param("amount$value");
130 if ($accounttype eq 'Res'){
131 my $accountno=$input->param("accountno$value");
132 writeoff($bornum,$accountno,$itemno,$accounttype,$amount);
134 writeoff($bornum,'',$itemno,$accounttype,$amount);
137 $bornum=$input->param('bornum');
138 print $input->redirect("/cgi-bin/koha/pay.pl?bornum=$bornum");
143 my ($bornum,$accountnum,$itemnum,$accounttype,$amount)=@_;
144 my $user=$input->remote_user;
147 $user=~ s/Shannon/S/;
148 my $dbh = C4::Context->dbh;
150 my $query="Update accountlines set amountoutstanding=0 where ";
151 if ($accounttype eq 'Res'){
152 $query.="accounttype='Res' and accountno='$accountnum' and borrowernumber='$bornum'";
154 $query.="accounttype='$accounttype' and itemnumber='$itemnum' and borrowernumber='$bornum'";
156 my $sth=$dbh->prepare($query);
160 $query="select max(accountno) from accountlines";
161 $sth=$dbh->prepare($query);
163 my $account=$sth->fetchrow_hashref;
165 $account->{'max(accountno)'}++;
166 $query="insert into accountlines (borrowernumber,accountno,itemnumber,date,amount,description,accounttype)
167 values ('$bornum','$account->{'max(accountno)'}','$itemnum',now(),'$amount','Writeoff','W')";
168 $sth=$dbh->prepare($query);
172 UpdateStats($env,$user,'writeoff',$amount,'','','',$bornum);