[Koha-cvs] koha/C4 Acquisition.pm

Antoine Farnault antoine at koha-fr.org
Tue Aug 1 10:26:53 CEST 2006


CVSROOT:	/sources/koha
Module name:	koha
Changes by:	Antoine Farnault <toins>	06/08/01 08:26:53

Modified files:
	C4             : Acquisition.pm 

Log message:
	* Function GetBasketContent renamed to GetOrders.
	* Function GetOrder renamed to GetOrderNumber.
	* Function GetSingleOrder renamed to GetOrder.
	* GetAllOrders has been merged with GetPendingOrders.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Acquisition.pm?cvsroot=koha&r1=1.41&r2=1.42

Patches:
Index: Acquisition.pm
===================================================================
RCS file: /sources/koha/koha/C4/Acquisition.pm,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -b -r1.41 -r1.42
--- Acquisition.pm	31 Jul 2006 14:38:14 -0000	1.41
+++ Acquisition.pm	1 Aug 2006 08:26:53 -0000	1.42
@@ -17,7 +17,7 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id: Acquisition.pm,v 1.41 2006/07/31 14:38:14 toins Exp $
+# $Id: Acquisition.pm,v 1.42 2006/08/01 08:26:53 toins Exp $
 
 use strict;
 require Exporter;
@@ -30,7 +30,7 @@
 use vars qw($VERSION @ISA @EXPORT);
 
 # set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.41 $' =~ /\d+/g; shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v ); };
+$VERSION = do { my @v = '$Revision: 1.42 $' =~ /\d+/g; shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v ); };
 
 # used in receiveorder subroutine
 # to provide library specific handling
@@ -57,11 +57,11 @@
 
 @ISA    = qw(Exporter);
 @EXPORT = qw(
-  &GetBasket &GetBasketContent &NewBasket &CloseBasket
-  &GetPendingOrders &GetAllOrders
-  &GetOrder &GetLateOrders &NewOrder &DelOrder
+  &GetBasket &NewBasket &CloseBasket
+  &GetPendingOrders &GetOrder &GetOrders
+  &GetOrderNumber &GetLateOrders &NewOrder &DelOrder
   &SearchOrder &GetHistory
-  &ModOrder &GetSingleOrder &ModReceiveOrder
+  &ModOrder &ModReceiveOrder
   &GetParcels &GetParcel
 );
 
@@ -108,59 +108,6 @@
 
 #------------------------------------------------------------#
 
-=head3 GetBasketContent
-
-=over 4
-
- at orders = &GetBasketContent($basketnumber, $orderby);
-
-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.
-
-return :
-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.
-
-=back
-
-=cut
-
-sub GetBasketContent {
-    my ( $basketno, $orderby ) = @_;
-    my $dbh   = C4::Context->dbh;
-    my $query ="
-        SELECT  aqorderbreakdown.*,
-                biblio.*,biblioitems.*,
-                aqorders.*,
-                biblio.title
-        FROM    aqorders,biblio,biblioitems
-        LEFT JOIN aqorderbreakdown ON
-                    aqorders.ordernumber=aqorderbreakdown.ordernumber
-        WHERE   basketno=?
-            AND biblio.biblionumber=aqorders.biblionumber
-            AND biblioitems.biblioitemnumber=aqorders.biblioitemnumber
-            AND (datecancellationprinted IS NULL OR datecancellationprinted='0000-00-00')
-    ";
-
-    $orderby = "biblioitems.publishercode" unless $orderby;
-    $query .= " ORDER BY $orderby";
-    my $sth = $dbh->prepare($query);
-    $sth->execute($basketno);
-    my @results;
-
-    my $i=0;
-    #  print $query;
-    while ( my $data = $sth->fetchrow_hashref ) {
-        $results[$i++] = $data;
-    }
-    $sth->finish;
-    return @results;
-}
-
-#------------------------------------------------------------#
-
 =head3 NewBasket
 
 =over 4
@@ -296,26 +243,74 @@
 
 #------------------------------------------------------------#
 
-=head3 GetOrder
+=head3 GetOrders
 
 =over 4
 
-($order, $ordernumber) = &GetOrder($biblioitemnumber, $biblionumber);
+ at orders = &GetOrders($basketnumber, $orderby);
 
-Looks up the order with the given biblionumber and biblioitemnumber.
+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.
 
-Returns a two-element array.
+return :
+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.
 
-=item C<$ordernumber> is the order number.
+=back
 
