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);
21 %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
23 # your exported package globals go here,
24 # as well as any optionally exported functions
26 @EXPORT_OK = qw($Var1 %Hashit);
29 # non-exported package globals go here
30 use vars qw(@more $stuff);
32 # initalize package globals, first exported ones
39 # then the others (which are still accessible as $Some::Module::stuff)
43 # all file-scoped lexicals must be created before
44 # the functions below that use them.
46 # file-private lexicals go here
50 # here's a file-private function as a closure,
51 # callable as &$priv_func; it cannot be prototyped.
56 # make all your functions, whether exported or not;
61 my $query = "Select count(*),authorisedby,entrydate,basketno from aqorders where
62 booksellerid='$supplierid' and (quantity > quantityreceived or
63 quantityreceived is NULL)
64 and (datecancellationprinted is NULL or datecancellationprinted = '0000-00-00')";
65 $query.=" group by basketno order by entrydate desc";
67 my $sth=$dbh->prepare($query);
71 while (my $data=$sth->fetchrow_hashref){
77 return ($i,\@results);
83 my $query="Select count(*) from items where biblionumber=$biblio";
85 my $sth=$dbh->prepare($query);
87 my $data=$sth->fetchrow_hashref;
90 return($data->{'count(*)'});
96 my $query="Select ordernumber from aqorders where biblionumber=$bib and
97 biblioitemnumber='$bi'";
98 my $sth=$dbh->prepare($query);
100 my $ordnum=$sth->fetchrow_hashref;
102 my $order=getsingleorder($ordnum->{'ordernumber'});
105 return ($order,$ordnum->{'ordernumber'});
111 my $query="Select * from biblio,biblioitems,aqorders,aqorderbreakdown
112 where aqorders.ordernumber='$ordnum'
113 and biblio.biblionumber=aqorders.biblionumber and
114 biblioitems.biblioitemnumber=aqorders.biblioitemnumber and
115 aqorders.ordernumber=aqorderbreakdown.ordernumber";
116 my $sth=$dbh->prepare($query);
118 my $data=$sth->fetchrow_hashref;
127 my $query="Select * from aqorders,biblio,biblioitems where
128 booksellerinvoicenumber='$invoice'
129 and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber=
130 aqorders.biblioitemnumber group by aqorders.ordernumber,aqorders.biblioitemnumber";
133 my $sth=$dbh->prepare($query);
135 while (my $data=$sth->fetchrow_hashref){
145 #gets all orders from a certain supplier, orders them alphabetically
148 my $query="Select * from aqorders,biblio,biblioitems where booksellerid='$supid'
149 and (cancelledby is NULL or cancelledby = '')
150 and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber=
151 aqorders.biblioitemnumber
152 group by aqorders.biblioitemnumber
157 my $sth=$dbh->prepare($query);
159 while (my $data=$sth->fetchrow_hashref){
169 #gets all orders from a certain supplier, orders them alphabetically
172 my $query="Select * from aqorders,biblio,biblioitems where booksellerid='$supid'
173 and (cancelledby is NULL or cancelledby = '')
174 and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber=
175 aqorders.biblioitemnumber and
176 aqorders.quantityreceived>0
177 and aqorders.datereceived >=now()
178 group by aqorders.biblioitemnumber
183 my $sth=$dbh->prepare($query);
185 while (my $data=$sth->fetchrow_hashref){
195 my ($search,$biblio,$catview)=@_;
197 my $query="Select *,biblio.title from aqorders,biblioitems,biblio
198 where aqorders.biblioitemnumber=
199 biblioitems.biblioitemnumber and biblio.biblionumber=aqorders.biblionumber
200 and (datecancellationprinted is NULL or datecancellationprinted =
203 my @data=split(' ',$search);
205 for (my $i=0;$i<$count;$i++){
206 $query.= "(biblio.title like '$data[$i]%' or biblio.title like '% $data[$i]%') and ";
209 $query.=" ) or biblioitems.isbn='$search'
210 or (aqorders.ordernumber='$search' and aqorders.biblionumber='$biblio')) ";
211 if ($catview ne 'yes'){
212 $query.=" and (quantityreceived < quantity or quantityreceived is NULL)";
214 $query.=" group by aqorders.ordernumber";
215 my $sth=$dbh->prepare($query);
220 while (my $data=$sth->fetchrow_hashref){
221 my $sth2=$dbh->prepare("Select * from biblio where
222 biblionumber='$data->{'biblionumber'}'");
224 my $data2=$sth2->fetchrow_hashref;
226 $data->{'author'}=$data2->{'author'};
227 $data->{'seriestitle'}=$data2->{'seriestitle'};
228 $sth2=$dbh->prepare("Select * from aqorderbreakdown where
229 ordernumber=$data->{'ordernumber'}");
231 $data2=$sth2->fetchrow_hashref;
233 $data->{'branchcode'}=$data2->{'branchcode'};
234 $data->{'bookfundid'}=$data2->{'bookfundid'};
245 my ($searchstring)=@_;
247 my $query="Select * from aqbooksellers where name like '%$searchstring%' or
248 id = '$searchstring'";
249 my $sth=$dbh->prepare($query);
253 while (my $data=$sth->fetchrow_hashref){
265 my $query="Select * from aqorderbreakdown where ordernumber='$id'";
266 my $sth=$dbh->prepare($query);
270 while (my $data=$sth->fetchrow_hashref){
276 return($i,\@results);
280 my ($basketno,$supplier)=@_;
282 my $query="Select *,biblio.title from aqorders,biblio,biblioitems
283 where basketno='$basketno'
284 and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber
285 =aqorders.biblioitemnumber
286 and (datecancellationprinted is NULL or datecancellationprinted =
288 if ($supplier ne ''){
289 $query.=" and aqorders.booksellerid='$supplier'";
291 $query.=" group by aqorders.ordernumber";
292 my $sth=$dbh->prepare($query);
297 while (my $data=$sth->fetchrow_hashref){
308 my $query="Select max(basketno) from aqorders";
309 my $sth=$dbh->prepare($query);
311 my $data=$sth->fetchrow_arrayref;
312 my $basket=$$data[0];
321 my $query="Select * from aqbookfund,aqbudget where aqbookfund.bookfundid
323 and aqbudget.startdate='2001=07-01'
324 group by aqbookfund.bookfundid order by bookfundname";
325 my $sth=$dbh->prepare($query);
329 while (my $data=$sth->fetchrow_hashref){
340 my $query="Select * from branches";
341 my $sth=$dbh->prepare($query);
345 while (my $data=$sth->fetchrow_hashref){
354 sub bookfundbreakdown {
357 my $query="Select quantity,datereceived,freight,unitprice,listprice,ecost,quantityreceived,subscription
358 from aqorders,aqorderbreakdown where bookfundid='$id' and
359 aqorders.ordernumber=aqorderbreakdown.ordernumber and ((budgetdate >=
360 '2001-07-01' and budgetdate <'2002-07-01') or
361 (datereceived >= '2001-07-01' and datereceived < '2002-07-01'))
362 and (datecancellationprinted is NULL or
363 datecancellationprinted='0000-00-00')";
364 my $sth=$dbh->prepare($query);
368 while (my $data=$sth->fetchrow_hashref){
369 if ($data->{'subscription'} == 1){
370 $spent+=$data->{'quantity'}*$data->{'unitprice'};
372 my $leftover=$data->{'quantity'}-$data->{'quantityreceived'};
373 $comtd+=($data->{'ecost'})*$leftover;
374 $spent+=($data->{'unitprice'})*$data->{'quantityreceived'};
379 return($spent,$comtd);
385 my $dbh = &C4Connect;
386 my $query = "Select max(biblionumber) from biblio";
387 my $sth = $dbh->prepare($query);
389 my $data = $sth->fetchrow_arrayref;
390 my $bibnum = $$data[0] + 1;
393 $biblio->{'title'} = $dbh->quote($biblio->{'title'});
394 $biblio->{'author'} = $dbh->quote($biblio->{'author'});
395 $biblio->{'copyright'} = $dbh->quote($biblio->{'copyright'});
396 $biblio->{'seriestitle'} = $dbh->quote($biblio->{'seriestitle'});
397 $biblio->{'notes'} = $dbh->quote($biblio->{'notes'});
398 if ($biblio->{'seriestitle'}) { $series = 1 };
401 $query = "insert into biblio set
402 biblionumber = $bibnum,
403 title = $biblio->{'title'},
404 author = $biblio->{'author'},
405 copyrightdate = $biblio->{'copyright'},
407 seriestitle = $biblio->{'seriestitle'},
408 notes = $biblio->{'notes'}";
410 $sth = $dbh->prepare($query);
420 my ($bibnum,$title,$author,$copyright,$seriestitle,$serial,$unititle,$notes)=@_;
422 #$title=~ s/\'/\\\'/g;
423 #$author=~ s/\'/\\\'/g;
424 my $query="update biblio set title='$title',
425 author='$author',copyrightdate='$copyright',
426 seriestitle='$seriestitle',serial='$serial',unititle='$unititle',notes='$notes'
428 biblionumber=$bibnum";
429 my $sth=$dbh->prepare($query);
437 my ($bibnum,$subtitle)=@_;
439 my $query="update bibliosubtitle set subtitle='$subtitle' where biblionumber=$bibnum";
440 my $sth=$dbh->prepare($query);
447 my ($bibnum,$author)=@_;
449 my $query="Delete from additionalauthors where biblionumber=$bibnum";
450 my $sth=$dbh->prepare($query);
452 $query="insert into additionalauthors (author,biblionumber) values ('$author','$bibnum')";
454 $sth=$dbh->prepare($query);
461 my ($bibnum,$force,@subject)=@_;
465 for (my $i=0;$i<$count;$i++){
466 $subject[$i]=~ s/^ //g;
467 $subject[$i]=~ s/ $//g;
468 my $query="select * from catalogueentry where entrytype='s' and
469 catalogueentry='$subject[$i]'";
470 my $sth=$dbh->prepare($query);
472 if (my $data=$sth->fetchrow_hashref){
475 if ($force eq $subject[$i]){
476 #subject not in aut, chosen to force anway
477 #so insert into cataloguentry so its in auth file
478 $query="Insert into catalogueentry (entrytype,catalogueentry)
479 values ('s','$subject[$i]')";
480 my $sth2=$dbh->prepare($query);
485 $error="$subject[$i]\n does not exist in the subject authority file";
486 $query= "Select * from catalogueentry where
487 entrytype='s' and (catalogueentry like '$subject[$i] %' or
488 catalogueentry like '% $subject[$i] %' or catalogueentry like
490 my $sth2=$dbh->prepare($query);
493 while (my $data=$sth2->fetchrow_hashref){
494 $error=$error."<br>$data->{'catalogueentry'}";
497 # $error=$error."<br>$query";
503 my $query="Delete from bibliosubject where biblionumber=$bibnum";
505 my $sth=$dbh->prepare($query);
509 for (my $i=0;$i<$count;$i++){
510 $sth=$dbh->prepare("Insert into bibliosubject values ('$subject[$i]',$bibnum)");
511 # print $subject[$i];
521 my ($bibitemnum,$itemtype,$isbn,$publishercode,$publicationdate,$classification,$dewey,$subclass,$illus,$pages,$volumeddesc,$notes,$size,$place)=@_;
523 my $query="update biblioitems set itemtype='$itemtype',
524 isbn='$isbn',publishercode='$publishercode',publicationyear='$publicationdate',
525 classification='$classification',dewey='$dewey',subclass='$subclass',illus='$illus',
526 pages='$pages',volumeddesc='$volumeddesc',notes='$notes',size='$size',place='$place'
528 biblioitemnumber=$bibitemnum";
529 my $sth=$dbh->prepare($query);
537 my ($bibitemnum,$note)=@_;
539 my $query="update biblioitems set notes='$note' where
540 biblioitemnumber='$bibitemnum'";
541 my $sth=$dbh->prepare($query);
548 my ($biblioitem) = @_;
550 my $query = "Select max(biblioitemnumber) from biblioitems";
551 my $sth = $dbh->prepare($query);
555 $biblioitem->{'volume'} = $dbh->quote($biblioitem->{'volume'});
556 $biblioitem->{'number'} = $dbh->quote($biblioitem->{'number'});
557 $biblioitem->{'classification'} = $dbh->quote($biblioitem->{'classification'});
558 $biblioitem->{'itemtype'} = $dbh->quote($biblioitem->{'itemtype'});
559 $biblioitem->{'isbn'} = $dbh->quote($biblioitem->{'isbn'});
560 $biblioitem->{'issn'} = $dbh->quote($biblioitem->{'issn'});
561 $biblioitem->{'dewey'} = $dbh->quote($biblioitem->{'dewey'});
562 $biblioitem->{'subclass'} = $dbh->quote($biblioitem->{'subclass'});
563 $biblioitem->{'publicationyear'} = $dbh->quote($biblioitem->{'publicationyear'});
564 $biblioitem->{'publishercode'} = $dbh->quote($biblioitem->{'publishercode'});
565 $biblioitem->{'volumedate'} = $dbh->quote($biblioitem->{'volumedate'});
566 $biblioitem->{'volumeddesc'} = $dbh->quote($biblioitem->{'volumeddesc'}); $biblioitem->{'illus'} = $dbh->quote($biblioitem->{'illus'});
567 $biblioitem->{'pages'} = $dbh->quote($biblioitem->{'pages'});
568 $biblioitem->{'notes'} = $dbh->quote($biblioitem->{'notes'});
569 $biblioitem->{'size'} = $dbh->quote($biblioitem->{'size'});
570 $biblioitem->{'place'} = $dbh->quote($biblioitem->{'place'});
573 $data = $sth->fetchrow_arrayref;
574 $bibitemnum = $$data[0] + 1;
578 $query = "insert into biblioitems set
579 biblioitemnumber = $bibitemnum,
580 biblionumber = $biblioitem->{'biblionumber'},
581 volume = $biblioitem->{'volume'},
582 number = $biblioitem->{'number'},
583 classification = $biblioitem->{'classification'},
584 itemtype = $biblioitem->{'itemtype'},
585 isbn = $biblioitem->{'isbn'},
586 issn = $biblioitem->{'issn'},
587 dewey = $biblioitem->{'dewey'},
588 subclass = $biblioitem->{'subclass'},
589 publicationyear = $biblioitem->{'publicationyear'},
590 publishercode = $biblioitem->{'publishercode'},
591 volumedate = $biblioitem->{'volumedate'},
592 volumeddesc = $biblioitem->{'volumeddesc'},
593 illus = $biblioitem->{'illus'},
594 pages = $biblioitem->{'pages'},
595 notes = $biblioitem->{'notes'},
596 size = $biblioitem->{'size'},
597 place = $biblioitem->{'place'}";
599 $sth = $dbh->prepare($query);
610 my $query="insert into bibliosubject (biblionumber) values
612 my $sth=$dbh->prepare($query);
620 my ($bibnum, $subtitle) = @_;
622 $subtitle = $dbh->quote($subtitle);
623 my $query = "insert into bibliosubtitle set
624 biblionumber = $bibnum,
625 subtitle = $subtitle";
626 my $sth = $dbh->prepare($query);
635 my ($bibnum,$title,$ordnum,$basket,$quantity,$listprice,$supplier,$who,$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst,$budget,$cost,$sub,$invoice)=@_;
636 if ($budget eq 'now'){
639 $budget="'2001-07-01'";
647 my $query="insert into aqorders (biblionumber,title,basketno,
648 quantity,listprice,booksellerid,entrydate,requisitionedby,authorisedby,notes,
649 biblioitemnumber,rrp,ecost,gst,budgetdate,unitprice,subscription,booksellerinvoicenumber)
652 ($bibnum,'$title',$basket,$quantity,$listprice,'$supplier',now(),
653 '$who','$who','$notes',$bibitemnum,'$rrp','$ecost','$gst',$budget,'$cost',
655 my $sth=$dbh->prepare($query);
659 $query="select * from aqorders where
660 biblionumber=$bibnum and basketno=$basket and ordernumber >=$ordnum";
661 $sth=$dbh->prepare($query);
663 my $data=$sth->fetchrow_hashref;
665 $ordnum=$data->{'ordernumber'};
666 $query="insert into aqorderbreakdown (ordernumber,bookfundid) values
667 ($ordnum,'$bookfund')";
668 $sth=$dbh->prepare($query);
676 my ($bibnum,$ordnum)=@_;
678 my $query="update aqorders set datecancellationprinted=now()
679 where biblionumber='$bibnum' and
680 ordernumber='$ordnum'";
681 my $sth=$dbh->prepare($query);
685 my $count=itemcount($bibnum);
693 my ($title,$ordnum,$quantity,$listprice,$bibnum,$basketno,$supplier,$who,$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst,$budget,$cost,$invoice)=@_;
695 my $query="update aqorders set title='$title',
696 quantity='$quantity',listprice='$listprice',basketno='$basketno',
697 rrp='$rrp',ecost='$ecost',unitprice='$cost',
698 booksellerinvoicenumber='$invoice'
700 ordernumber=$ordnum and biblionumber=$bibnum";
701 my $sth=$dbh->prepare($query);
705 $query="update aqorderbreakdown set bookfundid=$bookfund where
706 ordernumber=$ordnum";
707 $sth=$dbh->prepare($query);
716 my $query="Select max(ordernumber) from aqorders";
717 my $sth=$dbh->prepare($query);
719 my $data=$sth->fetchrow_arrayref;
720 my $ordnum=$$data[0];
728 my ($biblio,$ordnum,$quantrec,$user,$cost,$invoiceno,$bibitemno,$freight,$bookfund,$rrp)=@_;
730 my $query="update aqorders set quantityreceived='$quantrec',
731 datereceived=now(),booksellerinvoicenumber='$invoiceno',
732 biblioitemnumber=$bibitemno,unitprice='$cost',freight='$freight',
734 where biblionumber=$biblio and ordernumber=$ordnum
737 my $sth=$dbh->prepare($query);
740 $query="update aqorderbreakdown set bookfundid=$bookfund where
741 ordernumber=$ordnum";
742 $sth=$dbh->prepare($query);
749 my($biblio,$ordnum,$user,$cost,$bookfund,$rrp)=@_;
751 my $query="update aqorders set
752 unitprice='$cost', rrp='$rrp'
753 where biblionumber=$biblio and ordernumber=$ordnum
756 my $sth=$dbh->prepare($query);
759 $query="update aqorderbreakdown set bookfundid=$bookfund where
760 ordernumber=$ordnum";
761 $sth=$dbh->prepare($query);
769 my ($currency,$price)=@_;
771 my $query="Select rate from currency where currency='$currency'";
772 my $sth=$dbh->prepare($query);
774 my $data=$sth->fetchrow_hashref;
777 my $cur=$data->{'rate'};
781 my $price=$price / $cur;
787 my $query="Select * from currency";
788 my $sth=$dbh->prepare($query);
792 while (my $data=$sth->fetchrow_hashref){
798 return($i,\@results);
804 my $query="Select * from currency where currency='$cur'";
805 my $sth=$dbh->prepare($query);
808 my $data=$sth->fetchrow_hashref;
814 sub updatecurrencies {
815 my ($currency,$rate)=@_;
817 my $query="update currency set rate=$rate where currency='$currency'";
818 my $sth=$dbh->prepare($query);
827 my $query="Update aqbooksellers set
828 name='$data->{'name'}',address1='$data->{'address1'}',address2='$data->{'address2'}',
829 address3='$data->{'address3'}',address4='$data->{'address4'}',postal='$data->{'postal'}',
830 phone='$data->{'phone'}',fax='$data->{'fax'}',url='$data->{'url'}',
831 contact='$data->{'contact'}',contpos='$data->{'contpos'}',
832 contphone='$data->{'contphone'}', contfax='$data->{'contfax'}', contaltphone=
833 '$data->{'contaltphone'}', contemail='$data->{'contemail'}', contnotes=
834 '$data->{'contnotes'}', active=$data->{'active'},
835 listprice='$data->{'listprice'}', invoiceprice='$data->{'invoiceprice'}',
836 gstreg=$data->{'gstreg'}, listincgst=$data->{'listincgst'},
837 invoiceincgst=$data->{'invoiceincgst'}, specialty='$data->{'specialty'}',
838 discount='$data->{'discount'}',invoicedisc='$data->{'invoicedisc'}',
839 nocalc='$data->{'nocalc'}'
840 where id='$data->{'id'}'";
841 my $sth=$dbh->prepare($query);
851 my $sth=$dbh->prepare("Select max(id) from aqbooksellers");
853 my $data2=$sth->fetchrow_hashref;
855 $data2->{'max(id)'}++;
856 $sth=$dbh->prepare("Insert into aqbooksellers (id) values ($data2->{'max(id)'})");
859 $data->{'id'}=$data2->{'max(id)'};
862 return($data->{'id'});
867 ($count,$bibitemno,$biblio,$replacement,$price,$booksellerid,$branch,$loan,@barcodes)=@_;
869 my $sth=$dbh->prepare("Select max(itemnumber) from items");
871 my $data=$sth->fetchrow_hashref;
872 my $item=$data->{'max(itemnumber)'};
876 for (my $i=0;$i<$count;$i++){
877 $barcodes[$i]=uc $barcodes[$i];
878 my $query="Insert into items (biblionumber,biblioitemnumber,itemnumber,barcode,
879 booksellerid,dateaccessioned,homebranch,holdingbranch,price,replacementprice,
880 replacementpricedate,notforloan) values
881 ($biblio,$bibitemno,$item,'$barcodes[$i]','$booksellerid',now(),'$branch',
882 '$branch','$price','$replacement',now(),$loan)";
883 my $sth=$dbh->prepare($query);
885 $error.=$sth->errstr;
895 my ($count,@barcodes)=@_;
898 for (my $i=0;$i<$count;$i++){
899 $barcodes[$i]=uc $barcodes[$i];
900 my $query="Select * from items where barcode='$barcodes[$i]'";
901 my $sth=$dbh->prepare($query);
903 if (my $data=$sth->fetchrow_hashref){
904 $error.=" Duplicate Barcode: $barcodes[$i]";
913 my ($loan,$itemnum,$bibitemnum,$barcode,$notes,$homebranch,$lost,$wthdrawn,$replacement)=@_;
915 my $query="update items set biblioitemnumber=$bibitemnum,
916 barcode='$barcode',itemnotes='$notes'
917 where itemnumber=$itemnum";
919 $query="update items set biblioitemnumber=$bibitemnum,notforloan=$loan where itemnumber=$itemnum";
922 $query="update items set biblioitemnumber=$bibitemnum,
923 barcode='$barcode',itemnotes='$notes',homebranch='$homebranch',
924 itemlost='$lost',wthdrawn='$wthdrawn' where itemnumber=$itemnum";
926 if ($replacement ne ''){
927 $query=~ s/ where/,replacementprice='$replacement' where/;
930 my $sth=$dbh->prepare($query);
937 my($price,$rrp,$itemnum)=@_;
939 my $query="update items set price='$price',replacementprice='$rrp'
940 where itemnumber=$itemnum";
941 my $sth=$dbh->prepare($query);
949 my $query="Select count(*) from items where biblioitemnumber='$bibitemnum'";
950 my $sth=$dbh->prepare($query);
952 my $data=$sth->fetchrow_hashref;
955 return($data->{'count(*)'});
959 my ($biblionumber)=@_;
961 my $query="Select * from biblioitems,items,itemtypes where
962 biblioitems.biblionumber=$biblionumber
963 and biblioitems.biblioitemnumber=items.biblioitemnumber and
964 itemtypes.itemtype=biblioitems.itemtype
965 order by items.biblioitemnumber";
966 my $sth=$dbh->prepare($query);
970 while (my $data=$sth->fetchrow_hashref){
980 my ($bibitemnum,$itemtype)=@_;
982 my $query="Select * from biblioitems where biblioitemnumber=$bibitemnum
983 and itemtype='$itemtype'";
984 my $sth=$dbh->prepare($query);
987 if (my $data=$sth->fetchrow_hashref){
998 my $query="select * from items where itemnumber=$itemnum";
999 my $sth=$dbh->prepare($query);
1001 my @data=$sth->fetchrow_array;
1003 $query="Insert into deleteditems values (";
1004 foreach my $temp (@data){
1005 $query=$query."'$temp',";
1009 $sth=$dbh->prepare($query);
1012 $query = "Delete from items where itemnumber=$itemnum";
1013 $sth=$dbh->prepare($query);
1022 my $query="select * from biblioitems where biblioitemnumber=$itemnum";
1023 my $sth=$dbh->prepare($query);
1025 if (my @data=$sth->fetchrow_array){
1027 $query="Insert into deletedbiblioitems values (";
1028 foreach my $temp (@data){
1029 $temp=~ s/\'/\\\'/g;
1030 $query=$query."'$temp',";
1034 $sth=$dbh->prepare($query);
1037 $query = "Delete from biblioitems where biblioitemnumber=$itemnum";
1038 $sth=$dbh->prepare($query);
1049 my $query="select * from biblio where biblionumber=$biblio";
1050 my $sth=$dbh->prepare($query);
1052 if (my @data=$sth->fetchrow_array){
1054 $query="Insert into deletedbiblio values (";
1055 foreach my $temp (@data){
1056 $temp=~ s/\'/\\\'/g;
1057 $query=$query."'$temp',";
1061 $sth=$dbh->prepare($query);
1064 $query = "Delete from biblio where biblionumber=$biblio";
1065 $sth=$dbh->prepare($query);
1075 my $dbh = C4Connect;
1076 my $query = "select * from itemtypes";
1077 my $sth = $dbh->prepare($query);
1078 # || die "Cannot prepare $query" . $dbh->errstr;
1083 # || die "Cannot execute $query\n" . $sth->errstr;
1084 while (my $data = $sth->fetchrow_hashref) {
1085 @results[$count] = $data;
1091 return($count, @results);
1092 } # sub getitemtypes
1096 my ($biblionumber) = @_;
1097 my $dbh = C4Connect;
1098 my $query = "Select * from biblio where biblionumber = $biblionumber";
1099 my $sth = $dbh->prepare($query);
1100 # || die "Cannot prepare $query" . $dbh->errstr;
1105 # || die "Cannot execute $query" . $sth->errstr;
1106 while (my $data = $sth->fetchrow_hashref) {
1107 $results[$count] = $data;
1113 return($count, @results);
1117 END { } # module clean-up code here (global destructor)