From: tipaul Date: Thu, 15 Jul 2004 09:41:03 +0000 (+0000) Subject: Acquisition & Suggestion : X-Git-Tag: R_2-1~100 X-Git-Url: http://git.rot13.org/?a=commitdiff_plain;h=f29ce59691b349687d2a023c07383997d7d55dcb;p=koha.git Acquisition & Suggestion : * acquisition rewritte : create a aqbasket table to deal with "bookseller order header". * add "close basket" feature : a closed basket can't be modified * suggestion feature : manage suggestions in acquisition (after suggestion filled in OPAC) --- diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index d5f06ed6a9..950411a3e4 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -1,12 +1,4 @@ -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.... - +package C4::Acquisition; # Copyright 2000-2002 Katipo Communications # @@ -29,7 +21,7 @@ use strict; require Exporter; use C4::Context; use MARC::Record; -use C4::Biblio; +# use C4::Biblio; use vars qw($VERSION @ISA @EXPORT); @@ -38,11 +30,11 @@ $VERSION = 0.01; =head1 NAME -C4::Catalogue - Koha functions for dealing with orders and acquisitions +C4::Acquisition - Koha functions for dealing with orders and acquisitions =head1 SYNOPSIS - use C4::Catalogue; + use C4::Acquisition; =head1 DESCRIPTION @@ -57,19 +49,19 @@ orders, converting money to different currencies, and so forth. @ISA = qw(Exporter); @EXPORT = qw( - &basket &newbasket + &getbasket &getbasketcontent &newbasket &closebasket - &getorders &getallorders &getrecorders - &getorder &neworder &delorder - &ordersearch - &modorder &getsingleorder &invoice &receiveorder - &updaterecorder &newordernum + &getorders &getallorders &getrecorders + &getorder &neworder &delorder + &ordersearch + &modorder &getsingleorder &invoice &receiveorder + &updaterecorder &newordernum - &bookfunds &bookfundbreakdown &updatecost - &curconvert &getcurrencies &updatecurrencies &getcurrency + &bookfunds &curconvert &getcurrencies &bookfundbreakdown + &updatecurrencies &getcurrency - &findall &needsmod &branches &updatesup &insertsup - &bookseller &breakdown &checkitems + &branches &updatesup &insertsup + &bookseller &breakdown ); # @@ -79,9 +71,24 @@ orders, converting money to different currencies, and so forth. # # # -=item basket +=item getbasket + + $aqbasket = &getbasket($basketnumber); - ($count, @orders) = &basket($basketnumber, $booksellerID); +get all basket informations in aqbasket for a given basket +=cut + +sub getbasket { + my ($basketno)=@_; + my $dbh=C4::Context->dbh; + my $sth=$dbh->prepare("select aqbasket.*,borrowers.firstname+' '+borrowers.surname as authorisedbyname from aqbasket left join borrowers on aqbasket.authorisedby=borrowers.borrowernumber where basketno=?"); + $sth->execute($basketno); + return($sth->fetchrow_hashref); +} + +=item getbasketcontent + + ($count, @orders) = &getbasketcontent($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 @@ -94,64 +101,65 @@ number of elements in C<@orders>. =cut #' -sub basket { - my ($basketno,$supplier)=@_; - my $dbh = C4::Context->dbh; - my $query="Select *,biblio.title from aqorders,biblio,biblioitems - where basketno='$basketno' - and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber - =aqorders.biblioitemnumber - and (datecancellationprinted is NULL or datecancellationprinted = - '0000-00-00')"; - if ($supplier ne ''){ - $query.=" and aqorders.booksellerid='$supplier'"; - } - $query.=" order by biblioitems.publishercode"; - my $sth=$dbh->prepare($query); - $sth->execute; - my @results; -# print $query; - my $i=0; - while (my $data=$sth->fetchrow_hashref){ - $results[$i]=$data; - $i++; - } - $sth->finish; - return($i,@results); +sub getbasketcontent { + my ($basketno,$supplier)=@_; + my $dbh = C4::Context->dbh; + my $query="Select *,biblio.title from aqorders,biblio,biblioitems + where basketno='$basketno' + and biblio.biblionumber=aqorders.biblionumber and biblioitems.biblioitemnumber + =aqorders.biblioitemnumber + and (datecancellationprinted is NULL or datecancellationprinted = + '0000-00-00')"; + if ($supplier ne ''){ + $query.=" and aqorders.booksellerid='$supplier'"; + } + $query.=" order by biblioitems.publishercode"; + my $sth=$dbh->prepare($query); + $sth->execute; + my @results; + # print $query; + my $i=0; + while (my $data=$sth->fetchrow_hashref){ + $results[$i]=$data; + $i++; + } + $sth->finish; + return($i,@results); } =item newbasket $basket = &newbasket(); -Finds the next unused basket number in the aqorders table of the Koha -database, and returns it. - +Create a new basket in aqbasket table =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