package C4::Catalogue; # Continue working on updateItem!!!!!! # # updateItem is looking not bad. Need to add addSubfield and deleteSubfield # functions # # Trying to track down $dbh's that aren't disconnected.... # Copyright 2000-2002 Katipo Communications # # This file is part of Koha. # # Koha is free software; you can redistribute it and/or modify it under the # terms of the GNU General Public License as published by the Free Software # Foundation; either version 2 of the License, or (at your option) any later # version. # # Koha is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along with # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, # Suite 330, Boston, MA 02111-1307 USA use strict; require Exporter; use C4::Context; use MARC::Record; use C4::Biblio; use vars qw($VERSION @ISA @EXPORT); # set the version for version checking $VERSION = 0.01; =head1 NAME C4::Catalogue - Koha functions for dealing with orders and acquisitions =head1 SYNOPSIS use C4::Catalogue; =head1 DESCRIPTION The functions in this module deal with acquisitions, managing book orders, converting money to different currencies, and so forth. =head1 FUNCTIONS =over 2 =cut @ISA = qw(Exporter); @EXPORT = qw( &basket &newbasket &getorders &getallorders &getrecorders &getorder &neworder &delorder &ordersearch &modorder &getsingleorder &invoice &receiveorder &updaterecorder &newordernum &bookfunds &bookfundbreakdown &updatecost &curconvert &getcurrencies &updatecurrencies &getcurrency &findall &needsmod &branches &updatesup &insertsup &bookseller &breakdown &checkitems &websitesearch &addwebsite &updatewebsite &deletewebsite ); # # # # BASKETS # # # =item basket ($count, @orders) = &basket($basketnumber, $booksellerID); Looks up the pending (non-cancelled) orders with the given basket number. If C<$booksellerID> is non-empty, only orders from that seller are returned. C<&basket> returns a two-element array. C<@orders> is an array of references-to-hash, whose keys are the fields from the aqorders, biblio, and biblioitems tables in the Koha database. C<$count> is the number of elements in C<@orders>. =cut #' sub basket { my ($basketno,$supplier)=@_; my $dbh = C4::Context->dbh; my $sth=$dbh->prepare("Select *,biblio.title from aqorders,biblio,biblioitems where basketno=? and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber =aqorders.biblioitemnumber and (datecancellationprinted is NULL or datecancellationprinted = '0000-00-00')" .(($supplier ne '')?" and aqorders.booksellerid=?":"") ." group by aqorders.ordernumber"); if ($supplier ne '') { $sth->execute($basketno,$supplier); } else { $sth->execute($basketno); } my @results = (); while (my $data=$sth->fetchrow_hashref){ push(@results,$data); } $sth->finish; return(scalar(@results),@results); } =item newbasket $basket = &newbasket(); Finds the next unused basket number in the aqorders table of the Koha database, and returns it. =cut #' # FIXME - There's a race condition here: # A calls &newbasket # B calls &newbasket (gets the same number as A) # A updates the basket # B updates the basket, and clobbers A's result. # A better approach might be to create a dummy order (with, say, # requisitionedby == "Dummy-$$" or notes == "dummy