updated links in README
[koha_fer] / C4 / Acquisition.pm
index 2b60f39..4616d69 100644 (file)
@@ -13,9 +13,9 @@ package C4::Acquisition;
 # 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
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 
 use strict;
@@ -166,16 +166,20 @@ sub GetBasket {
 
 $basket = &NewBasket( $booksellerid, $authorizedby, $basketname, $basketnote, $basketbooksellernote, $basketcontractnumber );
 
+=back
+
 Create a new basket in aqbasket table
 
+=over 2
+
 =item C<$booksellerid> is a foreign key in the aqbasket table
 
 =item C<$authorizedby> is the username of who created the basket
 
-The other parameters are optional, see ModBasketHeader for more info on them.
-
 =back
 
+The other parameters are optional, see ModBasketHeader for more info on them.
+
 =cut
 
 # FIXME : this function seems to be unused.
@@ -658,13 +662,13 @@ sub ModBasketgroup {
 
 DelBasketgroup($basketgroupid);
 
-=over 2
+=back
 
 Deletes a basketgroup in the aqbasketgroups table, and removes the reference to it from the baskets,
 
-=item C<$basketgroupid> is the 'id' field of the basket in the aqbasketgroup table
+=over 2
 
-=back
+=item C<$basketgroupid> is the 'id' field of the basket in the aqbasketgroup table
 
 =back
 
@@ -682,7 +686,6 @@ sub DelBasketgroup {
 
 #------------------------------------------------------------#
 
-=back
 
 =head2 FUNCTIONS ABOUT ORDERS
 
@@ -690,6 +693,8 @@ sub DelBasketgroup {
 
 =cut
 
+=back
+
 =head3 GetBasketgroup
 
 =over 4
@@ -750,12 +755,8 @@ sub GetBasketgroups {
 
 #------------------------------------------------------------#
 
-=back
-
 =head2 FUNCTIONS ABOUT ORDERS
 
-=over 2
-
 =cut
 
 #------------------------------------------------------------#
@@ -1008,12 +1009,15 @@ sub NewOrder {
         die "Mandatory parameter $key missing" unless $orderinfo->{$key};
     }
 
-    if ( $orderinfo->{'subscription'} eq 'yes' ) {
+    if ( defined $orderinfo->{subscription} && $orderinfo->{'subscription'} eq 'yes' ) {
         $orderinfo->{'subscription'} = 1;
     } else {
         $orderinfo->{'subscription'} = 0;
     }
     $orderinfo->{'entrydate'} ||= C4::Dates->new()->output("iso");
+    if (!$orderinfo->{quantityreceived}) {
+        $orderinfo->{quantityreceived} = 0;
+    }
 
     my $ordernumber=InsertInTable("aqorders",$orderinfo);
     return ( $orderinfo->{'basketno'}, $ordernumber );
@@ -1668,7 +1672,11 @@ sub GetHistory {
                 biblio.title,
                 biblio.author,
                 aqorders.basketno,
-                name,aqbasket.creationdate,
+               aqbasket.basketname,
+               aqbasket.basketgroupid,
+               aqbasketgroups.name as groupname,
+                aqbooksellers.name,
+               aqbasket.creationdate,
                 aqorders.datereceived,
                 aqorders.quantity,
                 aqorders.quantityreceived,
@@ -1679,12 +1687,13 @@ sub GetHistory {
                 aqorders.biblionumber
             FROM aqorders
             LEFT JOIN aqbasket ON aqorders.basketno=aqbasket.basketno
+           LEFT JOIN aqbasketgroups ON aqbasket.basketgroupid=aqbasketgroups.id
             LEFT JOIN aqbooksellers ON aqbasket.booksellerid=aqbooksellers.id
             LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber";
 
         $query .= " LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber"
         if ( C4::Context->preference("IndependantBranches") );
-
+       
         $query .= " WHERE (datecancellationprinted is NULL or datecancellationprinted='0000-00-00') ";
 
         my @query_params  = ();
@@ -1700,7 +1709,7 @@ sub GetHistory {
         }
 
         if ( defined $name ) {
-            $query .= " AND name LIKE ? ";
+            $query .= " AND aqbooksellers.name LIKE ? ";
             push @query_params, "%$name%";
         }
 
@@ -1721,7 +1730,8 @@ sub GetHistory {
                 push @query_params, $userenv->{branch};
             }
         }
-        $query .= " ORDER BY booksellerid";
+        $query .= " ORDER BY id";
+       warn $query;
         my $sth = $dbh->prepare($query);
         $sth->execute( @query_params );
         my $cnt = 1;
@@ -1768,10 +1778,14 @@ sub GetRecentAcqui {
 
 $contractlist = &GetContracts($booksellerid, $activeonly);
 
+=back
+
 Looks up the contracts that belong to a bookseller
 
 Returns a list of contracts
 
+=over 2
+
 =item C<$booksellerid> is the "id" field in the "aqbooksellers" table.
 
 =item C<$activeonly> if exists get only contracts that are still active.