1 package C4::Acquisition;
3 # Copyright 2000-2002 Katipo Communications
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 USA
26 use vars qw($VERSION @ISA @EXPORT);
28 # set the version for version checking
33 C4::Acquisition - Koha functions for dealing with orders and acquisitions
41 The functions in this module deal with acquisitions, managing book
42 orders, converting money to different currencies, and so forth.
52 &getbasket &getbasketcontent &newbasket &closebasket
54 &getorders &getallorders &getrecorders
55 &getorder &neworder &delorder
57 &modorder &getsingleorder &invoice &receiveorder
58 &updaterecorder &newordernum
60 &bookfunds &curconvert &getcurrencies &bookfundbreakdown
61 &updatecurrencies &getcurrency
63 &branches &updatesup &insertsup
64 &bookseller &breakdown
76 $aqbasket = &getbasket($basketnumber);
78 get all basket informations in aqbasket for a given basket
83 my $dbh=C4::Context->dbh;
84 my $sth=$dbh->prepare("select aqbasket.*,borrowers.firstname+' '+borrowers.surname as authorisedbyname from aqbasket left join borrowers on aqbasket.authorisedby=borrowers.borrowernumber where basketno=?");
85 $sth->execute($basketno);
86 return($sth->fetchrow_hashref);
89 =item getbasketcontent
91 ($count, @orders) = &getbasketcontent($basketnumber, $booksellerID);
93 Looks up the pending (non-cancelled) orders with the given basket
94 number. If C<$booksellerID> is non-empty, only orders from that seller
97 C<&basket> returns a two-element array. C<@orders> is an array of
98 references-to-hash, whose keys are the fields from the aqorders,
99 biblio, and biblioitems tables in the Koha database. C<$count> is the
100 number of elements in C<@orders>.
104 sub getbasketcontent {
105 my ($basketno,$supplier)=@_;
106 my $dbh = C4::Context->dbh;
107 my $query="Select *,biblio.title from aqorders,biblio,biblioitems
108 where basketno='$basketno'
109 and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber
110 =aqorders.biblioitemnumber
111 and (datecancellationprinted is NULL or datecancellationprinted =
113 if ($supplier ne ''){
114 $query.=" and aqorders.booksellerid='$supplier'";
116 $query.=" order by biblioitems.publishercode";
117 my $sth=$dbh->prepare($query);
122 while (my $data=$sth->fetchrow_hashref){
132 $basket = &newbasket();
134 Create a new basket in aqbasket table
138 my ($booksellerid,$authorisedby) = @_;
139 my $dbh = C4::Context->dbh;
140 my $sth=$dbh->do("insert into aqbasket (creationdate,booksellerid,authorisedby) values(now(),'$booksellerid','$authorisedby')");
141 #find & return basketno MYSQL dependant, but $dbh->last_insert_id always returns null :-(
142 my $basket = $dbh->{'mysql_insertid'};
148 &newbasket($basketno);
150 close a basket (becomes unmodifiable,except for recieves
155 my $dbh = C4::Context->dbh;
156 my $sth=$dbh->prepare("update aqbasket set closedate=now() where basketno=?");
157 $sth->execute($basketno);
162 &neworder($basket, $biblionumber, $title, $quantity, $listprice,
163 $booksellerid, $who, $notes, $bookfund, $biblioitemnumber, $rrp,
164 $ecost, $gst, $budget, $unitprice, $subscription,
165 $booksellerinvoicenumber);
167 Adds a new order to the database. Any argument that isn't described
168 below is the new value of the field with the same name in the aqorders
169 table of the Koha database.
171 C<$ordnum> is a "minimum order number." After adding the new entry to
172 the aqorders table, C<&neworder> finds the first entry in aqorders
173 with order number greater than or equal to C<$ordnum>, and adds an
174 entry to the aqorderbreakdown table, with the order number just found,
175 and the book fund ID of the newly-added order.
177 C<$budget> is effectively ignored.
179 C<$subscription> may be either "yes", or anything else for "no".
184 my ($basketno,$bibnum,$title,$quantity,$listprice,$booksellerid,$authorisedby,$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst,$budget,$cost,$sub,$invoice,$sort1,$sort2)=@_;
185 if ($budget eq 'now'){
188 $budget="'2001-07-01'";
195 # if $basket empty, it's also a new basket, create it
197 $basketno=newbasket($booksellerid,$authorisedby);
199 my $dbh = C4::Context->dbh;
200 my $sth=$dbh->prepare("insert into aqorders
201 (biblionumber,title,basketno,quantity,listprice,notes,
202 biblioitemnumber,rrp,ecost,gst,unitprice,subscription,sort1,sort2)
203 values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
204 $sth->execute($bibnum,$title,$basketno,$quantity,$listprice,$notes,
205 $bibitemnum,$rrp,$ecost,$gst,$cost,$sub,$sort1,$sort2);
207 #get ordnum MYSQL dependant, but $dbh->last_insert_id returns null
208 my $ordnum = $dbh->{'mysql_insertid'};
209 $sth=$dbh->prepare("insert into aqorderbreakdown (ordernumber,bookfundid) values
211 $sth->execute($ordnum,$bookfund);
218 &delorder($biblionumber, $ordernumber);
220 Cancel the order with the given order and biblio numbers. It does not
221 delete any entries in the aqorders table, it merely marks them as
224 If there are no items remaining with the given biblionumber,
225 C<&delorder> also deletes them from the marc_subfield_table and
226 marc_biblio tables of the Koha database.
231 my ($bibnum,$ordnum)=@_;
232 my $dbh = C4::Context->dbh;
233 my $sth=$dbh->prepare("update aqorders set datecancellationprinted=now()
234 where biblionumber=? and ordernumber=?");
235 $sth->execute($bibnum,$ordnum);
237 my $count=itemcount($bibnum);
245 &modorder($title, $ordernumber, $quantity, $listprice,
246 $biblionumber, $basketno, $supplier, $who, $notes,
247 $bookfundid, $bibitemnum, $rrp, $ecost, $gst, $budget,
248 $unitprice, $booksellerinvoicenumber);
250 Modifies an existing order. Updates the order with order number
251 C<$ordernumber> and biblionumber C<$biblionumber>. All other arguments
252 update the fields with the same name in the aqorders table of the Koha
255 Entries with order number C<$ordernumber> in the aqorderbreakdown
256 table are also updated to the new book fund ID.
261 my ($title,$ordnum,$quantity,$listprice,$bibnum,$basketno,$supplier,$who,$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst,$budget,$cost,$invoice,$sort1,$sort2)=@_;
262 my $dbh = C4::Context->dbh;
263 my $sth=$dbh->prepare("update aqorders set title=?,
264 quantity=?,listprice=?,basketno=?,
265 rrp=?,ecost=?,unitprice=?,
268 ordernumber=? and biblionumber=?");
269 $sth->execute($title,$quantity,$listprice,$basketno,$rrp,$ecost,$cost,$sort1,$sort2,$ordnum,$bibnum);
271 $sth=$dbh->prepare("update aqorderbreakdown set bookfundid=? where
273 if ($sth->execute($bookfund,$ordnum) == 0) { # zero rows affected [Bug 734]
274 my $query="insert into aqorderbreakdown (ordernumber,bookfundid) values (?,?)";
275 $sth=$dbh->prepare($query);
276 $sth->execute($ordnum,$bookfund);
283 $order = &newordernum();
285 Finds the next unused order number in the aqorders table of the Koha
286 database, and returns it.
290 # FIXME - Race condition
292 my $dbh = C4::Context->dbh;
293 my $sth=$dbh->prepare("Select max(ordernumber) from aqorders");
295 my $data=$sth->fetchrow_arrayref;
296 my $ordnum=$$data[0];
304 &receiveorder($biblionumber, $ordernumber, $quantityreceived, $user,
305 $unitprice, $booksellerinvoicenumber, $biblioitemnumber,
306 $freight, $bookfund, $rrp);
308 Updates an order, to reflect the fact that it was received, at least
309 in part. All arguments not mentioned below update the fields with the
310 same name in the aqorders table of the Koha database.
312 Updates the order with bibilionumber C<$biblionumber> and ordernumber
315 Also updates the book fund ID in the aqorderbreakdown table.
320 my ($biblio,$ordnum,$quantrec,$user,$cost,$invoiceno,$bibitemno,$freight,$bookfund,$rrp)=@_;
321 my $dbh = C4::Context->dbh;
322 my $sth=$dbh->prepare("update aqorders set quantityreceived=?,datereceived=now(),booksellerinvoicenumber=?,
323 biblioitemnumber=?,unitprice=?,freight=?,rrp=?
324 where biblionumber=? and ordernumber=?");
325 $sth->execute($quantrec,$invoiceno,$bibitemno,$cost,$freight,$rrp,$biblio,$ordnum);
327 $sth=$dbh->prepare("update aqorderbreakdown set bookfundid=? where
329 $sth->execute($bookfund,$ordnum);
335 &updaterecorder($biblionumber, $ordernumber, $user, $unitprice,
338 Updates the order with biblionumber C<$biblionumber> and order number
339 C<$ordernumber>. C<$bookfundid> is the new value for the book fund ID
340 in the aqorderbreakdown table of the Koha database. All other
341 arguments update the fields with the same name in the aqorders table.
348 my($biblio,$ordnum,$user,$cost,$bookfund,$rrp)=@_;
349 my $dbh = C4::Context->dbh;
350 my $sth=$dbh->prepare("update aqorders set
352 where biblionumber=? and ordernumber=?
354 $sth->execute($cost,$rrp,$biblio,$ordnum);
356 $sth=$dbh->prepare("update aqorderbreakdown set bookfundid=? where ordernumber=?");
357 $sth->execute($bookfund,$ordnum);
369 ($count, $orders) = &getorders($booksellerid);
371 Finds pending orders from the bookseller with the given ID. Ignores
372 completed and cancelled orders.
374 C<$count> is the number of elements in C<@{$orders}>.
376 C<$orders> is a reference-to-array; each element is a
377 reference-to-hash with the following fields:
383 Gives the number of orders in with this basket number.
385 =item C<authorizedby>
391 These give the value of the corresponding field in the aqorders table
392 of the Koha database.
396 Results are ordered from most to least recent.
402 my $dbh = C4::Context->dbh;
403 my $sth=$dbh->prepare("Select count(*),authorisedby,creationdate,aqbasket.basketno,closedate from aqorders left join aqbasket on
404 aqbasket.basketno=aqorders.basketno where booksellerid=? and (quantity > quantityreceived or
405 quantityreceived is NULL)
406 group by basketno order by aqbasket.basketno");
407 $sth->execute($supplierid);
409 while (my $data=$sth->fetchrow_hashref){
410 push(@results,$data);
413 return (scalar(@results),\@results);
418 ($order, $ordernumber) = &getorder($biblioitemnumber, $biblionumber);
420 Looks up the order with the given biblionumber and biblioitemnumber.
422 Returns a two-element array. C<$ordernumber> is the order number.
423 C<$order> is a reference-to-hash describing the order; its keys are
424 fields from the biblio, biblioitems, aqorders, and aqorderbreakdown
425 tables of the Koha database.
431 my $dbh = C4::Context->dbh;
432 my $sth=$dbh->prepare("Select ordernumber from aqorders where biblionumber=? and biblioitemnumber=?");
433 $sth->execute($bib,$bi);
434 # FIXME - Use fetchrow_array(), since we're only interested in the one
436 my $ordnum=$sth->fetchrow_hashref;
438 my $order=getsingleorder($ordnum->{'ordernumber'});
439 return ($order,$ordnum->{'ordernumber'});
444 $order = &getsingleorder($ordernumber);
446 Looks up an order by order number.
448 Returns a reference-to-hash describing the order. The keys of
449 C<$order> are fields from the biblio, biblioitems, aqorders, and
450 aqorderbreakdown tables of the Koha database.
456 my $dbh = C4::Context->dbh;
457 my $sth=$dbh->prepare("Select * from biblio,biblioitems,aqorders left join aqorderbreakdown
458 on aqorders.ordernumber=aqorderbreakdown.ordernumber
459 where aqorders.ordernumber=?
460 and biblio.biblionumber=aqorders.biblionumber and
461 biblioitems.biblioitemnumber=aqorders.biblioitemnumber");
462 $sth->execute($ordnum);
463 my $data=$sth->fetchrow_hashref;
470 ($count, @results) = &getallorders($booksellerid);
472 Looks up all of the pending orders from the supplier with the given
473 bookseller ID. Ignores cancelled and completed orders.
475 C<$count> is the number of elements in C<@results>. C<@results> is an
476 array of references-to-hash. The keys of each element are fields from
477 the aqorders, biblio, and biblioitems tables of the Koha database.
479 C<@results> is sorted alphabetically by book title.
484 #gets all orders from a certain supplier, orders them alphabetically
486 my $dbh = C4::Context->dbh;
488 my $sth=$dbh->prepare("Select * from aqorders,biblio,biblioitems where booksellerid=?
489 and (cancelledby is NULL or cancelledby = '')
490 and (quantityreceived < quantity or quantityreceived is NULL)
491 and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber=
492 aqorders.biblioitemnumber
493 group by aqorders.biblioitemnumber
496 $sth->execute($supid);
497 while (my $data=$sth->fetchrow_hashref){
498 push(@results,$data);
501 return(scalar(@results),@results);
506 #gets all orders from a certain supplier, orders them alphabetically
508 my $dbh = C4::Context->dbh;
510 my $sth=$dbh->prepare("Select * from aqorders,biblio,biblioitems where booksellerid=?
511 and (cancelledby is NULL or cancelledby = '')
512 and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber=
513 aqorders.biblioitemnumber and
514 aqorders.quantityreceived>0
515 and aqorders.datereceived >=now()
516 group by aqorders.biblioitemnumber
519 $sth->execute($supid);
520 while (my $data=$sth->fetchrow_hashref){
521 push(@results,$data);
524 return(scalar(@results),@results);
529 ($count, @results) = &ordersearch($search, $biblionumber, $complete);
533 C<$search> may take one of several forms: if it is an ISBN,
534 C<&ordersearch> returns orders with that ISBN. If C<$search> is an
535 order number, C<&ordersearch> returns orders with that order number
536 and biblionumber C<$biblionumber>. Otherwise, C<$search> is considered
537 to be a space-separated list of search terms; in this case, all of the
538 terms must appear in the title (matching the beginning of title
541 If C<$complete> is C<yes>, the results will include only completed
542 orders. In any case, C<&ordersearch> ignores cancelled orders.
544 C<&ordersearch> returns an array. C<$count> is the number of elements
545 in C<@results>. C<@results> is an array of references-to-hash with the
563 my ($search,$id,$biblio,$catview) = @_;
564 my $dbh = C4::Context->dbh;
565 my @data = split(' ',$search);
566 my @searchterms = ($id);
567 map { push(@searchterms,"$_%","% $_%") } @data;
568 push(@searchterms,$search,$search,$biblio);
569 my $sth=$dbh->prepare("Select *,biblio.title from aqorders,biblioitems,biblio
570 where aqorders.biblioitemnumber = biblioitems.biblioitemnumber
571 and aqorders.booksellerid = ?
572 and biblio.biblionumber=aqorders.biblionumber
573 and ((datecancellationprinted is NULL)
574 or (datecancellationprinted = '0000-00-00'))
576 .(join(" and ",map { "(biblio.title like ? or biblio.title like ?)" } @data))
577 .") or biblioitems.isbn=? or (aqorders.ordernumber=? and aqorders.biblionumber=?)) "
578 .(($catview ne 'yes')?" and (quantityreceived < quantity or quantityreceived is NULL)":"")
579 ." group by aqorders.ordernumber");
580 $sth->execute(@searchterms);
582 my $sth2=$dbh->prepare("Select * from biblio where biblionumber=?");
583 my $sth3=$dbh->prepare("Select * from aqorderbreakdown where ordernumber=?");
584 while (my $data=$sth->fetchrow_hashref){
585 $sth2->execute($data->{'biblionumber'});
586 my $data2=$sth2->fetchrow_hashref;
587 $data->{'author'}=$data2->{'author'};
588 $data->{'seriestitle'}=$data2->{'seriestitle'};
589 $sth3->execute($data->{'ordernumber'});
590 my $data3=$sth3->fetchrow_hashref;
591 $data->{'branchcode'}=$data3->{'branchcode'};
592 $data->{'bookfundid'}=$data3->{'bookfundid'};
593 push(@results,$data);
598 return(scalar(@results),@results);
608 ($count, @results) = &invoice($booksellerinvoicenumber);
610 Looks up orders by invoice number.
612 Returns an array. C<$count> is the number of elements in C<@results>.
613 C<@results> is an array of references-to-hash; the keys of each
614 elements are fields from the aqorders, biblio, and biblioitems tables
615 of the Koha database.
621 my $dbh = C4::Context->dbh;
623 my $sth=$dbh->prepare("Select * from aqorders,biblio,biblioitems where
624 booksellerinvoicenumber=?
625 and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber=
626 aqorders.biblioitemnumber group by aqorders.ordernumber,aqorders.biblioitemnumber");
627 $sth->execute($invoice);
628 while (my $data=$sth->fetchrow_hashref){
629 push(@results,$data);
632 return(scalar(@results),@results);
637 ($count, @results) = &bookfunds();
639 Returns a list of all book funds.
641 C<$count> is the number of elements in C<@results>. C<@results> is an
642 array of references-to-hash, whose keys are fields from the aqbookfund
643 and aqbudget tables of the Koha database. Results are ordered
644 alphabetically by book fund name.
649 my $dbh = C4::Context->dbh;
650 my $sth=$dbh->prepare("Select * from aqbookfund,aqbudget where aqbookfund.bookfundid
652 group by aqbookfund.bookfundid order by bookfundname");
655 while (my $data=$sth->fetchrow_hashref){
656 push(@results,$data);
659 return(scalar(@results),@results);
662 =item bookfundbreakdown
664 returns the total comtd & spent for a given bookfund
665 used in acqui-home.pl
669 sub bookfundbreakdown {
671 my $dbh = C4::Context->dbh;
672 my $sth=$dbh->prepare("Select quantity,datereceived,freight,unitprice,listprice,ecost,quantityreceived,subscription
673 from aqorders,aqorderbreakdown where bookfundid=? and
674 aqorders.ordernumber=aqorderbreakdown.ordernumber
675 and (datecancellationprinted is NULL or
676 datecancellationprinted='0000-00-00')");
680 while (my $data=$sth->fetchrow_hashref){
681 if ($data->{'subscription'} == 1){
682 $spent+=$data->{'quantity'}*$data->{'unitprice'};
684 my $leftover=$data->{'quantity'}-$data->{'quantityreceived'};
685 $comtd+=($data->{'ecost'})*$leftover;
686 $spent+=($data->{'unitprice'})*$data->{'quantityreceived'};
690 return($spent,$comtd);
697 $foreignprice = &curconvert($currency, $localprice);
699 Converts the price C<$localprice> to foreign currency C<$currency> by
700 dividing by the exchange rate, and returns the result.
702 If no exchange rate is found, C<&curconvert> assumes the rate is one
708 my ($currency,$price)=@_;
709 my $dbh = C4::Context->dbh;
710 my $sth=$dbh->prepare("Select rate from currency where currency=?");
711 $sth->execute($currency);
712 my $cur=($sth->fetchrow_array())[0];
717 return($price / $cur);
722 ($count, $currencies) = &getcurrencies();
724 Returns the list of all known currencies.
726 C<$count> is the number of elements in C<$currencies>. C<$currencies>
727 is a reference-to-array; its elements are references-to-hash, whose
728 keys are the fields from the currency table in the Koha database.
733 my $dbh = C4::Context->dbh;
734 my $sth=$dbh->prepare("Select * from currency");
737 while (my $data=$sth->fetchrow_hashref){
738 push(@results,$data);
741 return(scalar(@results),\@results);
744 =item updatecurrencies
746 &updatecurrencies($currency, $newrate);
748 Sets the exchange rate for C<$currency> to be C<$newrate>.
752 sub updatecurrencies {
753 my ($currency,$rate)=@_;
754 my $dbh = C4::Context->dbh;
755 my $sth=$dbh->prepare("update currency set rate=? where currency=?");
756 $sth->execute($rate,$currency);
768 ($count, @results) = &bookseller($searchstring);
770 Looks up a book seller. C<$searchstring> may be either a book seller
771 ID, or a string to look for in the book seller's name.
773 C<$count> is the number of elements in C<@results>. C<@results> is an
774 array of references-to-hash, whose keys are the fields of of the
775 aqbooksellers table in the Koha database.
780 my ($searchstring)=@_;
781 my $dbh = C4::Context->dbh;
782 my $sth=$dbh->prepare("Select * from aqbooksellers where name like ? or id = ?");
783 $sth->execute("$searchstring%",$searchstring);
785 while (my $data=$sth->fetchrow_hashref){
786 push(@results,$data);
789 return(scalar(@results),@results);
794 ($count, $results) = &breakdown($ordernumber);
796 Looks up an order by order ID, and returns its breakdown.
798 C<$count> is the number of elements in C<$results>. C<$results> is a
799 reference-to-array; its elements are references-to-hash, whose keys
800 are the fields of the aqorderbreakdown table in the Koha database.
806 my $dbh = C4::Context->dbh;
807 my $sth=$dbh->prepare("Select * from aqorderbreakdown where ordernumber=?");
810 while (my $data=$sth->fetchrow_hashref){
811 push(@results,$data);
814 return(scalar(@results),\@results);
819 ($count, @results) = &branches();
821 Returns a list of all library branches.
823 C<$count> is the number of elements in C<@results>. C<@results> is an
824 array of references-to-hash, whose keys are the fields of the branches
825 table of the Koha database.
830 my $dbh = C4::Context->dbh;
831 my $sth = $dbh->prepare("Select * from branches order by branchname");
835 while (my $data = $sth->fetchrow_hashref) {
836 push(@results,$data);
840 return(scalar(@results), @results);
845 &updatesup($bookseller);
847 Updates the information for a given bookseller. C<$bookseller> is a
848 reference-to-hash whose keys are the fields of the aqbooksellers table
849 in the Koha database. It must contain entries for all of the fields.
850 The entry to modify is determined by C<$bookseller-E<gt>{id}>.
852 The easiest way to get all of the necessary fields is to look up a
853 book seller with C<&booksellers>, modify what's necessary, then call
854 C<&updatesup> with the result.
860 my $dbh = C4::Context->dbh;
861 my $sth=$dbh->prepare("Update aqbooksellers set
862 name=?,address1=?,address2=?,address3=?,address4=?,postal=?,
863 phone=?,fax=?,url=?,contact=?,contpos=?,contphone=?,contfax=?,contaltphone=?,
864 contemail=?,contnotes=?,active=?,
865 listprice=?, invoiceprice=?,gstreg=?, listincgst=?,
866 invoiceincgst=?, specialty=?,discount=?,invoicedisc=?,
869 $sth->execute($data->{'name'},$data->{'address1'},$data->{'address2'},
870 $data->{'address3'},$data->{'address4'},$data->{'postal'},$data->{'phone'},
871 $data->{'fax'},$data->{'url'},$data->{'contact'},$data->{'contpos'},
872 $data->{'contphone'},$data->{'contfax'},$data->{'contaltphone'},
873 $data->{'contemail'},
874 $data->{'contnote'},$data->{'active'},$data->{'listprice'},
875 $data->{'invoiceprice'},$data->{'gstreg'},$data->{'listincgst'},
876 $data->{'invoiceincgst'},$data->{'specialty'},$data->{'discount'},
877 $data->{'invoicedisc'},$data->{'nocalc'},$data->{'id'});
883 $id = &insertsup($bookseller);
885 Creates a new bookseller. C<$bookseller> is a reference-to-hash whose
886 keys are the fields of the aqbooksellers table in the Koha database.
887 All fields must be present.
889 Returns the ID of the newly-created bookseller.
895 my $dbh = C4::Context->dbh;
896 my $sth=$dbh->prepare("Select max(id) from aqbooksellers");
898 my $data2=$sth->fetchrow_hashref;
900 $data2->{'max(id)'}++;
901 $sth=$dbh->prepare("Insert into aqbooksellers (id) values (?)");
902 $sth->execute($data2->{'max(id)'});
904 $data->{'id'}=$data2->{'max(id)'};
906 return($data->{'id'});
909 END { } # module clean-up code here (global destructor)
918 Koha Developement team <info@koha.org>