[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] CVS: koha/C4 Accounts2.pm,1.21,1.22
From: |
MJ Ray |
Subject: |
[Koha-cvs] CVS: koha/C4 Accounts2.pm,1.21,1.22 |
Date: |
Tue, 09 Dec 2003 07:03:02 -0800 |
Update of /cvsroot/koha/koha/C4
In directory sc8-pr-cvs1:/tmp/cvs-serv9380/C4
Modified Files:
Accounts2.pm
Log Message:
DBI call fix for bug 662
Index: Accounts2.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Accounts2.pm,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -r1.21 -r1.22
*** Accounts2.pm 23 Apr 2003 12:20:28 -0000 1.21
--- Accounts2.pm 9 Dec 2003 15:03:00 -0000 1.22
***************
*** 82,86 ****
my ($env,$bornumber,$data)address@hidden;
my $dbh = C4::Context->dbh;
- my $updquery = "";
my $newamtos = 0;
my $accdata = "";
--- 82,85 ----
***************
*** 90,98 ****
my $nextaccntno = getnextacctno($env,$bornumber,$dbh);
# get lines with outstanding amounts to offset
! my $query = "select * from accountlines
! where (borrowernumber = '$bornumber') and (amountoutstanding<>0)
! order by date";
! my $sth = $dbh->prepare($query);
! $sth->execute;
# offset transactions
while (($accdata=$sth->fetchrow_hashref) and ($amountleft>0)){
--- 89,96 ----
my $nextaccntno = getnextacctno($env,$bornumber,$dbh);
# get lines with outstanding amounts to offset
! my $sth = $dbh->prepare("select * from accountlines
! where (borrowernumber = ?) and (amountoutstanding<>0)
! order by date");
! $sth->execute($bornumber);
# offset transactions
while (($accdata=$sth->fetchrow_hashref) and ($amountleft>0)){
***************
*** 105,127 ****
}
my $thisacct = $accdata->{accountno};
! $updquery = "update accountlines set amountoutstanding= '$newamtos'
! where (borrowernumber = '$bornumber') and (accountno='$thisacct')";
! my $usth = $dbh->prepare($updquery);
! $usth->execute;
$usth->finish;
! $updquery = "insert into accountoffsets
(borrowernumber, accountno, offsetaccount, offsetamount)
! values ($bornumber,$accdata->{'accountno'},$nextaccntno,$newamtos)";
! $usth = $dbh->prepare($updquery);
! $usth->execute;
$usth->finish;
}
# create new line
! $updquery = "insert into accountlines
(borrowernumber,
accountno,date,amount,description,accounttype,amountoutstanding)
! values ($bornumber,$nextaccntno,now(),0-$data,'Payment,thanks',
! 'Pay',0-$amountleft)";
! my $usth = $dbh->prepare($updquery);
! $usth->execute;
$usth->finish;
UpdateStats($env,$branch,'payment',$data,'','','',$bornumber);
--- 103,121 ----
}
my $thisacct = $accdata->{accountno};
! my $usth = $dbh->prepare("update accountlines set amountoutstanding= ?
! where (borrowernumber = ?) and (accountno=?)");
! $usth->execute($newamtos,$bornumber,$thisacct);
$usth->finish;
! $usth = $dbh->prepare("insert into accountoffsets
(borrowernumber, accountno, offsetaccount, offsetamount)
! values (?,?,?,?)");
!
$usth->execute($bornumber,$accdata->{'accountno'},$nextaccntno,$newamtos);
$usth->finish;
}
# create new line
! my $usth = $dbh->prepare("insert into accountlines
(borrowernumber,
accountno,date,amount,description,accounttype,amountoutstanding)
! values (?,?,now(),?,'Payment,thanks','Pay',?)");
! $usth->execute($bornumber,$nextaccntno,0-$data,0-$amountleft);
$usth->finish;
UpdateStats($env,$branch,'payment',$data,'','','',$bornumber);
***************
*** 156,163 ****
my $nextaccntno = getnextacctno($env,$bornumber,$dbh);
my $newamtos=0;
! my $sel="Select * from accountlines where borrowernumber=$bornumber and
! accountno=$accountno";
! my $sth=$dbh->prepare($sel);
! $sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
--- 150,155 ----
my $nextaccntno = getnextacctno($env,$bornumber,$dbh);
my $newamtos=0;
! my $sth=$dbh->prepare("Select * from accountlines where borrowernumber=?
and accountno=?");
! $sth->execute($bornumber,$accountno);
my $data=$sth->fetchrow_hashref;
$sth->finish;
***************
*** 215,223 ****
my ($env,$bornumber,$dbh)address@hidden;
my $nextaccntno = 1;
! my $query = "select * from accountlines
! where (borrowernumber = '$bornumber')
! order by accountno desc";
! my $sth = $dbh->prepare($query);
! $sth->execute;
if (my $accdata=$sth->fetchrow_hashref){
$nextaccntno = $accdata->{'accountno'} + 1;
--- 207,214 ----
my ($env,$bornumber,$dbh)address@hidden;
my $nextaccntno = 1;
! my $sth = $dbh->prepare("select * from accountlines
! where (borrowernumber = ?)
! order by accountno desc");
! $sth->execute($bornumber);
if (my $accdata=$sth->fetchrow_hashref){
$nextaccntno = $accdata->{'accountno'} + 1;
***************
*** 237,244 ****
my ($borrowernumber,$accountno,$amount)address@hidden;
my $dbh = C4::Context->dbh;
! my $query="Select * from accountlines where borrowernumber=$borrowernumber
! and accountno=$accountno";
! my $sth=$dbh->prepare($query);
! $sth->execute;
my $data=$sth->fetchrow_hashref;
# FIXME - Error-checking
--- 228,234 ----
my ($borrowernumber,$accountno,$amount)address@hidden;
my $dbh = C4::Context->dbh;
! my $sth=$dbh->prepare("Select * from accountlines where borrowernumber=?
! and accountno=?");
! $sth->execute($borrowernumber,$accountno);
my $data=$sth->fetchrow_hashref;
# FIXME - Error-checking
***************
*** 261,276 ****
my $dbh = C4::Context->dbh;
my $borrower=borrdata('',$borrnum); #from C4::Search;
! my $upiss="Update issues set returndate=now() where
! borrowernumber='$borrnum' and itemnumber='$itemnum' and returndate is null";
! my $sth=$dbh->prepare($upiss);
! $sth->execute;
$sth->finish;
my @datearr = localtime(time);
my $date = (1900+$datearr[5])."-".($datearr[4]+1)."-".$datearr[3];
my $bor="$borrower->{'firstname'} $borrower->{'surname'}
$borrower->{'cardnumber'}";
! # FIXME - Use $dbh->do();
! my $upitem="Update items set paidfor='Paid for by $bor $date' where
itemnumber='$itemnum'";
! $sth=$dbh->prepare($upitem);
! $sth->execute;
$sth->finish;
}
--- 251,263 ----
my $dbh = C4::Context->dbh;
my $borrower=borrdata('',$borrnum); #from C4::Search;
! my $sth=$dbh->prepare("Update issues set returndate=now() where
! borrowernumber=? and itemnumber=? and returndate is null");
! $sth->execute($borrnum,$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->execute("Paid for by $bor $date",$itemnum);
$sth->finish;
}
***************
*** 315,318 ****
--- 302,306 ----
}
if ($itemnum ne ''){
+ #FIXME to use ? before uncommenting
# my $sth=$dbh->prepare("Select * from items where barcode='$itemnum'");
# $sth->execute;
***************
*** 343,347 ****
my ($env,$bornumber,$data,$barcode,$type,$user)address@hidden;
my $dbh = C4::Context->dbh;
- my $updquery = "";
my $newamtos = 0;
my $accdata = "";
--- 331,334 ----
***************
*** 350,355 ****
my $item=getiteminformation($env,'',$barcode);
my $nextaccntno = getnextacctno($env,$bornumber,$dbh);
! my $query="Select * from accountlines where (borrowernumber='$bornumber'
! and itemnumber='$item->{'itemnumber'}' and amountoutstanding > 0)";
if ($type eq 'CL'){
$query.=" and (accounttype = 'L' or accounttype = 'Rep')";
--- 337,342 ----
my $item=getiteminformation($env,'',$barcode);
my $nextaccntno = getnextacctno($env,$bornumber,$dbh);
! my $query="Select * from accountlines where (borrowernumber=?
! and itemnumber=? and amountoutstanding > 0)";
if ($type eq 'CL'){
$query.=" and (accounttype = 'L' or accounttype = 'Rep')";
***************
*** 362,366 ****
# print $query;
my $sth=$dbh->prepare($query);
! $sth->execute;
$accdata=$sth->fetchrow_hashref;
$sth->finish;
--- 349,353 ----
# print $query;
my $sth=$dbh->prepare($query);
! $sth->execute($bornumber,$item->{'itemnumber'});
$accdata=$sth->fetchrow_hashref;
$sth->finish;
***************
*** 373,386 ****
}
my $thisacct = $accdata->{accountno};
! my $updquery = "update accountlines set amountoutstanding= '$newamtos'
! where (borrowernumber = '$bornumber') and (accountno='$thisacct')";
! my $usth = $dbh->prepare($updquery);
! $usth->execute;
$usth->finish;
! $updquery = "insert into accountoffsets
(borrowernumber, accountno, offsetaccount, offsetamount)
! values ($bornumber,$accdata->{'accountno'},$nextaccntno,$newamtos)";
! $usth = $dbh->prepare($updquery);
! $usth->execute;
$usth->finish;
}
--- 360,371 ----
}
my $thisacct = $accdata->{accountno};
! my $usth = $dbh->prepare("update accountlines set amountoutstanding= ?
! where (borrowernumber = ?) and (accountno=?)");
! $usth->execute($newamtos,$bornumber,$thisacct);
$usth->finish;
! $usth = $dbh->prepare("insert into accountoffsets
(borrowernumber, accountno, offsetaccount, offsetamount)
! values (?,?,?,?)");
!
$usth->execute($bornumber,$accdata->{'accountno'},$nextaccntno,$newamtos);
$usth->finish;
}
***************
*** 388,396 ****
my $nextaccntno = getnextacctno($env,$bornumber,$dbh);
# get lines with outstanding amounts to offset
! my $query = "select * from accountlines
! where (borrowernumber = '$bornumber') and (amountoutstanding >0)
! order by date";
! my $sth = $dbh->prepare($query);
! $sth->execute;
# print $query;
# offset transactions
--- 373,380 ----
my $nextaccntno = getnextacctno($env,$bornumber,$dbh);
# get lines with outstanding amounts to offset
! my $sth = $dbh->prepare("select * from accountlines
! where (borrowernumber = ?) and (amountoutstanding >0)
! order by date");
! $sth->execute($bornumber);
# print $query;
# offset transactions
***************
*** 404,417 ****
}
my $thisacct = $accdata->{accountno};
! $updquery = "update accountlines set amountoutstanding= '$newamtos'
! where (borrowernumber = '$bornumber') and (accountno='$thisacct')";
! my $usth = $dbh->prepare($updquery);
! $usth->execute;
$usth->finish;
! $updquery = "insert into accountoffsets
(borrowernumber, accountno, offsetaccount, offsetamount)
! values ($bornumber,$accdata->{'accountno'},$nextaccntno,$newamtos)";
! $usth = $dbh->prepare($updquery);
! $usth->execute;
$usth->finish;
}
--- 388,399 ----
}
my $thisacct = $accdata->{accountno};
! my $usth = $dbh->prepare("update accountlines set amountoutstanding= ?
! where (borrowernumber = ?) and (accountno=?)");
! $usth->execute($newamtos,$bornumber,$thisacct);
$usth->finish;
! $usth = $dbh->prepare("insert into accountoffsets
(borrowernumber, accountno, offsetaccount, offsetamount)
! values (?,?,?,?)");
!
$usth->execute($bornumber,$accdata->{'accountno'},$nextaccntno,$newamtos);
$usth->finish;
}
***************
*** 430,434 ****
my ($env,$bornumber,$data)address@hidden;
my $dbh = C4::Context->dbh;
- my $updquery = "";
my $newamtos = 0;
my $accdata = "";
--- 412,415 ----
***************
*** 439,448 ****
my $nextaccntno = getnextacctno($env,$bornumber,$dbh);
# get lines with outstanding amounts to offset
! my $query = "select * from accountlines
! where (borrowernumber = '$bornumber') and (amountoutstanding<0)
! order by date";
! my $sth = $dbh->prepare($query);
! $sth->execute;
! # print $query;
# print $amountleft;
# offset transactions
--- 420,427 ----
my $nextaccntno = getnextacctno($env,$bornumber,$dbh);
# get lines with outstanding amounts to offset
! my $sth = $dbh->prepare("select * from accountlines
! where (borrowernumber = ?) and (amountoutstanding<0)
! order by date");
! $sth->execute($bornumber);
# print $amountleft;
# offset transactions
***************
*** 457,470 ****
# print $amountleft;
my $thisacct = $accdata->{accountno};
! $updquery = "update accountlines set amountoutstanding= '$newamtos'
! where (borrowernumber = '$bornumber') and (accountno='$thisacct')";
! my $usth = $dbh->prepare($updquery);
! $usth->execute;
$usth->finish;
! $updquery = "insert into accountoffsets
(borrowernumber, accountno, offsetaccount, offsetamount)
! values ($bornumber,$accdata->{'accountno'},$nextaccntno,$newamtos)";
! $usth = $dbh->prepare($updquery);
! $usth->execute;
$usth->finish;
}
--- 436,447 ----
# print $amountleft;
my $thisacct = $accdata->{accountno};
! my $usth = $dbh->prepare("update accountlines set amountoutstanding= ?
! where (borrowernumber = ?) and (accountno=?)");
! $usth->execute($newamtos,$bornumber,$thisacct);
$usth->finish;
! $usth = $dbh->prepare("insert into accountoffsets
(borrowernumber, accountno, offsetaccount, offsetamount)
! values (?,?,?,?)");
!
$usth->execute($bornumber,$accdata->{'accountno'},$nextaccntno,$newamtos);
$usth->finish;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Koha-cvs] CVS: koha/C4 Accounts2.pm,1.21,1.22,
MJ Ray <=