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 left join aqorderbreakdown on aqorderbreakdown.ordernumber=aqorders.ordernumber
109 where basketno='$basketno'
110 and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber
111 =aqorders.biblioitemnumber
112 and (datecancellationprinted is NULL or datecancellationprinted =
114 if ($supplier ne ''){
115 $query.=" and aqorders.booksellerid='$supplier'";
117 $query.=" order by biblioitems.publishercode";
118 my $sth=$dbh->prepare($query);
123 while (my $data=$sth->fetchrow_hashref){
133 $basket = &newbasket();
135 Create a new basket in aqbasket table
139 my ($booksellerid,$authorisedby) = @_;
140 my $dbh = C4::Context->dbh;
141 my $sth=$dbh->do("insert into aqbasket (creationdate,booksellerid,authorisedby) values(now(),'$booksellerid','$authorisedby')");
142 #find & return basketno MYSQL dependant, but $dbh->last_insert_id always returns null :-(
143 my $basket = $dbh->{'mysql_insertid'};
149 &newbasket($basketno);
151 close a basket (becomes unmodifiable,except for recieves
156 my $dbh = C4::Context->dbh;
157 my $sth=$dbh->prepare("update aqbasket set closedate=now() where basketno=?");
158 $sth->execute($basketno);
163 &neworder($basket, $biblionumber, $title, $quantity, $listprice,
164 $booksellerid, $who, $notes, $bookfund, $biblioitemnumber, $rrp,
165 $ecost, $gst, $budget, $unitprice, $subscription,
166 $booksellerinvoicenumber);
168 Adds a new order to the database. Any argument that isn't described
169 below is the new value of the field with the same name in the aqorders
170 table of the Koha database.
172 C<$ordnum> is a "minimum order number." After adding the new entry to
173 the aqorders table, C<&neworder> finds the first entry in aqorders
174 with order number greater than or equal to C<$ordnum>, and adds an
175 entry to the aqorderbreakdown table, with the order number just found,
176 and the book fund ID of the newly-added order.
178 C<$budget> is effectively ignored.
180 C<$subscription> may be either "yes", or anything else for "no".
185 my ($basketno,$bibnum,$title,$quantity,$listprice,$booksellerid,$authorisedby,$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst,$budget,$cost,$sub,$invoice,$sort1,$sort2)=@_;
186 if ($budget eq 'now'){
189 $budget="'2001-07-01'";
196 # if $basket empty, it's also a new basket, create it
198 $basketno=newbasket($booksellerid,$authorisedby);
200 my $dbh = C4::Context->dbh;
201 my $sth=$dbh->prepare("insert into aqorders
202 (biblionumber,title,basketno,quantity,listprice,notes,
203 biblioitemnumber,rrp,ecost,gst,unitprice,subscription,sort1,sort2)
204 values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
205 $sth->execute($bibnum,$title,$basketno,$quantity,$listprice,$notes,
206 $bibitemnum,$rrp,$ecost,$gst,$cost,$sub,$sort1,$sort2);
208 #get ordnum MYSQL dependant, but $dbh->last_insert_id returns null
209 my $ordnum = $dbh->{'mysql_insertid'};
210 $sth=$dbh->prepare("insert into aqorderbreakdown (ordernumber,bookfundid) values
212 $sth->execute($ordnum,$bookfund);
219 &delorder($biblionumber, $ordernumber);
221 Cancel the order with the given order and biblio numbers. It does not
222 delete any entries in the aqorders table, it merely marks them as
228 my ($bibnum,$ordnum)=@_;
229 my $dbh = C4::Context->dbh;
230 my $sth=$dbh->prepare("update aqorders set datecancellationprinted=now()
231 where biblionumber=? and ordernumber=?");
232 $sth->execute($bibnum,$ordnum);
238 &modorder($title, $ordernumber, $quantity, $listprice,
239 $biblionumber, $basketno, $supplier, $who, $notes,
240 $bookfundid, $bibitemnum, $rrp, $ecost, $gst, $budget,
241 $unitprice, $booksellerinvoicenumber);
243 Modifies an existing order. Updates the order with order number
244 C<$ordernumber> and biblionumber C<$biblionumber>. All other arguments
245 update the fields with the same name in the aqorders table of the Koha
248 Entries with order number C<$ordernumber> in the aqorderbreakdown
249 table are also updated to the new book fund ID.
254 my ($title,$ordnum,$quantity,$listprice,$bibnum,$basketno,$supplier,$who,$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst,$budget,$cost,$invoice,$sort1,$sort2)=@_;
255 my $dbh = C4::Context->dbh;
256 my $sth=$dbh->prepare("update aqorders set title=?,
257 quantity=?,listprice=?,basketno=?,
258 rrp=?,ecost=?,unitprice=?,booksellerinvoicenumber=?,
259 notes=?,sort1=?, sort2=?
261 ordernumber=? and biblionumber=?");
262 $sth->execute($title,$quantity,$listprice,$basketno,$rrp,$ecost,$cost,$invoice,$notes,$sort1,$sort2,$ordnum,$bibnum);
264 $sth=$dbh->prepare("update aqorderbreakdown set bookfundid=? where
266 if ($sth->execute($bookfund,$ordnum) == 0) { # zero rows affected [Bug 734]
267 my $query="insert into aqorderbreakdown (ordernumber,bookfundid) values (?,?)";
268 $sth=$dbh->prepare($query);
269 $sth->execute($ordnum,$bookfund);
276 $order = &newordernum();
278 Finds the next unused order number in the aqorders table of the Koha
279 database, and returns it.
283 # FIXME - Race condition
285 my $dbh = C4::Context->dbh;
286 my $sth=$dbh->prepare("Select max(ordernumber) from aqorders");
288 my $data=$sth->fetchrow_arrayref;
289 my $ordnum=$$data[0];
297 &receiveorder($biblionumber, $ordernumber, $quantityreceived, $user,
298 $unitprice, $booksellerinvoicenumber, $biblioitemnumber,
299 $freight, $bookfund, $rrp);
301 Updates an order, to reflect the fact that it was received, at least
302 in part. All arguments not mentioned below update the fields with the
303 same name in the aqorders table of the Koha database.
305 Updates the order with bibilionumber C<$biblionumber> and ordernumber
308 Also updates the book fund ID in the aqorderbreakdown table.
313 my ($biblio,$ordnum,$quantrec,$user,$cost,$invoiceno,$freight,$rrp)=@_;
314 my $dbh = C4::Context->dbh;
315 my $sth=$dbh->prepare("update aqorders set quantityreceived=?,datereceived=now(),booksellerinvoicenumber=?,
316 unitprice=?,freight=?,rrp=?
317 where biblionumber=? and ordernumber=?");
318 $sth->execute($quantrec,$invoiceno,$cost,$freight,$rrp,$biblio,$ordnum);
324 &updaterecorder($biblionumber, $ordernumber, $user, $unitprice,
327 Updates the order with biblionumber C<$biblionumber> and order number
328 C<$ordernumber>. C<$bookfundid> is the new value for the book fund ID
329 in the aqorderbreakdown table of the Koha database. All other
330 arguments update the fields with the same name in the aqorders table.
337 my($biblio,$ordnum,$user,$cost,$bookfund,$rrp)=@_;
338 my $dbh = C4::Context->dbh;
339 my $sth=$dbh->prepare("update aqorders set
341 where biblionumber=? and ordernumber=?
343 $sth->execute($cost,$rrp,$biblio,$ordnum);
345 $sth=$dbh->prepare("update aqorderbreakdown set bookfundid=? where ordernumber=?");
346 $sth->execute($bookfund,$ordnum);
358 ($count, $orders) = &getorders($booksellerid);
360 Finds pending orders from the bookseller with the given ID. Ignores
361 completed and cancelled orders.
363 C<$count> is the number of elements in C<@{$orders}>.
365 C<$orders> is a reference-to-array; each element is a
366 reference-to-hash with the following fields:
372 Gives the number of orders in with this basket number.
374 =item C<authorizedby>
380 These give the value of the corresponding field in the aqorders table
381 of the Koha database.
385 Results are ordered from most to least recent.
391 my $dbh = C4::Context->dbh;
392 my $sth=$dbh->prepare("Select count(*),authorisedby,creationdate,aqbasket.basketno,
393 closedate,surname,firstname
395 left join aqbasket on aqbasket.basketno=aqorders.basketno
396 left join borrowers on aqbasket.authorisedby=borrowers.borrowernumber
397 where booksellerid=? and (quantity > quantityreceived or
398 quantityreceived is NULL)
399 group by basketno order by aqbasket.basketno");
400 $sth->execute($supplierid);
402 while (my $data=$sth->fetchrow_hashref){
403 push(@results,$data);
406 return (scalar(@results),\@results);
411 ($order, $ordernumber) = &getorder($biblioitemnumber, $biblionumber);
413 Looks up the order with the given biblionumber and biblioitemnumber.
415 Returns a two-element array. C<$ordernumber> is the order number.
416 C<$order> is a reference-to-hash describing the order; its keys are
417 fields from the biblio, biblioitems, aqorders, and aqorderbreakdown
418 tables of the Koha database.
424 my $dbh = C4::Context->dbh;
425 my $sth=$dbh->prepare("Select ordernumber from aqorders where biblionumber=? and biblioitemnumber=?");
426 $sth->execute($bib,$bi);
427 # FIXME - Use fetchrow_array(), since we're only interested in the one
429 my $ordnum=$sth->fetchrow_hashref;
431 my $order=getsingleorder($ordnum->{'ordernumber'});
432 return ($order,$ordnum->{'ordernumber'});
437 $order = &getsingleorder($ordernumber);
439 Looks up an order by order number.
441 Returns a reference-to-hash describing the order. The keys of
442 C<$order> are fields from the biblio, biblioitems, aqorders, and
443 aqorderbreakdown tables of the Koha database.
449 my $dbh = C4::Context->dbh;
450 my $sth=$dbh->prepare("Select * from biblio,biblioitems,aqorders left join aqorderbreakdown
451 on aqorders.ordernumber=aqorderbreakdown.ordernumber
452 where aqorders.ordernumber=?
453 and biblio.biblionumber=aqorders.biblionumber and
454 biblioitems.biblioitemnumber=aqorders.biblioitemnumber");
455 $sth->execute($ordnum);
456 my $data=$sth->fetchrow_hashref;
463 ($count, @results) = &getallorders($booksellerid);
465 Looks up all of the pending orders from the supplier with the given
466 bookseller ID. Ignores cancelled and completed orders.
468 C<$count> is the number of elements in C<@results>. C<@results> is an
469 array of references-to-hash. The keys of each element are fields from
470 the aqorders, biblio, and biblioitems tables of the Koha database.
472 C<@results> is sorted alphabetically by book title.
477 #gets all orders from a certain supplier, orders them alphabetically
479 my $dbh = C4::Context->dbh;
481 my $sth=$dbh->prepare("Select * from aqorders,biblio,biblioitems,aqbasket where aqbasket.basketno=aqorders.basketno
483 and (cancelledby is NULL or cancelledby = '')
484 and (quantityreceived < quantity or quantityreceived is NULL)
485 and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber=
486 aqorders.biblioitemnumber
487 group by aqorders.biblioitemnumber
490 $sth->execute($supid);
491 while (my $data=$sth->fetchrow_hashref){
492 push(@results,$data);
495 return(scalar(@results),@results);
500 #gets all orders from a certain supplier, orders them alphabetically
502 my $dbh = C4::Context->dbh;
504 my $sth=$dbh->prepare("Select * from aqorders,biblio,biblioitems where booksellerid=?
505 and (cancelledby is NULL or cancelledby = '')
506 and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber=
507 aqorders.biblioitemnumber and
508 aqorders.quantityreceived>0
509 and aqorders.datereceived >=now()
510 group by aqorders.biblioitemnumber
513 $sth->execute($supid);
514 while (my $data=$sth->fetchrow_hashref){
515 push(@results,$data);
518 return(scalar(@results),@results);
523 ($count, @results) = &ordersearch($search, $biblionumber, $complete);
527 C<$search> may take one of several forms: if it is an ISBN,
528 C<&ordersearch> returns orders with that ISBN. If C<$search> is an
529 order number, C<&ordersearch> returns orders with that order number
530 and biblionumber C<$biblionumber>. Otherwise, C<$search> is considered
531 to be a space-separated list of search terms; in this case, all of the
532 terms must appear in the title (matching the beginning of title
535 If C<$complete> is C<yes>, the results will include only completed
536 orders. In any case, C<&ordersearch> ignores cancelled orders.
538 C<&ordersearch> returns an array. C<$count> is the number of elements
539 in C<@results>. C<@results> is an array of references-to-hash with the
557 my ($search,$id,$biblio,$catview) = @_;
558 my $dbh = C4::Context->dbh;
559 my @data = split(' ',$search);
560 my @searchterms = ($id);
561 map { push(@searchterms,"$_%","% $_%") } @data;
562 push(@searchterms,$search,$search,$biblio);
563 my $sth=$dbh->prepare("Select *,biblio.title from aqorders,biblioitems,biblio,aqbasket
564 where aqorders.biblioitemnumber = biblioitems.biblioitemnumber and
565 aqorders.basketno = aqbasket.basketno
566 and aqbasket.booksellerid = ?
567 and biblio.biblionumber=aqorders.biblionumber
568 and ((datecancellationprinted is NULL)
569 or (datecancellationprinted = '0000-00-00'))
571 .(join(" and ",map { "(biblio.title like ? or biblio.title like ?)" } @data))
572 .") or biblioitems.isbn=? or (aqorders.ordernumber=? and aqorders.biblionumber=?)) "
573 .(($catview ne 'yes')?" and (quantityreceived < quantity or quantityreceived is NULL)":"")
574 ." group by aqorders.ordernumber");
575 $sth->execute(@searchterms);
577 my $sth2=$dbh->prepare("Select * from biblio where biblionumber=?");
578 my $sth3=$dbh->prepare("Select * from aqorderbreakdown where ordernumber=?");
579 while (my $data=$sth->fetchrow_hashref){
580 $sth2->execute($data->{'biblionumber'});
581 my $data2=$sth2->fetchrow_hashref;
582 $data->{'author'}=$data2->{'author'};
583 $data->{'seriestitle'}=$data2->{'seriestitle'};
584 $sth3->execute($data->{'ordernumber'});
585 my $data3=$sth3->fetchrow_hashref;
586 $data->{'branchcode'}=$data3->{'branchcode'};
587 $data->{'bookfundid'}=$data3->{'bookfundid'};
588 push(@results,$data);
593 return(scalar(@results),@results);
603 ($count, @results) = &invoice($booksellerinvoicenumber);
605 Looks up orders by invoice number.
607 Returns an array. C<$count> is the number of elements in C<@results>.
608 C<@results> is an array of references-to-hash; the keys of each
609 elements are fields from the aqorders, biblio, and biblioitems tables
610 of the Koha database.
616 my $dbh = C4::Context->dbh;
618 my $sth=$dbh->prepare("Select * from aqorders,biblio,biblioitems where
619 booksellerinvoicenumber=?
620 and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber=
621 aqorders.biblioitemnumber group by aqorders.ordernumber,aqorders.biblioitemnumber");
622 $sth->execute($invoice);
623 while (my $data=$sth->fetchrow_hashref){
624 push(@results,$data);
627 return(scalar(@results),@results);
632 ($count, @results) = &bookfunds();
634 Returns a list of all book funds.
636 C<$count> is the number of elements in C<@results>. C<@results> is an
637 array of references-to-hash, whose keys are fields from the aqbookfund
638 and aqbudget tables of the Koha database. Results are ordered
639 alphabetically by book fund name.
644 my $dbh = C4::Context->dbh;
645 my $sth=$dbh->prepare("Select * from aqbookfund,aqbudget where aqbookfund.bookfundid
647 group by aqbookfund.bookfundid order by bookfundname");
650 while (my $data=$sth->fetchrow_hashref){
651 push(@results,$data);
654 return(scalar(@results),@results);
657 =item bookfundbreakdown
659 returns the total comtd & spent for a given bookfund
660 used in acqui-home.pl
664 sub bookfundbreakdown {
666 my $dbh = C4::Context->dbh;
667 my $sth=$dbh->prepare("Select quantity,datereceived,freight,unitprice,listprice,ecost,quantityreceived,subscription
668 from aqorders,aqorderbreakdown where bookfundid=? and
669 aqorders.ordernumber=aqorderbreakdown.ordernumber
670 and (datecancellationprinted is NULL or
671 datecancellationprinted='0000-00-00')");
675 while (my $data=$sth->fetchrow_hashref){
676 if ($data->{'subscription'} == 1){
677 $spent+=$data->{'quantity'}*$data->{'unitprice'};
679 my $leftover=$data->{'quantity'}-$data->{'quantityreceived'};
680 $comtd+=($data->{'ecost'})*$leftover;
681 $spent+=($data->{'unitprice'})*$data->{'quantityreceived'};
685 return($spent,$comtd);
692 $foreignprice = &curconvert($currency, $localprice);
694 Converts the price C<$localprice> to foreign currency C<$currency> by
695 dividing by the exchange rate, and returns the result.
697 If no exchange rate is found, C<&curconvert> assumes the rate is one
703 my ($currency,$price)=@_;
704 my $dbh = C4::Context->dbh;
705 my $sth=$dbh->prepare("Select rate from currency where currency=?");
706 $sth->execute($currency);
707 my $cur=($sth->fetchrow_array())[0];
712 return($price / $cur);
717 ($count, $currencies) = &getcurrencies();
719 Returns the list of all known currencies.
721 C<$count> is the number of elements in C<$currencies>. C<$currencies>
722 is a reference-to-array; its elements are references-to-hash, whose
723 keys are the fields from the currency table in the Koha database.
728 my $dbh = C4::Context->dbh;
729 my $sth=$dbh->prepare("Select * from currency");
732 while (my $data=$sth->fetchrow_hashref){
733 push(@results,$data);
736 return(scalar(@results),\@results);
739 =item updatecurrencies
741 &updatecurrencies($currency, $newrate);
743 Sets the exchange rate for C<$currency> to be C<$newrate>.
747 sub updatecurrencies {
748 my ($currency,$rate)=@_;
749 my $dbh = C4::Context->dbh;
750 my $sth=$dbh->prepare("update currency set rate=? where currency=?");
751 $sth->execute($rate,$currency);
763 ($count, @results) = &bookseller($searchstring);
765 Looks up a book seller. C<$searchstring> may be either a book seller
766 ID, or a string to look for in the book seller's name.
768 C<$count> is the number of elements in C<@results>. C<@results> is an
769 array of references-to-hash, whose keys are the fields of of the
770 aqbooksellers table in the Koha database.
775 my ($searchstring)=@_;
776 my $dbh = C4::Context->dbh;
777 my $sth=$dbh->prepare("Select * from aqbooksellers where name like ? or id = ?");
778 $sth->execute("$searchstring%",$searchstring);
780 while (my $data=$sth->fetchrow_hashref){
781 push(@results,$data);
784 return(scalar(@results),@results);
789 ($count, $results) = &breakdown($ordernumber);
791 Looks up an order by order ID, and returns its breakdown.
793 C<$count> is the number of elements in C<$results>. C<$results> is a
794 reference-to-array; its elements are references-to-hash, whose keys
795 are the fields of the aqorderbreakdown table in the Koha database.
801 my $dbh = C4::Context->dbh;
802 my $sth=$dbh->prepare("Select * from aqorderbreakdown where ordernumber=?");
805 while (my $data=$sth->fetchrow_hashref){
806 push(@results,$data);
809 return(scalar(@results),\@results);
814 ($count, @results) = &branches();
816 Returns a list of all library branches.
818 C<$count> is the number of elements in C<@results>. C<@results> is an
819 array of references-to-hash, whose keys are the fields of the branches
820 table of the Koha database.
825 my $dbh = C4::Context->dbh;
826 my $sth = $dbh->prepare("Select * from branches order by branchname");
830 while (my $data = $sth->fetchrow_hashref) {
831 push(@results,$data);
835 return(scalar(@results), @results);
840 &updatesup($bookseller);
842 Updates the information for a given bookseller. C<$bookseller> is a
843 reference-to-hash whose keys are the fields of the aqbooksellers table
844 in the Koha database. It must contain entries for all of the fields.
845 The entry to modify is determined by C<$bookseller-E<gt>{id}>.
847 The easiest way to get all of the necessary fields is to look up a
848 book seller with C<&booksellers>, modify what's necessary, then call
849 C<&updatesup> with the result.
855 my $dbh = C4::Context->dbh;
856 my $sth=$dbh->prepare("Update aqbooksellers set
857 name=?,address1=?,address2=?,address3=?,address4=?,postal=?,
858 phone=?,fax=?,url=?,contact=?,contpos=?,contphone=?,contfax=?,contaltphone=?,
859 contemail=?,contnotes=?,active=?,
860 listprice=?, invoiceprice=?,gstreg=?, listincgst=?,
861 invoiceincgst=?, specialty=?,discount=?,invoicedisc=?,
864 $sth->execute($data->{'name'},$data->{'address1'},$data->{'address2'},
865 $data->{'address3'},$data->{'address4'},$data->{'postal'},$data->{'phone'},
866 $data->{'fax'},$data->{'url'},$data->{'contact'},$data->{'contpos'},
867 $data->{'contphone'},$data->{'contfax'},$data->{'contaltphone'},
868 $data->{'contemail'},
869 $data->{'contnote'},$data->{'active'},$data->{'listprice'},
870 $data->{'invoiceprice'},$data->{'gstreg'},$data->{'listincgst'},
871 $data->{'invoiceincgst'},$data->{'specialty'},$data->{'discount'},
872 $data->{'invoicedisc'},$data->{'nocalc'},$data->{'id'});
878 $id = &insertsup($bookseller);
880 Creates a new bookseller. C<$bookseller> is a reference-to-hash whose
881 keys are the fields of the aqbooksellers table in the Koha database.
882 All fields must be present.
884 Returns the ID of the newly-created bookseller.
890 my $dbh = C4::Context->dbh;
891 my $sth=$dbh->prepare("Select max(id) from aqbooksellers");
893 my $data2=$sth->fetchrow_hashref;
895 $data2->{'max(id)'}++;
896 $sth=$dbh->prepare("Insert into aqbooksellers (id) values (?)");
897 $sth->execute($data2->{'max(id)'});
899 $data->{'id'}=$data2->{'max(id)'};
901 return($data->{'id'});
904 END { } # module clean-up code here (global destructor)
913 Koha Developement team <info@koha.org>