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
227 my ($bibnum,$ordnum)=@_;
228 my $dbh = C4::Context->dbh;
229 my $sth=$dbh->prepare("update aqorders set datecancellationprinted=now()
230 where biblionumber=? and ordernumber=?");
231 $sth->execute($bibnum,$ordnum);
237 &modorder($title, $ordernumber, $quantity, $listprice,
238 $biblionumber, $basketno, $supplier, $who, $notes,
239 $bookfundid, $bibitemnum, $rrp, $ecost, $gst, $budget,
240 $unitprice, $booksellerinvoicenumber);
242 Modifies an existing order. Updates the order with order number
243 C<$ordernumber> and biblionumber C<$biblionumber>. All other arguments
244 update the fields with the same name in the aqorders table of the Koha
247 Entries with order number C<$ordernumber> in the aqorderbreakdown
248 table are also updated to the new book fund ID.
253 my ($title,$ordnum,$quantity,$listprice,$bibnum,$basketno,$supplier,$who,$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst,$budget,$cost,$invoice,$sort1,$sort2)=@_;
254 my $dbh = C4::Context->dbh;
255 my $sth=$dbh->prepare("update aqorders set title=?,
256 quantity=?,listprice=?,basketno=?,
257 rrp=?,ecost=?,unitprice=?,booksellerinvoicenumber=?,
258 notes=?,sort1=?, sort2=?
260 ordernumber=? and biblionumber=?");
261 $sth->execute($title,$quantity,$listprice,$basketno,$rrp,$ecost,$cost,$invoice,$notes,$sort1,$sort2,$ordnum,$bibnum);
263 $sth=$dbh->prepare("update aqorderbreakdown set bookfundid=? where
265 if ($sth->execute($bookfund,$ordnum) == 0) { # zero rows affected [Bug 734]
266 my $query="insert into aqorderbreakdown (ordernumber,bookfundid) values (?,?)";
267 $sth=$dbh->prepare($query);
268 $sth->execute($ordnum,$bookfund);
275 $order = &newordernum();
277 Finds the next unused order number in the aqorders table of the Koha
278 database, and returns it.
282 # FIXME - Race condition
284 my $dbh = C4::Context->dbh;
285 my $sth=$dbh->prepare("Select max(ordernumber) from aqorders");
287 my $data=$sth->fetchrow_arrayref;
288 my $ordnum=$$data[0];
296 &receiveorder($biblionumber, $ordernumber, $quantityreceived, $user,
297 $unitprice, $booksellerinvoicenumber, $biblioitemnumber,
298 $freight, $bookfund, $rrp);
300 Updates an order, to reflect the fact that it was received, at least
301 in part. All arguments not mentioned below update the fields with the
302 same name in the aqorders table of the Koha database.
304 Updates the order with bibilionumber C<$biblionumber> and ordernumber
307 Also updates the book fund ID in the aqorderbreakdown table.
312 my ($biblio,$ordnum,$quantrec,$user,$cost,$invoiceno,$freight,$rrp)=@_;
313 my $dbh = C4::Context->dbh;
314 my $sth=$dbh->prepare("update aqorders set quantityreceived=?,datereceived=now(),booksellerinvoicenumber=?,
315 unitprice=?,freight=?,rrp=?
316 where biblionumber=? and ordernumber=?");
317 $sth->execute($quantrec,$invoiceno,$cost,$freight,$rrp,$biblio,$ordnum);
323 &updaterecorder($biblionumber, $ordernumber, $user, $unitprice,
326 Updates the order with biblionumber C<$biblionumber> and order number
327 C<$ordernumber>. C<$bookfundid> is the new value for the book fund ID
328 in the aqorderbreakdown table of the Koha database. All other
329 arguments update the fields with the same name in the aqorders table.
336 my($biblio,$ordnum,$user,$cost,$bookfund,$rrp)=@_;
337 my $dbh = C4::Context->dbh;
338 my $sth=$dbh->prepare("update aqorders set
340 where biblionumber=? and ordernumber=?
342 $sth->execute($cost,$rrp,$biblio,$ordnum);
344 $sth=$dbh->prepare("update aqorderbreakdown set bookfundid=? where ordernumber=?");
345 $sth->execute($bookfund,$ordnum);
357 ($count, $orders) = &getorders($booksellerid);
359 Finds pending orders from the bookseller with the given ID. Ignores
360 completed and cancelled orders.
362 C<$count> is the number of elements in C<@{$orders}>.
364 C<$orders> is a reference-to-array; each element is a
365 reference-to-hash with the following fields:
371 Gives the number of orders in with this basket number.
373 =item C<authorizedby>
379 These give the value of the corresponding field in the aqorders table
380 of the Koha database.
384 Results are ordered from most to least recent.
390 my $dbh = C4::Context->dbh;
391 my $sth=$dbh->prepare("Select count(*),authorisedby,creationdate,aqbasket.basketno,
392 closedate,surname,firstname
394 left join aqbasket on aqbasket.basketno=aqorders.basketno
395 left join borrowers on aqbasket.authorisedby=borrowers.borrowernumber
396 where booksellerid=? and (quantity > quantityreceived or
397 quantityreceived is NULL)
398 group by basketno order by aqbasket.basketno");
399 $sth->execute($supplierid);
401 while (my $data=$sth->fetchrow_hashref){
402 push(@results,$data);
405 return (scalar(@results),\@results);
410 ($order, $ordernumber) = &getorder($biblioitemnumber, $biblionumber);
412 Looks up the order with the given biblionumber and biblioitemnumber.
414 Returns a two-element array. C<$ordernumber> is the order number.
415 C<$order> is a reference-to-hash describing the order; its keys are
416 fields from the biblio, biblioitems, aqorders, and aqorderbreakdown
417 tables of the Koha database.
423 my $dbh = C4::Context->dbh;
424 my $sth=$dbh->prepare("Select ordernumber from aqorders where biblionumber=? and biblioitemnumber=?");
425 $sth->execute($bib,$bi);
426 # FIXME - Use fetchrow_array(), since we're only interested in the one
428 my $ordnum=$sth->fetchrow_hashref;
430 my $order=getsingleorder($ordnum->{'ordernumber'});
431 return ($order,$ordnum->{'ordernumber'});
436 $order = &getsingleorder($ordernumber);
438 Looks up an order by order number.
440 Returns a reference-to-hash describing the order. The keys of
441 C<$order> are fields from the biblio, biblioitems, aqorders, and
442 aqorderbreakdown tables of the Koha database.
448 my $dbh = C4::Context->dbh;
449 my $sth=$dbh->prepare("Select * from biblio,biblioitems,aqorders left join aqorderbreakdown
450 on aqorders.ordernumber=aqorderbreakdown.ordernumber
451 where aqorders.ordernumber=?
452 and biblio.biblionumber=aqorders.biblionumber and
453 biblioitems.biblioitemnumber=aqorders.biblioitemnumber");
454 $sth->execute($ordnum);
455 my $data=$sth->fetchrow_hashref;
462 ($count, @results) = &getallorders($booksellerid);
464 Looks up all of the pending orders from the supplier with the given
465 bookseller ID. Ignores cancelled and completed orders.
467 C<$count> is the number of elements in C<@results>. C<@results> is an
468 array of references-to-hash. The keys of each element are fields from
469 the aqorders, biblio, and biblioitems tables of the Koha database.
471 C<@results> is sorted alphabetically by book title.
476 #gets all orders from a certain supplier, orders them alphabetically
478 my $dbh = C4::Context->dbh;
480 my $sth=$dbh->prepare("Select * from aqorders,biblio,biblioitems,aqbasket where aqbasket.basketno=aqorders.basketno
482 and (cancelledby is NULL or cancelledby = '')
483 and (quantityreceived < quantity or quantityreceived is NULL)
484 and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber=
485 aqorders.biblioitemnumber
486 group by aqorders.biblioitemnumber
489 $sth->execute($supid);
490 while (my $data=$sth->fetchrow_hashref){
491 push(@results,$data);
494 return(scalar(@results),@results);
499 #gets all orders from a certain supplier, orders them alphabetically
501 my $dbh = C4::Context->dbh;
503 my $sth=$dbh->prepare("Select * from aqorders,biblio,biblioitems where booksellerid=?
504 and (cancelledby is NULL or cancelledby = '')
505 and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber=
506 aqorders.biblioitemnumber and
507 aqorders.quantityreceived>0
508 and aqorders.datereceived >=now()
509 group by aqorders.biblioitemnumber
512 $sth->execute($supid);
513 while (my $data=$sth->fetchrow_hashref){
514 push(@results,$data);
517 return(scalar(@results),@results);
522 ($count, @results) = &ordersearch($search, $biblionumber, $complete);
526 C<$search> may take one of several forms: if it is an ISBN,
527 C<&ordersearch> returns orders with that ISBN. If C<$search> is an
528 order number, C<&ordersearch> returns orders with that order number
529 and biblionumber C<$biblionumber>. Otherwise, C<$search> is considered
530 to be a space-separated list of search terms; in this case, all of the
531 terms must appear in the title (matching the beginning of title
534 If C<$complete> is C<yes>, the results will include only completed
535 orders. In any case, C<&ordersearch> ignores cancelled orders.
537 C<&ordersearch> returns an array. C<$count> is the number of elements
538 in C<@results>. C<@results> is an array of references-to-hash with the
556 my ($search,$id,$biblio,$catview) = @_;
557 my $dbh = C4::Context->dbh;
558 my @data = split(' ',$search);
559 my @searchterms = ($id);
560 map { push(@searchterms,"$_%","% $_%") } @data;
561 push(@searchterms,$search,$search,$biblio);
562 my $sth=$dbh->prepare("Select *,biblio.title from aqorders,biblioitems,biblio,aqbasket
563 where aqorders.biblioitemnumber = biblioitems.biblioitemnumber and
564 aqorders.basketno = aqbasket.basketno
565 and aqbasket.booksellerid = ?
566 and biblio.biblionumber=aqorders.biblionumber
567 and ((datecancellationprinted is NULL)
568 or (datecancellationprinted = '0000-00-00'))
570 .(join(" and ",map { "(biblio.title like ? or biblio.title like ?)" } @data))
571 .") or biblioitems.isbn=? or (aqorders.ordernumber=? and aqorders.biblionumber=?)) "
572 .(($catview ne 'yes')?" and (quantityreceived < quantity or quantityreceived is NULL)":"")
573 ." group by aqorders.ordernumber");
574 $sth->execute(@searchterms);
576 my $sth2=$dbh->prepare("Select * from biblio where biblionumber=?");
577 my $sth3=$dbh->prepare("Select * from aqorderbreakdown where ordernumber=?");
578 while (my $data=$sth->fetchrow_hashref){
579 $sth2->execute($data->{'biblionumber'});
580 my $data2=$sth2->fetchrow_hashref;
581 $data->{'author'}=$data2->{'author'};
582 $data->{'seriestitle'}=$data2->{'seriestitle'};
583 $sth3->execute($data->{'ordernumber'});
584 my $data3=$sth3->fetchrow_hashref;
585 $data->{'branchcode'}=$data3->{'branchcode'};
586 $data->{'bookfundid'}=$data3->{'bookfundid'};
587 push(@results,$data);
592 return(scalar(@results),@results);
602 ($count, @results) = &invoice($booksellerinvoicenumber);
604 Looks up orders by invoice number.
606 Returns an array. C<$count> is the number of elements in C<@results>.
607 C<@results> is an array of references-to-hash; the keys of each
608 elements are fields from the aqorders, biblio, and biblioitems tables
609 of the Koha database.
615 my $dbh = C4::Context->dbh;
617 my $sth=$dbh->prepare("Select * from aqorders,biblio,biblioitems where
618 booksellerinvoicenumber=?
619 and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber=
620 aqorders.biblioitemnumber group by aqorders.ordernumber,aqorders.biblioitemnumber");
621 $sth->execute($invoice);
622 while (my $data=$sth->fetchrow_hashref){
623 push(@results,$data);
626 return(scalar(@results),@results);
631 ($count, @results) = &bookfunds();
633 Returns a list of all book funds.
635 C<$count> is the number of elements in C<@results>. C<@results> is an
636 array of references-to-hash, whose keys are fields from the aqbookfund
637 and aqbudget tables of the Koha database. Results are ordered
638 alphabetically by book fund name.
643 my $dbh = C4::Context->dbh;
644 my $sth=$dbh->prepare("Select * from aqbookfund,aqbudget where aqbookfund.bookfundid
646 group by aqbookfund.bookfundid order by bookfundname");
649 while (my $data=$sth->fetchrow_hashref){
650 push(@results,$data);
653 return(scalar(@results),@results);
656 =item bookfundbreakdown
658 returns the total comtd & spent for a given bookfund
659 used in acqui-home.pl
663 sub bookfundbreakdown {
665 my $dbh = C4::Context->dbh;
666 my $sth=$dbh->prepare("Select quantity,datereceived,freight,unitprice,listprice,ecost,quantityreceived,subscription
667 from aqorders,aqorderbreakdown where bookfundid=? and
668 aqorders.ordernumber=aqorderbreakdown.ordernumber
669 and (datecancellationprinted is NULL or
670 datecancellationprinted='0000-00-00')");
674 while (my $data=$sth->fetchrow_hashref){
675 if ($data->{'subscription'} == 1){
676 $spent+=$data->{'quantity'}*$data->{'unitprice'};
678 my $leftover=$data->{'quantity'}-$data->{'quantityreceived'};
679 $comtd+=($data->{'ecost'})*$leftover;
680 $spent+=($data->{'unitprice'})*$data->{'quantityreceived'};
684 return($spent,$comtd);
691 $foreignprice = &curconvert($currency, $localprice);
693 Converts the price C<$localprice> to foreign currency C<$currency> by
694 dividing by the exchange rate, and returns the result.
696 If no exchange rate is found, C<&curconvert> assumes the rate is one
702 my ($currency,$price)=@_;
703 my $dbh = C4::Context->dbh;
704 my $sth=$dbh->prepare("Select rate from currency where currency=?");
705 $sth->execute($currency);
706 my $cur=($sth->fetchrow_array())[0];
711 return($price / $cur);
716 ($count, $currencies) = &getcurrencies();
718 Returns the list of all known currencies.
720 C<$count> is the number of elements in C<$currencies>. C<$currencies>
721 is a reference-to-array; its elements are references-to-hash, whose
722 keys are the fields from the currency table in the Koha database.
727 my $dbh = C4::Context->dbh;
728 my $sth=$dbh->prepare("Select * from currency");
731 while (my $data=$sth->fetchrow_hashref){
732 push(@results,$data);
735 return(scalar(@results),\@results);
738 =item updatecurrencies
740 &updatecurrencies($currency, $newrate);
742 Sets the exchange rate for C<$currency> to be C<$newrate>.
746 sub updatecurrencies {
747 my ($currency,$rate)=@_;
748 my $dbh = C4::Context->dbh;
749 my $sth=$dbh->prepare("update currency set rate=? where currency=?");
750 $sth->execute($rate,$currency);
762 ($count, @results) = &bookseller($searchstring);
764 Looks up a book seller. C<$searchstring> may be either a book seller
765 ID, or a string to look for in the book seller's name.
767 C<$count> is the number of elements in C<@results>. C<@results> is an
768 array of references-to-hash, whose keys are the fields of of the
769 aqbooksellers table in the Koha database.
774 my ($searchstring)=@_;
775 my $dbh = C4::Context->dbh;
776 my $sth=$dbh->prepare("Select * from aqbooksellers where name like ? or id = ?");
777 $sth->execute("$searchstring%",$searchstring);
779 while (my $data=$sth->fetchrow_hashref){
780 push(@results,$data);
783 return(scalar(@results),@results);
788 ($count, $results) = &breakdown($ordernumber);
790 Looks up an order by order ID, and returns its breakdown.
792 C<$count> is the number of elements in C<$results>. C<$results> is a
793 reference-to-array; its elements are references-to-hash, whose keys
794 are the fields of the aqorderbreakdown table in the Koha database.
800 my $dbh = C4::Context->dbh;
801 my $sth=$dbh->prepare("Select * from aqorderbreakdown where ordernumber=?");
804 while (my $data=$sth->fetchrow_hashref){
805 push(@results,$data);
808 return(scalar(@results),\@results);
813 ($count, @results) = &branches();
815 Returns a list of all library branches.
817 C<$count> is the number of elements in C<@results>. C<@results> is an
818 array of references-to-hash, whose keys are the fields of the branches
819 table of the Koha database.
824 my $dbh = C4::Context->dbh;
825 my $sth = $dbh->prepare("Select * from branches order by branchname");
829 while (my $data = $sth->fetchrow_hashref) {
830 push(@results,$data);
834 return(scalar(@results), @results);
839 &updatesup($bookseller);
841 Updates the information for a given bookseller. C<$bookseller> is a
842 reference-to-hash whose keys are the fields of the aqbooksellers table
843 in the Koha database. It must contain entries for all of the fields.
844 The entry to modify is determined by C<$bookseller-E<gt>{id}>.
846 The easiest way to get all of the necessary fields is to look up a
847 book seller with C<&booksellers>, modify what's necessary, then call
848 C<&updatesup> with the result.
854 my $dbh = C4::Context->dbh;
855 my $sth=$dbh->prepare("Update aqbooksellers set
856 name=?,address1=?,address2=?,address3=?,address4=?,postal=?,
857 phone=?,fax=?,url=?,contact=?,contpos=?,contphone=?,contfax=?,contaltphone=?,
858 contemail=?,contnotes=?,active=?,
859 listprice=?, invoiceprice=?,gstreg=?, listincgst=?,
860 invoiceincgst=?, specialty=?,discount=?,invoicedisc=?,
863 $sth->execute($data->{'name'},$data->{'address1'},$data->{'address2'},
864 $data->{'address3'},$data->{'address4'},$data->{'postal'},$data->{'phone'},
865 $data->{'fax'},$data->{'url'},$data->{'contact'},$data->{'contpos'},
866 $data->{'contphone'},$data->{'contfax'},$data->{'contaltphone'},
867 $data->{'contemail'},
868 $data->{'contnote'},$data->{'active'},$data->{'listprice'},
869 $data->{'invoiceprice'},$data->{'gstreg'},$data->{'listincgst'},
870 $data->{'invoiceincgst'},$data->{'specialty'},$data->{'discount'},
871 $data->{'invoicedisc'},$data->{'nocalc'},$data->{'id'});
877 $id = &insertsup($bookseller);
879 Creates a new bookseller. C<$bookseller> is a reference-to-hash whose
880 keys are the fields of the aqbooksellers table in the Koha database.
881 All fields must be present.
883 Returns the ID of the newly-created bookseller.
889 my $dbh = C4::Context->dbh;
890 my $sth=$dbh->prepare("Select max(id) from aqbooksellers");
892 my $data2=$sth->fetchrow_hashref;
894 $data2->{'max(id)'}++;
895 $sth=$dbh->prepare("Insert into aqbooksellers (id) values (?)");
896 $sth->execute($data2->{'max(id)'});
898 $data->{'id'}=$data2->{'max(id)'};
900 return($data->{'id'});
903 END { } # module clean-up code here (global destructor)
912 Koha Developement team <info@koha.org>