[Koha-cvs] CVS: koha/C4 Reserves2.pm,1.20,1.21
Andrew Arensburger
arensb at users.sourceforge.net
Sat Oct 5 11:52:27 CEST 2002
Update of /cvsroot/koha/koha/C4
In directory usw-pr-cvs1:/tmp/cvs-serv22577/C4
Modified Files:
Reserves2.pm
Log Message:
Merged with arensb-context branch: use C4::Context->dbh instead of
&C4Connect, and generally prefer C4::Context over C4::Database.
Index: Reserves2.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Reserves2.pm,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -r1.20 -r1.21
*** Reserves2.pm 27 Sep 2002 05:21:44 -0000 1.20
--- Reserves2.pm 5 Oct 2002 09:52:25 -0000 1.21
***************
*** 22,27 ****
require Exporter;
use DBI;
! use C4::Database;
use C4::Search;
#use C4::Accounts;
--- 22,29 ----
require Exporter;
use DBI;
! use C4::Context;
use C4::Search;
+ # FIXME - C4::Reserves2 uses C4::Search, which uses C4::Reserves2.
+ # So Perl complains that all of the functions here get redefined.
#use C4::Accounts;
***************
*** 38,42 ****
sub FindReserves {
my ($bib,$bor)=@_;
! my $dbh=C4Connect;
my $query="SELECT *,reserves.branchcode,biblio.title AS btitle
FROM reserves,borrowers,biblio ";
--- 40,44 ----
sub FindReserves {
my ($bib,$bor)=@_;
! my $dbh = C4::Context->dbh;
my $query="SELECT *,reserves.branchcode,biblio.title AS btitle
FROM reserves,borrowers,biblio ";
***************
*** 93,97 ****
# print $query;
$sth->finish;
- $dbh->disconnect;
return($i,\@results);
}
--- 95,98 ----
***************
*** 100,104 ****
my ($item, $barcode) = @_;
# warn "In CheckReserves: itemnumber = $item";
! my $dbh=C4Connect;
my $sth;
if ($item) {
--- 101,105 ----
my ($item, $barcode) = @_;
# warn "In CheckReserves: itemnumber = $item";
! my $dbh = C4::Context->dbh;
my $sth;
if ($item) {
***************
*** 122,126 ****
my ($biblio, $bibitem, $notforloan) = $sth->fetchrow_array;
$sth->finish;
- $dbh->disconnect;
# if item is not for loan it cannot be reserved either.....
return (0, 0) if ($notforloan);
--- 123,126 ----
***************
*** 151,155 ****
sub CancelReserve {
my ($biblio, $item, $borr) = @_;
! my $dbh=C4Connect;
#warn "In CancelReserve";
if (($item and $borr) and (not $biblio)) {
--- 151,155 ----
sub CancelReserve {
my ($biblio, $item, $borr) = @_;
! my $dbh = C4::Context->dbh;
#warn "In CancelReserve";
if (($item and $borr) and (not $biblio)) {
***************
*** 182,185 ****
--- 182,186 ----
$sth->finish;
# update the database, removing the record...
+ # FIXME - There's already a $query in this scope.
my $query = "update reserves set cancellationdate = now(),
found = Null,
***************
*** 189,193 ****
--- 190,197 ----
and cancellationdate is NULL
and (found <> 'F' or found is NULL)";
+ # FIXME - There's already a $query in this scope.
+ # FIXME - There's already a $sth in this scope.
my $sth = $dbh->prepare($query);
+ # FIXME - There's already a $sth in this scope.
$sth->execute;
$sth->finish;
***************
*** 195,199 ****
fixpriority($priority, $biblio);
}
- $dbh->disconnect;
}
--- 199,202 ----
***************
*** 201,205 ****
sub FillReserve {
my ($res) = @_;
! my $dbh=C4Connect;
# fillinf a reserve record....
my $biblio = $res->{'biblionumber'}; my $qbiblio = $dbh->quote($biblio);
--- 204,208 ----
sub FillReserve {
my ($res) = @_;
! my $dbh = C4::Context->dbh;
# fillinf a reserve record....
my $biblio = $res->{'biblionumber'}; my $qbiblio = $dbh->quote($biblio);
***************
*** 216,219 ****
--- 219,223 ----
$sth->finish;
# update the database...
+ # FIXME - There's already a $query in this scope.
my $query = "UPDATE reserves SET found = 'F',
priority = 0
***************
*** 221,225 ****
--- 225,232 ----
AND reservedate = $resdate
AND borrowernumber = $borr";
+ # FIXME - There's already a $query in this scope.
+ # FIXME - There's already a $sth in this scope.
my $sth = $dbh->prepare($query);
+ # FIXME - There's already a $sth in this scope.
$sth->execute;
$sth->finish;
***************
*** 228,237 ****
fixpriority($priority, $biblio);
}
- $dbh->disconnect;
}
sub fixpriority {
my ($priority, $biblio) = @_;
! my $dbh = C4Connect;
my ($count, $reserves) = FindReserves($biblio);
foreach my $rec (@$reserves) {
--- 235,243 ----
fixpriority($priority, $biblio);
}
}
sub fixpriority {
my ($priority, $biblio) = @_;
! my $dbh = C4::Context->dbh;
my ($count, $reserves) = FindReserves($biblio);
foreach my $rec (@$reserves) {
***************
*** 251,255 ****
}
}
- $dbh->disconnect;
}
--- 257,260 ----
***************
*** 258,262 ****
sub ReserveWaiting {
my ($item, $borr) = @_;
! my $dbh = C4Connect;
$item = $dbh->quote($item);
$borr = $dbh->quote($borr);
--- 263,267 ----
sub ReserveWaiting {
my ($item, $borr) = @_;
! my $dbh = C4::Context->dbh;
$item = $dbh->quote($item);
$borr = $dbh->quote($borr);
***************
*** 290,294 ****
$sth->execute;
$sth->finish;
- $dbh->disconnect;
# now fix up the remaining priorities....
fixpriority($data->{'priority'}, $biblio);
--- 295,298 ----
***************
*** 299,303 ****
sub CheckWaiting {
my ($borr)=@_;
! my $dbh = C4Connect;
$borr = $dbh->quote($borr);
my @itemswaiting;
--- 303,307 ----
sub CheckWaiting {
my ($borr)=@_;
! my $dbh = C4::Context->dbh;
$borr = $dbh->quote($borr);
my @itemswaiting;
***************
*** 308,314 ****
my $sth = $dbh->prepare($query);
$sth->execute();
my $cnt=0;
if (my $data=$sth->fetchrow_hashref) {
! @itemswaiting[$cnt] =$data;
$cnt ++;
}
--- 312,319 ----
my $sth = $dbh->prepare($query);
$sth->execute();
+ # FIXME - Use 'push'
my $cnt=0;
if (my $data=$sth->fetchrow_hashref) {
! $itemswaiting[$cnt] =$data;
$cnt ++;
}
***************
*** 319,323 ****
sub Findgroupreserve {
my ($bibitem,$biblio)=@_;
! my $dbh=C4Connect;
$bibitem=$dbh->quote($bibitem);
my $query = "SELECT reserves.biblionumber AS biblionumber,
--- 324,328 ----
sub Findgroupreserve {
my ($bibitem,$biblio)=@_;
! my $dbh = C4::Context->dbh;
$bibitem=$dbh->quote($bibitem);
my $query = "SELECT reserves.biblionumber AS biblionumber,
***************
*** 350,354 ****
}
$sth->finish;
- $dbh->disconnect;
return($i, at results);
}
--- 355,358 ----
***************
*** 358,362 ****
($env,$branch,$borrnum,$biblionumber,$constraint,$bibitems,$priority,$notes,$title)= @_;
my $fee=CalcReserveFee($env,$borrnum,$biblionumber,$constraint,$bibitems);
! my $dbh = &C4Connect;
my $const = lc substr($constraint,0,1);
my @datearr = localtime(time);
--- 362,366 ----
($env,$branch,$borrnum,$biblionumber,$constraint,$bibitems,$priority,$notes,$title)= @_;
my $fee=CalcReserveFee($env,$borrnum,$biblionumber,$constraint,$bibitems);
! my $dbh = C4::Context->dbh;
my $const = lc substr($constraint,0,1);
my @datearr = localtime(time);
***************
*** 401,405 ****
}
# print $query;
- $dbh->disconnect();
return();
}
--- 405,408 ----
***************
*** 408,412 ****
my ($env,$borrnum,$biblionumber,$constraint,$bibitems) = @_;
#check for issues;
! my $dbh = &C4Connect;
my $const = lc substr($constraint,0,1);
my $query = "SELECT * FROM borrowers,categories
--- 411,415 ----
my ($env,$borrnum,$biblionumber,$constraint,$bibitems) = @_;
#check for issues;
! my $dbh = C4::Context->dbh;
my $const = lc substr($constraint,0,1);
my $query = "SELECT * FROM borrowers,categories
***************
*** 487,491 ****
}
# print "fee $fee";
- $dbh->disconnect();
return $fee;
}
--- 490,493 ----
***************
*** 509,513 ****
#subroutine to update a reserve
my ($rank,$biblio,$borrower,$del,$branch)=@_;
! my $dbh=C4Connect;
my $query="Update reserves ";
if ($del == 0){
--- 511,515 ----
#subroutine to update a reserve
my ($rank,$biblio,$borrower,$del,$branch)=@_;
! my $dbh = C4::Context->dbh;
my $query="Update reserves ";
if ($del == 0){
***************
*** 541,546 ****
my $sth=$dbh->prepare($query);
$sth->execute;
! $sth->finish;
! $dbh->disconnect;
}
sub UpdateReserve {
--- 543,547 ----
my $sth=$dbh->prepare($query);
$sth->execute;
! $sth->finish;
}
sub UpdateReserve {
***************
*** 548,552 ****
my ($rank,$biblio,$borrower,$branch)=@_;
return if $rank eq "W";
! my $dbh=C4Connect;
if ($rank eq "del") {
my $query = "UPDATE reserves SET cancellationdate=now()
--- 549,553 ----
my ($rank,$biblio,$borrower,$branch)=@_;
return if $rank eq "W";
! my $dbh = C4::Context->dbh;
if ($rank eq "del") {
my $query = "UPDATE reserves SET cancellationdate=now()
***************
*** 568,577 ****
$sth->finish;
}
- $dbh->disconnect;
}
sub getreservetitle {
my ($biblio,$bor,$date,$timestamp)=@_;
! my $dbh=C4Connect;
my $query="Select * from reserveconstraints,biblioitems where
reserveconstraints.biblioitemnumber=biblioitems.biblioitemnumber
--- 569,577 ----
$sth->finish;
}
}
sub getreservetitle {
my ($biblio,$bor,$date,$timestamp)=@_;
! my $dbh = C4::Context->dbh;
my $query="Select * from reserveconstraints,biblioitems where
reserveconstraints.biblioitemnumber=biblioitems.biblioitemnumber
***************
*** 583,587 ****
my $data=$sth->fetchrow_hashref;
$sth->finish;
- $dbh->disconnect;
# print $query;
return($data);
--- 583,586 ----
More information about the Koha-cvs
mailing list