commiting modif already in RC2 (bug in breeding import)
[srvgit] / pay.pl
diff --git a/pay.pl b/pay.pl
index cd069ec..f3de382 100755 (executable)
--- a/pay.pl
+++ b/pay.pl
@@ -1,4 +1,6 @@
 #!/usr/bin/perl
+# WARNING: Not enough context to figure out the correct tabstop size
+# WARNING: Assume that this file uses 4-character tabs
 
 # $Id$
 
@@ -25,6 +27,7 @@
 
 use strict;
 use C4::Context;
+use C4::Auth;
 use C4::Output;
 use CGI;
 use C4::Search;
@@ -76,7 +79,14 @@ my %env;
 $env{'branchcode'}=$user;
 my $total=$input->param('total');
 if ($check ==0){
-       my $template = gettemplate("members/pay.tmpl");
+       my($template, $loggedinuser, $cookie)
+               = get_template_and_user ({ template_name => "members/pay.tmpl",
+                                          query => $input,
+                                          type => "intranet",
+                                          authnotrequired => 0,
+                                          flagsrequired => {borrowers => 1},
+                                          debug => 1,
+                                        });
        if ($total ne ''){
                recordpayment(\%env,$bornum,$total);
        }
@@ -147,27 +157,27 @@ sub writeoff{
        $user=~ s/Shannon/S/;
        my $dbh = C4::Context->dbh;
        my $env;
-       my $query="Update accountlines set amountoutstanding=0 where ";
+       my $sth;
        if ($accounttype eq 'Res'){
-               $query.="accounttype='Res' and accountno='$accountnum' and borrowernumber='$bornum'";
+               $sth=$dbh->prepare("Update accountlines set amountoutstanding=0 where accounttype='Res' and accountno=? and borrowernumber=?");
+               $sth->execute($accountnum,$bornum);
        } else {
-               $query.="accounttype='$accounttype' and itemnumber='$itemnum' and borrowernumber='$bornum'";
+               $sth=$dbh->prepare("Update accountlines set amountoutstanding=0 where accounttype=? and itemnumber=? and borrowernumber=?");
+               $sth->execute($accounttype,$itemnum,$bornum);
        }
-       my $sth=$dbh->prepare($query);
-       #  print $query;
-       $sth->execute;
        $sth->finish;
-       $query="select max(accountno) from accountlines";
-       $sth=$dbh->prepare($query);
+       $sth=$dbh->prepare("select max(accountno) from accountlines");
        $sth->execute;
        my $account=$sth->fetchrow_hashref;
        $sth->finish;
        $account->{'max(accountno)'}++;
-       $query="insert into accountlines (borrowernumber,accountno,itemnumber,date,amount,description,accounttype)
-                                               values ('$bornum','$account->{'max(accountno)'}','$itemnum',now(),'$amount','Writeoff','W')";
-       $sth=$dbh->prepare($query);
-       $sth->execute;
+       $sth=$dbh->prepare("insert into accountlines (borrowernumber,accountno,itemnumber,date,amount,description,accounttype)
+                                               values (?,?,?,now(),?,'Writeoff','W')");
+       $sth->execute($bornum,$account->{'max(accountno)'},$itemnum,$amount);
        $sth->finish;
-       #  print $query;
        UpdateStats($env,$user,'writeoff',$amount,'','','',$bornum);
 }
+
+# Local Variables:
+# tab-width: 4
+# End: