[Koha-cvs] CVS: koha/C4/Circulation Issues.pm,1.7,1.8
MJ Ray
slef at users.sourceforge.net
Mon Dec 8 15:45:32 CET 2003
Update of /cvsroot/koha/koha/C4/Circulation
In directory sc8-pr-cvs1:/tmp/cvs-serv17160/C4/Circulation
Modified Files:
Issues.pm
Log Message:
DBI call fix for bug 662
Index: Issues.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Circulation/Issues.pm,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** Issues.pm 1 Jul 2003 17:22:17 -0000 1.7
--- Issues.pm 8 Dec 2003 14:45:30 -0000 1.8
***************
*** 217,228 ****
my $canissue = 1;
## my ($itemnum,$reason)=&scanbook();
- my $query="Select * from items,biblio,biblioitems where (barcode='$itemnum') and
- (items.biblionumber=biblio.biblionumber) and
- (items.biblioitemnumber=biblioitems.biblioitemnumber) ";
my $item;
my $charge;
my $datedue = $env->{'loanlength'};
! my $sth=$dbh->prepare($query);
! $sth->execute;
if ($item=$sth->fetchrow_hashref) {
$sth->finish;
--- 217,227 ----
my $canissue = 1;
## my ($itemnum,$reason)=&scanbook();
my $item;
my $charge;
my $datedue = $env->{'loanlength'};
! my $sth=$dbh->prepare("Select * from items,biblio,biblioitems where (barcode=?) and
! (items.biblionumber=biblio.biblionumber) and
! (items.biblioitemnumber=biblioitems.biblioitemnumber) ");
! $sth->execute($itemnum);
if ($item=$sth->fetchrow_hashref) {
$sth->finish;
***************
*** 270,286 ****
#debug_msg($env,$resbor);
if ($resbor eq $bornum) {
! my $rquery = "update reserves
set found = 'F'
! where reservedate = '$resrec->{'reservedate'}'
! and borrowernumber = '$resrec->{'borrowernumber'}'
! and biblionumber = '$resrec->{'biblionumber'}'";
! my $rsth = $dbh->prepare($rquery);
! $rsth->execute;
$rsth->finish;
} elsif ($resbor ne "") {
! my $bquery = "select * from borrowers
! where borrowernumber = '$resbor'";
! my $btsh = $dbh->prepare($bquery);
! $btsh->execute;
my $resborrower = $btsh->fetchrow_hashref;
my $msgtxt = chr(7)."Res for $resborrower->{'cardnumber'},";
--- 269,282 ----
#debug_msg($env,$resbor);
if ($resbor eq $bornum) {
! my $rsth = $dbh->prepare("update reserves
set found = 'F'
! where reservedate = ?
! and borrowernumber = ?
! and biblionumber = ?");
! $rsth->execute($resrec->{'reservedate'},$resrec->{'borrowernumber'},$resrec->{'biblionumber'});
$rsth->finish;
} elsif ($resbor ne "") {
! my $btsh = $dbh->prepare("select * from borrowers where borrowernumber = ?");
! $btsh->execute($resbor);
my $resborrower = $btsh->fetchrow_hashref;
my $msgtxt = chr(7)."Res for $resborrower->{'cardnumber'},";
***************
*** 294,306 ****
my $ans = msg_ny($env,"Cancel reserve?");
if ($ans eq "Y") {
! my $rquery = "update reserves
set found = 'F'
! where reservedate = '$resrec->{'reservedate'}'
! and borrowernumber = '$resrec->{'borrowernumber'}'
! and biblionumber = '$resrec->{'biblionumber'}'";
! my $rsth = $dbh->prepare($rquery);
! $rsth->execute;
! $rsth->finish;
! }
}
$btsh->finish();
--- 290,301 ----
my $ans = msg_ny($env,"Cancel reserve?");
if ($ans eq "Y") {
! my $rsth = $dbh->prepare("update reserves
set found = 'F'
! where reservedate = ?
! and borrowernumber = ?
! and biblionumber = ?");
! $rsth->execute($resrec->{'reservedate'},$resrec->{'borrowernumber'},$resrec->{'biblionumber'});
! $rsth->finish;
! }
}
$btsh->finish();
***************
*** 346,355 ****
my ($env,$dbh,$itemno,$bornum,$charge) = @_;
my $nextaccntno = getnextacctno($env,$bornum,$dbh);
! my $query = "insert into accountlines
(borrowernumber,itemnumber,accountno,date,amount,
description,accounttype,amountoutstanding)
! values ($bornum,$itemno,$nextaccntno,now(),$charge,'Rental','Rent',$charge)";
! my $sth = $dbh->prepare($query);
! $sth->execute;
$sth->finish;
}
--- 341,349 ----
my ($env,$dbh,$itemno,$bornum,$charge) = @_;
my $nextaccntno = getnextacctno($env,$bornum,$dbh);
! my $sth = $dbh->prepare("insert into accountlines
(borrowernumber,itemnumber,accountno,date,amount,
description,accounttype,amountoutstanding)
! values (?,?,?,now(),?,'Rental','Rent',?)");
! $sth->execute($bornum,$itemno,$nextaccntno,$charge,$charge);
$sth->finish;
}
***************
*** 361,369 ****
my ($env,$itemno,$bitno,$dbh,$bornum)=@_;
my $loanlength=21;
! my $query="Select * from biblioitems,itemtypes
! where (biblioitems.biblioitemnumber='$bitno')
! and (biblioitems.itemtype = itemtypes.itemtype)";
! my $sth=$dbh->prepare($query);
! $sth->execute;
if (my $data=$sth->fetchrow_hashref) {
$loanlength = $data->{'loanlength'}
--- 355,362 ----
my ($env,$itemno,$bitno,$dbh,$bornum)=@_;
my $loanlength=21;
! my $sth=$dbh->prepare("Select * from biblioitems,itemtypes
! where (biblioitems.biblioitemnumber=?)
! and (biblioitems.itemtype = itemtypes.itemtype)");
! $sth->execute($bitno);
if (my $data=$sth->fetchrow_hashref) {
$loanlength = $data->{'loanlength'}
***************
*** 379,396 ****
$dateduef = $env->{'loanlength'};
}
! $query = "Insert into issues (borrowernumber,itemnumber, date_due,branchcode)
! values ($bornum,$itemno,'$dateduef','$env->{'branchcode'}')";
! my $sth=$dbh->prepare($query);
! $sth->execute;
$sth->finish;
! $query = "Select * from items where itemnumber=$itemno";
! $sth=$dbh->prepare($query);
! $sth->execute;
my $item=$sth->fetchrow_hashref;
$sth->finish;
$item->{'issues'}++;
! $query="Update items set issues=$item->{'issues'} where itemnumber=$itemno";
! $sth=$dbh->prepare($query);
! $sth->execute;
$sth->finish;
#my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($datedue);
--- 372,387 ----
$dateduef = $env->{'loanlength'};
}
! #FIXME: what is going on above? Replaces with MySQL function or strftime?
! my $sth=$dbh->prepare("Insert into issues (borrowernumber,itemnumber, date_due,branchcode)
! values (?,?,?,?)");
! $sth->execute($bornum,$itemno,$dateduef,$env->{'branchcode'});
$sth->finish;
! $sth=$dbh->prepare("Select * from items where itemnumber=?");
! $sth->execute($itemno);
my $item=$sth->fetchrow_hashref;
$sth->finish;
$item->{'issues'}++;
! $sth=$dbh->prepare("Update items set issues=? where itemnumber=?");
! $sth->execute($item->{'issues'},$itemno);
$sth->finish;
#my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($datedue);
***************
*** 412,435 ****
my $charge=0;
my $item_type;
! my $q1 = "select itemtypes.itemtype,rentalcharge from items,biblioitems,itemtypes
! where (items.itemnumber ='$itemno')
and (biblioitems.biblioitemnumber = items.biblioitemnumber)
! and (biblioitems.itemtype = itemtypes.itemtype)";
! my $sth1= $dbh->prepare($q1);
! $sth1->execute;
if (my $data1=$sth1->fetchrow_hashref) {
$item_type = $data1->{'itemtype'};
$charge = $data1->{'rentalcharge'};
! my $q2 = "select rentaldiscount from borrowers,categoryitem
! where (borrowers.borrowernumber = '$bornum')
and (borrowers.categorycode = categoryitem.categorycode)
! and (categoryitem.itemtype = '$item_type')";
! my $sth2=$dbh->prepare($q2);
! $sth2->execute;
if (my $data2=$sth2->fetchrow_hashref) {
my $discount = $data2->{'rentaldiscount'};
$charge = ($charge *(100 - $discount)) / 100;
}
! $sth2->{'finish'}; # FIXME - Was this supposed to be $sth2->finish ?
}
$sth1->finish;
--- 403,424 ----
my $charge=0;
my $item_type;
! my $sth1= $dbh->prepare("select itemtypes.itemtype,rentalcharge from items,biblioitems,itemtypes
! where (items.itemnumber =?)
and (biblioitems.biblioitemnumber = items.biblioitemnumber)
! and (biblioitems.itemtype = itemtypes.itemtype)");
! $sth1->execute($itemno);
if (my $data1=$sth1->fetchrow_hashref) {
$item_type = $data1->{'itemtype'};
$charge = $data1->{'rentalcharge'};
! my $sth2=$dbh->prepare("select rentaldiscount from borrowers,categoryitem
! where (borrowers.borrowernumber = ?)
and (borrowers.categorycode = categoryitem.categorycode)
! and (categoryitem.itemtype = ?)");
! $sth2->execute($bornum,$item_type);
if (my $data2=$sth2->fetchrow_hashref) {
my $discount = $data2->{'rentaldiscount'};
$charge = ($charge *(100 - $discount)) / 100;
}
! $sth2->finish;
}
$sth1->finish;
More information about the Koha-cvs
mailing list