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
39 #print $input->header;
40 my $bornum=$input->param('bornum');
42 $bornum=$input->param('bornum0');
44 # get borrower details
45 my $data=borrdata('',$bornum);
46 my $user=$input->remote_user;
50 $bor{'borrowernumber'}=$bornum;
51 my $branches = GetBranches();
52 my $printers = getprinters();
53 my $branch = getbranch($input, $branches);
55 my @names=$input->param;
58 for (my $i=0;$i<@names;$i++){
59 my $temp=$input->param($names[$i]);
61 $inp{$names[$i]}=$temp;
68 $user=~ s/Shannon/S/i;
69 # FIXME : using array +4, +5, +6 is dirty. Should use arrays for each accountline
70 my $amount=$input->param($names[$i+4]);
71 my $bornum=$input->param($names[$i+5]);
72 my $accountno=$input->param($names[$i+6]);
73 makepayment($bornum,$accountno,$amount,$user,$branch);
80 $user=~ s/Shannon/S/i;
82 $env{'branchcode'}=$branch;
83 my $total=$input->param('total');
85 my($template, $loggedinuser, $cookie)
86 = get_template_and_user ({ template_name => "members/pay.tmpl",
90 flagsrequired => {borrowers => 1},
94 recordpayment(\%env,$bornum,$total);
96 my ($numaccts,$accts,$total)=getboracctrecord('',\%bor);
99 for (my $i=0;$i<$numaccts;$i++){
100 if ($accts->[$i]{'amountoutstanding'} > 0){
101 $accts->[$i]{'amount'}+=0.00;
102 $accts->[$i]{'amountoutstanding'}+=0.00;
105 $line{itemnumber} = $accts->[$i]{'itemnumber'};
106 $line{accounttype} = $accts->[$i]{'accounttype'};
107 $line{amount} = sprintf("%.2f",$accts->[$i]{'amount'});
108 $line{amountoutstanding} = sprintf("%.2f",$accts->[$i]{'amountoutstanding'});
109 $line{bornum} = $bornum;
110 $line{accountno} = $accts->[$i]{'accountno'};
111 $line{description} = $accts->[$i]{'description'};
112 $line{title} = $accts->[$i]{'title'};
113 push(@loop_pay, \%line);
116 $template->param(firstname => $data->{'firstname'},
117 surname => $data->{'surname'},
119 loop_pay => \@loop_pay,
120 total => sprintf("%.2f",$total));
121 print "Content-Type: text/html\n\n", $template->output;
124 # my $quety=$input->query_string;
125 # print $input->redirect("/cgi-bin/koha/sec/writeoff.pl?$quety");
127 my @name=$input->param;
128 for (my $i=0;$i<@name;$i++){
129 my $test=$input->param($name[$i]);
133 $inp{$name[$i]}=$temp;
137 while ( my ($key, $value) = each %inp){
139 my $accounttype=$input->param("accounttype$value");
140 $bornum=$input->param("bornum$value");
141 my $itemno=$input->param("itemnumber$value");
142 my $amount=$input->param("amount$value");
143 my $accountno=$input->param("accountno$value");
144 writeoff($bornum,$accountno,$itemno,$accounttype,$amount);
146 $bornum=$input->param('bornum');
147 print $input->redirect("/cgi-bin/koha/members/moremember.pl?bornum=$bornum");
152 my ($bornum,$accountnum,$itemnum,$accounttype,$amount)=@_;
153 my $user=$input->remote_user;
154 my $dbh = C4::Context->dbh;
156 my $sth=$dbh->prepare("Update accountlines set amountoutstanding=0 where accounttype='Res' and accountno=? and borrowernumber=?");
157 $sth->execute($accountnum,$bornum);
159 $sth=$dbh->prepare("select max(accountno) from accountlines");
161 my $account=$sth->fetchrow_hashref;
163 $account->{'max(accountno)'}++;
164 $sth=$dbh->prepare("insert into accountlines (borrowernumber,accountno,itemnumber,date,amount,description,accounttype)
165 values (?,?,?,now(),?,'Writeoff','W')");
166 $sth->execute($bornum,$account->{'max(accountno)'},$itemnum,$amount);
168 UpdateStats($env,$branch,'writeoff',$amount,'','','',$bornum);