3 # Continue working on updateItem!!!!!!
5 # updateItem is looking not bad. Need to add addSubfield and deleteSubfield
8 # Trying to track down $dbh's that aren't disconnected....
11 # Copyright 2000-2002 Katipo Communications
13 # This file is part of Koha.
15 # Koha is free software; you can redistribute it and/or modify it under the
16 # terms of the GNU General Public License as published by the Free Software
17 # Foundation; either version 2 of the License, or (at your option) any later
20 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
21 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
22 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License along with
25 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
26 # Suite 330, Boston, MA 02111-1307 USA
34 use vars qw($VERSION @ISA @EXPORT);
36 # set the version for version checking
41 C4::Catalogue - Koha functions for dealing with orders and acquisitions
49 The functions in this module deal with acquisitions, managing book
50 orders, converting money to different currencies, and so forth.
62 &getorders &getallorders &getrecorders
63 &getorder &neworder &delorder
65 &modorder &getsingleorder &invoice &receiveorder
66 &updaterecorder &newordernum
68 &bookfunds &bookfundbreakdown &updatecost
69 &curconvert &getcurrencies &updatecurrencies &getcurrency
71 &findall &needsmod &branches &updatesup &insertsup
72 &bookseller &breakdown &checkitems
84 ($count, @orders) = &basket($basketnumber, $booksellerID);
86 Looks up the pending (non-cancelled) orders with the given basket
87 number. If C<$booksellerID> is non-empty, only orders from that seller
90 C<&basket> returns a two-element array. C<@orders> is an array of
91 references-to-hash, whose keys are the fields from the aqorders,
92 biblio, and biblioitems tables in the Koha database. C<$count> is the
93 number of elements in C<@orders>.
98 my ($basketno,$supplier)=@_;
99 my $dbh = C4::Context->dbh;
100 my $query="Select *,biblio.title from aqorders,biblio,biblioitems
101 where basketno='$basketno'
102 and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber
103 =aqorders.biblioitemnumber
104 and (datecancellationprinted is NULL or datecancellationprinted =
106 if ($supplier ne ''){
107 $query.=" and aqorders.booksellerid='$supplier'";
109 $query.=" order by biblioitems.publishercode";
110 my $sth=$dbh->prepare($query);
115 while (my $data=$sth->fetchrow_hashref){
125 $basket = &newbasket();
127 Finds the next unused basket number in the aqorders table of the Koha
128 database, and returns it.
132 # FIXME - There's a race condition here:
134 # B calls &newbasket (gets the same number as A)
135 # A updates the basket
136 # B updates the basket, and clobbers A's result.
137 # A better approach might be to create a dummy order (with, say,
138 # requisitionedby == "Dummy-$$" or notes == "dummy <time> <pid>"), and
139 # see which basket number it gets. Then have a cron job periodically
140 # remove out-of-date dummy orders.
142 my $dbh = C4::Context->dbh;
143 my $sth=$dbh->prepare("Select max(basketno) from aqorders");
145 my $data=$sth->fetchrow_arrayref;
146 my $basket=$$data[0];
154 &neworder($biblionumber, $title, $ordnum, $basket, $quantity, $listprice,
155 $booksellerid, $who, $notes, $bookfund, $biblioitemnumber, $rrp,
156 $ecost, $gst, $budget, $unitprice, $subscription,
157 $booksellerinvoicenumber);
159 Adds a new order to the database. Any argument that isn't described
160 below is the new value of the field with the same name in the aqorders
161 table of the Koha database.
163 C<$ordnum> is a "minimum order number." After adding the new entry to
164 the aqorders table, C<&neworder> finds the first entry in aqorders
165 with order number greater than or equal to C<$ordnum>, and adds an
166 entry to the aqorderbreakdown table, with the order number just found,
167 and the book fund ID of the newly-added order.
169 C<$budget> is effectively ignored.
171 C<$subscription> may be either "yes", or anything else for "no".
176 my ($bibnum,$title,$ordnum,$basket,$quantity,$listprice,$supplier,$who,$notes,$bookfund,$bibitemnum,$rrp,$ecost,$gst,$budget,$cost,$sub,$invoice,$sort1,$sort2)=@_;
177 if ($budget eq 'now'){
180 $budget="'2001-07-01'";
187 my $dbh = C4::Context->dbh;
188 my $sth=$dbh->prepare("insert into aqorders (biblionumber,title,basketno,
189 quantity,listprice,booksellerid,entrydate,requisitionedby,authorisedby,notes,
190 biblioitemnumber,rrp,ecost,gst,unitprice,subscription,booksellerinvoicenumber,sort1,sort2)
191 values (?,?,?,?,?,?,now(),?,?,?,?,?,?,?,?,?,?,?,?)");
192 $sth->execute($bibnum,$title,$basket,$quantity,$listprice,$supplier,
193 $who,$who,$notes,$bibitemnum,$rrp,$ecost,$gst,$cost,
194 $sub,$invoice,$sort1,$sort2);
196 $sth=$dbh->prepare("select * from aqorders where
197 biblionumber=? and basketno=? and ordernumber >=?");
198 $sth->execute($bibnum,$basket,$ordnum);
199 my $data=$sth->fetchrow_hashref;
201 $ordnum=$data->{'ordernumber'};
202 $sth=$dbh->prepare("insert into aqorderbreakdown (ordernumber,bookfundid) values
205 $sth->execute($ordnum,$bookfund);
211 &delorder($biblionumber, $ordernumber);
213 Cancel the order with the given order and biblio numbers. It does not
214 delete any entries in the aqorders table, it merely marks them as
217 If there are no items remaining with the given biblionumber,
218 C<&delorder> also deletes them from the marc_subfield_table and
219 marc_biblio tables of the Koha database.
224 my ($bibnum,$ordnum)=@_;
225 my $dbh = C4::Context->dbh;
226 my $sth=$dbh->prepare("update aqorders set datecancellationprinted=now()
227 where biblionumber=? and ordernumber=?");
228 $sth->execute($bibnum,$ordnum);
230 my $count=itemcount($bibnum);
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=?,
259 booksellerinvoicenumber=?,
262 ordernumber=? and biblionumber=?");
263 $sth->execute($title,$quantity,$listprice,$basketno,$rrp,$ecost,$cost,$invoice,$sort1,$sort2,$ordnum,$bibnum);
265 $sth=$dbh->prepare("update aqorderbreakdown set bookfundid=? where
267 if ($sth->execute($bookfund,$ordnum) == 0) { # zero rows affected [Bug 734]
268 my $query="insert into aqorderbreakdown (ordernumber,bookfundid) values (?,?)";
269 $sth=$dbh->prepare($query);
270 $sth->execute($ordnum,$bookfund);
277 $order = &newordernum();
279 Finds the next unused order number in the aqorders table of the Koha
280 database, and returns it.
284 # FIXME - Race condition
286 my $dbh = C4::Context->dbh;
287 my $sth=$dbh->prepare("Select max(ordernumber) from aqorders");
289 my $data=$sth->fetchrow_arrayref;
290 my $ordnum=$$data[0];
298 &receiveorder($biblionumber, $ordernumber, $quantityreceived, $user,
299 $unitprice, $booksellerinvoicenumber, $biblioitemnumber,
300 $freight, $bookfund, $rrp);
302 Updates an order, to reflect the fact that it was received, at least
303 in part. All arguments not mentioned below update the fields with the
304 same name in the aqorders table of the Koha database.
306 Updates the order with bibilionumber C<$biblionumber> and ordernumber
309 Also updates the book fund ID in the aqorderbreakdown table.
314 my ($biblio,$ordnum,$quantrec,$user,$cost,$invoiceno,$bibitemno,$freight,$bookfund,$rrp)=@_;
315 my $dbh = C4::Context->dbh;
316 my $sth=$dbh->prepare("update aqorders set quantityreceived=?,datereceived=now(),booksellerinvoicenumber=?,
317 biblioitemnumber=?,unitprice=?,freight=?,rrp=?
318 where biblionumber=? and ordernumber=?");
319 $sth->execute($quantrec,$invoiceno,$bibitemno,$cost,$freight,$rrp,$biblio,$ordnum);
321 $sth=$dbh->prepare("update aqorderbreakdown set bookfundid=? where
323 $sth->execute($bookfund,$ordnum);
329 &updaterecorder($biblionumber, $ordernumber, $user, $unitprice,
332 Updates the order with biblionumber C<$biblionumber> and order number
333 C<$ordernumber>. C<$bookfundid> is the new value for the book fund ID
334 in the aqorderbreakdown table of the Koha database. All other
335 arguments update the fields with the same name in the aqorders table.
342 my($biblio,$ordnum,$user,$cost,$bookfund,$rrp)=@_;
343 my $dbh = C4::Context->dbh;
344 my $sth=$dbh->prepare("update aqorders set
346 where biblionumber=? and ordernumber=?
348 $sth->execute($cost,$rrp,$biblio,$ordnum);
350 $sth=$dbh->prepare("update aqorderbreakdown set bookfundid=? where ordernumber=?");
351 $sth->execute($bookfund,$ordnum);
363 ($count, $orders) = &getorders($booksellerid);
365 Finds pending orders from the bookseller with the given ID. Ignores
366 completed and cancelled orders.
368 C<$count> is the number of elements in C<@{$orders}>.
370 C<$orders> is a reference-to-array; each element is a
371 reference-to-hash with the following fields:
377 Gives the number of orders in with this basket number.
379 =item C<authorizedby>
385 These give the value of the corresponding field in the aqorders table
386 of the Koha database.
390 Results are ordered from most to least recent.
396 my $dbh = C4::Context->dbh;
397 my $sth=$dbh->prepare("Select count(*),authorisedby,entrydate,basketno from aqorders where
398 booksellerid=? and (quantity > quantityreceived or
399 quantityreceived is NULL)
400 and (datecancellationprinted is NULL or datecancellationprinted = '0000-00-00')
401 group by basketno order by entrydate desc");
402 $sth->execute($supplierid);
404 while (my $data=$sth->fetchrow_hashref){
405 push(@results,$data);
408 return (scalar(@results),\@results);
413 ($order, $ordernumber) = &getorder($biblioitemnumber, $biblionumber);
415 Looks up the order with the given biblionumber and biblioitemnumber.
417 Returns a two-element array. C<$ordernumber> is the order number.
418 C<$order> is a reference-to-hash describing the order; its keys are
419 fields from the biblio, biblioitems, aqorders, and aqorderbreakdown
420 tables of the Koha database.
424 # FIXME - This is effectively identical to &C4::Biblio::getorder.
425 # Pick one and stick with it.
428 my $dbh = C4::Context->dbh;
429 my $sth=$dbh->prepare("Select ordernumber from aqorders where biblionumber=? and biblioitemnumber=?");
430 $sth->execute($bib,$bi);
431 # FIXME - Use fetchrow_array(), since we're only interested in the one
433 my $ordnum=$sth->fetchrow_hashref;
435 my $order=getsingleorder($ordnum->{'ordernumber'});
436 return ($order,$ordnum->{'ordernumber'});
441 $order = &getsingleorder($ordernumber);
443 Looks up an order by order number.
445 Returns a reference-to-hash describing the order. The keys of
446 C<$order> are fields from the biblio, biblioitems, aqorders, and
447 aqorderbreakdown tables of the Koha database.
451 # FIXME - This is effectively identical to
452 # &C4::Biblio::getsingleorder.
453 # Pick one and stick with it.
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 # FIXME - POD. I can't figure out what this function is doing. Then
663 # again, I don't think it's being used (anymore).
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);
690 $foreignprice = &curconvert($currency, $localprice);
692 Converts the price C<$localprice> to foreign currency C<$currency> by
693 dividing by the exchange rate, and returns the result.
695 If no exchange rate is found, C<&curconvert> assumes the rate is one
701 my ($currency,$price)=@_;
702 my $dbh = C4::Context->dbh;
703 my $sth=$dbh->prepare("Select rate from currency where currency=?");
704 $sth->execute($currency);
705 my $cur=($sth->fetchrow_array())[0];
710 return($price / $cur);
715 ($count, $currencies) = &getcurrencies();
717 Returns the list of all known currencies.
719 C<$count> is the number of elements in C<$currencies>. C<$currencies>
720 is a reference-to-array; its elements are references-to-hash, whose
721 keys are the fields from the currency table in the Koha database.
726 my $dbh = C4::Context->dbh;
727 my $sth=$dbh->prepare("Select * from currency");
730 while (my $data=$sth->fetchrow_hashref){
731 push(@results,$data);
734 return(scalar(@results),\@results);
737 =item updatecurrencies
739 &updatecurrencies($currency, $newrate);
741 Sets the exchange rate for C<$currency> to be C<$newrate>.
745 sub updatecurrencies {
746 my ($currency,$rate)=@_;
747 my $dbh = C4::Context->dbh;
748 my $sth=$dbh->prepare("update currency set rate=? where currency=?");
749 $sth->execute($rate,$currency);
753 # FIXME - This is never used
755 my($price,$rrp,$itemnum)=@_;
756 my $dbh = C4::Context->dbh;
757 my $sth=$dbh->prepare("update items set price=?,replacementprice=? where itemnumber=?");
758 $sth->execute($price,$rrp,$itemnum);
770 ($count, @results) = &bookseller($searchstring);
772 Looks up a book seller. C<$searchstring> may be either a book seller
773 ID, or a string to look for in the book seller's name.
775 C<$count> is the number of elements in C<@results>. C<@results> is an
776 array of references-to-hash, whose keys are the fields of of the
777 aqbooksellers table in the Koha database.
782 my ($searchstring)=@_;
783 my $dbh = C4::Context->dbh;
784 my $sth=$dbh->prepare("Select * from aqbooksellers where name like ? or id = ?");
785 $sth->execute("$searchstring%",$searchstring);
787 while (my $data=$sth->fetchrow_hashref){
788 push(@results,$data);
791 return(scalar(@results),@results);
796 ($count, $results) = &breakdown($ordernumber);
798 Looks up an order by order ID, and returns its breakdown.
800 C<$count> is the number of elements in C<$results>. C<$results> is a
801 reference-to-array; its elements are references-to-hash, whose keys
802 are the fields of the aqorderbreakdown table in the Koha database.
808 my $dbh = C4::Context->dbh;
809 my $sth=$dbh->prepare("Select * from aqorderbreakdown where ordernumber=?");
812 while (my $data=$sth->fetchrow_hashref){
813 push(@results,$data);
816 return(scalar(@results),\@results);
821 ($count, @results) = &branches();
823 Returns a list of all library branches.
825 C<$count> is the number of elements in C<@results>. C<@results> is an
826 array of references-to-hash, whose keys are the fields of the branches
827 table of the Koha database.
832 my $dbh = C4::Context->dbh;
833 my $sth = $dbh->prepare("Select * from branches order by branchname");
837 while (my $data = $sth->fetchrow_hashref) {
838 push(@results,$data);
842 return(scalar(@results), @results);
847 my ($biblionumber)=@_;
848 my $dbh = C4::Context->dbh;
849 my $sth=$dbh->prepare("Select * from biblioitems,items,itemtypes where
850 biblioitems.biblionumber=?
851 and biblioitems.biblioitemnumber=items.biblioitemnumber and
852 itemtypes.itemtype=biblioitems.itemtype
853 order by items.biblioitemnumber");
854 $sth->execute($biblionumber);
856 while (my $data=$sth->fetchrow_hashref){
857 push(@results,$data);
865 my ($bibitemnum,$itemtype)=@_;
866 my $dbh = C4::Context->dbh;
867 my $sth=$dbh->prepare("Select * from biblioitems where biblioitemnumber=?
869 $sth->execute($bibitemnum,$itemtype);
871 if (my $data=$sth->fetchrow_hashref){
880 &updatesup($bookseller);
882 Updates the information for a given bookseller. C<$bookseller> is a
883 reference-to-hash whose keys are the fields of the aqbooksellers table
884 in the Koha database. It must contain entries for all of the fields.
885 The entry to modify is determined by C<$bookseller-E<gt>{id}>.
887 The easiest way to get all of the necessary fields is to look up a
888 book seller with C<&booksellers>, modify what's necessary, then call
889 C<&updatesup> with the result.
895 my $dbh = C4::Context->dbh;
896 my $sth=$dbh->prepare("Update aqbooksellers set
897 name=?,address1=?,address2=?,address3=?,address4=?,postal=?,
898 phone=?,fax=?,url=?,contact=?,contpos=?,contphone=?,contfax=?,contaltphone=?,
899 contemail=?,contnotes=?,active=?,
900 listprice=?, invoiceprice=?,gstreg=?, listincgst=?,
901 invoiceincgst=?, specialty=?,discount=?,invoicedisc=?,
904 $sth->execute($data->{'name'},$data->{'address1'},$data->{'address2'},
905 $data->{'address3'},$data->{'address4'},$data->{'postal'},$data->{'phone'},
906 $data->{'fax'},$data->{'url'},$data->{'contact'},$data->{'contpos'},
907 $data->{'contphone'},$data->{'contfax'},$data->{'contaltphone'},
908 $data->{'contemail'},
909 $data->{'contnote'},$data->{'active'},$data->{'listprice'},
910 $data->{'invoiceprice'},$data->{'gstreg'},$data->{'listincgst'},
911 $data->{'invoiceincgst'},$data->{'specialty'},$data->{'discount'},
912 $data->{'invoicedisc'},$data->{'nocalc'},$data->{'id'});
919 $id = &insertsup($bookseller);
921 Creates a new bookseller. C<$bookseller> is a reference-to-hash whose
922 keys are the fields of the aqbooksellers table in the Koha database.
923 All fields must be present.
925 Returns the ID of the newly-created bookseller.
931 my $dbh = C4::Context->dbh;
932 my $sth=$dbh->prepare("Select max(id) from aqbooksellers");
934 my $data2=$sth->fetchrow_hashref;
936 $data2->{'max(id)'}++;
937 $sth=$dbh->prepare("Insert into aqbooksellers (id) values (?)");
938 $sth->execute($data2->{'max(id)'});
940 $data->{'id'}=$data2->{'max(id)'};
942 return($data->{'id'});
945 END { } # module clean-up code here (global destructor)
954 Koha Developement team <info@koha.org>