Browse Source

work

master
chris 22 years ago
parent
commit
6236c83e9b
  1. 321
      C4/Acquisitions.pm
  2. 45
      C4/Output.pm
  3. 34
      C4/Search.pm
  4. 8
      fixcatalog.pl
  5. 5
      modbib.pl
  6. 67
      showbudget.pl

321
C4/Acquisitions.pm

@ -10,7 +10,10 @@ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
$VERSION = 0.01;
@ISA = qw(Exporter);
@EXPORT = qw(&getorders &bookseller &breakdown &basket);
@EXPORT = qw(&getorders &bookseller &breakdown &basket &newbasket &bookfunds
&ordersearch &newbiblio &newbiblioitem &newsubject &newsubtitle &neworder
&newordernum &modbiblio &modorder &getsingleorder &invoice &receiveorder
&bookfundbreakdown &curconvert &updatesup);
%EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
# your exported package globals go here,
@ -50,7 +53,9 @@ my $priv_func = sub {
sub getorders {
my ($supplierid)=@_;
my $dbh=C4Connect;
my $query = "Select count(*),authorisedby,entrydate,basketno from aqorders where booksellerid='$supplierid'";
my $query = "Select count(*),authorisedby,entrydate,basketno from aqorders where
booksellerid='$supplierid' and (datereceived = '0000-00-00' or
datereceived is NULL)";
$query.=" group by basketno order by entrydate";
my $sth=$dbh->prepare($query);
$sth->execute;
@ -65,11 +70,82 @@ sub getorders {
return ($i,\@results);
}
sub getsingleorder {
my ($ordnum)=@_;
my $dbh=C4Connect;
my $query="Select * from biblio,biblioitems,aqorders where ordernumber=$ordnum
and biblio.biblionumber=aqorders.biblionumber and
biblioitems.biblioitemnumber=aqorders.biblioitemnumber";
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";
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)=@_;
my $dbh=C4Connect;
my $query="Select * from aqorders,biblioitems
where aqorders.biblioitemnumber=
biblioitems.biblioitemnumber
and (aqorders.title like '%$search%' or biblioitems.isbn='$search'
or aqorders.ordernumber='$search')
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'};
$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 like '$searchstring%'";
id = '$searchstring'";
my $sth=$dbh->prepare($query);
$sth->execute;
my @results;
@ -103,10 +179,13 @@ sub breakdown {
sub basket {
my ($basketno)=@_;
my $dbh=C4Connect;
my $query="Select * from aqorders where basketno='$basketno'";
my $query="Select * from aqorders,biblio,biblioitems where basketno='$basketno'
and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber
=aqorders.biblioitemnumber 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;
@ -117,6 +196,240 @@ sub basket {
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";
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 >=
'1999-06-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)=@_;
my $dbh=C4Connect;
my $query="update biblio set title='$title',
author='$author',copyrightdate='$copyright' where
biblionumber=$bibnum";
my $sth=$dbh->prepare($query);
# print $query;
$sth->execute;
$sth->finish;
$dbh->disconnect;
return($bibnum);
}
sub newbiblioitem {
my ($bibnum,$itemtype,$isbn)=@_;
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)
values
($bibnum,$bibitemnum,'$itemtype','$isbn')";
$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)=@_;
my $dbh=C4Connect;
my $query="insert into aqorders (biblionumber,title,ordernumber,basketno,
quantity,listprice,booksellerid,entrydate,requisitionedby,authorisedby,notes,
biblioitemnumber)
values
($bibnum,'$title',$ordnum,$basket,$quantity,$listprice,'$supplier',now(),
'$who','$who','$notes',$bibitemnum)";
my $sth=$dbh->prepare($query);
# print $query;
$sth->execute;
$sth->finish;
$query="insert into aqorderbreakdown (ordernumber,bookfundid) values
($ordnum,'$bookfund')";
$sth=$dbh->prepare($query);
# print $query;
$sth->execute;
$sth->finish;
$dbh->disconnect;
}
sub modorder {
my ($title,$ordnum,$quantity,$listprice)=@_;
my $dbh=C4Connect;
my $query="update aqorders set title='$title',
quantity='$quantity',listprice='$listprice' where
ordernum=$ordnum";
my $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)=@_;
my $dbh=C4Connect;
my $query="update aqorders set quantityreceived='$quantrec',
datereceived=now(),booksellerinvoicenumber='$invoiceno',
biblioitemnumber=$bibitemno,unitprice=$cost
where biblionumber=$biblio and ordernumber=$ordnum
";
# print $query;
my $sth=$dbh->prepare($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'};
my $price=$price / $cur;
return($price);
}
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;
}
END { } # module clean-up code here (global destructor)

