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 my $amount=$input->param($names[$i+4]);
68 my $bornum=$input->param($names[$i+5]);
69 my $accountno=$input->param($names[$i+6]);
70 makepayment($bornum,$accountno,$amount,$user);
77 $user=~ s/Shannon/S/i;
79 $env{'branchcode'}=$user;
80 my $total=$input->param('total');
82 my($template, $loggedinuser, $cookie)
83 = get_template_and_user ({ template_name => "members/pay.tmpl",
87 flagsrequired => {borrowers => 1},
91 recordpayment(\%env,$bornum,$total);
93 my ($numaccts,$accts,$total)=getboracctrecord('',\%bor);
96 for (my $i=0;$i<$numaccts;$i++){
97 if ($accts->[$i]{'amountoutstanding'} > 0){
98 $accts->[$i]{'amount'}+=0.00;
99 $accts->[$i]{'amountoutstanding'}+=0.00;
102 $line{itemnumber} = $accts->[$i]{'itemnumber'};
103 $line{accounttype} = $accts->[$i]{'accounttype'};
104 $line{amount} = $accts->[$i]{'amount'};
105 $line{amountoutstanding} = $accts->[$i]{'amountoutstanding'};
106 $line{bornum} = $bornum;
107 $line{accountno} = $accts->[$i]{'accountno'};
108 $line{description} = $accts->[$i]{'description'};
109 $line{title} = $accts->[$i]{'title'};
110 push(@loop_pay, \%line);
113 $template->param(firstname => $data->{'firstname'},
114 surname => $data->{'surname'},
116 loop_pay => \@loop_pay,
118 print "Content-Type: text/html\n\n", $template->output;
121 # my $quety=$input->query_string;
122 # print $input->redirect("/cgi-bin/koha/sec/writeoff.pl?$quety");
124 my @name=$input->param;
125 for (my $i=0;$i<@name;$i++){
126 my $test=$input->param($name[$i]);
130 $inp{$name[$i]}=$temp;
134 while ( my ($key, $value) = each %inp){
136 my $accounttype=$input->param("accounttype$value");
137 $bornum=$input->param("bornum$value");
138 my $itemno=$input->param("itemnumber$value");
139 my $amount=$input->param("amount$value");
140 if ($accounttype eq 'Res'){
141 my $accountno=$input->param("accountno$value");
142 writeoff($bornum,$accountno,$itemno,$accounttype,$amount);
144 writeoff($bornum,'',$itemno,$accounttype,$amount);
147 $bornum=$input->param('bornum');
148 print $input->redirect("/cgi-bin/koha/pay.pl?bornum=$bornum");
153 my ($bornum,$accountnum,$itemnum,$accounttype,$amount)=@_;
154 my $user=$input->remote_user;
157 $user=~ s/Shannon/S/;
158 my $dbh = C4::Context->dbh;
161 if ($accounttype eq 'Res'){
162 $sth=$dbh->prepare("Update accountlines set amountoutstanding=0 where accounttype='Res' and accountno=? and borrowernumber=?");
163 $sth->execute($accountnum,$bornum);
165 $sth=$dbh->prepare("Update accountlines set amountoutstanding=0 where accounttype=? and itemnumber=? and borrowernumber=?");
166 $sth->execute($accounttype,$itemnum,$bornum);
169 $sth=$dbh->prepare("select max(accountno) from accountlines");
171 my $account=$sth->fetchrow_hashref;
173 $account->{'max(accountno)'}++;
174 $sth=$dbh->prepare("insert into accountlines (borrowernumber,accountno,itemnumber,date,amount,description,accounttype)
175 values (?,?,?,now(),?,'Writeoff','W')");
176 $sth->execute($bornum,$account->{'max(accountno)'},$itemnum,$amount);
178 UpdateStats($env,$user,'writeoff',$amount,'','','',$bornum);