Bug 5549 : move rollingloans.t to db_dependent tests
[koha.git] / acqui / booksellers.pl
index 634eb93..ac3c557 100755 (executable)
@@ -41,7 +41,7 @@ C<$supplier> is the string with which we search for a supplier
 
 =back
 
-=item id or supplierid
+=item id or booksellerid
 
 The id of the supplier whose baskets we will display
 
@@ -74,11 +74,11 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
 
 #parameters
 my $supplier = $query->param('supplier');
-my $id = $query->param('id') || $query->param('supplierid');
+my $booksellerid = $query->param('booksellerid');
 my @suppliers;
 
-if ($id) {
-    push @suppliers, GetBookSellerFromId($id);
+if ($booksellerid) {
+    push @suppliers, GetBookSellerFromId($booksellerid);
 } else {
     @suppliers = GetBookSeller($supplier);
 }
@@ -87,7 +87,7 @@ my $supplier_count = @suppliers;
 if ( $supplier_count == 1 ) {
     $template->param(
         supplier_name => $suppliers[0]->{'name'},
-        id            => $suppliers[0]->{'id'}
+        booksellerid  => $suppliers[0]->{'booksellerid'}
     );
 }
 
@@ -111,16 +111,11 @@ for my $vendor (@suppliers) {
     
     for my $basket ( @{$baskets} ) {
         my $authorisedby = $basket->{authorisedby};
-        my $basketbranch = ''; # set a blank branch to start with
-        if ( GetMember( borrowernumber => $authorisedby ) ) {
-           # authorisedby may not be a valid borrowernumber; it's not foreign-key constrained!
-           $basketbranch = GetMember( borrowernumber => $authorisedby )->{branchcode};
-        }
         
         if ($userenv->{'flags'} & 1 || #user is superlibrarian
                (haspermission( $uid, { acquisition => q{*} } ) && #user has acq permissions and
                    ($viewbaskets eq 'all' || #user is allowed to see all baskets
-                   ($viewbaskets eq 'branch' && $authorisedby && $userbranch eq $basketbranch) || #basket belongs to user's branch
+                   ($viewbaskets eq 'branch' && $authorisedby && $userbranch eq GetMember( borrowernumber => $authorisedby )->{branchcode}) || #basket belongs to user's branch
                    ($basket->{authorisedby} &&  $viewbaskets == 'user' && $authorisedby == $loggedinuser) #user created this basket
                    ) 
                 ) 
@@ -136,7 +131,7 @@ for my $vendor (@suppliers) {
 
     push @{$loop_suppliers},
       { loop_basket => $loop_basket,
-        supplierid  => $vendor->{id},
+        booksellerid  => $vendor->{id},
         name        => $vendor->{name},
         active      => $vendor->{active},
       };
@@ -144,7 +139,7 @@ for my $vendor (@suppliers) {
 }
 $template->param(
     loop_suppliers => $loop_suppliers,
-    supplier       => ( $id || $supplier ),
+    supplier       => ( $booksellerid || $supplier ),
     count          => $supplier_count,
 );