45
C4/Output.pm

@ -66,13 +66,15 @@ sub gotopage{
sub startmenu{
my ($type)=@_;
if ($type eq 'issue') {
open (FILE,'/usr/local/www/koha/htdocs/includes/issues-top.inc');
open (FILE,'/usr/local/www/hdl/htdocs/includes/issues-top.inc') || die;
} elsif ($type eq 'opac') {
open (FILE,'/usr/local/www/koha/htdocs/includes/opac-top.inc');
open (FILE,'/usr/local/www/hdl/htdocs/includes/opac-top.inc') || die;
} elsif ($type eq 'member') {
open (FILE,'/usr/local/www/koha/htdocs/includes/members-top.inc');
open (FILE,'/usr/local/www/hdl/htdocs/includes/members-top.inc') || die;
} elsif ($type eq 'acquisitions'){
open (FILE,'/usr/local/www/hdl/htdocs/includes/aquisitions-top.inc') || die;
} else {
open (FILE,'/usr/local/www/koha/htdocs/includes/cat-top.inc');
open (FILE,'/usr/local/www/hdl/htdocs/includes/cat-top.inc') || die;
}
my @string=<FILE>;
close FILE;
@ -85,13 +87,15 @@ sub startmenu{
sub endmenu{
my ($type)=@_;
if ($type eq 'issue'){
open (FILE,'/usr/local/www/koha/htdocs/includes/issues-bottom.inc');
open (FILE,'/usr/local/www/hdl/htdocs/includes/issues-bottom.inc') || die;
} elsif ($type eq 'opac') {
open (FILE,'/usr/local/www/koha/htdocs/includes/opac-bottom.inc');
open (FILE,'/usr/local/www/hdl/htdocs/includes/opac-bottom.inc') || die;
} elsif ($type eq 'member') {
open (FILE,'/usr/local/www/koha/htdocs/includes/members-bottom.inc');
open (FILE,'/usr/local/www/hdl/htdocs/includes/members-bottom.inc') || die;
} elsif ($type eq 'acquisitions') {
open (FILE,'/usr/local/www/hdl/htdocs/includes/aquisitions-bottom.inc') || die;
} else {
open (FILE,'/usr/local/www/koha/htdocs/includes/cat-bottom.inc');
open (FILE,'/usr/local/www/hdl/htdocs/includes/cat-bottom.inc') || die;
}
my @string=<FILE>;
close FILE;
@ -137,26 +141,30 @@ sub mkform{
my $string="<form action=$action method=post>\n";
$string=$string.mktablehdr();
my $key;
my @order;
while ( my ($key, $value) = each %inputs) {
my @keys=sort keys %inputs;
my $count=@keys;
my $i2=0;
while ( $i2<$count) {
my $value=$inputs{$keys[$i2]};
my @data=split('\t',$value);
#my $posn = shift(@data);
if ($data[0] eq 'hidden'){
$string=$string."<input type=hidden name=$key value=\"$data[1]\">\n";
$string=$string."<input type=hidden name=$keys[$i2] value=\"$data[1]\">\n";
} else {
my $text;
if ($data[0] eq 'radio') {
$text="<input type=radio name=$key value=$data[1]>$data[1]
<input type=radio name=$key value=$data[2]>$data[2]";
$text="<input type=radio name=$keys[$i2] value=$data[1]>$data[1]
<input type=radio name=$keys[$i2] value=$data[2]>$data[2]";
}
if ($data[0] eq 'text') {
$text="<input type=$data[0] name=$key value=\"$data[1]\">";
$text="<input type=$data[0] name=$keys[$i2] value=\"$data[1]\">";
}
if ($data[0] eq 'textarea') {
$text="<textarea name=$key wrap=physical cols=40 rows=4>$data[1]</textarea>";
$text="<textarea name=$keys[$i2] wrap=physical cols=40 rows=4>$data[1]</textarea>";
}
if ($data[0] eq 'select') {
$text="<select name=$key>";
$text="<select name=$keys[$i2]>";
my $i=1;
while ($data[$i] ne "") {
my $val = $data[$i+1];
@ -165,9 +173,10 @@ sub mkform{
}
$text=$text."</select>";
}
$string=$string.mktablerow(2,'white',$key,$text);
#@order[$posn] =mktablerow(2,'white',$key,$text);
$string=$string.mktablerow(2,'white',$keys[$i2],$text);
#@order[$posn] =mktablerow(2,'white',$keys[$i2],$text);
}
$i2++;
}
#$string=$string.join("\n",@order);
$string=$string.mktablerow(2,'white','<input type=submit>','<input type=reset>');

34
C4/Search.pm

@ -352,18 +352,19 @@ sub CatSearch {
my $search2=uc $search->{'isbn'};
my $query1 = "select * from biblioitems where isbn='$search2'";
my $sth1=$dbh->prepare($query1);
print $query1;
$sth1->execute;
my $i2=0;
while (my $data=$sth1->fetchrow_hashref) {
$query="select * from items,biblio where
$query="select * from biblioitems,biblio where
biblio.biblionumber = $data->{'biblionumber'}
and items.biblionumber = biblio.biblionumber";
and biblioitems.biblionumber = biblio.biblionumber";
my $sth=$dbh->prepare($query);
# $sth->execute;
# my $data=$sth->fetchrow_hashref;
$results[$i2]="$data->{'author'}\t$data->{'title'}\t$data->{'biblionumber'}";
$sth->execute;
my $data=$sth->fetchrow_hashref;
$results[$i2]="$data->{'author'}\t$data->{'title'}\t$data->{'biblionumber'}\t$data->{'copyrightdate'}\t$data->{'isbn'}\t$data->{'itemtype'}";
$i2++;
# $sth->finish;
$sth->finish;
}
$sth1->finish;
}
@ -404,22 +405,11 @@ sub CatSearch {
my $i=0;
my $i2=0;
my $limit=$num+$offset;
# if ($search->{'title'} ne '' || $search->{'author'} ne '' ){
# while ((my $data=$sth->fetchrow_hashref) && $i < $limit){
# if ($i >= $offset){
#
# $results[$i2]="$data->{'author'}\t$data->{'title'}\t$data->{'biblionumber'}";
# $i2++;
# }
# $i++;
# }
# } else {
while (my $data=$sth->fetchrow_hashref){
if ($type ne 'subject'){
$results[$i]="$data->{'author'}\t$data->{'title'}\t$data->{'biblionumber'}\t$data->{'copyrightdate'}";
} elsif ($search->{'isbn'} ne ''){
} else {
while (my $data=$sth->fetchrow_hashref){
if ($type ne 'subject' && $type ne 'precise'){
$results[$i]="$data->{'author'}\t$data->{'title'}\t$data->{'biblionumber'}\t$data->{'copyrightdate'}";
} elsif ($search->{'isbn'} ne ''){
} else {
$results[$i]="$data->{'author'}\t$data->{'subject'}\t$data->{'biblionumber'}\t$data->{'copyrightdate'}";
}
$i++;

8
fixcatalog.pl

@ -15,7 +15,7 @@ $sth->finish;
while (my $da=<STDIN>){
chomp $da;
my @temp=split('\t',$da);
if ($temp[1] =~ /t/){
# if ($temp[1] =~ /t/){
my $dat=$temp[0];
# print "hey";
while ( my ($key, $value) = each %stop) {
@ -25,10 +25,10 @@ while (my $da=<STDIN>){
}
$dat=~ s/\'//g;
print "$temp[0]\t$temp[1]\t \t \t \t$dat\n";
} else {
print $da,"\n";
# } else {
# print $da,"\n";
# print $temp[1],"\n";
}
# }
}
$dbh->disconnect;

5
modbib.pl

@ -40,8 +40,9 @@ $inputs{'Publication Year'}="text\t$data->{'publicationyear'}";
$inputs{'Volume'}="text\t$data->{'volumedesc'}";
$inputs{'Illustrations'}="text\t$data->{'illustration'}";
$inputs{'Pages'}="text\t$data->{'pages'}";
print mkform('wah',%inputs);
$inputs{'bibnum'}="hidden\t$data->{'biblionumber'}";
$inputs{'bibitemnum'}="hidden\t$data->{'biblioitemnumber'}";
print mkform('updatebiblio.pl',%inputs);
#print mktablehdr();
#print mktableft();
print endmenu();

67
showbudget.pl

@ -5,8 +5,13 @@
#called as an include by the acquisitions index page
use C4::Acquisitions;
#use CGI;
#my $inp=new CGI;
#print $inp->header;
my ($count,@results)=bookfunds;
print <<printend
open (FILE,'>/usr/local/www/hdl/htdocs/includes/budgets.inc') || die "Cant open file";
print FILE <<printend
<TABLE width="40%" cellspacing=0 cellpadding=5 border=1 >
<FORM ACTION="/cgi-bin/koha/search.pl">
@ -18,32 +23,48 @@ print <<printend
<tr><td>
<b>Budgets</B></TD> <TD><b>Total</B></TD> <TD><b>Spent</B></TD><TD><b>Comtd</B></TD><TD><b>Avail</B></TD></TR>
<tr><td>
<A HREF="total-budget-1.html">Fund Name</a> </TD> <TD>$10 000</TD> <TD>$6000</TD><TD>$3000</TD><TD>$1000</TD></TR>
<tr><td>
<A HREF="total-budget-2.html">Children</a> </TD> <TD>$10 000</TD> <TD>$6000</TD><TD>$3000</TD><TD>$1000</TD></TR>
<tr><td>
<A HREF="total-budget-3.html">Maori</a> </TD> <TD>$10 000</TD> <TD>$6000</TD><TD>$3000</TD><TD>$1000</TD></TR>
<tr><td>
<A HREF="total-budget-4.html">Talking Books</a> </TD> <TD>$10 000</TD> <TD>$6000</TD><TD>$3000</TD><TD>$1000</TD></TR>
<tr><td>
<A HREF="total-budget-5.html">etc</a> </TD> <TD>$10 000</TD> <TD>$6000</TD><TD>$3000</TD><TD>$1000</TD></TR>
printend
;
my $total=0;
my $totspent=0;
my $totcomtd=0;
my $totavail=0;
for (my $i=0;$i<$count;$i++){
my ($spent,$comtd)=bookfundbreakdown($results[$i]->{'bookfundid'});
my $avail=$results[$i]->{'budgetamount'}-($spent+$comtd);
print FILE <<EOP
<tr><td>
<A HREF="total-budget-6.html">fund name</a> </TD> <TD>$10 000</TD> <TD>$6000</TD><TD>$3000</TD><TD>$1000</TD></TR>
<A HREF="total-budget-1.html">$results[$i]->{'bookfundname'}</a> </TD>
<TD>$results[$i]->{'budgetamount'}</TD> <TD>
EOP
;
printf FILE ("%.2f", $spent);
print FILE "</TD><TD>";
printf FILE ("%.2f",$comtd);
print FILE "</TD><TD>";
printf FILE ("%.2f",$avail);
print FILE "</TD></TR>";
$total+=$results[$i]->{'budgetamount'};
$totspent+=$spent;
$totcomtd+=$comtd;
$totavail+=$avail;
}
print FILE <<printend
<tr><td colspan=5>
<hr size=1 noshade></TD></TR>
<tr><td>
<A HREF="total.html">Total</a> </TD> <TD>$60 000</TD> <TD>$36000</TD><TD>$18000</TD><TD>$6000</TD></TR>
<A HREF="total.html">Total</a> </TD> <TD>$total</TD> <TD>
printend
;
printf FILE ("%.2f",$totspent);
print FILE "</TD><TD>";
printf FILE ("%.2f",$totcomtd);
print FILE "</TD><TD>";
printf FILE ("%.2f",$totavail);
print FILE "</TD></TR>";
print FILE <<printend
</table><br>
Use your reload button [ctrl + r] to get the most recent figures.
Committed figures are approximate only, as exchange rates will affect the amount actually paid.
@ -54,3 +75,5 @@ Committed figures are approximate only, as exchange rates will affect the amount
printend
;
close FILE;
Loading…
Cancel
Save