1 package C4::Acquisitions; #asummes C4/Acquisitions.pm
7 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
9 # set the version for version checking
13 @EXPORT = qw(&getorders &bookseller &breakdown &basket &newbasket &bookfunds
14 &ordersearch &newbiblio &newbiblioitem &newsubject &newsubtitle &neworder
15 &newordernum &modbiblio &modorder &getsingleorder &invoice &receiveorder
16 &bookfundbreakdown &curconvert &updatesup &insertsup &makeitems &modbibitem
17 &getcurrencies &modsubtitle &modsubject &modaddauthor &moditem &countitems
18 &findall &needsmod &delitem &delbibitem &delbiblio &delorder &branches
19 &getallorders &getrecorders &updatecurrencies &getorder &getcurrency &updaterecorder
20 &updatecost &checkitems &modnote &getitemtypes &getbiblio);
22 %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
24 # your exported package globals go here,
25 # as well as any optionally exported functions
27 @EXPORT_OK = qw($Var1 %Hashit);
30 # non-exported package globals go here
31 use vars qw(@more $stuff);
33 # initalize package globals, first exported ones
40 # then the others (which are still accessible as $Some::Module::stuff)
44 # all file-scoped lexicals must be created before
45 # the functions below that use them.
47 # file-private lexicals go here
51 # here's a file-private function as a closure,
52 # callable as &$priv_func; it cannot be prototyped.
57 # make all your functions, whether exported or not;
62 my $query = "Select count(*),authorisedby,entrydate,basketno from aqorders where
63 booksellerid='$supplierid' and (quantity > quantityreceived or
64 quantityreceived is NULL)
65 and (datecancellationprinted is NULL or datecancellationprinted = '0000-00-00')";
66 $query.=" group by basketno order by entrydate desc";
68 my $sth=$dbh->prepare($query);
72 while (my $data=$sth->fetchrow_hashref){
78 return ($i,\@results);
84 my $query="Select count(*) from items where biblionumber=$biblio";
86 my $sth=$dbh->prepare($query);
88 my $data=$sth->fetchrow_hashref;
91 return($data->{'count(*)'});
97 my $query="Select ordernumber from aqorders where biblionumber=$bib and
98 biblioitemnumber='$bi'";
99 my $sth=$dbh->prepare($query);
101 my $ordnum=$sth->fetchrow_hashref;
103 my $order=getsingleorder($ordnum->{'ordernumber'});
106 return ($order,$ordnum->{'ordernumber'});
112 my $query="Select * from biblio,biblioitems,aqorders,aqorderbreakdown
113 where aqorders.ordernumber='$ordnum'
114 and biblio.biblionumber=aqorders.biblionumber and
115 biblioitems.biblioitemnumber=aqorders.biblioitemnumber and
116 aqorders.ordernumber=aqorderbreakdown.ordernumber";
117 my $sth=$dbh->prepare($query);
119 my $data=$sth->fetchrow_hashref;
128 my $query="Select * from aqorders,biblio,biblioitems where
129 booksellerinvoicenumber='$invoice'
130 and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber=
131 aqorders.biblioitemnumber group by aqorders.ordernumber,aqorders.biblioitemnumber";
134 my $sth=$dbh->prepare($query);
136 while (my $data=$sth->fetchrow_hashref){
146 #gets all orders from a certain supplier, orders them alphabetically
149 my $query="Select * from aqorders,biblio,biblioitems where booksellerid='$supid'
150 and (cancelledby is NULL or cancelledby = '')
151 and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber=
152 aqorders.biblioitemnumber
153 group by aqorders.biblioitemnumber
158 my $sth=$dbh->prepare($query);
160 while (my $data=$sth->fetchrow_hashref){
170 #gets all orders from a certain supplier, orders them alphabetically
173 my $query="Select * from aqorders,biblio,biblioitems where booksellerid='$supid'
174 and (cancelledby is NULL or cancelledby = '')
175 and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber=
176 aqorders.biblioitemnumber and
177 aqorders.quantityreceived>0
178 and aqorders.datereceived >=now()
179 group by aqorders.biblioitemnumber
184 my $sth=$dbh->prepare($query);
186 while (my $data=$sth->fetchrow_hashref){
196 my ($search,$biblio,$catview)=@_;
198 my $query="Select *,biblio.title from aqorders,biblioitems,biblio
199 where aqorders.biblioitemnumber=
200 biblioitems.biblioitemnumber and biblio.biblionumber=aqorders.biblionumber
201 and (datecancellationprinted is NULL or datecancellationprinted =
204 my @data=split(' ',$search);
206 for (my $i=0;$i<$count;$i++){
207 $query.= "(biblio.title like '$data[$i]%' or biblio.title like '% $data[$i]%') and ";
210 $query.=" ) or biblioitems.isbn='$search'
211 or (aqorders.ordernumber='$search' and aqorders.biblionumber='$biblio')) ";
212 if ($catview ne 'yes'){
213 $query.=" and (quantityreceived < quantity or quantityreceived is NULL)";
215 $query.=" group by aqorders.ordernumber";
216 my $sth=$dbh->prepare($query);
221 while (my $data=$sth->fetchrow_hashref){
222 my $sth2=$dbh->prepare("Select * from biblio where
223 biblionumber='$data->{'biblionumber'}'");
225 my $data2=$sth2->fetchrow_hashref;
227 $data->{'author'}=$data2->{'author'};
228 $data->{'seriestitle'}=$data2->{'seriestitle'};
229 $sth2=$dbh->prepare("Select * from aqorderbreakdown where
230 ordernumber=$data->{'ordernumber'}");
232 $data2=$sth2->fetchrow_hashref;
234 $data->{'branchcode'}=$data2->{'branchcode'};
235 $data->{'bookfundid'}=$data2->{'bookfundid'};
246 my ($searchstring)=@_;
248 my $query="Select * from aqbooksellers where name like '%$searchstring%' or
249 id = '$searchstring'";
250 my $sth=$dbh->prepare($query);
254 while (my $data=$sth->fetchrow_hashref){
266 my $query="Select * from aqorderbreakdown where ordernumber='$id'";
267 my $sth=$dbh->prepare($query);
271 while (my $data=$sth->fetchrow_hashref){
277 return($i,\@results);
281 my ($basketno,$supplier)=@_;
283 my $query="Select *,biblio.title from aqorders,biblio,biblioitems
284 where basketno='$basketno'
285 and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber
286 =aqorders.biblioitemnumber
287 and (datecancellationprinted is NULL or datecancellationprinted =
289 if ($supplier ne ''){
290 $query.=" and aqorders.booksellerid='$supplier'";
292 $query.=" group by aqorders.ordernumber";
293 my $sth=$dbh->prepare($query);
298 while (my $data=$sth->fetchrow_hashref){
309 my $query="Select max(basketno) from aqorders";
310 my $sth=$dbh->prepare($query);
312 my $data=$sth->fetchrow_arrayref;
313 my $basket=$$data[0];
322 my $query="Select * from aqbookfund,aqbudget where aqbookfund.bookfundid
324 and aqbudget.startdate='2001=07-01'
325 group by aqbookfund.bookfundid order by bookfundname";
326 my $sth=$dbh->prepare($query);
330 while (my $data=$sth->fetchrow_hashref){
341 my $query="Select * from branches";
342 my $sth=$dbh->prepare($query);
346 while (my $data=$sth->fetchrow_hashref){
355 sub bookfundbreakdown {
358 my $query="Select quantity,datereceived,freight,unitprice,listprice,ecost,quantityreceived,subscription
359 from aqorders,aqorderbreakdown where bookfundid='$id' and
360 aqorders.ordernumber=aqorderbreakdown.ordernumber and ((budgetdate >=
361 '2001-07-01' and budgetdate <'2002-07-01') or
362 (datereceived >= '2001-07-01' and datereceived < '2002-07-01'))
363 and (datecancellationprinted is NULL or
364 datecancellationprinted='0000-00-00')";
365 my $sth=$dbh->prepare($query);
369 while (my $data=$sth->fetchrow_hashref){
370 if ($data->{'subscription'} == 1){
371 $spent+=$data->{'quantity'}*$data->{'unitprice'};
373 my $leftover=$data->{'quantity'}-$data->{'quantityreceived'};
374 $comtd+=($data->{'ecost'})*$leftover;
375 $spent+=($data->{'unitprice'})*$data->{'quantityreceived'};
380 return($spent,$comtd);
386 my $dbh = &C4Connect;
387 my $query = "Select max(biblionumber) from biblio";
388 my $sth = $dbh->prepare($query);
390 my $data = $sth->fetchrow_arrayref;
391 my $bibnum = $$data[0] + 1;
394 $biblio->{'title'} = $dbh->quote($biblio->{'title'});
395 $biblio->{'author'} = $dbh->quote($biblio->{'author'});
396 $biblio->{'copyright'} = $dbh->quote($biblio->{'copyright'});
397 $biblio->{'seriestitle'} = $dbh->quote($biblio->{'seriestitle'});
398 $biblio->{'notes'} = $dbh->quote($biblio->{'notes'});
399 if ($biblio->{'seriestitle'}) { $series = 1 };
402 $query = "insert into biblio set
403 biblionumber = $bibnum,
404 title = $biblio->{'title'},
405 author = $biblio->{'author'},
406 copyrightdate = $biblio->{'copyright'},
408 seriestitle = $biblio->{'seriestitle'},
409 notes = $biblio->{'notes'}";
411 $sth = $dbh->prepare($query);
421 my ($bibnum,$title,$author,$copyright,$seriestitle,$serial,$unititle,$notes)=@_;
423 my $query="update biblio set title='$title',
424 author='$author',copyrightdate='$copyright',
425 seriestitle='$seriestitle',serial='$serial',unititle='$unititle',notes='$notes'
427 biblionumber=$bibnum";
428 my $sth=$dbh->prepare($query);
436 my ($bibnum,$subtitle)=@_;
438 my $query="update bibliosubtitle set subtitle='$subtitle' where biblionumber=$bibnum";
439 my $sth=$dbh->prepare($query);
446 my ($bibnum,$author)=@_;
448 my $query="Delete from additionalauthors where biblionumber=$bibnum";
449 my $sth=$dbh->prepare($query);
453 $query="insert into additionalauthors (author,biblionumber) values ('$author','$bibnum')";
454 $sth=$dbh->prepare($query);
462 my ($bibnum,$force,@subject)=@_;
466 for (my $i=0;$i<$count;$i++){
467 $subject[$i]=~ s/^ //g;
468 $subject[$i]=~ s/ $//g;
469 my $query="select * from catalogueentry where entrytype='s' and
470 catalogueentry='$subject[$i]'";
471 my $sth=$dbh->prepare($query);
473 if (my $data=$sth->fetchrow_hashref){
476 if ($force eq $subject[$i]){
477 #subject not in aut, chosen to force anway
478 #so insert into cataloguentry so its in auth file
479 $query="Insert into catalogueentry (entrytype,catalogueentry)
480 values ('s','$subject[$i]')";
481 my $sth2=$dbh->prepare($query);
486 $error="$subject[$i]\n does not exist in the subject authority file";
487 $query= "Select * from catalogueentry where
488 entrytype='s' and (catalogueentry like '$subject[$i] %' or
489 catalogueentry like '% $subject[$i] %' or catalogueentry like
491 my $sth2=$dbh->prepare($query);
494 while (my $data=$sth2->fetchrow_hashref){
495 $error=$error."<br>$data->{'catalogueentry'}";
498 # $error=$error."<br>$query";
504 my $query="Delete from bibliosubject where biblionumber=$bibnum";
506 my $sth=$dbh->prepare($query);
510 for (my $i=0;$i<$count;$i++){
511 $sth=$dbh->prepare("Insert into bibliosubject values ('$subject[$i]',$bibnum)");
512 # print $subject[$i];
522 my ($bibitemnum,$itemtype,$isbn,$publishercode,$publicationdate,$classification,$dewey,$subclass,$illus,$pages,$volumeddesc,$notes,$size,$place)=@_;
524 my $query="update biblioitems set itemtype='$itemtype',
525 isbn='$isbn',publishercode='$publishercode',publicationyear='$publicationdate',
526 classification='$classification',dewey='$dewey',subclass='$subclass',illus='$illus',
527 pages='$pages',volumeddesc='$volumeddesc',notes='$notes',size='$size',place='$place'
529 biblioitemnumber=$bibitemnum";
530 my $sth=$dbh->prepare($query);
538 my ($bibitemnum,$note)=@_;
540 my $query="update biblioitems set notes='$note' where
541 biblioitemnumber='$bibitemnum'";
542 my $sth=$dbh->prepare($query);
549 my ($biblioitem) = @_;
551 my $query = "Select max(biblioitemnumber) from biblioitems";
552 my $sth = $dbh->prepare($query);
556 $biblioitem->{'volume'} = $dbh->quote($biblioitem->{'volume'});
557 $biblioitem->{'number'} = $dbh->quote($biblioitem->{'number'});
558 $biblioitem->{'classification'} = $dbh->quote($biblioitem->{'classification'});
559 $biblioitem->{'itemtype'} = $dbh->quote($biblioitem->{'itemtype'});
560 $biblioitem->{'isbn'} = $dbh->quote($biblioitem->{'isbn'});
561 $biblioitem->{'issn'} = $dbh->quote($biblioitem->{'issn'});
562 $biblioitem->{'dewey'} = $dbh->quote($biblioitem->{'dewey'});
563 $biblioitem->{'subclass'} = $dbh->quote($biblioitem->{'subclass'});
564 $biblioitem->{'publicationyear'} = $dbh->quote($biblioitem->{'publicationyear'});
565 $biblioitem->{'publishercode'} = $dbh->quote($biblioitem->{'publishercode'});
566 $biblioitem->{'volumedate'} = $dbh->quote($biblioitem->{'volumedate'});
567 $biblioitem->{'volumeddesc'} = $dbh->quote($biblioitem->{'volumeddesc'}); $biblioitem->{'illus'} = $dbh->quote($biblioitem->{'illus'});
568 $biblioitem->{'pages'} = $dbh->quote($biblioitem->{'pages'});
569 $biblioitem->{'notes'} = $dbh->quote($biblioitem->{'notes'});
570 $biblioitem->{'size'} = $dbh->quote($biblioitem->{'size'});
571 $biblioitem->{'place'} = $dbh->quote($biblioitem->{'place'});
574 $data = $sth->fetchrow_arrayref;
575 $bibitemnum = $$data[0] + 1;
579 $query = "insert into biblioitems set
580 biblioitemnumber = $bibitemnum,
581 biblionumber = $biblioitem->{'biblionumber'},
582 volume = $biblioitem->{'volume'},
583 number = $biblioitem->{'number'},
584 classification = $biblioitem->{'classification'},
585 itemtype = $biblioitem->{'itemtype'},
586 isbn = $biblioitem->{'isbn'},
587 issn = $biblioitem->{'issn'},
588 dewey = $biblioitem->{'dewey'},
589 subclass = $biblioitem->{'subclass'},
590 publicationyear = $biblioitem->{'publicationyear'},
591 publishercode = $biblioitem->{'publishercode'},
592 volumedate = $biblioitem->{'volumedate'},
593 volumeddesc = $biblioitem->{'volumeddesc'},
594 illus = $biblioitem->{'illus'},
595 pages = $biblioitem->{'pages'},
596 notes = $biblioitem->{'notes'},
597 size = $biblioitem->{'size'},
598 place = $biblioitem->{'place'}";
600 $sth = $dbh->prepare($query);
611 my $query="insert into bibliosubject (biblionumber) values
613 my $sth=$dbh->prepare($query);
621 my ($bibnum, $subtitle) = @_;
623 $subtitle = $dbh->quote($subtitle);
624 my $query = "insert into bibliosubtitle set
625 biblionumber = $bibnum,
626 subtitle = $subtitle";
627 my $sth = $dbh->prepare($query);
636 my ($bibnum,$title,$ordnum,$basket,$quantity,$listprice,$supplier,$who,$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst,$budget,$cost,$sub,$invoice)=@_;
637 if ($budget eq 'now'){
640 $budget="'2001-07-01'";
648 my $query="insert into aqorders (biblionumber,title,basketno,
649 quantity,listprice,booksellerid,entrydate,requisitionedby,authorisedby,notes,
650 biblioitemnumber,rrp,ecost,gst,budgetdate,unitprice,subscription,booksellerinvoicenumber)
653 ($bibnum,'$title',$basket,$quantity,$listprice,'$supplier',now(),
654 '$who','$who','$notes',$bibitemnum,'$rrp','$ecost','$gst',$budget,'$cost',
656 my $sth=$dbh->prepare($query);
660 $query="select * from aqorders where
661 biblionumber=$bibnum and basketno=$basket and ordernumber >=$ordnum";
662 $sth=$dbh->prepare($query);
664 my $data=$sth->fetchrow_hashref;
666 $ordnum=$data->{'ordernumber'};
667 $query="insert into aqorderbreakdown (ordernumber,bookfundid) values
668 ($ordnum,'$bookfund')";
669 $sth=$dbh->prepare($query);
677 my ($bibnum,$ordnum)=@_;
679 my $query="update aqorders set datecancellationprinted=now()
680 where biblionumber='$bibnum' and
681 ordernumber='$ordnum'";
682 my $sth=$dbh->prepare($query);
686 my $count=itemcount($bibnum);
694 my ($title,$ordnum,$quantity,$listprice,$bibnum,$basketno,$supplier,$who,$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst,$budget,$cost,$invoice)=@_;
696 my $query="update aqorders set title='$title',
697 quantity='$quantity',listprice='$listprice',basketno='$basketno',
698 rrp='$rrp',ecost='$ecost',unitprice='$cost',
699 booksellerinvoicenumber='$invoice'
701 ordernumber=$ordnum and biblionumber=$bibnum";
702 my $sth=$dbh->prepare($query);
706 $query="update aqorderbreakdown set bookfundid=$bookfund where
707 ordernumber=$ordnum";
708 $sth=$dbh->prepare($query);
717 my $query="Select max(ordernumber) from aqorders";
718 my $sth=$dbh->prepare($query);
720 my $data=$sth->fetchrow_arrayref;
721 my $ordnum=$$data[0];
729 my ($biblio,$ordnum,$quantrec,$user,$cost,$invoiceno,$bibitemno,$freight,$bookfund,$rrp)=@_;
731 my $query="update aqorders set quantityreceived='$quantrec',
732 datereceived=now(),booksellerinvoicenumber='$invoiceno',
733 biblioitemnumber=$bibitemno,unitprice='$cost',freight='$freight',
735 where biblionumber=$biblio and ordernumber=$ordnum
738 my $sth=$dbh->prepare($query);
741 $query="update aqorderbreakdown set bookfundid=$bookfund where
742 ordernumber=$ordnum";
743 $sth=$dbh->prepare($query);
750 my($biblio,$ordnum,$user,$cost,$bookfund,$rrp)=@_;
752 my $query="update aqorders set
753 unitprice='$cost', rrp='$rrp'
754 where biblionumber=$biblio and ordernumber=$ordnum
757 my $sth=$dbh->prepare($query);
760 $query="update aqorderbreakdown set bookfundid=$bookfund where
761 ordernumber=$ordnum";
762 $sth=$dbh->prepare($query);
770 my ($currency,$price)=@_;
772 my $query="Select rate from currency where currency='$currency'";
773 my $sth=$dbh->prepare($query);
775 my $data=$sth->fetchrow_hashref;
778 my $cur=$data->{'rate'};
782 my $price=$price / $cur;
788 my $query="Select * from currency";
789 my $sth=$dbh->prepare($query);
793 while (my $data=$sth->fetchrow_hashref){
799 return($i,\@results);
805 my $query="Select * from currency where currency='$cur'";
806 my $sth=$dbh->prepare($query);
809 my $data=$sth->fetchrow_hashref;
815 sub updatecurrencies {
816 my ($currency,$rate)=@_;
818 my $query="update currency set rate=$rate where currency='$currency'";
819 my $sth=$dbh->prepare($query);
828 my $query="Update aqbooksellers set
829 name='$data->{'name'}',address1='$data->{'address1'}',address2='$data->{'address2'}',
830 address3='$data->{'address3'}',address4='$data->{'address4'}',postal='$data->{'postal'}',
831 phone='$data->{'phone'}',fax='$data->{'fax'}',url='$data->{'url'}',
832 contact='$data->{'contact'}',contpos='$data->{'contpos'}',
833 contphone='$data->{'contphone'}', contfax='$data->{'contfax'}', contaltphone=
834 '$data->{'contaltphone'}', contemail='$data->{'contemail'}', contnotes=
835 '$data->{'contnotes'}', active=$data->{'active'},
836 listprice='$data->{'listprice'}', invoiceprice='$data->{'invoiceprice'}',
837 gstreg=$data->{'gstreg'}, listincgst=$data->{'listincgst'},
838 invoiceincgst=$data->{'invoiceincgst'}, specialty='$data->{'specialty'}',
839 discount='$data->{'discount'}',invoicedisc='$data->{'invoicedisc'}',
840 nocalc='$data->{'nocalc'}'
841 where id='$data->{'id'}'";
842 my $sth=$dbh->prepare($query);
852 my $sth=$dbh->prepare("Select max(id) from aqbooksellers");
854 my $data2=$sth->fetchrow_hashref;
856 $data2->{'max(id)'}++;
857 $sth=$dbh->prepare("Insert into aqbooksellers (id) values ($data2->{'max(id)'})");
860 $data->{'id'}=$data2->{'max(id)'};
863 return($data->{'id'});
868 ($count,$bibitemno,$biblio,$replacement,$price,$booksellerid,$branch,$loan,@barcodes)=@_;
870 my $sth=$dbh->prepare("Select max(itemnumber) from items");
872 my $data=$sth->fetchrow_hashref;
873 my $item=$data->{'max(itemnumber)'};
877 for (my $i=0;$i<$count;$i++){
878 $barcodes[$i]=uc $barcodes[$i];
879 my $query="Insert into items (biblionumber,biblioitemnumber,itemnumber,barcode,
880 booksellerid,dateaccessioned,homebranch,holdingbranch,price,replacementprice,
881 replacementpricedate,notforloan) values
882 ($biblio,$bibitemno,$item,'$barcodes[$i]','$booksellerid',now(),'$branch',
883 '$branch','$price','$replacement',now(),$loan)";
884 my $sth=$dbh->prepare($query);
886 $error.=$sth->errstr;
896 my ($count,@barcodes)=@_;
899 for (my $i=0;$i<$count;$i++){
900 $barcodes[$i]=uc $barcodes[$i];
901 my $query="Select * from items where barcode='$barcodes[$i]'";
902 my $sth=$dbh->prepare($query);
904 if (my $data=$sth->fetchrow_hashref){
905 $error.=" Duplicate Barcode: $barcodes[$i]";
914 my ($loan,$itemnum,$bibitemnum,$barcode,$notes,$homebranch,$lost,$wthdrawn,$replacement)=@_;
916 my $query="update items set biblioitemnumber=$bibitemnum,
917 barcode='$barcode',itemnotes='$notes'
918 where itemnumber=$itemnum";
920 $query="update items set biblioitemnumber=$bibitemnum,notforloan=$loan where itemnumber=$itemnum";
923 $query="update items set biblioitemnumber=$bibitemnum,
924 barcode='$barcode',itemnotes='$notes',homebranch='$homebranch',
925 itemlost='$lost',wthdrawn='$wthdrawn' where itemnumber=$itemnum";
927 if ($replacement ne ''){
928 $query=~ s/ where/,replacementprice='$replacement' where/;
931 my $sth=$dbh->prepare($query);
938 my($price,$rrp,$itemnum)=@_;
940 my $query="update items set price='$price',replacementprice='$rrp'
941 where itemnumber=$itemnum";
942 my $sth=$dbh->prepare($query);
950 my $query="Select count(*) from items where biblioitemnumber='$bibitemnum'";
951 my $sth=$dbh->prepare($query);
953 my $data=$sth->fetchrow_hashref;
956 return($data->{'count(*)'});
960 my ($biblionumber)=@_;
962 my $query="Select * from biblioitems,items,itemtypes where
963 biblioitems.biblionumber=$biblionumber
964 and biblioitems.biblioitemnumber=items.biblioitemnumber and
965 itemtypes.itemtype=biblioitems.itemtype
966 order by items.biblioitemnumber";
967 my $sth=$dbh->prepare($query);
971 while (my $data=$sth->fetchrow_hashref){
981 my ($bibitemnum,$itemtype)=@_;
983 my $query="Select * from biblioitems where biblioitemnumber=$bibitemnum
984 and itemtype='$itemtype'";
985 my $sth=$dbh->prepare($query);
988 if (my $data=$sth->fetchrow_hashref){
999 my $query="select * from items where itemnumber=$itemnum";
1000 my $sth=$dbh->prepare($query);
1002 my @data=$sth->fetchrow_array;
1004 $query="Insert into deleteditems values (";
1005 foreach my $temp (@data){
1006 $query=$query."'$temp',";
1010 $sth=$dbh->prepare($query);
1013 $query = "Delete from items where itemnumber=$itemnum";
1014 $sth=$dbh->prepare($query);
1023 my $query="select * from biblioitems where biblioitemnumber=$itemnum";
1024 my $sth=$dbh->prepare($query);
1026 if (my @data=$sth->fetchrow_array){
1028 $query="Insert into deletedbiblioitems values (";
1029 foreach my $temp (@data){
1030 $temp=~ s/\'/\\\'/g;
1031 $query=$query."'$temp',";
1035 $sth=$dbh->prepare($query);
1038 $query = "Delete from biblioitems where biblioitemnumber=$itemnum";
1039 $sth=$dbh->prepare($query);
1050 my $query="select * from biblio where biblionumber=$biblio";
1051 my $sth=$dbh->prepare($query);
1053 if (my @data=$sth->fetchrow_array){
1055 $query="Insert into deletedbiblio values (";
1056 foreach my $temp (@data){
1057 $temp=~ s/\'/\\\'/g;
1058 $query=$query."'$temp',";
1062 $sth=$dbh->prepare($query);
1065 $query = "Delete from biblio where biblionumber=$biblio";
1066 $sth=$dbh->prepare($query);
1076 my $dbh = C4Connect;
1077 my $query = "select * from itemtypes";
1078 my $sth = $dbh->prepare($query);
1079 # || die "Cannot prepare $query" . $dbh->errstr;
1084 # || die "Cannot execute $query\n" . $sth->errstr;
1085 while (my $data = $sth->fetchrow_hashref) {
1086 @results[$count] = $data;
1092 return($count, @results);
1093 } # sub getitemtypes
1097 my ($biblionumber) = @_;
1098 my $dbh = C4Connect;
1099 my $query = "Select * from biblio where biblionumber = $biblionumber";
1100 my $sth = $dbh->prepare($query);
1101 # || die "Cannot prepare $query" . $dbh->errstr;
1106 # || die "Cannot execute $query" . $sth->errstr;
1107 while (my $data = $sth->fetchrow_hashref) {
1108 $results[$count] = $data;
1114 return($count, @results);
1118 END { } # module clean-up code here (global destructor)