Bug 10483: fix item uniqueness check on order form
[koha.git] / acqui / basket.pl
index 7163bf4..06d4d1a 100755 (executable)
@@ -103,7 +103,7 @@ if ( $op eq 'delete_confirm' ) {
     $template->param( NO_BOOKSELLER => 1 );
 } elsif ( $op eq 'del_basket') {
     $template->param( delete_confirm => 1 );
-    if ( C4::Context->preference("IndependantBranches") ) {
+    if ( C4::Context->preference("IndependentBranches") ) {
         my $userenv = C4::Context->userenv;
         unless ( $userenv->{flags} == 1 ) {
             my $validtest = ( $basket->{creationdate} eq '' )
@@ -192,7 +192,7 @@ if ( $op eq 'delete_confirm' ) {
     print $query->redirect('/cgi-bin/koha/acqui/basket.pl?basketno='.$basket->{'basketno'})
 } else {
     # get librarian branch...
-    if ( C4::Context->preference("IndependantBranches") ) {
+    if ( C4::Context->preference("IndependentBranches") ) {
         my $userenv = C4::Context->userenv;
         unless ( $userenv->{flags} == 1 ) {
             my $validtest = ( $basket->{creationdate} eq '' )
@@ -206,13 +206,14 @@ if ( $op eq 'delete_confirm' ) {
         }
     }
 #if the basket is closed,and the user has the permission to edit basketgroups, display a list of basketgroups
-    my $basketgroups;
-    my $member = GetMember(borrowernumber => $loggedinuser);
-    if ($basket->{closedate} && haspermission({ acquisition => 'group_manage'} )) {
+    my ($basketgroup, $basketgroups);
+    my $staffuser = GetMember(borrowernumber => $loggedinuser);
+    if ($basket->{closedate} && haspermission($staffuser->{userid}, { acquisition => 'group_manage'} )) {
         $basketgroups = GetBasketgroups($basket->{booksellerid});
         for my $bg ( @{$basketgroups} ) {
             if ($basket->{basketgroupid} && $basket->{basketgroupid} == $bg->{id}){
                 $bg->{default} = 1;
+                $basketgroup = $bg;
             }
         }
         my %emptygroup = ( id   =>   undef,
@@ -286,13 +287,9 @@ if ( $op eq 'delete_confirm' ) {
     my @orders = GetOrders($basketno);
 
     if ($basket->{basketgroupid}){
-        my $basketgroup = GetBasketgroup($basket->{basketgroupid});
-        for my $key (keys %$basketgroup ){
-            $basketgroup->{"basketgroup$key"} = delete $basketgroup->{$key};
-        }
-        $basketgroup->{basketgroupdeliveryplace} = C4::Branch::GetBranchName( $basketgroup->{basketgroupdeliveryplace} );
-        $basketgroup->{basketgroupbillingplace} = C4::Branch::GetBranchName( $basketgroup->{basketgroupbillingplace} );
-        $template->param(%$basketgroup);
+        $basketgroup = GetBasketgroup($basket->{basketgroupid});
+        $basketgroup->{deliveryplacename} = C4::Branch::GetBranchName( $basketgroup->{deliveryplace} );
+        $basketgroup->{billingplacename} = C4::Branch::GetBranchName( $basketgroup->{billingplace} );
     }
     my $borrower= GetMember('borrowernumber' => $loggedinuser);
     my $budgets = GetBudgetHierarchy;
@@ -339,6 +336,7 @@ if ( $op eq 'delete_confirm' ) {
         currency             => $cur->{'currency'},
         listincgst           => $bookseller->{listincgst},
         basketgroups         => $basketgroups,
+        basketgroup          => $basketgroup,
         grouped              => $basket->{basketgroupid},
         unclosable           => @orders ? 0 : 1, 
         has_budgets          => $has_budgets,