(bug #3348) another order receive fix
[koha.git] / acqui / orderreceive.pl
index c13eda3..6d33e7e 100755 (executable)
@@ -81,11 +81,11 @@ my $datereceived = C4::Dates->new($input->param('datereceived'),'iso') || C4::Da
 my $catview      = $input->param('catview');
 my $gst          = $input->param('gst');
 
-my @results = SearchOrder( $search, $supplierid, $biblionumber, $catview );
+my @results = SearchOrder( $search, $supplierid, $biblionumber);
 my $count   = scalar @results;
 my $order      = GetOrder($search);
 
-my $bookseller = GetBookSellerFromId( $results[0]->{'booksellerid'} );
+my $bookseller = GetBookSellerFromId( $supplierid );
 
 my $date = $results[0]->{'entrydate'};
 
@@ -104,7 +104,7 @@ if ( $count == 1 ) {
 
     my (@itemtypesloop,@locationloop,@ccodeloop);
     my $itemtypes = GetItemTypes;
-    foreach my $thisitemtype (sort keys %$itemtypes) {
+    foreach my $thisitemtype (sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'}} keys %$itemtypes) {
         push @itemtypesloop, {
                   value => $thisitemtype,
             description => $itemtypes->{$thisitemtype}->{'description'},
@@ -112,14 +112,14 @@ if ( $count == 1 ) {
         };
     }
     my $locs = GetKohaAuthorisedValues( 'items.location' );
-    foreach my $thisloc (sort keys %$locs) {
+    foreach my $thisloc (sort {$locs->{$a} cmp $locs->{$b}} keys %$locs) {
            push @locationloop, {
                   value => $thisloc,
             description => $locs->{$thisloc},
         };
     }
     my $ccodes = GetKohaAuthorisedValues( 'items.ccode' );
-       foreach my $thisccode (sort keys %$ccodes) {
+       foreach my $thisccode (sort {$ccodes->{$a} cmp $ccodes->{$b}} keys %$ccodes) {
         push @ccodeloop, {
                   value => $thisccode,
             description => $ccodes->{$thisccode},
@@ -197,6 +197,7 @@ $template->param(
     name             => $bookseller->{'name'},
     freight          => $freight,
     gst              => $gst,
+    previousurl      => $input->referer(),
 );
 
 output_html_with_http_headers $input, $cookie, $template->output;