-=item C<$order> is a reference-to-hash describing the order;
-its keys are fields from the biblio, biblioitems, aqorders, and aqorderbreakdown
-tables of the Koha database.
+=cut
+
+sub GetOrders {
+    my ( $basketno, $orderby ) = @_;
+    my $dbh   = C4::Context->dbh;
+    my $query ="
+        SELECT  aqorderbreakdown.*,
+                biblio.*,biblioitems.*,
+                aqorders.*,
+                biblio.title
+        FROM    aqorders,biblio,biblioitems
+        LEFT JOIN aqorderbreakdown ON
+                    aqorders.ordernumber=aqorderbreakdown.ordernumber
+        WHERE   basketno=?
+            AND biblio.biblionumber=aqorders.biblionumber
+            AND biblioitems.biblioitemnumber=aqorders.biblioitemnumber
+            AND (datecancellationprinted IS NULL OR datecancellationprinted='0000-00-00')
+    ";
+
+    $orderby = "biblioitems.publishercode" unless $orderby;
+    $query .= " ORDER BY $orderby";
+    my $sth = $dbh->prepare($query);
+    $sth->execute($basketno);
+    my @results;
+
+    #  print $query;
+    while ( my $data = $sth->fetchrow_hashref ) {
+        push @results, $data;
+    }
+    $sth->finish;
+    return @results;
+}
+
+#------------------------------------------------------------#
+
+=head3 GetOrderNumber
+
+=over 4
+
+$ordernumber = &GetOrderNumber($biblioitemnumber, $biblionumber);
+
+Looks up the ordernumber with the given biblionumber and biblioitemnumber.
+
+Returns the number of this order.
+
+=item C<$ordernumber> is the order number.
 
 =back
 
 =cut
-sub GetOrder {
+sub GetOrderNumber {
     my ( $biblionumber,$biblioitemnumber ) = @_;
     my $dbh = C4::Context->dbh;
     my $query = "
@@ -327,21 +322,16 @@
     my $sth = $dbh->prepare($query);
     $sth->execute( $biblionumber, $biblioitemnumber );
 
-    # FIXME - Use fetchrow_array(), since we're only interested in the one
-    # value.
-    my $ordnum = $sth->fetchrow_hashref;
-    $sth->finish;
-    my $order = GetSingleOrder( $ordnum->{'ordernumber'} );
-    return ( $order, $ordnum->{'ordernumber'} );
+    return $sth->fetchrow;
 }
 
 #------------------------------------------------------------#
 
-=head3 GetSingleOrder
+=head3 GetOrder
 
 =over 4
 
-$order = &GetSingleOrder($ordernumber);
+$order = &GetOrder($ordernumber);
 
 Looks up an order by order number.
 
@@ -353,7 +343,7 @@
 
 =cut
 
-sub GetSingleOrder {
+sub GetOrder {
     my ($ordnum) = @_;
     my $dbh      = C4::Context->dbh;
     my $query = "
@@ -373,62 +363,6 @@
 
 #------------------------------------------------------------#
 
-=head3 GetAllOrders
-
-=over 4
-
- at results = &GetAllOrders($booksellerid);
-
-Looks up all of the pending orders from the supplier with the given
-bookseller ID. Ignores cancelled and completed orders.
-
-C<@results> is an array of references-to-hash. The keys of each element are fields from
-the aqorders, biblio, and biblioitems tables of the Koha database.
-
-C<@results> is sorted alphabetically by book title.
-
-=back
-
-=cut
-
-sub GetAllOrders {
-
-    #gets all orders from a certain supplier, orders them alphabetically
-    my ($supplierid) = @_;
-    my $dbh          = C4::Context->dbh;
-    my @results      = ();
-    my $strsth = "
-        SELECT  count(*),authorisedby,creationdate,aqbasket.basketno,
-                closedate,surname,firstname,aqorders.biblionumber,aqorders.title, aqorders.ordernumber 
-        FROM    aqorders
-        LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno
-        LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber
-        WHERE   booksellerid=?
-            AND (quantity > quantityreceived OR quantityreceived IS NULL)
-            AND datecancellationprinted IS NULL
-    ";
-
-    if ( C4::Context->preference("IndependantBranches") ) {
-        my $userenv = C4::Context->userenv;
-        if ( ($userenv) && ( $userenv->{flags} != 1 ) ) {
-            $strsth .=
-                " and (borrowers.branchcode = '"
-              . $userenv->{branch}
-              . "' or borrowers.branchcode ='')";
-        }
-    }
-    $strsth .= " group by basketno order by aqbasket.basketno";
-    my $sth = $dbh->prepare($strsth);
-    $sth->execute($supplierid);
-    while ( my $data = $sth->fetchrow_hashref ) {
-        push( @results, $data );
-    }
-    $sth->finish;
-    return @results;
-}
-
-#------------------------------------------------------------#
-
 =head3 NewOrder
 
 =over 4





More information about the Koha-cvs mailing list