Fixed bug 202, the branch menu-building code has spurious checks for CU and
[koha_gimpoz] / sec / writeoff.pl
index 960849e..b930b3b 100755 (executable)
@@ -3,9 +3,27 @@
 #written 11/1/2000 by chris@katipo.co.nz
 #script to write off accounts
 
+
+# Copyright 2000-2002 Katipo Communications
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA  02111-1307 USA
+
 use strict;
 use CGI;
-use C4::Database;
+use C4::Context;
 use C4::Stats;
 my $input=new CGI;
 
@@ -45,7 +63,10 @@ print $input->redirect("/cgi-bin/koha/pay.pl?bornum=$bornum");
 sub writeoff{
   my ($bornum,$accountnum,$itemnum,$accounttype,$amount)=@_;
   my $user=$input->remote_user;
-  my $dbh=C4Connect;
+  $user=~ s/Levin/C/;
+  $user=~ s/Foxton/F/;
+  $user=~ s/Shannon/S/;
+  my $dbh = C4::Context->dbh;
   my $env;
   my $query="Update accountlines set amountoutstanding=0 where ";
   if ($accounttype eq 'Res'){
@@ -67,8 +88,7 @@ sub writeoff{
   values ('$bornum','$account->{'max(accountno)'}','$itemnum',now(),'$amount','Writeoff','W')";
   $sth=$dbh->prepare($query);
   $sth->execute;
-  $sth->finish; 
+  $sth->finish;
 #  print $query;
-  $dbh->disconnect;
   UpdateStats($env,$user,'writeoff',$amount,'','','',$bornum);
 }