Remove Stopwords bug fixing
[koha.git] / acqui / neworderempty.pl
index c9cfc07..ac4a934 100755 (executable)
@@ -94,7 +94,6 @@ my $suggestionid = $input->param('suggestionid');
 my $close        = $input->param('close');
 my $data;
 my $new;
-my $dbh = C4::Context->dbh;
 
 if ( $ordnum eq '' ) {    # create order
     $new = 'yes';
@@ -146,7 +145,7 @@ for ( my $i = 0 ; $i < $count ; $i++ ) {
 my $itemtypes = GetItemTypes;
 
 my @itemtypesloop;
-foreach my $thisitemtype (sort keys %$itemtypes) {
+foreach my $thisitemtype (sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'}} keys %$itemtypes) {
     push @itemtypesloop, { itemtype => $itemtypes->{$thisitemtype}->{'itemtype'} , desc =>  $itemtypes->{$thisitemtype}->{'description'} } ;
 }
 
@@ -157,11 +156,12 @@ my $onlymine=C4::Context->preference('IndependantBranches') &&
              C4::Context->userenv->{branch};
 my $branches = GetBranches($onlymine);
 my @branchloop;
-foreach my $thisbranch ( sort keys %$branches ) {
+foreach my $thisbranch ( sort {$branches->{$a}->{'branchname'} cmp $branches->{$b}->{'branchname'}} keys %$branches ) {
      my %row = (
         value      => $thisbranch,
         branchname => $branches->{$thisbranch}->{'branchname'},
     );
+       $row{'selected'} = 1 if( $thisbranch eq $data->{branchcode}) ;
     push @branchloop, \%row;
 }
 $template->param( branchloop => \@branchloop , itypeloop => \@itemtypesloop );
@@ -185,10 +185,9 @@ my $CGIbookfund = CGI::scrolling_list(
     -name     => 'bookfund',
        -id       => 'bookfund',
     -values   => \@select_bookfund,
-    -default  => $data->{'bookfundid'},
+    -default  => ($data->{'bookfundid'} ? $data->{'bookfundid'} : $select_bookfund[0]),
     -labels   => \%select_bookfunds,
        #-size     => 1,
-       -tabindex =>'',
     -multiple => 0
 );
 
@@ -262,7 +261,7 @@ $template->param(
     nocalc           => $bookseller->{'nocalc'},
     name             => $bookseller->{'name'},
     currency         => $bookseller->{'listprice'},
-    gstrate          => C4::Context->preference("gist"),
+    gstrate          => C4::Context->preference("gist") || 0,
     loop_currencies  => \@loop_currency,
     orderexists      => ( $new eq 'yes' ) ? 0 : 1,
     title            => $data->{'title'},