2 # WARNING: Not enough context to figure out the correct tabstop size
3 # WARNING: Assume that this file uses 4-character tabs
7 #written 11/1/2000 by chris@katipo.oc.nz
8 #part of the koha library system, script to facilitate paying off fines
11 # Copyright 2000-2002 Katipo Communications
13 # This file is part of Koha.
15 # Koha is free software; you can redistribute it and/or modify it under the
16 # terms of the GNU General Public License as published by the Free Software
17 # Foundation; either version 2 of the License, or (at your option) any later
20 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
21 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
22 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License along with
25 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
26 # Suite 330, Boston, MA 02111-1307 USA
40 #print $input->header;
41 my $bornum=$input->param('bornum');
43 $bornum=$input->param('bornum0');
46 my $data=borrdata('',$bornum);
47 my $user=$input->remote_user;
51 $bor{'borrowernumber'}=$bornum;
54 my @names=$input->param;
57 for (my $i=0;$i<@names;$i++){
58 my $temp=$input->param($names[$i]);
60 $inp{$names[$i]}=$temp;
66 $user=~ s/Shannon/S/i;
67 # FIXME : using array +4, +5, +6 is dirty. Should use arrays for each accountline
68 my $amount=$input->param($names[$i+4]);
69 my $bornum=$input->param($names[$i+5]);
70 my $accountno=$input->param($names[$i+6]);
71 makepayment($bornum,$accountno,$amount,$user);
78 $user=~ s/Shannon/S/i;
80 $env{'branchcode'}=$user;
81 my $total=$input->param('total');
83 my($template, $loggedinuser, $cookie)
84 = get_template_and_user ({ template_name => "members/pay.tmpl",
88 flagsrequired => {borrowers => 1},
92 recordpayment(\%env,$bornum,$total);
94 my ($numaccts,$accts,$total)=getboracctrecord('',\%bor);
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 $line{itemnumber} = $accts->[$i]{'itemnumber'};
104 $line{accounttype} = $accts->[$i]{'accounttype'};
105 $line{amount} = sprintf("%.2f",$accts->[$i]{'amount'});
106 $line{amountoutstanding} = sprintf("%.2f",$accts->[$i]{'amountoutstanding'});
107 $line{bornum} = $bornum;
108 $line{accountno} = $accts->[$i]{'accountno'};
109 $line{description} = $accts->[$i]{'description'};
110 $line{title} = $accts->[$i]{'title'};
111 push(@loop_pay, \%line);
114 $template->param(firstname => $data->{'firstname'},
115 surname => $data->{'surname'},
117 loop_pay => \@loop_pay,
118 total => sprintf("%.2f",$total));
119 print "Content-Type: text/html\n\n", $template->output;
122 # my $quety=$input->query_string;
123 # print $input->redirect("/cgi-bin/koha/sec/writeoff.pl?$quety");
125 my @name=$input->param;
126 for (my $i=0;$i<@name;$i++){
127 my $test=$input->param($name[$i]);
131 $inp{$name[$i]}=$temp;
135 while ( my ($key, $value) = each %inp){
137 my $accounttype=$input->param("accounttype$value");
138 $bornum=$input->param("bornum$value");
139 my $itemno=$input->param("itemnumber$value");
140 my $amount=$input->param("amount$value");
141 if ($accounttype eq 'Res'){
142 my $accountno=$input->param("accountno$value");
143 writeoff($bornum,$accountno,$itemno,$accounttype,$amount);
145 writeoff($bornum,'',$itemno,$accounttype,$amount);
148 $bornum=$input->param('bornum');
149 print $input->redirect("/cgi-bin/koha/members/moremember.pl?bornum=$bornum");
154 my ($bornum,$accountnum,$itemnum,$accounttype,$amount)=@_;
155 my $user=$input->remote_user;
158 $user=~ s/Shannon/S/;
159 my $dbh = C4::Context->dbh;
162 if ($accounttype eq 'Res'){
163 $sth=$dbh->prepare("Update accountlines set amountoutstanding=0 where accounttype='Res' and accountno=? and borrowernumber=?");
164 $sth->execute($accountnum,$bornum);
166 $sth=$dbh->prepare("Update accountlines set amountoutstanding=0 where accounttype=? and itemnumber=? and borrowernumber=?");
167 $sth->execute($accounttype,$itemnum,$bornum);
170 $sth=$dbh->prepare("select max(accountno) from accountlines");
172 my $account=$sth->fetchrow_hashref;
174 $account->{'max(accountno)'}++;
175 $sth=$dbh->prepare("insert into accountlines (borrowernumber,accountno,itemnumber,date,amount,description,accounttype)
176 values (?,?,?,now(),?,'Writeoff','W')");
177 $sth->execute($bornum,$account->{'max(accountno)'},$itemnum,$amount);
179 UpdateStats($env,$user,'writeoff',$amount,'','','',$bornum);