Browse Source

Initial revision

3.0.x
rangi 23 years ago
commit
d0374d0037
  1. 208
      C4/Accounts.pm
  2. 176
      C4/Accounts2.pm
  3. 894
      C4/Acquisitions.pm
  4. 100
      C4/Circmain.pm
  5. 227
      C4/Circulation.pm
  6. 77
      C4/Circulation/Borrissues.pm
  7. 382
      C4/Circulation/Borrower.pm
  8. 176
      C4/Circulation/Fines.pm
  9. 389
      C4/Circulation/Issues.pm
  10. 265
      C4/Circulation/Main.pm
  11. 214
      C4/Circulation/Renewals.pm
  12. 173
      C4/Circulation/Renewals2.pm
  13. 335
      C4/Circulation/Returns.pm
  14. 156
      C4/Database.pm
  15. 127
      C4/Format.pm
  16. 92
      C4/Input.pm
  17. 138
      C4/Interface/AccountsCDK.pm
  18. 94
      C4/Interface/BorrowerCDK.pm
  19. 133
      C4/Interface/FlagsCDK.pm
  20. 75
      C4/Interface/RenewalsCDK.pm
  21. 244
      C4/Interface/ReserveentCDK.pm
  22. 630
      C4/InterfaceCDK.pm
  23. 84
      C4/Maintainance.pm
  24. 376
      C4/Output.pm
  25. 120
      C4/Print.pm
  26. 299
      C4/Reserves.pm
  27. 295
      C4/Reserves2.pm
  28. 54
      C4/Scan.pm
  29. 1157
      C4/Search.pm
  30. 102
      C4/Security.pm
  31. 243
      C4/Stats.pm
  32. 71
      C4/Stock.pm
  33. 240
      acqui/acquire.pl
  34. 78
      acqui/addorder.pl
  35. 126
      acqui/basket.pl
  36. 97
      acqui/finishreceive.pl
  37. 30
      acqui/modorders.pl
  38. 69
      acqui/newbasket.pl
  39. 205
      acqui/newbasket2.pl
  40. 279
      acqui/newbiblio.pl
  41. 79
      acqui/order.pl
  42. 140
      acqui/receive.pl
  43. 58
      acqui/recieveorder.pl
  44. 251
      acqui/supplier.pl
  45. 61
      acqui/updatesupplier.pl
  46. 91
      boraccount.pl
  47. 48
      borrwraper.pl
  48. 54
      catmaintain.pl
  49. 60
      charges.pl
  50. 54
      currency.pl
  51. 21
      delbiblio.pl
  52. 19
      delitem.pl
  53. 231
      detail.pl
  54. 61
      fines.pl
  55. 148
      imemberentry.pl
  56. 66
      insertdata.pl
  57. 50
      insertidata.pl
  58. 84
      insertjdata.pl
  59. 166
      jmemberentry.pl
  60. 60
      member.pl
  61. 399
      memberentry.pl
  62. 220
      misc/fixborrower.pl
  63. 21
      misc/fixcatalog.pl
  64. 30
      misc/fixorders.pl
  65. 14
      misc/fixorders.pl2
  66. 21
      misc/fixrefs.pl
  67. 27
      misc/makebaskets.pl
  68. 35
      misc/makeformats.pl
  69. 28
      misc/tidyaccounts.pl
  70. 90
      modbib.pl
  71. 190
      modbibitem.pl
  72. 143
      moditem.pl
  73. 40
      modrequest.pl
  74. 180
      moredetail.pl
  75. 276
      moremember.pl
  76. 70
      newimember.pl
  77. 110
      newjmember.pl
  78. 156
      newmember.pl
  79. 151
      opac-search.pl
  80. 22
      orderbreakdown.pl
  81. 132
      pay.pl
  82. 59
      placerequest.pl
  83. 33
      readingrec.pl
  84. 39
      renewscript.pl
  85. 32
      reports.pl
  86. 241
      request.pl
  87. 27
      reservereport.pl
  88. 27
      reservereport.xls
  89. 290
      search.pl
  90. 70
      sec/writeoff.pl
  91. 79
      showbudget.pl
  92. 19
      simpleredirect.pl
  93. 133
      stats.pl
  94. 79
      stats2.pl
  95. 96
      subjectsearch.pl
  96. 52
      telnet/borrwraper.pl
  97. 15
      telnet/circ
  98. 66
      telnet/doreturns.pl
  99. 20
      telnet/issuewrapper.pl
  100. 13
      telnet/returnswrapper.pl

208
C4/Accounts.pm

