Bug 19256: Make Koha::Acq::Order using Koha::Object
[koha.git] / acqui / basketheader.pl
index 18090c4..45e11e5 100755 (executable)
@@ -50,12 +50,11 @@ use warnings;
 use CGI qw ( -utf8 );
 use C4::Context;
 use C4::Auth;
-use C4::Branch;
 use C4::Output;
 use C4::Acquisition qw/GetBasket NewBasket ModBasketHeader/;
 use C4::Contract qw/GetContracts/;
 
-use Koha::Acquisition::Bookseller;
+use Koha::Acquisition::Booksellers;
 
 my $input = new CGI;
 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
@@ -72,7 +71,6 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
 #parameters:
 my $booksellerid = $input->param('booksellerid');
 my $basketno = $input->param('basketno');
-my $branches = GetBranches;
 my $basket;
 my $op = $input ->param('op');
 my $is_an_edit= $input ->param('is_an_edit');
@@ -106,35 +104,32 @@ if ( $op eq 'add_form' ) {
         });
         push(@contractloop, @$contracts);
     }
-    my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
+    my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
     my $count = scalar @contractloop;
     if ( $count > 0) {
         $template->param(contractloop => \@contractloop,
                          basketcontractnumber => $basket->{'contractnumber'});
     }
-    my @booksellers = Koha::Acquisition::Bookseller->search;
+    my @booksellers = Koha::Acquisition::Booksellers->search(
+                        undef,
+                        { order_by => { -asc => 'name' } } );
+
     $template->param( add_form => 1,
                     basketname => $basket->{'basketname'},
                     basketnote => $basket->{'note'},
                     basketbooksellernote => $basket->{'booksellernote'},
-                    booksellername => $bookseller->{'name'},
+                    booksellername => $bookseller->name,
                     booksellerid => $booksellerid,
                     basketno => $basketno,
                     booksellers => \@booksellers,
-                    deliveryplace => $basket->{deliveryplace},
-                    billingplace => $basket->{billingplace},
+                    is_standing => $basket->{is_standing},
     );
 
     my $billingplace = $basket->{'billingplace'} || C4::Context->userenv->{"branch"};
     my $deliveryplace = $basket->{'deliveryplace'} || C4::Context->userenv->{"branch"};
 
-    # Build the combobox to select the billing place
-    my @billingplaceloop;
-
-    my $branches = C4::Branch::GetBranchesLoop( $billingplace );
-    $template->param( billingplaceloop => $branches );
-    $branches = C4::Branch::GetBranchesLoop( $deliveryplace );
-    $template->param( deliveryplaceloop => $branches );
+    $template->param( billingplace => $billingplace );
+    $template->param( deliveryplace => $deliveryplace );
 
 #End Edit
 } elsif ( $op eq 'add_validate' ) {
@@ -149,6 +144,7 @@ if ( $op eq 'add_form' ) {
             $input->param('basketbooksellerid'),
             $input->param('deliveryplace'),
             $input->param('billingplace'),
+            $input->param('is_standing') ? 1 : undef,
         );
     } else { #New basket
         $basketno = NewBasket(
@@ -160,6 +156,7 @@ if ( $op eq 'add_form' ) {
             $input->param('basketcontractnumber') || undef,
             $input->param('deliveryplace'),
             $input->param('billingplace'),
+            $input->param('is_standing') ? 1 : undef,
         );
     }
     print $input->redirect('basket.pl?basketno='.$basketno);