Merged with arensb-context branch: use C4::Context->dbh instead of

&C4Connect, and generally prefer C4::Context over C4::Database.
This commit is contained in:
arensb 2002-10-05 09:44:27 +00:00
parent 7e1bad92e6
commit dbca39823f
103 changed files with 1079 additions and 1172 deletions

View File

@ -21,7 +21,7 @@ package C4::Accounts; #assumes C4/Accounts
use strict;
require Exporter;
use DBI;
use C4::Database;
use C4::Context;
use C4::Format;
use C4::Search;
use C4::Stats;
@ -103,7 +103,7 @@ sub checkaccount {
sub reconcileaccount {
#print put money owing give person opportunity to pay it off
my ($env,$dummy,$bornumber,$total)=@_;
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
#get borrower record
my $sth=$dbh->prepare("select * from borrowers
where borrowernumber=$bornumber");
@ -144,7 +144,6 @@ sub reconcileaccount {
#Check if the borrower still owes
$total=&checkaccount($env,$bornumber,$dbh);
}
$dbh->disconnect;
return($total);
}
@ -186,6 +185,7 @@ sub recordpayment{
$updquery = "insert into accountoffsets
(borrowernumber, accountno, offsetaccount, offsetamount)
values ($bornumber,$accdata->{'accountno'},$nextaccntno,$newamtos)";
# FIXME - There's already a $usth in this scope.
my $usth = $dbh->prepare($updquery);
# print $updquery
$usth->execute;

View File

@ -21,7 +21,7 @@ package C4::Accounts2; #assumes C4/Accounts2
use strict;
require Exporter;
use DBI;
use C4::Database;
use C4::Context;
use C4::Stats;
use C4::Search;
use C4::Circulation::Circ2;
@ -80,7 +80,7 @@ will be credited to the next one.
sub recordpayment{
#here we update both the accountoffsets and the account lines
my ($env,$bornumber,$data)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $updquery = "";
my $newamtos = 0;
my $accdata = "";
@ -126,7 +126,6 @@ sub recordpayment{
$usth->finish;
UpdateStats($env,$branch,'payment',$data,'','','',$bornumber);
$sth->finish;
$dbh->disconnect;
}
=item makepayment
@ -152,7 +151,7 @@ sub makepayment{
# from their card, and put a note on the item record
my ($bornumber,$accountno,$amount,$user)=@_;
my $env;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
# begin transaction
my $nextaccntno = getnextacctno($env,$bornumber,$dbh);
my $newamtos=0;
@ -188,7 +187,6 @@ sub makepayment{
# branch code.
UpdateStats($env,$user,'payment',$amount,'','','',$bornumber);
$sth->finish;
$dbh->disconnect;
#check to see what accounttype
if ($data->{'accounttype'} eq 'Rep' || $data->{'accounttype'} eq 'L'){
returnlost($bornumber,$data->{'itemnumber'});
@ -233,7 +231,7 @@ sub getnextacctno {
# FIXME - I don't understand what this function does.
sub fixaccounts {
my ($borrowernumber,$accountno,$amount)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from accountlines where borrowernumber=$borrowernumber
and accountno=$accountno";
my $sth=$dbh->prepare($query);
@ -243,19 +241,19 @@ sub fixaccounts {
my $diff=$amount-$data->{'amount'};
my $outstanding=$data->{'amountoutstanding'}+$diff;
$sth->finish;
# FIXME - Use $dbh->do();
$query="Update accountlines set amount='$amount',amountoutstanding='$outstanding' where
borrowernumber=$borrowernumber and accountno=$accountno";
$sth=$dbh->prepare($query);
# print $query;
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
# FIXME - Never used, but not exported, either.
sub returnlost{
my ($borrnum,$itemnum)=@_;
my $dbh=C4Connect;
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";
@ -265,11 +263,11 @@ sub returnlost{
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;
$dbh->disconnect;
}
=item manualinvoice
@ -289,7 +287,7 @@ should be the empty string.
# FIXME - Okay, so what does this function do, really?
sub manualinvoice{
my ($bornum,$itemnum,$desc,$type,$amount,$user)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $insert;
$itemnum=~ s/ //g;
my %env;
@ -317,10 +315,12 @@ sub manualinvoice{
$sth->finish;
$desc.=" ".$itemnum;
$desc=$dbh->quote($desc);
# FIXME - Use $dbh->do();
$insert="insert into accountlines (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber)
values ($bornum,$accountno,now(),'$amount',$desc,'$type','$amountleft','$data->{'itemnumber'}')";
} else {
$desc=$dbh->quote($desc);
# FIXME - Use $dbh->do();
$insert="insert into accountlines (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding)
values ($bornum,$accountno,now(),'$amount',$desc,'$type','$amountleft')";
}
@ -328,8 +328,6 @@ sub manualinvoice{
my $sth=$dbh->prepare($insert);
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
# fixcredit
@ -340,7 +338,7 @@ sub manualinvoice{
sub fixcredit{
#here we update both the accountoffsets and the account lines
my ($env,$bornumber,$data,$barcode,$type,$user)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $updquery = "";
my $newamtos = 0;
my $accdata = "";
@ -415,7 +413,6 @@ sub fixcredit{
$usth->finish;
}
$sth->finish;
$dbh->disconnect;
$env->{'branch'}=$user;
$type="Credit ".$type;
UpdateStats($env,$user,$type,$data,$user,'','',$bornumber);
@ -428,7 +425,7 @@ sub fixcredit{
sub refund{
#here we update both the accountoffsets and the account lines
my ($env,$bornumber,$data)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $updquery = "";
my $newamtos = 0;
my $accdata = "";
@ -469,7 +466,6 @@ sub refund{
$usth->finish;
}
$sth->finish;
$dbh->disconnect;
return($amountleft);
}

View File

@ -25,7 +25,7 @@ package C4::Acquisitions; #assumes C4/Acquisitions.pm
use strict;
require Exporter;
use C4::Database;
use C4::Context;
#use C4::Biblio;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
@ -138,7 +138,7 @@ Results are ordered from most to least recent.
# FIXME - This exact function already exists in C4::Catalogue
sub getorders {
my ($supplierid)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query = "Select count(*),authorisedby,entrydate,basketno from aqorders where
booksellerid='$supplierid' and (quantity > quantityreceived or
quantityreceived is NULL)
@ -154,7 +154,6 @@ sub getorders {
$i++;
}
$sth->finish;
$dbh->disconnect;
return ($i,\@results);
}
@ -163,14 +162,13 @@ sub getorders {
# the same as &C4::Search::itemcount
sub itemcount{
my ($biblio)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select count(*) from items where biblionumber=$biblio";
# print $query;
my $sth=$dbh->prepare($query);
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
return($data->{'count(*)'});
}
@ -192,7 +190,7 @@ tables of the Koha database.
# FIXME - Almost the exact same function is already in C4::Catalogue
sub getorder{
my ($bi,$bib)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select ordernumber
from aqorders
where biblionumber=? and biblioitemnumber=?";
@ -201,7 +199,6 @@ sub getorder{
my $ordnum=$sth->fetchrow_hashref;
$sth->finish;
my $order=getsingleorder($ordnum->{'ordernumber'});
$dbh->disconnect;
# print $query;
return ($order,$ordnum->{'ordernumber'});
}
@ -222,7 +219,7 @@ aqorderbreakdown tables of the Koha database.
# &C4::Catalogue::getsingleorder and &C4::Biblio::getsingleorder.
sub getsingleorder {
my ($ordnum)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from biblio,biblioitems,aqorders,aqorderbreakdown
where aqorders.ordernumber=?
and biblio.biblionumber=aqorders.biblionumber and
@ -232,7 +229,6 @@ sub getsingleorder {
$sth->execute($ordnum);
my $data=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
return($data);
}
@ -252,7 +248,7 @@ of the Koha database.
# FIXME - This exact function is already in C4::Catalogue
sub invoice {
my ($invoice)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from aqorders,biblio,biblioitems where
booksellerinvoicenumber='$invoice'
and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber=
@ -266,7 +262,6 @@ sub invoice {
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,@results);
}
@ -290,7 +285,7 @@ C<@results> is sorted alphabetically by book title.
sub getallorders {
#gets all orders from a certain supplier, orders them alphabetically
my ($supid)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from aqorders,biblio,biblioitems where booksellerid='$supid'
and (cancelledby is NULL or cancelledby = '')
and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber=
@ -307,7 +302,6 @@ sub getallorders {
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,@results);
}
@ -316,7 +310,7 @@ sub getallorders {
sub getrecorders {
#gets all orders from a certain supplier, orders them alphabetically
my ($supid)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from aqorders,biblio,biblioitems where booksellerid='$supid'
and (cancelledby is NULL or cancelledby = '')
and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber=
@ -335,7 +329,6 @@ sub getrecorders {
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,@results);
}
@ -377,7 +370,7 @@ following keys:
# FIXME - The same function (modulo whitespace) appears in C4::Catalogue
sub ordersearch {
my ($search,$biblio,$catview)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select *,biblio.title from aqorders,biblioitems,biblio
where aqorders.biblioitemnumber = biblioitems.biblioitemnumber
and biblio.biblionumber=aqorders.biblionumber
@ -420,7 +413,6 @@ sub ordersearch {
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,@results);
}
@ -440,7 +432,7 @@ aqbooksellers table in the Koha database.
# FIXME - This function appears in C4::Catalogue
sub bookseller {
my ($searchstring)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from aqbooksellers where name like '%$searchstring%' or
id = '$searchstring'";
my $sth=$dbh->prepare($query);
@ -452,7 +444,6 @@ sub bookseller {
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,@results);
}
@ -471,7 +462,7 @@ are the fields of the aqorderbreakdown table in the Koha database.
# FIXME - This function appears in C4::Catalogue.
sub breakdown {
my ($id)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from aqorderbreakdown where ordernumber='$id'";
my $sth=$dbh->prepare($query);
$sth->execute;
@ -482,7 +473,6 @@ sub breakdown {
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,\@results);
}
@ -505,7 +495,7 @@ number of elements in C<@orders>.
# C4::Catalogue.pm
sub basket {
my ($basketno,$supplier)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select *,biblio.title from aqorders,biblio,biblioitems
where basketno='$basketno'
and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber
@ -526,7 +516,6 @@ sub basket {
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,@results);
}
@ -550,7 +539,7 @@ database, and returns it.
# remove out-of-date dummy orders.
# FIXME - This function appears in C4::Catalogue.pm
sub newbasket {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select max(basketno) from aqorders";
my $sth=$dbh->prepare($query);
$sth->execute;
@ -558,7 +547,6 @@ sub newbasket {
my $basket=$$data[0];
$basket++;
$sth->finish;
$dbh->disconnect;
return($basket);
}
@ -578,7 +566,7 @@ alphabetically by book fund name.
# FIXME - An identical function (without the hardcoded date) appears in
# C4::Catalogue
sub bookfunds {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from aqbookfund,aqbudget where aqbookfund.bookfundid
=aqbudget.bookfundid
and aqbudget.startdate='2001-07-01'
@ -592,7 +580,6 @@ sub bookfunds {
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,@results);
}
@ -610,7 +597,7 @@ table of the Koha database.
#'
# FIXME - This function (modulo whitespace) appears in C4::Catalogue
sub branches {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from branches";
my $sth=$dbh->prepare($query);
my $i=0;
@ -623,7 +610,6 @@ sub branches {
} # while
$sth->finish;
$dbh->disconnect;
return($i, @results);
} # sub branches
@ -631,7 +617,7 @@ sub branches {
# FIXME - An almost identical function appears in C4::Catalogue
sub bookfundbreakdown {
my ($id)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select quantity,datereceived,freight,unitprice,listprice,ecost,quantityreceived,subscription
from aqorders,aqorderbreakdown where bookfundid='$id' and
aqorders.ordernumber=aqorderbreakdown.ordernumber and ((budgetdate >=
@ -653,14 +639,15 @@ sub bookfundbreakdown {
}
}
$sth->finish;
$dbh->disconnect;
return($spent,$comtd);
}
# FIXME - This is in effect identical to &C4::Biblio::newbiblio.
# Pick one and stick with it.
# XXX - POD
sub newbiblio {
my ($biblio) = @_;
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $query = "Select max(biblionumber) from biblio";
my $sth = $dbh->prepare($query);
$sth->execute;
@ -677,6 +664,7 @@ sub newbiblio {
if ($biblio->{'seriestitle'}) { $series = 1 };
$sth->finish;
# FIXME - Use $dbh->do();
$query = "insert into biblio set
biblionumber = $bibnum,
title = $biblio->{'title'},
@ -691,14 +679,15 @@ abstract = $biblio->{'abstract'}";
$sth->execute;
$sth->finish;
$dbh->disconnect;
return($bibnum);
}
# FIXME - This is in effect the same as &C4::Biblio::modbiblio.
# Pick one and stick with it.
# XXX - POD
sub modbiblio {
my ($biblio) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $query;
my $sth;
@ -726,14 +715,15 @@ where biblionumber = $biblio->{'biblionumber'}";
$sth->execute;
$sth->finish;
$dbh->disconnect;
return($biblio->{'biblionumber'});
} # sub modbiblio
# FIXME - This is in effect identical to &C4::Biblio::modsubtitle.
# Pick one and stick with it.
# XXX - POD
sub modsubtitle {
my ($bibnum, $subtitle) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $query = "update bibliosubtitle set
subtitle = '$subtitle'
where biblionumber = $bibnum";
@ -741,14 +731,14 @@ where biblionumber = $bibnum";
$sth->execute;
$sth->finish;
$dbh->disconnect;
} # sub modsubtitle
# XXX - POD
# FIXME - This is functionally identical to &C4::Biblio::modaddauthor
# Pick one and stick with it.
sub modaddauthor {
my ($bibnum, $author) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $query = "Delete from additionalauthors where biblionumber = $bibnum";
my $sth = $dbh->prepare($query);
@ -765,14 +755,14 @@ biblionumber = '$bibnum'";
$sth->finish;
} # if
$dbh->disconnect;
} # sub modaddauthor
# FIXME - This is in effect identical to &C4::Biblio::modsubject.
# Pick one and stick with it.
# XXX - POD
sub modsubject {
my ($bibnum, $force, @subject) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $count = @subject;
my $error;
for (my $i = 0; $i < $count; $i++) {
@ -834,14 +824,15 @@ values ('$subject[$i]', $bibnum)");
} # for
} # if
$dbh->disconnect;
return($error);
} # sub modsubject
# FIXME - This is very similar to &C4::Biblio::modbibitem.
# Pick one and stick with it.
# XXX - POD
sub modbibitem {
my ($biblioitem) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $query;
# FIXME -
@ -882,27 +873,27 @@ place = $biblioitem->{'place'}
where biblioitemnumber = $biblioitem->{'biblioitemnumber'}";
$dbh->do($query);
$dbh->disconnect;
} # sub modbibitem
# FIXME - This is in effect identical to &C4::Biblio::modnote.
# Pick one and stick with it.
# XXX - POD
sub modnote {
my ($bibitemnum,$note)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
# FIXME - Use $dbh->do();
my $query="update biblioitems set notes='$note' where
biblioitemnumber='$bibitemnum'";
my $sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
# XXX - POD
# FIXME - &C4::Biblio::newbiblioitem is quite similar to this
sub newbiblioitem {
my ($biblioitem) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $query = "Select max(biblioitemnumber) from biblioitems";
my $sth = $dbh->prepare($query);
my $data;
@ -963,28 +954,29 @@ place = $biblioitem->{'place'}";
$sth->execute;
$sth->finish;
$dbh->disconnect;
return($bibitemnum);
}
# FIXME - This is in effect identical to &C4::Biblio::newsubject.
# Pick one and stick with it.
# XXX - POD
sub newsubject {
my ($bibnum)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="insert into bibliosubject (biblionumber) values
($bibnum)";
my $sth=$dbh->prepare($query);
# print $query;
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
# XXX - POD
# FIXME - This is in effect the same as &C4::Biblio::newsubtitle
# Pick one and stick with it.
sub newsubtitle {
my ($bibnum, $subtitle) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
$subtitle = $dbh->quote($subtitle);
my $query = "insert into bibliosubtitle set
biblionumber = $bibnum,
@ -994,7 +986,6 @@ subtitle = $subtitle";
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
=item neworder
@ -1033,7 +1024,7 @@ sub neworder {
} else {
$sub=0;
}
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="insert into aqorders (biblionumber,title,basketno,
quantity,listprice,booksellerid,entrydate,requisitionedby,authorisedby,notes,
biblioitemnumber,rrp,ecost,gst,unitprice,subscription,booksellerinvoicenumber)
@ -1059,7 +1050,6 @@ sub neworder {
# print $query;
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
=item delorder
@ -1079,7 +1069,7 @@ marc_biblio tables of the Koha database.
# FIXME - This function appears in C4::Catalogue
sub delorder {
my ($bibnum,$ordnum)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="update aqorders set datecancellationprinted=now()
where biblionumber='$bibnum' and
ordernumber='$ordnum'";
@ -1091,7 +1081,6 @@ sub delorder {
if ($count == 0){
delbiblio($bibnum);
}
$dbh->disconnect;
}
=item modorder
@ -1114,7 +1103,7 @@ table are also updated to the new book fund ID.
# FIXME - This function appears in C4::Catalogue
sub modorder {
my ($title,$ordnum,$quantity,$listprice,$bibnum,$basketno,$supplier,$who,$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst,$budget,$cost,$invoice)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="update aqorders set title='$title',
quantity='$quantity',listprice='$listprice',basketno='$basketno',
rrp='$rrp',ecost='$ecost',unitprice='$cost',
@ -1131,7 +1120,6 @@ sub modorder {
# print $query;
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
=item newordernum
@ -1146,7 +1134,7 @@ database, and returns it.
# FIXME - Race condition
# FIXME - This function appears in C4::Catalogue
sub newordernum {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select max(ordernumber) from aqorders";
my $sth=$dbh->prepare($query);
$sth->execute;
@ -1154,7 +1142,6 @@ sub newordernum {
my $ordnum=$$data[0];
$ordnum++;
$sth->finish;
$dbh->disconnect;
return($ordnum);
}
@ -1178,7 +1165,7 @@ Also updates the book fund ID in the aqorderbreakdown table.
# FIXME - This function appears in C4::Catalogue
sub receiveorder {
my ($biblio,$ordnum,$quantrec,$user,$cost,$invoiceno,$bibitemno,$freight,$bookfund,$rrp)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="update aqorders set quantityreceived='$quantrec',
datereceived=now(),booksellerinvoicenumber='$invoiceno',
biblioitemnumber=$bibitemno,unitprice='$cost',freight='$freight',
@ -1195,7 +1182,6 @@ sub receiveorder {
# print $query;
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
=item updaterecorder
@ -1215,7 +1201,7 @@ C<$user> is ignored.
# FIXME - This function appears in C4::Catalogue
sub updaterecorder{
my($biblio,$ordnum,$user,$cost,$bookfund,$rrp)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="update aqorders set
unitprice='$cost', rrp='$rrp'
where biblionumber=$biblio and ordernumber=$ordnum
@ -1230,7 +1216,6 @@ sub updaterecorder{
# print $query;
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
=item curconvert
@ -1249,13 +1234,12 @@ to one.
# C4::Catalogue
sub curconvert {
my ($currency,$price)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select rate from currency where currency='$currency'";
my $sth=$dbh->prepare($query);
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
my $cur=$data->{'rate'};
if ($cur==0){
$cur=1;
@ -1278,7 +1262,7 @@ keys are the fields from the currency table in the Koha database.
#'
# FIXME - This function appears in C4::Catalogue
sub getcurrencies {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from currency";
my $sth=$dbh->prepare($query);
$sth->execute;
@ -1289,21 +1273,19 @@ sub getcurrencies {
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,\@results);
}
# FIXME - This function appears in C4::Catalogue. Neither one is used.
sub getcurrency {
my ($cur)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from currency where currency='$cur'";
my $sth=$dbh->prepare($query);
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
return($data);
}
@ -1318,12 +1300,11 @@ Sets the exchange rate for C<$currency> to be C<$newrate>.
# FIXME - This function appears in C4::Catalogue
sub updatecurrencies {
my ($currency,$rate)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="update currency set rate=$rate where currency='$currency'";
my $sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
=item updatesup
@ -1344,7 +1325,7 @@ C<&updatesup> with the result.
# FIXME - This function appears in C4::Catalogue
sub updatesup {
my ($data)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Update aqbooksellers set
name='$data->{'name'}',address1='$data->{'address1'}',address2='$data->{'address2'}',
address3='$data->{'address3'}',address4='$data->{'address4'}',postal='$data->{'postal'}',
@ -1362,14 +1343,13 @@ sub updatesup {
my $sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
$dbh->disconnect;
# print $query;
}
# XXX - POD
sub insertsup {
my ($data)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("Select max(id) from aqbooksellers");
$sth->execute;
my $data2=$sth->fetchrow_hashref;
@ -1379,7 +1359,6 @@ sub insertsup {
$sth->execute;
$sth->finish;
$data->{'id'}=$data2->{'max(id)'};
$dbh->disconnect;
updatesup($data);
return($data->{'id'});
}
@ -1397,9 +1376,11 @@ Returns the ID of the newly-created bookseller.
=cut
#'
# FIXME - This function appears in C4::Catalogue
# FIXME - This is different from &C4::Biblio::newitems, though both
# are exported.
sub newitems {
my ($item, @barcodes) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $query = "Select max(itemnumber) from items";
my $sth = $dbh->prepare($query);
my $data;
@ -1448,14 +1429,15 @@ notforloan = $item->{'loan'}";
$itemnumber++;
} # for
$dbh->disconnect;
return($error);
}
# FIXME - This is the same as &C4::Biblio::Checkitems.
# Pick one and stick with it.
# XXX - POD
sub checkitems{
my ($count,@barcodes)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $error;
for (my $i=0;$i<$count;$i++){
$barcodes[$i]=uc $barcodes[$i];
@ -1467,14 +1449,16 @@ sub checkitems{
}
$sth->finish;
}
$dbh->disconnect;
return($error);
}
# FIXME - This appears to be functionally equivalent to
# &C4::Biblio::moditem.
# Pick one and stick with it.
# XXX - POD
sub moditem {
my ($loan,$itemnum,$bibitemnum,$barcode,$notes,$homebranch,$lost,$wthdrawn,$replacement)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="update items set biblioitemnumber=$bibitemnum,
barcode='$barcode',itemnotes='$notes'
where itemnumber=$itemnum";
@ -1493,38 +1477,37 @@ sub moditem {
my $sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
# FIXME - This function appears in C4::Catalogue. Neither one is used
sub updatecost{
my($price,$rrp,$itemnum)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="update items set price='$price',replacementprice='$rrp'
where itemnumber=$itemnum";
my $sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
# FIXME - This is identical to &C4::Biblio::countitems.
# Pick one and stick with it.
# XXX - POD
sub countitems{
my ($bibitemnum)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select count(*) from items where biblioitemnumber='$bibitemnum'";
my $sth=$dbh->prepare($query);
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
return($data->{'count(*)'});
}
# FIXME - This function appears in C4::Catalogue. Neither one is used.
sub findall {
my ($biblionumber)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from biblioitems,items,itemtypes where
biblioitems.biblionumber=$biblionumber
and biblioitems.biblioitemnumber=items.biblioitemnumber and
@ -1539,14 +1522,13 @@ sub findall {
$i++;
}
$sth->finish;
$dbh->disconnect;
return(@results);
}
# FIXME - This function appears in C4::Catalogue. Neither one is used
sub needsmod{
my ($bibitemnum,$itemtype)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from biblioitems where biblioitemnumber=$bibitemnum
and itemtype='$itemtype'";
my $sth=$dbh->prepare($query);
@ -1556,15 +1538,15 @@ sub needsmod{
$result=1;
}
$sth->finish;
$dbh->disconnect;
return($result);
}
# FIXME - A nearly-identical function, appears in C4::Biblio
# Pick one and stick with it.
# XXX - POD
sub delitem{
my ($itemnum)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="select * from items where itemnumber=$itemnum";
my $sth=$dbh->prepare($query);
$sth->execute;
@ -1583,13 +1565,14 @@ sub delitem{
$sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
# FIXME - This is functionally identical to &C4::Biblio::deletebiblioitem.
# Pick one and stick with it.
# XXX - POD
sub deletebiblioitem {
my ($biblioitemnumber) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $query = "Select * from biblioitems
where biblioitemnumber = $biblioitemnumber";
my $sth = $dbh->prepare($query);
@ -1639,13 +1622,14 @@ where biblioitemnumber = $biblioitemnumber";
$query = "Delete from items where biblioitemnumber = $biblioitemnumber";
$dbh->do($query);
$dbh->disconnect;
} # sub deletebiblioitem
# FIXME - This is functionally identical to &C4::Biblio::delbiblio.
# Pick one and stick with it.
# XXX - POD
sub delbiblio{
my ($biblio)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="select * from biblio where biblionumber=$biblio";
my $sth=$dbh->prepare($query);
$sth->execute;
@ -1668,12 +1652,11 @@ sub delbiblio{
}
$sth->finish;
$dbh->disconnect;
}
# XXX - POD
sub getitemtypes {
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $query = "select * from itemtypes";
my $sth = $dbh->prepare($query);
# || die "Cannot prepare $query" . $dbh->errstr;
@ -1688,14 +1671,15 @@ sub getitemtypes {
} # while
$sth->finish;
$dbh->disconnect;
return($count, @results);
} # sub getitemtypes
# FIXME - This is identical to &C4::Biblio::getitemtypes.
# Pick one and stick with it.
# XXX - POD
sub getbiblio {
my ($biblionumber) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $query = "Select * from biblio where biblionumber = $biblionumber";
my $sth = $dbh->prepare($query);
# || die "Cannot prepare $query\n" . $dbh->errstr;
@ -1710,14 +1694,13 @@ sub getbiblio {
} # while
$sth->finish;
$dbh->disconnect;
return($count, @results);
} # sub getbiblio
# XXX - POD
sub getbiblioitem {
my ($biblioitemnum) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $query = "Select * from biblioitems where
biblioitemnumber = $biblioitemnum";
my $sth = $dbh->prepare($query);
@ -1732,14 +1715,15 @@ biblioitemnumber = $biblioitemnum";
} # while
$sth->finish;
$dbh->disconnect;
return($count, @results);
} # sub getbiblioitem
# FIXME - This is identical to &C4::Biblio::getbiblioitem.
# Pick one and stick with it.
# XXX - POD
sub getbiblioitembybiblionumber {
my ($biblionumber) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $query = "Select * from biblioitems where biblionumber =
$biblionumber";
my $sth = $dbh->prepare($query);
@ -1754,14 +1738,16 @@ $biblionumber";
} # while
$sth->finish;
$dbh->disconnect;
return($count, @results);
} # sub
# FIXME - This is identical to
# &C4::Biblio::getbiblioitembybiblionumber.
# Pick one and stick with it.
# XXX - POD
sub getitemsbybiblioitem {
my ($biblioitemnum) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $query = "Select * from items, biblio where
biblio.biblionumber = items.biblionumber and biblioitemnumber
= $biblioitemnum";
@ -1778,14 +1764,15 @@ biblio.biblionumber = items.biblionumber and biblioitemnumber
} # while
$sth->finish;
$dbh->disconnect;
return($count, @results);
} # sub getitemsbybiblioitem
# FIXME - This is identical to &C4::Biblio::isbnsearch.
# Pick one and stick with it.
# XXX - POD
sub isbnsearch {
my ($isbn) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $count = 0;
my $query;
my $sth;
@ -1804,7 +1791,6 @@ and isbn = $isbn";
} # while
$sth->finish;
$dbh->disconnect;
return($count, @results);
} # sub isbnsearch
@ -1827,7 +1813,7 @@ and biblioitems tables in the Koha database.
# FIXME - This function appears in C4::Catalogue
sub websitesearch {
my ($keywordlist) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $query = "Select distinct biblio.* from biblio, biblioitems where
biblio.biblionumber = biblioitems.biblionumber and (";
my $count = 0;
@ -1860,7 +1846,6 @@ biblio.biblionumber = biblioitems.biblionumber and (";
} # while
$sth->finish;
$dbh->disconnect;
return($count, @results);
} # sub websitesearch
@ -1877,7 +1862,7 @@ are mandatory.
# FIXME - This function appears in C4::Catalogue
sub addwebsite {
my ($website) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $query;
$website->{'biblionumber'} = $dbh->quote($website->{'biblionumber'});
@ -1892,8 +1877,6 @@ description = $website->{'description'},
url = $website->{'url'}";
$dbh->do($query);
$dbh->disconnect;
} # sub website
=item updatewebsite
@ -1910,7 +1893,7 @@ the entry to update.
# FIXME - This function appears in C4::Catalogue
sub updatewebsite {
my ($website) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $query;
$website->{'title'} = $dbh->quote($website->{'title'});
@ -1924,8 +1907,6 @@ url = $website->{'url'}
where websitenumber = $website->{'websitenumber'}";
$dbh->do($query);
$dbh->disconnect;
} # sub updatewebsite
=item deletewebsite
@ -1939,12 +1920,14 @@ Deletes the web site with number C<$websitenumber>.
# FIXME - This function appears in C4::Catalogue
sub deletewebsite {
my ($websitenumber) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
# FIXME - $query is unnecessary: just use
# $dbh->do(<<EOT);
# DELETE FROM websites where websitenumber=$websitenumber
# EOT
my $query = "Delete from websites where websitenumber = $websitenumber";
$dbh->do($query);
$dbh->disconnect;
} # sub deletewebsite

View File

@ -23,7 +23,7 @@ use Digest::MD5 qw(md5_base64);
require Exporter;
use C4::Database;
use C4::Context;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
@ -51,7 +51,7 @@ sub checkauth {
my $sessionID=$query->cookie('sessionID');
my $message='';
my $dbh=C4Connect();
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("select userid,ip,lasttime from sessions where sessionid=?");
$sth->execute($sessionID);
if ($sth->rows) {
@ -189,6 +189,7 @@ sub checkpw {
return 1;
}
}
# FIXME - There's already a $sth in this scope.
my $sth=$dbh->prepare("select password from borrowers where cardnumber=?");
$sth->execute($userid);
if ($sth->rows) {

View File

@ -1,6 +1,10 @@
package C4::Biblio;
# $Id$
# $Log$
# Revision 1.15 2002/10/05 09:49:25 arensb
# Merged with arensb-context branch: use C4::Context->dbh instead of
# &C4Connect, and generally prefer C4::Context over C4::Database.
#
# Revision 1.14 2002/10/03 11:28:18 tipaul
# Extending Context.pm to add stopword management and using it in MARC-API.
# First benchmarks show a medium speed improvement, which is nice as this part is heavily called.
@ -8,6 +12,29 @@ package C4::Biblio;
# Revision 1.13 2002/10/02 16:26:44 tipaul
# road to 1.3.1
#
# Revision 1.12.2.4 2002/10/05 07:09:31 arensb
# Merged in changes from main branch.
#
# Revision 1.12.2.3 2002/10/05 06:12:10 arensb
# Added a whole mess of FIXME comments.
#
# Revision 1.12.2.2 2002/10/05 04:03:14 arensb
# Added some missing semicolons.
#
# Revision 1.12.2.1 2002/10/04 02:24:01 arensb
# Use C4::Connect instead of C4::Database, C4::Connect->dbh instead
# C4Connect.
#
# Revision 1.12.2.3 2002/10/05 06:12:10 arensb
# Added a whole mess of FIXME comments.
#
# Revision 1.12.2.2 2002/10/05 04:03:14 arensb
# Added some missing semicolons.
#
# Revision 1.12.2.1 2002/10/04 02:24:01 arensb
# Use C4::Connect instead of C4::Database, C4::Connect->dbh instead
# C4Connect.
#
# Revision 1.12 2002/10/01 11:48:51 arensb
# Added some FIXME comments, mostly marking duplicate functions.
#
@ -106,6 +133,7 @@ package C4::Biblio;
use strict;
require Exporter;
use C4::Context;
use C4::Database;
use MARC::Record;
@ -153,7 +181,7 @@ $VERSION = 0.01;
# your exported package globals go here,
# as well as any optionally exported functions
@EXPORT_OK = qw($Var1 %Hashit);
@EXPORT_OK = qw($Var1 %Hashit); # FIXME - These are never used
#
#
@ -240,7 +268,7 @@ $VERSION = 0.01;
=head1 AUTHOR
Paul POULAIN paul.poulain@free.fr
/
=cut
sub MARCgettagslib {
@ -451,6 +479,7 @@ sub MARCgetitem {
from marc_subfield_table
where bibid=? and tagorder=? order by subfieldorder
");
# FIXME - There's already a $sth2 in this scope.
my $sth2=$dbh->prepare("select subfieldvalue from marc_blob_subfield where blobidlink=?");
$sth->execute($bibid,$tagorder);
while (my $row=$sth->fetchrow_hashref) {
@ -758,14 +787,18 @@ sub MARCmarc2koha {
while (($field)=$sth2->fetchrow) {
$result=&MARCmarc2kohaOneField($sth,"biblio",$field,$record,$result);
}
# FIXME - There's already a $sth2 in this scope.
my $sth2=$dbh->prepare("SHOW COLUMNS from biblioitems");
$sth2->execute;
# FIXME - There's already a $field in this scope.
my $field;
while (($field)=$sth2->fetchrow) {
$result=&MARCmarc2kohaOneField($sth,"biblioitems",$field,$record,$result);
}
# FIXME - There's already a $sth2 in this scope.
my $sth2=$dbh->prepare("SHOW COLUMNS from items");
$sth2->execute;
# FIXME - There's already a $field in this scope.
my $field;
while (($field)=$sth2->fetchrow) {
$result = &MARCmarc2kohaOneField($sth,"items",$field,$record,$result);
@ -1086,7 +1119,6 @@ where biblionumber = $biblio->{'biblionumber'}";
$sth->execute;
$sth->finish;
$dbh->disconnect;
return($biblio->{'biblionumber'});
} # sub modbiblio
@ -1123,8 +1155,6 @@ sub OLDmodaddauthor {
$sth->finish;
} # if
$dbh->disconnect;
} # sub modaddauthor
@ -1522,22 +1552,22 @@ sub OLDdelbiblio{
# FIXME - This is the same as &C4::Acquisitions::itemcount, but not
# the same as &C4::Search::itemcount
# Since they're both exported, acqui/acquire.pl doesn't compile with -w.
sub itemcount{
my ($biblio)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select count(*) from items where biblionumber=$biblio";
# print $query;
my $sth=$dbh->prepare($query);
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
return($data->{'count(*)'});
}
sub getorder{
my ($bi,$bib)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select ordernumber
from aqorders
where biblionumber=? and biblioitemnumber=?";
@ -1546,7 +1576,6 @@ sub getorder{
my $ordnum=$sth->fetchrow_hashref;
$sth->finish;
my $order=getsingleorder($ordnum->{'ordernumber'});
$dbh->disconnect;
# print $query;
return ($order,$ordnum->{'ordernumber'});
}
@ -1555,7 +1584,7 @@ sub getorder{
# &C4::Acquisitions::getsingleorder and &C4::Catalogue::getsingleorder
sub getsingleorder {
my ($ordnum)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from biblio,biblioitems,aqorders,aqorderbreakdown
where aqorders.ordernumber=?
and biblio.biblionumber=aqorders.biblionumber and
@ -1565,73 +1594,80 @@ sub getsingleorder {
$sth->execute($ordnum);
my $data=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
return($data);
}
# FIXME - This is in effect identical to &C4::Acquisitions::newbiblio.
# Pick one and stick with it.
sub newbiblio {
my ($biblio) = @_;
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $bibnum=OLDnewbiblio($dbh,$biblio);
# TODO : MARC add
$dbh->disconnect;
return($bibnum);
}
# FIXME - This is in effect the same as &C4::Acquisitions::modbiblio.
# Pick one and stick with it.
sub modbiblio {
my ($biblio) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $biblionumber=OLDmodbiblio($dbh,$biblio);
$dbh->disconnect;
return($biblionumber);
} # sub modbiblio
# FIXME - This is in effect identical to &C4::Acquisitions::modsubtitle.
# Pick one and stick with it.
sub modsubtitle {
my ($bibnum, $subtitle) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
&OLDmodsubtitle($dbh,$bibnum,$subtitle);
$dbh->disconnect;
} # sub modsubtitle
# FIXME - This is functionally identical to
# &C4::Acquisitions::modaddauthor
# Pick one and stick with it.
sub modaddauthor {
my ($bibnum, $author) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
&OLDmodaddauthor($dbh,$bibnum,$author);
$dbh->disconnect;
} # sub modaddauthor
# FIXME - This is in effect identical to &C4::Acquisitions::modsubject.
# Pick one and stick with it.
sub modsubject {
my ($bibnum, $force, @subject) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $error= &OLDmodsubject($dbh,$bibnum,$force, @subject);
return($error);
} # sub modsubject
# FIXME - This is very similar to &C4::Acquisitions::modbibitem.
# Pick one and stick with it.
sub modbibitem {
my ($biblioitem) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
&OLDmodbibitem($dbh,$biblioitem);
my $MARCbibitem = MARCkoha2marcBiblio($dbh,$biblioitem);
&MARCmodbiblio($dbh,$biblioitem->{biblionumber},0,$MARCbibitem);
$dbh->disconnect;
} # sub modbibitem
# FIXME - This is in effect identical to &C4::Acquisitions::modnote.
# Pick one and stick with it.
sub modnote {
my ($bibitemnum,$note)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
&OLDmodnote($dbh,$bibitemnum,$note);
$dbh->disconnect;
}
# FIXME - This is quite similar in effect to &C4::newbiblioitem,
# except for the MARC stuff.
# except for the MARC stuff. There's also a &newbiblioitem in
# acqui.simple/addbookslccn.pl
sub newbiblioitem {
my ($biblioitem) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $bibitemnum = &OLDnewbiblioitem($dbh,$biblioitem);
# print STDERR "bibitemnum : $bibitemnum\n";
my $MARCbiblio= MARCkoha2marcBiblio($dbh,$biblioitem->{biblionumber},$bibitemnum);
@ -1640,25 +1676,27 @@ sub newbiblioitem {
return($bibitemnum);
}
# FIXME - This is in effect identical to &C4::Acquisitions::newsubject.
# Pick one and stick with it.
sub newsubject {
my ($bibnum)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
&OLDnewsubject($dbh,$bibnum);
$dbh->disconnect;
}
# FIXME - This is just a wrapper around &OLDnewsubtitle
# FIXME - This is in effect the same as &C4::Acquisitions::newsubtitle
sub newsubtitle {
my ($bibnum, $subtitle) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
&OLDnewsubtitle($dbh,$bibnum,$subtitle);
$dbh->disconnect;
}
# FIXME - This is different from &C4::Acquisitions::newitems, though
# both are exported.
sub newitems {
my ($item, @barcodes) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $errors;
my $itemnumber;
my $error;
@ -1671,14 +1709,16 @@ sub newitems {
&MARCadditem($dbh,$MARCitem,$item->{biblionumber});
# print STDERR "MARCmodbiblio called\n";
}
$dbh->disconnect;
return($errors);
}
# FIXME - This appears to be functionally equivalent to
# &C4::Acquisitions::moditem.
# Pick one and stick with it.
sub moditem {
my ($item) = @_;
# my ($loan,$itemnum,$bibitemnum,$barcode,$notes,$homebranch,$lost,$wthdrawn,$replacement)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
&OLDmoditem($dbh,$item);
warn "biblionumber : $item->{'biblionumber'} / $item->{'itemnum'}\n";
my $MARCitem = &MARCkoha2marcItem($dbh,$item->{'biblionumber'},$item->{'itemnum'});
@ -1687,12 +1727,13 @@ sub moditem {
# print STDERR "MARCitem ".$MARCitem->as_formatted()."\n";
my $bibid = &MARCfind_MARCbibid_from_oldbiblionumber($dbh,$item->{biblionumber});
&MARCmoditem($dbh,$MARCitem,$bibid,$item->{itemnum},0);
$dbh->disconnect;
}
# FIXME - This is the same as &C4::Acquisitions::Checkitems.
# Pick one and stick with it.
sub checkitems{
my ($count,@barcodes)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $error;
for (my $i=0;$i<$count;$i++){
$barcodes[$i]=uc $barcodes[$i];
@ -1704,48 +1745,53 @@ sub checkitems{
}
$sth->finish;
}
$dbh->disconnect;
return($error);
}
# FIXME - This is identical to &C4::Acquisitions::countitems.
# Pick one and stick with it.
sub countitems{
my ($bibitemnum)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select count(*) from items where biblioitemnumber='$bibitemnum'";
my $sth=$dbh->prepare($query);
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
return($data->{'count(*)'});
}
# FIXME - This is just a wrapper around &OLDdelitem, and acts
# identically to &C4::Acquisitions::delitem
# Pick one and stick with it.
sub delitem{
my ($itemnum)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
&OLDdelitem($dbh,$itemnum);
$dbh->disconnect;
}
# FIXME - This is functionally identical to
# &C4::Acquisitions::deletebiblioitem.
# Pick one and stick with it.
sub deletebiblioitem {
my ($biblioitemnumber) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
&OLDdeletebiblioitem($dbh,$biblioitemnumber);
$dbh->disconnect;
} # sub deletebiblioitem
# FIXME - This is functionally identical to &C4::Acquisitions::delbiblio.
# Pick one and stick with it.
sub delbiblio {
my ($biblio)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
&OLDdelbiblio($dbh,$biblio);
$dbh->disconnect;
}
# FIXME - This is identical to &C4::Acquisitions::getitemtypes.
# Pick one and stick with it.
sub getitemtypes {
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $query = "select * from itemtypes";
my $sth = $dbh->prepare($query);
# || die "Cannot prepare $query" . $dbh->errstr;
@ -1760,13 +1806,12 @@ sub getitemtypes {
} # while
$sth->finish;
$dbh->disconnect;
return($count, @results);
} # sub getitemtypes
sub getbiblio {
my ($biblionumber) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $query = "Select * from biblio where biblionumber = $biblionumber";
my $sth = $dbh->prepare($query);
# || die "Cannot prepare $query\n" . $dbh->errstr;
@ -1781,13 +1826,14 @@ sub getbiblio {
} # while
$sth->finish;
$dbh->disconnect;
return($count, @results);
} # sub getbiblio
# FIXME - This is identical to &C4::Acquisitions::getbiblioitem.
# Pick one and stick with it.
sub getbiblioitem {
my ($biblioitemnum) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $query = "Select * from biblioitems where
biblioitemnumber = $biblioitemnum";
my $sth = $dbh->prepare($query);
@ -1802,13 +1848,15 @@ biblioitemnumber = $biblioitemnum";
} # while
$sth->finish;
$dbh->disconnect;
return($count, @results);
} # sub getbiblioitem
# FIXME - This is identical to
# &C4::Acquisitions::getbiblioitembybiblionumber.
# Pick one and stick with it.
sub getbiblioitembybiblionumber {
my ($biblionumber) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $query = "Select * from biblioitems where biblionumber =
$biblionumber";
my $sth = $dbh->prepare($query);
@ -1823,13 +1871,15 @@ $biblionumber";
} # while
$sth->finish;
$dbh->disconnect;
return($count, @results);
} # sub
# FIXME - This is identical to
# &C4::Acquisitions::getbiblioitembybiblionumber.
# Pick one and stick with it.
sub getitemsbybiblioitem {
my ($biblioitemnum) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $query = "Select * from items, biblio where
biblio.biblionumber = items.biblionumber and biblioitemnumber
= $biblioitemnum";
@ -1846,13 +1896,14 @@ biblio.biblionumber = items.biblionumber and biblioitemnumber
} # while
$sth->finish;
$dbh->disconnect;
return($count, @results);
} # sub getitemsbybiblioitem
# FIXME - This is identical to &C4::Acquisitions::isbnsearch.
# Pick one and stick with it.
sub isbnsearch {
my ($isbn) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $count = 0;
my $query;
my $sth;
@ -1871,7 +1922,6 @@ and isbn = $isbn";
} # while
$sth->finish;
$dbh->disconnect;
return($count, @results);
} # sub isbnsearch
@ -2000,7 +2050,7 @@ sub getoraddbiblio {
sub OLD_MAYBE_DELETED_newBiblioItem {
my ($env, $biblioitem) = @_;
my $dbh=&C4Connect;
my $dbh = C4::Context->dbh;
my $biblionumber=$biblioitem->{'biblionumber'};
my $biblioitemnumber=$biblioitem->{'biblioitemnumber'};
my $volume=$biblioitem->{'volume'};
@ -2254,13 +2304,12 @@ sub OLD_MAYBE_DELETED_newBiblioItem {
addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
}
$sth->finish;
$dbh->disconnect;
return ($env, $Record_ID);
}
sub OLD_MAYBE_DELETED_newItem {
my ($env, $Record_ID, $item) = @_;
my $dbh=&C4Connect;
my $dbh = C4::Context->dbh;
my $barcode=$item->{'barcode'};
my $q_barcode=$dbh->quote($barcode);
my $biblionumber=$item->{'biblionumber'};
@ -2363,7 +2412,7 @@ sub OLD_MAYBE_DELETED_updateBiblio {
my ($env, $biblio) = @_;
my $Record_ID;
my $biblionumber=$biblio->{'biblionumber'};
my $dbh=&C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("select * from biblio where biblionumber=$biblionumber");
$sth->execute;
my $origbiblio=$sth->fetchrow_hashref;
@ -2511,7 +2560,7 @@ sub OLD_MAYBE_DELETED_updateBiblioItem {
# modified, and log all changes.
my ($env, $biblioitem) = @_;
my $dbh=&C4Connect;
my $dbh = C4::Context->dbh;
my $biblioitemnumber=$biblioitem->{'biblioitemnumber'};
my $sth=$dbh->prepare("select * from biblioitems where biblioitemnumber=$biblioitemnumber");
@ -2631,8 +2680,6 @@ sub OLD_MAYBE_DELETED_updateBiblioItem {
changeSubfield($Record_ID, '010', 'a', $obi->{'lccn'}, $biblioitem->{'lccn'});
}
$sth->finish;
$dbh->disconnect;
}
sub OLD_MAYBE_DELETED_updateItem {
@ -2644,7 +2691,7 @@ sub OLD_MAYBE_DELETED_updateItem {
# modified, and log all changes.
my ($env, $item) = @_;
my $dbh=&C4Connect;
my $dbh = C4::Context->dbh;
my $itemnumber=$item->{'itemnumber'};
my $biblionumber=$item->{'biblionumber'};
my $biblioitemnumber=$item->{'biblioitemnumber'};
@ -2785,7 +2832,6 @@ sub OLD_MAYBE_DELETED_updateItem {
}
}
$sth->finish;
$dbh->disconnect;
}
# Add a biblioitem and related data to Koha database

View File

@ -26,7 +26,7 @@ package C4::BookShelves; #assumes C4/BookShelves
use strict;
require Exporter;
use DBI;
use C4::Database;
use C4::Context;
use C4::Circulation::Circ2;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
@ -93,7 +93,7 @@ my $priv_func = sub {
# make all your functions, whether exported or not;
my $dbh=C4Connect();
my $dbh = C4::Context->dbh;
=item GetShelfList
@ -280,6 +280,14 @@ END { } # module clean-up code here (global destructor)
#
# $Log$
# Revision 1.7 2002/10/05 09:50:10 arensb
# Merged with arensb-context branch: use C4::Context->dbh instead of
# &C4Connect, and generally prefer C4::Context over C4::Database.
#
# Revision 1.6.2.1 2002/10/04 02:24:43 arensb
# Use C4::Connect instead of C4::Database, C4::Connect->dbh instead
# C4Connect.
#
# Revision 1.6 2002/09/23 13:50:30 arensb
# Fixed missing bit in POD.
#

View File

@ -29,7 +29,7 @@ package C4::Catalogue; #assumes C4/Acquisitions.pm
use strict;
require Exporter;
use C4::Database;
use C4::Context;
use MARC::Record;
use C4::Biblio;
@ -137,7 +137,7 @@ number of elements in C<@orders>.
#'
sub basket {
my ($basketno,$supplier)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select *,biblio.title from aqorders,biblio,biblioitems
where basketno='$basketno'
and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber
@ -158,7 +158,6 @@ sub basket {
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,@results);
}
@ -181,7 +180,7 @@ database, and returns it.
# see which basket number it gets. Then have a cron job periodically
# remove out-of-date dummy orders.
sub newbasket {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select max(basketno) from aqorders";
my $sth=$dbh->prepare($query);
$sth->execute;
@ -189,7 +188,6 @@ sub newbasket {
my $basket=$$data[0];
$basket++;
$sth->finish;
$dbh->disconnect;
return($basket);
}
@ -228,7 +226,7 @@ sub neworder {
} else {
$sub=0;
}
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="insert into aqorders (biblionumber,title,basketno,
quantity,listprice,booksellerid,entrydate,requisitionedby,authorisedby,notes,
biblioitemnumber,rrp,ecost,gst,unitprice,subscription,booksellerinvoicenumber)
@ -254,7 +252,6 @@ sub neworder {
# print $query;
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
=item delorder
@ -273,7 +270,7 @@ marc_biblio tables of the Koha database.
#'
sub delorder {
my ($bibnum,$ordnum)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="update aqorders set datecancellationprinted=now()
where biblionumber='$bibnum' and
ordernumber='$ordnum'";
@ -286,7 +283,6 @@ sub delorder {
delbiblio($bibnum); # This is C4::Biblio::delbiblio, not
# C4::Acquisitions::delbiblio
}
$dbh->disconnect;
}
=item modorder
@ -309,7 +305,7 @@ table are also updated to the new book fund ID.
# FIXME - This function appears in C4::Acquisitions
sub modorder {
my ($title,$ordnum,$quantity,$listprice,$bibnum,$basketno,$supplier,$who,$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst,$budget,$cost,$invoice)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="update aqorders set title='$title',
quantity='$quantity',listprice='$listprice',basketno='$basketno',
rrp='$rrp',ecost='$ecost',unitprice='$cost',
@ -326,7 +322,6 @@ sub modorder {
# print $query;
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
=item newordernum
@ -340,7 +335,7 @@ database, and returns it.
#'
# FIXME - Race condition
sub newordernum {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select max(ordernumber) from aqorders";
my $sth=$dbh->prepare($query);
$sth->execute;
@ -348,7 +343,6 @@ sub newordernum {
my $ordnum=$$data[0];
$ordnum++;
$sth->finish;
$dbh->disconnect;
return($ordnum);
}
@ -371,7 +365,7 @@ Also updates the book fund ID in the aqorderbreakdown table.
#'
sub receiveorder {
my ($biblio,$ordnum,$quantrec,$user,$cost,$invoiceno,$bibitemno,$freight,$bookfund,$rrp)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="update aqorders set quantityreceived='$quantrec',
datereceived=now(),booksellerinvoicenumber='$invoiceno',
biblioitemnumber=$bibitemno,unitprice='$cost',freight='$freight',
@ -388,7 +382,6 @@ sub receiveorder {
# print $query;
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
=item updaterecorder
@ -407,7 +400,7 @@ C<$user> is ignored.
#'
sub updaterecorder{
my($biblio,$ordnum,$user,$cost,$bookfund,$rrp)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="update aqorders set
unitprice='$cost', rrp='$rrp'
where biblionumber=$biblio and ordernumber=$ordnum
@ -422,7 +415,6 @@ sub updaterecorder{
# print $query;
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
#
@ -466,7 +458,7 @@ Results are ordered from most to least recent.
#'
sub getorders {
my ($supplierid)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query = "Select count(*),authorisedby,entrydate,basketno from aqorders where
booksellerid='$supplierid' and (quantity > quantityreceived or
quantityreceived is NULL)
@ -482,7 +474,6 @@ sub getorders {
$i++;
}
$sth->finish;
$dbh->disconnect;
return ($i,\@results);
}
@ -501,7 +492,7 @@ tables of the Koha database.
#'
sub getorder{
my ($bi,$bib)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select ordernumber from aqorders where biblionumber=$bib and
biblioitemnumber='$bi'";
my $sth=$dbh->prepare($query);
@ -511,7 +502,6 @@ sub getorder{
my $ordnum=$sth->fetchrow_hashref;
$sth->finish;
my $order=getsingleorder($ordnum->{'ordernumber'});
$dbh->disconnect;
# print $query;
return ($order,$ordnum->{'ordernumber'});
}
@ -533,7 +523,7 @@ aqorderbreakdown tables of the Koha database.
# the other one.
sub getsingleorder {
my ($ordnum)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from biblio,biblioitems,aqorders,aqorderbreakdown
where aqorders.ordernumber='$ordnum'
and biblio.biblionumber=aqorders.biblionumber and
@ -543,7 +533,6 @@ sub getsingleorder {
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
return($data);
}
@ -565,7 +554,7 @@ C<@results> is sorted alphabetically by book title.
sub getallorders {
#gets all orders from a certain supplier, orders them alphabetically
my ($supid)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from aqorders,biblio,biblioitems where booksellerid='$supid'
and (cancelledby is NULL or cancelledby = '')
and (quantityreceived < quantity or quantityreceived is NULL)
@ -583,7 +572,6 @@ sub getallorders {
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,@results);
}
@ -591,7 +579,7 @@ sub getallorders {
sub getrecorders {
#gets all orders from a certain supplier, orders them alphabetically
my ($supid)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from aqorders,biblio,biblioitems where booksellerid='$supid'
and (cancelledby is NULL or cancelledby = '')
and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber=
@ -610,7 +598,6 @@ sub getrecorders {
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,@results);
}
@ -651,7 +638,7 @@ following keys:
#'
sub ordersearch {
my ($search,$biblio,$catview) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $query = "Select *,biblio.title from aqorders,biblioitems,biblio
where aqorders.biblioitemnumber = biblioitems.biblioitemnumber
and biblio.biblionumber=aqorders.biblionumber
@ -695,7 +682,6 @@ and ((";
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,@results);
}
@ -719,7 +705,7 @@ of the Koha database.
#'
sub invoice {
my ($invoice)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from aqorders,biblio,biblioitems where
booksellerinvoicenumber='$invoice'
and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber=
@ -733,7 +719,6 @@ sub invoice {
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,@results);
}
@ -751,7 +736,7 @@ alphabetically by book fund name.
=cut
#'
sub bookfunds {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from aqbookfund,aqbudget where aqbookfund.bookfundid
=aqbudget.bookfundid
group by aqbookfund.bookfundid order by bookfundname";
@ -764,7 +749,6 @@ sub bookfunds {
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,@results);
}
@ -772,7 +756,7 @@ sub bookfunds {
# again, I don't think it's being used (anymore).
sub bookfundbreakdown {
my ($id)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select quantity,datereceived,freight,unitprice,listprice,ecost,quantityreceived,subscription
from aqorders,aqorderbreakdown where bookfundid='$id' and
aqorders.ordernumber=aqorderbreakdown.ordernumber
@ -792,7 +776,6 @@ sub bookfundbreakdown {
}
}
$sth->finish;
$dbh->disconnect;
return($spent,$comtd);
}
@ -810,19 +793,17 @@ to one.
#'
sub curconvert {
my ($currency,$price)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select rate from currency where currency='$currency'";
my $sth=$dbh->prepare($query);
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
my $cur=$data->{'rate'};
if ($cur==0){
$cur=1;
}
my $price=$price / $cur;
return($price);
return($price / $cur);
}
=item getcurrencies
@ -838,7 +819,7 @@ keys are the fields from the currency table in the Koha database.
=cut
#'
sub getcurrencies {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from currency";
my $sth=$dbh->prepare($query);
$sth->execute;
@ -849,21 +830,19 @@ sub getcurrencies {
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,\@results);
}
# FIXME - Never used
sub getcurrency {
my ($cur)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from currency where currency='$cur'";
my $sth=$dbh->prepare($query);
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
return($data);
}
@ -877,25 +856,23 @@ Sets the exchange rate for C<$currency> to be C<$newrate>.
#'
sub updatecurrencies {
my ($currency,$rate)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="update currency set rate=$rate where currency='$currency'";
my $sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
# FIXME - Identical to &C4::Acquisitions::updatecost. Neither one is
# used
sub updatecost{
my($price,$rrp,$itemnum)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="update items set price='$price',replacementprice='$rrp'
where itemnumber=$itemnum";
my $sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
#
@ -919,7 +896,7 @@ aqbooksellers table in the Koha database.
#'
sub bookseller {
my ($searchstring)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from aqbooksellers where name like '%$searchstring%' or
id = '$searchstring'";
my $sth=$dbh->prepare($query);
@ -931,7 +908,6 @@ sub bookseller {
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,@results);
}
@ -949,7 +925,7 @@ are the fields of the aqorderbreakdown table in the Koha database.
#'
sub breakdown {
my ($id)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from aqorderbreakdown where ordernumber='$id'";
my $sth=$dbh->prepare($query);
$sth->execute;
@ -960,7 +936,6 @@ sub breakdown {
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,\@results);
}
@ -977,7 +952,7 @@ table of the Koha database.
=cut
#'
sub branches {
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $query = "Select * from branches";
my $sth = $dbh->prepare($query);
my $i = 0;
@ -990,14 +965,13 @@ sub branches {
} # while
$sth->finish;
$dbh->disconnect;
return($i, @results);
} # sub branches
# FIXME - Never used
sub findall {
my ($biblionumber)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from biblioitems,items,itemtypes where
biblioitems.biblionumber=$biblionumber
and biblioitems.biblioitemnumber=items.biblioitemnumber and
@ -1012,14 +986,13 @@ sub findall {
$i++;
}
$sth->finish;
$dbh->disconnect;
return(@results);
}
# FIXME - Never used
sub needsmod{
my ($bibitemnum,$itemtype)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from biblioitems where biblioitemnumber=$bibitemnum
and itemtype='$itemtype'";
my $sth=$dbh->prepare($query);
@ -1029,7 +1002,6 @@ sub needsmod{
$result=1;
}
$sth->finish;
$dbh->disconnect;
return($result);
}
@ -1050,7 +1022,7 @@ C<&updatesup> with the result.
#'
sub updatesup {
my ($data)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Update aqbooksellers set
name='$data->{'name'}',address1='$data->{'address1'}',address2='$data->{'address2'}',
address3='$data->{'address3'}',address4='$data->{'address4'}',postal='$data->{'postal'}',
@ -1068,7 +1040,6 @@ sub updatesup {
my $sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
$dbh->disconnect;
# print $query;
}
@ -1086,7 +1057,7 @@ Returns the ID of the newly-created bookseller.
#'
sub insertsup {
my ($data)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("Select max(id) from aqbooksellers");
$sth->execute;
my $data2=$sth->fetchrow_hashref;
@ -1096,7 +1067,6 @@ sub insertsup {
$sth->execute;
$sth->finish;
$data->{'id'}=$data2->{'max(id)'};
$dbh->disconnect;
updatesup($data);
return($data->{'id'});
}
@ -1119,7 +1089,7 @@ and biblioitems tables in the Koha database.
#'
sub websitesearch {
my ($keywordlist) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $query = "Select distinct biblio.* from biblio, biblioitems where
biblio.biblionumber = biblioitems.biblionumber and (";
my $count = 0;
@ -1156,7 +1126,6 @@ biblio.biblionumber = biblioitems.biblionumber and (";
} # while
$sth->finish;
$dbh->disconnect;
return($count, @results);
} # sub websitesearch
@ -1172,7 +1141,7 @@ are mandatory.
#'
sub addwebsite {
my ($website) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $query;
# FIXME -
@ -1194,8 +1163,6 @@ description = $website->{'description'},
url = $website->{'url'}";
$dbh->do($query);
$dbh->disconnect;
} # sub website
=item updatewebsite
@ -1211,7 +1178,7 @@ the entry to update.
#'
sub updatewebsite {
my ($website) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $query;
$website->{'title'} = $dbh->quote($website->{'title'});
@ -1225,8 +1192,6 @@ url = $website->{'url'}
where websitenumber = $website->{'websitenumber'}";
$dbh->do($query);
$dbh->disconnect;
} # sub updatewebsite
=item deletewebsite
@ -1239,12 +1204,11 @@ Deletes the web site with number C<$websitenumber>.
#'
sub deletewebsite {
my ($websitenumber) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
# FIXME - $query is unneeded
my $query = "Delete from websites where websitenumber = $websitenumber";
$dbh->do($query);
$dbh->disconnect;
} # sub deletewebsite
END { } # module clean-up code here (global destructor)

View File

@ -20,10 +20,11 @@ package C4::Circmain; #assumes C4/Circulation
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
# FIXME - This module doesn't compile!
use strict;
require Exporter;
use DBI;
use C4::Database;
use C4::Circulation::Main;
use C4::Circulation::Issues;
use C4::Circulation::Returns;

View File

@ -23,7 +23,6 @@ package C4::Circulation; #assumes C4/Circulation
use strict;
require Exporter;
use DBI;
use C4::Database;
use C4::Circulation::Issues;
use C4::Circulation::Returns;
use C4::Circulation::Renewals;

View File

@ -24,7 +24,7 @@ package C4::Circulation::Borrissues; #assumes C4/Circulation/Borrissues
use strict;
require Exporter;
use DBI;
use C4::Database;
use C4::Context;
use C4::Print;
use C4::Format;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
@ -73,7 +73,7 @@ my $priv_func = sub {
sub printallissues {
my ($env,$borrower)=@_;
my @issues;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query = "select * from issues,items,biblioitems,biblio
where borrowernumber = '$borrower->{'borrowernumber'}'
and (returndate is null)
@ -85,11 +85,12 @@ sub printallissues {
$sth->execute();
my $x;
while (my $data = $sth->fetchrow_hashref) {
# FIXME - This should be $issues[$x] = $data, right?
# Or better yet, push @issues, $data.
@issues[$x] =$data;
$x++;
}
$sth->finish();
$dbh->disconnect();
remoteprint ($env,\@issues,$borrower);
}
END { } # module clean-up code here (global destructor)

View File

@ -24,12 +24,16 @@ package C4::Circulation::Borrower; #assumes C4/Circulation/Borrower
use strict;
require Exporter;
use DBI;
use C4::Database;
use C4::Context;
use C4::Accounts;
use C4::InterfaceCDK;
use C4::Interface::FlagsCDK;
use C4::Circulation::Main;
# FIXME - C4::Circulation::Main and C4::Circulation::Borrower
# use each other, so functions get redefined.
use C4::Circulation::Issues;
# FIXME - C4::Circulation::Issues and C4::Circulation::Borrower
# use each other, so functions get redefined.
use C4::Circulation::Renewals;
use C4::Scan;
use C4::Search;
@ -217,6 +221,7 @@ sub checktraps {
#check if borrower has any items waiting
my ($nowaiting,$itemswaiting) = &C4::Circulation::Main::checkwaiting($env,$dbh,$bornum);
if ($nowaiting > 0) { push (@traps_set,"WAITING"); }
# FIXME - This should be $traps_set[0], right?
if (@traps_set[0] ne "" ) {
($issuesallowed,$traps_done,$amount,$odues) =
process_traps($env,$dbh,$bornum,$borrower,
@ -318,7 +323,7 @@ sub process_traps {
sub Borenq {
my ($env)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
#get borrower guff
my $bornum;
my $issuesallowed;
@ -337,7 +342,6 @@ sub Borenq {
$reason = "";
}
}
$dbh->disconnect;
}
return $reason;
}
@ -350,7 +354,7 @@ sub modifyuser {
sub reserveslist {
my ($env,$borrower,$amount,$odues,$waiting) = @_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my @items;
my $x=0;
my $query="Select * from reserves where
@ -366,23 +370,21 @@ sub reserveslist {
}
$sth->finish;
reservesdisplay($env,$borrower,$amount,$odues,\@items);
$dbh->disconnect;
}
sub NewBorrowerNumber {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("Select max(borrowernumber) from borrowers");
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
$data->{'max(borrowernumber)'}++;
return($data->{'max(borrowernumber)'});
$dbh->disconnect;
}
sub findguarantees{
my ($bornum)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="select cardnumber,borrowernumber from borrowers where
guarantor='$bornum'";
my $sth=$dbh->prepare($query);
@ -394,7 +396,6 @@ sub findguarantees{
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,\@dat);
}
END { } # module clean-up code here (global destructor)

View File

@ -25,7 +25,7 @@ use strict;
# use warnings;
require Exporter;
use DBI;
use C4::Database;
use C4::Context;
#use C4::Accounts;
#use C4::InterfaceCDK;
#use C4::Circulation::Main;
@ -84,7 +84,7 @@ my $priv_func = sub {
sub getbranches {
# returns a reference to a hash of references to branches...
my %branches;
my $dbh=&C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("select * from branches");
$sth->execute;
while (my $branch=$sth->fetchrow_hashref) {
@ -98,7 +98,6 @@ sub getbranches {
$nsth->finish;
$branches{$branch->{'branchcode'}}=$branch;
}
$dbh->disconnect;
return (\%branches);
}
@ -106,13 +105,12 @@ sub getbranches {
sub getprinters {
my ($env) = @_;
my %printers;
my $dbh=&C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("select * from printers");
$sth->execute;
while (my $printer=$sth->fetchrow_hashref) {
$printers{$printer->{'printqueue'}}=$printer;
}
$dbh->disconnect;
return (\%printers);
}
@ -121,7 +119,7 @@ sub getprinters {
sub getpatroninformation {
# returns
my ($env, $borrowernumber,$cardnumber) = @_;
my $dbh=&C4Connect;
my $dbh = C4::Context->dbh;
my $query;
my $sth;
if ($borrowernumber) {
@ -138,7 +136,6 @@ sub getpatroninformation {
my $borrower = $sth->fetchrow_hashref;
my $flags = patronflags($env, $borrower, $dbh);
$sth->finish;
$dbh->disconnect;
$borrower->{'flags'}=$flags;
return($borrower, $flags);
}
@ -177,7 +174,7 @@ sub decode {
sub getiteminformation {
# returns a hash of item information given either the itemnumber or the barcode
my ($env, $itemnumber, $barcode) = @_;
my $dbh=&C4Connect;
my $dbh = C4::Context->dbh;
my $sth;
if ($itemnumber) {
$sth=$dbh->prepare("select * from biblio,items,biblioitems where items.itemnumber=$itemnumber and biblio.biblionumber=items.biblionumber and biblioitems.biblioitemnumber = items.biblioitemnumber");
@ -207,7 +204,6 @@ sub getiteminformation {
$iteminformation->{'notforloan'}=$itemtype->{'notforloan'};
$sth->finish;
}
$dbh->disconnect;
return($iteminformation);
}
@ -215,7 +211,7 @@ sub findborrower {
# returns an array of borrower hash references, given a cardnumber or a partial
# surname
my ($env, $key) = @_;
my $dbh=&C4Connect;
my $dbh = C4::Context->dbh;
my @borrowers;
my $q_key=$dbh->quote($key);
my $sth=$dbh->prepare("select * from borrowers where cardnumber=$q_key");
@ -233,7 +229,6 @@ sub findborrower {
}
}
$sth->finish;
$dbh->disconnect;
return(\@borrowers);
}
@ -286,7 +281,7 @@ sub transferbook {
sub dotransfer {
my ($itm, $fbr, $tbr) = @_;
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
$itm = $dbh->quote($itm);
$fbr = $dbh->quote($fbr);
$tbr = $dbh->quote($tbr);
@ -297,18 +292,18 @@ sub dotransfer {
$sth->execute;
$sth->finish;
#update holdingbranch in items .....
# FIXME - Use $dbh->do()
$query = "update items set datelastseen = now(), holdingbranch=$tbr where items.itemnumber=$itm";
$sth = $dbh->prepare($query);
$sth->execute;
$sth->finish;
$dbh->disconnect;
return;
}
sub issuebook {
my ($env, $patroninformation, $barcode, $responses, $date) = @_;
my $dbh=&C4Connect;
my $dbh = C4::Context->dbh;
my $iteminformation = getiteminformation($env, 0, $barcode);
my ($datedue);
my ($rejected,$question,$defaultanswer,$questionnumber, $noissue);
@ -485,7 +480,6 @@ sub issuebook {
if ($iteminformation->{'charge'}) {
$message=sprintf "Rental charge of \$%.02f applies.", $iteminformation->{'charge'};
}
$dbh->disconnect;
return ($iteminformation, $dateduef, $rejected, $question, $questionnumber, $defaultanswer, $message);
}
@ -521,18 +515,18 @@ sub returnbook {
}
# update issues, thereby returning book (should push this out into another subroutine
my ($borrower) = getpatroninformation(\%env, $currentborrower, 0);
if ($doreturn) {
if ($doreturn) { # FIXME - perl -wc complains about this line.
doreturn($borrower->{'borrowernumber'}, $iteminformation->{'itemnumber'});
$messages->{'WasReturned'};
}
($borrower) = getpatroninformation(\%env, $currentborrower, 0);
# transfer book
my ($transfered, $mess, $item) = transferbook($branch, $barcode, 1);
if ($transfered) {
if ($transfered) { # FIXME - perl -wc complains about this line.
$messages->{'WasTransfered'};
}
# fix up the accounts.....
if ($iteminformation->{'itemlost'}) {
if ($iteminformation->{'itemlost'}) { # FIXME - perl -wc complains about this line.
updateitemlost($iteminformation->{'itemnumber'});
fixaccountforlostandreturned($iteminformation, $borrower);
$messages->{'WasLost'};
@ -553,7 +547,7 @@ sub returnbook {
sub doreturn {
my ($brn, $itm) = @_;
my $dbh=&C4Connect;
my $dbh = C4::Context->dbh;
$brn = $dbh->quote($brn);
$itm = $dbh->quote($itm);
my $query = "update issues set returndate = now() where (borrowernumber = $brn)
@ -565,13 +559,13 @@ sub doreturn {
$sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
$dbh->disconnect;
return;
}
sub updateitemlost{
my ($itemno)=@_;
my $dbh=&C4Connect;
my $dbh = C4::Context->dbh;
# FIXME - Use $dbh->do();
my $query="update items set itemlost=0 where itemnumber=$itemno";
my $sth=$dbh->prepare($query);
$sth->execute;
@ -581,7 +575,7 @@ sub updateitemlost{
sub fixaccountforlostandreturned {
my ($iteminfo, $borrower) = @_;
my %env;
my $dbh=&C4Connect;
my $dbh = C4::Context->dbh;
my $itm = $dbh->quote($iteminfo->{'itemnumber'});
# check for charge made for lost book
my $query = "select * from accountlines where (itemnumber = $itm)
@ -673,7 +667,7 @@ sub fixaccountforlostandreturned {
sub fixoverduesonreturn {
my ($brn, $itm) = @_;
my $dbh=&C4Connect;
my $dbh = C4::Context->dbh;
$itm = $dbh->quote($itm);
$brn = $dbh->quote($brn);
# check for overdue fine
@ -785,7 +779,7 @@ sub checkoverdues {
sub currentborrower {
# Original subroutine for Circ2.pm
my ($itemnumber) = @_;
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $q_itemnumber = $dbh->quote($itemnumber);
my $sth=$dbh->prepare("select borrowers.borrowernumber from
issues,borrowers where issues.itemnumber=$q_itemnumber and
@ -844,7 +838,7 @@ sub checkreserve {
sub currentissues {
# New subroutine for Circ2.pm
my ($env, $borrower) = @_;
my $dbh=&C4Connect;
my $dbh = C4::Context->dbh;
my %currentissues;
my $counter=1;
my $borrowernumber = $borrower->{'borrowernumber'};
@ -883,13 +877,13 @@ sub currentissues {
$counter++;
}
$sth->finish;
$dbh->disconnect;
return(\%currentissues);
}
sub getissues {
# New subroutine for Circ2.pm
my ($borrower) = @_;
my $dbh=&C4Connect;
my $dbh = C4::Context->dbh;
my $borrowernumber = $borrower->{'borrowernumber'};
my $brn =$dbh->quote($borrowernumber);
my %currentissues;
@ -921,7 +915,6 @@ sub getissues {
$counter++;
}
$sth->finish;
$dbh->disconnect;
return(\%currentissues);
}
@ -1047,6 +1040,10 @@ sub renewbook {
return($odatedue);
}
# FIXME - This is almost, but not quite, identical to
# &C4::Circulation::Issues::calc_charges and
# &C4::Circulation::Renewals2::calc_charges.
# Pick one and stick with it.
sub calc_charges {
# Stolen from Issues.pm
# calculate charges due
@ -1119,7 +1116,7 @@ sub find_reserves {
# Stolen from Returns.pm
my ($itemno) = @_;
my %env;
my $dbh=&C4Connect;
my $dbh = C4::Context->dbh;
my ($itemdata) = getiteminformation(\%env, $itemno,0);
my $bibno = $dbh->quote($itemdata->{'biblionumber'});
my $bibitm = $dbh->quote($itemdata->{'biblioitemnumber'});

View File

@ -24,7 +24,7 @@ package C4::Circulation::Fines; #asummes C4/Circulation/Fines
use strict;
require Exporter;
use DBI;
use C4::Database;
use C4::Context;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
# set the version for version checking
@ -70,7 +70,7 @@ my $priv_func = sub {
sub Getoverdues{
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from issues where date_due < now() and returndate is
NULL order by borrowernumber";
my $sth=$dbh->prepare($query);
@ -82,14 +82,13 @@ sub Getoverdues{
$i++;
}
$sth->finish;
$dbh->disconnect;
# print @results;
return($i,\@results);
}
sub CalcFine {
my ($itemnumber,$bortype,$difference)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from items,biblioitems,itemtypes,categoryitem where items.itemnumber=$itemnumber
and items.biblioitemnumber=biblioitems.biblioitemnumber and
biblioitems.itemtype=itemtypes.itemtype and
@ -115,13 +114,12 @@ sub CalcFine {
$amount=5;
$printout="Final Notice";
}
$dbh->disconnect;
return($amount,$data->{'chargename'},$printout);
}
sub UpdateFine {
my ($itemnum,$bornum,$amount,$type,$due)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from accountlines where itemnumber=$itemnum and
borrowernumber=$bornum and (accounttype='FU' or accounttype='O' or
accounttype='F' or accounttype='M') and description like '%$due%'";
@ -154,6 +152,7 @@ sub UpdateFine {
my $title=$sth4->fetchrow_hashref;
$sth4->finish;
# print "not in account";
# FIXME - There's already a $query2 in this scope.
my $query2="Select max(accountno) from accountlines";
my $sth3=$dbh->prepare($query2);
$sth3->execute;
@ -171,12 +170,11 @@ sub UpdateFine {
$sth2->finish;
}
$sth->finish;
$dbh->disconnect;
}
sub BorType {
my ($borrowernumber)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from borrowers,categories where
borrowernumber=$borrowernumber and
borrowers.categorycode=categories.categorycode";
@ -184,19 +182,17 @@ borrowers.categorycode=categories.categorycode";
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
return($data);
}
sub ReplacementCost{
my ($itemnum)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select replacementprice from items where itemnumber='$itemnum'";
my $sth=$dbh->prepare($query);
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
return($data->{'replacementprice'});
}

View File

@ -24,11 +24,15 @@ package C4::Circulation::Issues; #asummes C4/Circulation/Issues
use strict;
require Exporter;
use DBI;
use C4::Database;
use C4::Context;
use C4::Accounts;
use C4::InterfaceCDK;
use C4::Circulation::Main;
# FIXME - C4::Circulation::Main and C4::Circulation::Issues
# use each other, so functions get redefined.
use C4::Circulation::Borrower;
# FIXME - C4::Circulation::Issues and C4::Circulation::Borrower
# use each other, so functions get redefined.
use C4::Scan;
use C4::Stats;
use C4::Print;
@ -79,7 +83,7 @@ my $priv_func = sub {
sub Issue {
my ($env) = @_;
my $dbh=&C4Connect;
my $dbh = C4::Context->dbh;
#clear help
helptext('');
#clearscreen();
@ -113,8 +117,7 @@ sub Issue {
#&endint($env);
}
}
$dbh->disconnect;
Cdk::refreshCdkScreen();
Cdk::refreshCdkScreen();
return ($done);
}
@ -122,7 +125,7 @@ sub Issue {
sub processitems {
#process a users items
my ($env,$bornum,$borrower,$items,$items2,$it2p,$amountdue,$itemsdet,$odues)=@_;
my $dbh=&C4Connect;
my $dbh = C4::Context->dbh;
$env->{'newborrower'} = "";
my ($itemnum,$reason) =
issuewindow($env,'Issues',$dbh,$items,$items2,$borrower,fmtdec($env,$amountdue,"32"));
@ -141,7 +144,6 @@ sub processitems {
$amountdue += $charge;
}
}
$dbh->disconnect;
#check to see if more books to process for this user
my @done;
if ($env->{'newborrower'} ne "") {$reason = "Finished user";}
@ -166,7 +168,6 @@ sub processitems {
}
}
#debug_msg($env, "return from issues $done[0]");
$dbh->disconnect;
return @done;
}
@ -374,6 +375,10 @@ sub updateissues{
return($dateret);
}
# FIXME - This is very similar to
# &C4::Circulation::Renewals2::calc_charges and
# &C4::Circulation::Circ2::calc_charges.
# Pick one and stick with it.
sub calc_charges {
# calculate charges due
my ($env, $dbh, $itemno, $bornum)=@_;
@ -398,7 +403,7 @@ sub calc_charges {
my $discount = $data2->{'rentaldiscount'};
$charge = ($charge *(100 - $discount)) / 100;
}
$sth2->{'finish'};
$sth2->{'finish'}; # FIXME - Was this supposed to be $sth2->finish ?
}
$sth1->finish;
return ($charge);

View File

@ -23,11 +23,19 @@ package C4::Circulation::Main; #asummes C4/Circulation/Main
use strict;
require Exporter;
use DBI;
use C4::Database;
use C4::Context;
use C4::Circulation::Issues;
# FIXME - C4::Circulation::Main and C4::Circulation::Issues
# use each other, so functions get redefined.
use C4::Circulation::Returns;
# FIXME - C4::Circulation::Main and C4::Circulation::Returns
# use each other, so functions get redefined.
use C4::Circulation::Renewals;
# FIXME - C4::Circulation::Main and C4::Circulation::Renewals
# use each other, so functions get redefined.
use C4::Circulation::Borrower;
# FIXME - C4::Circulation::Main and C4::Circulation::Borrower
# use each other, so functions get redefined.
use C4::Reserves;
use C4::Search;
use C4::InterfaceCDK;
@ -79,7 +87,7 @@ my $priv_func = sub {
sub getbranch {
my ($env) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $query = "select * from branches order by branchcode";
my $sth = $dbh->prepare($query);
$sth->execute;
@ -101,12 +109,11 @@ sub getbranch {
$env->{'brdata'} = $data;
$env->{'branchname'} = $data->{'branchname'};
$sth->finish;
$dbh->disconnect;
}
sub getprinter {
my ($env) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $query = "select * from printers order by printername";
my $sth = $dbh->prepare($query);
$sth->execute;
@ -122,8 +129,7 @@ sub getprinter {
$env->{'printtype'}=$data->{'printtype'};
}
$sth->finish;
$dbh->disconnect;
}
}
# FIXME - This is not the same as &C4::Circulation::pastitems, though
# the two appear to share some code.

View File

@ -24,13 +24,14 @@ package C4::Circulation::Renewals; #assumes C4/Circulation/Renewals
use strict;
require Exporter;
use DBI;
use C4::Database;
use C4::Format;
use C4::Accounts;
use C4::InterfaceCDK;
use C4::Interface::RenewalsCDK;
use C4::Circulation::Issues;
use C4::Circulation::Main;
# FIXME - C4::Circulation::Main and C4::Circulation::Renewals
# use each other, so functions get redefined.
use C4::Search;
use C4::Scan;

View File

@ -28,7 +28,6 @@ package C4::Circulation::Renewals2; #assumes C4/Circulation/Renewals2.pm
use strict;
require Exporter;
use DBI;
use C4::Database;
use C4::Stats;
use C4::Accounts2;
use C4::Circulation::Circ2;
@ -83,7 +82,7 @@ sub Return {
sub renewstatus {
# check renewal status
my ($env,$bornum,$itemno)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $renews = 1;
my $renewokay = 0;
my $q1 = "select * from issues
@ -108,7 +107,6 @@ sub renewstatus {
$sth2->finish;
}
$sth1->finish;
$dbh->disconnect;
return($renewokay);
}
@ -116,7 +114,7 @@ sub renewstatus {
sub renewbook {
# mark book as renewed
my ($env,$bornum,$itemno,$datedue)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
if ($datedue eq "" ) {
#debug_msg($env, "getting date");
my $loanlength=21;
@ -163,17 +161,19 @@ sub renewbook {
$sth->finish;
# print $account;
}
$dbh->disconnect;
# return();
}
# FIXME - This is very similar to
# &C4::Circulation::Issues::calc_charges and
# &C4::Circulation::Circ2::calc_charges.
# Pick one and stick with it.
sub calc_charges {
# calculate charges due
my ($env, $itemno, $bornum)=@_;
my $charge=0;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $item_type;
my $q1 = "select itemtypes.itemtype,rentalcharge from
items,biblioitems,itemtypes
@ -199,7 +199,6 @@ sub calc_charges {
$sth2->finish;
}
$sth1->finish;
$dbh->disconnect;
# print "item $item_type";
return ($charge,$item_type);
}

View File

@ -24,10 +24,12 @@ package C4::Circulation::Returns; #assumes C4/Circulation/Returns
use strict;
require Exporter;
use DBI;
use C4::Database;
use C4::Context;
use C4::Accounts;
use C4::InterfaceCDK;
use C4::Circulation::Main;
# FIXME - C4::Circulation::Main and C4::Circulation::Returns
# use each other, so functions get redefined.
use C4::Format;
use C4::Scan;
use C4::Stats;
@ -78,7 +80,7 @@ my $priv_func = sub {
sub Returns {
my ($env)=@_;
my $dbh=&C4Connect;
my $dbh = C4::Context->dbh;
my @items;
@items[0]=" "x50;
my $reason;
@ -131,7 +133,6 @@ sub Returns {
}
}
# clearscreen;
$dbh->disconnect;
return($reason);
}

View File

@ -20,6 +20,15 @@ package C4::Database; #assumes C4/Database
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
# NOTE:
# C4::Database::C4Connect has been superseded by C4::Context->dbh;
# FIXME
# If C4::Biblio::OLD_MAY_BE_DELETED_newcompletebiblioitem can, in
# fact, be deleted, then it should be. Then C4::Biblio::getoraddbiblio
# won't be used anywhere, and it can be deleted too. That'll make two
# fewer functions that use C4::Database::requireDBI.
use strict;
require Exporter;
use DBI;
@ -29,29 +38,9 @@ $VERSION = 0.01;
@ISA = qw(Exporter);
@EXPORT = qw(
&C4Connect &requireDBI &configfile
&C4Connect &requireDBI
);
sub configfile {
my $configfile;
open (KC, "/etc/koha.conf");
while (<KC>) {
chomp;
(next) if (/^\s*#/);
if (/(.*)\s*=\s*(.*)/) {
my $variable=$1;
my $value=$2;
# Clean up white space at beginning and end
$variable=~s/^\s*//g;
$variable=~s/\s*$//g;
$value=~s/^\s*//g;
$value=~s/\s*$//g;
$configfile->{$variable}=$value;
}
}
return $configfile;
}
sub C4Connect {
my $dbname="c4";
my ($database,$hostname,$user,$pass,%configfile);

View File

@ -27,7 +27,7 @@ package C4::Groups;
use strict;
require Exporter;
use DBI;
use C4::Database;
use C4::Context;
use C4::Circulation::Circ2;
#use C4::Accounts;
#use C4::InterfaceCDK;
@ -50,20 +50,19 @@ $VERSION = 0.01;
sub getgroups {
my ($env) = @_;
my %groups;
my $dbh=&C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("select distinct groupshortname,grouplongname from borrowergroups");
$sth->execute;
while (my ($short, $long)=$sth->fetchrow) {
$groups{$short}=$long;
}
$dbh->disconnect;
return (\%groups);
}
sub groupmembers {
my ($env, $group) = @_;
my @members;
my $dbh=&C4Connect;
my $dbh = C4::Context->dbh;
my $q_group=$dbh->quote($group);
my $sth=$dbh->prepare("select borrowernumber from borrowergroups where groupshortname=$q_group");
$sth->execute;

View File

@ -19,6 +19,8 @@ package C4::InterfaceCDK; #assumes C4/InterfaceCDK
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
# FIXME - This module doesn't compile!
use C4::Format;
use strict;
use Cdk;
@ -421,6 +423,7 @@ sub actloanlength {
sub prebook {
my ($input,$env,$dbh,$funcmenu,$entryBox,$loanlength,
$scroll1,$scroll2,$borrower,$amountowing,$odues)= @_;
# FIXME - $key_tab is undefined
if ($input eq $key_tab) {
actfmenu ($env,$dbh,$funcmenu,$entryBox,$loanlength,$scroll1,
$scroll2,$borrower,$amountowing,$odues);
@ -582,6 +585,7 @@ sub preborr {
my ($input,$env, $entry) = @_;
if ($env->{"bcard"} ne "") {
# error_msg($env,"hi there");
# FIXME - $lastval is undefined
if ($input eq $lastval) {
# error_msg($env,"its a ctrl-r");
borfill($env,$entry);

View File

@ -20,7 +20,7 @@ package C4::Koha;
use strict;
require Exporter;
use C4::Database;
use C4::Context;
use vars qw($VERSION @ISA @EXPORT);
@ -91,12 +91,11 @@ Koha database ("European" or "Pacific Islander").
sub fixEthnicity($) {
my $ethnicity = shift;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("Select name from ethnicity where code = ?");
$sth->execute($ethnicity);
my $data=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
return $data->{'name'};
}
@ -113,7 +112,7 @@ to category descriptions.
#'
sub borrowercategories {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("Select categorycode,description from categories order by description");
$sth->execute;
my %labels;
@ -123,7 +122,6 @@ sub borrowercategories {
$labels{$data->{'categorycode'}}=$data->{'description'};
}
$sth->finish;
$dbh->disconnect;
return(\@codes,\%labels);
}
@ -140,7 +138,7 @@ descriptions.
#'
sub ethnicitycategories {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("Select code,name from ethnicity order by name");
$sth->execute;
my %labels;
@ -150,7 +148,6 @@ sub ethnicitycategories {
$labels{$data->{'code'}}=$data->{'name'};
}
$sth->finish;
$dbh->disconnect;
return(\@codes,\%labels);
}

View File

@ -21,7 +21,7 @@ package C4::Maintainance; #assumes C4/Maintainance
# Suite 330, Boston, MA 02111-1307 USA
use strict;
use C4::Database;
use C4::Context;
require Exporter;
@ -78,7 +78,7 @@ C<$n> is 0, it will return all matching subjects.
# just return a list of strings.
sub listsubjects {
my ($sub,$num,$offset)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from bibliosubject where subject like '$sub%' group by subject";
# FIXME - Make $num and $offset optional.
# If $num was given, make sure $offset was, too.
@ -95,7 +95,6 @@ sub listsubjects {
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,\@results);
}
@ -110,14 +109,14 @@ bibliosubject table of the Koha database.
#'
sub updatesub{
my ($sub,$oldsub)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
$sub=$dbh->quote($sub);
$oldsub=$dbh->quote($oldsub);
# FIXME - Just use $dbh->do();
my $query="update bibliosubject set subject=$sub where subject=$oldsub";
my $sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
=item shiftgroup
@ -132,16 +131,17 @@ C<$biblionumber> is the biblionumber to associate it with.
#'
sub shiftgroup{
my ($bib,$bi)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
# FIXME - Just use $dbh->do();
my $query="update biblioitems set biblionumber=$bib where biblioitemnumber=$bi";
my $sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
# FIXME - Just use $dbh->do();
$query="update items set biblionumber=$bib where biblioitemnumber=$bi";
$sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
=item deletedbib
@ -159,7 +159,7 @@ is the number of elements in C<$results>.
#'
sub deletedbib{
my ($title)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from deletedbiblio where title like '$title%' order by title";
my $sth=$dbh->prepare($query);
$sth->execute;
@ -170,7 +170,6 @@ sub deletedbib{
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,\@results);
}
@ -186,7 +185,7 @@ moves its entry to the biblio table.
#'
sub undeletebib{
my ($bib)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="select * from deletedbiblio where biblionumber=$bib";
my $sth=$dbh->prepare($query);
$sth->execute;
@ -209,7 +208,6 @@ sub undeletebib{
$sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
=item updatetype
@ -223,12 +221,11 @@ C<$itemtype>.
#'
sub updatetype{
my ($bi,$type)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
# FIXME - Use $dbh->do(...);
my $sth=$dbh->prepare("Update biblioitems set itemtype='$type' where biblioitemnumber=$bi");
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
END { } # module clean-up code here (global destructor)

View File

@ -25,6 +25,7 @@ package C4::Output;
use strict;
require Exporter;
use C4::Context;
use C4::Database;
use C4::Search; #for getting the systempreferences
@ -92,17 +93,8 @@ my @more = ();
# all file-scoped lexicals must be created before
# the functions below that use them.
#
# Change this value to reflect where you will store your includes
#
# FIXME - Since this is used in several places, it ought to be put
# into a separate file. Better yet, put "use C4::Config;" inside the
# &import method of any package that requires the config file.
my $configfile=configfile();
my $path=$configfile->{'includes'};
($path) || ($path="/usr/local/www/hdl/htdocs/includes");
my $path = C4::Context->config('includes') ||
"/usr/local/www/hdl/htdocs/includes";
#---------------------------------------------------------------------------------------------------------
sub gettemplate {
@ -258,7 +250,7 @@ sub pathtotemplate {
#where to search for templates
my @tmpldirs = ("$path/templates", $path);
unshift (@tmpldirs, $configfile->{'templatedirectory'}) if $configfile->{'templatedirectory'};
unshift (@tmpldirs, C4::Context->config('templatedirectory')) if C4::Context->config('templatedirectory');
unshift (@tmpldirs, $params{'path'}) if $params{'path'};
my ($edir, $etheme, $elanguage, $epath);

View File

@ -138,6 +138,7 @@ will print to the file F</tmp/kohares>.
=cut
#'
# FIXME - There's also a &printslip in circ/circulation.pl
sub printslip {
my($env, $slip)=@_;
my $printer = $env->{'printer'};

View File

@ -24,7 +24,7 @@ package C4::Reserves; #asummes C4/Reserves
use strict;
require Exporter;
use DBI;
use C4::Database;
use C4::Context;
use C4::Format;
use C4::Accounts;
use C4::Stats;
@ -147,7 +147,7 @@ sub EnterReserves{
} else {
my @items = GetItems($env,$biblionumber);
my $cnt_it = @items;
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $query = "Select * from biblio where biblionumber = $biblionumber";
my $sth = $dbh->prepare($query);
$sth->execute;
@ -183,7 +183,6 @@ sub EnterReserves{
}
} else { $donext = "Circ" }
}
$dbh->disconnect;
}
}
}
@ -193,7 +192,7 @@ sub EnterReserves{
sub CalcReserveFee {
my ($env,$borrnum,$biblionumber,$constraint,$bibitems) = @_;
#check for issues;
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $const = lc substr($constraint,0,1);
my $query = "select * from borrowers,categories
where (borrowernumber = '$borrnum')
@ -259,13 +258,12 @@ sub CalcReserveFee {
}
}
}
$dbh->disconnect();
return $fee;
} # end CalcReserveFee
sub CreateReserve {
my ($env,$branch,$borrnum,$biblionumber,$constraint,$bibitems,$fee) = @_;
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
#$dbh->{RaiseError} = 1;
#$dbh->{AutoCommit} = 0;
my $const = lc substr($constraint,0,1);
@ -307,7 +305,6 @@ sub CreateReserve {
# # error_msg($env,"Update failed");
# $dbh->rollback();
#}
$dbh->disconnect();
return();
} # end CreateReserve

View File

@ -21,8 +21,10 @@ package C4::Reserves2; #assumes C4/Reserves2
use strict;
require Exporter;
use DBI;
use C4::Database;
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;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
@ -37,7 +39,7 @@ $VERSION = 0.01;
sub FindReserves {
my ($bib,$bor)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="SELECT *,reserves.branchcode,biblio.title AS btitle
FROM reserves,borrowers,biblio ";
if ($bib ne ''){
@ -92,14 +94,13 @@ sub FindReserves {
}
# print $query;
$sth->finish;
$dbh->disconnect;
return($i,\@results);
}
sub CheckReserves {
my ($item, $barcode) = @_;
# warn "In CheckReserves: itemnumber = $item";
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $sth;
if ($item) {
my $qitem=$dbh->quote($item);
@ -121,7 +122,6 @@ sub CheckReserves {
$sth->execute;
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);
# get the reserves...
@ -150,7 +150,7 @@ sub CheckReserves {
sub CancelReserve {
my ($biblio, $item, $borr) = @_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
#warn "In CancelReserve";
if (($item and $borr) and (not $biblio)) {
# removing a waiting reserve record....
@ -181,6 +181,7 @@ sub CancelReserve {
my ($priority) = $sth->fetchrow_array;
$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,
priority = 0
@ -188,19 +189,21 @@ sub CancelReserve {
and borrowernumber = $borr
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;
# now fix the priority on the others....
fixpriority($priority, $biblio);
}
$dbh->disconnect;
}
sub FillReserve {
my ($res) = @_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
# fillinf a reserve record....
my $biblio = $res->{'biblionumber'}; my $qbiblio = $dbh->quote($biblio);
my $borr = $res->{'borrowernumber'}; $borr = $dbh->quote($borr);
@ -215,24 +218,27 @@ sub FillReserve {
my ($priority) = $sth->fetchrow_array;
$sth->finish;
# update the database...
# FIXME - There's already a $query in this scope.
my $query = "UPDATE reserves SET found = 'F',
priority = 0
WHERE biblionumber = $qbiblio
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;
# now fix the priority on the others (if the priority wasnt already sorted!)....
unless ($priority == 0) {
fixpriority($priority, $biblio);
}
$dbh->disconnect;
}
sub fixpriority {
my ($priority, $biblio) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my ($count, $reserves) = FindReserves($biblio);
foreach my $rec (@$reserves) {
if ($rec->{'priority'} > $priority) {
@ -250,14 +256,13 @@ sub fixpriority {
$sth->finish;
}
}
$dbh->disconnect;
}
sub ReserveWaiting {
my ($item, $borr) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
$item = $dbh->quote($item);
$borr = $dbh->quote($borr);
# get priority and biblionumber....
@ -289,7 +294,6 @@ sub ReserveWaiting {
$sth = $dbh->prepare($query);
$sth->execute;
$sth->finish;
$dbh->disconnect;
# now fix up the remaining priorities....
fixpriority($data->{'priority'}, $biblio);
my $branchcode = $data->{'branchcode'};
@ -298,7 +302,7 @@ sub ReserveWaiting {
sub CheckWaiting {
my ($borr)=@_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
$borr = $dbh->quote($borr);
my @itemswaiting;
my $query = "SELECT * FROM reserves
@ -307,9 +311,10 @@ sub CheckWaiting {
AND cancellationdate is NULL";
my $sth = $dbh->prepare($query);
$sth->execute();
# FIXME - Use 'push'
my $cnt=0;
if (my $data=$sth->fetchrow_hashref) {
@itemswaiting[$cnt] =$data;
$itemswaiting[$cnt] =$data;
$cnt ++;
}
$sth->finish;
@ -318,7 +323,7 @@ sub CheckWaiting {
sub Findgroupreserve {
my ($bibitem,$biblio)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
$bibitem=$dbh->quote($bibitem);
my $query = "SELECT reserves.biblionumber AS biblionumber,
reserves.borrowernumber AS borrowernumber,
@ -349,7 +354,6 @@ sub Findgroupreserve {
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,@results);
}
@ -357,7 +361,7 @@ sub CreateReserve {
my
($env,$branch,$borrnum,$biblionumber,$constraint,$bibitems,$priority,$notes,$title)= @_;
my $fee=CalcReserveFee($env,$borrnum,$biblionumber,$constraint,$bibitems);
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $const = lc substr($constraint,0,1);
my @datearr = localtime(time);
my $resdate =(1900+$datearr[5])."-".($datearr[4]+1)."-".$datearr[3];
@ -400,14 +404,13 @@ sub CreateReserve {
}
}
# print $query;
$dbh->disconnect();
return();
}
sub CalcReserveFee {
my ($env,$borrnum,$biblionumber,$constraint,$bibitems) = @_;
#check for issues;
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $const = lc substr($constraint,0,1);
my $query = "SELECT * FROM borrowers,categories
WHERE (borrowernumber = ?)
@ -486,7 +489,6 @@ sub CalcReserveFee {
}
}
# print "fee $fee";
$dbh->disconnect();
return $fee;
}
@ -508,7 +510,7 @@ sub getnextacctno {
sub updatereserves{
#subroutine to update a reserve
my ($rank,$biblio,$borrower,$del,$branch)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Update reserves ";
if ($del == 0){
$query.="set priority='$rank',branchcode='$branch' where
@ -540,14 +542,13 @@ sub updatereserves{
}
my $sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
$dbh->disconnect;
$sth->finish;
}
sub UpdateReserve {
#subroutine to update a reserve
my ($rank,$biblio,$borrower,$branch)=@_;
return if $rank eq "W";
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
if ($rank eq "del") {
my $query = "UPDATE reserves SET cancellationdate=now()
WHERE biblionumber = ?
@ -567,12 +568,11 @@ sub UpdateReserve {
$sth->execute($rank, $branch, $biblio, $borrower);
$sth->finish;
}
$dbh->disconnect;
}
sub getreservetitle {
my ($biblio,$bor,$date,$timestamp)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from reserveconstraints,biblioitems where
reserveconstraints.biblioitemnumber=biblioitems.biblioitemnumber
and reserveconstraints.biblionumber=$biblio and reserveconstraints.borrowernumber
@ -582,7 +582,6 @@ sub getreservetitle {
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
# print $query;
return($data);
}

View File

@ -21,8 +21,10 @@ package C4::Search; #assumes C4/Search
use strict;
require Exporter;
use DBI;
use C4::Database;
use C4::Context;
use C4::Reserves2;
# FIXME - C4::Search uses C4::Reserves2, which uses C4::Search.
# So Perl complains that all of the functions here get redefined.
use Set::Scalar;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
@ -81,7 +83,7 @@ of references to hash, which gives the actual results.
#'
sub findguarantees{
my ($bornum)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="select cardnumber,borrowernumber from borrowers where
guarantor='$bornum'";
my $sth=$dbh->prepare($query);
@ -93,7 +95,6 @@ sub findguarantees{
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,\@dat);
}
@ -115,7 +116,7 @@ from the C<borrowers> database table;
#'
sub findguarantor{
my ($bornum)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="select guarantor from borrowers where
borrowernumber='$bornum'";
my $sth=$dbh->prepare($query);
@ -128,7 +129,6 @@ sub findguarantor{
$sth->execute;
$data=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
return($data);
}
@ -143,14 +143,13 @@ dump of the C<systempreferences> database table.
#'
sub systemprefs {
my %systemprefs;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("select variable,value from systempreferences");
$sth->execute;
while (my ($variable,$value)=$sth->fetchrow) {
$systemprefs{$variable}=$value;
}
$sth->finish;
$dbh->disconnect;
return(%systemprefs);
}
@ -163,13 +162,12 @@ Allocates a new, unused borrower number, and returns it.
=cut
#'
sub NewBorrowerNumber {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("Select max(borrowernumber) from borrowers");
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
$data->{'max(borrowernumber)'}++;
$dbh->disconnect;
return($data->{'max(borrowernumber)'});
}
@ -215,7 +213,7 @@ HTML.
#'
sub catalogsearch {
my ($env,$type,$search,$num,$offset)=@_;
my $dbh = C4Connect();
my $dbh = C4::Context->dbh;
# foreach my $key (%$search){
# $search->{$key}=$dbh->quote($search->{$key});
# }
@ -330,7 +328,7 @@ C<$num> to 5 will return results 100 through 104 inclusive.
sub KeywordSearch {
my ($env,$type,$search,$num,$offset)=@_;
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
$search->{'keyword'}=~ s/ +$//;
$search->{'keyword'}=~ s/'/\\'/;
my @key=split(' ',$search->{'keyword'});
@ -552,7 +550,6 @@ sub KeywordSearch {
}
}
$dbh->disconnect;
#$count=$i;
return($count,@res2);
@ -560,7 +557,7 @@ sub KeywordSearch {
sub KeywordSearch2 {
my ($env,$type,$search,$num,$offset)=@_;
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
$search->{'keyword'}=~ s/ +$//;
$search->{'keyword'}=~ s/'/\\'/;
my @key=split(' ',$search->{'keyword'});
@ -702,7 +699,6 @@ sub KeywordSearch2 {
$i2++;
}
$sth->finish;
$dbh->disconnect;
# $i--;
# $i++;
return($i,@res2);
@ -865,7 +861,7 @@ not ordered.
#'
sub CatSearch {
my ($env,$type,$search,$num,$offset)=@_;
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $query = '';
my @results;
# FIXME - Why not just
@ -1067,6 +1063,7 @@ sub CatSearch {
and biblioitems.biblionumber = biblio.biblionumber";
my $sth=$dbh->prepare($query);
$sth->execute;
# FIXME - There's already a $data in this scope.
my $data=$sth->fetchrow_hashref;
my ($dewey, $subclass) = ($data->{'dewey'}, $data->{'subclass'});
# FIXME - The following assumes that the Dewey code is a
@ -1180,7 +1177,7 @@ C<$env> is ignored.
#'
sub subsearch {
my ($env,$subject)=@_;
my $dbh=C4Connect();
my $dbh = C4::Context->dbh;
$subject=$dbh->quote($subject);
my $query="Select * from biblio,bibliosubject where
biblio.biblionumber=bibliosubject.biblionumber and
@ -1196,7 +1193,6 @@ sub subsearch {
$i++;
}
$sth->finish;
$dbh->disconnect;
return(@results);
}
@ -1248,7 +1244,7 @@ If this is set, it is set to C<One Order>.
#'
sub ItemInfo {
my ($env,$biblionumber,$type) = @_;
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $query = "SELECT * FROM items, biblio, biblioitems, itemtypes
WHERE items.biblionumber = ?
AND biblioitems.biblioitemnumber = items.biblioitemnumber
@ -1348,7 +1344,6 @@ sub ItemInfo {
}
$sth2->finish;
$dbh->disconnect;
return(@results);
}
@ -1375,7 +1370,7 @@ is lost.
sub GetItems {
my ($env,$biblionumber)=@_;
#debug_msg($env,"GetItems");
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $query = "Select * from biblioitems where (biblionumber = $biblionumber)";
#debug_msg($env,$query);
my $sth=$dbh->prepare($query);
@ -1408,7 +1403,6 @@ sub GetItems {
$i++;
}
$sth->finish;
$dbh->disconnect;
return(@results);
}
@ -1425,7 +1419,7 @@ the Koha database.
#'
sub itemdata {
my ($barcode)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from items,biblioitems where barcode='$barcode'
and items.biblioitemnumber=biblioitems.biblioitemnumber";
# print $query;
@ -1433,7 +1427,6 @@ sub itemdata {
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
return($data);
}
@ -1459,7 +1452,7 @@ the first one is considered.
#'
sub bibdata {
my ($bibnum, $type) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $query = "Select *, biblio.notes
from biblio, biblioitems
left join bibliosubtitle on
@ -1481,7 +1474,6 @@ sub bibdata {
} # while
$sth->finish;
$dbh->disconnect;
return($data);
} # sub bibdata
@ -1498,7 +1490,7 @@ that C<biblioitems.notes> is given as C<$itemdata-E<gt>{bnotes}>.
#'
sub bibitemdata {
my ($bibitem) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $query = "Select *,biblioitems.notes as bnotes from biblio, biblioitems,itemtypes
where biblio.biblionumber = biblioitems.biblionumber
and biblioitemnumber = $bibitem
@ -1511,7 +1503,6 @@ and biblioitems.itemtype = itemtypes.itemtype";
$data = $sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
return($data);
} # sub bibitemdata
@ -1528,7 +1519,7 @@ elements in C<$subjects>.
#'
sub subject {
my ($bibnum)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from bibliosubject where biblionumber=$bibnum";
my $sth=$dbh->prepare($query);
$sth->execute;
@ -1539,7 +1530,6 @@ sub subject {
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,\@results);
}
@ -1558,7 +1548,7 @@ elements in C<$authors>.
#'
sub addauthor {
my ($bibnum)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from additionalauthors where biblionumber=$bibnum";
my $sth=$dbh->prepare($query);
$sth->execute;
@ -1569,7 +1559,6 @@ sub addauthor {
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,\@results);
}
@ -1587,7 +1576,7 @@ elements in C<$subtitles>.
#'
sub subtitle {
my ($bibnum)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from bibliosubtitle where biblionumber=$bibnum";
my $sth=$dbh->prepare($query);
$sth->execute;
@ -1598,7 +1587,6 @@ sub subtitle {
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,\@results);
}
@ -1648,7 +1636,7 @@ The borrower number of the last three patrons who borrowed this item.
#'
sub itemissues {
my ($bibitem, $biblio)=@_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $query = "Select * from items where
items.biblioitemnumber = '$bibitem'";
# FIXME - If this function die()s, the script will abort, and the
@ -1717,7 +1705,6 @@ order by returndate desc,timestamp desc";
}
$sth->finish;
$dbh->disconnect;
return(@results);
}
@ -1737,7 +1724,7 @@ database.
#'
sub itemnodata {
my ($env,$dbh,$itemnumber) = @_;
$dbh=C4Connect;
$dbh = C4::Context->dbh;
my $query="Select * from biblio,items,biblioitems
where items.itemnumber = '$itemnumber'
and biblio.biblionumber = items.biblionumber
@ -1747,7 +1734,6 @@ sub itemnodata {
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
return($data);
}
@ -1774,7 +1760,7 @@ C<$count> is the number of elements in C<$borrowers>.
#called by member.pl
sub BornameSearch {
my ($env,$searchstring,$type)=@_;
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
$searchstring=~ s/\'/\\\'/g;
my @data=split(' ',$searchstring);
my $count=@data;
@ -1801,7 +1787,6 @@ sub BornameSearch {
}
# $sth->execute;
$sth->finish;
$dbh->disconnect;
return ($cnt,\@results);
}
@ -1821,7 +1806,7 @@ the C<borrowers> table in the Koha database.
sub borrdata {
my ($cardnumber,$bornum)=@_;
$cardnumber = uc $cardnumber;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query;
if ($bornum eq ''){
$query="Select * from borrowers where cardnumber='$cardnumber'";
@ -1833,7 +1818,6 @@ sub borrdata {
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
return($data);
}
@ -1853,7 +1837,7 @@ C<$issues>.
#'
sub borrissues {
my ($bornum)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query;
$query="Select * from issues,biblio,items where borrowernumber='$bornum' and
items.itemnumber=issues.itemnumber and
@ -1869,7 +1853,6 @@ by date_due";
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,\@result);
}
@ -1896,7 +1879,7 @@ elements in C<$issues>
#'
sub allissues {
my ($bornum,$order,$limit)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query;
$query="Select * from issues,biblio,items,biblioitems
where borrowernumber='$bornum' and
@ -1917,7 +1900,6 @@ sub allissues {
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,\@result);
}
@ -1939,7 +1921,7 @@ the total fine currently due by the borrower.
#'
sub borrdata2 {
my ($env,$bornum)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select count(*) from issues where borrowernumber='$bornum' and
returndate is NULL";
# print $query;
@ -1957,7 +1939,6 @@ sub borrdata2 {
$sth->execute;
my $data3=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
return($data2->{'count(*)'},$data->{'count(*)'},$data3->{'sum(amountoutstanding)'});
}
@ -1982,7 +1963,7 @@ total amount outstanding for all of the account lines.
#'
sub getboracctrecord {
my ($env,$params) = @_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my @acctlines;
my $numlines=0;
my $query= "Select * from accountlines where
@ -2006,7 +1987,6 @@ borrowernumber=$params->{'borrowernumber'} order by date desc,timestamp desc";
$total = $total+ $data->{'amountoutstanding'};
}
$sth->finish;
$dbh->disconnect;
return ($numlines,\@acctlines,$total);
}
@ -2050,9 +2030,13 @@ C<$ocount> is the number of items that haven't arrived yet
=cut
#'
# FIXME - There's also a &C4::Acquisitions::itemcount and
# &C4::Biblio::itemcount.
# Since they're all exported, acqui/acquire.pl doesn't compile with -w.
sub itemcount {
my ($env,$bibnum,$type)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from items where
biblionumber=$bibnum ";
if ($type ne 'intra'){
@ -2118,7 +2102,6 @@ sub itemcount {
# $count+=$ocount;
$sth2->finish;
$sth->finish;
$dbh->disconnect;
return ($count,$lcount,$nacount,$fcount,$scount,$lostcount,$mending,$transit,$ocount);
}
@ -2160,7 +2143,7 @@ that branch.
#'
sub itemcount2 {
my ($env,$bibnum,$type)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from items,branches where
biblionumber=$bibnum and items.holdingbranch=branches.branchcode";
if ($type ne 'intra'){
@ -2201,7 +2184,6 @@ sub itemcount2 {
}
$sth2->finish;
$sth->finish;
$dbh->disconnect;
return (\%counts);
}
@ -2236,13 +2218,12 @@ Given an item type code, returns the description for that type.
# rates, printers, stopwords, and perhaps others.
sub ItemType {
my ($type)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="select description from itemtypes where itemtype='$type'";
my $sth=$dbh->prepare($query);
$sth->execute;
my $dat=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
return ($dat->{'description'});
}
@ -2266,7 +2247,7 @@ all copies are lost; otherwise, there is at least one copy available.
#'
sub bibitems {
my ($bibnum) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $query = "SELECT biblioitems.*,
itemtypes.*,
MIN(items.itemlost) as itemlost,
@ -2285,7 +2266,6 @@ sub bibitems {
$count++;
} # while
$sth->finish;
$dbh->disconnect;
return($count, @results);
} # sub bibitems
@ -2305,7 +2285,7 @@ The returned items include very overdue items, but not lost ones.
sub barcodes{
#called from request.pl
my ($biblioitemnumber)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="SELECT barcode, itemlost, holdingbranch FROM items
WHERE biblioitemnumber = ?
AND (wthdrawn <> 1 OR wthdrawn IS NULL)";
@ -2318,7 +2298,6 @@ sub barcodes{
$i++;
}
$sth->finish;
$dbh->disconnect;
return(@barcodes);
}
@ -2338,7 +2317,7 @@ fields from the C<websites> table in the Koha database.
#'
sub getwebsites {
my ($biblionumber) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $query = "Select * from websites where biblionumber = $biblionumber";
my $sth = $dbh->prepare($query);
my $count = 0;
@ -2358,7 +2337,6 @@ sub getwebsites {
} # while
$sth->finish;
$dbh->disconnect;
return($count, @results);
} # sub getwebsites
@ -2377,7 +2355,7 @@ C<biblioitems> table of the Koha database.
#'
sub getwebbiblioitems {
my ($biblionumber) = @_;
my $dbh = C4Connect;
my $dbh = C4::Context->dbh;
my $query = "Select * from biblioitems where biblionumber = $biblionumber
and itemtype = 'WEB'";
my $sth = $dbh->prepare($query);
@ -2392,7 +2370,6 @@ and itemtype = 'WEB'";
} # while
$sth->finish;
$dbh->disconnect;
return($count, @results);
} # sub getwebbiblioitems

View File

@ -21,7 +21,7 @@ package C4::Security; #assumes C4/Security
use strict;
require Exporter;
use DBI;
use C4::Database;
use C4::Context;
use C4::Format;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
@ -33,7 +33,7 @@ $VERSION = 0.01;
sub Login {
my ($env)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my @branches;
my $query = "select * from branches order by branchname";
my $sth=$dbh->prepare($query);
@ -70,7 +70,6 @@ sub Login {
}
$sth->finish;
}
$dbh->disconnect;
&endint();
}

View File

@ -34,7 +34,6 @@ use strict;
use DBI;
# Koha modules used
use C4::Database;
require Exporter;
@ -465,6 +464,13 @@ sub taglabel {
#---------------------------------------------
# $Log$
# Revision 1.4 2002/10/05 09:53:11 arensb
# Merged with arensb-context branch: use C4::Context->dbh instead of
# &C4Connect, and generally prefer C4::Context over C4::Database.
#
# Revision 1.3.2.1 2002/10/04 02:57:38 arensb
# Removed useless "use C4::Database;" line.
#
# Revision 1.3 2002/08/14 18:12:52 tonnesen
# Added copyright statement to all .pl and .pm files
#

View File

@ -21,7 +21,7 @@ package C4::Stats; #assumes C4/Stats
use strict;
require Exporter;
use DBI;
use C4::Database;
use C4::Context;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
# set the version for version checking
@ -72,13 +72,13 @@ C<$env-E<gt>{usercode} specifies the value of the C<usercode> field.
sub UpdateStats {
#module to insert stats data into stats table
my ($env,$branch,$type,$amount,$other,$itemnum,$itemtype,$borrowernumber)=@_;
my $dbh=C4Connect();
my $dbh = C4::Context->dbh;
if ($branch eq ''){
$branch=$env->{'branchcode'};
}
my $user = $env->{'usercode'};
print $borrowernumber;
# FIXME - Use $dbh->do() instead?
# FIXME - Use $dbh->do() instead
my $sth=$dbh->prepare("Insert into statistics
(datetime,branch,type,usercode,value,
other,itemnumber,itemtype,borrowernumber)
@ -86,7 +86,6 @@ sub UpdateStats {
'$other','$itemnum','$itemtype','$borrowernumber')");
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
# XXX - POD
@ -110,7 +109,7 @@ sub statsreport {
# &statsreport.
sub circrep {
my ($time,$type)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from statistics";
if ($time eq 'today'){
# FIXME - What is this supposed to do? MySQL 3.23.42 barfs on it.
@ -127,16 +126,14 @@ sub circrep {
}
$sth->finish;
# print $query;
$dbh->disconnect;
return(@results);
}
# XXX - POD
# FIXME - This is only used in stats.pl, which in turn is never used.
sub Count {
my ($type,$branch,$time,$time2)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select count(*) from statistics where type='$type'";
$query.=" and datetime >= '$time' and datetime< '$time2' and branch='$branch'";
my $sth=$dbh->prepare($query);
@ -144,26 +141,24 @@ sub Count {
my $data=$sth->fetchrow_hashref;
$sth->finish;
# print $query;
$dbh->disconnect;
return($data->{'count(*)'});
}
# XXX - POD. Doesn't appear to be used
sub Overdues{
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select count(*) from issues where date_due >= now()";
my $sth=$dbh->prepare($query);
$sth->execute;
my $count=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
return($count->{'count(*)'});
}
# XXX - POD. Never used
sub TotalOwing{
my ($type)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select sum(amountoutstanding) from accountlines";
if ($type eq 'fine'){
$query=$query." where accounttype='F' or accounttype='FN'";
@ -173,14 +168,13 @@ sub TotalOwing{
$sth->execute;
my $total=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
return($total->{'sum(amountoutstanding)'});
}
# XXX - POD. Never used
sub TotalPaid {
my ($time)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from accountlines,borrowers where (accounttype = 'Pay'
or accounttype ='W')
and accountlines.borrowernumber = borrowers.borrowernumber";
@ -208,7 +202,6 @@ or accounttype ='W')
$i++;
}
$sth->finish;
$dbh->disconnect;
# print $query;
return(@results);
}
@ -216,7 +209,7 @@ or accounttype ='W')
# XXX - POD. Only used in stats.pl, which in turn is never used.
sub getcharges{
my($borrowerno,$timestamp)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $timestamp2=$timestamp-1;
my $query="Select * from accountlines where borrowernumber=$borrowerno
and timestamp = '$timestamp' and accounttype <> 'Pay' and
@ -232,7 +225,6 @@ sub getcharges{
$i++;
# }
}
$dbh->disconnect;
return(@results);
}
@ -240,7 +232,7 @@ sub getcharges{
# which is used.
sub Getpaidbranch{
my($date,$borrno)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="select * from statistics where type='payment' and datetime
>'$date' and borrowernumber='$borrno'";
my $sth=$dbh->prepare($query);
@ -248,14 +240,13 @@ sub Getpaidbranch{
# print $query;
my $data=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
return($data->{'branch'});
}
# XXX - POD. This is only used in reservereport.pl and
# reservereport.xls, neither of which is used.
sub unfilledreserves {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="select *,biblio.title from reserves,reserveconstraints,biblio,borrowers,biblioitems where found <> 'F' and cancellationdate
is NULL and biblio.biblionumber=reserves.biblionumber and
reserves.constrainttype='o'
@ -286,7 +277,6 @@ biblio.title,reserves.reservedate";
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,\@results);
}

View File

@ -22,7 +22,7 @@ use strict;
require Exporter;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
use C4::Database;
use C4::Context;
# set the version for version checking
$VERSION = 0.01;
@ -34,7 +34,7 @@ $VERSION = 0.01;
# never used. This function (and therefore this module) is probably
# obsolete.
sub stockreport {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my @results;
my $query="Select count(*) from items where homebranch='C'";
my $sth=$dbh->prepare($query);
@ -48,7 +48,6 @@ sub stockreport {
$count=$sth->fetchrow_hashref;
$results[1]="$count->{'count'}\t Foxton";
$sth->finish;
$dbh->disconnect;
return(@results);
}

View File

@ -19,14 +19,15 @@ package C4::test;
use strict;
require Exporter;
use C4::Database;
use C4::Context;
use C4::Catalogue;
our $dbh=&C4Connect;
our $dbh = C4::Context->dbh;
$dbh->do("delete from marc_subfield_table");
$dbh->do("delete from marc_blob_subfield");
&MARCaddSubfield(1,'001',1,'##','a',1,'1 - This is a value');
&MARCaddSubfield(1,'001',1,'##','b',1,'2 - This is another value');
# FIXME - Just use "a"x1024 to generate very long strings.
&MARCaddSubfield(1,'001',1,'##','c',1,"3 - This is a value very very long. I try to make it longer than 255 char. I need to add something else. will it be long enough now... I'm not sure. That's why i continue to add a few word to this very important sentence. Now I hope it will be enough... Oh, not it need some more characters. So i add stupid strings : xxxxxxxxxxxxxxx dddddddddddddddddddd eeeeeeeeeeeeeeeeeeeeeee rrrrrrrrrrrrrrrrrrr ffffffffffffffffff");
&MARCaddSubfield(1,'001',1,'##','d',1,"4 - This is another value very very long. I try to make it longer than 255 char. I need to add something else. will it be long enough now... I'm not sure. That's why i continue to add a few word to this very important sentence. Now I hope it will be enough... Oh, not it need some more characters. So i add stupid strings : xxxxxxxxxxxxxxx dddddddddddddddddddd eeeeeeeeeeeeeeeeeeeeeee rrrrrrrrrrrrrrrrrrr ffffffffffffffffff");
print "change 1\n";

188
ChangeLog
View File

@ -1,3 +1,191 @@
2002-10-05 Andrew Arensburger <arensb@baa.ooblick.com>
* C4/Output.pm, C4/Context.pm, C4/Biblio.pm: Merged in changes
from main branch.
* marc/viewmarc.pl: Added a FIXME comment.
* marc/viewmarc.pl: Oops! Stupid bug fix.
* marc/koha2marc: Removed a useless statement.
* moredetail.pl: Removed some obsolete commented-out code.
* updater/updatedatabase2.pl, updater/updatedatabase,
updater/thesaurus_create.pl, misc/fixborrower.pl, marc/test,
maint/shiftbib.pl, html-template/search.pl,
html-template/Search.pm, circ/circulation.pl, admin/itemtypes.pl,
admin/currency.pl, admin/categoryitem.pl, admin/categorie.pl,
admin/branches.pl, admin/aqbudget.pl,
acqui.simple/processz3950queue, acqui.simple/bulkmarcimport.pl,
acqui.simple/addbookslccn.pl, C4/Circulation/Returns.pm,
C4/Circulation/Renewals2.pm, C4/Circulation/Renewals.pm,
C4/Circulation/Main.pm, C4/Circulation/Issues.pm,
C4/Circulation/Fines.pm, C4/Circulation/Circ2.pm,
C4/Circulation/Borrower.pm, C4/Circulation/Borrissues.pm,
C4/test.pl, C4/Search.pm, C4/Reserves2.pm, C4/Print.pm,
C4/InterfaceCDK.pm, C4/Circmain.pm, C4/Biblio.pm, C4/Auth.pm,
C4/Acquisitions.pm, C4/Accounts.pm, stats2.pl, search.pl,
overdue.pl, bookcount.pl: Added a whole mess of FIXME comments.
* C4/Acquisitions.pm: Oops! Forgot to add "use C4::Context;"
* C4/Biblio.pm: Added some missing semicolons.
2002-10-03 Andrew Arensburger <arensb@baa.ooblick.com>
* telnet/doreturns.pl, telnet/borrwraper.pl: Use C4::Connect
instead of C4::Database, C4::Connect->dbh instead C4Connect.
Removed trailing whitespace, 'cos it was bugging me.
* C4/Database.pm: Added a FIXME comment.
* C4/Context.pm: A couple of bug fixes so it'll actually load.
* misc/tidyaccounts.pl, maint/catmaintain.pl: Removed useless "use
C4::Database;" line.
* acqui.simple/addbooks.pl, C4/Circulation/Renewals.pm,
C4/SimpleMarc.pm, C4/Circulation.pm, C4/Circmain.pm,
updatebiblio.pl, updatebibitem.pl, tidyaccounts.pl: Removed
useless "use C4::Database;" line.
* marc/MARCdetail.pl, html-template/search.pl,
html-template/moredetail.pl, html-template/detail.pl,
acqui.simple/marcimport.pl, C4/Output.pm, userpage.pl, search.pl,
moredetail.pl, detail.pl: Use C4::Connect instead of C4::Database,
C4::Connect->dbh instead C4Connect. Removed old code for reading
/etc/koha.conf.
* updater/updatedatabase2.pl, updater/updatedatabase,
updater/thesaurus_create.pl, sec/writeoff.pl, misc/makeformats.pl,
misc/makebaskets.pl, misc/fixrefs.pl, misc/fixorders.pl,
misc/fixcatalog.pl, misc/fixborrower.pl, misc/fines2.pl,
marc/viewmarc.pl, marc/updatedb2marc.pl, marc/test,
marc/koha2marc, marc/fill_usmarc.pl, maint/shiftbib.pl,
html-template/Search.pm, admin/systempreferences.pl,
admin/stopwords.pl, admin/printers.pl, admin/marctagstructure.pl,
admin/itemtypes.pl, admin/currency.pl, admin/categoryitem.pl,
admin/categorie.pl, admin/branches.pl, admin/aqbudget.pl,
admin/aqbookfund.pl, acqui.simple/viewmarc.pl,
acqui.simple/processz3950queue, acqui.simple/bulkmarcimport.pl,
acqui.simple/addbookslccn.pl, acqui/newbiblio.pl,
acqui/acquire.pl, C4/Circulation/Returns.pm,
C4/Circulation/Renewals2.pm, C4/Circulation/Main.pm,
C4/Circulation/Issues.pm, C4/Circulation/Fines.pm,
C4/Circulation/Circ2.pm, C4/Circulation/Borrower.pm,
C4/Circulation/Borrissues.pm, C4/test.pl, C4/Stock.pm,
C4/Stats.pm, C4/Security.pm, C4/Search.pm, C4/Reserves2.pm,
C4/Reserves.pm, C4/Maintainance.pm, C4/Koha.pm, C4/Groups.pm,
C4/Catalogue.pm, C4/BookShelves.pm, C4/Biblio.pm, C4/Auth.pm,
C4/Acquisitions.pm, C4/Accounts2.pm, C4/Accounts.pm,
updateitem.pl, updatecharges.pl, thesaurus_popup.pl, stats2.pl,
pay.pl, overdue.pl, moremember.pl, memberentry.pl, logout.pl,
insertjdata.pl, insertidata.pl, insertdata.pl, fixBranches.pl,
deletemem.pl, charges.pl, bookcount.pl: Use C4::Connect instead of
C4::Database, C4::Connect->dbh instead C4Connect.
2002-10-05 Andrew Arensburger <arensb@baa.ooblick.com>
arensb-context branch:
* marc/fill_usmarc.pl,
koha-tmpl/opac-tmpl/default/en/includes/opac-top.inc,
koha-tmpl/opac-tmpl/default/en/includes/opac-bottom.inc,
koha-tmpl/opac-tmpl/default/en/includes/members-top.inc,
koha-tmpl/opac-tmpl/default/en/opac-searchresults.tmpl,
koha-tmpl/opac-tmpl/default/en/opac-search.tmpl,
koha-tmpl/opac-tmpl/default/en/opac-main.tmpl,
koha-tmpl/opac-tmpl/default/en/opac-detail.tmpl, C4/Search.pm,
overdue.pl, moremember.pl, installer-lite.pl: Merged with head.
* C4/Output.pm, C4/Context.pm, C4/Biblio.pm: Merged in changes
from main branch.
* marc/viewmarc.pl: Added a FIXME comment.
* marc/viewmarc.pl: Oops! Stupid bug fix.
* marc/koha2marc: Removed a useless statement.
* moredetail.pl: Removed some obsolete commented-out code.
* updater/updatedatabase2.pl, updater/updatedatabase,
updater/thesaurus_create.pl, misc/fixborrower.pl, marc/test,
maint/shiftbib.pl, html-template/search.pl,
html-template/Search.pm, circ/circulation.pl, admin/itemtypes.pl,
admin/currency.pl, admin/categoryitem.pl, admin/categorie.pl,
admin/branches.pl, admin/aqbudget.pl,
acqui.simple/processz3950queue, acqui.simple/bulkmarcimport.pl,
acqui.simple/addbookslccn.pl, C4/Circulation/Returns.pm,
C4/Circulation/Renewals2.pm, C4/Circulation/Renewals.pm,
C4/Circulation/Main.pm, C4/Circulation/Issues.pm,
C4/Circulation/Fines.pm, C4/Circulation/Circ2.pm,
C4/Circulation/Borrower.pm, C4/Circulation/Borrissues.pm,
C4/test.pl, C4/Search.pm, C4/Reserves2.pm, C4/Print.pm,
C4/InterfaceCDK.pm, C4/Circmain.pm, C4/Biblio.pm, C4/Auth.pm,
C4/Acquisitions.pm, C4/Accounts.pm, stats2.pl, search.pl,
overdue.pl, bookcount.pl: Added a whole mess of FIXME comments.
* C4/Acquisitions.pm: Oops! Forgot to add "use C4::Context;"
* C4/Biblio.pm: Added some missing semicolons.
2002-10-03 Andrew Arensburger <arensb@baa.ooblick.com>
arensb-context branch:
* telnet/doreturns.pl, telnet/borrwraper.pl: Use C4::Connect
instead of C4::Database, C4::Connect->dbh instead C4Connect.
Removed trailing whitespace, 'cos it was bugging me.
* C4/Database.pm: Added a FIXME comment.
* C4/Context.pm: A couple of bug fixes so it'll actually load.
* misc/tidyaccounts.pl, maint/catmaintain.pl: Removed useless "use
C4::Database;" line.
* acqui.simple/addbooks.pl, C4/Circulation/Renewals.pm,
C4/SimpleMarc.pm, C4/Circulation.pm, C4/Circmain.pm,
updatebiblio.pl, updatebibitem.pl, tidyaccounts.pl: Removed
useless "use C4::Database;" line.
* marc/MARCdetail.pl, html-template/search.pl,
html-template/moredetail.pl, html-template/detail.pl,
acqui.simple/marcimport.pl, C4/Output.pm, userpage.pl, search.pl,
moredetail.pl, detail.pl: Use C4::Connect instead of C4::Database,
C4::Connect->dbh instead C4Connect. Removed old code for reading
/etc/koha.conf.
* updater/updatedatabase2.pl, updater/updatedatabase,
updater/thesaurus_create.pl, sec/writeoff.pl, misc/makeformats.pl,
misc/makebaskets.pl, misc/fixrefs.pl, misc/fixorders.pl,
misc/fixcatalog.pl, misc/fixborrower.pl, misc/fines2.pl,
marc/viewmarc.pl, marc/updatedb2marc.pl, marc/test,
marc/koha2marc, marc/fill_usmarc.pl, maint/shiftbib.pl,
html-template/Search.pm, admin/systempreferences.pl,
admin/stopwords.pl, admin/printers.pl, admin/marctagstructure.pl,
admin/itemtypes.pl, admin/currency.pl, admin/categoryitem.pl,
admin/categorie.pl, admin/branches.pl, admin/aqbudget.pl,
admin/aqbookfund.pl, acqui.simple/viewmarc.pl,
acqui.simple/processz3950queue, acqui.simple/bulkmarcimport.pl,
acqui.simple/addbookslccn.pl, acqui/newbiblio.pl,
acqui/acquire.pl, C4/Circulation/Returns.pm,
C4/Circulation/Renewals2.pm, C4/Circulation/Main.pm,
C4/Circulation/Issues.pm, C4/Circulation/Fines.pm,
C4/Circulation/Circ2.pm, C4/Circulation/Borrower.pm,
C4/Circulation/Borrissues.pm, C4/test.pl, C4/Stock.pm,
C4/Stats.pm, C4/Security.pm, C4/Search.pm, C4/Reserves2.pm,
C4/Reserves.pm, C4/Maintainance.pm, C4/Koha.pm, C4/Groups.pm,
C4/Catalogue.pm, C4/BookShelves.pm, C4/Biblio.pm, C4/Auth.pm,
C4/Acquisitions.pm, C4/Accounts2.pm, C4/Accounts.pm,
updateitem.pl, updatecharges.pl, thesaurus_popup.pl, stats2.pl,
pay.pl, overdue.pl, moremember.pl, memberentry.pl, logout.pl,
insertjdata.pl, insertidata.pl, insertdata.pl, fixBranches.pl,
deletemem.pl, charges.pl, bookcount.pl: Use C4::Connect instead of
C4::Database, C4::Connect->dbh instead C4Connect.
2002-10-02 Andrew Arensburger <arensb@nerafo.umd.edu>
* C4/Context.pm (added) Module for reading the config file and

View File

@ -31,7 +31,6 @@
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
use C4::Database;
use CGI;
use strict;
use C4::Catalogue;

View File

@ -31,16 +31,16 @@
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
use C4::Database;
use CGI;
use strict;
use CGI;
use C4::Context;
use C4::Catalogue;
use C4::Biblio;
use C4::Output;
use C4::Circulation::Circ2;
my $input = new CGI;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $lccn=$input->param('lccn');
my $q_lccn=$dbh->quote($lccn);
@ -178,7 +178,7 @@ EOF
exit;
}
# FIXME - There's already a &C4::Biblio::newbiblioitem.
sub newbiblioitem {
my $biblionumber=$input->param('biblionumber');
my $volume=$input->param('volume');

View File

@ -45,14 +45,14 @@ my $lc1='#dddddd';
my $lc2='#ddaaaa';
use C4::Database;
use C4::Context;
use CGI;
use DBI;
#use strict;
use C4::Catalogue;
use C4::Biblio;
use C4::Output;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $userid=$ENV{'REMOTE_USER'};
%tagtext = (
'001' => 'Control number',
@ -113,7 +113,6 @@ my $userid=$ENV{'REMOTE_USER'};
);
my $dbh=C4Connect;
if ($file) {
open (F, "$file");
my $data=<F>;
@ -143,10 +142,10 @@ RECORD:
$directory=$field;
my $itemcounter=1;
$counter=0;
while ($item=substr($directory,0,12)) {
while ($item=substr($directory,0,12)) { # FIXME - $item never used
$tag=substr($directory,0,3);
$length=substr($directory,3,4);
$start=substr($directory,7,6);
$length=substr($directory,3,4); # FIXME - Unused
$start=substr($directory,7,6); # FIXME - Unused
$directory=substr($directory,12);
$tag{$counter}=$tag;
$counter++;
@ -454,9 +453,9 @@ RECORD:
$subclass=uc(substr($cleanauthor,0,3));
my $q_subclass=$dbh->quote($subclass);
my $q_publicationyear=$dbh->quote($publicationyear);
my $q_publishercode=$dbh->quote($publishercode);
my $q_volumedate=$dbh->quote($volumedate);
my $q_volumeddesc=$dbh->quote($volumeddesc);
my $q_publishercode=$dbh->quote($publishercode); # FIXME - $publishercode undefined
my $q_volumedate=$dbh->quote($volumedate); # FIXME - $volumedate undefined
my $q_volumeddesc=$dbh->quote($volumeddesc); # FIXME - $volumeddesc undefined
my $q_illus=$dbh->quote($illustrator);
my $q_pages=$dbh->quote($pages);
my $q_notes=$dbh->quote($note);
@ -495,6 +494,7 @@ RECORD:
my $q_homebranch="'$branchname'";
my $q_notes="''";
#my $replacementprice=0;
# FIXME - There's already a $sth in this scope.
my $sth=$dbh->prepare("select max(itemnumber) from items");
$sth->execute;
my ($itemnumber) = $sth->fetchrow;
@ -520,4 +520,3 @@ BARCODE:
}
}
}
$dbh->disconnect;

View File

@ -34,6 +34,7 @@ use CGI;
use DBI;
# Koha modules used
use C4::Context;
use C4::Database;
use C4::Acquisitions;
use C4::Output;
@ -47,24 +48,8 @@ use HTML::Template;
#------------------
# Constants
my %configfile;
open (KC, "/etc/koha.conf");
while (<KC>) {
chomp;
(next) if (/^\s*#/);
if (/(.*)\s*=\s*(.*)/) {
my $variable=$1;
my $value=$2;
# Clean up white space at beginning and end
$variable=~s/^\s*//g;
$variable=~s/\s*$//g;
$value=~s/^\s*//g;
$value=~s/\s*$//g;
$configfile{$variable}=$value;
}
}
my $includes=$configfile{'includes'};
($includes) || ($includes="/usr/local/www/hdl/htdocs/includes");
my $includes = C4::Context->config('includes') ||
"/usr/local/www/hdl/htdocs/includes";
# HTML colors for alternating lines
my $lc1='#dddddd';
@ -77,7 +62,7 @@ my $lc2='#ddaaaa';
my $userid=$ENV{'REMOTE_USER'};
my $input = new CGI;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
#-------------
# Display output
@ -258,6 +243,7 @@ sub ListFileRecords {
my $recordsource;
my $record;
my ($numrecords,$resultsid,$data,$startdate,$enddate);
# FIXME - there's already a $data a few lines above.
requireDBI($dbh,"ListFileRecords");
@ -550,6 +536,7 @@ sub z3950menu {
my $sth=$dbh->prepare("select id,name,checked
from z3950servers
order by rank");
# FIXME - There's already a $sth in this function.
$sth->execute;
my $serverlist='';
while (my ($id, $name, $checked) = $sth->fetchrow) {
@ -751,6 +738,7 @@ sub AcceptBiblioitem {
my $numrecord = $input->param('numrecord');
if ($numrecord) {
for (my $i==1;$i<$numrecord;$i++) {
# FIXME - This "==" was supposed to be a "=", right?
$record=$file->next;
}
} else {
@ -1005,6 +993,15 @@ sub FormatMarcText {
#---------------
# $Log$
# Revision 1.14 2002/10/05 09:56:14 arensb
# Merged with arensb-context branch: use C4::Context->dbh instead of
# &C4Connect, and generally prefer C4::Context over C4::Database.
#
# Revision 1.13.2.1 2002/10/04 02:52:50 arensb
# Use C4::Connect instead of C4::Database, C4::Connect->dbh instead
# C4Connect.
# Removed old code for reading /etc/koha.conf.
#
# Revision 1.13 2002/08/14 18:12:52 tonnesen
# Added copyright statement to all .pl and .pm files
#

View File

@ -1,5 +1,5 @@
#!/usr/bin/perl
use C4::Database;
use C4::Context;
use DBI;
#use strict;
use C4::Acquisitions;
@ -26,7 +26,7 @@ if ($< == 0) {
}
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("update z3950results set active=0");
$sth->execute;
@ -99,7 +99,7 @@ while (1) {
#$sth->finish;
#$sti->finish;
#$dbh->disconnect;
my $dbi=C4Connect;
my $dbi = C4::Context->dbh;
my ($name, $server, $database, $user, $password) = split(/\//, $serverinfo, 5);
$server=~/(.*)\:(\d+)/;
my $servername=$1;
@ -211,10 +211,10 @@ while (1) {
}
}
}
# FIXME - There's already a $stj in this scope
my $stj=$dbi->prepare("update z3950results set active=0 where id=$resultsid");
$stj->execute;
eval {$stj->finish};
$dbi->disconnect;
print " $server done.\n";
exit;
sub pe {

View File

@ -26,16 +26,16 @@
my $starttime=gettime();
use C4::Database;
use CGI;
use strict;
use CGI;
use C4::Context;
use C4::Catalogue;
use C4::Biblio;
use C4::Output;
my $input = new CGI;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $fields;
marcdefs();

View File

@ -21,13 +21,13 @@
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
use strict;
use CGI;
use C4::Context;
use C4::Catalogue;
use C4::Biblio;
use C4::Output;
use C4::Database;
use C4::Search;
use CGI;
use strict;
my $input=new CGI;
print $input->header();
@ -113,7 +113,7 @@ Shopping Basket For: $booksellers[0]->{'name'}
EOP
;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select itemtype,description from itemtypes order by description";
my $sth=$dbh->prepare($query);
$sth->execute;
@ -125,7 +125,6 @@ while (my $data=$sth->fetchrow_hashref){
}
}
$sth->finish;
$dbh->disconnect;
print <<EOP
</select>
@ -174,14 +173,13 @@ EOP
my %systemprefs=systemprefs();
if ($systemprefs{'autoBarcode'} eq '1') {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select barcode from items order by barcode desc";
my $sth=$dbh->prepare($query);
$sth->execute;
my $data=$sth->fetchrow_hashref;
print $data->{'barcode'}+1;
$sth->finish;
$dbh->disconnect;
}
print <<EOP

View File

@ -21,13 +21,13 @@
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
use strict;
use CGI;
use C4::Context;
use C4::Catalogue;
use C4::Biblio;
use C4::Output;
use C4::Search;
use C4::Database;
use CGI;
use strict;
my $input=new CGI;
print $input->header();
@ -176,7 +176,7 @@ Shopping Basket For: $booksellers[0]->{'name'}
printend
;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select itemtype,description from itemtypes order by description";
my $sth=$dbh->prepare($query);
$sth->execute;
@ -189,7 +189,6 @@ while (my $data2=$sth->fetchrow_hashref){
}
}
$sth->finish;
$dbh->disconnect;
print <<printend
</select>
@ -234,14 +233,13 @@ printend
my %systemprefs=systemprefs();
if ($systemprefs{'autoBarcode'} eq '1') {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select barcode from items order by barcode desc";
my $sth=$dbh->prepare($query);
$sth->execute;
my $data=$sth->fetchrow_hashref;
print $data->{'barcode'}+1;
$sth->finish;
$dbh->disconnect;
}
print <<printend

View File

@ -38,14 +38,14 @@
# Suite 330, Boston, MA 02111-1307 USA
use strict;
use C4::Output;
use CGI;
use C4::Context;
use C4::Output;
use C4::Search;
use C4::Database;
sub StringSearch {
my ($env,$searchstring,$type)=@_;
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
$searchstring=~ s/\'/\\\'/g;
my @data=split(' ',$searchstring);
my $count=@data;
@ -60,7 +60,6 @@ sub StringSearch {
}
# $sth->execute;
$sth->finish;
$dbh->disconnect;
return ($cnt,\@results);
}
@ -84,7 +83,7 @@ if ($op eq 'add_form') {
#---- if primkey exists, it's a modify action, so read values to modify...
my $data;
if ($bookfundid) {
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("select bookfundid,bookfundname,bookfundgroup from aqbookfund where bookfundid='$bookfundid'");
$sth->execute;
$data=$sth->fetchrow_hashref;
@ -170,7 +169,7 @@ print "</table>";
################## ADD_VALIDATE ##################################
# called by add_form, used to insert/modify data in DB
} elsif ($op eq 'add_validate') {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query = "replace aqbookfund (bookfundid,bookfundname,bookfundgroup) values (";
$query.= $dbh->quote($input->param('bookfundid')).",";
$query.= $dbh->quote($input->param('bookfundname')).",";
@ -186,7 +185,7 @@ print "</table>";
################## DELETE_CONFIRM ##################################
# called by default form, used to confirm deletion of data in DB
} elsif ($op eq 'delete_confirm') {
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
# my $sth=$dbh->prepare("select count(*) as total from categoryitem where itemtype='$itemtype'");
# $sth->execute;
# my $total = $sth->fetchrow_hashref;
@ -211,7 +210,7 @@ print "</table>";
################## DELETE_CONFIRMED ##################################
# called by delete_confirm, used to effectively confirm deletion of data in DB
} elsif ($op eq 'delete_confirmed') {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $bookfundid=uc($input->param('bookfundid'));
my $query = "delete from aqbookfund where bookfundid='$bookfundid'";
my $sth=$dbh->prepare($query);

View File

@ -38,14 +38,14 @@
# Suite 330, Boston, MA 02111-1307 USA
use strict;
use C4::Output;
use CGI;
use C4::Context;
use C4::Output;
use C4::Search;
use C4::Database;
sub StringSearch {
my ($env,$searchstring,$type)=@_;
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
$searchstring=~ s/\'/\\\'/g;
my @data=split(' ',$searchstring);
my $count=@data;
@ -60,7 +60,6 @@ sub StringSearch {
}
# $sth->execute;
$sth->finish;
$dbh->disconnect;
return ($cnt,\@results);
}
@ -84,7 +83,7 @@ if ($op eq 'add_form') {
#---- if primkey exists, it's a modify action, so read values to modify...
my $data;
if ($bookfundid) {
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $query="select aqbookfund.bookfundid,startdate,enddate,budgetamount,bookfundname from aqbudget,aqbookfund where aqbudget.bookfundid=aqbookfund.bookfundid and aqbookfund.bookfundid='$bookfundid'";
# print $query;
my $sth=$dbh->prepare($query);
@ -174,7 +173,7 @@ print "</table>";
################## ADD_VALIDATE ##################################
# called by add_form, used to insert/modify data in DB
} elsif ($op eq 'add_validate') {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query = "replace aqbudget (bookfundid,startdate,enddate,budgetamount) values (";
$query.= $dbh->quote($input->param('bookfundid')).",";
$query.= $dbh->quote($input->param('startdate')).",";
@ -191,7 +190,7 @@ print "</table>";
################## DELETE_CONFIRM ##################################
# called by default form, used to confirm deletion of data in DB
} elsif ($op eq 'delete_confirm') {
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
# my $sth=$dbh->prepare("select count(*) as total from categoryitem where itemtype='$itemtype'");
# $sth->execute;
# my $total = $sth->fetchrow_hashref;
@ -217,7 +216,7 @@ print "</table>";
################## DELETE_CONFIRMED ##################################
# called by delete_confirm, used to effectively confirm deletion of data in DB
} elsif ($op eq 'delete_confirmed') {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $bookfundid=uc($input->param('bookfundid'));
my $query = "delete from aqbudget where bookfundid='$bookfundid'";
my $sth=$dbh->prepare($query);
@ -260,7 +259,7 @@ printend
$results->[$i]{'startdate'},$results->[$i]{'enddate'},
$results->[$i]{'budgetamount'},
mklink("$script_name?op=add_form&bookfundid=".$results->[$i]{'bookfundid'},'Edit'),
mklink("$script_name?op=delete_confirm&bookfundid=".$results->[$i]{'bookfundid'},'Delete',''));
mklink("$script_name?op=delete_confirm&bookfundid=".$results->[$i]{'bookfundid'},'Delete','')); # FIXME - Too many arguments. Drop the 3d one?
}
print mktableft;
print "<form action='$script_name' method=post>";

View File

@ -23,8 +23,8 @@
use strict;
use CGI;
use C4::Context;
use C4::Output;
use C4::Database;
# Fixed variables
my $linecolor1='#ffffcc';
@ -266,7 +266,7 @@ sub getbranchinfo {
# returns a reference to an array of hashes containing branches,
my ($branchcode) = @_;
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $query;
if ($branchcode) {
my $bc = $dbh->quote($branchcode);
@ -290,14 +290,13 @@ sub getbranchinfo {
push(@results, $data);
}
$sth->finish;
$dbh->disconnect;
return \@results;
}
sub getcategoryinfo {
# returns a reference to an array of hashes containing branches,
my ($catcode) = @_;
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $query;
if ($catcode) {
my $cc = $dbh->quote($catcode);
@ -312,14 +311,13 @@ sub getcategoryinfo {
push(@results, $data);
}
$sth->finish;
$dbh->disconnect;
return \@results;
}
sub setbranchinfo {
# sets the data from the editbranch form, and writes to the database...
my ($data) = @_;
my $dbh=&C4Connect;
my $dbh = C4::Context->dbh;
my $query = "replace branches (branchcode,branchname,branchaddress1,branchaddress2,branchaddress3,branchphone,branchfax,branchemail) values (";
my $tmp;
$tmp = $data->{'branchcode'}; $query.= $dbh->quote($tmp).",";
@ -333,7 +331,6 @@ sub setbranchinfo {
my $sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
$dbh->disconnect;
# sort out the categories....
my @checkedcats;
my $cats = getcategoryinfo();
@ -359,7 +356,8 @@ sub setbranchinfo {
push(@addcats, $ccat);
}
}
my $dbh=&C4Connect;
# FIXME - There's already a $dbh in this scope.
my $dbh = C4::Context->dbh;
foreach my $cat (@addcats) {
my $query = "insert into branchrelations (branchcode, categorycode) values('$branchcode', '$cat')";
my $sth = $dbh->prepare($query);
@ -372,29 +370,26 @@ sub setbranchinfo {
$sth->execute;
$sth->finish;
}
$dbh->disconnect;
}
sub deletebranch {
# delete branch...
my ($branchcode) = @_;
my $query = "delete from branches where branchcode = '$branchcode'";
my $dbh=&C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
sub checkdatabasefor {
# check to see if the branchcode is being used in the database somewhere....
my ($branchcode) = @_;
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("select count(*) from items where holdingbranch='$branchcode' or homebranch='$branchcode'");
$sth->execute;
my ($total) = $sth->fetchrow_array;
$sth->finish;
$dbh->disconnect;
my $message;
if ($total) {
$message = "Branch cannot be deleted because there are $total items using that branch.";

View File

@ -37,14 +37,14 @@
# Suite 330, Boston, MA 02111-1307 USA
use strict;
use C4::Output;
use CGI;
use C4::Context;
use C4::Output;
use C4::Search;
use C4::Database;
sub StringSearch {
my ($env,$searchstring,$type)=@_;
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
$searchstring=~ s/\'/\\\'/g;
my @data=split(' ',$searchstring);
my $count=@data;
@ -59,7 +59,6 @@ sub StringSearch {
}
# $sth->execute;
$sth->finish;
$dbh->disconnect;
return ($cnt,\@results);
}
@ -80,7 +79,7 @@ if ($op eq 'add_form') {
#---- if primkey exists, it's a modify action, so read values to modify...
my $data;
if ($categorycode) {
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("select categorycode,description,enrolmentperiod,upperagelimit,dateofbirthrequired,finetype,bulk,enrolmentfee,issuelimit,reservefee,overduenoticerequired from categories where categorycode='$categorycode'");
$sth->execute;
$data=$sth->fetchrow_hashref;
@ -178,7 +177,7 @@ print "</table>";
################## ADD_VALIDATE ##################################
# called by add_form, used to insert/modify data in DB
} elsif ($op eq 'add_validate') {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query = "replace categories (categorycode,description,enrolmentperiod,upperagelimit,dateofbirthrequired,finetype,bulk,enrolmentfee,issuelimit,reservefee,overduenoticerequired) values (";
$query.= $dbh->quote($input->param('categorycode')).",";
$query.= $dbh->quote($input->param('description')).",";
@ -202,12 +201,13 @@ print "</table>";
################## DELETE_CONFIRM ##################################
# called by default form, used to confirm deletion of data in DB
} elsif ($op eq 'delete_confirm') {
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("select count(*) as total from categoryitem where categorycode='$categorycode'");
$sth->execute;
my $total = $sth->fetchrow_hashref;
print "TOTAL : $categorycode : $total->{'total'}<br>";
$sth->finish;
# FIXME - there's already a $sth in this scope.
my $sth=$dbh->prepare("select categorycode,description,enrolmentperiod,upperagelimit,dateofbirthrequired,finetype,bulk,enrolmentfee,issuelimit,reservefee,overduenoticerequired from categories where categorycode='$categorycode'");
$sth->execute;
my $data=$sth->fetchrow_hashref;
@ -236,7 +236,7 @@ print "</table>";
################## DELETE_CONFIRMED ##################################
# called by delete_confirm, used to effectively confirm deletion of data in DB
} elsif ($op eq 'delete_confirmed') {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $categorycode=uc($input->param('categorycode'));
my $query = "delete from categories where categorycode='$categorycode'";
my $sth=$dbh->prepare($query);

View File

@ -38,14 +38,14 @@
# Suite 330, Boston, MA 02111-1307 USA
use strict;
use C4::Output;
use CGI;
use C4::Context;
use C4::Output;
use C4::Search;
use C4::Database;
sub StringSearch {
my ($env,$searchstring,$type)=@_;
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
$searchstring=~ s/\'/\\\'/g;
my @data=split(' ',$searchstring);
my $count=@data;
@ -60,7 +60,6 @@ sub StringSearch {
}
# $sth->execute;
$sth->finish;
$dbh->disconnect;
return ($cnt,\@results);
}
@ -81,7 +80,7 @@ if ($op eq 'add_form') {
#---- if primkey exists, it's a modify action, so read values to modify...
my $data;
if ($categorycode) {
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("select categorycode,description,enrolmentperiod,upperagelimit,dateofbirthrequired,finetype,bulk,enrolmentfee,issuelimit,reservefee,overduenoticerequired from categories where categorycode='$categorycode'");
$sth->execute;
$data=$sth->fetchrow_hashref;
@ -179,7 +178,7 @@ print "</table>";
################## ADD_VALIDATE ##################################
# called by add_form, used to insert/modify data in DB
} elsif ($op eq 'add_validate') {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query = "replace categories (categorycode,description,enrolmentperiod,upperagelimit,dateofbirthrequired,finetype,bulk,enrolmentfee,issuelimit,reservefee,overduenoticerequired) values (";
$query.= $dbh->quote($input->param('categorycode')).",";
$query.= $dbh->quote($input->param('description')).",";
@ -203,12 +202,13 @@ print "</table>";
################## DELETE_CONFIRM ##################################
# called by default form, used to confirm deletion of data in DB
} elsif ($op eq 'delete_confirm') {
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("select count(*) as total from categoryitem where categorycode='$categorycode'");
$sth->execute;
my $total = $sth->fetchrow_hashref;
print "TOTAL : $categorycode : $total->{'total'}<br>";
$sth->finish;
# FIXME - There's already a $sth in this scope.
my $sth=$dbh->prepare("select categorycode,description,enrolmentperiod,upperagelimit,dateofbirthrequired,finetype,bulk,enrolmentfee,issuelimit,reservefee,overduenoticerequired from categories where categorycode='$categorycode'");
$sth->execute;
my $data=$sth->fetchrow_hashref;
@ -237,7 +237,7 @@ print "</table>";
################## DELETE_CONFIRMED ##################################
# called by delete_confirm, used to effectively confirm deletion of data in DB
} elsif ($op eq 'delete_confirmed') {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $categorycode=uc($input->param('categorycode'));
my $query = "delete from categories where categorycode='$categorycode'";
my $sth=$dbh->prepare($query);

View File

@ -38,14 +38,14 @@
# Suite 330, Boston, MA 02111-1307 USA
use strict;
use C4::Output;
use CGI;
use C4::Context;
use C4::Output;
use C4::Search;
use C4::Database;
sub StringSearch {
my ($env,$searchstring,$type)=@_;
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
$searchstring=~ s/\'/\\\'/g;
my @data=split(' ',$searchstring);
my $count=@data;
@ -60,7 +60,6 @@ sub StringSearch {
}
# $sth->execute;
$sth->finish;
$dbh->disconnect;
return ($cnt,\@results);
}
@ -88,7 +87,7 @@ if ($op eq 'add_form') {
#---- if primkey exists, it's a modify action, so read values to modify...
my $data;
if ($searchfield) {
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("select currency,rate from currency where currency='$searchfield'");
$sth->execute;
$data=$sth->fetchrow_hashref;
@ -172,7 +171,7 @@ printend
################## ADD_VALIDATE ##################################
# called by add_form, used to insert/modify data in DB
} elsif ($op eq 'add_validate') {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query = "replace currency (currency,rate) values (";
$query.= $dbh->quote($input->param('currency')).",";
$query.= $dbh->quote($input->param('rate')).")";
@ -187,11 +186,12 @@ printend
################## DELETE_CONFIRM ##################################
# called by default form, used to confirm deletion of data in DB
} elsif ($op eq 'delete_confirm') {
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("select count(*) as total from aqbooksellers where currency='$searchfield'");
$sth->execute;
my $total = $sth->fetchrow_hashref;
$sth->finish;
# FIXME - There's already a $sth in this scope.
my $sth=$dbh->prepare($reqsel);
$sth->execute;
my $data=$sth->fetchrow_hashref;
@ -211,7 +211,7 @@ printend
################## DELETE_CONFIRMED ##################################
# called by delete_confirm, used to effectively confirm deletion of data in DB
} elsif ($op eq 'delete_confirmed') {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
# my $searchfield=$input->param('branchcode');
my $sth=$dbh->prepare($reqdel);
$sth->execute;

View File

@ -38,14 +38,14 @@
# Suite 330, Boston, MA 02111-1307 USA
use strict;
use C4::Output;
use CGI;
use C4::Context;
use C4::Output;
use C4::Search;
use C4::Database;
sub StringSearch {
my ($env,$searchstring,$type)=@_;
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
$searchstring=~ s/\'/\\\'/g;
my @data=split(' ',$searchstring);
my $count=@data;
@ -60,7 +60,6 @@ sub StringSearch {
}
# $sth->execute;
$sth->finish;
$dbh->disconnect;
return ($cnt,\@results);
}
@ -84,7 +83,7 @@ if ($op eq 'add_form') {
#---- if primkey exists, it's a modify action, so read values to modify...
my $data;
if ($itemtype) {
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("select itemtype,description,loanlength,renewalsallowed,rentalcharge from itemtypes where itemtype='$itemtype'");
$sth->execute;
$data=$sth->fetchrow_hashref;
@ -183,7 +182,7 @@ print "</table>";
################## ADD_VALIDATE ##################################
# called by add_form, used to insert/modify data in DB
} elsif ($op eq 'add_validate') {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query = "replace itemtypes (itemtype,description,loanlength,renewalsallowed,rentalcharge) values (";
$query.= $dbh->quote($input->param('itemtype')).",";
$query.= $dbh->quote($input->param('description')).",";
@ -205,11 +204,12 @@ print "</table>";
################## DELETE_CONFIRM ##################################
# called by default form, used to confirm deletion of data in DB
} elsif ($op eq 'delete_confirm') {
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("select count(*) as total from categoryitem where itemtype='$itemtype'");
$sth->execute;
my $total = $sth->fetchrow_hashref;
$sth->finish;
# FIXME - There's already a $sth in this scope.
my $sth=$dbh->prepare("select itemtype,description,loanlength,renewalsallowed,rentalcharge from itemtypes where itemtype='$itemtype'");
$sth->execute;
my $data=$sth->fetchrow_hashref;
@ -232,7 +232,7 @@ print "</table>";
################## DELETE_CONFIRMED ##################################
# called by delete_confirm, used to effectively confirm deletion of data in DB
} elsif ($op eq 'delete_confirmed') {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $itemtype=uc($input->param('itemtype'));
my $query = "delete from itemtypes where itemtype='$itemtype'";
my $sth=$dbh->prepare($query);

View File

@ -19,14 +19,14 @@
# Suite 330, Boston, MA 02111-1307 USA
use strict;
use C4::Output;
use CGI;
use C4::Context;
use C4::Output;
use C4::Search;
use C4::Database;
sub StringSearch {
my ($env,$searchstring,$type)=@_;
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
$searchstring=~ s/\'/\\\'/g;
my @data=split(' ',$searchstring);
my $count=@data;
@ -41,7 +41,6 @@ sub StringSearch {
}
# $sth->execute;
$sth->finish;
$dbh->disconnect;
return ($cnt,\@results);
}
@ -68,7 +67,7 @@ if ($op eq 'add_form') {
#---- if primkey exists, it's a modify action, so read values to modify...
my $data;
if ($searchfield) {
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory from marc_tag_structure where $pkfield='$searchfield'");
$sth->execute;
$data=$sth->fetchrow_hashref;
@ -158,7 +157,7 @@ printend
################## ADD_VALIDATE ##################################
# called by add_form, used to insert/modify data in DB
} elsif ($op eq 'add_validate') {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query = "replace marc_tag_structure (tagfield,liblibrarian,libopac,repeatable,mandatory) values (";
$query.= $dbh->quote($input->param('tagfield')).",";
$query.= $dbh->quote($input->param('liblibrarian')).",";
@ -176,7 +175,7 @@ printend
################## DELETE_CONFIRM ##################################
# called by default form, used to confirm deletion of data in DB
} elsif ($op eq 'delete_confirm') {
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare($reqsel);
$sth->execute;
my $data=$sth->fetchrow_hashref;
@ -191,7 +190,7 @@ printend
################## DELETE_CONFIRMED ##################################
# called by delete_confirm, used to effectively confirm deletion of data in DB
} elsif ($op eq 'delete_confirmed') {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
# my $searchfield=$input->param('branchcode');
my $sth=$dbh->prepare($reqdel);
$sth->execute;

View File

@ -38,14 +38,14 @@
# Suite 330, Boston, MA 02111-1307 USA
use strict;
use C4::Output;
use CGI;
use C4::Context;
use C4::Output;
use C4::Search;
use C4::Database;
sub StringSearch {
my ($env,$searchstring,$type)=@_;
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
$searchstring=~ s/\'/\\\'/g;
my @data=split(' ',$searchstring);
my $count=@data;
@ -60,7 +60,6 @@ sub StringSearch {
}
# $sth->execute;
$sth->finish;
$dbh->disconnect;
return ($cnt,\@results);
}
@ -88,7 +87,7 @@ if ($op eq 'add_form') {
#---- if primkey exists, it's a modify action, so read values to modify...
my $data;
if ($searchfield) {
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("select printername,printqueue,printtype from printers where printername='$searchfield'");
$sth->execute;
$data=$sth->fetchrow_hashref;
@ -173,7 +172,7 @@ printend
################## ADD_VALIDATE ##################################
# called by add_form, used to insert/modify data in DB
} elsif ($op eq 'add_validate') {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query = "replace printers (printername,printqueue,printtype) values (";
$query.= $dbh->quote($input->param('printername')).",";
$query.= $dbh->quote($input->param('printqueue')).",";
@ -189,7 +188,7 @@ printend
################## DELETE_CONFIRM ##################################
# called by default form, used to confirm deletion of data in DB
} elsif ($op eq 'delete_confirm') {
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare($reqsel);
$sth->execute;
my $data=$sth->fetchrow_hashref;
@ -205,7 +204,7 @@ printend
################## DELETE_CONFIRMED ##################################
# called by delete_confirm, used to effectively confirm deletion of data in DB
} elsif ($op eq 'delete_confirmed') {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
# my $searchfield=$input->param('branchcode');
my $sth=$dbh->prepare($reqdel);
$sth->execute;

View File

@ -38,14 +38,14 @@
# Suite 330, Boston, MA 02111-1307 USA
use strict;
use C4::Output;
use CGI;
use C4::Context;
use C4::Output;
use C4::Search;
use C4::Database;
sub StringSearch {
my ($env,$searchstring,$type)=@_;
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
$searchstring=~ s/\'/\\\'/g;
my @data=split(' ',$searchstring);
my $count=@data;
@ -60,7 +60,6 @@ sub StringSearch {
}
# $sth->execute;
$sth->finish;
$dbh->disconnect;
return ($cnt,\@results);
}
@ -87,7 +86,7 @@ if ($op eq 'add_form') {
#---- if primkey exists, it's a modify action, so read values to modify...
my $data;
if ($searchfield) {
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("select word from stopwords where word='$searchfield'");
$sth->execute;
$data=$sth->fetchrow_hashref;
@ -167,7 +166,7 @@ printend
################## ADD_VALIDATE ##################################
# called by add_form, used to insert/modify data in DB
} elsif ($op eq 'add_validate') {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query = "replace stopwords (word) values (";
$query.= $dbh->quote($input->param('word')).")";
my $sth=$dbh->prepare($query);
@ -181,7 +180,7 @@ printend
################## DELETE_CONFIRM ##################################
# called by default form, used to confirm deletion of data in DB
} elsif ($op eq 'delete_confirm') {
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare($reqsel);
$sth->execute;
my $data=$sth->fetchrow_hashref;
@ -195,7 +194,7 @@ printend
################## DELETE_CONFIRMED ##################################
# called by delete_confirm, used to effectively confirm deletion of data in DB
} elsif ($op eq 'delete_confirmed') {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
# my $searchfield=$input->param('branchcode');
my $sth=$dbh->prepare($reqdel);
$sth->execute;

View File

@ -38,14 +38,14 @@
# Suite 330, Boston, MA 02111-1307 USA
use strict;
use C4::Output;
use CGI;
use C4::Context;
use C4::Output;
use C4::Search;
use C4::Database;
sub StringSearch {
my ($env,$searchstring,$type)=@_;
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
$searchstring=~ s/\'/\\\'/g;
my @data=split(' ',$searchstring);
my $count=@data;
@ -60,7 +60,6 @@ sub StringSearch {
}
# $sth->execute;
$sth->finish;
$dbh->disconnect;
return ($cnt,\@results);
}
@ -87,7 +86,7 @@ if ($op eq 'add_form') {
#---- if primkey exists, it's a modify action, so read values to modify...
my $data;
if ($searchfield) {
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("select variable,value,explanation from systempreferences where variable='$searchfield'");
$sth->execute;
$data=$sth->fetchrow_hashref;
@ -172,7 +171,7 @@ printend
################## ADD_VALIDATE ##################################
# called by add_form, used to insert/modify data in DB
} elsif ($op eq 'add_validate') {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query = "replace systempreferences (variable,value,explanation) values (";
$query.= $dbh->quote($input->param('variable')).",";
$query.= $dbh->quote($input->param('value')).",";
@ -188,7 +187,7 @@ printend
################## DELETE_CONFIRM ##################################
# called by default form, used to confirm deletion of data in DB
} elsif ($op eq 'delete_confirm') {
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare($reqsel);
$sth->execute;
my $data=$sth->fetchrow_hashref;
@ -203,7 +202,7 @@ printend
################## DELETE_CONFIRMED ##################################
# called by delete_confirm, used to effectively confirm deletion of data in DB
} elsif ($op eq 'delete_confirmed') {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
# my $searchfield=$input->param('branchcode');
my $sth=$dbh->prepare($reqdel);
$sth->execute;

View File

@ -23,6 +23,7 @@
use strict;
use CGI;
use C4::Context;
use C4::Search;
use C4::Circulation::Circ2;
use C4::Output;
@ -111,24 +112,22 @@ print endpage;
# This stuff should probably go into C4::Search
# database includes
use DBI;
use C4::Database;
sub itemdatanum {
my ($itemnumber)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $itm = $dbh->quote("$itemnumber");
my $query = "select * from items where itemnumber=$itm";
my $sth=$dbh->prepare($query);
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
return($data);
}
sub lastmove {
my ($itemnumber)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $var1 = $dbh->quote($itemnumber);
my $sth =$dbh->prepare("select max(branchtransfers.datearrived) from branchtransfers where branchtransfers.itemnumber=$var1");
$sth->execute;
@ -140,26 +139,24 @@ sub lastmove {
my ($data) = $sth->fetchrow_hashref;
return(0, "Item has no branch transfers record") if not $data;
$sth->finish;
$dbh->disconnect;
return($data,"");
}
sub issuessince {
my ($itemnumber, $date)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $itm = $dbh->quote($itemnumber);
my $dat = $dbh->quote($date);
my $sth=$dbh->prepare("Select count(*) from issues where issues.itemnumber=$itm and issues.timestamp > $dat");
$sth->execute;
my $count=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
return($count->{'count(*)'});
}
sub issuesat {
my ($itemnumber, $brcd)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $itm = $dbh->quote($itemnumber);
my $brc = $dbh->quote($brcd);
my $query = "Select count(*) from issues where itemnumber=$itm and branchcode = $brc";
@ -167,13 +164,12 @@ sub issuesat {
$sth->execute;
my ($count)=$sth->fetchrow_array;
$sth->finish;
$dbh->disconnect;
return($count);
}
sub lastseenat {
my ($itemnumber, $brcd)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $itm = $dbh->quote($itemnumber);
my $brc = $dbh->quote($brcd);
my $query = "Select max(timestamp) from issues where itemnumber=$itm and branchcode = $brc";
@ -182,11 +178,11 @@ sub lastseenat {
my ($date1)=$sth->fetchrow_array;
$sth->finish;
$query = "Select max(datearrived) from branchtransfers where itemnumber=$itm and tobranch = $brc";
# FIXME - There's already a $sth in this scope.
my $sth=$dbh->prepare($query);
$sth->execute;
my ($date2)=$sth->fetchrow_array;
$sth->finish;
$dbh->disconnect;
$date2 =~ s/-//g;
$date2 =~ s/://g;
$date2 =~ s/ //g;

View File

@ -23,8 +23,8 @@
use strict;
use CGI;
use C4::Context;
use C4::Output;
use C4::Database;
my $input = new CGI;
print $input->header;
@ -34,7 +34,7 @@ print startmenu('issue');
print "Each box needs to be filled in with fine,time to start charging,charging cycle<br>
eg 1,7,7 = $1 fine, after 7 days, every 7 days";
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select description,categorycode from categories";
my $sth=$dbh->prepare($query);
$sth->execute;

View File

@ -31,7 +31,7 @@ use C4::Print;
my %env;
my $headerbackgroundcolor='#99cc33';
my $circbackgroundcolor='#ffffcc';
my $circbackgroundcolor='white';
my $circbackgroundcolor='white'; # FIXME - Duplicate
my $linecolor1='#ffffcc';
my $linecolor2='white';
my $backgroundimage="/images/background-mem.gif";
@ -643,7 +643,7 @@ EOF
}
# FIXME - This clashes with &C4::Print::printslip
sub printslip {
my ($env,$borrowernumber)=@_;
my ($borrower, $flags) = getpatroninformation($env,$borrowernumber,0);

View File

@ -24,10 +24,10 @@
use strict;
use C4::Search;
use CGI;
use C4::Context;
use C4::Search;
use C4::Output;
use C4::Database;
use C4::Circulation::Circ2;
#use C4::Acquisitions;
@ -44,13 +44,12 @@ $env{'nottodayissues'}=1;
$i++;
}
my ($bor,$flags)=getpatroninformation(\%env, $member,'');
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from borrowers where guarantor='$member'";
my $sth=$dbh->prepare($query);
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
if ($i > 0 || $flags->{'CHARGES'} ne '' || $data ne ''){
@ -74,7 +73,7 @@ if ($i > 0 || $flags->{'CHARGES'} ne '' || $data ne ''){
sub delmember{
my ($member)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from borrowers where borrowernumber='$member'";
my $sth=$dbh->prepare($query);
$sth->execute;
@ -86,16 +85,18 @@ sub delmember{
}
$query=~ s/\,$/\)/;
# print $query;
# FIXME - Use $dbh->do()
$sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
# FIXME - Use $dbh->do()
$query = "Delete from borrowers where borrowernumber='$member'";
$sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
# FIXME - Use $dbh->do()
$query="Delete from reserves where borrowernumber='$member'";
$sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
$dbh->disconnect;
}

View File

@ -20,34 +20,13 @@
use HTML::Template;
use strict;
require Exporter;
use C4::Database;
use C4::Context;
use C4::Output; # contains picktemplate
use CGI;
use C4::Search;
my $query=new CGI;
my $language='french';
my %configfile;
open (KC, "/etc/koha.conf");
while (<KC>) {
chomp;
(next) if (/^\s*#/);
if (/(.*)\s*=\s*(.*)/) {
my $variable=$1;
my $value=$2;
# Clean up white space at beginning and end
$variable=~s/^\s*//g;
$variable=~s/\s*$//g;
$value=~s/^\s*//g;
$value=~s/\s*$//g;
$configfile{$variable}=$value;
}
}
my $biblionumber=$query->param('bib');
my $type='intra';
@ -86,8 +65,8 @@ my $itemsarray=\@items;
my $webarray=\@webbiblioitems;
my $sitearray=\@websites;
my $includes=$configfile{'includes'};
($includes) || ($includes="/usr/local/www/hdl/htdocs/includes");
my $includes = C4::Context->config('includes') ||
"/usr/local/www/hdl/htdocs/includes";
my $templatebase="catalogue/detail.tmpl";
my $startfrom=$query->param('startfrom');
($startfrom) || ($startfrom=0);

View File

@ -4,7 +4,7 @@
use strict;
use DBI;
use C4::Database;
use C4::Context;
# This script makes the following substitutions.
# on homebranch field:
@ -43,7 +43,7 @@ my %hold = ( 'F' => 'F' ,
# do the substitutions.....
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare("SELECT barcode, holdingbranch, homebranch FROM items");
$sth->execute();
@ -71,5 +71,3 @@ while (my $item = $sth->fetchrow_hashref) {
}
print "\nFinished output from fixbranches.pl\n";
$dbh->disconnect;

View File

@ -21,10 +21,13 @@ package C4::Search; #asummes C4/Search
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
# FIXME - This file is very similar to C4/Search.pm (and they both
# claim to be package C4::Search). So shouldn't this file be nuked?
use strict;
require Exporter;
use DBI;
use C4::Database;
use C4::Context;
use C4::Reserves2;
use Set::Scalar;
@ -76,7 +79,7 @@ my $priv_func = sub {
# make all your functions, whether exported or not;
sub findguarantees{
my ($bornum)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="select cardnumber,borrowernumber from borrowers where
guarantor='$bornum'";
my $sth=$dbh->prepare($query);
@ -88,12 +91,11 @@ sub findguarantees{
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,\@dat);
}
sub findguarantor{
my ($bornum)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="select guarantor from borrowers where
borrowernumber='$bornum'";
my $sth=$dbh->prepare($query);
@ -106,38 +108,35 @@ sub findguarantor{
$sth->execute;
$data=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
return($data);
}
sub systemprefs {
my %systemprefs;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("select variable,value from systempreferences");
$sth->execute;
while (my ($variable,$value)=$sth->fetchrow) {
$systemprefs{$variable}=$value;
}
$sth->finish;
$dbh->disconnect;
return(%systemprefs);
}
sub NewBorrowerNumber {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("Select max(borrowernumber) from borrowers");
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
$data->{'max(borrowernumber)'}++;
$dbh->disconnect;
return($data->{'max(borrowernumber)'});
}
sub KeywordSearch {
my ($env,$type,$search,$num,$offset)=@_;
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $resulthash;
$search->{'keyword'}=~ s/ +$//;
$search->{'keyword'}=~ s/'/\\'/;
@ -306,7 +305,6 @@ sub KeywordSearch {
$i2++;
}
}
$dbh->disconnect;
#$count=$i;
return($count,$resulthash,@res2);
@ -314,7 +312,7 @@ sub KeywordSearch {
sub KeywordSearch2 {
my ($env,$type,$search,$num,$offset)=@_;
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
$search->{'keyword'}=~ s/ +$//;
$search->{'keyword'}=~ s/'/\\'/;
my @key=split(' ',$search->{'keyword'});
@ -454,7 +452,6 @@ sub KeywordSearch2 {
$i2++;
}
$sth->finish;
$dbh->disconnect;
# $i--;
# $i++;
return($i,@res2);
@ -462,7 +459,7 @@ sub KeywordSearch2 {
sub CatSearch {
my ($env,$type,$search,$num,$offset)=@_;
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $query = '';
my @results;
$search->{'title'}=~ s/'/\\'/g;
@ -716,7 +713,7 @@ sub updatesearchstats{
sub subsearch {
my ($env,$subject)=@_;
my $dbh=C4Connect();
my $dbh = C4::Context->dbh;
$subject=$dbh->quote($subject);
my $query="Select * from biblio,bibliosubject where
biblio.biblionumber=bibliosubject.biblionumber and
@ -731,14 +728,13 @@ sub subsearch {
$i++;
}
$sth->finish;
$dbh->disconnect;
return(@results);
}
sub ItemInfo {
my ($env,$biblionumber,$type)=@_;
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from items,biblio,biblioitems,branches
where (items.biblioitemnumber = biblioitems.biblioitemnumber)
and biblioitems.biblionumber=biblio.biblionumber
@ -814,14 +810,13 @@ sub ItemInfo {
}
$sth2->finish;
$dbh->disconnect;
return(@results);
}
sub GetItems {
my ($env,$biblionumber)=@_;
#debug_msg($env,"GetItems");
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
my $query = "Select * from biblioitems where (biblionumber = $biblionumber)";
#debug_msg($env,$query);
my $sth=$dbh->prepare($query);
@ -854,26 +849,24 @@ sub GetItems {
$i++;
}
$sth->finish;
$dbh->disconnect;
return(@results);
}
sub itemdata {
my ($barcode)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from items,biblioitems where barcode='$barcode'
and items.biblioitemnumber=biblioitems.biblioitemnumber";
my $sth=$dbh->prepare($query);
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
return($data);
}
sub bibdata {
my ($bibnum,$type)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select *,biblio.notes
from biblio,biblioitems
left join bibliosubtitle on
@ -893,13 +886,12 @@ sub bibdata {
}
$sth->finish;
$dbh->disconnect;
return($data);
}
sub bibitemdata {
my ($bibitem)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select *,biblioitems.notes as bnotes from biblio,biblioitems,itemtypes where biblio.biblionumber=
biblioitems.biblionumber and biblioitemnumber=$bibitem and
biblioitems.itemtype=itemtypes.itemtype";
@ -907,13 +899,12 @@ sub bibitemdata {
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
return($data);
}
sub subject {
my ($bibnum)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from bibliosubject where biblionumber=$bibnum";
my $sth=$dbh->prepare($query);
$sth->execute;
@ -924,13 +915,12 @@ sub subject {
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,\@results);
}
sub addauthor {
my ($bibnum)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from additionalauthors where biblionumber=$bibnum";
my $sth=$dbh->prepare($query);
$sth->execute;
@ -941,13 +931,12 @@ sub addauthor {
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,\@results);
}
sub subtitle {
my ($bibnum)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from bibliosubtitle where biblionumber=$bibnum";
my $sth=$dbh->prepare($query);
$sth->execute;
@ -958,7 +947,6 @@ sub subtitle {
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,\@results);
}
@ -966,7 +954,7 @@ sub subtitle {
sub itemissues {
my ($bibitem,$biblio)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from items where
items.biblioitemnumber='$bibitem'";
my $sth=$dbh->prepare($query) || die $dbh->errstr;
@ -1006,13 +994,12 @@ sub itemissues {
$i++;
}
$sth->finish;
$dbh->disconnect;
return(@results);
}
sub itemnodata {
my ($env,$dbh,$itemnumber) = @_;
$dbh=C4Connect;
$dbh = C4::Context->dbh;
my $query="Select * from biblio,items,biblioitems
where items.itemnumber = '$itemnumber'
and biblio.biblionumber = items.biblionumber
@ -1021,7 +1008,6 @@ sub itemnodata {
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
return($data);
}
@ -1029,7 +1015,7 @@ sub itemnodata {
#called by member.pl
sub BornameSearch {
my ($env,$searchstring,$type)=@_;
my $dbh = &C4Connect;
my $dbh = C4::Context->dbh;
$searchstring=~ s/\'/\\\'/g;
my @data=split(' ',$searchstring);
my $count=@data;
@ -1055,14 +1041,13 @@ sub BornameSearch {
}
# $sth->execute;
$sth->finish;
$dbh->disconnect;
return ($cnt,\@results);
}
sub borrdata {
my ($cardnumber,$bornum)=@_;
$cardnumber = uc $cardnumber;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query;
if ($bornum eq ''){
$query="Select * from borrowers where cardnumber='$cardnumber'";
@ -1073,13 +1058,12 @@ sub borrdata {
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
return($data);
}
sub borrissues {
my ($bornum)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query;
$query="Select * from issues,biblio,items where borrowernumber='$bornum' and
items.itemnumber=issues.itemnumber and
@ -1094,13 +1078,12 @@ by date_due";
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,\@result);
}
sub allissues {
my ($bornum,$order,$limit)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query;
$query="Select * from issues,biblio,items,biblioitems
where borrowernumber='$bornum' and
@ -1120,13 +1103,12 @@ sub allissues {
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,\@result);
}
sub borrdata2 {
my ($env,$bornum)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select count(*) from issues where borrowernumber='$bornum' and
returndate is NULL";
my $sth=$dbh->prepare($query);
@ -1143,7 +1125,6 @@ sub borrdata2 {
$sth->execute;
my $data3=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
return($data2->{'count(*)'},$data->{'count(*)'},$data3->{'sum(amountoutstanding)'});
}
@ -1151,7 +1132,7 @@ return($data2->{'count(*)'},$data->{'count(*)'},$data3->{'sum(amountoutstanding)
sub getboracctrecord {
my ($env,$params) = @_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my @acctlines;
my $numlines=0;
my $query= "Select * from accountlines where
@ -1174,13 +1155,12 @@ borrowernumber=$params->{'borrowernumber'} order by date desc,timestamp desc";
$total = $total+ $data->{'amountoutstanding'};
}
$sth->finish;
$dbh->disconnect;
return ($numlines,\@acctlines,$total);
}
sub itemcount {
my ($env,$bibnum,$type)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from items where
biblionumber=$bibnum ";
if ($type ne 'intra'){
@ -1240,25 +1220,23 @@ sub itemcount {
# $count+=$ocount;
$sth2->finish;
$sth->finish;
$dbh->disconnect;
return ($count,$lcount,$nacount,$fcount,$scount,$lostcount,$mending,$transit,$ocount);
}
sub ItemType {
my ($type)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="select description from itemtypes where itemtype='$type'";
my $sth=$dbh->prepare($query);
$sth->execute;
my $dat=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
return ($dat->{'description'});
}
sub bibitems {
my ($bibnum)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from biblioitems,itemtypes,items where
biblioitems.biblionumber='$bibnum' and biblioitems.itemtype=itemtypes.itemtype and
biblioitems.biblioitemnumber=items.biblioitemnumber group by
@ -1272,13 +1250,12 @@ sub bibitems {
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,@results);
}
sub barcodes{
my ($biblioitemnumber)=@_;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select barcode from items where
biblioitemnumber='$biblioitemnumber'";
my $sth=$dbh->prepare($query);
@ -1290,7 +1267,6 @@ sub barcodes{
$i++;
}
$sth->finish;
$dbh->disconnect;
return(@barcodes);
}

View File

@ -19,35 +19,14 @@
use HTML::Template;
use strict;
require Exporter;
use C4::Database;
require Exporter; # FIXME - Is this really necessary?
use C4::Context;
use C4::Output; # contains picktemplate
use CGI;
use C4::Search;
my $query=new CGI;
my $language='french';
my %configfile;
open (KC, "/etc/koha.conf");
while (<KC>) {
chomp;
(next) if (/^\s*#/);
if (/(.*)\s*=\s*(.*)/) {
my $variable=$1;
my $value=$2;
# Clean up white space at beginning and end
$variable=~s/^\s*//g;
$variable=~s/\s*$//g;
$value=~s/^\s*//g;
$value=~s/\s*$//g;
$configfile{$variable}=$value;
}
}
my $biblionumber=$query->param('bib');
my $type=$query->param('type');
@ -77,8 +56,8 @@ my $itemsarray=\@items;
my $webarray=\@webbiblioitems;
my $sitearray=\@websites;
my $includes=$configfile{'includes'};
($includes) || ($includes="/usr/local/www/hdl/htdocs/includes");
my $includes = C4::Context->config('includes') ||
"/usr/local/www/hdl/htdocs/includes";
my $templatebase="catalogue/detail.tmpl";
my $startfrom=$query->param('startfrom');
($startfrom) || ($startfrom=0);

View File

@ -20,6 +20,7 @@
use HTML::Template;
use strict;
require Exporter;
use C4::Context;
use C4::Koha;
use CGI;
use C4::Search;
@ -28,32 +29,10 @@ use C4::Output; # contains picktemplate
my $query=new CGI;
my $language='french';
my %configfile;
open (KC, "/etc/koha.conf");
while (<KC>) {
chomp;
(next) if (/^\s*#/);
if (/(.*)\s*=\s*(.*)/) {
my $variable=$1;
my $value=$2;
# Clean up white space at beginning and end
$variable=~s/^\s*//g;
$variable=~s/\s*$//g;
$value=~s/^\s*//g;
$value=~s/\s*$//g;
$configfile{$variable}=$value;
}
}
my $includes=$configfile{'includes'};
($includes) || ($includes="/usr/local/www/hdl/htdocs/includes");
my $includes = C4::Context->config('includes') ||
"/usr/local/www/hdl/htdocs/includes";
my $templatebase="catalogue/moredetail.tmpl";
my $startfrom=$query->param('startfrom');
($startfrom) || ($startfrom=0);
my $startfrom=$query->param('startfrom') || 0;
my $theme=picktemplate($includes, $templatebase);
my $subject=$query->param('subject');

View File

@ -17,43 +17,23 @@
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
# FIXME - This file is nearly identical to "../search.pl". One of them
# should be nuked.
use HTML::Template;
use strict;
require Exporter;
use C4::Database;
require Exporter; # FIXME - Is this really needed?
use C4::Context;
use CGI;
use C4::Search;
use C4::Output; # no contains picktemplate
my $query=new CGI;
my $language='french';
my %configfile;
open (KC, "/etc/koha.conf");
while (<KC>) {
chomp;
(next) if (/^\s*#/);
if (/(.*)\s*=\s*(.*)/) {
my $variable=$1;
my $value=$2;
# Clean up white space at beginning and end
$variable=~s/^\s*//g;
$variable=~s/\s*$//g;
$value=~s/^\s*//g;
$value=~s/\s*$//g;
$configfile{$variable}=$value;
}
}
#print $query->header;
my $includes=$configfile{'includes'};
($includes) || ($includes="/usr/local/www/hdl/htdocs/includes");
my $includes = C4::Context->config('includes') ||
"/usr/local/www/hdl/htdocs/includes";
my $templatebase="catalogue/searchresults.tmpl";
my $startfrom=$query->param('startfrom');
($startfrom) || ($startfrom=0);
my $startfrom=$query->param('startfrom') || 0;
my $theme=picktemplate($includes, $templatebase);
my $subject=$query->param('subject');
@ -70,6 +50,9 @@ $env->{itemcount}=1;
# get all the search variables
# we assume that C4::Search will validate these values for us
# FIXME - This looks like it could go inside a
# foreach my $term (qw(keyword subject author ...))
# loop.
my %search;
my $keyword=$query->param('keyword');
$search{'keyword'}=$keyword;
@ -88,7 +71,7 @@ $search{'date-before'}=$datebefore;
my $class=$query->param('class');
$search{'class'}=$class;
my $dewey=$query->param('dewey');
$search{'dewey'};
$search{'dewey'}; # FIXME - Was this supposed to be $search{'dewey'} = $dewey ?
my $branch=$query->param('branch');
$search{'branch'}=$branch;
my $title=$query->param('title');

View File

@ -23,7 +23,7 @@
# Suite 330, Boston, MA 02111-1307 USA
use CGI;
use C4::Database;
use C4::Context;
use C4::Input;
use C4::Search;
use Date::Manip;
@ -45,7 +45,7 @@ foreach my $key (@names){
$data{$key}=~ s/\'/\\\'/g;
$data{$key}=~ s/\"/\\\"/g;
}
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from borrowers where borrowernumber=$data{'borrowernumber'}";
my $sth=$dbh->prepare($query);
$sth->execute;
@ -106,5 +106,4 @@ if ($data{'categorycode'} eq 'A' || $data{'categorycode'} eq 'W'){
$sth2->execute;
$sth2->finish;
$sth->finish;
$dbh->disconnect;
print $input->redirect("/cgi-bin/koha/moremember.pl?bornum=$data{'borrowernumber'}");

View File

@ -23,7 +23,7 @@
# Suite 330, Boston, MA 02111-1307 USA
use CGI;
use C4::Database;
use C4::Context;
use C4::Input;
use Date::Manip;
use strict;
@ -42,7 +42,7 @@ my $env;
foreach my $key (@names){
$data{$key}=$input->param($key);
}
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $surname=$data{'institution_name'};
my $query="insert into borrowers (title,expiry,cardnumber,sex,ethnotes,streetaddress,faxnumber,
firstname,altnotes,dateofbirth,contactname,emailaddress,dateenrolled,streetcity,
@ -64,5 +64,4 @@ now(),'$data{'streetcity'}','$data{'altrelationship'}','$data{'othernames'}',
$sth2->finish;
#$sth->finish;
$dbh->disconnect;
print $input->redirect("/cgi-bin/koha/moremember.pl?bornum=$data{'borrowernumber'}");

View File

@ -23,7 +23,7 @@
# Suite 330, Boston, MA 02111-1307 USA
use CGI;
use C4::Database;
use C4::Context;
use C4::Input;
use Date::Manip;
use strict;
@ -42,7 +42,7 @@ my $env;
foreach my $key (@names){
$data{$key}=$input->param($key);
}
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
for (my $i=0;$i<3;$i++){
my $query="Select * from borrowers where borrowernumber=$data{'bornumber_child_$i'}";
@ -98,5 +98,4 @@ if (my $data=$sth->fetchrow_hashref){
$sth2->finish;
$sth->finish;
}
$dbh->disconnect;
print $input->redirect("/cgi-bin/koha/moremember.pl?bornum=$data{'borrowernumber'}");

View File

@ -19,7 +19,7 @@
# Suite 330, Boston, MA 02111-1307 USA
use CGI;
use C4::Database;
use C4::Context;
my $query=new CGI;
@ -41,7 +41,7 @@ foreach (keys %$sessions) {
print S "$_:$userid:$lasttime\n";
}
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
# Check that this is the ip that created the session before deleting it

View File

@ -25,7 +25,6 @@
use strict;
use CGI;
use C4::Output;
use C4::Database;
use C4::Maintainance;
my $input = new CGI;

View File

@ -24,8 +24,8 @@
use strict;
use CGI;
use C4::Context;
use C4::Output;
use C4::Database;
use C4::Maintainance;
my $input = new CGI;
@ -33,13 +33,13 @@ print $input->header;
my $type=$input->param('type');
my $bi=$input->param('bi');
my $bib=$input->param('bib');
my $type=$input->param('type');
my $type=$input->param('type'); # FIXME - Redundant
print startpage();
print startmenu('catalog');
if ($type eq 'change'){
my $biblionumber=$input->param('biblionumber');
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from biblio where biblionumber=$biblionumber";
my $sth=$dbh->prepare($query);
$sth->execute;

View File

@ -17,10 +17,10 @@
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
use HTML::Template;
use strict;
require Exporter;
use C4::Database;
use HTML::Template;
require Exporter; # FIXME - Is this really necessary?
use C4::Context;
use C4::Output; # contains picktemplate
use CGI;
use C4::Search;
@ -29,37 +29,14 @@ use C4::Biblio;
use C4::Catalogue;
my $query=new CGI;
my $language='french';
my %configfile;
open (KC, "/etc/koha.conf");
while (<KC>) {
chomp;
(next) if (/^\s*#/
);
if (/(.*)\s*=\s*(.*)/) {
my $variable=$1;
my $value=$2;
# Clean up white space at beginning and end
$variable=~s/^\s*//g;
$variable=~s/\s*$//g;
$value=~s/^\s*//g;
$value=~s/\s*$//g;
$configfile{$variable}=$value;
}
}
my $biblionumber=$query->param('bib');
my $tag=$query->param('tag');
if (! defined $tag) { $tag='2XX';}
#print STDERR "BIB : $biblionumber // TAG : $tag\n";
if (! defined $biblionumber) {
my $includes=$configfile{'includes'};
($includes) || ($includes="/usr/local/www/hdl/htdocs/includes");
my $includes = C4::Context->config('includes') ||
"/usr/local/www/hdl/htdocs/includes";
my $templatebase="MARCdetailbiblioselect.tmpl";
my $theme=picktemplate($includes, $templatebase);
my $template = HTML::Template->new(filename => "$includes/templates/$theme/$templatebase", die_on_bad_params => 0, path => [$includes]);
@ -71,13 +48,13 @@ if (! defined $biblionumber) {
sub showmarcrecord {
my ($biblionumber,$tag) = @_;
my $dbh=&C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("select liblibrarian from marc_subfield_structure where tagfield=? and tagsubfield=?");
my $record =MARCgetbiblio($dbh,$biblionumber);
# open template
my $templatebase="catalogue/MARCdetail.tmpl";
my $includes=$configfile{'includes'};
($includes) || ($includes="/usr/local/www/hdl/htdocs/includes");
my $includes = C4::Context->config('includes') ||
"/usr/local/www/hdl/htdocs/includes";
my $theme=picktemplate($includes, $templatebase);
my $template = HTML::Template->new(filename => "$includes/templates/$theme/$templatebase", die_on_bad_params => 0, path => [$includes]);
# fill arrays

View File

@ -20,9 +20,10 @@
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
use C4::Database;
use strict;
my $dbh=C4Connect;
use C4::Context;
my $dbh = C4::Context->dbh;
my $fields;
marcdefs();
my $tag;

View File

@ -7,7 +7,7 @@
system("mysql Koha -pkohapass < deletemarc");
use C4::Database;
use C4::Context;
use C4::Catalogue;
use CGI;
use DBI;
@ -15,13 +15,9 @@ use DBI;
use C4::Acquisitions;
use C4::Biblio;
use C4::Output;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $userid=$ENV{'REMOTE_USER'};
my $dbh=C4Connect;
my $sth=$dbh->prepare("select * from biblio,biblioitems where biblio.biblionumber=biblioitems.biblionumber");
$sth->execute;
my $env;

View File

@ -1,8 +1,5 @@
#!/usr/bin/perl
use C4::Database;
use C4::Context;
use C4::Catalogue;
use CGI;
use DBI;
@ -13,7 +10,7 @@ use C4::Output;
my $userid=$ENV{'REMOTE_USER'};
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $newschool=$ARGV[0];
($newschool) || ($newschool='SHE');
@ -29,6 +26,5 @@ print $item->{'barcode'}."\n";
print $item->{'biblionumber'}."\n";
$item->{'homebranch'}=$newschool;
print $item->{'homebranch'}."\n";
updateItem($env, $item);
updateItem($env, $item); # FIXME - $env undefined
$sth->finish;
$dbh->disconnect;

View File

@ -22,16 +22,14 @@ package C4::test;
use strict;
require Exporter;
#use C4::Database;
use C4::Context;
use C4::Catalogue;
use C4::Biblio;
use MARC::Record;
use MARC::File::USMARC;
use C4::Context;
#die;
#my $dbh=&C4Connect;
my $dbh=C4::Context->dbh;
my $dbh = C4::Context->dbh;
$dbh->do("delete from marc_biblio");
$dbh->do("delete from marc_blob_subfield");
$dbh->do("delete from marc_subfield_table");

View File

@ -26,16 +26,16 @@
my $starttime=gettime();
use C4::Database;
use CGI;
use strict;
use CGI;
use C4::Context;
use C4::Acquisitions;
use C4::Biblio;
use C4::Output;
my $input = new CGI;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $fields;
marcdefs();
@ -445,6 +445,16 @@ sub codewise {
return $a cmp $b;
}
# FIXME - 9800-line functions are bogus. Presumably these fields and
# such were generated from a data file. Perl is good at reading files,
# so just read that file. If you don't want to use a separate file,
# use the __DATA__ pseudofile. Failing that, this could be redone as a
# single giant assignment:
# $fields = {
# "010" => {
# "name" => "LIBRARY OF CONGRESS CONTROL NUMBER",
# "description" => "..."
# ...
sub marcdefs {
$fields->{'010'}->{"name"}="LIBRARY OF CONGRESS CONTROL NUMBER";
$fields->{'010'}->{"description"}='A unique number assigned to a MARC record by the Library of Congress. Valid MARC prefixes for LC control numbers are published in "MARC 21 Format for Bibliographic Data." ';

View File

@ -22,10 +22,10 @@
# Suite 330, Boston, MA 02111-1307 USA
use strict;
use C4::Context;
use C4::Output;
use CGI;
use C4::Search;
use C4::Database;
use C4::Koha;
use HTML::Template;
@ -67,14 +67,13 @@ if ($delete){
# Not tonight though.
#
if ($cardnumber eq '' && $systemprefs{'autoMemberNum'} eq '1') {
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="select max(substring(borrowers.cardnumber,2,7)) from borrowers";
my $sth=$dbh->prepare($query);
$sth->execute;
my $data=$sth->fetchrow_hashref;
$cardnumber=$data->{'max(substring(borrowers.cardnumber,2,7))'};
$sth->finish;
$dbh->disconnect;
# purpose: generate checksum'd member numbers.
# We'll assume we just got the max value of digits 2-8 of member #'s from the database and our job is to
# increment that by one, determine the 1st and 9th digits and return the full string.

View File

@ -26,7 +26,7 @@
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
use C4::Database;
use C4::Context;
use C4::Search;
use C4::Circulation::Circ2;
use C4::Circulation::Fines;
@ -105,13 +105,12 @@ for (my $i=0;$i<$numOverdueItems;$i++){
# this should be a
# separate function
#
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="Select * from borrowers where borrowernumber='$borrower->{'guarantor'}'";
my $sth=$dbh->prepare($query);
$sth->execute;
my $tdata=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
$borrower->{'phone'}=$tdata->{'phone'};
}
print "$printout\t$borrower->{'cardnumber'}\t$borrower->{'categorycode'}\t$borrower->{'firstname'}\t$borrower->{'surname'}\t$data->[$i]->{'date_due'}\t$type\t$difference\t$borrower->{'emailaddress'}\t$borrower->{'phone'}\t$borrower->{'streetaddress'}\t$borrower->{'city'}\t$amount\n";
@ -127,7 +126,7 @@ for (my $i=0;$i<$numOverdueItems;$i++){
my $borrower=BorType($data->[$i]->{'borrowernumber'});
if ($borrower->{'cardnumber'} ne ''){
my $cost=ReplacementCost($data->[$i]->{'itemnumber'});
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $env;
my $accountno=C4::Circulation::Circ2::getnextacctno($env,$data->[$i]->{'borrowernumber'},$dbh);
my $item=itemnodata($env,$dbh,$data->[$i]->{'itemnumber'});
@ -152,7 +151,6 @@ for (my $i=0;$i<$numOverdueItems;$i++){
# this should be deleted
#
}
$dbh->disconnect;
}
}

View File

@ -22,10 +22,10 @@
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
use C4::Database;
use C4::Context;
use strict;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query = "Select * from categories where (categorycode like 'L%' or categorycode like 'F%'
or categorycode like 'S%' or categorycode like 'O%' or categorycode like 'H%') and (categorycode <>'HR'
@ -60,7 +60,7 @@ while (my $data=$sth->fetchrow_hashref){
$query = "Select * from categories where (categorycode like 'V%') and (categorycode <>'HR'
and categorycode <> 'ST')";
my $sth=$dbh->prepare($query);
my $sth=$dbh->prepare($query); # FIXME - There's already a $sth in this scope
$sth->execute;
while (my $data=$sth->fetchrow_hashref){
@ -85,8 +85,8 @@ while (my $data=$sth->fetchrow_hashref){
}
my $query = "Select * from categories where categorycode = 'ST'";
my $sth=$dbh->prepare($query);
my $query = "Select * from categories where categorycode = 'ST'"; # FIXME - There's already a $query in this scope
my $sth=$dbh->prepare($query); # FIXME - There's already a $sth in this scope
$sth->execute;
while (my $data=$sth->fetchrow_hashref){
@ -109,8 +109,8 @@ while (my $data=$sth->fetchrow_hashref){
}
my $query = "Select * from categories where categorycode = 'BR' or categorycode='CO' or categorycode='IS'";
my $sth=$dbh->prepare($query);
my $query = "Select * from categories where categorycode = 'BR' or categorycode='CO' or categorycode='IS'"; # FIXME - There's already a $query in this scope
my $sth=$dbh->prepare($query); # FIXME - There's already a $sth in this scope
$sth->execute;
while (my $data=$sth->fetchrow_hashref){
@ -133,8 +133,8 @@ while (my $data=$sth->fetchrow_hashref){
}
my $query = "Select * from categories where categorycode = 'TD' or categorycode='TR'";
my $sth=$dbh->prepare($query);
my $query = "Select * from categories where categorycode = 'TD' or categorycode='TR'"; # FIXME - There's already a $query in this scope
my $sth=$dbh->prepare($query); # FIXME - There's already a $sth in this scope
$sth->execute;
while (my $data=$sth->fetchrow_hashref){
@ -157,8 +157,8 @@ while (my $data=$sth->fetchrow_hashref){
}
my $query = "Select * from categories where categorycode = 'HR'";
my $sth=$dbh->prepare($query);
my $query = "Select * from categories where categorycode = 'HR'"; # FIXME - There's already a $query in this scope
my $sth=$dbh->prepare($query); # FIXME - There's already a $sth in this scope
$sth->execute;
while (my $data=$sth->fetchrow_hashref){
@ -181,8 +181,8 @@ while (my $data=$sth->fetchrow_hashref){
}
my $query = "Select * from categories where categorycode = 'IL'";
my $sth=$dbh->prepare($query);
my $query = "Select * from categories where categorycode = 'IL'"; # FIXME - There's already a $query in this scope
my $sth=$dbh->prepare($query); # FIXME - There's already a $sth in this scope
$sth->execute;
while (my $data=$sth->fetchrow_hashref){
@ -205,8 +205,8 @@ while (my $data=$sth->fetchrow_hashref){
}
my $query = "Select * from categories where categorycode = 'TB'";
my $sth=$dbh->prepare($query);
my $query = "Select * from categories where categorycode = 'TB'"; # FIXME - There's already a $query in this scope
my $sth=$dbh->prepare($query); # FIXME - There's already a $sth in this scope
$sth->execute;
while (my $data=$sth->fetchrow_hashref){
#update borrowers corresponding
@ -248,5 +248,3 @@ foreach $query (@queryValues) {
$sth->execute;
$sth->finish;
}
$dbh->disconnect;

View File

@ -18,10 +18,10 @@
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
use C4::Database;
use C4::Context;
use strict;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("Select biblio.biblionumber,biblio.title from biblio,catalogueentry where catalogueentry.entrytype
='t' and catalogueentry.catalogueentry=biblio.title limit 500");
@ -34,6 +34,3 @@ while (my $data=$sth->fetchrow_hashref){
$sth2->finish;
}
$sth->finish;
$dbh->disconnect;

View File

@ -18,10 +18,10 @@
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
use C4::Database;
use strict;
use C4::Context;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("Select ordernumber,biblionumber from aqorders order by ordernumber");
$sth->execute;
@ -43,6 +43,3 @@ while (my $data=$sth->fetchrow_hashref){
$number=$data->{'ordernumber'};
}
$sth->finish;
$dbh->disconnect;

View File

@ -19,9 +19,9 @@
# Suite 330, Boston, MA 02111-1307 USA
use strict;
use C4::Database;
use C4::Context;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $count=0;
my $query="Select * from biblioitems where itemtype='REF' or itemtype='TREF'";
my $sth=$dbh->prepare($query);
@ -34,6 +34,3 @@ while (my $data=$sth->fetchrow_hashref){
$sth2->finish;
}
$sth->finish;
$dbh->disconnect;

View File

@ -19,9 +19,9 @@
# Suite 330, Boston, MA 02111-1307 USA
use strict;
use C4::Database;
use C4::Context;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $count=0;
my $basket='HLT-';
for (my $i=1;$i<59;$i++){
@ -41,5 +41,3 @@ for (my $i=1;$i<59;$i++){
}
$sth->finish;
}
$dbh->disconnect;

View File

@ -19,9 +19,9 @@
# Suite 330, Boston, MA 02111-1307 USA
use strict;
use C4::Database;
use C4::Context;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $count=0;
my $query="Select biblionumber from aqorders where datereceived = '0000-00-00'";
my $sth=$dbh->prepare($query);
@ -48,6 +48,3 @@ while (my $data=$sth->fetchrow_hashref){
}
$sth->finish;
$dbh->disconnect;

View File

@ -22,7 +22,6 @@
# Suite 330, Boston, MA 02111-1307 USA
use strict;
use C4::Database;
use CGI;
use C4::Accounts2;

View File

@ -28,32 +28,10 @@ use C4::Output; # contains picktemplate
my $query=new CGI;
my $language='french';
my %configfile;
open (KC, "/etc/koha.conf");
while (<KC>) {
chomp;
(next) if (/^\s*#/);
if (/(.*)\s*=\s*(.*)/) {
my $variable=$1;
my $value=$2;
# Clean up white space at beginning and end
$variable=~s/^\s*//g;
$variable=~s/\s*$//g;
$value=~s/^\s*//g;
$value=~s/\s*$//g;
$configfile{$variable}=$value;
}
}
my $includes=$configfile{'includes'};
($includes) || ($includes="/usr/local/www/hdl/htdocs/includes");
my $includes = C4::Context->config('includes') ||
"/usr/local/www/hdl/htdocs/includes";
my $templatebase="catalogue/moredetail.tmpl";
my $startfrom=$query->param('startfrom');
($startfrom) || ($startfrom=0);
my $startfrom=$query->param('startfrom') || 0;
my $theme=picktemplate($includes, $templatebase);
my $subject=$query->param('subject');
@ -109,6 +87,7 @@ foreach my $item (@items){
$item->{'ordernumber'} = $ordernum;
$item->{'booksellerinvoicenumber'} = $order->{'booksellerinvoicenumber'};
# FIXME - This should be "==", not "=", right?
if ($item->{'date_due'} = 'Available'){
$item->{'issue'}="<b>Available</b><br>";
} else {

View File

@ -29,6 +29,7 @@
# Suite 330, Boston, MA 02111-1307 USA
use strict;
use C4::Context;
use C4::Output;
use CGI;
use C4::Search;
@ -37,10 +38,9 @@ use C4::Reserves2;
use C4::Circulation::Renewals2;
use C4::Circulation::Circ2;
use C4::Koha;
use C4::Database;
use HTML::Template;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $input = new CGI;
@ -180,8 +180,6 @@ for (my $i=0;$i<$rescount;$i++){
push (@reservedata, \%row);
}
$dbh->disconnect;
$template->param($data);
$template->param(startmenumember => join('', startmenu('member')),
endmenumember => join('', endmenu('member')),

View File

@ -19,9 +19,9 @@
# Suite 330, Boston, MA 02111-1307 USA
use strict;
use C4::Context;
use C4::Output;
use CGI;
use C4::Database;
use HTML::Template;
my $input = new CGI;
@ -46,7 +46,7 @@ my $author;
my @datearr = localtime(time());
my $todaysdate = (1900+$datearr[5]).'-'.sprintf ("%0.2d", ($datearr[4]+1)).'-'.sprintf ("%0.2d", $datearr[3]);
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="select date_due,borrowernumber,itemnumber from issues where isnull(returndate) && date_due<'$todaysdate' order by date_due,borrowernumber";
my $sth=$dbh->prepare($query);
@ -67,6 +67,7 @@ while (my $data=$sth->fetchrow_hashref) {
$email=$data1->{'emailaddress'};
$sth1->finish;
# FIXME - There's already a $query in this scope.
my $query="select biblionumber from items where itemnumber='$itemnum'";
my $sth2=$dbh->prepare($query);
$sth2->execute;
@ -74,6 +75,7 @@ while (my $data=$sth->fetchrow_hashref) {
$biblionumber=$data2->{'biblionumber'};
$sth2->finish;
# FIXME - There's already a $query in this scope.
my $query="select title,author from biblio where biblionumber='$biblionumber'";
my $sth3=$dbh->prepare($query);
$sth3->execute;
@ -94,7 +96,6 @@ while (my $data=$sth->fetchrow_hashref) {
}
$sth->finish;
$dbh->disconnect;
$template->param( startmenureport => join ('', startmenu('report')),
endmenureport => join ('', endmenu('report')),

7
pay.pl
View File

@ -22,13 +22,13 @@
# Suite 330, Boston, MA 02111-1307 USA
use strict;
use C4::Context;
use C4::Output;
use CGI;
use C4::Search;
use C4::Accounts2;
use C4::Database;
use C4::Stats;
my $input=new CGI;
#print $input->header;
@ -178,7 +178,7 @@ sub writeoff{
$user=~ s/Levin/C/;
$user=~ s/Foxton/F/;
$user=~ s/Shannon/S/;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $env;
my $query="Update accountlines set amountoutstanding=0 where ";
if ($accounttype eq 'Res'){
@ -202,6 +202,5 @@ sub writeoff{
$sth->execute;
$sth->finish;
# print $query;
$dbh->disconnect;
UpdateStats($env,$user,'writeoff',$amount,'','','',$bornum);
}

View File

@ -22,37 +22,14 @@ use HTML::Template;
use strict;
require Exporter;
use C4::Database;
use CGI;
use C4::Search;
use C4::Output; # no contains picktemplate
my $query=new CGI;
my $language='french';
my %configfile;
open (KC, "/etc/koha.conf");
while (<KC>) {
chomp;
(next) if (/^\s*#/);
if (/(.*)\s*=\s*(.*)/) {
my $variable=$1;
my $value=$2;
# Clean up white space at beginning and end
$variable=~s/^\s*//g;
$variable=~s/\s*$//g;
$value=~s/^\s*//g;
$value=~s/\s*$//g;
$configfile{$variable}=$value;
}
}
#print $query->header;
my $includes=$configfile{'includes'};
($includes) || ($includes="/usr/local/www/hdl/htdocs/includes");
my $includes = C4::Context->config('includes') ||
"/usr/local/www/hdl/htdocs/includes";
my $templatebase="catalogue/searchresults.tmpl";
my $startfrom=$query->param('startfrom');
($startfrom) || ($startfrom=0);
@ -72,6 +49,10 @@ $env->{itemcount}=1;
# get all the search variables
# we assume that C4::Search will validate these values for us
# FIXME - This whole section, up to the &catalogsearch call, is crying
# out for
# foreach $search_term (qw(keyword subject author ...))
# { ... }
my %search;
my $keyword=$query->param('keyword');
$search{'keyword'}=$keyword;
@ -90,7 +71,7 @@ $search{'date-before'}=$datebefore;
my $class=$query->param('class');
$search{'class'}=$class;
my $dewey=$query->param('dewey');
$search{'dewey'};
$search{'dewey'}; # FIXME - This should be $search{'dewey'} = $dewey, right?
my $branch=$query->param('branch');
$search{'branch'}=$branch;
my $title=$query->param('title');

View File

@ -23,7 +23,7 @@
use strict;
use CGI;
use C4::Database;
use C4::Context;
use C4::Stats;
my $input=new CGI;
@ -66,7 +66,7 @@ sub writeoff{
$user=~ s/Levin/C/;
$user=~ s/Foxton/F/;
$user=~ s/Shannon/S/;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $env;
my $query="Update accountlines set amountoutstanding=0 where ";
if ($accounttype eq 'Res'){
@ -90,6 +90,5 @@ sub writeoff{
$sth->execute;
$sth->finish;
# print $query;
$dbh->disconnect;
UpdateStats($env,$user,'writeoff',$amount,'','','',$bornum);
}

View File

@ -21,13 +21,13 @@
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
use C4::Stats;
use strict;
use C4::Context;
use C4::Stats;
use Date::Manip;
use CGI;
use C4::Output;
use DBI;
use C4::Database;
my $input=new CGI;
my $time=$input->param('time');
@ -59,7 +59,7 @@ if ($time=~ /\//){
$date=UnixDate($date,'%Y-%m-%d');
$date2=UnixDate($date2,'%Y-%m-%d');
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $query="select *
from accountlines,accountoffsets,borrowers where
accountlines.borrowernumber=accountoffsets.borrowernumber and
@ -76,7 +76,7 @@ print mktablehdr;
while (my $data=$sth->fetchrow_hashref){
print "<TR><Td>$data->{'surname'}</td><td>$data->{'description'}</td><td>$data->{'amount'}
</td>";
if ($data->{'accountype'}='Pay'){
if ($data->{'accountype'}='Pay'){ # FIXME - This should be "==", not "=", right?
my $branch=Getpaidbranch($data->{'timestamp'});
print "<td>$branch</td>";
}
@ -94,4 +94,3 @@ print endcenter;
print endmenu('report');
print endpage;
$sth->finish;
$dbh->disconnect;

View File

@ -19,7 +19,7 @@
# Suite 330, Boston, MA 02111-1307 USA
use DBI;
use C4::Database;
use C4::Context;
use C4::Circulation::Issues;
use C4::Circulation::Main;
use C4::InterfaceCDK;
@ -31,40 +31,38 @@ my %env = (
logintime => "", lasttime => $ARGV[6], tempuser => "", debug => "9",
telnet => $ARGV[2], queue => $ARGV[3], printtype => $ARGV[4], brdata => $ARGV[5], bcard=>$ARGV[7]
);
my ($env) = \%env;
my ($env) = \%env;
startint();
helptext('');
my $done;
my ($items,$items2,$amountdue);
my $itemsdet;
$env->{'sysarea'} = "Issues";
$done = "Issues";
helptext('');
my $done;
my ($items,$items2,$amountdue);
my $itemsdet;
$env->{'sysarea'} = "Issues";
$done = "Issues";
my $i=0;
my $dbh=&C4Connect;
my $dbh = C4::Context->dbh;
my ($bornum,$issuesallowed,$borrower,$reason,$amountdue) = C4::Circulation::Borrower::findborrower($env,$dbh);
# my $time=localtime(time);
# open (FILE,">>/tmp/$<_$ARGV[6]");
# my $time=localtime(time);
# open (FILE,">>/tmp/$<_$ARGV[6]");
# print FILE "borrower found $bornum";
# close FILE;
$env->{'loanlength'}="";
if ($reason ne "") {
$done = $reason;
} elsif ($env->{'IssuesAllowed'} eq '0') {
error_msg($env,"No Issues Allowed =$env->{'IssuesAllowed'}");
} else {
$env->{'bornum'} = $bornum;
$env->{'bcard'} = $borrower->{'cardnumber'};
($items,$items2)=C4::Circulation::Main::pastitems($env,$bornum,$dbh); #from Circulation.pm
$done = "No";
my $it2p=0;
while ($done eq 'No'){
($done,$items2,$it2p,$amountdue,$itemsdet) = C4::Circulation::Issues::processitems($env,$bornum,$borrower,$items,$items2,$it2p,$amountdue,$itemsdet);
}
}
$env->{'loanlength'}="";
if ($reason ne "") {
$done = $reason;
} elsif ($env->{'IssuesAllowed'} eq '0') {
error_msg($env,"No Issues Allowed =$env->{'IssuesAllowed'}");
} else {
$env->{'bornum'} = $bornum;
$env->{'bcard'} = $borrower->{'cardnumber'};
($items,$items2)=C4::Circulation::Main::pastitems($env,$bornum,$dbh); #from Circulation.pm
$done = "No";
my $it2p=0;
while ($done eq 'No'){
($done,$items2,$it2p,$amountdue,$itemsdet) = C4::Circulation::Issues::processitems($env,$bornum,$borrower,$items,$items2,$it2p,$amountdue,$itemsdet);
}
}
if ($done ne 'Issues'){
$dbh->disconnect;
die "test";
}
$dbh->disconnect;

View File

@ -19,7 +19,7 @@
# Suite 330, Boston, MA 02111-1307 USA
use DBI;
use C4::Database;
use C4::Context;
use C4::Accounts;
use C4::InterfaceCDK;
use C4::Circulation::Main;
@ -31,15 +31,15 @@ use C4::Print;
use C4::Circulation::Returns;
my %env = (
branchcode => $ARGV[0], usercode => $ARGV[1], proccode => "lgon", borrowernumber => "",
logintime => "", lasttime => "", tempuser => "", debug => "9",
telnet => $ARGV[2], queue => $ARGV[3], printtype => $ARGV[4], brdata => $ARGV[5]
);
my %env = (
branchcode => $ARGV[0], usercode => $ARGV[1], proccode => "lgon", borrowernumber => "",
logintime => "", lasttime => "", tempuser => "", debug => "9",
telnet => $ARGV[2], queue => $ARGV[3], printtype => $ARGV[4], brdata => $ARGV[5]
);
my $env=\%env;
my $dbh=&C4Connect;
my $dbh = C4::Context->dbh;
my @items;
@items[0]=" "x50;
my $reason;
@ -55,30 +55,29 @@ my $issues;
my $resp;
startint();
until ($reason ne "") {
($reason,$item) = returnwindow($env,"Enter Returns",$item,\@items,$borrower,$amt_owing,$odues,$dbh,$resp); #C4::Circulation
($reason,$item) = returnwindow($env,"Enter Returns",$item,\@items,$borrower,$amt_owing,$odues,$dbh,$resp); #C4::Circulation
if ($reason eq "") {
$resp = "";
($resp,$bornum,$borrower,$itemno,$itemrec,$amt_owing) = C4::Circulation::Returns::checkissue($env,$dbh,$item);
if ($bornum ne "") {
($issues,$odues,$amt_owing) = borrdata2($env,$bornum);
} else {
$issues = "";
$odues = "";
$amt_owing = "";
}
if ($resp ne "") {
if ($itemno ne "" ) {
my $item = itemnodata($env,$dbh,$itemno);
my $fmtitem = C4::Circulation::Issues::formatitem($env,$item,"",$amt_owing);
unshift @items,$fmtitem;
if ($items[20] > "") {
pop @items;
}
}
}
}
}
$resp = "";
($resp,$bornum,$borrower,$itemno,$itemrec,$amt_owing) = C4::Circulation::Returns::checkissue($env,$dbh,$item);
if ($bornum ne "") {
($issues,$odues,$amt_owing) = borrdata2($env,$bornum);
} else {
$issues = "";
$odues = "";
$amt_owing = "";
}
if ($resp ne "") {
if ($itemno ne "" ) {
my $item = itemnodata($env,$dbh,$itemno);
my $fmtitem = C4::Circulation::Issues::formatitem($env,$item,"",$amt_owing);
unshift @items,$fmtitem;
if ($items[20] > "") {
pop @items;
}
}
}
}
}
die;
$dbh->disconnect;

View File

@ -23,7 +23,7 @@
use strict;
use CGI;
use C4::Database;
use C4::Context;
use C4::Search;
use C4::Circulation::Circ2;
use C4::Output;
@ -37,7 +37,7 @@ my $search_string= $input->param('search_string');
my $op = $input->param('op');
my $freelib_text = $input->param('freelib_text');
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
# make the page ...
print $input->header;

View File

@ -22,7 +22,6 @@
# Suite 330, Boston, MA 02111-1307 USA
use strict;
use C4::Database;
use CGI;
use C4::Accounts2;

View File

@ -18,7 +18,6 @@
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
use C4::Database;
use CGI;
use strict;
use C4::Acquisitions;

View File

@ -18,7 +18,6 @@
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
use C4::Database;
use CGI;
use strict;
use C4::Acquisitions;

View File

@ -25,8 +25,8 @@
use strict;
use CGI;
use C4::Context;
use C4::Output;
use C4::Database;
my $input = new CGI;
#print $input->header;
@ -34,7 +34,7 @@ my $input = new CGI;
#print startmenu('issue');
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
#print $input->dump;
my @names=$input->param();
@ -51,7 +51,6 @@ foreach my $key (@names){
$sth->execute;
$sth->finish;
}
$dbh->disconnect;
print $input->redirect("/cgi-bin/koha/charges.pl");
#print endmenu('issue');
#print endpage();

View File

@ -18,9 +18,9 @@
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
use C4::Database;
use CGI;
use strict;
use CGI;
use C4::Context;
use C4::Acquisitions;
use C4::Biblio;
use C4::Output;
@ -87,7 +87,7 @@ if ($wthdrawn == 0 && $override ne 'yes'){
wthdranw => $wthdrawn
});
if ($lost ==1){
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("Select * from issues where (itemnumber='$itemnum') and (returndate is null)");
$sth->execute;
my $data=$sth->fetchrow_hashref;
@ -114,7 +114,7 @@ if ($wthdrawn == 0 && $override ne 'yes'){
# print "marking cancelled";
#need to check if it is on reserve or issued
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
my $flag=0;
my ($resbor,$resrec)=C4::Circulation::Circ2::checkreserve($env,$dbh,$itemnum);
# print $resbor;
@ -132,7 +132,6 @@ if ($wthdrawn == 0 && $override ne 'yes'){
$flag=1;
}
$sth->finish;
$dbh->disconnect;
if ($flag == 1){
my $url=$input->self_url;
$url.="&override=yes";

View File

@ -22,13 +22,13 @@ use strict;
# This script generates and fill the thesaurus table
# with the data in bibliothesaurus
use C4::Database;
use C4::Context;
use C4::Catalogue;
use DBI;
use C4::Acquisitions;
use C4::Output;
my $dbh=C4Connect;
my $dbh = C4::Context->dbh;
sub dosql {
my ($dbh,$sql_cmd)=@_;
@ -53,6 +53,7 @@ dosql($dbh,"CREATE TABLE bibliothesaurus (code BIGINT not null AUTO_INCREMENT, f
my $sti=$dbh->prepare("select count(*) as tot from bibliosubject");
$sti->execute;
my $total = $sti->fetchrow_hashref;
# FIXME - There's already a $sti in this scope.
my $sti=$dbh->prepare("select subject from bibliosubject");
$sti->execute;
my $i;

Some files were not shown because too many files have changed in this diff Show More