[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] koha/C4 Accounts.pm
From: |
paul poulain |
Subject: |
[Koha-cvs] koha/C4 Accounts.pm |
Date: |
Mon, 23 Apr 2007 14:06:19 +0000 |
CVSROOT: /sources/koha
Module name: koha
Changes by: paul poulain <tipaul> 07/04/23 14:06:18
Modified files:
C4 : Accounts.pm
Log message:
code convention for SQL
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Accounts.pm?cvsroot=koha&r1=1.21&r2=1.22
Patches:
Index: Accounts.pm
===================================================================
RCS file: /sources/koha/koha/C4/Accounts.pm,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- Accounts.pm 23 Apr 2007 13:10:08 -0000 1.21
+++ Accounts.pm 23 Apr 2007 14:06:18 -0000 1.22
@@ -17,7 +17,7 @@
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
-# $Id: Accounts.pm,v 1.21 2007/04/23 13:10:08 hdl Exp $
+# $Id: Accounts.pm,v 1.22 2007/04/23 14:06:18 tipaul Exp $
use strict;
require Exporter;
@@ -28,7 +28,7 @@
use vars qw($VERSION @ISA @EXPORT);
# set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.21 $' =~ /\d+/g;
+$VERSION = do { my @v = '$Revision: 1.22 $' =~ /\d+/g;
shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); };
=head1 NAME
@@ -81,9 +81,9 @@
# begin transaction
my $nextaccntno = getnextacctno($borrowernumber);
# get lines with outstanding amounts to offset
- my $sth = $dbh->prepare("select * from accountlines
- where (borrowernumber = ?) and (amountoutstanding<>0)
- order by date");
+ my $sth = $dbh->prepare("SELECT * FROM accountlines
+ WHERE (borrowernumber = ?) AND (amountoutstanding<>0)
+ ORDER BY date");
$sth->execute($borrowernumber);
# offset transactions
while (($accdata=$sth->fetchrow_hashref) and ($amountleft>0)){
@@ -95,20 +95,20 @@
$amountleft = 0;
}
my $thisacct = $accdata->{accountno};
- my $usth = $dbh->prepare("update accountlines set amountoutstanding= ?
- where (borrowernumber = ?) and (accountno=?)");
+ my $usth = $dbh->prepare("UPDATE accountlines SET amountoutstanding= ?
+ WHERE (borrowernumber = ?) AND (accountno=?)");
$usth->execute($newamtos,$borrowernumber,$thisacct);
$usth->finish;
- $usth = $dbh->prepare("insert into accountoffsets
+ $usth = $dbh->prepare("INSERT INTO accountoffsets
(borrowernumber, accountno, offsetaccount, offsetamount)
- values (?,?,?,?)");
+ VALUES (?,?,?,?)");
$usth->execute($borrowernumber,$accdata->{'accountno'},$nextaccntno,$newamtos);
$usth->finish;
}
# create new line
- my $usth = $dbh->prepare("insert into accountlines
+ my $usth = $dbh->prepare("INSERT INTO accountlines
(borrowernumber,
accountno,date,amount,description,accounttype,amountoutstanding)
- values (?,?,now(),?,'Payment,thanks','Pay',?)");
+ VALUES (?,?,now(),?,'Payment,thanks','Pay',?)");
$usth->execute($borrowernumber,$nextaccntno,0-$data,0-$amountleft);
$usth->finish;
UpdateStats($branch,'payment',$data,'','','',$borrowernumber);
@@ -142,35 +142,34 @@
# begin transaction
my $nextaccntno = getnextacctno($borrowernumber);
my $newamtos=0;
- my $sth=$dbh->prepare("Select * from accountlines where borrowernumber=?
and accountno=?");
+ my $sth=$dbh->prepare("SELECT * FROM accountlines WHERE borrowernumber=?
AND accountno=?");
$sth->execute($borrowernumber,$accountno);
my $data=$sth->fetchrow_hashref;
$sth->finish;
- $dbh->do(<<EOT);
- UPDATE accountlines
+ $dbh->do("UPDATE accountlines
SET amountoutstanding = 0
WHERE borrowernumber = $borrowernumber
AND accountno = $accountno
-EOT
+ ");
# print $updquery;
- $dbh->do(<<EOT);
+ $dbh->do("
INSERT INTO accountoffsets
(borrowernumber, accountno, offsetaccount,
offsetamount)
VALUES ($borrowernumber, $accountno, $nextaccntno, $newamtos)
-EOT
+ ");
# create new line
my $payment=0-$amount;
- $dbh->do(<<EOT);
+ $dbh->do("
INSERT INTO accountlines
(borrowernumber, accountno, date, amount,
description, accounttype, amountoutstanding)
VALUES ($borrowernumber, $nextaccntno, now(), $payment,
'Payment,thanks - $user', 'Pay', 0)
-EOT
+ ");
# FIXME - The second argument to &UpdateStats is supposed to be the
# branch code.
@@ -190,8 +189,6 @@
Returns the next unused account number for the patron with the given
borrower number.
-C<$dbh> is a DBI::db handle to the Koha database.
-
=cut
#'
@@ -222,8 +219,8 @@
sub fixaccounts {
my ($borrowernumber,$accountno,$amount)address@hidden;
my $dbh = C4::Context->dbh;
- my $sth=$dbh->prepare("Select * from accountlines where borrowernumber=?
- and accountno=?");
+ my $sth=$dbh->prepare("SELECT * FROM accountlines WHERE borrowernumber=?
+ AND accountno=?");
$sth->execute($borrowernumber,$accountno);
my $data=$sth->fetchrow_hashref;
# FIXME - Error-checking
@@ -245,14 +242,14 @@
my ($borrowernumber,$itemnum)address@hidden;
my $dbh = C4::Context->dbh;
my $borrower=GetMember($borrowernumber,'borrowernumber');
- my $sth=$dbh->prepare("Update issues set returndate=now() where
- borrowernumber=? and itemnumber=? and returndate is null");
+ my $sth=$dbh->prepare("UPDATE issues SET returndate=now() WHERE
+ borrowernumber=? AND itemnumber=? AND returndate IS NULL");
$sth->execute($borrowernumber,$itemnum);
$sth->finish;
my @datearr = localtime(time);
my $date = (1900+$datearr[5])."-".($datearr[4]+1)."-".$datearr[3];
my $bor="$borrower->{'firstname'} $borrower->{'surname'}
$borrower->{'cardnumber'}";
- $sth=$dbh->prepare("Update items set paidfor=? where itemnumber=?");
+ $sth=$dbh->prepare("UPDATE items SET paidfor=? WHERE itemnumber=?");
$sth->execute("Paid for by $bor $date",$itemnum);
$sth->finish;
}
@@ -346,13 +343,13 @@
if ($barcode ne ''){
my $item=GetBiblioFromItemNumber('',$barcode);
my $nextaccntno = getnextacctno($borrowernumber);
- my $query="Select * from accountlines where (borrowernumber=?
- and itemnumber=? and amountoutstanding > 0)";
+ my $query="SELECT * FROM accountlines WHERE (borrowernumber=?
+ AND itemnumber=? AND amountoutstanding > 0)";
if ($type eq 'CL'){
- $query.=" and (accounttype = 'L' or accounttype = 'Rep')";
+ $query.=" AND (accounttype = 'L' OR accounttype = 'Rep')";
} elsif ($type eq 'CF'){
- $query.=" and (accounttype = 'F' or accounttype = 'FU' or
- accounttype='Res' or accounttype='Rent')";
+ $query.=" AND (accounttype = 'F' OR accounttype = 'FU' OR
+ accounttype='Res' OR accounttype='Rent')";
} elsif ($type eq 'CB'){
$query.=" and accounttype='A'";
}
@@ -369,22 +366,22 @@
$amountleft = 0;
}
my $thisacct = $accdata->{accountno};
- my $usth = $dbh->prepare("update accountlines set amountoutstanding= ?
- where (borrowernumber = ?) and (accountno=?)");
+ my $usth = $dbh->prepare("UPDATE accountlines SET amountoutstanding= ?
+ WHERE (borrowernumber = ?) AND (accountno=?)");
$usth->execute($newamtos,$borrowernumber,$thisacct);
$usth->finish;
- $usth = $dbh->prepare("insert into accountoffsets
+ $usth = $dbh->prepare("INSERT INTO accountoffsets
(borrowernumber, accountno, offsetaccount, offsetamount)
- values (?,?,?,?)");
+ VALUES (?,?,?,?)");
$usth->execute($borrowernumber,$accdata->{'accountno'},$nextaccntno,$newamtos);
$usth->finish;
}
# begin transaction
my $nextaccntno = getnextacctno($borrowernumber);
# get lines with outstanding amounts to offset
- my $sth = $dbh->prepare("select * from accountlines
- where (borrowernumber = ?) and (amountoutstanding >0)
- order by date");
+ my $sth = $dbh->prepare("SELECT * FROM accountlines
+ WHERE (borrowernumber = ?) AND (amountoutstanding >0)
+ ORDER BY date");
$sth->execute($borrowernumber);
# print $query;
# offset transactions
@@ -397,13 +394,13 @@
$amountleft = 0;
}
my $thisacct = $accdata->{accountno};
- my $usth = $dbh->prepare("update accountlines set amountoutstanding= ?
- where (borrowernumber = ?) and (accountno=?)");
+ my $usth = $dbh->prepare("UPDATE accountlines SET amountoutstanding= ?
+ WHERE (borrowernumber = ?) AND (accountno=?)");
$usth->execute($newamtos,$borrowernumber,$thisacct);
$usth->finish;
- $usth = $dbh->prepare("insert into accountoffsets
+ $usth = $dbh->prepare("INSERT INTO accountoffsets
(borrowernumber, accountno, offsetaccount, offsetamount)
- values (?,?,?,?)");
+ VALUE (?,?,?,?)");
$usth->execute($borrowernumber,$accdata->{'accountno'},$nextaccntno,$newamtos);
$usth->finish;
}
@@ -432,9 +429,9 @@
# begin transaction
my $nextaccntno = getnextacctno($borrowernumber);
# get lines with outstanding amounts to offset
- my $sth = $dbh->prepare("select * from accountlines
- where (borrowernumber = ?) and (amountoutstanding<0)
- order by date");
+ my $sth = $dbh->prepare("SELECT * FROM accountlines
+ WHERE (borrowernumber = ?) AND (amountoutstanding<0)
+ ORDER BY date");
$sth->execute($borrowernumber);
# print $amountleft;
# offset transactions
@@ -448,13 +445,13 @@
}
# print $amountleft;
my $thisacct = $accdata->{accountno};
- my $usth = $dbh->prepare("update accountlines set amountoutstanding= ?
- where (borrowernumber = ?) and (accountno=?)");
+ my $usth = $dbh->prepare("UPDATE accountlines SET amountoutstanding= ?
+ WHERE (borrowernumber = ?) AND (accountno=?)");
$usth->execute($newamtos,$borrowernumber,$thisacct);
$usth->finish;
- $usth = $dbh->prepare("insert into accountoffsets
+ $usth = $dbh->prepare("INSERT INTO accountoffsets
(borrowernumber, accountno, offsetaccount, offsetamount)
- values (?,?,?,?)");
+ VALUES (?,?,?,?)");
$usth->execute($borrowernumber,$accdata->{'accountno'},$nextaccntno,$newamtos);
$usth->finish;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Koha-cvs] koha/C4 Accounts.pm,
paul poulain <=