fix for 191, code reindenting & some query improvment

This commit is contained in:
tipaul 2003-05-05 09:41:03 +00:00
parent 95dde50470
commit 3c4012d4de
2 changed files with 645 additions and 674 deletions

View file

@ -31,16 +31,9 @@ use strict;
require Exporter; require Exporter;
use DBI; use DBI;
use C4::Context; use C4::Context;
#use C4::Accounts;
#use C4::InterfaceCDK;
#use C4::Circulation::Main;
#use C4::Circulation::Renewals;
#use C4::Scan;
use C4::Stats; use C4::Stats;
use C4::Reserves2; use C4::Reserves2;
use C4::Koha; use C4::Koha;
#use C4::Search;
#use C4::Print;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
@ -494,19 +487,10 @@ sub dotransfer {
$fbr = $dbh->quote($fbr); $fbr = $dbh->quote($fbr);
$tbr = $dbh->quote($tbr); $tbr = $dbh->quote($tbr);
#new entry in branchtransfers.... #new entry in branchtransfers....
$dbh->do(<<EOT); $dbh->do("INSERT INTO branchtransfers (itemnumber, frombranch, datearrived, tobranch)
INSERT INTO branchtransfers VALUES ($itm, $fbr, now(), $tbr)");
(itemnumber, frombranch, datearrived, tobranch)
VALUES ($itm, $fbr, now(), $tbr)
EOT
#update holdingbranch in items ..... #update holdingbranch in items .....
$dbh->do(<<EOT); $dbh->do("UPDATE items SET datelastseen = now(), holdingbranch = $tbr WHERE items.itemnumber = $itm);
UPDATE items
SET datelastseen = now(),
holdingbranch = $tbr
WHERE items.itemnumber = $itm
EOT
return; return;
} }
@ -687,7 +671,7 @@ sub issuebook {
$defaultanswer = 'Y'; $defaultanswer = 'Y';
last SWITCH; last SWITCH;
} elsif ($responses->{4} eq 'Y') { } elsif ($responses->{4} eq 'Y') {
my $charge = calc_charges($env, $dbh, $iteminformation->{'itemnumber'}, $patroninformation->{'borrowernumber'}); my ($charge,$itemtype) = calc_charges($env, $dbh, $iteminformation->{'itemnumber'}, $patroninformation->{'borrowernumber'});
if ($charge > 0) { if ($charge > 0) {
createcharge($env, $dbh, $iteminformation->{'itemnumber'}, $patroninformation->{'borrowernumber'}, $charge); createcharge($env, $dbh, $iteminformation->{'itemnumber'}, $patroninformation->{'borrowernumber'}, $charge);
$iteminformation->{'charge'} = $charge; $iteminformation->{'charge'} = $charge;
@ -818,7 +802,7 @@ sub issuebook {
$sth->execute; $sth->execute;
$sth->finish; $sth->finish;
# If it costs to borrow this book, charge it to the patron's account. # If it costs to borrow this book, charge it to the patron's account.
my $charge=calc_charges($env, $dbh, $iteminformation->{'itemnumber'}, $patroninformation->{'borrowernumber'}); my ($charge,$itemtype)=calc_charges($env, $dbh, $iteminformation->{'itemnumber'}, $patroninformation->{'borrowernumber'});
if ($charge > 0) { if ($charge > 0) {
createcharge($env, $dbh, $iteminformation->{'itemnumber'}, $patroninformation->{'borrowernumber'}, $charge); createcharge($env, $dbh, $iteminformation->{'itemnumber'}, $patroninformation->{'borrowernumber'}, $charge);
$iteminformation->{'charge'}=$charge; $iteminformation->{'charge'}=$charge;
@ -993,11 +977,7 @@ sub updateitemlost{
my ($itemno)=@_; my ($itemno)=@_;
my $dbh = C4::Context->dbh; my $dbh = C4::Context->dbh;
$dbh->do(<<EOT); $dbh->do("UPDATE items SET itemlost = 0 WHERE itemnumber = $itemno");
UPDATE items
SET itemlost = 0
WHERE itemnumber = $itemno
EOT
} }
# Not exported # Not exported
@ -1384,8 +1364,7 @@ sub currentissues {
# Either way, the date should be be formatted outside of the # Either way, the date should be be formatted outside of the
# loop. # loop.
my @datearr = localtime(time()); my @datearr = localtime(time());
my $todaysdate = (1900+$datearr[5]).sprintf ("%0.2d", ($datearr[4] my $todaysdate = (1900+$datearr[5]).sprintf ("%0.2d", ($datearr[4]+1)).sprintf ("%0.2d", $datearr[3]);
+1)).sprintf ("%0.2d", $datearr[3]);
my $datedue=$data->{'date_due'}; my $datedue=$data->{'date_due'};
$datedue=~s/-//g; $datedue=~s/-//g;
if ($datedue < $todaysdate) { if ($datedue < $todaysdate) {
@ -1483,9 +1462,7 @@ sub checkwaiting {
# check for reserves waiting # check for reserves waiting
my ($env,$dbh,$bornum)=@_; my ($env,$dbh,$bornum)=@_;
my @itemswaiting; my @itemswaiting;
my $query = "select * from reserves my $query = "select * from reserves where (borrowernumber = '$bornum') and (reserves.found='W') and cancellationdate is NULL";
where (borrowernumber = '$bornum')
and (reserves.found='W') and cancellationdate is NULL";
my $sth = $dbh->prepare($query); my $sth = $dbh->prepare($query);
$sth->execute(); $sth->execute();
my $cnt=0; my $cnt=0;

View file

@ -221,13 +221,9 @@ sub renewbook {
if ($charge > 0){ if ($charge > 0){
my $accountno=getnextacctno($env,$bornum,$dbh); my $accountno=getnextacctno($env,$bornum,$dbh);
my $item=getiteminformation($env, $itemno); my $item=getiteminformation($env, $itemno);
my $account="Insert into accountlines $sth=$dbh->prepare("Insert into accountlines (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber)
(borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber) values (?,?,now(),?,?,?,?,?)");
values $sth->execute($bornum,$accountno,$charge,"Renewal of Rental Item $item->{'title'} $item->{'barcode'}",'Rent',$charge,$itemno);
(?,?,now(),?,?,?,?,?)";
$sth=$dbh->prepare($account);
$sth->execute($bornum,$accountno,$charge,"Renewal of Rental Item $item->{'title'} $item->{'barcode'}",
'Rent',$charge,$itemno)";
$sth->finish; $sth->finish;
# print $account; # print $account;
} }
@ -266,13 +262,11 @@ sub calc_charges {
my $item_type; my $item_type;
# Get the book's item type and rental charge (via its biblioitem). # Get the book's item type and rental charge (via its biblioitem).
my $q1 = "select itemtypes.itemtype,rentalcharge from my $sth1= $dbh->prepare("select itemtypes.itemtype,rentalcharge from items,biblioitems,itemtypes
items,biblioitems,itemtypes where (items.itemnumber =?)
where (items.itemnumber ='$itemno')
and (biblioitems.biblioitemnumber = items.biblioitemnumber) and (biblioitems.biblioitemnumber = items.biblioitemnumber)
and (biblioitems.itemtype = itemtypes.itemtype)"; and (biblioitems.itemtype = itemtypes.itemtype)");
my $sth1= $dbh->prepare($q1); $sth1->execute($itemno);
$sth1->execute;
# FIXME - Why not just use fetchrow_array? # FIXME - Why not just use fetchrow_array?
if (my $data1=$sth1->fetchrow_hashref) { if (my $data1=$sth1->fetchrow_hashref) {
$item_type = $data1->{'itemtype'}; $item_type = $data1->{'itemtype'};