@ -0,0 +1,208 @@
package C4::Accounts; #asummes C4/Accounts
#requires DBI.pm to be installed
#uses DBD:Pg
use strict;
require Exporter;
use DBI;
use C4::Database;
use C4::Format;
use C4::Search;
use C4::Stats;
use C4::InterfaceCDK;
use C4::Interface::AccountsCDK;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
# set the version for version checking
$VERSION = 0.01;
@ISA = qw(Exporter);
@EXPORT = qw(&checkaccount &reconcileaccount &getnextacctno);
%EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
# your exported package globals go here,
# as well as any optionally exported functions
@EXPORT_OK = qw($Var1 %Hashit);
# non-exported package globals go here
use vars qw(@more $stuff);
# initalize package globals, first exported ones
my $Var1 = '';
my %Hashit = ();
# then the others (which are still accessible as $Some::Module::stuff)
my $stuff = '';
my @more = ();
# all file-scoped lexicals must be created before
# the functions below that use them.
# file-private lexicals go here
my $priv_var = '';
my %secret_hash = ();
# here's a file-private function as a closure,
# callable as &$priv_func; it cannot be prototyped.
my $priv_func = sub {
# stuff goes here.
};
# make all your functions, whether exported or not;
sub displayaccounts{
my ($env)=@_;
}
sub checkaccount {
#take borrower number
#check accounts and list amounts owing
my ($env,$bornumber,$dbh)=@_;
my $sth=$dbh->prepare("Select sum(amountoutstanding) from accountlines where
borrowernumber=$bornumber and amountoutstanding<>0");
$sth->execute;
my $total=0;
while (my $data=$sth->fetchrow_hashref){
$total=$total+$data->{'sum(amountoutstanding)'};
}
$sth->finish;
# output(1,2,"borrower owes $total");
#if ($total > 0){
# # output(1,2,"borrower owes $total");
# if ($total > 5){
# reconcileaccount($env,$dbh,$bornumber,$total);
# }
#}
# pause();
return($total);
}
sub reconcileaccount {
#print put money owing give person opportunity to pay it off
my ($env,$dummy,$bornumber,$total)=@_;
my $dbh = &C4Connect;
#get borrower record
my $sth=$dbh->prepare("select * from borrowers
where borrowernumber=$bornumber");
$sth->execute;
my $borrower=$sth->fetchrow_hashref;
$sth->finish();
#get borrower information
$sth=$dbh->prepare("Select * from accountlines where
borrowernumber=$bornumber and amountoutstanding<>0 order by date");
$sth->execute;
#display account information
&clearscreen();
#&helptext('F11 quits');
output(20,0,"Accounts");
my @accountlines;
my $row=4;
my $i=0;
my $text;
#output (1,2,"Account Info");
#output (1,3,"Item\tDate \tAmount\tDescription");
while (my $data=$sth->fetchrow_hashref){
my $line=$i+1;
my $amount=0+$data->{'amountoutstanding'};
my $itemdata = itemnodata($env,$dbh,$data->{'itemnumber'});
$line= $data->{'accountno'}." ".$data->{'date'}." ".$data->{'accounttype'}." ";
my $title = $itemdata->{'title'};
if (length($title) > 15 ) {$title = substr($title,0,15);}
$line= $line.$itemdata->{'barcode'}." $title ".$data->{'description'};
$line = fmtstr($env,$line,"L65")." ".fmtdec($env,$amount,"52");
push @accountlines,$line;
$i++;
}
#get amount paid and update database
my ($data,$reason)=
&accountsdialog($env,"Payment Entry",$borrower,\@accountlines,$total);
if ($data>0) {
&recordpayment($env,$bornumber,$dbh,$data);
#Check if the borrower still owes
$total=&checkaccount($env,$bornumber,$dbh);
}
$dbh->disconnect;
return($total);
}
sub recordpayment{
#here we update both the accountoffsets and the account lines
my ($env,$bornumber,$dbh,$data)=@_;
my $updquery = "";
my $newamtos = 0;
my $accdata = "";
my $amountleft = $data;
# begin transaction
# my $sth = $dbh->prepare("begin");
# $sth->execute;
my $nextaccntno = getnextacctno($env,$bornumber,$dbh);
# get lines with outstanding amounts to offset
my $query = "select * from accountlines
where (borrowernumber = '$bornumber') and (amountoutstanding<>0)
order by date";
my $sth = $dbh->prepare($query);
$sth->execute;
# offset transactions
while (($accdata=$sth->fetchrow_hashref) and ($amountleft>0)){
if ($accdata->{'amountoutstanding'} < $amountleft) {
$newamtos = 0;
$amountleft = $amountleft - $accdata->{'amountoutstanding'};
} else {
$newamtos = $accdata->{'amountoutstanding'} - $amountleft;
$amountleft = 0;
}
my $thisacct = $accdata->{accountno};
$updquery = "update accountlines set amountoutstanding= '$newamtos'
where (borrowernumber = '$bornumber') and (accountno='$thisacct')";
my $usth = $dbh->prepare($updquery);
$usth->execute;
$usth->finish;
$updquery = "insert into accountoffsets
(borrowernumber, accountno, offsetaccount, offsetamount)
values ($bornumber,$accdata->{'accountno'},$nextaccntno,$newamtos)";
my $usth = $dbh->prepare($updquery);
# print $updquery
$usth->execute;
$usth->finish;
}
# create new line
#$updquery = "insert into accountlines (borrowernumber,
#accountno,date,amount,description,accounttype,amountoutstanding) values
#($bornumber,$nextaccntno,datetime('now'::abstime),0-$data,'Payment,thanks',
#'Pay',0-$amountleft)";
$updquery = "insert into accountlines
(borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding)
values ($bornumber,$nextaccntno,now(),0-$data,'Payment,thanks',
'Pay',0-$amountleft)";
my $usth = $dbh->prepare($updquery);
$usth->execute;
$usth->finish;
UpdateStats($env,'branch','payment',$data)
# $sth->finish;
# $query = "commit";
# $sth = $dbh->prepare;
# $sth->execute;
# $sth-finish;
}
sub getnextacctno {
my ($env,$bornumber,$dbh)=@_;
my $nextaccntno = 1;
my $query = "select * from accountlines
where (borrowernumber = '$bornumber')
order by accountno desc";
my $sth = $dbh->prepare($query);
$sth->execute;
if (my $accdata=$sth->fetchrow_hashref){
$nextaccntno = $accdata->{'accountno'} + 1;
}
$sth->finish;
return($nextaccntno);
}
END { } # module clean-up code here (global destructor)

176
C4/Accounts2.pm

@ -0,0 +1,176 @@
package C4::Accounts2; #asummes C4/Accounts2
#requires DBI.pm to be installed
#uses DBD:Pg
use strict;
require Exporter;
use DBI;
use C4::Database;
use C4::Stats;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
# set the version for version checking
$VERSION = 0.01;
@ISA = qw(Exporter);
@EXPORT = qw(&recordpayment &fixaccounts &makepayment);
%EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
# your exported package globals go here,
# as well as any optionally exported functions
@EXPORT_OK = qw($Var1 %Hashit);
# non-exported package globals go here
use vars qw(@more $stuff);
# initalize package globals, first exported ones
my $Var1 = '';
my %Hashit = ();
# then the others (which are still accessible as $Some::Module::stuff)
my $stuff = '';
my @more = ();
# all file-scoped lexicals must be created before
# the functions below that use them.
# file-private lexicals go here
my $priv_var = '';
my %secret_hash = ();
# here's a file-private function as a closure,
# callable as &$priv_func; it cannot be prototyped.
my $priv_func = sub {
# stuff goes here.
};
# make all your functions, whether exported or not;
sub displayaccounts{
my ($env)=@_;
}
sub recordpayment{
#here we update both the accountoffsets and the account lines
my ($env,$bornumber,$data)=@_;
my $dbh=C4Connect;
my $updquery = "";
my $newamtos = 0;
my $accdata = "";
my $amountleft = $data;
# begin transaction
my $nextaccntno = getnextacctno($env,$bornumber,$dbh);
# get lines with outstanding amounts to offset
my $query = "select * from accountlines
where (borrowernumber = '$bornumber') and (amountoutstanding<>0)
order by date";
my $sth = $dbh->prepare($query);
$sth->execute;
# offset transactions
while (($accdata=$sth->fetchrow_hashref) and ($amountleft>0)){
if ($accdata->{'amountoutstanding'} < $amountleft) {
$newamtos = 0;
$amountleft = $amountleft - $accdata->{'amountoutstanding'};
} else {
$newamtos = $accdata->{'amountoutstanding'} - $amountleft;
$amountleft = 0;
}
my $thisacct = $accdata->{accountno};
$updquery = "update accountlines set amountoutstanding= '$newamtos'
where (borrowernumber = '$bornumber') and (accountno='$thisacct')";
my $usth = $dbh->prepare($updquery);
$usth->execute;
$usth->finish;
$updquery = "insert into accountoffsets
(borrowernumber, accountno, offsetaccount, offsetamount)
values ($bornumber,$accdata->{'accountno'},$nextaccntno,$newamtos)";
my $usth = $dbh->prepare($updquery);
$usth->execute;
$usth->finish;
}
# create new line
$updquery = "insert into accountlines
(borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding)
values ($bornumber,$nextaccntno,now(),0-$data,'Payment,thanks',
'Pay',0-$amountleft)";
my $usth = $dbh->prepare($updquery);
$usth->execute;
$usth->finish;
UpdateStats($env,'branch','payment',$data);
$sth->finish;
$dbh->disconnect;
}
sub makepayment{
#here we update both the accountoffsets and the account lines
my ($bornumber,$accountno,$amount,$user)=@_;
my $env;
my $dbh=C4Connect;
# begin transaction
my $nextaccntno = getnextacctno($env,$bornumber,$dbh);
my $newamtos=0;
my $updquery="Update accountlines set amountoutstanding=0 where
borrowernumber=$bornumber and accountno=$accountno";
my $sth=$dbh->prepare($updquery);
$sth->execute;
$sth->finish;
# print $updquery;
$updquery = "insert into accountoffsets
(borrowernumber, accountno, offsetaccount, offsetamount)
values ($bornumber,$accountno,$nextaccntno,$newamtos)";
my $usth = $dbh->prepare($updquery);
$usth->execute;
$usth->finish;
# create new line
my $payment=0-$amount;
$updquery = "insert into accountlines
(borrowernumber, accountno,date,amount,description,accounttype,amountoutstanding)
values ($bornumber,$nextaccntno,now(),$payment,'Payment,thanks - $user', 'Pay',0)";
my $usth = $dbh->prepare($updquery);
$usth->execute;
$usth->finish;
UpdateStats($env,$user,'payment',$amount);
$sth->finish;
$dbh->disconnect;
}
sub getnextacctno {
my ($env,$bornumber,$dbh)=@_;
my $nextaccntno = 1;
my $query = "select * from accountlines
where (borrowernumber = '$bornumber')
order by accountno desc";
my $sth = $dbh->prepare($query);
$sth->execute;
if (my $accdata=$sth->fetchrow_hashref){
$nextaccntno = $accdata->{'accountno'} + 1;
}
$sth->finish;
return($nextaccntno);
}
sub fixaccounts {
my ($borrowernumber,$accountno,$amount)=@_;
my $dbh=C4Connect;
my $query="Select * from accountlines where borrowernumber=$borrowernumber
and accountno=$accountno";
my $sth=$dbh->prepare($query);
$sth->execute;
my $data=$sth->fetchrow_hashref;
my $diff=$amount-$data->{'amount'};
my $outstanding=$data->{'amountoutstanding'}+$diff;
$sth->finish;
$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;
}
END { } # module clean-up code here (global destructor)

894
C4/Acquisitions.pm

@ -0,0 +1,894 @@
package C4::Acquisitions; #asummes C4/Acquisitions.pm
use strict;
require Exporter;
use C4::Database;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
# set the version for version checking
$VERSION = 0.01;
@ISA = qw(Exporter);
@EXPORT = qw(&getorders &bookseller &breakdown &basket &newbasket &bookfunds
&ordersearch &newbiblio &newbiblioitem &newsubject &newsubtitle &neworder
&newordernum &modbiblio &modorder &getsingleorder &invoice &receiveorder
&bookfundbreakdown &curconvert &updatesup &insertsup &makeitems &modbibitem
&getcurrencies &modsubtitle &modsubject &modaddauthor &moditem &countitems
&findall &needsmod &delitem &delbibitem &delbiblio &delorder &branches
&getallorders &updatecurrencies &getorder);
%EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
# your exported package globals go here,
# as well as any optionally exported functions
@EXPORT_OK = qw($Var1 %Hashit);
# non-exported package globals go here
use vars qw(@more $stuff);
# initalize package globals, first exported ones
my $Var1 = '';
my %Hashit = ();
# then the others (which are still accessible as $Some::Module::stuff)
my $stuff = '';
my @more = ();
# all file-scoped lexicals must be created before
# the functions below that use them.
# file-private lexicals go here
my $priv_var = '';
my %secret_hash = ();
# here's a file-private function as a closure,
# callable as &$priv_func; it cannot be prototyped.
my $priv_func = sub {
# stuff goes here.
};
# make all your functions, whether exported or not;
sub getorders {
my ($supplierid)=@_;
my $dbh=C4Connect;
my $query = "Select count(*),authorisedby,entrydate,basketno from aqorders where
booksellerid='$supplierid' and (datereceived = '0000-00-00' or
datereceived is NULL) and (cancelledby is NULL or cancelledby = '')";
$query.=" group by basketno order by entrydate";
# print $query;
my $sth=$dbh->prepare($query);
$sth->execute;
my @results;
my $i=0;
while (my $data=$sth->fetchrow_hashref){
$results[$i]=$data;
$i++;
}
$sth->finish;
$dbh->disconnect;
return ($i,\@results);
}
sub itemcount{
my ($biblio)=@_;
my $dbh=C4Connect;
my $query="Select count(*) from items where biblionumber=$biblio";
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 $query="Select ordernumber from aqorders where biblionumber=$bib and
biblioitemnumber='$bi'";
my $sth=$dbh->prepare($query);
$sth->execute;
my $ordnum=$sth->fetchrow_hashref;
$sth->finish;
my $order=getsingleorder($ordnum->{'ordernumber'});
$dbh->disconnect;
# print $query;
return ($order);
}
sub getsingleorder {
my ($ordnum)=@_;
my $dbh=C4Connect;
my $query="Select * from biblio,biblioitems,aqorders,aqorderbreakdown
where aqorders.ordernumber=$ordnum
and biblio.biblionumber=aqorders.biblionumber and
biblioitems.biblioitemnumber=aqorders.biblioitemnumber and
aqorders.ordernumber=aqorderbreakdown.ordernumber";
my $sth=$dbh->prepare($query);
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
$dbh->disconnect;
return($data);
}
sub invoice {
my ($invoice)=@_;
my $dbh=C4Connect;
my $query="Select * from aqorders,biblio,biblioitems where
booksellerinvoicenumber='$invoice'
and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber=
aqorders.biblioitemnumber group by aqorders.ordernumber,aqorders.biblioitemnumber";
my $i=0;
my @results;
my $sth=$dbh->prepare($query);
$sth->execute;
while (my $data=$sth->fetchrow_hashref){
$results[$i]=$data;
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,@results);
}
sub getallorders {
#gets all orders from a certain supplier, orders them alphabetically
my ($supid)=@_;
my $dbh=C4Connect;
my $query="Select * from aqorders,biblio,biblioitems where booksellerid='$supid'
and (cancelledby is NULL or cancelledby = '')
and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber=
aqorders.biblioitemnumber
group by aqorders.biblioitemnumber
order by
biblio.title";
my $i=0;
my @results;
my $sth=$dbh->prepare($query);
$sth->execute;
while (my $data=$sth->fetchrow_hashref){
$results[$i]=$data;
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,@results);
}
sub ordersearch {
my ($search,$biblio,$catview)=@_;
my $dbh=C4Connect;
my $query="Select *,biblio.title from aqorders,biblioitems,biblio
where aqorders.biblioitemnumber=
biblioitems.biblioitemnumber and biblio.biblionumber=aqorders.biblionumber
and (datecancellationprinted is NULL or datecancellationprinted =
'000-00-00')
and ((";
my @data=split(' ',$search);
my $count=@data;
for (my $i=0;$i<$count;$i++){
$query.= "(biblio.title like '$data[$i]%' or biblio.title like '% $data[$i]%') and ";
}
$query=~ s/ and $//;
$query.=" ) or biblioitems.isbn='$search'
or (aqorders.ordernumber='$search' and aqorders.biblionumber='$biblio')) ";
if ($catview ne 'yes'){
$query.=" and (quantityreceived < quantity or quantityreceived is NULL)";
}
$query.=" group by aqorders.ordernumber";
my $sth=$dbh->prepare($query);
# print $query;
$sth->execute;
my $i=0;
my @results;
while (my $data=$sth->fetchrow_hashref){
my $sth2=$dbh->prepare("Select * from biblio where
biblionumber='$data->{'biblionumber'}'");
$sth2->execute;
my $data2=$sth2->fetchrow_hashref;
$sth2->finish;
$data->{'author'}=$data2->{'author'};
$data->{'seriestitle'}=$data2->{'seriestitle'};
$sth2=$dbh->prepare("Select * from aqorderbreakdown where
ordernumber=$data->{'ordernumber'}");
$sth2->execute;
$data2=$sth2->fetchrow_hashref;
$sth2->finish;
$data->{'branchcode'}=$data2->{'branchcode'};
$data->{'bookfundid'}=$data2->{'bookfundid'};
$results[$i]=$data;
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,@results);
}
sub bookseller {
my ($searchstring)=@_;
my $dbh=C4Connect;
my $query="Select * from aqbooksellers where name like '%$searchstring%' or
id = '$searchstring'";
my $sth=$dbh->prepare($query);
$sth->execute;
my @results;
my $i=0;
while (my $data=$sth->fetchrow_hashref){
$results[$i]=$data;
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,@results);
}
sub breakdown {
my ($id)=@_;
my $dbh=C4Connect;
my $query="Select * from aqorderbreakdown where ordernumber='$id'";
my $sth=$dbh->prepare($query);
$sth->execute;
my @results;
my $i=0;
while (my $data=$sth->fetchrow_hashref){
$results[$i]=$data;
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,\@results);
}
sub basket {
my ($basketno)=@_;
my $dbh=C4Connect;
my $query="Select *,biblio.title from aqorders,biblio,biblioitems
where basketno='$basketno'
and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber
=aqorders.biblioitemnumber
and (datecancellationprinted is NULL or datecancellationprinted =
'0000-00-00')
group by aqorders.ordernumber";
my $sth=$dbh->prepare($query);
$sth->execute;
my @results;
# print $query;
my $i=0;
while (my $data=$sth->fetchrow_hashref){
$results[$i]=$data;
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,@results);
}
sub newbasket {
my $dbh=C4Connect;
my $query="Select max(basketno) from aqorders";
my $sth=$dbh->prepare($query);
$sth->execute;
my $data=$sth->fetchrow_arrayref;
my $basket=$$data[0];
$basket++;
$sth->finish;
$dbh->disconnect;
return($basket);
}
sub bookfunds {
my $dbh=C4Connect;
my $query="Select * from aqbookfund,aqbudget where aqbookfund.bookfundid
=aqbudget.bookfundid group by aqbookfund.bookfundid order by bookfundname";
my $sth=$dbh->prepare($query);
$sth->execute;
my @results;
my $i=0;
while (my $data=$sth->fetchrow_hashref){
$results[$i]=$data;
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,@results);
}
sub branches {
my $dbh=C4Connect;
my $query="Select * from branches";
my $sth=$dbh->prepare($query);
$sth->execute;
my @results;
my $i=0;
while (my $data=$sth->fetchrow_hashref){
$results[$i]=$data;
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,@results);
}
sub bookfundbreakdown {
my ($id)=@_;
my $dbh=C4Connect;
my $query="Select quantity,datereceived,freight,unitprice,listprice
from aqorders,aqorderbreakdown where bookfundid='$id' and
aqorders.ordernumber=aqorderbreakdown.ordernumber and entrydate >=
'2000-07-01' ";
my $sth=$dbh->prepare($query);
$sth->execute;
my $comtd=0;
my $spent=0;
while (my $data=$sth->fetchrow_hashref){
if ($data->{'datereceived'} =~ /0000/){
$comtd+=($data->{'listprice'}+$data->{'freight'})*$data->{'quantity'};
} else {
$spent+=($data->{'unitprice'}+$data->{'freight'})*$data->{'quantity'};
}
}
$sth->finish;
$dbh->disconnect;
return($spent,$comtd);
}
sub newbiblio {
my ($title,$author,$copyright)=@_;
my $dbh=C4Connect;
my $query="Select max(biblionumber) from biblio";
my $sth=$dbh->prepare($query);
$sth->execute;
my $data=$sth->fetchrow_arrayref;
my $bibnum=$$data[0];
$bibnum++;
$sth->finish;
$query="insert into biblio (biblionumber,title,author,copyrightdate) values
($bibnum,'$title','$author','$copyright')";
$sth=$dbh->prepare($query);
# print $query;
$sth->execute;
$sth->finish;
$dbh->disconnect;
return($bibnum);
}
sub modbiblio {
my ($bibnum,$title,$author,$copyright,$seriestitle,$serial,$unititle,$notes)=@_;
my $dbh=C4Connect;
# $title=~ s/\'/\\\'/g;
# $author=~ s/\'/\\\'/g;
my $query="update biblio set title='$title',
author='$author',copyrightdate='$copyright',
seriestitle='$seriestitle',serial='$serial',unititle='$unititle',notes='$notes'
where
biblionumber=$bibnum";
my $sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
$dbh->disconnect;
return($bibnum);
}
sub modsubtitle {
my ($bibnum,$subtitle)=@_;
my $dbh=C4Connect;
my $query="update bibliosubtitle set subtitle='$subtitle' where biblionumber=$bibnum";
my $sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
sub modaddauthor {
my ($bibnum,$author)=@_;
my $dbh=C4Connect;
my $query="Select * from additionalauthors where biblionumber=$bibnum";
my $sth=$dbh->prepare($query);
$sth->execute;
if (my $data=$sth->fetchrow_hashref){
$query="update additionalauthors set author='$author' where biblionumber=$bibnum";
} else {
$query="insert into additionalauthors (author,biblionumber) values ('$author','$bibnum')";
}
$sth->finish;
$sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
sub modsubject {
my ($bibnum,$force,@subject)=@_;
my $dbh=C4Connect;
my $count=@subject;
my $error;
for (my $i=0;$i<$count;$i++){
$subject[$i]=~ s/^ //g;
$subject[$i]=~ s/ $//g;
my $query="select * from catalogueentry where entrytype='s' and
catalogueentry='$subject[$i]'";
my $sth=$dbh->prepare($query);
$sth->execute;
if (my $data=$sth->fetchrow_hashref){
} else {
if ($force eq $subject[$i]){
#subject not in aut, chosen to force anway
#so insert into cataloguentry so its in auth file
$query="Insert into catalogueentry (entrytype,catalogueentry)
values ('s','$subject[$i]')";
my $sth2=$dbh->prepare($query);
# print $query;
$sth2->execute;
$sth2->finish;
} else {
$error="$subject[$i]\n does not exist in the subject authority file";
$query= "Select * from catalogueentry where
entrytype='s' and (catalogueentry like '$subject[$i] %' or
catalogueentry like '% $subject[$i] %' or catalogueentry like
'% $subject[$i]')";
my $sth2=$dbh->prepare($query);
# print $query;
$sth2->execute;
while (my $data=$sth2->fetchrow_hashref){
$error=$error."<br>$data->{'catalogueentry'}";
}
$sth2->finish;
# $error=$error."<br>$query";
}
}
$sth->finish;
}
if ($error eq ''){
my $query="Delete from bibliosubject where biblionumber=$bibnum";
# print $query;
my $sth=$dbh->prepare($query);
# print $query;
$sth->execute;
$sth->finish;
for (my $i=0;$i<$count;$i++){
$sth=$dbh->prepare("Insert into bibliosubject values ('$subject[$i]',$bibnum)");
# print $subject[$i];
$sth->execute;
$sth->finish;
}
}
$dbh->disconnect;
return($error);
}
sub modbibitem {
my ($bibitemnum,$itemtype,$isbn,$publishercode,$publicationdate,$classification,$dewey,$subclass,$illus,$pages,$volumeddesc,$notes,$size,$place)=@_;
my $dbh=C4Connect;
my $query="update biblioitems set itemtype='$itemtype',
isbn='$isbn',publishercode='$publishercode',publicationyear='$publicationdate',
classification='$classification',dewey='$dewey',subclass='$subclass',illus='$illus',
pages='$pages',volumeddesc='$volumeddesc',notes='$notes',size='$size',place='$place'
where
biblioitemnumber=$bibitemnum";
my $sth=$dbh->prepare($query);
# print $query;
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
sub newbiblioitem {
my ($bibnum,$itemtype,$isbn,$volinf,$class)=@_;
my $dbh=C4Connect;
my $query="Select max(biblioitemnumber) from biblioitems";
my $sth=$dbh->prepare($query);
$sth->execute;
my $data=$sth->fetchrow_arrayref;
my $bibitemnum=$$data[0];
$bibitemnum++;
$sth->finish;
$query="insert into biblioitems (biblionumber,biblioitemnumber,
itemtype,isbn,volumeddesc,classification)
values
($bibnum,$bibitemnum,'$itemtype','$isbn','$volinf','$class')";
$sth=$dbh->prepare($query);
# print $query;
$sth->execute;
$sth->finish;
$dbh->disconnect;
return($bibitemnum);
}
sub newsubject {
my ($bibnum)=@_;
my $dbh=C4Connect;
my $query="insert into bibliosubject (biblionumber) values
($bibnum)";
my $sth=$dbh->prepare($query);
# print $query;
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
sub newsubtitle {
my ($bibnum)=@_;
my $dbh=C4Connect;
my $query="insert into bibliosubtitle (biblionumber) values
($bibnum)";
my $sth=$dbh->prepare($query);
# print $query;
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
sub neworder {
my ($bibnum,$title,$ordnum,$basket,$quantity,$listprice,$supplier,$who,
$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst)=@_;
my $dbh=C4Connect;
my $query="insert into aqorders (biblionumber,title,basketno,
quantity,listprice,booksellerid,entrydate,requisitionedby,authorisedby,notes,
biblioitemnumber,rrp,ecost,gst)
values
($bibnum,'$title',$basket,$quantity,$listprice,'$supplier',now(),
'$who','$who','$notes',$bibitemnum,'$rrp','$ecost','$gst')";
my $sth=$dbh->prepare($query);
# print $query;
$sth->execute;
$sth->finish;
$query="select * from aqorders where
biblionumber=$bibnum and basketno=$basket and ordernumber >=$ordnum";
$sth=$dbh->prepare($query);
$sth->execute;
my $data=$sth->fetchrow_hashref;
$sth->finish;
$ordnum=$data->{'ordernumber'};
$query="insert into aqorderbreakdown (ordernumber,bookfundid) values
($ordnum,'$bookfund')";
$sth=$dbh->prepare($query);
# print $query;
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
sub delorder {
my ($bibnum,$ordnum)=@_;
my $dbh=C4Connect;
my $query="update aqorders set datecancellationprinted=now()
where biblionumber='$bibnum' and
ordernumber='$ordnum'";
my $sth=$dbh->prepare($query);
print $query;
$sth->execute;
$sth->finish;
my $count=itemcount($bibnum);
if ($count == 0){
delbiblio($bibnum);
}
$dbh->disconnect;
}
sub modorder {
my ($title,$ordnum,$quantity,$listprice,$bibnum,$basketno,$supplier,$who,$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst)=@_;
my $dbh=C4Connect;
my $query="update aqorders set title='$title',
quantity='$quantity',listprice='$listprice',basketno='$basketno',
rrp='$rrp',ecost='$ecost'
where
ordernumber=$ordnum and biblionumber=$bibnum";
my $sth=$dbh->prepare($query);
# print $query;
$sth->execute;
$sth->finish;
$query="update aqorderbreakdown set bookfundid=$bookfund where
ordernumber=$ordnum";
$sth=$dbh->prepare($query);
# print $query;
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
sub newordernum {
my $dbh=C4Connect;
my $query="Select max(ordernumber) from aqorders";
my $sth=$dbh->prepare($query);
$sth->execute;
my $data=$sth->fetchrow_arrayref;
my $ordnum=$$data[0];
$ordnum++;
$sth->finish;
$dbh->disconnect;
return($ordnum);
}
sub receiveorder {
my ($biblio,$ordnum,$quantrec,$user,$cost,$invoiceno,$bibitemno,$freight,$bookfund)=@_;
my $dbh=C4Connect;
my $query="update aqorders set quantityreceived='$quantrec',
datereceived=now(),booksellerinvoicenumber='$invoiceno',
biblioitemnumber=$bibitemno,unitprice='$cost',freight='$freight'
where biblionumber=$biblio and ordernumber=$ordnum
";
# print $query;
my $sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
$query="update aqorderbreakdown set bookfundid=$bookfund where
ordernumber=$ordnum";
$sth=$dbh->prepare($query);
# print $query;
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
sub curconvert {
my ($currency,$price)=@_;
my $dbh=C4Connect;
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);
}
sub getcurrencies {
my $dbh=C4Connect;
my $query="Select * from currency";
my $sth=$dbh->prepare($query);
$sth->execute;
my @results;
my $i=0;
while (my $data=$sth->fetchrow_hashref){
$results[$i]=$data;
$i++;
}
$sth->finish;
$dbh->disconnect;
return($i,\@results);
}
sub updatecurrencies {
my ($currency,$rate)=@_;
my $dbh=C4Connect;
my $query="update currency set rate=$rate where currency='$currency'";
my $sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
sub updatesup {
my ($data)=@_;
my $dbh=C4Connect;
my $query="Update aqbooksellers set
name='$data->{'name'}',address1='$data->{'address1'}',address2='$data->{'address2'}',
address3='$data->{'address3'}',address4='$data->{'address4'}',postal='$data->{'postal'}',
phone='$data->{'phone'}',fax='$data->{'fax'}',url='$data->{'url'}',
contact='$data->{'contact'}',contpos='$data->{'contpos'}',
contphone='$data->{'contphone'}', contfax='$data->{'contfax'}', contaltphone=
'$data->{'contaltphone'}', contemail='$data->{'contemail'}', contnotes=
'$data->{'contnotes'}', active=$data->{'active'},
listprice='$data->{'listprice'}', invoiceprice='$data->{'invoiceprice'}',
gstreg=$data->{'gstreg'}, listincgst=$data->{'listincgst'},
invoiceincgst=$data->{'invoiceincgst'}, specialty='$data->{'specialty'}',
discount='$data->{'discount'}'
where id='$data->{'id'}'";
my $sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
$dbh->disconnect;
# print $query;
}
sub insertsup {
my ($data)=@_;
my $dbh=C4Connect;
my $sth=$dbh->prepare("Select max(id) from aqbooksellers");
$sth->execute;
my $data2=$sth->fetchrow_hashref;
$sth->finish;
$data2->{'max(id)'}++;
$sth=$dbh->prepare("Insert into aqbooksellers (id) values ($data2->{'max(id)'})");
$sth->execute;
$sth->finish;
$data->{'id'}=$data2->{'max(id)'};
$dbh->disconnect;
updatesup($data);
return($data->{'id'});
}
sub makeitems {
my
($count,$bibitemno,$biblio,$replacement,$price,$booksellerid,$branch,$loan,@barcodes)=@_;
my $dbh=C4Connect;
my $sth=$dbh->prepare("Select max(itemnumber) from items");
$sth->execute;
my $data=$sth->fetchrow_hashref;
my $item=$data->{'max(itemnumber)'};
$sth->finish;
$item++;
my $error;
for (my $i=0;$i<$count;$i++){
$barcodes[$i]=uc $barcodes[$i];
my $query="Insert into items (biblionumber,biblioitemnumber,itemnumber,barcode,
booksellerid,dateaccessioned,homebranch,holdingbranch,price,replacementprice,
replacementpricedate,notforloan) values
($biblio,$bibitemno,$item,'$barcodes[$i]','$booksellerid',now(),'$branch',
'$branch','$price','$replacement',now(),$loan)";
my $sth=$dbh->prepare($query);
$sth->execute;
$error.=$sth->errstr;
$sth->finish;
$item++;
# print $query;
}
$dbh->disconnect;
return($error);
}
sub moditem {
my ($loan,$itemnum,$bibitemnum,$barcode,$notes,$homebranch,$lost,$wthdrawn)=@_;
my $dbh=C4Connect;
my $query="update items set biblioitemnumber=$bibitemnum,
barcode='$barcode',itemnotes='$notes'
where itemnumber=$itemnum";
if ($barcode eq ''){
$query="update items set biblioitemnumber=$bibitemnum,notforloan=$loan where itemnumber=$itemnum";
}
if ($lost ne ''){
$query="update items set biblioitemnumber=$bibitemnum,
barcode='$barcode',itemnotes='$notes',homebranch='$homebranch',
itemlost='$lost',wthdrawn='$wthdrawn' where itemnumber=$itemnum";
}
my $sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
sub countitems{
my ($bibitemnum)=@_;
my $dbh=C4Connect;
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(*)'});
}
sub findall {
my ($biblionumber)=@_;
my $dbh=C4Connect;
my $query="Select * from biblioitems,items,itemtypes where
biblioitems.biblionumber=$biblionumber
and biblioitems.biblioitemnumber=items.biblioitemnumber and
itemtypes.itemtype=biblioitems.itemtype
order by items.biblioitemnumber";
my $sth=$dbh->prepare($query);
$sth->execute;
my @results;
my $i;
while (my $data=$sth->fetchrow_hashref){
$results[$i]=$data;
$i++;
}
$sth->finish;
$dbh->disconnect;
return(@results);
}
sub needsmod{
my ($bibitemnum,$itemtype)=@_;
my $dbh=C4Connect;
my $query="Select * from biblioitems where biblioitemnumber=$bibitemnum
and itemtype='$itemtype'";
my $sth=$dbh->prepare($query);
$sth->execute;
my $result=0;
if (my $data=$sth->fetchrow_hashref){
$result=1;
}
$sth->finish;
$dbh->disconnect;
return($result);
}
sub delitem{
my ($itemnum)=@_;
my $dbh=C4Connect;
my $query="select * from items where itemnumber=$itemnum";
my $sth=$dbh->prepare($query);
$sth->execute;
my @data=$sth->fetchrow_array;
$sth->finish;
$query="Insert into deleteditems values (";
foreach my $temp (@data){
$query=$query."'$temp',";
}
$query=~ s/\,$/\)/;
# print $query;
$sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
$query = "Delete from items where itemnumber=$itemnum";
$sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
sub delbibitem{
my ($itemnum)=@_;
my $dbh=C4Connect;
my $query="select * from biblioitems where biblioitemnumber=$itemnum";
my $sth=$dbh->prepare($query);
$sth->execute;
if (my @data=$sth->fetchrow_array){
$sth->finish;
$query="Insert into deletedbiblioitems values (";
foreach my $temp (@data){
$temp=~ s/\'/\\\'/g;
$query=$query."'$temp',";
}
$query=~ s/\,$/\)/;
# print $query;
$sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
$query = "Delete from biblioitems where biblioitemnumber=$itemnum";
$sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
}
$sth->finish;
$dbh->disconnect;
}
sub delbiblio{
my ($biblio)=@_;
my $dbh=C4Connect;
my $query="select * from biblio where biblionumber=$biblio";
my $sth=$dbh->prepare($query);
$sth->execute;
if (my @data=$sth->fetchrow_array){
$sth->finish;
$query="Insert into deletedbiblio values (";
foreach my $temp (@data){
$temp=~ s/\'/\\\'/g;
$query=$query."'$temp',";
}
$query=~ s/\,$/\)/;
# print $query;
$sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
$query = "Delete from biblio where biblionumber=$biblio";
$sth=$dbh->prepare($query);
$sth->execute;
$sth->finish;
}
$sth->finish;
$dbh->disconnect;
}
END { } # module clean-up code here (global destructor)

100
C4/Circmain.pm

@ -0,0 +1,100 @@
package C4::Circmain; #asummes C4/Circulation
#package to deal with circulation
use strict;
require Exporter;
use DBI;
use C4::Database;
use C4::Circulation::Main;
use C4::Circulation::Issues;
use C4::Circulation::Returns;
use C4::Circulation::Renewals;
use C4::Circulation::Borrower;
use C4::Reserves;
use C4::InterfaceCDK;
use C4::Security;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
# set the version for version checking
$VERSION = 0.01;
@ISA = qw(Exporter);
@EXPORT = qw(&Start_circ);
%EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
# your exported package globals go here,
# as well as any optionally exported functions
@EXPORT_OK = qw($Var1 %Hashit);
# non-exported package globals go here
use vars qw(@more $stuff);
# initalize package globals, first exported ones
my $Var1 = '';
my %Hashit = ();
# then the others (which are still accessible as $Some::Module::stuff)
my $stuff = '';
my @more = ();
# all file-scoped lexicals must be created before
# the functions below that use them.
# file-private lexicals go here
my $priv_var = '';
my %secret_hash = ();
# here's a file-private function as a closure,
# callable as &$priv_func; it cannot be prototyped.
my $priv_func = sub {
# stuff goes here.
};
# make all your functions, whether exported or not;
sub Start_circ{
my ($env)=@_;
#connect to database
#start interface
&startint($env,'Circulation');
getbranch($env);
getprinter($env);
my $donext = 'Circ';
my $reason;
my $data;
while ($donext ne 'Quit') {
if ($donext eq "Circ") {
#($reason,$data) = menu($env,'console','Circulation',
# ('Issues','Returns','Borrower Enquiries','Reserves','Log In'));
#&startint($env,"Menu");
($reason,$data) = menu($env,'console','Circulation',
('Issues','Returns','Select Branch','Select Printer'));
} else {
$data = $donext;
}
if ($data eq 'Issues') {
$donext=Issue($env); #C4::Circulation::Issues
} elsif ($data eq 'Returns') {
$donext=Returns($env); #C4::Circulation::Returns
} elsif ($data eq 'Select Branch') {
getbranch($env);
} elsif ($data eq 'Select Printer') {
getprinter($env);
} elsif ($data eq 'Borrower Enquiries') {
# $donext=Borenq($env); #C4::Circulation::Borrower - conversion
} elsif ($data eq 'Reserves'){
$donext=EnterReserves($env); #C4::Reserves
} elsif ($data eq 'Quit') {
$donext = $data;
}
}
&endint($env)
}
END { } # module clean-up code here (global destructor)

227
C4/Circulation.pm

@ -0,0 +1,227 @@
package C4::Circulation; #asummes C4/Circulation
#package to deal with circulation
use strict;
require Exporter;
use DBI;
use C4::Database;
use C4::Circulation::Issues;
use C4::Circulation::Returns;
use C4::Circulation::Renewals;
use C4::Circulation::Borrower;
use C4::Reserves;
#use C4::Interface;
use C4::Security;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
# set the version for version checking
$VERSION = 0.01;
@ISA = qw(Exporter);
@EXPORT = qw(&Start_circ &scanborrower);
#@EXPORT = qw(&Start_circ checkoverdues);
%EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
# your exported package globals go here,
# as well as any optionally exported functions
@EXPORT_OK = qw($Var1 %Hashit);
# non-exported package globals go here
use vars qw(@more $stuff);
# initalize package globals, first exported ones
my $Var1 = '';
my %Hashit = ();
# then the others (which are still accessible as $Some::Module::stuff)
my $stuff = '';
my @more = ();
# all file-scoped lexicals must be created before
# the functions below that use them.
# file-private lexicals go here
my $priv_var = '';
my %secret_hash = ();
# here's a file-private function as a closure,
# callable as &$priv_func; it cannot be prototyped.
my $priv_func = sub {
# stuff goes here.
};
# make all your functions, whether exported or not;